|
20 | 20 | extern "C" { |
21 | 21 | #endif |
22 | 22 |
|
23 | | -#if defined(__GNUC__) || defined(__GNUG__) |
24 | | - |
25 | 23 | #include <assert.h> |
26 | 24 |
|
| 25 | +static inline void cc_assert (int exp) |
| 26 | +{ |
| 27 | + assert (exp); // LCOV_EXCL_LINE |
| 28 | +} |
| 29 | + |
27 | 30 | #define CC_PACKED_BEGIN |
28 | 31 | #define CC_PACKED_END |
29 | 32 | #define CC_PACKED __attribute__ ((packed)) |
| 33 | +#define CC_ALIGNED(n) __attribute__((aligned (n))) |
30 | 34 |
|
31 | 35 | #define CC_FORMAT(str, arg) __attribute__ ((format (printf, str, arg))) |
32 | 36 |
|
@@ -78,60 +82,6 @@ extern "C" { |
78 | 82 |
|
79 | 83 | #define CC_UNUSED(var) (void)(var) |
80 | 84 |
|
81 | | -static inline void cc_assert (int exp) |
82 | | -{ |
83 | | - assert (exp); // LCOV_EXCL_LINE |
84 | | -} |
85 | | - |
86 | | -#elif defined(_MSC_VER) |
87 | | - |
88 | | -#include <assert.h> |
89 | | - |
90 | | -#define CC_PACKED_BEGIN __pragma (pack (push, 1)) |
91 | | -#define CC_PACKED_END __pragma (pack (pop)) |
92 | | -#define CC_PACKED |
93 | | - |
94 | | -#define CC_FORMAT(str, arg) |
95 | | - |
96 | | -#define CC_TO_LE16(x) ((uint16_t)(x)) |
97 | | -#define CC_TO_LE32(x) ((uint32_t)(x)) |
98 | | -#define CC_TO_LE64(x) ((uint64_t)(x)) |
99 | | -#define CC_FROM_LE16(x) ((uint16_t)(x)) |
100 | | -#define CC_FROM_LE32(x) ((uint32_t)(x)) |
101 | | -#define CC_FROM_LE64(x) ((uint64_t)(x)) |
102 | | -#define CC_TO_BE16(x) ((uint16_t)_byteswap_ushort (x)) |
103 | | -#define CC_TO_BE32(x) ((uint32_t)_byteswap_ulong (x)) |
104 | | -#define CC_TO_BE64(x) ((uint64_t)_byteswap_uint64 (x)) |
105 | | -#define CC_FROM_BE16(x) ((uint16_t)_byteswap_ushort (x)) |
106 | | -#define CC_FROM_BE32(x) ((uint32_t)_byteswap_ulong (x)) |
107 | | -#define CC_FROM_BE64(x) ((uint64_t)_byteswap_uint64 (x)) |
108 | | - |
109 | | -/* TODO */ |
110 | | -#define CC_ATOMIC_GET8(p) (*p) |
111 | | -#define CC_ATOMIC_GET16(p) (*p) |
112 | | -#define CC_ATOMIC_GET32(p) (*p) |
113 | | -#define CC_ATOMIC_GET64(p) (*p) |
114 | | - |
115 | | -/* TODO */ |
116 | | -#define CC_ATOMIC_SET8(p, v) ((*p) = (v)) |
117 | | -#define CC_ATOMIC_SET16(p, v) ((*p) = (v)) |
118 | | -#define CC_ATOMIC_SET32(p, v) ((*p) = (v)) |
119 | | -#define CC_ATOMIC_SET64(p, v) ((*p) = (v)) |
120 | | - |
121 | | -static uint8_t __inline cc_ctz (uint32_t x) |
122 | | -{ |
123 | | - DWORD n = 0; |
124 | | - _BitScanForward (&n, x); |
125 | | - return (uint8_t)n; |
126 | | -} |
127 | | - |
128 | | -#define __builtin_ctz(x) cc_ctz (x) |
129 | | - |
130 | | -#define CC_ASSERT(exp) assert (exp) |
131 | | -#define CC_STATIC_ASSERT(exp) static_assert ((exp), "") |
132 | | - |
133 | | -#endif |
134 | | - |
135 | 85 | #ifdef __cplusplus |
136 | 86 | } |
137 | 87 | #endif |
|
0 commit comments