github.com/moontrade/nogc@v0.1.7/collections/wormhole/ctypes.h (about) 1 /* 2 * Copyright (c) 2016--2021 Wu, Xingbo <wuxb45@gmail.com> 3 * 4 * All rights reserved. No warranty, explicit or implicit, provided. 5 */ 6 #pragma once 7 8 // C types only; C++ source code don't use this 9 10 #include <assert.h> 11 #include <stdatomic.h> 12 13 /* C11 atomic types */ 14 typedef atomic_bool abool; 15 16 typedef atomic_uchar au8; 17 typedef atomic_ushort au16; 18 typedef atomic_uint au32; 19 typedef atomic_ulong au64; 20 static_assert(sizeof(au8) == 1, "sizeof(au8)"); 21 static_assert(sizeof(au16) == 2, "sizeof(au16)"); 22 static_assert(sizeof(au32) == 4, "sizeof(au32)"); 23 static_assert(sizeof(au64) == 8, "sizeof(au64)"); 24 25 typedef atomic_char as8; 26 typedef atomic_short as16; 27 typedef atomic_int as32; 28 typedef atomic_long as64; 29 static_assert(sizeof(as8) == 1, "sizeof(as8)"); 30 static_assert(sizeof(as16) == 2, "sizeof(as16)"); 31 static_assert(sizeof(as32) == 4, "sizeof(as32)"); 32 static_assert(sizeof(as64) == 8, "sizeof(as64)"); 33 34 // shorten long names 35 #define MO_RELAXED memory_order_relaxed 36 #define MO_CONSUME memory_order_consume 37 #define MO_ACQUIRE memory_order_acquire 38 #define MO_RELEASE memory_order_release 39 #define MO_ACQ_REL memory_order_acq_rel 40 #define MO_SEQ_CST memory_order_seq_cst