struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / include / stdatomic.h
blobd4d7cbecade96693f506055982f20d05cfc786b9
1 #ifndef __SDCC_STDATOMIC_H
2 #define __SDCC_STDATOMIC_H 1
4 #include <sdcc-lib.h>
6 #ifndef __SDCC_ATOMIC_EXTERN
7 #define __SDCC_ATOMIC_EXTERN
8 #endif
10 typedef struct {unsigned char flag;} atomic_flag;
12 _Bool atomic_flag_test_and_set(volatile atomic_flag *object) __SDCC_NONBANKED;
14 #if defined(__SDCC_mcs51) || defined(__SDCC_ds390)
16 #define ATOMIC_FLAG_INIT {0}
18 __SDCC_ATOMIC_EXTERN
19 inline void atomic_flag_clear(volatile atomic_flag *object) __SDCC_NONBANKED
21 object->flag = 0;
24 #elif defined(__SDCC_f8)
26 #define ATOMIC_FLAG_INIT {0}
28 _Bool atomic_flag_test_and_set(volatile atomic_flag *object);
30 __SDCC_ATOMIC_EXTERN
31 inline void atomic_flag_clear(volatile atomic_flag *object)
33 object->flag = 0;
36 #elif defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_ez80_z80) || defined(__SDCC_z80n) || defined(__SDCC_sm83) || defined(__SDCC_r2k) || defined(__SDCC_r2ka) || defined(__SDCC_r3ka) || defined(__SDCC_r800)
38 #define ATOMIC_FLAG_INIT {0xfe}
40 __SDCC_ATOMIC_EXTERN
41 inline void atomic_flag_clear(volatile atomic_flag *object)
43 object->flag = 0xfe;
46 #elif defined(__SDCC_tlcs90) || defined(__SDCC_stm8) || defined(__SDCC_hc08) || defined(__SDCC_s08) || defined(__SDCC_mos6502) || defined(__SDCC_mos65c02)
48 #define ATOMIC_FLAG_INIT {1}
50 __SDCC_ATOMIC_EXTERN
51 inline void atomic_flag_clear(volatile atomic_flag *object)
53 object->flag = 1;
56 #else
58 #error Support for atomic_flag not implemented
60 #endif
62 #endif