| ... | ... | @@ -2,7 +2,8 @@ const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const print = std.debug.print; |
| 4 | 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 | 8 | extern fn run_c_tests() void; |
| 8 | 9 | |
| ... | ... | @@ -111,7 +112,6 @@ test "C ABI floats" { |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | 114 | test "C ABI long double" { |
| 114 | | if (!builtin.cpu.arch.isWasm() and !builtin.cpu.arch.isAARCH64()) return error.SkipZigTest; |
| 115 | 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 | 167 | extern fn c_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat; |
| 168 | 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 | 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 | 176 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; |
| 174 | 177 | const b = ComplexFloat{ .real = 11.3, .imag = -1.5 }; |
| ... | ... | @@ -179,7 +182,7 @@ test "C ABI complex float" { |
| 179 | 182 | } |
| 180 | 183 | |
| 181 | 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 | 187 | const a = ComplexFloat{ .real = 1.25, .imag = 2.6 }; |
| 185 | 188 | const b = ComplexFloat{ .real = 11.3, .imag = -1.5 }; |
| ... | ... | @@ -190,7 +193,7 @@ test "C ABI complex float by component" { |
| 190 | 193 | } |
| 191 | 194 | |
| 192 | 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 | 198 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; |
| 196 | 199 | const b = ComplexDouble{ .real = 11.3, .imag = -1.5 }; |
| ... | ... | @@ -201,7 +204,7 @@ test "C ABI complex double" { |
| 201 | 204 | } |
| 202 | 205 | |
| 203 | 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 | 209 | const a = ComplexDouble{ .real = 1.25, .imag = 2.6 }; |
| 207 | 210 | const b = ComplexDouble{ .real = 11.3, .imag = -1.5 }; |
| ... | ... | @@ -257,6 +260,9 @@ const BigStruct = extern struct { |
| 257 | 260 | extern fn c_big_struct(BigStruct) void; |
| 258 | 261 | |
| 259 | 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 | 266 | var s = BigStruct{ |
| 261 | 267 | .a = 1, |
| 262 | 268 | .b = 2, |
| ... | ... | @@ -281,6 +287,8 @@ const BigUnion = extern union { |
| 281 | 287 | extern fn c_big_union(BigUnion) void; |
| 282 | 288 | |
| 283 | 289 | test "C ABI big union" { |
| 290 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 291 | |
| 284 | 292 | var x = BigUnion{ |
| 285 | 293 | .a = BigStruct{ |
| 286 | 294 | .a = 1, |
| ... | ... | @@ -312,6 +320,9 @@ extern fn c_ret_med_struct_mixed() MedStructMixed; |
| 312 | 320 | |
| 313 | 321 | test "C ABI medium struct of ints and floats" { |
| 314 | 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 | 327 | var s = MedStructMixed{ |
| 317 | 328 | .a = 1234, |
| ... | ... | @@ -342,6 +353,9 @@ extern fn c_ret_small_struct_ints() SmallStructInts; |
| 342 | 353 | |
| 343 | 354 | test "C ABI small struct of ints" { |
| 344 | 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 | 360 | var s = SmallStructInts{ |
| 347 | 361 | .a = 1, |
| ... | ... | @@ -421,6 +435,9 @@ extern fn c_split_struct_ints(SplitStructInt) void; |
| 421 | 435 | |
| 422 | 436 | test "C ABI split struct of ints" { |
| 423 | 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 | 442 | var s = SplitStructInt{ |
| 426 | 443 | .a = 1234, |
| ... | ... | @@ -446,6 +463,9 @@ extern fn c_ret_split_struct_mixed() SplitStructMixed; |
| 446 | 463 | |
| 447 | 464 | test "C ABI split struct of ints and floats" { |
| 448 | 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 | 470 | var s = SplitStructMixed{ |
| 451 | 471 | .a = 1234, |
| ... | ... | @@ -471,6 +491,9 @@ extern fn c_multiple_struct_ints(Rect, Rect) void; |
| 471 | 491 | extern fn c_multiple_struct_floats(FloatRect, FloatRect) void; |
| 472 | 492 | |
| 473 | 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 | 497 | var s = BigStruct{ |
| 475 | 498 | .a = 1, |
| 476 | 499 | .b = 2, |
| ... | ... | @@ -520,6 +543,10 @@ const Vector5 = extern struct { |
| 520 | 543 | extern fn c_big_struct_floats(Vector5) void; |
| 521 | 544 | |
| 522 | 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 | 550 | var v3 = Vector3{ |
| 524 | 551 | .x = 3.0, |
| 525 | 552 | .y = 6.0, |
| ... | ... | @@ -557,6 +584,8 @@ export fn zig_multiple_struct_ints(x: Rect, y: Rect) void { |
| 557 | 584 | } |
| 558 | 585 | |
| 559 | 586 | test "C ABI structs of ints as multiple parameters" { |
| 587 | if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest; |
| 588 | |
| 560 | 589 | var r1 = Rect{ |
| 561 | 590 | .left = 1, |
| 562 | 591 | .right = 21, |
| ... | ... | @@ -591,6 +620,9 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void { |
| 591 | 620 | } |
| 592 | 621 | |
| 593 | 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 | 626 | var r1 = FloatRect{ |
| 595 | 627 | .left = 1, |
| 596 | 628 | .right = 21, |
| ... | ... | @@ -693,6 +725,9 @@ extern fn c_ret_struct_with_array() StructWithArray; |
| 693 | 725 | |
| 694 | 726 | test "Struct with array as padding." { |
| 695 | 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 | 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 | 751 | extern fn c_ret_float_array_struct() FloatArrayStruct; |
| 717 | 752 | |
| 718 | 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 | 757 | c_float_array_struct(.{ |
| 720 | 758 | .origin = .{ |
| 721 | 759 | .x = 5, |