| author | |
| committer | |
| log | 0c41edf4978cc45b59909fce69885e310360cbfa |
| tree | e143076d2f253578e9a5a6fdd4f13e201b98e3c0 |
| parent | 45c4f781a5a831dd08cbab745a55834d514e45f5 |
| parent | f1dbf830e225c47189f71d2952512a81e18b8651 |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/3556510 files changed, 140 insertions(+), 65 deletions(-)
lib/std/c.zig+20-3| ... | ... | @@ -11134,14 +11134,23 @@ pub const ioctl = switch (native_os) { |
| 11134 | 11134 | |
| 11135 | 11135 | pub extern "c" fn bzero(s: *anyopaque, n: usize) void; |
| 11136 | 11136 | |
| 11137 | pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; | |
| 11137 | pub const swab = switch (builtin.abi) { | |
| 11138 | .msvc => private._swab, | |
| 11139 | else => private.swab, | |
| 11140 | }; | |
| 11138 | 11141 | |
| 11139 | 11142 | pub extern "c" fn strncmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int; |
| 11140 | 11143 | pub extern "c" fn strcasecmp(a: [*:0]const c_char, b: [*:0]const c_char) c_int; |
| 11141 | 11144 | pub extern "c" fn strncasecmp(a: [*:0]const c_char, b: [*:0]const c_char, max: usize) c_int; |
| 11142 | pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char; | |
| 11145 | pub const strdup = switch (builtin.abi) { | |
| 11146 | .msvc => private._strdup, | |
| 11147 | else => private.strdup, | |
| 11148 | }; | |
| 11143 | 11149 | pub extern "c" fn strndup(s: [*:0]const c_char, n: usize) ?[*:0]c_char; |
| 11144 | pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; | |
| 11150 | pub const wcsdup = switch (builtin.abi) { | |
| 11151 | .msvc => private._wcsdup, | |
| 11152 | else => private.wcsdup, | |
| 11153 | }; | |
| 11145 | 11154 | |
| 11146 | 11155 | pub extern "c" fn ffs(i: c_int) c_int; |
| 11147 | 11156 | pub extern "c" fn ffsl(i: c_long) c_long; |
| ... | ... | @@ -11555,6 +11564,14 @@ pub const setkeymap = serenity.setkeymap; |
| 11555 | 11564 | |
| 11556 | 11565 | /// External definitions shared by two or more operating systems. |
| 11557 | 11566 | const private = struct { |
| 11567 | pub extern "c" fn strdup(s: [*:0]const c_char) ?[*:0]c_char; | |
| 11568 | pub extern "c" fn _strdup(s: [*:0]const c_char) ?[*:0]c_char; | |
| 11569 | pub extern "c" fn wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; | |
| 11570 | pub extern "c" fn _wcsdup(s: [*:0]const wchar_t) ?[*:0]wchar_t; | |
| 11571 | ||
| 11572 | pub extern "c" fn swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; | |
| 11573 | pub extern "c" fn _swab(noalias from: *const anyopaque, noalias to: *anyopaque, n: isize) void; | |
| 11574 | ||
| 11558 | 11575 | extern "c" fn close(fd: fd_t) c_int; |
| 11559 | 11576 | extern "c" fn clock_getres(clk_id: clockid_t, tp: *timespec) c_int; |
| 11560 | 11577 | extern "c" fn clock_gettime(clk_id: clockid_t, tp: *timespec) c_int; |
test/behavior/call.zig+4-4| ... | ... | @@ -277,7 +277,7 @@ test "forced tail call" { |
| 277 | 277 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 278 | 278 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 279 | 279 | |
| 280 | if (builtin.zig_backend == .stage2_llvm) { | |
| 280 | if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { | |
| 281 | 281 | if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { |
| 282 | 282 | return error.SkipZigTest; |
| 283 | 283 | } |
| ... | ... | @@ -312,7 +312,7 @@ test "inline call preserves tail call" { |
| 312 | 312 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 313 | 313 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 314 | 314 | |
| 315 | if (builtin.zig_backend == .stage2_llvm) { | |
| 315 | if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { | |
| 316 | 316 | if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { |
| 317 | 317 | return error.SkipZigTest; |
| 318 | 318 | } |
| ... | ... | @@ -708,7 +708,7 @@ test "tail call function pointer" { |
| 708 | 708 | if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; |
| 709 | 709 | if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; |
| 710 | 710 | |
| 711 | if (builtin.zig_backend == .stage2_llvm) { | |
| 711 | if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { | |
| 712 | 712 | if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { |
| 713 | 713 | return error.SkipZigTest; |
| 714 | 714 | } |
| ... | ... | @@ -736,7 +736,7 @@ test "tail call with potentially extended types" { |
| 736 | 736 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 737 | 737 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO |
| 738 | 738 | |
| 739 | if (builtin.zig_backend == .stage2_llvm) { | |
| 739 | if (builtin.zig_backend == .stage2_llvm or builtin.zig_backend == .stage2_c) { | |
| 740 | 740 | if (builtin.cpu.arch.isMIPS() or builtin.cpu.arch.isPowerPC() or builtin.cpu.arch.isWasm()) { |
| 741 | 741 | return error.SkipZigTest; |
| 742 | 742 | } |
test/c/math.zig+3| ... | ... | @@ -61,10 +61,13 @@ test "modf" { |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | test "modff" { |
| 64 | if (builtin.cpu.arch == .x86 and builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only | |
| 65 | ||
| 64 | 66 | try testModf(f32); |
| 65 | 67 | } |
| 66 | 68 | |
| 67 | 69 | test "modfl" { |
| 70 | if (builtin.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only | |
| 68 | 71 | if (builtin.target.cpu.arch.isPowerPC()) return error.SkipZigTest; // TODO: see https://codeberg.org/ziglang/zig/issues/30976 |
| 69 | 72 | |
| 70 | 73 | try testModf(c_longdouble); |
test/c/pthread.zig+1| ... | ... | @@ -7,6 +7,7 @@ const testing = std.testing; |
| 7 | 7 | |
| 8 | 8 | test "pthread_spinlock_t" { |
| 9 | 9 | if (builtin.target.os.tag.isDarwin()) return; // Darwin doesn't have `pthread_spin_*` |
| 10 | if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // winpthreads-only | |
| 10 | 11 | |
| 11 | 12 | var spin: c.pthread_spinlock_t = undefined; |
| 12 | 13 | _ = c.pthread_spin_init(&spin, c.PTHREAD_PROCESS_PRIVATE); |
test/c/stdlib.zig+14| ... | ... | @@ -33,6 +33,7 @@ test "div" { |
| 33 | 33 | if (builtin.target.cpu.arch.isMIPS64()) return error.SkipZigTest; // TODO |
| 34 | 34 | if (builtin.target.cpu.arch.isPowerPC()) return error.SkipZigTest; // TODO |
| 35 | 35 | if (builtin.target.cpu.arch == .s390x) return error.SkipZigTest; // TODO |
| 36 | if (builtin.target.cpu.arch == .x86 and builtin.target.os.tag == .windows) return error.SkipZigTest; // TODO | |
| 36 | 37 | |
| 37 | 38 | const expected: c.div_t = .{ .quot = 5, .rem = 5 }; |
| 38 | 39 | try testing.expectEqual(expected, c.div(55, 10)); |
| ... | ... | @@ -42,6 +43,7 @@ test "ldiv" { |
| 42 | 43 | if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO |
| 43 | 44 | if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest; // TODO |
| 44 | 45 | if (builtin.target.cpu.arch == .s390x) return error.SkipZigTest; // TODO |
| 46 | if (builtin.target.cpu.arch == .x86 and builtin.target.os.tag == .windows) return error.SkipZigTest; // TODO | |
| 45 | 47 | |
| 46 | 48 | const expected: c.ldiv_t = .{ .quot = -6, .rem = 2 }; |
| 47 | 49 | try testing.expectEqual(expected, c.ldiv(38, -6)); |
| ... | ... | @@ -129,6 +131,8 @@ fn testStrToLLikeFunctionAnyErrno( |
| 129 | 131 | } |
| 130 | 132 | |
| 131 | 133 | test "strtol" { |
| 134 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 135 | ||
| 132 | 136 | c._errno().* = @intFromEnum(c.E.SUCCESS); |
| 133 | 137 | try testStrToLLikeFunctionAnyErrno(c.strtol, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); |
| 134 | 138 | try testStrToLLikeFunction(c.strtol, @ptrCast("42true"), 0, 42, 2, .SUCCESS); |
| ... | ... | @@ -167,6 +171,8 @@ test "strtol" { |
| 167 | 171 | } |
| 168 | 172 | |
| 169 | 173 | test "strtoll" { |
| 174 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 175 | ||
| 170 | 176 | c._errno().* = @intFromEnum(c.E.SUCCESS); |
| 171 | 177 | try testStrToLLikeFunctionAnyErrno(c.strtoll, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); |
| 172 | 178 | try testStrToLLikeFunction(c.strtoll, @ptrCast("42true"), 0, 42, 2, .SUCCESS); |
| ... | ... | @@ -205,6 +211,8 @@ test "strtoll" { |
| 205 | 211 | } |
| 206 | 212 | |
| 207 | 213 | test "strtoul" { |
| 214 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 215 | ||
| 208 | 216 | c._errno().* = @intFromEnum(c.E.SUCCESS); |
| 209 | 217 | try testStrToLLikeFunctionAnyErrno(c.strtoul, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); |
| 210 | 218 | try testStrToLLikeFunction(c.strtoul, @ptrCast("42true"), 0, 42, 2, .SUCCESS); |
| ... | ... | @@ -241,6 +249,8 @@ test "strtoul" { |
| 241 | 249 | } |
| 242 | 250 | |
| 243 | 251 | test "strtoull" { |
| 252 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 253 | ||
| 244 | 254 | c._errno().* = @intFromEnum(c.E.SUCCESS); |
| 245 | 255 | try testStrToLLikeFunctionAnyErrno(c.strtoull, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); |
| 246 | 256 | try testStrToLLikeFunction(c.strtoull, @ptrCast("42true"), 0, 42, 2, .SUCCESS); |
| ... | ... | @@ -277,6 +287,8 @@ test "strtoull" { |
| 277 | 287 | } |
| 278 | 288 | |
| 279 | 289 | test "strtoimax" { |
| 290 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 291 | ||
| 280 | 292 | c._errno().* = @intFromEnum(c.E.SUCCESS); |
| 281 | 293 | try testStrToLLikeFunctionAnyErrno(c.strtoimax, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); |
| 282 | 294 | try testStrToLLikeFunction(c.strtoimax, @ptrCast("42true"), 0, 42, 2, .SUCCESS); |
| ... | ... | @@ -315,6 +327,8 @@ test "strtoimax" { |
| 315 | 327 | } |
| 316 | 328 | |
| 317 | 329 | test "strtoumax" { |
| 330 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 331 | ||
| 318 | 332 | c._errno().* = @intFromEnum(c.E.SUCCESS); |
| 319 | 333 | try testStrToLLikeFunctionAnyErrno(c.strtoumax, @ptrCast("stop42true"), 0, 0, 0, &.{ .SUCCESS, .INVAL }); |
| 320 | 334 | try testStrToLLikeFunction(c.strtoumax, @ptrCast("42true"), 0, 42, 2, .SUCCESS); |
test/c/strings.zig+4| ... | ... | @@ -48,6 +48,8 @@ test "ffs" { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | test "strcasecmp" { |
| 51 | if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only | |
| 52 | ||
| 51 | 53 | try testing.expect(c.strcasecmp(@ptrCast("a"), @ptrCast("b")) < 0); |
| 52 | 54 | try testing.expect(c.strcasecmp(@ptrCast("b"), @ptrCast("a")) > 0); |
| 53 | 55 | try testing.expect(c.strcasecmp(@ptrCast("A"), @ptrCast("b")) < 0); |
| ... | ... | @@ -58,6 +60,8 @@ test "strcasecmp" { |
| 58 | 60 | } |
| 59 | 61 | |
| 60 | 62 | test "strncasecmp" { |
| 63 | if (builtin.target.os.tag == .windows and builtin.target.abi != .gnu) return; // mingw-only | |
| 64 | ||
| 61 | 65 | try testing.expect(c.strncasecmp(@ptrCast("a"), @ptrCast("b"), 1) < 0); |
| 62 | 66 | try testing.expect(c.strncasecmp(@ptrCast("b"), @ptrCast("a"), 1) > 0); |
| 63 | 67 | try testing.expect(c.strncasecmp(@ptrCast("A"), @ptrCast("b"), 1) < 0); |
test/c/unistd.zig+1| ... | ... | @@ -8,6 +8,7 @@ test "swab" { |
| 8 | 8 | if (builtin.target.cpu.arch.isMIPS64() and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO |
| 9 | 9 | if (builtin.target.cpu.arch == .x86_64 and @sizeOf(usize) == 4) return error.SkipZigTest; // TODO |
| 10 | 10 | if (builtin.target.os.tag == .netbsd) return error.SkipZigTest; // TODO |
| 11 | if (builtin.target.cpu.arch.isX86() and builtin.target.os.tag == .windows and builtin.target.abi == .msvc) return error.SkipZigTest; // TODO | |
| 11 | 12 | |
| 12 | 13 | var a: [4]u8 = undefined; |
| 13 | 14 | @memset(a[0..], '\x00'); |
test/c_abi/cfuncs.c+14| ... | ... | @@ -2846,6 +2846,7 @@ void run_c_tests(void) { |
| 2846 | 2846 | #if !defined(__mips64) |
| 2847 | 2847 | #if !defined(ZIG_PPC32) |
| 2848 | 2848 | #if !defined(__s390x__) |
| 2849 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2849 | 2850 | { |
| 2850 | 2851 | struct Struct_u8 s = zig_ret_struct_u8(); |
| 2851 | 2852 | assert_or_panic(s.a == 1); |
| ... | ... | @@ -2854,10 +2855,12 @@ void run_c_tests(void) { |
| 2854 | 2855 | #endif |
| 2855 | 2856 | #endif |
| 2856 | 2857 | #endif |
| 2858 | #endif | |
| 2857 | 2859 | |
| 2858 | 2860 | #if !defined(__mips64) |
| 2859 | 2861 | #if !defined(ZIG_PPC32) |
| 2860 | 2862 | #if !defined(__s390x__) |
| 2863 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2861 | 2864 | { |
| 2862 | 2865 | struct Struct_u16 s = zig_ret_struct_u16(); |
| 2863 | 2866 | assert_or_panic(s.a == 7); |
| ... | ... | @@ -2866,10 +2869,12 @@ void run_c_tests(void) { |
| 2866 | 2869 | #endif |
| 2867 | 2870 | #endif |
| 2868 | 2871 | #endif |
| 2872 | #endif | |
| 2869 | 2873 | |
| 2870 | 2874 | #if !defined(__mips64) |
| 2871 | 2875 | #if !defined(ZIG_PPC32) |
| 2872 | 2876 | #if !defined(__s390x__) |
| 2877 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2873 | 2878 | { |
| 2874 | 2879 | struct Struct_u32 s = zig_ret_struct_u32(); |
| 2875 | 2880 | assert_or_panic(s.a == 13); |
| ... | ... | @@ -2878,10 +2883,12 @@ void run_c_tests(void) { |
| 2878 | 2883 | #endif |
| 2879 | 2884 | #endif |
| 2880 | 2885 | #endif |
| 2886 | #endif | |
| 2881 | 2887 | |
| 2882 | 2888 | #if !defined(ZIG_PPC32) |
| 2883 | 2889 | #if !defined(ZIG_RISCV32) |
| 2884 | 2890 | #if !defined(__s390x__) |
| 2891 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2885 | 2892 | { |
| 2886 | 2893 | struct Struct_u64 s = zig_ret_struct_u64(); |
| 2887 | 2894 | assert_or_panic(s.a == 19); |
| ... | ... | @@ -2890,6 +2897,7 @@ void run_c_tests(void) { |
| 2890 | 2897 | #endif |
| 2891 | 2898 | #endif |
| 2892 | 2899 | #endif |
| 2900 | #endif | |
| 2893 | 2901 | |
| 2894 | 2902 | #if !defined(ZIG_PPC32) && !defined(__hexagon__) && !defined(__s390x__) |
| 2895 | 2903 | { |
| ... | ... | @@ -2908,15 +2916,18 @@ void run_c_tests(void) { |
| 2908 | 2916 | } |
| 2909 | 2917 | |
| 2910 | 2918 | #if !defined(__mips64__) |
| 2919 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2911 | 2920 | { |
| 2912 | 2921 | struct Struct_f32 s = zig_ret_struct_f32(); |
| 2913 | 2922 | assert_or_panic(s.a == 2.5f); |
| 2914 | 2923 | zig_struct_f32((struct Struct_f32){ .a = 2.5f }); |
| 2915 | 2924 | } |
| 2916 | 2925 | #endif |
| 2926 | #endif | |
| 2917 | 2927 | |
| 2918 | 2928 | #if !(defined(__arm__) && defined(__SOFTFP__)) |
| 2919 | 2929 | #if !defined(ZIG_RISCV32) |
| 2930 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2920 | 2931 | { |
| 2921 | 2932 | struct Struct_f64 s = zig_ret_struct_f64(); |
| 2922 | 2933 | assert_or_panic(s.a == 2.5); |
| ... | ... | @@ -2924,6 +2935,7 @@ void run_c_tests(void) { |
| 2924 | 2935 | } |
| 2925 | 2936 | #endif |
| 2926 | 2937 | #endif |
| 2938 | #endif | |
| 2927 | 2939 | |
| 2928 | 2940 | #if !defined(__arm__) |
| 2929 | 2941 | #if !defined(__loongarch__) |
| ... | ... | @@ -2987,6 +2999,7 @@ void run_c_tests(void) { |
| 2987 | 2999 | #endif |
| 2988 | 3000 | |
| 2989 | 3001 | #if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) |
| 3002 | #if !(defined(_WIN32) && defined(__i386__)) | |
| 2990 | 3003 | { |
| 2991 | 3004 | struct Struct_u32_Union_u32_u32u32 s = zig_ret_struct_u32_union_u32_u32u32(); |
| 2992 | 3005 | assert_or_panic(s.a == 1); |
| ... | ... | @@ -3000,6 +3013,7 @@ void run_c_tests(void) { |
| 3000 | 3013 | zig_struct_i32_i32(s); |
| 3001 | 3014 | } |
| 3002 | 3015 | #endif |
| 3016 | #endif | |
| 3003 | 3017 | |
| 3004 | 3018 | #if !defined(__powerpc64__) && !defined(__loongarch__) && !defined(__mips64__) |
| 3005 | 3019 | { |
test/c_abi/main.zig+12| ... | ... | @@ -291,6 +291,7 @@ test "C ABI struct u8" { |
| 291 | 291 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 292 | 292 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 293 | 293 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 294 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 294 | 295 | |
| 295 | 296 | const s = c_ret_struct_u8(); |
| 296 | 297 | try expect(s.a == 4); |
| ... | ... | @@ -318,6 +319,7 @@ test "C ABI struct u16" { |
| 318 | 319 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 319 | 320 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 320 | 321 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 322 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 321 | 323 | |
| 322 | 324 | const s = c_ret_struct_u16(); |
| 323 | 325 | try expect(s.a == 10); |
| ... | ... | @@ -345,6 +347,7 @@ test "C ABI struct u32" { |
| 345 | 347 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 346 | 348 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 347 | 349 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 350 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 348 | 351 | |
| 349 | 352 | const s = c_ret_struct_u32(); |
| 350 | 353 | try expect(s.a == 16); |
| ... | ... | @@ -372,6 +375,7 @@ test "C ABI struct u64" { |
| 372 | 375 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 373 | 376 | if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; |
| 374 | 377 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 378 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 375 | 379 | |
| 376 | 380 | const s = c_ret_struct_u64(); |
| 377 | 381 | try expect(s.a == 22); |
| ... | ... | @@ -485,6 +489,7 @@ test "C ABI struct f32" { |
| 485 | 489 | if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest; |
| 486 | 490 | if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 487 | 491 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 492 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 488 | 493 | |
| 489 | 494 | const s = c_ret_struct_f32(); |
| 490 | 495 | try expect(s.a == 2.5); |
| ... | ... | @@ -513,6 +518,7 @@ test "C ABI struct f64" { |
| 513 | 518 | if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; |
| 514 | 519 | if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; |
| 515 | 520 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 521 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 516 | 522 | |
| 517 | 523 | const s = c_ret_struct_f64(); |
| 518 | 524 | try expect(s.a == 2.5); |
| ... | ... | @@ -705,6 +711,7 @@ test "C ABI struct i32 i32" { |
| 705 | 711 | if (builtin.cpu.arch == .riscv32) return error.SkipZigTest; |
| 706 | 712 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; |
| 707 | 713 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 714 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 708 | 715 | |
| 709 | 716 | const s: Struct_i32_i32 = .{ |
| 710 | 717 | .a = 1, |
| ... | ... | @@ -5681,6 +5688,7 @@ test "C ABI pointer sized float struct" { |
| 5681 | 5688 | if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest; |
| 5682 | 5689 | if (builtin.cpu.arch.isLoongArch() and builtin.abi.float() == .soft) return error.SkipZigTest; |
| 5683 | 5690 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 5691 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 5684 | 5692 | |
| 5685 | 5693 | c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); |
| 5686 | 5694 | |
| ... | ... | @@ -5812,6 +5820,7 @@ test "PD: Zig passes to C" { |
| 5812 | 5820 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; |
| 5813 | 5821 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| 5814 | 5822 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 5823 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 5815 | 5824 | try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 })); |
| 5816 | 5825 | } |
| 5817 | 5826 | test "PD: Zig returns to C" { |
| ... | ... | @@ -5827,6 +5836,7 @@ test "PD: C passes to Zig" { |
| 5827 | 5836 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; |
| 5828 | 5837 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| 5829 | 5838 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 5839 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 5830 | 5840 | try expectOk(c_send_PD()); |
| 5831 | 5841 | } |
| 5832 | 5842 | test "PD: C returns to Zig" { |
| ... | ... | @@ -5936,6 +5946,7 @@ test "f16 struct" { |
| 5936 | 5946 | if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest; |
| 5937 | 5947 | if (builtin.cpu.arch.isArm() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5938 | 5948 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 5949 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 5939 | 5950 | |
| 5940 | 5951 | const a = c_f16_struct(.{ .a = 12 }); |
| 5941 | 5952 | try expect(a.a == 34); |
| ... | ... | @@ -6045,6 +6056,7 @@ test "Stdcall ABI structs" { |
| 6045 | 6056 | if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest; |
| 6046 | 6057 | if (builtin.cpu.arch == .hexagon) return error.SkipZigTest; |
| 6047 | 6058 | if (builtin.cpu.arch == .s390x) return error.SkipZigTest; |
| 6059 | if (builtin.cpu.arch == .x86 and builtin.os.tag == .windows) return error.SkipZigTest; | |
| 6048 | 6060 | |
| 6049 | 6061 | const res = stdcall_coord2( |
| 6050 | 6062 | .{ .x = 0x1111, .y = 0x2222 }, |
test/tests.zig+67-58| ... | ... | @@ -1611,8 +1611,6 @@ const module_test_targets = blk: { |
| 1611 | 1611 | .abi = .msvc, |
| 1612 | 1612 | }, |
| 1613 | 1613 | .link_libc = true, |
| 1614 | // https://codeberg.org/ziglang/zig/issues/35517 | |
| 1615 | .skip_modules = &.{"libc"}, | |
| 1616 | 1614 | }, |
| 1617 | 1615 | .{ |
| 1618 | 1616 | .target = .{ |
| ... | ... | @@ -1628,8 +1626,6 @@ const module_test_targets = blk: { |
| 1628 | 1626 | .abi = .gnu, |
| 1629 | 1627 | }, |
| 1630 | 1628 | .link_libc = true, |
| 1631 | // https://codeberg.org/ziglang/zig/issues/35517 | |
| 1632 | .skip_modules = &.{"libc"}, | |
| 1633 | 1629 | }, |
| 1634 | 1630 | |
| 1635 | 1631 | .{ |
| ... | ... | @@ -1657,8 +1653,6 @@ const module_test_targets = blk: { |
| 1657 | 1653 | .abi = .msvc, |
| 1658 | 1654 | }, |
| 1659 | 1655 | .link_libc = true, |
| 1660 | // https://codeberg.org/ziglang/zig/issues/35517 | |
| 1661 | .skip_modules = &.{"libc"}, | |
| 1662 | 1656 | }, |
| 1663 | 1657 | .{ |
| 1664 | 1658 | .target = .{ |
| ... | ... | @@ -2001,14 +1995,13 @@ const c_abi_targets = blk: { |
| 2001 | 1995 | |
| 2002 | 1996 | // Windows Targets |
| 2003 | 1997 | |
| 2004 | // https://codeberg.org/ziglang/zig/issues/35521 | |
| 2005 | //.{ | |
| 2006 | // .target = .{ | |
| 2007 | // .cpu_arch = .x86, | |
| 2008 | // .os_tag = .windows, | |
| 2009 | // .abi = .gnu, | |
| 2010 | // }, | |
| 2011 | //}, | |
| 1998 | .{ | |
| 1999 | .target = .{ | |
| 2000 | .cpu_arch = .x86, | |
| 2001 | .os_tag = .windows, | |
| 2002 | .abi = .gnu, | |
| 2003 | }, | |
| 2004 | }, | |
| 2012 | 2005 | .{ |
| 2013 | 2006 | .target = .{ |
| 2014 | 2007 | .cpu_arch = .x86_64, |
| ... | ... | @@ -2650,11 +2643,6 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step { |
| 2650 | 2643 | |
| 2651 | 2644 | const target = &resolved_target.result; |
| 2652 | 2645 | |
| 2653 | if (target.cpu.arch == .powerpc64le and target.ofmt == .c) { | |
| 2654 | // https://codeberg.org/ziglang/zig/issues/35522 | |
| 2655 | continue; | |
| 2656 | } | |
| 2657 | ||
| 2658 | 2646 | if (target.cpu.arch == .s390x and target.ofmt == .c) { |
| 2659 | 2647 | // https://codeberg.org/ziglang/zig/issues/35523 |
| 2660 | 2648 | continue; |
| ... | ... | @@ -2811,45 +2799,66 @@ fn addOneModuleTest( |
| 2811 | 2799 | |
| 2812 | 2800 | compile_c.addCSourceFile(.{ |
| 2813 | 2801 | .file = these_tests.getEmittedBin(), |
| 2814 | .flags = &.{ | |
| 2815 | // Tracking issue for making the C backend generate C89 compatible code: | |
| 2816 | // https://github.com/ziglang/zig/issues/19468 | |
| 2817 | "-std=c99", | |
| 2818 | "-Werror", | |
| 2819 | ||
| 2820 | "-Wall", | |
| 2821 | "-Wembedded-directive", | |
| 2822 | "-Wempty-translation-unit", | |
| 2823 | "-Wextra", | |
| 2824 | "-Wgnu", | |
| 2825 | "-Winvalid-utf8", | |
| 2826 | "-Wkeyword-macro", | |
| 2827 | "-Woverlength-strings", | |
| 2828 | ||
| 2829 | // Tracking issue for making the C backend generate code | |
| 2830 | // that does not trigger warnings: | |
| 2831 | // https://github.com/ziglang/zig/issues/19467 | |
| 2832 | ||
| 2833 | // spotted everywhere | |
| 2834 | "-Wno-builtin-requires-header", | |
| 2835 | ||
| 2836 | // spotted on linux | |
| 2837 | "-Wno-braced-scalar-init", | |
| 2838 | "-Wno-excess-initializers", | |
| 2839 | "-Wno-incompatible-pointer-types-discards-qualifiers", | |
| 2840 | "-Wno-unused", | |
| 2841 | "-Wno-unused-parameter", | |
| 2842 | ||
| 2843 | // spotted on darwin | |
| 2844 | "-Wno-incompatible-pointer-types", | |
| 2845 | ||
| 2846 | // https://github.com/llvm/llvm-project/issues/153314 | |
| 2847 | "-Wno-unterminated-string-initialization", | |
| 2848 | ||
| 2849 | // In both Zig and C it is legal to return a pointer to a | |
| 2850 | // local. The C backend lowers such thing directly, so the | |
| 2851 | // corresponding warning in C must be disabled. | |
| 2852 | "-Wno-return-stack-address", | |
| 2802 | .flags = blk: { | |
| 2803 | const invariant_cflags: []const []const u8 = &.{ | |
| 2804 | // Tracking issue for making the C backend generate C89 compatible code: | |
| 2805 | // https://github.com/ziglang/zig/issues/19468 | |
| 2806 | "-std=c99", | |
| 2807 | "-Werror", | |
| 2808 | ||
| 2809 | "-Wall", | |
| 2810 | "-Wembedded-directive", | |
| 2811 | "-Wempty-translation-unit", | |
| 2812 | "-Wextra", | |
| 2813 | "-Wgnu", | |
| 2814 | "-Winvalid-utf8", | |
| 2815 | "-Wkeyword-macro", | |
| 2816 | "-Woverlength-strings", | |
| 2817 | ||
| 2818 | // Tracking issue for making the C backend generate code | |
| 2819 | // that does not trigger warnings: | |
| 2820 | // https://github.com/ziglang/zig/issues/19467 | |
| 2821 | ||
| 2822 | // spotted everywhere | |
| 2823 | "-Wno-builtin-requires-header", | |
| 2824 | ||
| 2825 | // spotted on linux | |
| 2826 | "-Wno-braced-scalar-init", | |
| 2827 | "-Wno-excess-initializers", | |
| 2828 | "-Wno-incompatible-pointer-types-discards-qualifiers", | |
| 2829 | "-Wno-unused", | |
| 2830 | "-Wno-unused-parameter", | |
| 2831 | ||
| 2832 | // spotted on darwin | |
| 2833 | "-Wno-incompatible-pointer-types", | |
| 2834 | ||
| 2835 | // https://github.com/llvm/llvm-project/issues/153314 | |
| 2836 | "-Wno-unterminated-string-initialization", | |
| 2837 | ||
| 2838 | // In both Zig and C it is legal to return a pointer to a | |
| 2839 | // local. The C backend lowers such thing directly, so the | |
| 2840 | // corresponding warning in C must be disabled. | |
| 2841 | "-Wno-return-stack-address", | |
| 2842 | }; | |
| 2843 | ||
| 2844 | const function_data_sections = switch (target.cpu.arch) { | |
| 2845 | .arm, | |
| 2846 | .armeb, | |
| 2847 | .thumb, | |
| 2848 | .thumbeb, | |
| 2849 | .hexagon, | |
| 2850 | .powerpc, | |
| 2851 | .powerpcle, | |
| 2852 | .powerpc64, | |
| 2853 | .powerpc64le, | |
| 2854 | => true, | |
| 2855 | else => false, | |
| 2856 | }; | |
| 2857 | ||
| 2858 | break :blk if (function_data_sections) invariant_cflags ++ &[_][]const u8{ | |
| 2859 | "-ffunction-sections", | |
| 2860 | "-fdata-sections", | |
| 2861 | } else invariant_cflags; | |
| 2853 | 2862 | }, |
| 2854 | 2863 | }); |
| 2855 | 2864 | compile_c.addIncludePath(b.path("lib")); // for zig.h |