UbixOS  2.0
stdatomic.h File Reference
#include <sys/cdefs.h>
#include <sys/_types.h>
Include dependency graph for stdatomic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  atomic_flag
 

Macros

#define __ATOMIC_ACQ_REL   4
 
#define __ATOMIC_ACQUIRE   2
 
#define __atomic_apply_stride(object, operand)   (((__typeof__((object)->__val))0) + (operand))
 
#define __ATOMIC_CONSUME   1
 
#define __ATOMIC_RELAXED   0
 
#define __ATOMIC_RELEASE   3
 
#define __ATOMIC_SEQ_CST   5
 
#define atomic_compare_exchange_strong(object, expected, desired)
 
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure)
 
#define atomic_compare_exchange_weak(object, expected, desired)
 
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure)
 
#define atomic_exchange(object, desired)   atomic_exchange_explicit(object, desired, memory_order_seq_cst)
 
#define atomic_exchange_explicit(object, desired, order)
 
#define atomic_fetch_add(object, operand)   atomic_fetch_add_explicit(object, operand, memory_order_seq_cst)
 
#define atomic_fetch_add_explicit(object, operand, order)
 
#define atomic_fetch_and(object, operand)   atomic_fetch_and_explicit(object, operand, memory_order_seq_cst)
 
#define atomic_fetch_and_explicit(object, operand, order)   ((void)(order), __sync_fetch_and_and(&(object)->__val, operand))
 
#define atomic_fetch_or(object, operand)   atomic_fetch_or_explicit(object, operand, memory_order_seq_cst)
 
#define atomic_fetch_or_explicit(object, operand, order)   ((void)(order), __sync_fetch_and_or(&(object)->__val, operand))
 
#define atomic_fetch_sub(object, operand)   atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst)
 
#define atomic_fetch_sub_explicit(object, operand, order)
 
#define atomic_fetch_xor(object, operand)   atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst)
 
#define atomic_fetch_xor_explicit(object, operand, order)   ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand))
 
#define ATOMIC_FLAG_INIT   { ATOMIC_VAR_INIT(0) }
 
#define atomic_init(obj, value)   ((void)((obj)->__val = (value)))
 
#define atomic_is_lock_free(obj)   ((void)(obj), sizeof((obj)->__val) <= sizeof(void *))
 
#define atomic_load(object)   atomic_load_explicit(object, memory_order_seq_cst)
 
#define atomic_load_explicit(object, order)   ((void)(order), __sync_fetch_and_add(&(object)->__val, 0))
 
#define atomic_store(object, desired)   atomic_store_explicit(object, desired, memory_order_seq_cst)
 
#define atomic_store_explicit(object, desired, order)   ((void)atomic_exchange_explicit(object, desired, order))
 
#define ATOMIC_VAR_INIT(value)   { .__val = (value) }
 

Enumerations

enum  memory_order {
  memory_order_relaxed = 0, memory_order_consume = 1, memory_order_acquire = 2, memory_order_release = 3,
  memory_order_acq_rel = 4, memory_order_seq_cst = 5
}
 

Functions

typedef _Atomic (_Bool) atomic_bool
 
typedef _Atomic (char) atomic_char
 
typedef _Atomic (int) atomic_int
 
typedef _Atomic (long long) atomic_llong
 
typedef _Atomic (long) atomic_long
 
typedef _Atomic (short) atomic_short
 
typedef _Atomic (signed char) atomic_schar
 
typedef _Atomic (unsigned char) atomic_uchar
 
typedef _Atomic (unsigned int) atomic_uint
 
typedef _Atomic (unsigned long long) atomic_ullong
 
typedef _Atomic (unsigned long) atomic_ulong
 
typedef _Atomic (unsigned short) atomic_ushort
 

Macro Definition Documentation

◆ __ATOMIC_ACQ_REL

#define __ATOMIC_ACQ_REL   4

Definition at line 112 of file stdatomic.h.

◆ __ATOMIC_ACQUIRE

#define __ATOMIC_ACQUIRE   2

