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