1atomic_cas(9F)           Kernel Functions for Drivers           atomic_cas(9F)
2
3
4

NAME

6       atomic_cas,      atomic_cas_8,     atomic_cas_uchar,     atomic_cas_16,
7       atomic_cas_ushort,  atomic_cas_32,  atomic_cas_uint,  atomic_cas_ulong,
8       atomic_cas_64, atomic_cas_ptr - atomic compare and swap operations
9

SYNOPSIS

11       #include <sys/atomic.h>
12
13       uint8_t atomic_cas_8(volatile uint8_t *target, uint8_t cmp, uint8_t
14            newval);
15
16
17       uchar_t atomic_cas_uchar(volatile uchar_t *target, uchar_t cmp, uchar_t
18            newval);
19
20
21       uint16_t atomic_cas_16(volatile uint16_t *target, uint16_t cmp, uint16_t
22            newval);
23
24
25       ushort_t atomic_cas_ushort(volatile ushort_t *target, ushort_t cmp,
26            ushort_t newval);
27
28
29       uint32_t atomic_cas_32(volatile uint32_t *target, uint32_t cmp, uint32_t
30            newval);
31
32
33       uint_t atomic_cas_uint(volatile uint_t *target, uint_t cmp, uint_t newval);
34
35
36       ulong_t atomic_cas_ulong(volatile ulong_t *target, ulong_t cmp, ulong_t
37            newval);
38
39
40       uint64_t atomic_cas_64(volatile uint64_t *target, uint64_t cmp, uint64_t
41            newval);
42
43
44       void *atomic_cas_ptr(volatile void *target, void *cmp, void *newval);
45
46

DESCRIPTION

48       These  functions  enable  a  compare and swap operation to occur atomi‐
49       cally. The value stored in target is compared with cmp. If these values
50       are  equal, the value stored in target is replaced with newval. The old
51       value stored in target is returned by the function whether or  not  the
52       replacement occurred.
53

RETURN VALUES

55       These functions return the old of *target.
56

ERRORS

58       No errors are defined.
59

CONTEXT

61       These functions can be called from user, interrupt, or kernel context.
62

ATTRIBUTES

64       See attributes(5) for descriptions of the following attributes:
65
66
67
68
69       ┌─────────────────────────────┬─────────────────────────────┐
70       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
71       ├─────────────────────────────┼─────────────────────────────┤
72       │Interface Stability          │Committed                    │
73       └─────────────────────────────┴─────────────────────────────┘
74

SEE ALSO

76       atomic_add(9F),    atomic_and(9F),   atomic_bits(9F),   atomic_dec(9F),
77       atomic_inc(9F),   atomic_or(9F),    atomic_swap(9F),    membar_ops(9F),
78       attributes(5), atomic_ops(3C)
79
80
81
82SunOS 5.11                        16 Jan 2006                   atomic_cas(9F)
Impressum