Definition at line 106 of file stdatomic.h.

◆ __atomic_apply_stride

#define __atomic_apply_stride (   object,
  operand 
)    (((__typeof__((object)->__val))0) + (operand))

Definition at line 284 of file stdatomic.h.

◆ __ATOMIC_CONSUME

#define __ATOMIC_CONSUME   1

Definition at line 103 of file stdatomic.h.

◆ __ATOMIC_RELAXED

#define __ATOMIC_RELAXED   0

Definition at line 100 of file stdatomic.h.

◆ __ATOMIC_RELEASE

#define __ATOMIC_RELEASE   3

Definition at line 109 of file stdatomic.h.

◆ __ATOMIC_SEQ_CST

#define __ATOMIC_SEQ_CST   5

Definition at line 115 of file stdatomic.h.

◆ atomic_compare_exchange_strong

#define atomic_compare_exchange_strong (   object,
  expected,
  desired 
)
Value:

Definition at line 343 of file stdatomic.h.

◆ atomic_compare_exchange_strong_explicit

#define atomic_compare_exchange_strong_explicit (   object,
  expected,
  desired,
  success,
  failure 
)
Value:
__extension__ ({ \
__typeof__(expected) __ep = (expected); \
__typeof__(*__ep) __e = *__ep; \
(void)(success); (void)(failure); \
(_Bool)((*__ep = __sync_val_compare_and_swap(&(object)->__val, \
__e, desired)) == __e); \
})

Definition at line 286 of file stdatomic.h.

◆ atomic_compare_exchange_weak

#define atomic_compare_exchange_weak (   object,
  expected,
  desired 
)
Value:

Definition at line 346 of file stdatomic.h.

◆ atomic_compare_exchange_weak_explicit

#define atomic_compare_exchange_weak_explicit (   object,
  expected,
  desired,
  success,
  failure 
)
Value:
desired, success, failure)

Definition at line 294 of file stdatomic.h.

◆ atomic_exchange

#define atomic_exchange (   object,
  desired 
)    atomic_exchange_explicit(object, desired, memory_order_seq_cst)

Definition at line 349 of file stdatomic.h.

◆ atomic_exchange_explicit

#define atomic_exchange_explicit (   object,
  desired,
  order 
)
Value:
__extension__ ({ \
__typeof__(object) __o = (object); \
__typeof__(desired) __d = (desired); \
(void)(order); \
__sync_synchronize(); \
__sync_lock_test_and_set(&(__o)->__val, __d); \
})

Definition at line 308 of file stdatomic.h.

◆ atomic_fetch_add

#define atomic_fetch_add (   object,
  operand 
)    atomic_fetch_add_explicit(object, operand, memory_order_seq_cst)

Definition at line 351 of file stdatomic.h.

◆ atomic_fetch_add_explicit

#define atomic_fetch_add_explicit (   object,
  operand,
  order 
)
Value:
((void)(order), __sync_fetch_and_add(&(object)->__val, \
__atomic_apply_stride(object, operand)))

Definition at line 317 of file stdatomic.h.

◆ atomic_fetch_and

#define atomic_fetch_and (   object,
  operand 
)    atomic_fetch_and_explicit(object, operand, memory_order_seq_cst)

Definition at line 353 of file stdatomic.h.

◆ atomic_fetch_and_explicit

#define atomic_fetch_and_explicit (   object,
  operand,
  order 
)    ((void)(order), __sync_fetch_and_and(&(object)->__val, operand))

Definition at line 320 of file stdatomic.h.

◆ atomic_fetch_or

#define atomic_fetch_or (   object,
  operand 
)    atomic_fetch_or_explicit(object, operand, memory_order_seq_cst)

Definition at line 355 of file stdatomic.h.

◆ atomic_fetch_or_explicit

#define atomic_fetch_or_explicit (   object,
  operand,
  order 
)    ((void)(order), __sync_fetch_and_or(&(object)->__val, operand))

Definition at line 322 of file stdatomic.h.

◆ atomic_fetch_sub

