| ... | ... | @@ -123,8 +123,8 @@ test "C ABI floats" { |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | test "C ABI long double" { |
| 126 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 127 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 126 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 127 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 128 | 128 | |
| 129 | 129 | c_long_double(12.34); |
| 130 | 130 | } |
| ... | ... | @@ -265,6 +265,83 @@ export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble |
| 265 | 265 | return .{ .real = 1.5, .imag = 13.5 }; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | const Struct_u64_u64 = extern struct { |
| 269 | a: u64, |
| 270 | b: u64, |
| 271 | }; |
| 272 | |
| 273 | export fn zig_ret_struct_u64_u64() Struct_u64_u64 { |
| 274 | return .{ .a = 1, .b = 2 }; |
| 275 | } |
| 276 | export fn zig_struct_u64_u64_0(s: Struct_u64_u64) void { |
| 277 | expect(s.a == 3) catch @panic("test failure"); |
| 278 | expect(s.b == 4) catch @panic("test failure"); |
| 279 | } |
| 280 | export fn zig_struct_u64_u64_1(_: usize, s: Struct_u64_u64) void { |
| 281 | expect(s.a == 5) catch @panic("test failure"); |
| 282 | expect(s.b == 6) catch @panic("test failure"); |
| 283 | } |
| 284 | export fn zig_struct_u64_u64_2(_: usize, _: usize, s: Struct_u64_u64) void { |
| 285 | expect(s.a == 7) catch @panic("test failure"); |
| 286 | expect(s.b == 8) catch @panic("test failure"); |
| 287 | } |
| 288 | export fn zig_struct_u64_u64_3(_: usize, _: usize, _: usize, s: Struct_u64_u64) void { |
| 289 | expect(s.a == 9) catch @panic("test failure"); |
| 290 | expect(s.b == 10) catch @panic("test failure"); |
| 291 | } |
| 292 | export fn zig_struct_u64_u64_4(_: usize, _: usize, _: usize, _: usize, s: Struct_u64_u64) void { |
| 293 | expect(s.a == 11) catch @panic("test failure"); |
| 294 | expect(s.b == 12) catch @panic("test failure"); |
| 295 | } |
| 296 | export fn zig_struct_u64_u64_5(_: usize, _: usize, _: usize, _: usize, _: usize, s: Struct_u64_u64) void { |
| 297 | expect(s.a == 13) catch @panic("test failure"); |
| 298 | expect(s.b == 14) catch @panic("test failure"); |
| 299 | } |
| 300 | export fn zig_struct_u64_u64_6(_: usize, _: usize, _: usize, _: usize, _: usize, _: usize, s: Struct_u64_u64) void { |
| 301 | expect(s.a == 15) catch @panic("test failure"); |
| 302 | expect(s.b == 16) catch @panic("test failure"); |
| 303 | } |
| 304 | export fn zig_struct_u64_u64_7(_: usize, _: usize, _: usize, _: usize, _: usize, _: usize, _: usize, s: Struct_u64_u64) void { |
| 305 | expect(s.a == 17) catch @panic("test failure"); |
| 306 | expect(s.b == 18) catch @panic("test failure"); |
| 307 | } |
| 308 | export fn zig_struct_u64_u64_8(_: usize, _: usize, _: usize, _: usize, _: usize, _: usize, _: usize, _: usize, s: Struct_u64_u64) void { |
| 309 | expect(s.a == 19) catch @panic("test failure"); |
| 310 | expect(s.b == 20) catch @panic("test failure"); |
| 311 | } |
| 312 | |
| 313 | extern fn c_ret_struct_u64_u64() Struct_u64_u64; |
| 314 | |
| 315 | extern fn c_struct_u64_u64_0(Struct_u64_u64) void; |
| 316 | extern fn c_struct_u64_u64_1(usize, Struct_u64_u64) void; |
| 317 | extern fn c_struct_u64_u64_2(usize, usize, Struct_u64_u64) void; |
| 318 | extern fn c_struct_u64_u64_3(usize, usize, usize, Struct_u64_u64) void; |
| 319 | extern fn c_struct_u64_u64_4(usize, usize, usize, usize, Struct_u64_u64) void; |
| 320 | extern fn c_struct_u64_u64_5(usize, usize, usize, usize, usize, Struct_u64_u64) void; |
| 321 | extern fn c_struct_u64_u64_6(usize, usize, usize, usize, usize, usize, Struct_u64_u64) void; |
| 322 | extern fn c_struct_u64_u64_7(usize, usize, usize, usize, usize, usize, usize, Struct_u64_u64) void; |
| 323 | extern fn c_struct_u64_u64_8(usize, usize, usize, usize, usize, usize, usize, usize, Struct_u64_u64) void; |
| 324 | |
| 325 | test "C ABI struct u64 u64" { |
| 326 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 327 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 328 | |
| 329 | { |
| 330 | const s = c_ret_struct_u64_u64(); |
| 331 | try expect(s.a == 21); |
| 332 | try expect(s.b == 22); |
| 333 | } |
| 334 | c_struct_u64_u64_0(.{ .a = 23, .b = 24 }); |
| 335 | c_struct_u64_u64_1(0, .{ .a = 25, .b = 26 }); |
| 336 | c_struct_u64_u64_2(0, 1, .{ .a = 27, .b = 28 }); |
| 337 | c_struct_u64_u64_3(0, 1, 2, .{ .a = 29, .b = 30 }); |
| 338 | c_struct_u64_u64_4(0, 1, 2, 3, .{ .a = 31, .b = 32 }); |
| 339 | c_struct_u64_u64_5(0, 1, 2, 3, 4, .{ .a = 33, .b = 34 }); |
| 340 | c_struct_u64_u64_6(0, 1, 2, 3, 4, 5, .{ .a = 35, .b = 36 }); |
| 341 | c_struct_u64_u64_7(0, 1, 2, 3, 4, 5, 6, .{ .a = 37, .b = 38 }); |
| 342 | c_struct_u64_u64_8(0, 1, 2, 3, 4, 5, 6, 7, .{ .a = 39, .b = 40 }); |
| 343 | } |
| 344 | |
| 268 | 345 | const BigStruct = extern struct { |
| 269 | 346 | a: u64, |
| 270 | 347 | b: u64, |
| ... | ... | @@ -275,8 +352,8 @@ const BigStruct = extern struct { |
| 275 | 352 | extern fn c_big_struct(BigStruct) void; |
| 276 | 353 | |
| 277 | 354 | test "C ABI big struct" { |
| 278 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 279 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 355 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 356 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 280 | 357 | |
| 281 | 358 | const s = BigStruct{ |
| 282 | 359 | .a = 1, |
| ... | ... | @@ -302,7 +379,7 @@ const BigUnion = extern union { |
| 302 | 379 | extern fn c_big_union(BigUnion) void; |
| 303 | 380 | |
| 304 | 381 | test "C ABI big union" { |
| 305 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 382 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 306 | 383 | |
| 307 | 384 | const x = BigUnion{ |
| 308 | 385 | .a = BigStruct{ |
| ... | ... | @@ -335,9 +412,9 @@ extern fn c_ret_med_struct_mixed() MedStructMixed; |
| 335 | 412 | |
| 336 | 413 | test "C ABI medium struct of ints and floats" { |
| 337 | 414 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 338 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 339 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 340 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 415 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 416 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 417 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 341 | 418 | |
| 342 | 419 | const s = MedStructMixed{ |
| 343 | 420 | .a = 1234, |
| ... | ... | @@ -368,9 +445,9 @@ extern fn c_ret_small_struct_ints() SmallStructInts; |
| 368 | 445 | |
| 369 | 446 | test "C ABI small struct of ints" { |
| 370 | 447 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 371 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 372 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 373 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 448 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 449 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 450 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 374 | 451 | |
| 375 | 452 | const s = SmallStructInts{ |
| 376 | 453 | .a = 1, |
| ... | ... | @@ -403,9 +480,9 @@ extern fn c_ret_med_struct_ints() MedStructInts; |
| 403 | 480 | |
| 404 | 481 | test "C ABI medium struct of ints" { |
| 405 | 482 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 406 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 407 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 408 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 483 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 484 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 485 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 409 | 486 | |
| 410 | 487 | const s = MedStructInts{ |
| 411 | 488 | .x = 1, |
| ... | ... | @@ -482,9 +559,9 @@ extern fn c_split_struct_ints(SplitStructInt) void; |
| 482 | 559 | |
| 483 | 560 | test "C ABI split struct of ints" { |
| 484 | 561 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 485 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 486 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 487 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 562 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 563 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 564 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 488 | 565 | |
| 489 | 566 | const s = SplitStructInt{ |
| 490 | 567 | .a = 1234, |
| ... | ... | @@ -510,9 +587,9 @@ extern fn c_ret_split_struct_mixed() SplitStructMixed; |
| 510 | 587 | |
| 511 | 588 | test "C ABI split struct of ints and floats" { |
| 512 | 589 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 513 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 514 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 515 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 590 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 591 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 592 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 516 | 593 | |
| 517 | 594 | const s = SplitStructMixed{ |
| 518 | 595 | .a = 1234, |
| ... | ... | @@ -538,8 +615,8 @@ extern fn c_multiple_struct_ints(Rect, Rect) void; |
| 538 | 615 | extern fn c_multiple_struct_floats(FloatRect, FloatRect) void; |
| 539 | 616 | |
| 540 | 617 | test "C ABI sret and byval together" { |
| 541 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 542 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 618 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 619 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 543 | 620 | |
| 544 | 621 | const s = BigStruct{ |
| 545 | 622 | .a = 1, |
| ... | ... | @@ -590,9 +667,9 @@ const Vector5 = extern struct { |
| 590 | 667 | extern fn c_big_struct_floats(Vector5) void; |
| 591 | 668 | |
| 592 | 669 | test "C ABI structs of floats as parameter" { |
| 593 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 594 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 595 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 670 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 671 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 672 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 596 | 673 | |
| 597 | 674 | const v3 = Vector3{ |
| 598 | 675 | .x = 3.0, |
| ... | ... | @@ -631,8 +708,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void { |
| 631 | 708 | } |
| 632 | 709 | |
| 633 | 710 | test "C ABI structs of ints as multiple parameters" { |
| 634 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 635 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 711 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 712 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 636 | 713 | |
| 637 | 714 | const r1 = Rect{ |
| 638 | 715 | .left = 1, |
| ... | ... | @@ -668,8 +745,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { |
| 668 | 745 | } |
| 669 | 746 | |
| 670 | 747 | test "C ABI structs of floats as multiple parameters" { |
| 671 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 672 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 748 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 749 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 673 | 750 | |
| 674 | 751 | const r1 = FloatRect{ |
| 675 | 752 | .left = 1, |
| ... | ... | @@ -781,9 +858,9 @@ extern fn c_ret_struct_with_array() StructWithArray; |
| 781 | 858 | |
| 782 | 859 | test "Struct with array as padding." { |
| 783 | 860 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 784 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 785 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 786 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 861 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 862 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 863 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 787 | 864 | |
| 788 | 865 | c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 }); |
| 789 | 866 | |
| ... | ... | @@ -808,8 +885,8 @@ extern fn c_ret_float_array_struct() FloatArrayStruct; |
| 808 | 885 | |
| 809 | 886 | test "Float array like struct" { |
| 810 | 887 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 811 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 812 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 888 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 889 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 813 | 890 | |
| 814 | 891 | c_float_array_struct(.{ |
| 815 | 892 | .origin = .{ |
| ... | ... | @@ -836,7 +913,7 @@ extern fn c_ret_small_vec() SmallVec; |
| 836 | 913 | |
| 837 | 914 | test "small simd vector" { |
| 838 | 915 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 839 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 916 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 840 | 917 | |
| 841 | 918 | c_small_vec(.{ 1, 2 }); |
| 842 | 919 | |
| ... | ... | @@ -854,7 +931,7 @@ test "medium simd vector" { |
| 854 | 931 | if (builtin.zig_backend == .stage2_x86_64 and |
| 855 | 932 | !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest; |
| 856 | 933 | |
| 857 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 934 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 858 | 935 | |
| 859 | 936 | c_medium_vec(.{ 1, 2, 3, 4 }); |
| 860 | 937 | |
| ... | ... | @@ -873,8 +950,8 @@ extern fn c_ret_big_vec() BigVec; |
| 873 | 950 | test "big simd vector" { |
| 874 | 951 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; |
| 875 | 952 | |
| 876 | | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 877 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 953 | if (builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 954 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 878 | 955 | if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .x86_64 and builtin.os.tag == .macos and builtin.mode != .Debug) return error.SkipZigTest; |
| 879 | 956 | |
| 880 | 957 | c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 }); |
| ... | ... | @@ -5155,9 +5232,9 @@ extern fn c_ret_ptr_size_float_struct() Vector2; |
| 5155 | 5232 | |
| 5156 | 5233 | test "C ABI pointer sized float struct" { |
| 5157 | 5234 | if (builtin.cpu.arch == .x86) return error.SkipZigTest; |
| 5158 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5159 | | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5160 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5235 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5236 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5237 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5161 | 5238 | |
| 5162 | 5239 | c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); |
| 5163 | 5240 | |
| ... | ... | @@ -5177,33 +5254,33 @@ pub inline fn expectOk(c_err: c_int) !void { |
| 5177 | 5254 | /// Tests for Double + Char struct |
| 5178 | 5255 | const DC = extern struct { v1: f64, v2: u8 }; |
| 5179 | 5256 | test "DC: Zig passes to C" { |
| 5180 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5181 | | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5182 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5183 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5257 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5258 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5259 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5260 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5184 | 5261 | try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 })); |
| 5185 | 5262 | } |
| 5186 | 5263 | test "DC: Zig returns to C" { |
| 5187 | 5264 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5188 | | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5189 | | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5190 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5191 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5265 | if (builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5266 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5267 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5268 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5192 | 5269 | try expectOk(c_assert_ret_DC()); |
| 5193 | 5270 | } |
| 5194 | 5271 | test "DC: C passes to Zig" { |
| 5195 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5196 | | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5197 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5198 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5272 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5273 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5274 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5275 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5199 | 5276 | try expectOk(c_send_DC()); |
| 5200 | 5277 | } |
| 5201 | 5278 | test "DC: C returns to Zig" { |
| 5202 | 5279 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5203 | | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5204 | | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5205 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5206 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5280 | if (builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5281 | if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 5282 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5283 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5207 | 5284 | try expectEqual(DC{ .v1 = -0.25, .v2 = 15 }, c_ret_DC()); |
| 5208 | 5285 | } |
| 5209 | 5286 | |
| ... | ... | @@ -5227,35 +5304,35 @@ const CFF = extern struct { v1: u8, v2: f32, v3: f32 }; |
| 5227 | 5304 | |
| 5228 | 5305 | test "CFF: Zig passes to C" { |
| 5229 | 5306 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5230 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5231 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5232 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5307 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5308 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5309 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5233 | 5310 | try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 })); |
| 5234 | 5311 | } |
| 5235 | 5312 | test "CFF: Zig returns to C" { |
| 5236 | 5313 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5237 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5238 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5239 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5314 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5315 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5316 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5240 | 5317 | try expectOk(c_assert_ret_CFF()); |
| 5241 | 5318 | } |
| 5242 | 5319 | test "CFF: C passes to Zig" { |
| 5243 | 5320 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5244 | | if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5321 | if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5245 | 5322 | if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5246 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5247 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5248 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5323 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5324 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5325 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5249 | 5326 | |
| 5250 | 5327 | try expectOk(c_send_CFF()); |
| 5251 | 5328 | } |
| 5252 | 5329 | test "CFF: C returns to Zig" { |
| 5253 | 5330 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5254 | 5331 | if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5255 | | if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5256 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5257 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5258 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5332 | if (builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5333 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5334 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5335 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5259 | 5336 | try expectEqual(CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }, c_ret_CFF()); |
| 5260 | 5337 | } |
| 5261 | 5338 | pub extern fn c_assert_CFF(lv: CFF) c_int; |
| ... | ... | @@ -5279,30 +5356,30 @@ const PD = extern struct { v1: ?*anyopaque, v2: f64 }; |
| 5279 | 5356 | |
| 5280 | 5357 | test "PD: Zig passes to C" { |
| 5281 | 5358 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5282 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5283 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5284 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5359 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5360 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5361 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5285 | 5362 | try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 })); |
| 5286 | 5363 | } |
| 5287 | 5364 | test "PD: Zig returns to C" { |
| 5288 | 5365 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5289 | | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5290 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5291 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5366 | if (builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5367 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5368 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5292 | 5369 | try expectOk(c_assert_ret_PD()); |
| 5293 | 5370 | } |
| 5294 | 5371 | test "PD: C passes to Zig" { |
| 5295 | 5372 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5296 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5297 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5298 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5373 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5374 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5375 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5299 | 5376 | try expectOk(c_send_PD()); |
| 5300 | 5377 | } |
| 5301 | 5378 | test "PD: C returns to Zig" { |
| 5302 | 5379 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5303 | | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5304 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5305 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5380 | if (builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5381 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5382 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5306 | 5383 | try expectEqual(PD{ .v1 = null, .v2 = 0.5 }, c_ret_PD()); |
| 5307 | 5384 | } |
| 5308 | 5385 | pub extern fn c_assert_PD(lv: PD) c_int; |
| ... | ... | @@ -5334,7 +5411,7 @@ const ByRef = extern struct { |
| 5334 | 5411 | extern fn c_modify_by_ref_param(ByRef) ByRef; |
| 5335 | 5412 | |
| 5336 | 5413 | test "C function modifies by ref param" { |
| 5337 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5414 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5338 | 5415 | |
| 5339 | 5416 | const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined }); |
| 5340 | 5417 | try expect(res.val == 42); |
| ... | ... | @@ -5356,8 +5433,8 @@ const ByVal = extern struct { |
| 5356 | 5433 | extern fn c_func_ptr_byval(*anyopaque, *anyopaque, ByVal, c_ulong, *anyopaque, c_ulong) void; |
| 5357 | 5434 | test "C function that takes byval struct called via function pointer" { |
| 5358 | 5435 | if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest; |
| 5359 | | if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5360 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5436 | if (builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5437 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5361 | 5438 | |
| 5362 | 5439 | var fn_ptr = &c_func_ptr_byval; |
| 5363 | 5440 | _ = &fn_ptr; |
| ... | ... | @@ -5376,7 +5453,7 @@ test "C function that takes byval struct called via function pointer" { |
| 5376 | 5453 | |
| 5377 | 5454 | extern fn c_f16(f16) f16; |
| 5378 | 5455 | test "f16 bare" { |
| 5379 | | if (!comptime builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| 5456 | if (!builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| 5380 | 5457 | |
| 5381 | 5458 | const a = c_f16(12); |
| 5382 | 5459 | try expect(a == 34); |
| ... | ... | @@ -5388,10 +5465,10 @@ const f16_struct = extern struct { |
| 5388 | 5465 | extern fn c_f16_struct(f16_struct) f16_struct; |
| 5389 | 5466 | test "f16 struct" { |
| 5390 | 5467 | if (builtin.target.cpu.arch == .x86) return error.SkipZigTest; |
| 5391 | | if (comptime builtin.target.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5392 | | if (comptime builtin.target.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5393 | | if (comptime builtin.target.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5394 | | if (comptime builtin.cpu.arch.isARM() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5468 | if (builtin.target.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5469 | if (builtin.target.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5470 | if (builtin.target.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5471 | if (builtin.cpu.arch.isARM() and builtin.mode != .Debug) return error.SkipZigTest; |
| 5395 | 5472 | |
| 5396 | 5473 | const a = c_f16_struct(.{ .a = 12 }); |
| 5397 | 5474 | try expect(a.a == 34); |
| ... | ... | @@ -5466,9 +5543,9 @@ const Coord2 = extern struct { |
| 5466 | 5543 | |
| 5467 | 5544 | extern fn stdcall_coord2(Coord2, Coord2, Coord2) callconv(stdcall_callconv) Coord2; |
| 5468 | 5545 | test "Stdcall ABI structs" { |
| 5469 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5470 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5471 | | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5546 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5547 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5548 | if (builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 5472 | 5549 | |
| 5473 | 5550 | const res = stdcall_coord2( |
| 5474 | 5551 | .{ .x = 0x1111, .y = 0x2222 }, |
| ... | ... | @@ -5481,7 +5558,7 @@ test "Stdcall ABI structs" { |
| 5481 | 5558 | |
| 5482 | 5559 | extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void; |
| 5483 | 5560 | test "Stdcall ABI big union" { |
| 5484 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5561 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5485 | 5562 | |
| 5486 | 5563 | const x = BigUnion{ |
| 5487 | 5564 | .a = BigStruct{ |
| ... | ... | @@ -5552,8 +5629,8 @@ const byval_tail_callsite_attr = struct { |
| 5552 | 5629 | }; |
| 5553 | 5630 | |
| 5554 | 5631 | test "byval tail callsite attribute" { |
| 5555 | | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5556 | | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5632 | if (builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 5633 | if (builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 5557 | 5634 | |
| 5558 | 5635 | // Originally reported at https://github.com/ziglang/zig/issues/16290 |
| 5559 | 5636 | // the bug was that the extern function had the byval attribute, but |