authorgravatar for vahursi@gmail.comVahur Sinijärv <vahursi@gmail.com> 2025-01-30 01:21:44+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-01-29 23:21:44+00:00
logc4445bc1565bf22ddce47e3a84fde430b9a2b7eb
tree0a55404732aa06e0fc390e1a3f2e3ffe7e69c4d1
parent7d699be772b974a10d2a54ae639822f051dbc68c
signaturebadge-check Signed by PGP key B5690EEEBB952194

Fix issues in zig.h when building with clang-cl on Windows (#20331)

Co-authored-by: Alex Rønne Petersen <alex@alexrp.com>

1 files changed, 11 insertions(+), 7 deletions(-)

lib/zig.h+11-7
...@@ -293,11 +293,11 @@...@@ -293,11 +293,11 @@
293#endif /* zig_macho */293#endif /* zig_macho */
294#endif /* zig_msvc */294#endif /* zig_msvc */
295295
296#if (zig_has_attribute(alias) || defined(zig_tinyc)) && !defined(zig_macho)296#if defined(zig_msvc)
297#define zig_export(symbol, name) __attribute__((alias(symbol)))
298#elif defined(zig_msvc)
299#define zig_export(symbol, name) ; \297#define zig_export(symbol, name) ; \
300 __pragma(comment(linker, "/alternatename:" zig_mangle_c(name) "=" zig_mangle_c(symbol)))298 __pragma(comment(linker, "/alternatename:" zig_mangle_c(name) "=" zig_mangle_c(symbol)))
299#elif (zig_has_attribute(alias) || defined(zig_tinyc)) && !defined(zig_macho)
300#define zig_export(symbol, name) __attribute__((alias(symbol)))
301#else301#else
302#define zig_export(symbol, name) ; \302#define zig_export(symbol, name) ; \
303 __asm(zig_mangle_c(name) " = " zig_mangle_c(symbol))303 __asm(zig_mangle_c(name) " = " zig_mangle_c(symbol))
...@@ -321,7 +321,7 @@...@@ -321,7 +321,7 @@
321#if defined(zig_msvc)321#if defined(zig_msvc)
322#define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\322#define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args;\
323 __pragma(comment(linker, "/alternatename:" zig_mangle_c(#fn_name) "=" zig_mangle_c(#libc_name)));323 __pragma(comment(linker, "/alternatename:" zig_mangle_c(#fn_name) "=" zig_mangle_c(#libc_name)));
324#define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, sig_args, call_args)324#define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_import(Type, fn_name, libc_name, sig_args, call_args)
325#else /* zig_msvc */325#else /* zig_msvc */
326#define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(zig_mangle_c(#libc_name));326#define zig_import(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type fn_name sig_args __asm(zig_mangle_c(#libc_name));
327#define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \327#define zig_import_builtin(Type, fn_name, libc_name, sig_args, call_args) zig_extern Type libc_name sig_args; \
...@@ -3729,7 +3729,11 @@ zig_float_builtins(64)...@@ -3729,7 +3729,11 @@ zig_float_builtins(64)
3729 res = zig_atomicrmw_expected; \3729 res = zig_atomicrmw_expected; \
3730} while (0)3730} while (0)
37313731
3732#if (__STDC_VERSION__ >= 201112L || (zig_has_include(<stdatomic.h>) && !defined(zig_msvc))) && !defined(__STDC_NO_ATOMICS__)3732#if (__STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)) || (zig_has_include(<stdatomic.h>) && !defined(zig_msvc))
3733#define zig_c11_atomics
3734#endif
3735
3736#if defined(zig_c11_atomics)
3733#include <stdatomic.h>3737#include <stdatomic.h>
3734typedef enum memory_order zig_memory_order;3738typedef enum memory_order zig_memory_order;
3735#define zig_memory_order_relaxed memory_order_relaxed3739#define zig_memory_order_relaxed memory_order_relaxed
...@@ -3823,7 +3827,7 @@ typedef int zig_memory_order;...@@ -3823,7 +3827,7 @@ typedef int zig_memory_order;
3823#define zig_atomic_load(res, obj, order, Type, ReprType) zig_atomics_unavailable3827#define zig_atomic_load(res, obj, order, Type, ReprType) zig_atomics_unavailable
3824#endif3828#endif
38253829
3826#if defined(zig_msvc) && defined(zig_x86)3830#if !defined(zig_c11_atomics) && defined(zig_msvc) && defined(zig_x86)
38273831
3828/* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */3832/* TODO: zig_msvc_atomic_load should load 32 bit without interlocked on x86, and load 64 bit without interlocked on x64 */
38293833
...@@ -4069,7 +4073,7 @@ static inline void zig_msvc_atomic_store_i128(zig_i128 volatile* obj, zig_i128 a...@@ -4069,7 +4073,7 @@ static inline void zig_msvc_atomic_store_i128(zig_i128 volatile* obj, zig_i128 a
40694073
4070#endif /* zig_x86_32 */4074#endif /* zig_x86_32 */
40714075
4072#endif /* zig_msvc && zig_x86 */4076#endif /* !zig_c11_atomics && zig_msvc && zig_x86 */
40734077
4074/* ======================== Special Case Intrinsics ========================= */4078/* ======================== Special Case Intrinsics ========================= */
40754079