4 * code protected with a GNU affero GPLv3 license
5 * copyright (C) 2020 Sylvain BERTRAND
15 #define U16_MAX 0xffff
19 #define U64_MAX 0xffffffffffffffff
21 #define S64_MIN 0x8000000000000000
22 #define S64_MAX 0x7fffffffffffffff
29 #define atomic_u8 atomic_uchar
31 #error "unable to find the right atomic for a 8 bits byte, be sure to have __STDC_WANT_IEC_60559_BFP_EXT__ defined"
34 #define atomic_u16 atomic_ushort
36 #error "unable to find the right atomic for an unsigned 16 bits word, be sure to have __STDC_WANT_IEC_60559_BFP_EXT__ defined"
39 #define atomic_u32 atomic_uint
40 #elif ULONG_WIDTH == 32
41 #define atomic_u32 atomic_ulong
43 #error "unable to select the right atomic for an unsigned 32 bits word, be sure to have __STDC_WANT_IEC_60559_BFP_EXT__ defined"
46 #define atomic_s64 atomic_long
48 #error "unable to select the right atomic for a 64 bits signed word, be sure to have __STDC_WANT_IEC_60559_BFP_EXT__ defined"
53 * we don't know how to handle enum from the C "standard" perspective. this
54 * is based on empirical conclusions based on gcc.
55 * this is for compiler constant, not compiler constant _variables_
57 #define constant_u32 enum
59 #define ARRAY_N(x) (sizeof(x) / sizeof((x)[0]))