Back to index

glibc  2.9
Defines
atomic.h File Reference
#include <stdlib.h>
#include <bits/atomic.h>

Go to the source code of this file.

Defines

#define __atomic_val_bysize(pre, post, mem,...)
#define __atomic_bool_bysize(pre, post, mem,...)
#define catomic_compare_and_exchange_val_acq(mem, newval, oldval)   atomic_compare_and_exchange_val_acq (mem, newval, oldval)
#define atomic_compare_and_exchange_val_rel(mem, newval, oldval)   atomic_compare_and_exchange_val_acq (mem, newval, oldval)
#define catomic_compare_and_exchange_val_rel(mem, newval, oldval)   atomic_compare_and_exchange_val_acq (mem, newval, oldval)
#define atomic_compare_and_exchange_bool_acq(mem, newval, oldval)
#define catomic_compare_and_exchange_bool_acq(mem, newval, oldval)
#define atomic_compare_and_exchange_bool_rel(mem, newval, oldval)   atomic_compare_and_exchange_bool_acq (mem, newval, oldval)
#define catomic_compare_and_exchange_bool_rel(mem, newval, oldval)   catomic_compare_and_exchange_bool_acq (mem, newval, oldval)
#define atomic_exchange_acq(mem, newvalue)
#define atomic_exchange_rel(mem, newvalue)   atomic_exchange_acq (mem, newvalue)
#define atomic_exchange_and_add(mem, value)
#define catomic_exchange_and_add(mem, value)
#define atomic_max(mem, value)
#define catomic_max(mem, value)
#define atomic_min(mem, value)
#define atomic_add(mem, value)   (void) atomic_exchange_and_add ((mem), (value))
#define catomic_add(mem, value)   (void) catomic_exchange_and_add ((mem), (value))
#define atomic_increment(mem)   atomic_add ((mem), 1)
#define catomic_increment(mem)   catomic_add ((mem), 1)
#define atomic_increment_val(mem)   (atomic_exchange_and_add ((mem), 1) + 1)
#define catomic_increment_val(mem)   (catomic_exchange_and_add ((mem), 1) + 1)
#define atomic_increment_and_test(mem)   (atomic_exchange_and_add ((mem), 1) + 1 == 0)
#define atomic_decrement(mem)   atomic_add ((mem), -1)
#define catomic_decrement(mem)   catomic_add ((mem), -1)
#define atomic_decrement_val(mem)   (atomic_exchange_and_add ((mem), -1) - 1)
#define catomic_decrement_val(mem)   (catomic_exchange_and_add ((mem), -1) - 1)
#define atomic_decrement_and_test(mem)   (atomic_exchange_and_add ((mem), -1) == 1)
#define atomic_decrement_if_positive(mem)
#define atomic_add_negative(mem, value)
#define atomic_add_zero(mem, value)
#define atomic_bit_set(mem, bit)   (void) atomic_bit_test_set(mem, bit)
#define atomic_bit_test_set(mem, bit)
#define atomic_and(mem, mask)
#define atomic_and_val(mem, mask)
#define atomic_or(mem, mask)
#define catomic_or(mem, mask)
#define atomic_or_val(mem, mask)
#define atomic_full_barrier()   __asm ("" ::: "memory")
#define atomic_read_barrier()   atomic_full_barrier ()
#define atomic_write_barrier()   atomic_full_barrier ()
#define atomic_forced_read(x)   ({ __typeof (x) __x; __asm ("" : "=r" (__x) : "0" (x)); __x; })
#define atomic_delay()   do { /* nothing */ } while (0)

Define Documentation

#define __atomic_bool_bysize (   pre,
  post,
  mem,
  ... 
)
Value:
({                                                                   \
    int __atg2_result;                                                      \
    if (sizeof (*mem) == 1)                                          \
      __atg2_result = pre##_8_##post (mem, __VA_ARGS__);                    \
    else if (sizeof (*mem) == 2)                                     \
      __atg2_result = pre##_16_##post (mem, __VA_ARGS__);                   \
    else if (sizeof (*mem) == 4)                                     \
      __atg2_result = pre##_32_##post (mem, __VA_ARGS__);                   \
    else if (sizeof (*mem) == 8)                                     \
      __atg2_result = pre##_64_##post (mem, __VA_ARGS__);                   \
    else								      \
      abort ();                                                             \
    __atg2_result;                                                   \
  })

Definition at line 71 of file atomic.h.

