don't forget this file
[c11tester.git] / include / impatomic.c
1 #include <stdint.h>
2 #include "impatomic.h"
3
4 bool atomic_flag_test_and_set_explicit
5 ( volatile atomic_flag* __a__, memory_order __x__ )
6 {
7         bool * __p__ = &((__a__)->__f__);
8         model->switch_to_master(new ModelAction(ATOMIC_READ, __x__, __p__));
9         bool result = (void *) thread_current()->get_return_value();
10         model->switch_to_master(new ModelAction(ATOMIC_RMW, __x__, __p__, true));
11         return result;
12 }
13
14 bool atomic_flag_test_and_set( volatile atomic_flag* __a__ )
15 { return atomic_flag_test_and_set_explicit( __a__, memory_order_seq_cst ); }
16
17 void atomic_flag_clear_explicit
18 ( volatile atomic_flag* __a__, memory_order __x__ )
19 {
20         bool * __p__ = &((__a__)->__f__);
21         model->switch_to_master(new ModelAction(ATOMIC_WRITE, __x__, __p__, false));
22 }
23
24 void atomic_flag_clear( volatile atomic_flag* __a__ )
25 { atomic_flag_clear_explicit( __a__, memory_order_seq_cst ); }
26
27 void atomic_flag_fence( const volatile atomic_flag* __a__, memory_order __x__ )
28 {
29         ASSERT(0);
30 }
31
32 void __atomic_flag_wait__( volatile atomic_flag* __a__ )
33 { while ( atomic_flag_test_and_set( __a__ ) ); }
34
35 void __atomic_flag_wait_explicit__( volatile atomic_flag* __a__,
36                                     memory_order __x__ )
37 { while ( atomic_flag_test_and_set_explicit( __a__, __x__ ) ); }