5# include <click/glue.hh>
9# if HAVE_LINUX_ASM_SYSTEM_H
10# include <click/cxxprotect.h>
12# include <asm/system.h>
14# include <click/cxxunprotect.h>
16# define CLICK_ATOMIC_VAL _val.counter
18# define CLICK_ATOMIC_VAL _val
20#if defined(__i386__) || defined(__arch_um__) || defined(__x86_64__)
21# if CLICK_LINUXMODULE || HAVE_MULTITHREAD
22# define CLICK_ATOMIC_X86 1
24# if (CLICK_LINUXMODULE && defined(CONFIG_SMP)) || HAVE_MULTITHREAD
25# define CLICK_ATOMIC_LOCK "lock ; "
27# define CLICK_ATOMIC_LOCK
32#if HAVE_MULTITHREAD && HAVE_ATOMIC_BUILTINS
34 # define CLICK_ATOMIC_BUILTINS 1
35 # define CLICK_ATOMIC_MEMORDER __ATOMIC_SEQ_CST
37 # define CLICK_BUILTINS_DEPRECATED = delete
38 # define CLICK_BUILTINS_NONDEPRECATED
39 # define CLICK_ATOMIC_COMPARE_SWAP 0
41 # define CLICK_ATOMIC_BUILTINS 0
45 # define CLICK_BUILTINS_DEPRECATED
46 # define CLICK_BUILTINS_NONDEPRECATED CLICK_DEPRECATED
47 # define CLICK_ATOMIC_COMPARE_SWAP 1
76 inline uint32_t
value()
const;
78 inline operator uint32_t()
const;
94 inline uint32_t
swap(uint32_t desired);
98 inline uint32_t compare_swap(uint32_t expected, uint32_t desired) CLICK_BUILTINS_DEPRECATED;
99 inline bool compare_and_swap(uint32_t expected, uint32_t desired) CLICK_BUILTINS_NONDEPRECATED;
101 inline static uint32_t
swap(
volatile uint32_t &x, uint32_t desired);
102 inline static void inc(
volatile uint32_t &x);
104 inline static uint32_t compare_swap(
volatile uint32_t &x, uint32_t expected, uint32_t desired) CLICK_BUILTINS_DEPRECATED;
105 inline static bool compare_and_swap(
volatile uint32_t &x, uint32_t expected, uint32_t desired) CLICK_BUILTINS_NONDEPRECATED;
107 inline static bool use_builtins(){
return CLICK_ATOMIC_BUILTINS;}
112#elif HAVE_MULTITHREAD
113 volatile uint32_t _val;
142 inline uint64_t
value()
const;
144 inline operator uint64_t()
const;
158 inline uint64_t compare_swap(uint64_t expected, uint64_t desired) CLICK_BUILTINS_DEPRECATED;
161 inline static void add(
volatile uint64_t &x, uint64_t delta);
162 inline static uint64_t compare_swap(
volatile uint64_t &x, uint64_t expected, uint64_t desired) CLICK_BUILTINS_DEPRECATED;
164 inline static bool use_builtins(){
return CLICK_ATOMIC_BUILTINS;}
169#elif HAVE_MULTITHREAD
170 volatile uint64_t _val __attribute__((aligned));
182 return atomic_read(&_val);
184 return CLICK_ATOMIC_VAL;
192 return *((uint32_t*)&_val);
197atomic_uint32_t::operator uint32_t()
const
207 atomic_set(&_val, x);
209 CLICK_ATOMIC_VAL = x;
219 atomic_add(delta, &_val);
220#elif CLICK_ATOMIC_BUILTINS
221 __atomic_add_fetch(&CLICK_ATOMIC_VAL, delta, CLICK_ATOMIC_MEMORDER);
222#elif CLICK_ATOMIC_X86
223 asm volatile (CLICK_ATOMIC_LOCK
"addl %1,%0"
224 :
"=m" (CLICK_ATOMIC_VAL)
225 :
"r" (delta),
"m" (CLICK_ATOMIC_VAL)
228 CLICK_ATOMIC_VAL += delta;
238 atomic_sub(delta, &_val);
239#elif CLICK_ATOMIC_BUILTINS
240 __atomic_sub_fetch(&CLICK_ATOMIC_VAL, delta, CLICK_ATOMIC_MEMORDER);
241#elif CLICK_ATOMIC_X86
242 asm volatile (CLICK_ATOMIC_LOCK
"subl %1,%0"
243 :
"=m" (CLICK_ATOMIC_VAL)
244 :
"r" (delta),
"m" (CLICK_ATOMIC_VAL)
247 CLICK_ATOMIC_VAL -= delta;
256#if CLICK_LINUXMODULE && HAVE_LINUX_ATOMIC_SET_MASK
257 atomic_set_mask(mask, &_val);
258#elif CLICK_ATOMIC_BUILTINS
259 __atomic_or_fetch(&CLICK_ATOMIC_VAL, mask, CLICK_ATOMIC_MEMORDER);
260#elif CLICK_ATOMIC_X86
261 asm volatile (CLICK_ATOMIC_LOCK
"orl %1,%0"
262 :
"=m" (CLICK_ATOMIC_VAL)
263 :
"r" (mask),
"m" (CLICK_ATOMIC_VAL)
265#elif CLICK_LINUXMODULE
266# warning "using nonatomic approximation for atomic_uint32_t::operator|="
268 local_irq_save(flags);
269 CLICK_ATOMIC_VAL |= mask;
270 local_irq_restore(flags);
272 CLICK_ATOMIC_VAL |= mask;
281#if CLICK_LINUXMODULE && HAVE_LINUX_ATOMIC_SET_MASK
282 atomic_clear_mask(~mask, &_val);
283#elif CLICK_ATOMIC_BUILTINS
284 __atomic_and_fetch(&CLICK_ATOMIC_VAL, mask, CLICK_ATOMIC_MEMORDER);
285#elif CLICK_ATOMIC_X86
286 asm volatile (CLICK_ATOMIC_LOCK
"andl %1,%0"
287 :
"=m" (CLICK_ATOMIC_VAL)
288 :
"r" (mask),
"m" (CLICK_ATOMIC_VAL)
290#elif CLICK_LINUXMODULE
291# warning "using nonatomic approximation for atomic_uint32_t::operator&="
293 local_irq_save(flags);
294 CLICK_ATOMIC_VAL &= mask;
295 local_irq_restore(flags);
297 CLICK_ATOMIC_VAL &= mask;
307 static_assert(
sizeof(atomic_t) ==
sizeof(x),
"atomic_t expected to take 32 bits.");
308 atomic_inc((atomic_t *) &x);
309#elif CLICK_ATOMIC_BUILTINS
310 __atomic_add_fetch(&x, 1, CLICK_ATOMIC_MEMORDER);
311#elif CLICK_ATOMIC_X86
312 asm volatile (CLICK_ATOMIC_LOCK
"incl %0"
334#elif CLICK_ATOMIC_BUILTINS
335 __atomic_add_fetch(&_val, 1, CLICK_ATOMIC_MEMORDER);
336#elif CLICK_ATOMIC_X86
337 asm volatile (CLICK_ATOMIC_LOCK
"incl %0"
338 :
"=m" (CLICK_ATOMIC_VAL)
339 :
"m" (CLICK_ATOMIC_VAL)
352#elif CLICK_ATOMIC_BUILTINS
353 __atomic_add_fetch(&CLICK_ATOMIC_VAL, 1, CLICK_ATOMIC_MEMORDER);
354#elif CLICK_ATOMIC_X86
355 asm volatile (CLICK_ATOMIC_LOCK
"incl %0"
356 :
"=m" (CLICK_ATOMIC_VAL)
357 :
"m" (CLICK_ATOMIC_VAL)
370#elif CLICK_ATOMIC_BUILTINS
371 __atomic_sub_fetch(&CLICK_ATOMIC_VAL, 1, CLICK_ATOMIC_MEMORDER);
372#elif CLICK_ATOMIC_X86
373 asm volatile (CLICK_ATOMIC_LOCK
"decl %0"
374 :
"=m" (CLICK_ATOMIC_VAL)
375 :
"m" (CLICK_ATOMIC_VAL)
395#elif CLICK_ATOMIC_BUILTINS
396 __atomic_sub_fetch(&CLICK_ATOMIC_VAL, 1, CLICK_ATOMIC_MEMORDER);
397#elif CLICK_ATOMIC_X86
398 asm volatile (CLICK_ATOMIC_LOCK
"decl %0"
399 :
"=m" (CLICK_ATOMIC_VAL)
400 :
"m" (CLICK_ATOMIC_VAL)
420#if CLICK_ATOMIC_BUILTINS
422 __atomic_exchange(&x, &desired, &actual, CLICK_ATOMIC_MEMORDER);
425#elif CLICK_ATOMIC_X86
426 asm volatile (
"xchgl %0,%1"
427 :
"=r" (desired),
"=m" (x)
428 :
"0" (desired),
"m" (x)
431#elif CLICK_LINUXMODULE && defined(xchg)
432 return xchg(&x, desired);
433#elif CLICK_LINUXMODULE
434# error "need xchg for atomic_uint32_t::swap"
455#if CLICK_LINUXMODULE && defined(xchg)
456 return atomic_xchg(&_val, desired);
457#elif CLICK_LINUXMODULE
458# error "need xchg for atomic_uint32_t::swap"
460 return swap(CLICK_ATOMIC_VAL, desired);
475#if CLICK_ATOMIC_BUILTINS
476 return __atomic_fetch_add(&_val, delta, CLICK_ATOMIC_MEMORDER);
477#elif CLICK_ATOMIC_X86
478 asm volatile (CLICK_ATOMIC_LOCK
"xaddl %0,%1"
479 :
"=r" (delta),
"=m" (CLICK_ATOMIC_VAL)
480 :
"0" (delta),
"m" (CLICK_ATOMIC_VAL)
483#elif CLICK_LINUXMODULE && HAVE_LINUX_ATOMIC_ADD_RETURN
484 return atomic_add_return(&_val, delta) - delta;
485#elif CLICK_LINUXMODULE
486# warning "using nonatomic approximation for atomic_uint32_t::fetch_and_add"
488 local_irq_save(flags);
489 uint32_t old_value =
value();
490 CLICK_ATOMIC_VAL += delta;
491 local_irq_restore(flags);
494 uint32_t old_value =
value();
495 CLICK_ATOMIC_VAL += delta;
512 static_assert(
sizeof(atomic_t) ==
sizeof(x),
"atomic_t expected to take 32 bits.");
513 return atomic_dec_and_test((atomic_t *) &x);
514#elif CLICK_ATOMIC_BUILTINS
515 return __atomic_sub_fetch(&x,1 , CLICK_ATOMIC_MEMORDER) == 0;
516#elif CLICK_ATOMIC_X86
518 asm volatile (CLICK_ATOMIC_LOCK
"decl %0 ; sete %1"
519 :
"=m" (x),
"=qm" (result)
544#if CLICK_ATOMIC_COMPARE_SWAP
546atomic_uint32_t::compare_swap(
volatile uint32_t &x, uint32_t expected, uint32_t desired)
548#if CLICK_ATOMIC_BUILTINS
549# warning "compare_swap is not truly atomic with system builtins"
550 return __atomic_compare_exchange(&x,&expected,&desired,0,CLICK_ATOMIC_MEMORDER, CLICK_ATOMIC_MEMORDER)
552#elif CLICK_ATOMIC_X86
553 asm volatile (CLICK_ATOMIC_LOCK
"cmpxchgl %2,%1"
554 :
"=a" (expected),
"=m" (x)
555 :
"r" (desired),
"0" (expected),
"m" (x)
558#elif CLICK_LINUXMODULE && defined(cmpxchg)
559 return cmpxchg(&x, expected, desired);
560#elif CLICK_LINUXMODULE
561# warning "using nonatomic approximation for atomic_uint32_t::compare_and_swap"
563 local_irq_save(flags);
565 if (actual == expected)
567 local_irq_restore(flags);
571 if (actual == expected)
598#if CLICK_ATOMIC_BUILTINS
599 return __atomic_compare_exchange(&x,&expected,&desired,0,CLICK_ATOMIC_MEMORDER, CLICK_ATOMIC_MEMORDER);
601#elif CLICK_ATOMIC_X86
602 asm volatile (CLICK_ATOMIC_LOCK
"cmpxchgl %2,%0 ; sete %%al"
603 :
"=m" (x),
"=a" (expected)
604 :
"r" (desired),
"m" (x),
"a" (expected)
606 return (uint8_t) expected;
607#elif CLICK_LINUXMODULE && defined(cmpxchg)
608 return cmpxchg(&x, expected, desired) == expected;
609#elif CLICK_LINUXMODULE
610# warning "using nonatomic approximation for atomic_uint32_t::compare_and_swap"
612 local_irq_save(flags);
613 uint32_t old_value = x;
614 if (old_value == expected)
616 local_irq_restore(flags);
617 return old_value == expected;
619 uint32_t old_value = x;
620 if (old_value == expected)
622 return old_value == expected;
638 return atomic_dec_and_test(&_val);
639#elif CLICK_ATOMIC_BUILTINS
640 return __atomic_sub_fetch(&_val, 1, CLICK_ATOMIC_MEMORDER) == 0;
641#elif CLICK_ATOMIC_X86
643 asm volatile (CLICK_ATOMIC_LOCK
"decl %0 ; sete %1"
644 :
"=m" (CLICK_ATOMIC_VAL),
"=qm" (result)
645 :
"m" (CLICK_ATOMIC_VAL)
649 return (--CLICK_ATOMIC_VAL == 0);
665 return CLICK_ATOMIC_VAL == 0;
683#if CLICK_ATOMIC_COMPARE_SWAP
685atomic_uint32_t::compare_swap(uint32_t expected, uint32_t desired)
687#if CLICK_ATOMIC_BUILTINS
688# warning "compare_swap is not truly atomic with system builtins"
689 return __atomic_compare_exchange(&_val, &expected, &desired, 0, CLICK_ATOMIC_MEMORDER, CLICK_ATOMIC_MEMORDER)
691#elif CLICK_ATOMIC_X86
692 asm volatile (CLICK_ATOMIC_LOCK
"cmpxchgl %2,%1"
693 :
"=a" (expected),
"=m" (CLICK_ATOMIC_VAL)
694 :
"r" (desired),
"0" (expected),
"m" (CLICK_ATOMIC_VAL)
697#elif CLICK_LINUXMODULE && HAVE_LINUX_ATOMIC_CMPXCHG
698 return atomic_cmpxchg(&_val, expected, desired);
699#elif CLICK_LINUXMODULE
700# warning "using nonatomic approximation for atomic_uint32_t::compare_swap"
702 local_irq_save(flags);
703 uint32_t actual =
value();
704 if (actual == expected)
705 CLICK_ATOMIC_VAL = desired;
706 local_irq_restore(flags);
709 uint32_t actual =
value();
710 if (actual == expected)
711 CLICK_ATOMIC_VAL = desired;
736#if CLICK_ATOMIC_BUILTINS
737 return __atomic_compare_exchange(&_val, &expected, &desired, 0, CLICK_ATOMIC_MEMORDER, CLICK_ATOMIC_MEMORDER);
738#elif CLICK_ATOMIC_X86
739 asm volatile (CLICK_ATOMIC_LOCK
"cmpxchgl %2,%0 ; sete %%al"
740 :
"=m" (CLICK_ATOMIC_VAL),
"=a" (expected)
741 :
"r" (desired),
"m" (CLICK_ATOMIC_VAL),
"a" (expected)
743 return (uint8_t) expected;
744#elif CLICK_LINUXMODULE && HAVE_LINUX_ATOMIC_CMPXCHG
745 return atomic_cmpxchg(&_val, expected, desired) == expected;
746#elif CLICK_LINUXMODULE
747# warning "using nonatomic approximation for atomic_uint32_t::compare_and_swap"
749 local_irq_save(flags);
750 uint32_t old_value =
value();
751 if (old_value == expected)
752 CLICK_ATOMIC_VAL = desired;
753 local_irq_restore(flags);
754 return old_value == expected;
756 uint32_t old_value =
value();
757 if (old_value == expected)
758 CLICK_ATOMIC_VAL = desired;
759 return old_value == expected;
820 return atomic64_read(&_val);
822 return CLICK_ATOMIC_VAL;
830 return *((uint64_t*)&_val);
835atomic_uint64_t::operator uint64_t()
const
845 atomic64_set(&_val, x);
847 CLICK_ATOMIC_VAL = x;
857 atomic64_add(delta, &_val);
858#elif CLICK_ATOMIC_BUILTINS
859 __atomic_add_fetch(&_val, delta, CLICK_ATOMIC_MEMORDER);
860#elif CLICK_ATOMIC_X86
861 asm volatile (CLICK_ATOMIC_LOCK
"addq %1,%0"
862 :
"=m" (CLICK_ATOMIC_VAL)
863 :
"r" (delta),
"m" (CLICK_ATOMIC_VAL)
866 CLICK_ATOMIC_VAL += delta;
876 atomic64_add(delta, (atomic64_t*)&x);
877#elif CLICK_ATOMIC_BUILTINS
878 __atomic_add_fetch(&x, delta, CLICK_ATOMIC_MEMORDER);
879#elif CLICK_ATOMIC_X86
880 asm volatile (CLICK_ATOMIC_LOCK
"addq %1,%0"
882 :
"r" (delta),
"m" (x)
894 atomic64_sub(delta, &_val);
895#elif CLICK_ATOMIC_BUILTINS
896 __atomic_sub_fetch(&CLICK_ATOMIC_VAL, delta, CLICK_ATOMIC_MEMORDER);
897#elif CLICK_ATOMIC_X86
898 asm volatile (CLICK_ATOMIC_LOCK
"subq %1,%0"
899 :
"=m" (CLICK_ATOMIC_VAL)
900 :
"r" (delta),
"m" (CLICK_ATOMIC_VAL)
903 CLICK_ATOMIC_VAL -= delta;
922#elif CLICK_ATOMIC_X86
923 asm volatile (CLICK_ATOMIC_LOCK
"incq %0"
924 :
"=m" (CLICK_ATOMIC_VAL)
925 :
"m" (CLICK_ATOMIC_VAL)
938#elif CLICK_ATOMIC_BUILTINS
939 __atomic_add_fetch(&CLICK_ATOMIC_VAL, 1, CLICK_ATOMIC_MEMORDER);
940#elif CLICK_ATOMIC_X86
941 asm volatile (CLICK_ATOMIC_LOCK
"incq %0"
942 :
"=m" (CLICK_ATOMIC_VAL)
943 :
"m" (CLICK_ATOMIC_VAL)
956#elif CLICK_ATOMIC_BUILTINS
957 __atomic_sub_fetch(&CLICK_ATOMIC_VAL, 1, CLICK_ATOMIC_MEMORDER);
958#elif CLICK_ATOMIC_X86
959 asm volatile (CLICK_ATOMIC_LOCK
"decq %0"
960 :
"=m" (CLICK_ATOMIC_VAL)
961 :
"m" (CLICK_ATOMIC_VAL)
981#elif CLICK_ATOMIC_BUILTINS
982 __atomic_sub_fetch(&CLICK_ATOMIC_VAL, 1, CLICK_ATOMIC_MEMORDER);
983#elif CLICK_ATOMIC_X86
984 asm volatile (CLICK_ATOMIC_LOCK
"decq %0"
985 :
"=m" (CLICK_ATOMIC_VAL)
986 :
"m" (CLICK_ATOMIC_VAL)
1009#if CLICK_ATOMIC_COMPARE_SWAP
1011atomic_uint64_t::compare_swap(
volatile uint64_t &x, uint64_t expected, uint64_t desired)
1013#if CLICK_ATOMIC_BUILTINS
1014# warning "compare_swap is not truly atomic with system builtins"
1015 return __atomic_compare_exchange(&x,&expected,&desired,0,CLICK_ATOMIC_MEMORDER, CLICK_ATOMIC_MEMORDER)
1017#elif CLICK_ATOMIC_X86
1018 asm volatile (CLICK_ATOMIC_LOCK
"cmpxchgq %2,%1"
1019 :
"=a" (expected),
"=m" (x)
1020 :
"r" (desired),
"0" (expected),
"m" (x)
1023#elif CLICK_LINUXMODULE && defined(cmpxchg)
1024 return cmpxchg(&x, expected, desired);
1025#elif CLICK_LINUXMODULE
1026# warning "using nonatomic approximation for atomic_uint§2_t::compare_and_swap"
1027 unsigned long flags;
1028 local_irq_save(flags);
1029 uint64_t actual = x;
1030 if (actual == expected)
1032 local_irq_restore(flags);
1035 uint64_t actual = x;
1036 if (actual == expected)
1043atomic_uint64_t::compare_swap(uint64_t expected, uint64_t desired) {
1044#if CLICK_LINUXMODULE && defined(cmpxchg)
1045 return atomic64_cmpxchg(&_val, expected, desired);
1047 return atomic_uint64_t::compare_swap(*(
volatile uint64_t*)&CLICK_ATOMIC_VAL, expected, desired);
1063#if CLICK_ATOMIC_BUILTINS
1064 return __atomic_fetch_add(&_val, delta, CLICK_ATOMIC_MEMORDER);
1065#elif CLICK_ATOMIC_X86
1066 asm volatile (CLICK_ATOMIC_LOCK
"xaddq %0,%1"
1067 :
"=r" (delta),
"=m" (CLICK_ATOMIC_VAL)
1068 :
"0" (delta),
"m" (CLICK_ATOMIC_VAL)
1071#elif CLICK_LINUXMODULE && HAVE_LINUX_ATOMIC_ADD_RETURN
1072 return atomic64_add_return(&_val, delta) - delta;
1073#elif CLICK_LINUXMODULE
1074# warning "using nonatomic approximation for atomic_uint64_t::fetch_and_add"
1075 unsigned long flags;
1076 local_irq_save(flags);
1077 uint64_t old_value =
value();
1078 CLICK_ATOMIC_VAL += delta;
1079 local_irq_restore(flags);
1082 uint64_t old_value =
value();
1083 CLICK_ATOMIC_VAL += delta;
1090class nonatomic_uint32_t {
public:
1094 inline uint32_t value()
const {
return _val; }
1095 inline uint32_t nonatomic_value()
const {
return _val; }
1096 inline operator uint32_t()
const {
return _val; }
1098 inline nonatomic_uint32_t &operator=(uint32_t x) { _val = x;
return *
this; }
1100 inline nonatomic_uint32_t &operator+=(int32_t delta) { _val += delta;
return *
this; }
1101 inline nonatomic_uint32_t &operator-=(int32_t delta) { _val -= delta;
return *
this; }
1102 inline nonatomic_uint32_t &operator|=(uint32_t mask) { _val |= mask;
return *
this; }
1103 inline nonatomic_uint32_t &operator&=(uint32_t mask) { _val &= mask;
return *
this; }
1105 inline void nonatomic_inc() { ++_val; }
1106 inline void operator++() { ++_val; }
1107 inline void operator++(
int) { ++_val; }
1108 inline void nonatomic_dec() { --_val; }
1109 inline void operator--() { --_val; }
1110 inline void operator--(
int) { --_val; }
1112 inline uint32_t swap(uint32_t desired) { uint32_t old = _val; _val = desired;
return old; }
1113 inline uint32_t fetch_and_add(uint32_t delta) { uint32_t old = _val; _val += delta;
return old; }
1114 inline bool dec_and_test() {
return --_val == 0; }
1115 inline bool nonatomic_dec_and_test() {
return --_val == 0; }
1116 inline uint32_t compare_swap(uint32_t expected, uint32_t desired) { uint32_t old = _val;
if (_val == expected) _val = desired;
return old; }
1117 inline bool compare_and_swap(uint32_t expected, uint32_t desired) {
if (_val == expected) { _val = desired;
return true; }
return false; }
1119 inline static uint32_t swap(
volatile uint32_t &x, uint32_t desired) { uint32_t old = x; x = desired;
return old; }
1120 inline static void inc(
volatile uint32_t &x) { ++x; }
1121 inline static bool dec_and_test(
volatile uint32_t &x) {
return --x == 0; }
1122 inline static uint32_t compare_swap(
volatile uint32_t &x, uint32_t expected, uint32_t desired) { uint32_t old = x;
if (x == expected) x = desired;
return old; }
1123 inline static bool compare_and_swap(
volatile uint32_t &x, uint32_t expected, uint32_t desired) {
if (x == expected) { x = desired;
return true; }
return false; }
1125 inline static bool use_builtins() {
return false; }
A 32-bit integer with support for atomic operations.
Definition atomic.hh:71
bool dec_and_test()
Atomically decrement the value, returning true if the new value is 0.
Definition atomic.hh:635
atomic_uint32_t & operator&=(uint32_t mask)
Atomically bitwise-and the value with mask.
Definition atomic.hh:279
void nonatomic_dec()
Decrement the value.
Definition atomic.hh:384
void operator++()
Atomically increment the value.
Definition atomic.hh:330
uint32_t swap(uint32_t desired)
Atomically assign the value to desired, returning the old value.
Definition atomic.hh:453
void operator--()
Atomically decrement the value.
Definition atomic.hh:366
atomic_uint32_t & operator-=(int32_t delta)
Atomically subtract delta from the value.
Definition atomic.hh:235
void nonatomic_inc()
Increment the value.
Definition atomic.hh:323
uint32_t fetch_and_add(uint32_t delta)
Atomically add delta to the value, returning the old value.
Definition atomic.hh:473
bool compare_and_swap(uint32_t expected, uint32_t desired) CLICK_BUILTINS_NONDEPRECATED
Perform a compare-and-swap operation.
Definition atomic.hh:734
uint32_t value() const
Return the value.
Definition atomic.hh:179
static void inc(volatile uint32_t &x)
Atomically increment value x.
Definition atomic.hh:304
bool nonatomic_dec_and_test()
Decrement the value, returning true if the new value is 0.
Definition atomic.hh:662
uint32_t nonatomic_value() const
Return the value.
Definition atomic.hh:190
atomic_uint32_t & operator|=(uint32_t mask)
Atomically bitwise-or the value with mask.
Definition atomic.hh:254
atomic_uint32_t & operator=(uint32_t x)
Set the value to x.
Definition atomic.hh:204
atomic_uint32_t & operator+=(int32_t delta)
Atomically add delta to the value.
Definition atomic.hh:216
A 64-bit integer with support for atomic operations.
Definition atomic.hh:137
atomic_uint64_t & operator+=(int64_t delta)
Atomically add delta to the value.
Definition atomic.hh:854
atomic_uint64_t & operator-=(int64_t delta)
Atomically subtract delta from the value.
Definition atomic.hh:891
void operator++()
Atomically increment the value.
Definition atomic.hh:918
static void add(volatile uint64_t &x, uint64_t delta)
Atomically increment value x.
Definition atomic.hh:873
atomic_uint64_t & operator=(uint64_t x)
Set the value to x.
Definition atomic.hh:842
uint64_t nonatomic_value() const
Return the value.
Definition atomic.hh:828
void nonatomic_inc()
Increment the value.
Definition atomic.hh:911
uint64_t fetch_and_add(uint64_t delta)
Perform a compare-and-swap operation.
Definition atomic.hh:1061
uint64_t value() const
Return the value.
Definition atomic.hh:817
void nonatomic_dec()
Decrement the value.
Definition atomic.hh:970
void operator--()
Atomically decrement the value.
Definition atomic.hh:952