#define __atomic_val_bysize (   pre,
  post,
  mem,
  ... 
)
Value:
({                                                                   \
    __typeof (*mem) __atg1_result;                                   \
    if (sizeof (*mem) == 1)                                          \
      __atg1_result = pre##_8_##post (mem, __VA_ARGS__);                    \
    else if (sizeof (*mem) == 2)                                     \
      __atg1_result = pre##_16_##post (mem, __VA_ARGS__);                   \
    else if (sizeof (*mem) == 4)                                     \
      __atg1_result = pre##_32_##post (mem, __VA_ARGS__);                   \
    else if (sizeof (*mem) == 8)                                     \
      __atg1_result = pre##_64_##post (mem, __VA_ARGS__);                   \
    else                                                             \
      abort ();                                                             \
    __atg1_result;                                                   \
  })

Definition at line 56 of file atomic.h.

#define atomic_add (   mem,
  value 
)    (void) atomic_exchange_and_add ((mem), (value))

Definition at line 279 of file atomic.h.

#define atomic_add_negative (   mem,
  value 
)
Value:
({ __typeof (value) __atg12_value = (value);                                \
     atomic_exchange_and_add (mem, __atg12_value) < -__atg12_value; })

Definition at line 364 of file atomic.h.

#define atomic_add_zero (   mem,
  value 
)
Value:
({ __typeof (value) __atg13_value = (value);                                \
     atomic_exchange_and_add (mem, __atg13_value) == -__atg13_value; })

Definition at line 371 of file atomic.h.

#define atomic_and (   mem,
  mask 
)
Value:
do {                                                                 \
    __typeof (*(mem)) __atg15_old;                                   \
    __typeof (mem) __atg15_memp = (mem);                             \
    __typeof (*(mem)) __atg15_mask = (mask);                                \
                                                                     \
    do                                                               \
      __atg15_old = (*__atg15_memp);                                        \
    while (__builtin_expect                                          \
          (atomic_compare_and_exchange_bool_acq (__atg15_memp,              \
                                            __atg15_old & __atg15_mask, \
                                            __atg15_old), 0));       \
  } while (0)

Definition at line 401 of file atomic.h.

#define atomic_and_val (   mem,
  mask 
)
Value:
({ __typeof (*(mem)) __atg16_old;                                    \
     __typeof (mem) __atg16_memp = (mem);                            \
     __typeof (*(mem)) __atg16_mask = (mask);                               \
                                                                     \
     do                                                                     \
       __atg16_old = (*__atg16_memp);                                       \
     while (__builtin_expect                                                \
           (atomic_compare_and_exchange_bool_acq (__atg16_memp,             \
                                             __atg16_old & __atg16_mask,\
                                             __atg16_old), 0));             \
                                                                     \
     __atg16_old; })

Definition at line 418 of file atomic.h.

#define atomic_bit_set (   mem,
  bit 
)    (void) atomic_bit_test_set(mem, bit)

Definition at line 378 of file atomic.h.

#define atomic_bit_test_set (   mem,
  bit 
)
Value:
({ __typeof (*(mem)) __atg14_old;                                    \
     __typeof (mem) __atg14_memp = (mem);                            \
     __typeof (*(mem)) __atg14_mask = ((__typeof (*(mem))) 1 << (bit));            \
                                                                     \
     do                                                                     \
       __atg14_old = (*__atg14_memp);                                       \
     while (__builtin_expect                                                \
           (atomic_compare_and_exchange_bool_acq (__atg14_memp,             \
                                             __atg14_old | __atg14_mask,\
                                             __atg14_old), 0));             \
                                                                     \
     __atg14_old & __atg14_mask; })

Definition at line 384 of file atomic.h.

#define atomic_compare_and_exchange_bool_acq (   mem,
  newval,
  oldval 
)
Value:
({ /* Cannot use __oldval here, because macros later in this file might     \
       call this macro with __oldval argument.    */                        \
     __typeof (oldval) __atg3_old = (oldval);                               \
     atomic_compare_and_exchange_val_acq (mem, newval, __atg3_old)          \
       != __atg3_old;                                                       \
  })

Definition at line 129 of file atomic.h.

#define atomic_compare_and_exchange_bool_rel (   mem,
  newval,
  oldval 
)    atomic_compare_and_exchange_bool_acq (mem, newval, oldval)

Definition at line 156 of file atomic.h.

#define atomic_compare_and_exchange_val_rel (   mem,
  newval,
  oldval 
)    atomic_compare_and_exchange_val_acq (mem, newval, oldval)

Definition at line 110 of file atomic.h.

#define atomic_decrement (   mem)    atomic_add ((mem), -1)

Definition at line 317 of file atomic.h.

#define atomic_decrement_and_test (   mem)    (atomic_exchange_and_add ((mem), -1) == 1)

Definition at line 338 of file atomic.h.