#define atomic_fetch_sub (   object,
  operand 
)    atomic_fetch_sub_explicit(object, operand, memory_order_seq_cst)

Definition at line 357 of file stdatomic.h.

◆ atomic_fetch_sub_explicit

#define atomic_fetch_sub_explicit (   object,
  operand,
  order 
)
Value:
((void)(order), __sync_fetch_and_sub(&(object)->__val, \
__atomic_apply_stride(object, operand)))

Definition at line 324 of file stdatomic.h.

◆ atomic_fetch_xor

#define atomic_fetch_xor (   object,
  operand 
)    atomic_fetch_xor_explicit(object, operand, memory_order_seq_cst)

Definition at line 359 of file stdatomic.h.

◆ atomic_fetch_xor_explicit

#define atomic_fetch_xor_explicit (   object,
  operand,
  order 
)    ((void)(order), __sync_fetch_and_xor(&(object)->__val, operand))

Definition at line 327 of file stdatomic.h.

◆ ATOMIC_FLAG_INIT

#define ATOMIC_FLAG_INIT   { ATOMIC_VAR_INIT(0) }

Definition at line 378 of file stdatomic.h.

◆ atomic_init

#define atomic_init (   obj,
  value 
)    ((void)((obj)->__val = (value)))

Definition at line 90 of file stdatomic.h.

◆ atomic_is_lock_free

#define atomic_is_lock_free (   obj)    ((void)(obj), sizeof((obj)->__val) <= sizeof(void *))

Definition at line 179 of file stdatomic.h.

◆ atomic_load

#define atomic_load (   object)    atomic_load_explicit(object, memory_order_seq_cst)

Definition at line 361 of file stdatomic.h.

◆ atomic_load_explicit

#define atomic_load_explicit (   object,
  order 
)    ((void)(order), __sync_fetch_and_add(&(object)->__val, 0))

Definition at line 329 of file stdatomic.h.

◆ atomic_store

#define atomic_store (   object,
  desired 
)    atomic_store_explicit(object, desired, memory_order_seq_cst)

Definition at line 363 of file stdatomic.h.

◆ atomic_store_explicit

#define atomic_store_explicit (   object,
  desired,
  order 
)    ((void)atomic_exchange_explicit(object, desired, order))

Definition at line 331 of file stdatomic.h.

◆ ATOMIC_VAR_INIT

#define ATOMIC_VAR_INIT (   value)    { .__val = (value) }

Definition at line 89 of file stdatomic.h.

Enumeration Type Documentation

◆ memory_order

Enumerator
memory_order_relaxed 
memory_order_consume 
memory_order_acquire 
memory_order_release 
memory_order_acq_rel 
memory_order_seq_cst 

Definition at line 125 of file stdatomic.h.

Function Documentation

◆ _Atomic() [1/12]

typedef _Atomic ( _Bool  )

◆ _Atomic() [2/12]

typedef _Atomic ( char  )

◆ _Atomic() [3/12]

typedef _Atomic ( int  )

◆ _Atomic() [4/12]

typedef _Atomic ( long long  )

◆ _Atomic() [5/12]

typedef _Atomic ( long  )

◆ _Atomic() [6/12]

typedef _Atomic ( short  )

◆ _Atomic() [7/12]

typedef _Atomic ( signed char  )

◆ _Atomic() [8/12]

typedef _Atomic ( unsigned char  )

◆ _Atomic() [9/12]

typedef _Atomic ( unsigned int  )

◆ _Atomic() [10/12]

typedef _Atomic ( unsigned long long  )

◆ _Atomic() [11/12]

typedef _Atomic ( unsigned long  )

◆ _Atomic() [12/12]

typedef _Atomic ( unsigned short  )
atomic_compare_exchange_weak_explicit
#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure)
Definition: stdatomic.h:294
__atomic_apply_stride
#define __atomic_apply_stride(object, operand)
Definition: stdatomic.h:284
atomic_compare_exchange_strong_explicit
#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure)
Definition: stdatomic.h:286
memory_order_seq_cst
Definition: stdatomic.h:131