| ... | ... | @@ -278,7 +278,7 @@ test "C ABI big struct" { |
| 278 | 278 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 279 | 279 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 280 | 280 | |
| 281 | | var s = BigStruct{ |
| 281 | const s = BigStruct{ |
| 282 | 282 | .a = 1, |
| 283 | 283 | .b = 2, |
| 284 | 284 | .c = 3, |
| ... | ... | @@ -304,7 +304,7 @@ extern fn c_big_union(BigUnion) void; |
| 304 | 304 | test "C ABI big union" { |
| 305 | 305 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 306 | 306 | |
| 307 | | var x = BigUnion{ |
| 307 | const x = BigUnion{ |
| 308 | 308 | .a = BigStruct{ |
| 309 | 309 | .a = 1, |
| 310 | 310 | .b = 2, |
| ... | ... | @@ -339,13 +339,13 @@ test "C ABI medium struct of ints and floats" { |
| 339 | 339 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 340 | 340 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 341 | 341 | |
| 342 | | var s = MedStructMixed{ |
| 342 | const s = MedStructMixed{ |
| 343 | 343 | .a = 1234, |
| 344 | 344 | .b = 100.0, |
| 345 | 345 | .c = 1337.0, |
| 346 | 346 | }; |
| 347 | 347 | c_med_struct_mixed(s); |
| 348 | | var s2 = c_ret_med_struct_mixed(); |
| 348 | const s2 = c_ret_med_struct_mixed(); |
| 349 | 349 | try expect(s2.a == 1234); |
| 350 | 350 | try expect(s2.b == 100.0); |
| 351 | 351 | try expect(s2.c == 1337.0); |
| ... | ... | @@ -372,14 +372,14 @@ test "C ABI small struct of ints" { |
| 372 | 372 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 373 | 373 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 374 | 374 | |
| 375 | | var s = SmallStructInts{ |
| 375 | const s = SmallStructInts{ |
| 376 | 376 | .a = 1, |
| 377 | 377 | .b = 2, |
| 378 | 378 | .c = 3, |
| 379 | 379 | .d = 4, |
| 380 | 380 | }; |
| 381 | 381 | c_small_struct_ints(s); |
| 382 | | var s2 = c_ret_small_struct_ints(); |
| 382 | const s2 = c_ret_small_struct_ints(); |
| 383 | 383 | try expect(s2.a == 1); |
| 384 | 384 | try expect(s2.b == 2); |
| 385 | 385 | try expect(s2.c == 3); |
| ... | ... | @@ -407,13 +407,13 @@ test "C ABI medium struct of ints" { |
| 407 | 407 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 408 | 408 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 409 | 409 | |
| 410 | | var s = MedStructInts{ |
| 410 | const s = MedStructInts{ |
| 411 | 411 | .x = 1, |
| 412 | 412 | .y = 2, |
| 413 | 413 | .z = 3, |
| 414 | 414 | }; |
| 415 | 415 | c_med_struct_ints(s); |
| 416 | | var s2 = c_ret_med_struct_ints(); |
| 416 | const s2 = c_ret_med_struct_ints(); |
| 417 | 417 | try expect(s2.x == 1); |
| 418 | 418 | try expect(s2.y == 2); |
| 419 | 419 | try expect(s2.z == 3); |
| ... | ... | @@ -442,9 +442,9 @@ export fn zig_small_packed_struct(x: SmallPackedStruct) void { |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | test "C ABI small packed struct" { |
| 445 | | var s = SmallPackedStruct{ .a = 0, .b = 1, .c = 2, .d = 3 }; |
| 445 | const s = SmallPackedStruct{ .a = 0, .b = 1, .c = 2, .d = 3 }; |
| 446 | 446 | c_small_packed_struct(s); |
| 447 | | var s2 = c_ret_small_packed_struct(); |
| 447 | const s2 = c_ret_small_packed_struct(); |
| 448 | 448 | try expect(s2.a == 0); |
| 449 | 449 | try expect(s2.b == 1); |
| 450 | 450 | try expect(s2.c == 2); |
| ... | ... | @@ -466,9 +466,9 @@ export fn zig_big_packed_struct(x: BigPackedStruct) void { |
| 466 | 466 | test "C ABI big packed struct" { |
| 467 | 467 | if (!has_i128) return error.SkipZigTest; |
| 468 | 468 | |
| 469 | | var s = BigPackedStruct{ .a = 1, .b = 2 }; |
| 469 | const s = BigPackedStruct{ .a = 1, .b = 2 }; |
| 470 | 470 | c_big_packed_struct(s); |
| 471 | | var s2 = c_ret_big_packed_struct(); |
| 471 | const s2 = c_ret_big_packed_struct(); |
| 472 | 472 | try expect(s2.a == 1); |
| 473 | 473 | try expect(s2.b == 2); |
| 474 | 474 | } |
| ... | ... | @@ -486,7 +486,7 @@ test "C ABI split struct of ints" { |
| 486 | 486 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 487 | 487 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 488 | 488 | |
| 489 | | var s = SplitStructInt{ |
| 489 | const s = SplitStructInt{ |
| 490 | 490 | .a = 1234, |
| 491 | 491 | .b = 100, |
| 492 | 492 | .c = 1337, |
| ... | ... | @@ -514,13 +514,13 @@ test "C ABI split struct of ints and floats" { |
| 514 | 514 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 515 | 515 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 516 | 516 | |
| 517 | | var s = SplitStructMixed{ |
| 517 | const s = SplitStructMixed{ |
| 518 | 518 | .a = 1234, |
| 519 | 519 | .b = 100, |
| 520 | 520 | .c = 1337.0, |
| 521 | 521 | }; |
| 522 | 522 | c_split_struct_mixed(s); |
| 523 | | var s2 = c_ret_split_struct_mixed(); |
| 523 | const s2 = c_ret_split_struct_mixed(); |
| 524 | 524 | try expect(s2.a == 1234); |
| 525 | 525 | try expect(s2.b == 100); |
| 526 | 526 | try expect(s2.c == 1337.0); |
| ... | ... | @@ -541,14 +541,14 @@ test "C ABI sret and byval together" { |
| 541 | 541 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 542 | 542 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 543 | 543 | |
| 544 | | var s = BigStruct{ |
| 544 | const s = BigStruct{ |
| 545 | 545 | .a = 1, |
| 546 | 546 | .b = 2, |
| 547 | 547 | .c = 3, |
| 548 | 548 | .d = 4, |
| 549 | 549 | .e = 5, |
| 550 | 550 | }; |
| 551 | | var y = c_big_struct_both(s); |
| 551 | const y = c_big_struct_both(s); |
| 552 | 552 | try expect(y.a == 10); |
| 553 | 553 | try expect(y.b == 11); |
| 554 | 554 | try expect(y.c == 12); |
| ... | ... | @@ -562,7 +562,7 @@ export fn zig_big_struct_both(x: BigStruct) BigStruct { |
| 562 | 562 | expect(x.c == 32) catch @panic("test failure"); |
| 563 | 563 | expect(x.d == 33) catch @panic("test failure"); |
| 564 | 564 | expect(x.e == 34) catch @panic("test failure"); |
| 565 | | var s = BigStruct{ |
| 565 | const s = BigStruct{ |
| 566 | 566 | .a = 20, |
| 567 | 567 | .b = 21, |
| 568 | 568 | .c = 22, |
| ... | ... | @@ -594,7 +594,7 @@ test "C ABI structs of floats as parameter" { |
| 594 | 594 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 595 | 595 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 596 | 596 | |
| 597 | | var v3 = Vector3{ |
| 597 | const v3 = Vector3{ |
| 598 | 598 | .x = 3.0, |
| 599 | 599 | .y = 6.0, |
| 600 | 600 | .z = 12.0, |
| ... | ... | @@ -602,7 +602,7 @@ test "C ABI structs of floats as parameter" { |
| 602 | 602 | c_small_struct_floats(v3); |
| 603 | 603 | c_small_struct_floats_extra(v3, "hello"); |
| 604 | 604 | |
| 605 | | var v5 = Vector5{ |
| 605 | const v5 = Vector5{ |
| 606 | 606 | .x = 76.0, |
| 607 | 607 | .y = -1.0, |
| 608 | 608 | .z = -12.0, |
| ... | ... | @@ -634,13 +634,13 @@ test "C ABI structs of ints as multiple parameters" { |
| 634 | 634 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 635 | 635 | if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest; |
| 636 | 636 | |
| 637 | | var r1 = Rect{ |
| 637 | const r1 = Rect{ |
| 638 | 638 | .left = 1, |
| 639 | 639 | .right = 21, |
| 640 | 640 | .top = 16, |
| 641 | 641 | .bottom = 4, |
| 642 | 642 | }; |
| 643 | | var r2 = Rect{ |
| 643 | const r2 = Rect{ |
| 644 | 644 | .left = 178, |
| 645 | 645 | .right = 189, |
| 646 | 646 | .top = 21, |
| ... | ... | @@ -671,13 +671,13 @@ test "C ABI structs of floats as multiple parameters" { |
| 671 | 671 | if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest; |
| 672 | 672 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 673 | 673 | |
| 674 | | var r1 = FloatRect{ |
| 674 | const r1 = FloatRect{ |
| 675 | 675 | .left = 1, |
| 676 | 676 | .right = 21, |
| 677 | 677 | .top = 16, |
| 678 | 678 | .bottom = 4, |
| 679 | 679 | }; |
| 680 | | var r2 = FloatRect{ |
| 680 | const r2 = FloatRect{ |
| 681 | 681 | .left = 178, |
| 682 | 682 | .right = 189, |
| 683 | 683 | .top = 21, |
| ... | ... | @@ -787,7 +787,7 @@ test "Struct with array as padding." { |
| 787 | 787 | |
| 788 | 788 | c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 }); |
| 789 | 789 | |
| 790 | | var x = c_ret_struct_with_array(); |
| 790 | const x = c_ret_struct_with_array(); |
| 791 | 791 | try expect(x.a == 4); |
| 792 | 792 | try expect(x.b == 155); |
| 793 | 793 | } |
| ... | ... | @@ -822,7 +822,7 @@ test "Float array like struct" { |
| 822 | 822 | }, |
| 823 | 823 | }); |
| 824 | 824 | |
| 825 | | var x = c_ret_float_array_struct(); |
| 825 | const x = c_ret_float_array_struct(); |
| 826 | 826 | try expect(x.origin.x == 1); |
| 827 | 827 | try expect(x.origin.y == 2); |
| 828 | 828 | try expect(x.size.width == 3); |
| ... | ... | @@ -840,7 +840,7 @@ test "small simd vector" { |
| 840 | 840 | |
| 841 | 841 | c_small_vec(.{ 1, 2 }); |
| 842 | 842 | |
| 843 | | var x = c_ret_small_vec(); |
| 843 | const x = c_ret_small_vec(); |
| 844 | 844 | try expect(x[0] == 3); |
| 845 | 845 | try expect(x[1] == 4); |
| 846 | 846 | } |
| ... | ... | @@ -858,7 +858,7 @@ test "medium simd vector" { |
| 858 | 858 | |
| 859 | 859 | c_medium_vec(.{ 1, 2, 3, 4 }); |
| 860 | 860 | |
| 861 | | var x = c_ret_medium_vec(); |
| 861 | const x = c_ret_medium_vec(); |
| 862 | 862 | try expect(x[0] == 5); |
| 863 | 863 | try expect(x[1] == 6); |
| 864 | 864 | try expect(x[2] == 7); |
| ... | ... | @@ -879,7 +879,7 @@ test "big simd vector" { |
| 879 | 879 | |
| 880 | 880 | c_big_vec(.{ 1, 2, 3, 4, 5, 6, 7, 8 }); |
| 881 | 881 | |
| 882 | | var x = c_ret_big_vec(); |
| 882 | const x = c_ret_big_vec(); |
| 883 | 883 | try expect(x[0] == 9); |
| 884 | 884 | try expect(x[1] == 10); |
| 885 | 885 | try expect(x[2] == 11); |
| ... | ... | @@ -903,7 +903,7 @@ test "C ABI pointer sized float struct" { |
| 903 | 903 | |
| 904 | 904 | c_ptr_size_float_struct(.{ .x = 1, .y = 2 }); |
| 905 | 905 | |
| 906 | | var x = c_ret_ptr_size_float_struct(); |
| 906 | const x = c_ret_ptr_size_float_struct(); |
| 907 | 907 | try expect(x.x == 3); |
| 908 | 908 | try expect(x.y == 4); |
| 909 | 909 | } |
| ... | ... | @@ -1102,6 +1102,7 @@ test "C function that takes byval struct called via function pointer" { |
| 1102 | 1102 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 1103 | 1103 | |
| 1104 | 1104 | var fn_ptr = &c_func_ptr_byval; |
| 1105 | _ = &fn_ptr; |
| 1105 | 1106 | fn_ptr( |
| 1106 | 1107 | @as(*anyopaque, @ptrFromInt(1)), |
| 1107 | 1108 | @as(*anyopaque, @ptrFromInt(2)), |
| ... | ... | @@ -1224,7 +1225,7 @@ extern fn stdcall_big_union(BigUnion) callconv(stdcall_callconv) void; |
| 1224 | 1225 | test "Stdcall ABI big union" { |
| 1225 | 1226 | if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest; |
| 1226 | 1227 | |
| 1227 | | var x = BigUnion{ |
| 1228 | const x = BigUnion{ |
| 1228 | 1229 | .a = BigStruct{ |
| 1229 | 1230 | .a = 1, |
| 1230 | 1231 | .b = 2, |