Value:
({ __typeof (*(mem)) __atg11_oldval;                                        \
     __typeof (mem) __atg11_memp = (mem);                            \
                                                                     \
     do                                                                     \
       {                                                             \
        __atg11_oldval = *__atg11_memp;                              \
        if (__builtin_expect (__atg11_oldval <= 0, 0))                      \
          break;                                                     \
       }                                                             \
     while (__builtin_expect                                                \
           (atomic_compare_and_exchange_bool_acq (__atg11_memp,             \
                                             __atg11_oldval - 1,            \
                                             __atg11_oldval), 0));      \
     __atg11_oldval; })

Definition at line 345 of file atomic.h.

#define atomic_decrement_val (   mem)    (atomic_exchange_and_add ((mem), -1) - 1)

Definition at line 327 of file atomic.h.

#define atomic_delay ( )    do { /* nothing */ } while (0)

Definition at line 505 of file atomic.h.

#define atomic_exchange_acq (   mem,
  newvalue 
)
Value:
({ __typeof (*(mem)) __atg5_oldval;                                         \
     __typeof (mem) __atg5_memp = (mem);                             \
     __typeof (*(mem)) __atg5_value = (newvalue);                           \
                                                                     \
     do                                                                     \
       __atg5_oldval = *__atg5_memp;                                        \
     while (__builtin_expect                                                \
           (atomic_compare_and_exchange_bool_acq (__atg5_memp, __atg5_value, \
                                             __atg5_oldval), 0));           \
                                                                     \
     __atg5_oldval; })

Definition at line 169 of file atomic.h.

#define atomic_exchange_and_add (   mem,
  value 
)
Value:
({ __typeof (*(mem)) __atg6_oldval;                                         \
     __typeof (mem) __atg6_memp = (mem);                             \
     __typeof (*(mem)) __atg6_value = (value);                              \
                                                                     \
     do                                                                     \
       __atg6_oldval = *__atg6_memp;                                        \
     while (__builtin_expect                                                \
           (atomic_compare_and_exchange_bool_acq (__atg6_memp,              \
                                             __atg6_oldval           \
                                             + __atg6_value,         \
                                             __atg6_oldval), 0));           \
                                                                     \
     __atg6_oldval; })

Definition at line 190 of file atomic.h.

#define atomic_exchange_rel (   mem,
  newvalue 
)    atomic_exchange_acq (mem, newvalue)

Definition at line 184 of file atomic.h.

#define atomic_forced_read (   x)    ({ __typeof (x) __x; __asm ("" : "=r" (__x) : "0" (x)); __x; })

Definition at line 499 of file atomic.h.

#define atomic_full_barrier ( )    __asm ("" ::: "memory")

Definition at line 484 of file atomic.h.

#define atomic_increment (   mem)    atomic_add ((mem), 1)

Definition at line 290 of file atomic.h.

#define atomic_increment_and_test (   mem)    (atomic_exchange_and_add ((mem), 1) + 1 == 0)

Definition at line 311 of file atomic.h.

#define atomic_increment_val (   mem)    (atomic_exchange_and_add ((mem), 1) + 1)

Definition at line 300 of file atomic.h.

#define atomic_max (   mem,
  value 
)
Value:
do {                                                                 \
    __typeof (*(mem)) __atg8_oldval;                                        \
    __typeof (mem) __atg8_memp = (mem);                                     \
    __typeof (*(mem)) __atg8_value = (value);                               \
    do {                                                             \
      __atg8_oldval = *__atg8_memp;                                         \
      if (__atg8_oldval >= __atg8_value)                             \
       break;                                                        \
    } while (__builtin_expect                                               \
            (atomic_compare_and_exchange_bool_acq (__atg8_memp, __atg8_value,\
                                              __atg8_oldval), 0));      \
  } while (0)

Definition at line 226 of file atomic.h.

#define atomic_min (   mem,
  value 
)
Value:
do {                                                                 \
    __typeof (*(mem)) __atg10_oldval;                                       \
    __typeof (mem) __atg10_memp = (mem);                             \
    __typeof (*(mem)) __atg10_value = (value);                              \
    do {                                                             \
      __atg10_oldval = *__atg10_memp;                                       \
      if (__atg10_oldval <= __atg10_value)                                  \
       break;                                                        \
    } while (__builtin_expect                                               \
            (atomic_compare_and_exchange_bool_acq (__atg10_memp,            \
                                              __atg10_value,         \
                                              __atg10_oldval), 0));     \
  } while (0)

Definition at line 261 of file atomic.h.

#define atomic_or (   mem,
  mask 
)
Value:
do {                                                                 \
    __typeof (*(mem)) __atg17_old;                                   \
    __typeof (mem) __atg17_memp = (mem);                             \
    __typeof (*(mem)) __atg17_mask = (mask);                                \
                                                                     \
    do                                                               \
      __atg17_old = (*__atg17_memp);                                        \
    while (__builtin_expect                                          \
          (atomic_compare_and_exchange_bool_acq (__atg17_memp,              \
                                            __atg17_old | __atg17_mask, \
                                            __atg17_old), 0));       \
  } while (0)

