| ... | ... | @@ -25,6 +25,14 @@ typedef char bool; |
| 25 | 25 | #endif |
| 26 | 26 | #endif |
| 27 | 27 | |
| 28 | #if defined(__clang__) |
| 29 | #define zig_clang |
| 30 | #elif defined(__GNUC__) |
| 31 | #define zig_gnuc |
| 32 | #elif defined(__TINYC__) |
| 33 | #define zig_tinyc |
| 34 | #endif |
| 35 | |
| 28 | 36 | #define zig_concat(lhs, rhs) lhs##rhs |
| 29 | 37 | #define zig_expand_concat(lhs, rhs) zig_concat(lhs, rhs) |
| 30 | 38 | |
| ... | ... | @@ -59,12 +67,6 @@ typedef char bool; |
| 59 | 67 | #define zig_threadlocal zig_threadlocal_unavailable |
| 60 | 68 | #endif |
| 61 | 69 | |
| 62 | | #if defined(__clang__) |
| 63 | | #define zig_clang |
| 64 | | #elif defined(__GNUC__) |
| 65 | | #define zig_gnuc |
| 66 | | #endif |
| 67 | | |
| 68 | 70 | #if defined(zig_gnuc) && (defined(__i386__) || defined(__x86_64__)) |
| 69 | 71 | #define zig_f128_has_miscompilations 1 |
| 70 | 72 | #else |
| ... | ... | @@ -124,13 +126,13 @@ typedef char bool; |
| 124 | 126 | |
| 125 | 127 | #if __STDC_VERSION__ >= 199901L |
| 126 | 128 | #define zig_restrict restrict |
| 127 | | #elif defined(__GNUC__) |
| 129 | #elif defined(__GNUC__) || defined(zig_tinyc) |
| 128 | 130 | #define zig_restrict __restrict |
| 129 | 131 | #else |
| 130 | 132 | #define zig_restrict |
| 131 | 133 | #endif |
| 132 | 134 | |
| 133 | | #if zig_has_attribute(aligned) |
| 135 | #if zig_has_attribute(aligned) || defined(zig_tinyc) |
| 134 | 136 | #define zig_under_align(alignment) __attribute__((aligned(alignment))) |
| 135 | 137 | #elif _MSC_VER |
| 136 | 138 | #define zig_under_align(alignment) __declspec(align(alignment)) |
| ... | ... | @@ -144,7 +146,7 @@ typedef char bool; |
| 144 | 146 | #define zig_align(alignment) zig_under_align(alignment) |
| 145 | 147 | #endif |
| 146 | 148 | |
| 147 | | #if zig_has_attribute(aligned) |
| 149 | #if zig_has_attribute(aligned) || defined(zig_tinyc) |
| 148 | 150 | #define zig_align_fn(alignment) __attribute__((aligned(alignment))) |
| 149 | 151 | #elif _MSC_VER |
| 150 | 152 | #define zig_align_fn(alignment) |
| ... | ... | @@ -152,7 +154,7 @@ typedef char bool; |
| 152 | 154 | #define zig_align_fn zig_align_fn_unavailable |
| 153 | 155 | #endif |
| 154 | 156 | |
| 155 | | #if zig_has_attribute(packed) |
| 157 | #if zig_has_attribute(packed) || defined(zig_tinyc) |
| 156 | 158 | #define zig_packed(definition) __attribute__((packed)) definition |
| 157 | 159 | #elif _MSC_VER |
| 158 | 160 | #define zig_packed(definition) __pragma(pack(1)) definition __pragma(pack()) |
| ... | ... | @@ -160,7 +162,7 @@ typedef char bool; |
| 160 | 162 | #define zig_packed(definition) zig_packed_unavailable |
| 161 | 163 | #endif |
| 162 | 164 | |
| 163 | | #if zig_has_attribute(section) |
| 165 | #if zig_has_attribute(section) || defined(zig_tinyc) |
| 164 | 166 | #define zig_linksection(name) __attribute__((section(name))) |
| 165 | 167 | #define zig_linksection_fn zig_linksection |
| 166 | 168 | #elif _MSC_VER |
| ... | ... | @@ -171,7 +173,7 @@ typedef char bool; |
| 171 | 173 | #define zig_linksection_fn zig_linksection |
| 172 | 174 | #endif |
| 173 | 175 | |
| 174 | | #if zig_has_builtin(unreachable) || defined(zig_gnuc) |
| 176 | #if zig_has_builtin(unreachable) || defined(zig_gnuc) || defined(zig_tinyc) |
| 175 | 177 | #define zig_unreachable() __builtin_unreachable() |
| 176 | 178 | #else |
| 177 | 179 | #define zig_unreachable() |
| ... | ... | @@ -197,7 +199,7 @@ typedef char bool; |
| 197 | 199 | #endif /* __APPLE__ */ |
| 198 | 200 | #endif /* _MSC_VER */ |
| 199 | 201 | |
| 200 | | #if zig_has_attribute(alias) && !__APPLE__ |
| 202 | #if (zig_has_attribute(alias) || defined(zig_tinyc)) && !__APPLE__ |
| 201 | 203 | #define zig_export(symbol, name) __attribute__((alias(symbol))) |
| 202 | 204 | #elif _MSC_VER |
| 203 | 205 | #define zig_export(symbol, name) ; \ |
| ... | ... | @@ -235,7 +237,7 @@ typedef char bool; |
| 235 | 237 | #define zig_expand_import_0(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, libc_name, sig_args, call_args) |
| 236 | 238 | #define zig_expand_import_1(Type, fn_name, libc_name, sig_args, call_args) zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) |
| 237 | 239 | |
| 238 | | #if zig_has_attribute(weak) || defined(zig_gnuc) |
| 240 | #if zig_has_attribute(weak) || defined(zig_gnuc) || defined(zig_tinyc) |
| 239 | 241 | #define zig_weak_linkage __attribute__((weak)) |
| 240 | 242 | #define zig_weak_linkage_fn __attribute__((weak)) |
| 241 | 243 | #elif _MSC_VER |
| ... | ... | @@ -302,7 +304,7 @@ typedef char bool; |
| 302 | 304 | #define zig_breakpoint() zig_breakpoint_unavailable |
| 303 | 305 | #endif |
| 304 | 306 | |
| 305 | | #if zig_has_builtin(return_address) || defined(zig_gnuc) |
| 307 | #if zig_has_builtin(return_address) || defined(zig_gnuc) || defined(zig_tinyc) |
| 306 | 308 | #define zig_return_address() __builtin_extract_return_addr(__builtin_return_address(0)) |
| 307 | 309 | #elif defined(_MSC_VER) |
| 308 | 310 | #define zig_return_address() _ReturnAddress() |
| ... | ... | @@ -310,7 +312,7 @@ typedef char bool; |
| 310 | 312 | #define zig_return_address() 0 |
| 311 | 313 | #endif |
| 312 | 314 | |
| 313 | | #if zig_has_builtin(frame_address) || defined(zig_gnuc) |
| 315 | #if zig_has_builtin(frame_address) || defined(zig_gnuc) || defined(zig_tinyc) |
| 314 | 316 | #define zig_frame_address() __builtin_frame_address(0) |
| 315 | 317 | #else |
| 316 | 318 | #define zig_frame_address() 0 |
| ... | ... | @@ -332,7 +334,7 @@ typedef char bool; |
| 332 | 334 | |
| 333 | 335 | #if __STDC_VERSION__ >= 201112L |
| 334 | 336 | #define zig_noreturn _Noreturn |
| 335 | | #elif zig_has_attribute(noreturn) || defined(zig_gnuc) |
| 337 | #elif zig_has_attribute(noreturn) || defined(zig_gnuc) || defined(zig_tinyc) |
| 336 | 338 | #define zig_noreturn __attribute__((noreturn)) |
| 337 | 339 | #elif _MSC_VER |
| 338 | 340 | #define zig_noreturn __declspec(noreturn) |
| ... | ... | @@ -1136,7 +1138,7 @@ static inline int64_t zig_bit_reverse_i64(int64_t val, uint8_t bits) { |
| 1136 | 1138 | static inline uint8_t zig_popcount_i##w(int##w##_t val, uint8_t bits) { \ |
| 1137 | 1139 | return zig_popcount_u##w((uint##w##_t)val, bits); \ |
| 1138 | 1140 | } |
| 1139 | | #if zig_has_builtin(popcount) || defined(zig_gnuc) |
| 1141 | #if zig_has_builtin(popcount) || defined(zig_gnuc) || defined(zig_tinyc) |
| 1140 | 1142 | #define zig_builtin_popcount(w) \ |
| 1141 | 1143 | static inline uint8_t zig_popcount_u##w(uint##w##_t val, uint8_t bits) { \ |
| 1142 | 1144 | (void)bits; \ |
| ... | ... | @@ -1165,7 +1167,7 @@ zig_builtin_popcount(64) |
| 1165 | 1167 | static inline uint8_t zig_ctz_i##w(int##w##_t val, uint8_t bits) { \ |
| 1166 | 1168 | return zig_ctz_u##w((uint##w##_t)val, bits); \ |
| 1167 | 1169 | } |
| 1168 | | #if zig_has_builtin(ctz) || defined(zig_gnuc) |
| 1170 | #if zig_has_builtin(ctz) || defined(zig_gnuc) || defined(zig_tinyc) |
| 1169 | 1171 | #define zig_builtin_ctz(w) \ |
| 1170 | 1172 | static inline uint8_t zig_ctz_u##w(uint##w##_t val, uint8_t bits) { \ |
| 1171 | 1173 | if (val == 0) return bits; \ |
| ... | ... | @@ -1190,7 +1192,7 @@ zig_builtin_ctz(64) |
| 1190 | 1192 | static inline uint8_t zig_clz_i##w(int##w##_t val, uint8_t bits) { \ |
| 1191 | 1193 | return zig_clz_u##w((uint##w##_t)val, bits); \ |
| 1192 | 1194 | } |
| 1193 | | #if zig_has_builtin(clz) || defined(zig_gnuc) |
| 1195 | #if zig_has_builtin(clz) || defined(zig_gnuc) || defined(zig_tinyc) |
| 1194 | 1196 | #define zig_builtin_clz(w) \ |
| 1195 | 1197 | static inline uint8_t zig_clz_u##w(uint##w##_t val, uint8_t bits) { \ |
| 1196 | 1198 | if (val == 0) return bits; \ |