| ... | ... | @@ -106,7 +106,7 @@ typedef char bool; |
| 106 | 106 | #define zig_never_tail zig_never_tail_unavailable |
| 107 | 107 | #endif |
| 108 | 108 | |
| 109 | | #if zig_has_attribute(always_inline) |
| 109 | #if zig_has_attribute(musttail) |
| 110 | 110 | #define zig_always_tail __attribute__((musttail)) |
| 111 | 111 | #else |
| 112 | 112 | #define zig_always_tail zig_always_tail_unavailable |
| ... | ... | @@ -177,12 +177,14 @@ typedef char bool; |
| 177 | 177 | #if _MSC_VER |
| 178 | 178 | #define zig_extern_mangled zig_extern |
| 179 | 179 | #else |
| 180 | | #define zig_extern_mangled static |
| 180 | #if zig_has_attribute(visibility) |
| 181 | #define zig_extern_mangled zig_extern __attribute__((visibility("hidden"))) |
| 182 | #else |
| 183 | #define zig_extern_mangled zig_extern |
| 184 | #endif |
| 181 | 185 | #endif |
| 182 | 186 | |
| 183 | | #if zig_has_attribute(alias) |
| 184 | | #define zig_export(sig, symbol, name) zig_extern sig __attribute__((alias(#symbol))) |
| 185 | | #elif _MSC_VER |
| 187 | #if _MSC_VER |
| 186 | 188 | #if _M_X64 |
| 187 | 189 | #define zig_export(sig, symbol, name) zig_extern sig;\ |
| 188 | 190 | __pragma(comment(linker, "/alternatename:" name "=" #symbol )) |
| ... | ... | @@ -190,27 +192,35 @@ typedef char bool; |
| 190 | 192 | #define zig_export(sig, symbol, name) zig_extern sig;\ |
| 191 | 193 | __pragma(comment(linker, "/alternatename:" name "=" #symbol )) |
| 192 | 194 | #endif /*_M_X64 */ |
| 193 | | #else |
| 195 | #else /* _MSC_VER */ |
| 196 | #if __APPLE__ |
| 197 | #define zig_export(sig, symbol, name) __asm("_" name " = _" #symbol) |
| 198 | #else /* __APPLE__ */ |
| 194 | 199 | #define zig_export(sig, symbol, name) __asm(name " = " #symbol) |
| 195 | | #endif |
| 200 | #endif /* __APPLE__ */ |
| 201 | #endif /* _MSC_VER */ |
| 196 | 202 | |
| 197 | 203 | #if _MSC_VER |
| 198 | 204 | #if _M_X64 |
| 199 | | #define zig_import(sig, symbol, name) zig_extern sig;\ |
| 200 | | __pragma(comment(linker, "/alternatename:" #symbol "=" #name )) |
| 205 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\ |
| 206 | __pragma(comment(linker, "/alternatename:" #fn_name "=" #libc_name )); |
| 201 | 207 | #else /*_M_X64 */ |
| 202 | | #define zig_import(sig, symbol, name) zig_extern sig;\ |
| 203 | | __pragma(comment(linker, "/alternatename:_" #symbol "=_" #name )) |
| 208 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\ |
| 209 | __pragma(comment(linker, "/alternatename:_" #fn_name "=_" #libc_name )); |
| 204 | 210 | #endif /*_M_X64 */ |
| 205 | | #else |
| 211 | #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, sig_args, call_args) |
| 212 | #else /* _MSC_VER */ |
| 206 | 213 | #if __APPLE__ |
| 207 | | #define zig_import(sig, symbol, name) zig_extern sig __asm("_" #name); |
| 214 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm("_" #libc_name); |
| 208 | 215 | #else /* __APPLE__ */ |
| 209 | | #define zig_import(sig, symbol, name) zig_extern sig __asm(#name); |
| 216 | #define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(#libc_name); |
| 210 | 217 | #endif /* __APPLE__ */ |
| 218 | #define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \ |
| 219 | static inline Type fn_name sig_args { return libc_name call_args; } |
| 211 | 220 | #endif |
| 212 | 221 | |
| 213 | | #define zig_expand_import(sig, symbol, name) zig_import(sig, symbol, name) |
| 222 | #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) |
| 223 | #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) |
| 214 | 224 | |
| 215 | 225 | #if zig_has_attribute(weak) || defined(zig_gnuc) |
| 216 | 226 | #define zig_weak_linkage __attribute__((weak)) |
| ... | ... | @@ -3111,6 +3121,7 @@ ypedef uint32_t zig_f32; |
| 3111 | 3121 | |
| 3112 | 3122 | #define zig_has_f64 1 |
| 3113 | 3123 | #define zig_libc_name_f64(name) name |
| 3124 | |
| 3114 | 3125 | #if _MSC_VER |
| 3115 | 3126 | #define zig_init_special_f64(sign, name, arg, repr) sign zig_make_f64(zig_msvc_flt_##name, ) |
| 3116 | 3127 | #else |
| ... | ... | @@ -3336,6 +3347,7 @@ zig_float_negate_builtin(128, zig_make_u128, (UINT64_C(1) << 63, UINT64_C(0))) |
| 3336 | 3347 | return lhs operator rhs; \ |
| 3337 | 3348 | } |
| 3338 | 3349 | |
| 3350 | #define zig_expand_has_builtin(b) zig_has_builtin(b) |
| 3339 | 3351 | #define zig_common_float_builtins(w) \ |
| 3340 | 3352 | zig_convert_builtin( int64_t, int64_t, fix, zig_f##w, zig_f##w, ) \ |
| 3341 | 3353 | zig_convert_builtin(zig_i128, zig_i128, fix, zig_f##w, zig_f##w, ) \ |
| ... | ... | @@ -3354,24 +3366,24 @@ zig_float_negate_builtin(128, zig_make_u128, (UINT64_C(1) << 63, UINT64_C(0))) |
| 3354 | 3366 | zig_expand_concat(zig_float_binary_builtin_, zig_has_f##w)(f##w, sub, -) \ |
| 3355 | 3367 | zig_expand_concat(zig_float_binary_builtin_, zig_has_f##w)(f##w, mul, *) \ |
| 3356 | 3368 | zig_expand_concat(zig_float_binary_builtin_, zig_has_f##w)(f##w, div, /) \ |
| 3357 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_sqrt(zig_f##w), zig_float_fn_f##w##_sqrt, zig_libc_name_f##w(sqrt)) \ |
| 3358 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_sin(zig_f##w), zig_float_fn_f##w##_sin, zig_libc_name_f##w(sin)) \ |
| 3359 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_cos(zig_f##w), zig_float_fn_f##w##_cos, zig_libc_name_f##w(cos)) \ |
| 3360 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_tan(zig_f##w), zig_float_fn_f##w##_tan, zig_libc_name_f##w(tan)) \ |
| 3361 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_exp(zig_f##w), zig_float_fn_f##w##_exp, zig_libc_name_f##w(exp)) \ |
| 3362 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_exp2(zig_f##w), zig_float_fn_f##w##_exp2, zig_libc_name_f##w(exp2)) \ |
| 3363 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_log(zig_f##w), zig_float_fn_f##w##_log, zig_libc_name_f##w(log)) \ |
| 3364 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_log2(zig_f##w), zig_float_fn_f##w##_log2, zig_libc_name_f##w(log2)) \ |
| 3365 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_log10(zig_f##w), zig_float_fn_f##w##_log10, zig_libc_name_f##w(log10)) \ |
| 3366 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_fabs(zig_f##w), zig_float_fn_f##w##_fabs, zig_libc_name_f##w(fabs)) \ |
| 3367 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_floor(zig_f##w), zig_float_fn_f##w##_floor, zig_libc_name_f##w(floor)) \ |
| 3368 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_ceil(zig_f##w), zig_float_fn_f##w##_ceil, zig_libc_name_f##w(ceil)) \ |
| 3369 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_round(zig_f##w), zig_float_fn_f##w##_round, zig_libc_name_f##w(round)) \ |
| 3370 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_trunc(zig_f##w), zig_float_fn_f##w##_trunc, zig_libc_name_f##w(trunc)) \ |
| 3371 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_fmod(zig_f##w, zig_f##w), zig_float_fn_f##w##_fmod, zig_libc_name_f##w(fmod)) \ |
| 3372 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_fmin(zig_f##w, zig_f##w), zig_float_fn_f##w##_fmin, zig_libc_name_f##w(fmin)) \ |
| 3373 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_fmax(zig_f##w, zig_f##w), zig_float_fn_f##w##_fmax, zig_libc_name_f##w(fmax)) \ |
| 3374 | | zig_expand_import(zig_f##w zig_float_fn_f##w##_fma(zig_f##w, zig_f##w, zig_f##w), zig_float_fn_f##w##_fma, zig_libc_name_f##w(fma)) \ |
| 3369 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(sqrt)))(zig_f##w, zig_float_fn_f##w##_sqrt, zig_libc_name_f##w(sqrt), (zig_f##w x), (x)) \ |
| 3370 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(sin)))(zig_f##w, zig_float_fn_f##w##_sin, zig_libc_name_f##w(sin), (zig_f##w x), (x)) \ |
| 3371 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(cos)))(zig_f##w, zig_float_fn_f##w##_cos, zig_libc_name_f##w(cos), (zig_f##w x), (x)) \ |
| 3372 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(tan)))(zig_f##w, zig_float_fn_f##w##_tan, zig_libc_name_f##w(tan), (zig_f##w x), (x)) \ |
| 3373 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(exp)))(zig_f##w, zig_float_fn_f##w##_exp, zig_libc_name_f##w(exp), (zig_f##w x), (x)) \ |
| 3374 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(exp2)))(zig_f##w, zig_float_fn_f##w##_exp2, zig_libc_name_f##w(exp2), (zig_f##w x), (x)) \ |
| 3375 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(log)))(zig_f##w, zig_float_fn_f##w##_log, zig_libc_name_f##w(log), (zig_f##w x), (x)) \ |
| 3376 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(log2)))(zig_f##w, zig_float_fn_f##w##_log2, zig_libc_name_f##w(log2), (zig_f##w x), (x)) \ |
| 3377 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(log10)))(zig_f##w, zig_float_fn_f##w##_log10, zig_libc_name_f##w(log10), (zig_f##w x), (x)) \ |
| 3378 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(fabs)))(zig_f##w, zig_float_fn_f##w##_fabs, zig_libc_name_f##w(fabs), (zig_f##w x), (x)) \ |
| 3379 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(floor)))(zig_f##w, zig_float_fn_f##w##_floor, zig_libc_name_f##w(floor), (zig_f##w x), (x)) \ |
| 3380 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(ceil)))(zig_f##w, zig_float_fn_f##w##_ceil, zig_libc_name_f##w(ceil), (zig_f##w x), (x)) \ |
| 3381 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(round)))(zig_f##w, zig_float_fn_f##w##_round, zig_libc_name_f##w(round), (zig_f##w x), (x)) \ |
| 3382 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(trunc)))(zig_f##w, zig_float_fn_f##w##_trunc, zig_libc_name_f##w(trunc), (zig_f##w x), (x)) \ |
| 3383 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(fmod)))(zig_f##w, zig_float_fn_f##w##_fmod, zig_libc_name_f##w(fmod), (zig_f##w x, zig_f##w y), (x, y)) \ |
| 3384 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(fmin)))(zig_f##w, zig_float_fn_f##w##_fmin, zig_libc_name_f##w(fmin), (zig_f##w x, zig_f##w y), (x, y)) \ |
| 3385 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(fmax)))(zig_f##w, zig_float_fn_f##w##_fmax, zig_libc_name_f##w(fmax), (zig_f##w x, zig_f##w y), (x, y)) \ |
| 3386 | zig_expand_concat(zig_expand_import_, zig_expand_has_builtin(zig_libc_name_f##w(fma)))(zig_f##w, zig_float_fn_f##w##_fma, zig_libc_name_f##w(fma), (zig_f##w x, zig_f##w y, zig_f##w z), (x, y, z)) \ |
| 3375 | 3387 | \ |
| 3376 | 3388 | static inline zig_f##w zig_div_trunc_f##w(zig_f##w lhs, zig_f##w rhs) { \ |
| 3377 | 3389 | return zig_float_fn_f##w##_trunc(zig_div_f##w(lhs, rhs)); \ |