Definition at line 435 of file atomic.h.

#define atomic_or_val (   mem,
  mask 
)
Value:
({ __typeof (*(mem)) __atg19_old;                                    \
     __typeof (mem) __atg19_memp = (mem);                            \
     __typeof (*(mem)) __atg19_mask = (mask);                               \
                                                                     \
     do                                                                     \
       __atg19_old = (*__atg19_memp);                                       \
     while (__builtin_expect                                                \
           (atomic_compare_and_exchange_bool_acq (__atg19_memp,             \
                                             __atg19_old | __atg19_mask,\
                                             __atg19_old), 0));             \
                                                                     \
     __atg19_old; })

Definition at line 468 of file atomic.h.

Definition at line 489 of file atomic.h.

Definition at line 494 of file atomic.h.

#define catomic_add (   mem,
  value 
)    (void) catomic_exchange_and_add ((mem), (value))

Definition at line 284 of file atomic.h.

#define catomic_compare_and_exchange_bool_acq (   mem,
  newval,
  oldval 
)
Value:
({ /* Cannot use __oldval here, because macros later in this file might     \
       call this macro with __oldval argument.    */                        \
     __typeof (oldval) __atg4_old = (oldval);                               \
     catomic_compare_and_exchange_val_acq (mem, newval, __atg4_old)         \
       != __atg4_old;                                                       \
  })

Definition at line 145 of file atomic.h.

#define catomic_compare_and_exchange_bool_rel (   mem,
  newval,
  oldval 
)    catomic_compare_and_exchange_bool_acq (mem, newval, oldval)

Definition at line 162 of file atomic.h.

#define catomic_compare_and_exchange_val_acq (   mem,
  newval,
  oldval 
)    atomic_compare_and_exchange_val_acq (mem, newval, oldval)

Definition at line 104 of file atomic.h.

#define catomic_compare_and_exchange_val_rel (   mem,
  newval,
  oldval 
)    atomic_compare_and_exchange_val_acq (mem, newval, oldval)

Definition at line 116 of file atomic.h.

#define catomic_decrement (   mem)    catomic_add ((mem), -1)

Definition at line 322 of file atomic.h.

#define catomic_decrement_val (   mem)    (catomic_exchange_and_add ((mem), -1) - 1)

Definition at line 332 of file atomic.h.

#define catomic_exchange_and_add (   mem,
  value 
)
Value:
({ __typeof (*(mem)) __atg7_oldv;                                    \
     __typeof (mem) __atg7_memp = (mem);                             \
     __typeof (*(mem)) __atg7_value = (value);                              \
                                                                     \
     do                                                                     \
       __atg7_oldv = *__atg7_memp;                                   \
     while (__builtin_expect                                                \
           (catomic_compare_and_exchange_bool_acq (__atg7_memp,             \
                                              __atg7_oldv                   \
                                              + __atg7_value,        \
                                              __atg7_oldv), 0));            \
                                                                     \
     __atg7_oldv; })

Definition at line 208 of file atomic.h.

#define catomic_increment (   mem)    catomic_add ((mem), 1)

Definition at line 295 of file atomic.h.

#define catomic_increment_val (   mem)    (catomic_exchange_and_add ((mem), 1) + 1)

Definition at line 305 of file atomic.h.

#define catomic_max (   mem,
  value 
)
Value:
do {                                                                 \
    __typeof (*(mem)) __atg9_oldv;                                   \
    __typeof (mem) __atg9_memp = (mem);                                     \
    __typeof (*(mem)) __atg9_value = (value);                               \
    do {                                                             \
      __atg9_oldv = *__atg9_memp;                                    \
      if (__atg9_oldv >= __atg9_value)                                      \
       break;                                                        \
    } while (__builtin_expect                                               \
            (catomic_compare_and_exchange_bool_acq (__atg9_memp,            \
                                               __atg9_value,         \
                                               __atg9_oldv), 0));           \
  } while (0)

Definition at line 243 of file atomic.h.

#define catomic_or (   mem,
  mask 
)
Value:
do {                                                                 \
    __typeof (*(mem)) __atg18_old;                                   \
    __typeof (mem) __atg18_memp = (mem);                             \
    __typeof (*(mem)) __atg18_mask = (mask);                                \
                                                                     \
    do                                                               \
      __atg18_old = (*__atg18_memp);                                        \
    while (__builtin_expect                                          \
          (catomic_compare_and_exchange_bool_acq (__atg18_memp,             \
                                             __atg18_old | __atg18_mask,\
                                             __atg18_old), 0));             \
  } while (0)

Definition at line 451 of file atomic.h.