| ... | ... | @@ -49,6 +49,8 @@ export fn zig_five_integers(a: i32, b: i32, c: i32, d: i32, e: i32) void { |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | test "C ABI integers" { |
| 52 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 53 | |
| 52 | 54 | c_u8(0xff); |
| 53 | 55 | c_u16(0xfffe); |
| 54 | 56 | c_u32(0xfffffffd); |
| ... | ... | @@ -185,6 +187,8 @@ const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.is |
| 185 | 187 | !builtin.cpu.arch.isARM() and !builtin.cpu.arch.isPPC() and !builtin.cpu.arch.isRISCV(); |
| 186 | 188 | |
| 187 | 189 | test "C ABI complex float" { |
| 190 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 191 | |
| 188 | 192 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 189 | 193 | if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465 |
| 190 | 194 | |
| ... | ... | @@ -197,6 +201,8 @@ test "C ABI complex float" { |
| 197 | 201 | } |
| 198 | 202 | |
| 199 | 203 | test "C ABI complex float by component" { |
| 204 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 205 | |
| 200 | 206 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 201 | 207 | |
| 202 | 208 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; |
| ... | ... | @@ -208,6 +214,8 @@ test "C ABI complex float by component" { |
| 208 | 214 | } |
| 209 | 215 | |
| 210 | 216 | test "C ABI complex double" { |
| 217 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 218 | |
| 211 | 219 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 212 | 220 | |
| 213 | 221 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; |
| ... | ... | @@ -219,6 +227,8 @@ test "C ABI complex double" { |
| 219 | 227 | } |
| 220 | 228 | |
| 221 | 229 | test "C ABI complex double by component" { |
| 230 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 231 | |
| 222 | 232 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 223 | 233 | |
| 224 | 234 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; |
| ... | ... | @@ -230,6 +240,8 @@ test "C ABI complex double by component" { |
| 230 | 240 | } |
| 231 | 241 | |
| 232 | 242 | export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat { |
| 243 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 244 | |
| 233 | 245 | expect(a.real == 1.25) catch @panic("test failure: zig_cmultf 1"); |
| 234 | 246 | expect(a.imag == 2.6) catch @panic("test failure: zig_cmultf 2"); |
| 235 | 247 | expect(b.real == 11.3) catch @panic("test failure: zig_cmultf 3"); |
| ... | ... | @@ -239,6 +251,8 @@ export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat { |
| 239 | 251 | } |
| 240 | 252 | |
| 241 | 253 | export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble { |
| 254 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 255 | |
| 242 | 256 | expect(a.real == 1.25) catch @panic("test failure: zig_cmultd 1"); |
| 243 | 257 | expect(a.imag == 2.6) catch @panic("test failure: zig_cmultd 2"); |
| 244 | 258 | expect(b.real == 11.3) catch @panic("test failure: zig_cmultd 3"); |
| ... | ... | @@ -248,6 +262,8 @@ export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble { |
| 248 | 262 | } |
| 249 | 263 | |
| 250 | 264 | export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat { |
| 265 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 266 | |
| 251 | 267 | expect(a_r == 1.25) catch @panic("test failure: zig_cmultf_comp 1"); |
| 252 | 268 | expect(a_i == 2.6) catch @panic("test failure: zig_cmultf_comp 2"); |
| 253 | 269 | expect(b_r == 11.3) catch @panic("test failure: zig_cmultf_comp 3"); |
| ... | ... | @@ -257,6 +273,8 @@ export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat { |
| 257 | 273 | } |
| 258 | 274 | |
| 259 | 275 | export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble { |
| 276 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 277 | |
| 260 | 278 | expect(a_r == 1.25) catch @panic("test failure: zig_cmultd_comp 1"); |
| 261 | 279 | expect(a_i == 2.6) catch @panic("test failure: zig_cmultd_comp 2"); |
| 262 | 280 | expect(b_r == 11.3) catch @panic("test failure: zig_cmultd_comp 3"); |
| ... | ... | @@ -334,6 +352,8 @@ extern fn c_med_struct_mixed(MedStructMixed) void; |
| 334 | 352 | extern fn c_ret_med_struct_mixed() MedStructMixed; |
| 335 | 353 | |
| 336 | 354 | test "C ABI medium struct of ints and floats" { |
| 355 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 356 | |
| 337 | 357 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 338 | 358 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 339 | 359 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -402,6 +422,8 @@ extern fn c_med_struct_ints(MedStructInts) void; |
| 402 | 422 | extern fn c_ret_med_struct_ints() MedStructInts; |
| 403 | 423 | |
| 404 | 424 | test "C ABI medium struct of ints" { |
| 425 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 426 | |
| 405 | 427 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 406 | 428 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 407 | 429 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -509,6 +531,8 @@ extern fn c_split_struct_mixed(SplitStructMixed) void; |
| 509 | 531 | extern fn c_ret_split_struct_mixed() SplitStructMixed; |
| 510 | 532 | |
| 511 | 533 | test "C ABI split struct of ints and floats" { |
| 534 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 535 | |
| 512 | 536 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 513 | 537 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 514 | 538 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -590,6 +614,8 @@ const Vector5 = extern struct { |
| 590 | 614 | extern fn c_big_struct_floats(Vector5) void; |
| 591 | 615 | |
| 592 | 616 | test "C ABI structs of floats as parameter" { |
| 617 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 618 | |
| 593 | 619 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 594 | 620 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 595 | 621 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| ... | ... | @@ -657,6 +683,8 @@ const FloatRect = extern struct { |
| 657 | 683 | }; |
| 658 | 684 | |
| 659 | 685 | export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { |
| 686 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 687 | |
| 660 | 688 | expect(x.left == 1) catch @panic("test failure"); |
| 661 | 689 | expect(x.right == 21) catch @panic("test failure"); |
| 662 | 690 | expect(x.top == 16) catch @panic("test failure"); |
| ... | ... | @@ -668,6 +696,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { |
| 668 | 696 | } |
| 669 | 697 | |
| 670 | 698 | test "C ABI structs of floats as multiple parameters" { |
| 699 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 700 | |
| 671 | 701 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 672 | 702 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 673 | 703 | |
| ... | ... | @@ -724,6 +754,8 @@ export fn zig_ret_small_struct_ints() SmallStructInts { |
| 724 | 754 | } |
| 725 | 755 | |
| 726 | 756 | export fn zig_ret_med_struct_ints() MedStructInts { |
| 757 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 758 | |
| 727 | 759 | return .{ |
| 728 | 760 | .x = 1, |
| 729 | 761 | .y = 2, |
| ... | ... | @@ -732,6 +764,8 @@ export fn zig_ret_med_struct_ints() MedStructInts { |
| 732 | 764 | } |
| 733 | 765 | |
| 734 | 766 | export fn zig_ret_med_struct_mixed() MedStructMixed { |
| 767 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 768 | |
| 735 | 769 | return .{ |
| 736 | 770 | .a = 1234, |
| 737 | 771 | .b = 100.0, |
| ... | ... | @@ -740,6 +774,8 @@ export fn zig_ret_med_struct_mixed() MedStructMixed { |
| 740 | 774 | } |
| 741 | 775 | |
| 742 | 776 | export fn zig_ret_split_struct_mixed() SplitStructMixed { |
| 777 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 778 | |
| 743 | 779 | return .{ |
| 744 | 780 | .a = 1234, |
| 745 | 781 | .b = 100, |
| ... | ... | @@ -780,6 +816,8 @@ extern fn c_struct_with_array(StructWithArray) void; |
| 780 | 816 | extern fn c_ret_struct_with_array() StructWithArray; |
| 781 | 817 | |
| 782 | 818 | test "Struct with array as padding." { |
| 819 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 820 | |
| 783 | 821 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 784 | 822 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 785 | 823 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -851,6 +889,8 @@ extern fn c_medium_vec(MediumVec) void; |
| 851 | 889 | extern fn c_ret_medium_vec() MediumVec; |
| 852 | 890 | |
| 853 | 891 | test "medium simd vector" { |
| 892 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 893 | |
| 854 | 894 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 855 | 895 | |
| 856 | 896 | c_medium_vec(.{ 1, 2, 3, 4 }); |
| ... | ... | @@ -868,6 +908,8 @@ extern fn c_big_vec(BigVec) void; |
| 868 | 908 | extern fn c_ret_big_vec() BigVec; |
| 869 | 909 | |
| 870 | 910 | test "big simd vector" { |
| 911 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 912 | |
| 871 | 913 | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 872 | 914 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 873 | 915 | if (builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest; |
| ... | ... | @@ -891,6 +933,8 @@ extern fn c_ptr_size_float_struct(Vector2) void; |
| 891 | 933 | extern fn c_ret_ptr_size_float_struct() Vector2; |
| 892 | 934 | |
| 893 | 935 | test "C ABI pointer sized float struct" { |
| 936 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 937 | |
| 894 | 938 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 895 | 939 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 896 | 940 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| ... | ... | @@ -914,6 +958,8 @@ pub inline fn expectOk(c_err: c_int) !void { |
| 914 | 958 | /// Tests for Double + Char struct |
| 915 | 959 | const DC = extern struct { v1: f64, v2: u8 }; |
| 916 | 960 | test "DC: Zig passes to C" { |
| 961 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 962 | |
| 917 | 963 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 918 | 964 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 919 | 965 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -921,6 +967,8 @@ test "DC: Zig passes to C" { |
| 921 | 967 | try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 })); |
| 922 | 968 | } |
| 923 | 969 | test "DC: Zig returns to C" { |
| 970 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 971 | |
| 924 | 972 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 925 | 973 | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 926 | 974 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| ... | ... | @@ -929,6 +977,8 @@ test "DC: Zig returns to C" { |
| 929 | 977 | try expectOk(c_assert_ret_DC()); |
| 930 | 978 | } |
| 931 | 979 | test "DC: C passes to Zig" { |
| 980 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 981 | |
| 932 | 982 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 933 | 983 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 934 | 984 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -936,6 +986,8 @@ test "DC: C passes to Zig" { |
| 936 | 986 | try expectOk(c_send_DC()); |
| 937 | 987 | } |
| 938 | 988 | test "DC: C returns to Zig" { |
| 989 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 990 | |
| 939 | 991 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 940 | 992 | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 941 | 993 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| ... | ... | @@ -949,6 +1001,8 @@ pub extern fn c_assert_ret_DC() c_int; |
| 949 | 1001 | pub extern fn c_send_DC() c_int; |
| 950 | 1002 | pub extern fn c_ret_DC() DC; |
| 951 | 1003 | pub export fn zig_assert_DC(lv: DC) c_int { |
| 1004 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1005 | |
| 952 | 1006 | var err: c_int = 0; |
| 953 | 1007 | if (lv.v1 != -0.25) err = 1; |
| 954 | 1008 | if (lv.v2 != 15) err = 2; |
| ... | ... | @@ -956,6 +1010,8 @@ pub export fn zig_assert_DC(lv: DC) c_int { |
| 956 | 1010 | return err; |
| 957 | 1011 | } |
| 958 | 1012 | pub export fn zig_ret_DC() DC { |
| 1013 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1014 | |
| 959 | 1015 | return .{ .v1 = -0.25, .v2 = 15 }; |
| 960 | 1016 | } |
| 961 | 1017 | |
| ... | ... | @@ -963,6 +1019,8 @@ pub export fn zig_ret_DC() DC { |
| 963 | 1019 | const CFF = extern struct { v1: u8, v2: f32, v3: f32 }; |
| 964 | 1020 | |
| 965 | 1021 | test "CFF: Zig passes to C" { |
| 1022 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1023 | |
| 966 | 1024 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 967 | 1025 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 968 | 1026 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -970,6 +1028,8 @@ test "CFF: Zig passes to C" { |
| 970 | 1028 | try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 })); |
| 971 | 1029 | } |
| 972 | 1030 | test "CFF: Zig returns to C" { |
| 1031 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1032 | |
| 973 | 1033 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 974 | 1034 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 975 | 1035 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -977,6 +1037,8 @@ test "CFF: Zig returns to C" { |
| 977 | 1037 | try expectOk(c_assert_ret_CFF()); |
| 978 | 1038 | } |
| 979 | 1039 | test "CFF: C passes to Zig" { |
| 1040 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1041 | |
| 980 | 1042 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 981 | 1043 | if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; |
| 982 | 1044 | if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest; |
| ... | ... | @@ -987,6 +1049,8 @@ test "CFF: C passes to Zig" { |
| 987 | 1049 | try expectOk(c_send_CFF()); |
| 988 | 1050 | } |
| 989 | 1051 | test "CFF: C returns to Zig" { |
| 1052 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1053 | |
| 990 | 1054 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 991 | 1055 | if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest; |
| 992 | 1056 | if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; |
| ... | ... | @@ -1000,6 +1064,8 @@ pub extern fn c_assert_ret_CFF() c_int; |
| 1000 | 1064 | pub extern fn c_send_CFF() c_int; |
| 1001 | 1065 | pub extern fn c_ret_CFF() CFF; |
| 1002 | 1066 | pub export fn zig_assert_CFF(lv: CFF) c_int { |
| 1067 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1068 | |
| 1003 | 1069 | var err: c_int = 0; |
| 1004 | 1070 | if (lv.v1 != 39) err = 1; |
| 1005 | 1071 | if (lv.v2 != 0.875) err = 2; |
| ... | ... | @@ -1008,6 +1074,8 @@ pub export fn zig_assert_CFF(lv: CFF) c_int { |
| 1008 | 1074 | return err; |
| 1009 | 1075 | } |
| 1010 | 1076 | pub export fn zig_ret_CFF() CFF { |
| 1077 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1078 | |
| 1011 | 1079 | return .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }; |
| 1012 | 1080 | } |
| 1013 | 1081 | |
| ... | ... | @@ -1015,6 +1083,8 @@ pub export fn zig_ret_CFF() CFF { |
| 1015 | 1083 | const PD = extern struct { v1: ?*anyopaque, v2: f64 }; |
| 1016 | 1084 | |
| 1017 | 1085 | test "PD: Zig passes to C" { |
| 1086 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1087 | |
| 1018 | 1088 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 1019 | 1089 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 1020 | 1090 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -1022,6 +1092,8 @@ test "PD: Zig passes to C" { |
| 1022 | 1092 | try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 })); |
| 1023 | 1093 | } |
| 1024 | 1094 | test "PD: Zig returns to C" { |
| 1095 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1096 | |
| 1025 | 1097 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 1026 | 1098 | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 1027 | 1099 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -1029,6 +1101,8 @@ test "PD: Zig returns to C" { |
| 1029 | 1101 | try expectOk(c_assert_ret_PD()); |
| 1030 | 1102 | } |
| 1031 | 1103 | test "PD: C passes to Zig" { |
| 1104 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1105 | |
| 1032 | 1106 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 1033 | 1107 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 1034 | 1108 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -1036,6 +1110,8 @@ test "PD: C passes to Zig" { |
| 1036 | 1110 | try expectOk(c_send_PD()); |
| 1037 | 1111 | } |
| 1038 | 1112 | test "PD: C returns to Zig" { |
| 1113 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1114 | |
| 1039 | 1115 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 1040 | 1116 | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 1041 | 1117 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| ... | ... | @@ -1047,6 +1123,8 @@ pub extern fn c_assert_ret_PD() c_int; |
| 1047 | 1123 | pub extern fn c_send_PD() c_int; |
| 1048 | 1124 | pub extern fn c_ret_PD() PD; |
| 1049 | 1125 | pub export fn zig_c_assert_PD(lv: PD) c_int { |
| 1126 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1127 | |
| 1050 | 1128 | var err: c_int = 0; |
| 1051 | 1129 | if (lv.v1 != null) err = 1; |
| 1052 | 1130 | if (lv.v2 != 0.5) err = 2; |
| ... | ... | @@ -1054,9 +1132,13 @@ pub export fn zig_c_assert_PD(lv: PD) c_int { |
| 1054 | 1132 | return err; |
| 1055 | 1133 | } |
| 1056 | 1134 | pub export fn zig_ret_PD() PD { |
| 1135 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1136 | |
| 1057 | 1137 | return .{ .v1 = null, .v2 = 0.5 }; |
| 1058 | 1138 | } |
| 1059 | 1139 | pub export fn zig_assert_PD(lv: PD) c_int { |
| 1140 | if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest"); |
| 1141 | |
| 1060 | 1142 | var err: c_int = 0; |
| 1061 | 1143 | if (lv.v1 != null) err = 1; |
| 1062 | 1144 | if (lv.v2 != 0.5) err = 2; |
| ... | ... | @@ -1146,6 +1228,8 @@ const f80_struct = extern struct { |
| 1146 | 1228 | }; |
| 1147 | 1229 | extern fn c_f80_struct(f80_struct) f80_struct; |
| 1148 | 1230 | test "f80 struct" { |
| 1231 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1232 | |
| 1149 | 1233 | if (!has_f80) return error.SkipZigTest; |
| 1150 | 1234 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 1151 | 1235 | if (builtin.mode != .Debug) return error.SkipZigTest; |
| ... | ... | @@ -1233,6 +1317,8 @@ test "Stdcall ABI big union" { |
| 1233 | 1317 | |
| 1234 | 1318 | extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef; |
| 1235 | 1319 | test "explicit SysV calling convention" { |
| 1320 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 1321 | |
| 1236 | 1322 | if (builtin.cpu.arch != .x86_64) return error.SkipZigTest; |
| 1237 | 1323 | |
| 1238 | 1324 | const res = c_explict_win64(.{ .val = 1, .arr = undefined }); |