source: CIVL/include/headers/stdatomic.h@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 4.5 KB
RevLine 
[aad342c]1/* stdatomic.h: The ABC representation of standard C library.
2 * C11 7.17: The header <stdatomic.h> defines several macros and declares several
3 * types and functions for performing atomic operations on data shared
4 * between threads.
5 */
6
7#ifndef _STDATOMIC_
8#define _STDATOMIC_
9
10#include <stddef.h>
11#include <stdint.h>
12
13/* Types */
14typedef enum memory_order{ //defines memory ordering constraints
15 memory_order_relaxed,
16 memory_order_consume,
17 memory_order_acquire,
18 memory_order_release,
19 memory_order_acq_rel,
20 memory_order_seq_cst
21}memory_order;
22
23/* lock-free atomic boolean flag */
24typedef struct atomic_flag atomic_flag;
25
26typedef unsigned long int char16_t;
27typedef unsigned long int char32_t;
28
29/* Atomic types */
30typedef _Atomic _Bool atomic_bool;
31typedef _Atomic char atomic_char;
32typedef _Atomic signed char atomic_schar;
33typedef _Atomic unsigned char atomic_uchar;
34typedef _Atomic short atomic_short;
35typedef _Atomic unsigned short atomic_ushort;
36typedef _Atomic int atomic_int;
37typedef _Atomic unsigned int atomic_uint;
38typedef _Atomic long atomic_long;
39typedef _Atomic unsigned long atomic_ulong;
40typedef _Atomic long long atomic_llong;
41typedef _Atomic unsigned long long atomic_ullong;
42typedef _Atomic char16_t atomic_char16_t;
43typedef _Atomic char32_t atomic_char32_t;
44typedef _Atomic wchar_t atomic_wchar_t;
45typedef _Atomic int_least8_t atomic_int_least8_t;
46typedef _Atomic uint_least8_t atomic_uint_least8_t;
47typedef _Atomic int_least16_t atomic_int_least16_t;
48typedef _Atomic uint_least16_t atomic_uint_least16_t;
49typedef _Atomic int_least32_t atomic_int_least32_t;
50typedef _Atomic uint_least32_t atomic_uint_least32_t;
51typedef _Atomic int_least64_t atomic_int_least64_t;
52typedef _Atomic uint_least64_t atomic_uint_least64_t;
53typedef _Atomic int_fast8_t atomic_int_fast8_t;
54typedef _Atomic uint_fast8_t atomic_uint_fast8_t;
55typedef _Atomic int_fast16_t atomic_int_fast16_t;
56typedef _Atomic uint_fast16_t atomic_uint_fast16_t;
57typedef _Atomic int_fast32_t atomic_int_fast32_t;
58typedef _Atomic uint_fast32_t atomic_uint_fast32_t;
59typedef _Atomic int_fast64_t atomic_int_fast64_t;
60typedef _Atomic uint_fast64_t atomic_uint_fast64_t;
61typedef _Atomic intptr_t atomic_intptr_t;
62typedef _Atomic uintptr_t atomic_uintptr_t;
63typedef _Atomic size_t atomic_size_t;
64typedef _Atomic ptrdiff_t atomic_ptrdiff_t;
65typedef _Atomic intmax_t atomic_intmax_t;
66typedef _Atomic uintmax_t atomic_uintmax_t;
67
68typedef struct A A;
69typedef struct C C;
70typedef struct M M;
71
72/* Macros */
73#define ATOMIC_BOOL_LOCK_FREE _ABC_ATOMIC_BOOL_LOCK_FREE
74#define ATOMIC_CHAR_LOCK_FREE _ABC_ATOMIC_CHAR_LOCK_FREE
75#define ATOMIC_CHAR16_T_LOCK_FREE _ABC_ATOMIC_CHAR16_T_LOCK_FREE
76#define ATOMIC_CHAR32_T_LOCK_FREE _ABC_ATOMIC_CHAR32_T_LOCK_FREE
77#define ATOMIC_WCHAR_T_LOCK_FREE _ABC_ATOMIC_WCHAR_T_LOCK_FREE
78#define ATOMIC_SHORT_T_LOCK_FREE _ABC_ATOMIC_SHORT_T_LOCK_FREE
79#define ATOMIC_INT_T_LOCK_FREE _ABC_ATOMIC_INT_T_LOCK_FREE
80#define ATOMIC_LONG_T_LOCK_FREE _ABC_ATOMIC_LONG_T_LOCK_FREE
81#define ATOMIC_LLONG_T_LOCK_FREE _ABC_ATOMIC_LLONG_T_LOCK_FREE
82#define ATOMIC_POINTER_T_LOCK_FREE _ABC_ATOMIC_POINTER_T_LOCK_FREE
83
84#define ATOMIC_FLAG_INIT 0
85#define ATOMIC_VAR_INIT(value)
86#define kill_dependency(y)
87
88/* Functions */
89void atomic_thread_fence(memory_order);
90void atomic_signal_fence(memory_order);
91_Bool atomic_is_lock_free(const volatile A *);
92void atomic_store(volatile A *, C);
93void atomic_store_explicit(volatile A *, C, memory_order);
94C atomic_load(volatile A *);
95C atomic_load_explicit(volatile A *, memory_order);
96C atomic_exchange(volatile A *, C);
97C atomic_exchange_explicit(volatile A *, C, memory_order);
98_Bool atomic_compare_exchange_strong(volatile A *, C *, C );
99_Bool atomic_compare_exchange_strong_explicit(volatile A *, C *, C, memory_order, memory_order);
100_Bool atomic_compare_exchange_weak(volatile A *, C *, C );
101_Bool atomic_compare_exchange_weak_explicit(volatile A *, C *, C, memory_order, memory_order);
102C atomic_fetch_key(volatile A *, M);
103C atomic_fetch_key_explicit(volatile A *, M, memory_order);
104_Bool atomic_flag_test_and_set(volatile atomic_flag *);
105_Bool atomic_flag_test_and_set_explicit(volatile atomic_flag *, memory_order);
106void atomic_flag_clear(volatile atomic_flag *);
107void atomic_flag_clear_explicit(volatile atomic_flag *, memory_order);
108
109#endif
Note: See TracBrowser for help on using the repository browser.