| ... | @@ -2,7 +2,8 @@ const std = @import("std"); | ... | @@ -2,7 +2,8 @@ const std = @import("std"); |
| 2 | const builtin = @import("builtin"); | 2 | const builtin = @import("builtin"); |
| 3 | const print = std.debug.print; | 3 | const print = std.debug.print; |
| 4 | const expect = std.testing.expect; | 4 | const expect = std.testing.expect; |
| 5 | const has_i128 = builtin.cpu.arch != .i386; | 5 | const has_i128 = builtin.cpu.arch != .i386 and !builtin.cpu.arch.isARM() and |
| | 6 | !builtin.cpu.arch.isMIPS(); |
| 6 | | 7 | |
| 7 | extern fn run_c_tests() void; | 8 | extern fn run_c_tests() void; |
| 8 | | 9 | |
| ... | @@ -111,7 +112,6 @@ test "C ABI floats" { | ... | @@ -111,7 +112,6 @@ test "C ABI floats" { |
| 111 | } | 112 | } |
| 112 | | 113 | |
| 113 | test "C ABI long double" { | 114 | test "C ABI long double" { |
| 114 | if (!builtin.cpu.arch.isWasm() and !builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; | | |
| 115 | c_long_double(12.34); | 115 | c_long_double(12.34); |
| 116 | } | 116 | } |
| 117 | | 117 | |
| ... | @@ -167,8 +167,11 @@ extern fn c_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble; | ... | @@ -167,8 +167,11 @@ extern fn c_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble; |
| 167 | extern fn c_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat; | 167 | extern fn c_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat; |
| 168 | extern fn c_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble; | 168 | extern fn c_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble; |
| 169 | | 169 | |
| | 170 | const complex_abi_compatible = builtin.cpu.arch != .i386 and !builtin.cpu.arch.isMIPS(); |
| | 171 | |
| 170 | test "C ABI complex float" { | 172 | test "C ABI complex float" { |
| 171 | if (true) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465 | 173 | if (!complex_abi_compatible) return error.SkipZigTest; |
| | 174 | if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465 |
| 172 | | 175 | |
| 173 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; | 176 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; |
| 174 | const b = ComplexFloat{ .real = 11.3, .imag = -1.5 }; | 177 | const b = ComplexFloat{ .real = 11.3, .imag = -1.5 }; |
| ... | @@ -179,7 +182,7 @@ test "C ABI complex float" { | ... | @@ -179,7 +182,7 @@ test "C ABI complex float" { |
| 179 | } | 182 | } |
| 180 | | 183 | |
| 181 | test "C ABI complex float by component" { | 184 | test "C ABI complex float by component" { |
| 182 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 185 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 183 | | 186 | |
| 184 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; | 187 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; |
| 185 | const b = ComplexFloat{ .real = 11.3, .imag = -1.5 }; | 188 | const b = ComplexFloat{ .real = 11.3, .imag = -1.5 }; |
| ... | @@ -190,7 +193,7 @@ test "C ABI complex float by component" { | ... | @@ -190,7 +193,7 @@ test "C ABI complex float by component" { |
| 190 | } | 193 | } |
| 191 | | 194 | |
| 192 | test "C ABI complex double" { | 195 | test "C ABI complex double" { |
| 193 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 196 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 194 | | 197 | |
| 195 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; | 198 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; |
| 196 | const b = ComplexDouble{ .real = 11.3, .imag = -1.5 }; | 199 | const b = ComplexDouble{ .real = 11.3, .imag = -1.5 }; |
| ... | @@ -201,7 +204,7 @@ test "C ABI complex double" { | ... | @@ -201,7 +204,7 @@ test "C ABI complex double" { |
| 201 | } | 204 | } |
| 202 | | 205 | |
| 203 | test "C ABI complex double by component" { | 206 | test "C ABI complex double by component" { |
| 204 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 207 | if (!complex_abi_compatible) return error.SkipZigTest; |
| 205 | | 208 | |
| 206 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; | 209 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; |
| 207 | const b = ComplexDouble{ .real = 11.3, .imag = -1.5 }; | 210 | const b = ComplexDouble{ .real = 11.3, .imag = -1.5 }; |
| ... | @@ -257,6 +260,9 @@ const BigStruct = extern struct { | ... | @@ -257,6 +260,9 @@ const BigStruct = extern struct { |
| 257 | extern fn c_big_struct(BigStruct) void; | 260 | extern fn c_big_struct(BigStruct) void; |
| 258 | | 261 | |
| 259 | test "C ABI big struct" { | 262 | test "C ABI big struct" { |
| | 263 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 264 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 265 | |
| 260 | var s = BigStruct{ | 266 | var s = BigStruct{ |
| 261 | .a = 1, | 267 | .a = 1, |
| 262 | .b = 2, | 268 | .b = 2, |
| ... | @@ -281,6 +287,8 @@ const BigUnion = extern union { | ... | @@ -281,6 +287,8 @@ const BigUnion = extern union { |
| 281 | extern fn c_big_union(BigUnion) void; | 287 | extern fn c_big_union(BigUnion) void; |
| 282 | | 288 | |
| 283 | test "C ABI big union" { | 289 | test "C ABI big union" { |
| | 290 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 291 | |
| 284 | var x = BigUnion{ | 292 | var x = BigUnion{ |
| 285 | .a = BigStruct{ | 293 | .a = BigStruct{ |
| 286 | .a = 1, | 294 | .a = 1, |
| ... | @@ -312,6 +320,9 @@ extern fn c_ret_med_struct_mixed() MedStructMixed; | ... | @@ -312,6 +320,9 @@ extern fn c_ret_med_struct_mixed() MedStructMixed; |
| 312 | | 320 | |
| 313 | test "C ABI medium struct of ints and floats" { | 321 | test "C ABI medium struct of ints and floats" { |
| 314 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 322 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; |
| | 323 | if (comptime builtin.cpu.arch.isARM()) return error.SkipZigTest; |
| | 324 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 325 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 315 | | 326 | |
| 316 | var s = MedStructMixed{ | 327 | var s = MedStructMixed{ |
| 317 | .a = 1234, | 328 | .a = 1234, |
| ... | @@ -342,6 +353,9 @@ extern fn c_ret_small_struct_ints() SmallStructInts; | ... | @@ -342,6 +353,9 @@ extern fn c_ret_small_struct_ints() SmallStructInts; |
| 342 | | 353 | |
| 343 | test "C ABI small struct of ints" { | 354 | test "C ABI small struct of ints" { |
| 344 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 355 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; |
| | 356 | if (comptime builtin.cpu.arch.isARM()) return error.SkipZigTest; |
| | 357 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 358 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 345 | | 359 | |
| 346 | var s = SmallStructInts{ | 360 | var s = SmallStructInts{ |
| 347 | .a = 1, | 361 | .a = 1, |
| ... | @@ -421,6 +435,9 @@ extern fn c_split_struct_ints(SplitStructInt) void; | ... | @@ -421,6 +435,9 @@ extern fn c_split_struct_ints(SplitStructInt) void; |
| 421 | | 435 | |
| 422 | test "C ABI split struct of ints" { | 436 | test "C ABI split struct of ints" { |
| 423 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 437 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; |
| | 438 | if (comptime builtin.cpu.arch.isARM()) return error.SkipZigTest; |
| | 439 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 440 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 424 | | 441 | |
| 425 | var s = SplitStructInt{ | 442 | var s = SplitStructInt{ |
| 426 | .a = 1234, | 443 | .a = 1234, |
| ... | @@ -446,6 +463,9 @@ extern fn c_ret_split_struct_mixed() SplitStructMixed; | ... | @@ -446,6 +463,9 @@ extern fn c_ret_split_struct_mixed() SplitStructMixed; |
| 446 | | 463 | |
| 447 | test "C ABI split struct of ints and floats" { | 464 | test "C ABI split struct of ints and floats" { |
| 448 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 465 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; |
| | 466 | if (comptime builtin.cpu.arch.isARM()) return error.SkipZigTest; |
| | 467 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 468 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 449 | | 469 | |
| 450 | var s = SplitStructMixed{ | 470 | var s = SplitStructMixed{ |
| 451 | .a = 1234, | 471 | .a = 1234, |
| ... | @@ -471,6 +491,9 @@ extern fn c_multiple_struct_ints(Rect, Rect) void; | ... | @@ -471,6 +491,9 @@ extern fn c_multiple_struct_ints(Rect, Rect) void; |
| 471 | extern fn c_multiple_struct_floats(FloatRect, FloatRect) void; | 491 | extern fn c_multiple_struct_floats(FloatRect, FloatRect) void; |
| 472 | | 492 | |
| 473 | test "C ABI sret and byval together" { | 493 | test "C ABI sret and byval together" { |
| | 494 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 495 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 496 | |
| 474 | var s = BigStruct{ | 497 | var s = BigStruct{ |
| 475 | .a = 1, | 498 | .a = 1, |
| 476 | .b = 2, | 499 | .b = 2, |
| ... | @@ -520,6 +543,10 @@ const Vector5 = extern struct { | ... | @@ -520,6 +543,10 @@ const Vector5 = extern struct { |
| 520 | extern fn c_big_struct_floats(Vector5) void; | 543 | extern fn c_big_struct_floats(Vector5) void; |
| 521 | | 544 | |
| 522 | test "C ABI structs of floats as parameter" { | 545 | test "C ABI structs of floats as parameter" { |
| | 546 | if (comptime builtin.cpu.arch.isARM()) return error.SkipZigTest; |
| | 547 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 548 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 549 | |
| 523 | var v3 = Vector3{ | 550 | var v3 = Vector3{ |
| 524 | .x = 3.0, | 551 | .x = 3.0, |
| 525 | .y = 6.0, | 552 | .y = 6.0, |
| ... | @@ -557,6 +584,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void { | ... | @@ -557,6 +584,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void { |
| 557 | } | 584 | } |
| 558 | | 585 | |
| 559 | test "C ABI structs of ints as multiple parameters" { | 586 | test "C ABI structs of ints as multiple parameters" { |
| | 587 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 588 | |
| 560 | var r1 = Rect{ | 589 | var r1 = Rect{ |
| 561 | .left = 1, | 590 | .left = 1, |
| 562 | .right = 21, | 591 | .right = 21, |
| ... | @@ -591,6 +620,9 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { | ... | @@ -591,6 +620,9 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { |
| 591 | } | 620 | } |
| 592 | | 621 | |
| 593 | test "C ABI structs of floats as multiple parameters" { | 622 | test "C ABI structs of floats as multiple parameters" { |
| | 623 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 624 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 625 | |
| 594 | var r1 = FloatRect{ | 626 | var r1 = FloatRect{ |
| 595 | .left = 1, | 627 | .left = 1, |
| 596 | .right = 21, | 628 | .right = 21, |
| ... | @@ -693,6 +725,9 @@ extern fn c_ret_struct_with_array() StructWithArray; | ... | @@ -693,6 +725,9 @@ extern fn c_ret_struct_with_array() StructWithArray; |
| 693 | | 725 | |
| 694 | test "Struct with array as padding." { | 726 | test "Struct with array as padding." { |
| 695 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; | 727 | if (builtin.cpu.arch == .i386) return error.SkipZigTest; |
| | 728 | if (comptime builtin.cpu.arch.isARM()) return error.SkipZigTest; |
| | 729 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 730 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 696 | | 731 | |
| 697 | c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 }); | 732 | c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 }); |
| 698 | | 733 | |
| ... | @@ -716,6 +751,9 @@ extern fn c_float_array_struct(FloatArrayStruct) void; | ... | @@ -716,6 +751,9 @@ extern fn c_float_array_struct(FloatArrayStruct) void; |
| 716 | extern fn c_ret_float_array_struct() FloatArrayStruct; | 751 | extern fn c_ret_float_array_struct() FloatArrayStruct; |
| 717 | | 752 | |
| 718 | test "Float array like struct" { | 753 | test "Float array like struct" { |
| | 754 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| | 755 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| | 756 | |
| 719 | c_float_array_struct(.{ | 757 | c_float_array_struct(.{ |
| 720 | .origin = .{ | 758 | .origin = .{ |
| 721 | .x = 5, | 759 | .x = 5, |