mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
commit
3b0dce8ebd
@ -295,8 +295,6 @@ const Arg = struct {
|
||||
test Options {
|
||||
if (builtin.os.tag == .wasi) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
|
||||
@ -2294,8 +2294,6 @@ test "popOrNull" {
|
||||
}
|
||||
|
||||
test "reIndex" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var map = ArrayHashMap(i32, i32, AutoContext(i32), true).init(std.testing.allocator);
|
||||
defer map.deinit();
|
||||
|
||||
|
||||
@ -1069,8 +1069,6 @@ var deflate_tests = [_]DeflateTest{
|
||||
};
|
||||
|
||||
test "deflate" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
for (deflate_tests) |dt| {
|
||||
var output = ArrayList(u8).init(testing.allocator);
|
||||
defer output.deinit();
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
const fifo = std.fifo;
|
||||
const io = std.io;
|
||||
@ -154,8 +153,6 @@ fn testToFromWithLimit(input: []const u8, limit: [11]u32) !void {
|
||||
}
|
||||
|
||||
test "deflate/inflate" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var limits = [_]u32{0} ** 11;
|
||||
|
||||
var test0 = [_]u8{};
|
||||
@ -180,8 +177,6 @@ test "deflate/inflate" {
|
||||
}
|
||||
|
||||
test "very long sparse chunk" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// A SparseReader returns a stream consisting of 0s ending with 65,536 (1<<16) 1s.
|
||||
// This tests missing hash references in a very large input.
|
||||
const SparseReader = struct {
|
||||
@ -243,8 +238,6 @@ test "very long sparse chunk" {
|
||||
}
|
||||
|
||||
test "compressor reset" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
for (std.enums.values(deflate.Compression)) |c| {
|
||||
try testWriterReset(c, null);
|
||||
try testWriterReset(c, "dict");
|
||||
@ -295,8 +288,6 @@ fn testWriterReset(level: deflate.Compression, dict: ?[]const u8) !void {
|
||||
}
|
||||
|
||||
test "decompressor dictionary" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const dict = "hello world"; // dictionary
|
||||
const text = "hello again world";
|
||||
|
||||
@ -337,8 +328,6 @@ test "decompressor dictionary" {
|
||||
}
|
||||
|
||||
test "compressor dictionary" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const dict = "hello world";
|
||||
const text = "hello again world";
|
||||
|
||||
@ -385,8 +374,6 @@ test "compressor dictionary" {
|
||||
// Update the hash for best_speed only if d.index < d.maxInsertIndex
|
||||
// See https://golang.org/issue/2508
|
||||
test "Go non-regression test for 2508" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var comp = try compressor(
|
||||
testing.allocator,
|
||||
io.null_writer,
|
||||
@ -404,8 +391,6 @@ test "Go non-regression test for 2508" {
|
||||
}
|
||||
|
||||
test "deflate/inflate string" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const StringTest = struct {
|
||||
filename: []const u8,
|
||||
limit: [11]u32,
|
||||
@ -453,8 +438,6 @@ test "deflate/inflate string" {
|
||||
}
|
||||
|
||||
test "inflate reset" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const strings = [_][]const u8{
|
||||
"lorem ipsum izzle fo rizzle",
|
||||
"the quick brown fox jumped over",
|
||||
@ -501,8 +484,6 @@ test "inflate reset" {
|
||||
}
|
||||
|
||||
test "inflate reset dictionary" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const dict = "the lorem fox";
|
||||
const strings = [_][]const u8{
|
||||
"lorem ipsum izzle fo rizzle",
|
||||
|
||||
@ -649,8 +649,6 @@ test "best speed shift offsets" {
|
||||
}
|
||||
|
||||
test "best speed reset" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// test that encoding is consistent across a warparound of the table offset.
|
||||
// See https://github.com/golang/go/issues/34121
|
||||
const fmt = std.fmt;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const expect = std.testing.expect;
|
||||
const io = std.io;
|
||||
const mem = std.mem;
|
||||
@ -12,8 +11,6 @@ const inflate = @import("decompressor.zig");
|
||||
const deflate_const = @import("deflate_const.zig");
|
||||
|
||||
test "best speed" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// Tests that round-tripping through deflate and then inflate recovers the original input.
|
||||
// The Write sizes are near the thresholds in the compressor.encSpeed method (0, 16, 128), as well
|
||||
// as near `deflate_const.max_store_block_size` (65535).
|
||||
@ -96,8 +93,6 @@ test "best speed" {
|
||||
}
|
||||
|
||||
test "best speed max match offset" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const abc = "abcdefgh";
|
||||
const xyz = "stuvwxyz";
|
||||
const input_margin = 16 - 1;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const io = std.io;
|
||||
|
||||
const Allocator = std.mem.Allocator;
|
||||
@ -845,8 +844,6 @@ const testing = std.testing;
|
||||
const ArrayList = std.ArrayList;
|
||||
|
||||
test "writeBlockHuff" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// Tests huffman encoding against reference files to detect possible regressions.
|
||||
// If encoding/bit allocation changes you can regenerate these files
|
||||
|
||||
@ -1571,8 +1568,6 @@ const TestType = enum {
|
||||
};
|
||||
|
||||
test "writeBlock" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// tests if the writeBlock encoding has changed.
|
||||
|
||||
const ttype: TestType = .write_block;
|
||||
@ -1588,8 +1583,6 @@ test "writeBlock" {
|
||||
}
|
||||
|
||||
test "writeBlockDynamic" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// tests if the writeBlockDynamic encoding has changed.
|
||||
|
||||
const ttype: TestType = .write_dyn_block;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("../../std.zig");
|
||||
const builtin = @import("builtin");
|
||||
const lzma = @import("../lzma.zig");
|
||||
|
||||
fn testDecompress(compressed: []const u8) ![]u8 {
|
||||
@ -33,8 +32,6 @@ test "LZMA: decompress empty world" {
|
||||
}
|
||||
|
||||
test "LZMA: decompress hello world" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try testDecompressEqual(
|
||||
"Hello world\n",
|
||||
&[_]u8{
|
||||
@ -46,8 +43,6 @@ test "LZMA: decompress hello world" {
|
||||
}
|
||||
|
||||
test "LZMA: decompress huge dict" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try testDecompressEqual(
|
||||
"Hello world\n",
|
||||
&[_]u8{
|
||||
@ -59,8 +54,6 @@ test "LZMA: decompress huge dict" {
|
||||
}
|
||||
|
||||
test "LZMA: unknown size with end of payload marker" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try testDecompressEqual(
|
||||
"Hello\nWorld!\n",
|
||||
@embedFile("testdata/good-unknown_size-with_eopm.lzma"),
|
||||
@ -68,8 +61,6 @@ test "LZMA: unknown size with end of payload marker" {
|
||||
}
|
||||
|
||||
test "LZMA: known size without end of payload marker" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try testDecompressEqual(
|
||||
"Hello\nWorld!\n",
|
||||
@embedFile("testdata/good-known_size-without_eopm.lzma"),
|
||||
@ -77,8 +68,6 @@ test "LZMA: known size without end of payload marker" {
|
||||
}
|
||||
|
||||
test "LZMA: known size with end of payload marker" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try testDecompressEqual(
|
||||
"Hello\nWorld!\n",
|
||||
@embedFile("testdata/good-known_size-with_eopm.lzma"),
|
||||
|
||||
@ -50,8 +50,6 @@ const expectEqualSlices = std.testing.expectEqualSlices;
|
||||
const expectError = std.testing.expectError;
|
||||
|
||||
test "Vec2D.init" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const allocator = testing.allocator;
|
||||
var vec2d = try Vec2D(i32).init(allocator, 1, .{ 2, 3 });
|
||||
defer vec2d.deinit(allocator);
|
||||
|
||||
@ -19,8 +19,6 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void {
|
||||
}
|
||||
|
||||
test "compressed data" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try testReader(@embedFile("testdata/good-0-empty.xz"), "");
|
||||
|
||||
inline for ([_][]const u8{
|
||||
|
||||
@ -264,8 +264,6 @@ test "sanity checks" {
|
||||
}
|
||||
|
||||
test "compress data" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const allocator = testing.allocator;
|
||||
const rfc1951_txt = @embedFile("testdata/rfc1951.txt");
|
||||
|
||||
|
||||
@ -685,8 +685,6 @@ test "ed25519 signatures with streaming" {
|
||||
}
|
||||
|
||||
test "ed25519 key pair from secret key" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const kp = try Ed25519.KeyPair.create(null);
|
||||
const kp2 = try Ed25519.KeyPair.fromSecretKey(kp.secret_key);
|
||||
try std.testing.expectEqualSlices(u8, &kp.secret_key.toBytes(), &kp2.secret_key.toBytes());
|
||||
|
||||
@ -1029,8 +1029,6 @@ test "crypto.chacha20 test vector 5" {
|
||||
}
|
||||
|
||||
test "seal" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
const m = "";
|
||||
const ad = "";
|
||||
@ -1081,8 +1079,6 @@ test "seal" {
|
||||
}
|
||||
|
||||
test "open" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
const c = [_]u8{ 0xa0, 0x78, 0x4d, 0x7a, 0x47, 0x16, 0xf3, 0xfe, 0xb4, 0xf6, 0x4e, 0x7f, 0x4b, 0x39, 0xbf, 0x4 };
|
||||
const ad = "";
|
||||
@ -1147,8 +1143,6 @@ test "open" {
|
||||
}
|
||||
|
||||
test "crypto.xchacha20" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const key = [_]u8{69} ** 32;
|
||||
const nonce = [_]u8{42} ** 24;
|
||||
const m = "Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
|
||||
|
||||
@ -372,10 +372,8 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type {
|
||||
}
|
||||
|
||||
test "ECDSA - Basic operations over EcdsaP384Sha384" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const Scheme = EcdsaP384Sha384;
|
||||
const kp = try Scheme.KeyPair.create(null);
|
||||
@ -391,10 +389,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha384" {
|
||||
}
|
||||
|
||||
test "ECDSA - Basic operations over Secp256k1" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const Scheme = EcdsaSecp256k1Sha256oSha256;
|
||||
const kp = try Scheme.KeyPair.create(null);
|
||||
@ -410,10 +406,8 @@ test "ECDSA - Basic operations over Secp256k1" {
|
||||
}
|
||||
|
||||
test "ECDSA - Basic operations over EcdsaP384Sha256" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
|
||||
const kp = try Scheme.KeyPair.create(null);
|
||||
@ -429,10 +423,8 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" {
|
||||
}
|
||||
|
||||
test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const Scheme = Ecdsa(crypto.ecc.P384, crypto.hash.sha2.Sha256);
|
||||
// zig fmt: off
|
||||
@ -476,10 +468,8 @@ const TestVector = struct {
|
||||
};
|
||||
|
||||
test "ECDSA - Test vectors from Project Wycheproof" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const vectors = [_]TestVector{
|
||||
.{ .key = "042927b10512bae3eddcfe467828128bad2903269919f7086069c8c4df6c732838c7787964eaac00e5921fb1498a60f4606766b3d9685001558d1a974e7341513e", .msg = "313233343030", .sig = "304402202ba3a8be6b94d5ec80a6d9d1190a436effe50d85a1eee859b8cc6af9bd5c2e1802204cd60b855d442f5b3c7b11eb6c4e0ae7525fe710fab9aa7c77a67f79e6fadd76", .result = .valid },
|
||||
@ -893,10 +883,8 @@ fn tvTry(vector: TestVector) !void {
|
||||
}
|
||||
|
||||
test "ECDSA - Sec1 encoding/decoding" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const Scheme = EcdsaP384Sha384;
|
||||
const kp = try Scheme.KeyPair.create(null);
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
//! Parts of that code was ported from the BSD-licensed crypto/internal/bigmod/nat.go file in the Go language, itself inspired from BearSSL.
|
||||
|
||||
const std = @import("std");
|
||||
const builtin = std.builtin;
|
||||
const builtin = @import("builtin");
|
||||
const crypto = std.crypto;
|
||||
const math = std.math;
|
||||
const mem = std.mem;
|
||||
@ -14,6 +14,7 @@ const meta = std.meta;
|
||||
const testing = std.testing;
|
||||
const BoundedArray = std.BoundedArray;
|
||||
const assert = std.debug.assert;
|
||||
const Endian = std.builtin.Endian;
|
||||
|
||||
// A Limb is a single digit in a big integer.
|
||||
const Limb = usize;
|
||||
@ -27,7 +28,7 @@ const t_bits: usize = @bitSizeOf(Limb) - carry_bits;
|
||||
// A TLimb is a Limb that is truncated to t_bits.
|
||||
const TLimb = meta.Int(.unsigned, t_bits);
|
||||
|
||||
const native_endian = @import("builtin").target.cpu.arch.endian();
|
||||
const native_endian = builtin.target.cpu.arch.endian();
|
||||
|
||||
// A WideLimb is a Limb that is twice as wide as a normal Limb.
|
||||
const WideLimb = struct {
|
||||
@ -128,7 +129,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
|
||||
}
|
||||
|
||||
/// Encodes a big integer into a byte array.
|
||||
pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
|
||||
pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
|
||||
if (bytes.len == 0) {
|
||||
if (self.isZero()) return;
|
||||
return error.Overflow;
|
||||
@ -175,7 +176,7 @@ pub fn Uint(comptime max_bits: comptime_int) type {
|
||||
}
|
||||
|
||||
/// Creates a new big integer from a byte array.
|
||||
pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) OverflowError!Self {
|
||||
pub fn fromBytes(bytes: []const u8, comptime endian: Endian) OverflowError!Self {
|
||||
if (bytes.len == 0) return Self.zero;
|
||||
var shift: usize = 0;
|
||||
var out = Self.zero;
|
||||
@ -335,7 +336,7 @@ fn Fe_(comptime bits: comptime_int) type {
|
||||
}
|
||||
|
||||
/// Creates a field element from a byte string.
|
||||
pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: builtin.Endian) (OverflowError || FieldElementError)!Self {
|
||||
pub fn fromBytes(m: Modulus(bits), bytes: []const u8, comptime endian: Endian) (OverflowError || FieldElementError)!Self {
|
||||
const v = try FeUint.fromBytes(bytes, endian);
|
||||
var fe = Self{ .v = v };
|
||||
try m.shrink(&fe);
|
||||
@ -344,7 +345,7 @@ fn Fe_(comptime bits: comptime_int) type {
|
||||
}
|
||||
|
||||
/// Converts the field element to a byte string.
|
||||
pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
|
||||
pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
|
||||
return self.v.toBytes(bytes, endian);
|
||||
}
|
||||
|
||||
@ -458,13 +459,13 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
|
||||
}
|
||||
|
||||
/// Creates a new modulus from a byte string.
|
||||
pub fn fromBytes(bytes: []const u8, comptime endian: builtin.Endian) (InvalidModulusError || OverflowError)!Self {
|
||||
pub fn fromBytes(bytes: []const u8, comptime endian: Endian) (InvalidModulusError || OverflowError)!Self {
|
||||
const v = try FeUint.fromBytes(bytes, endian);
|
||||
return try Self.fromUint(v);
|
||||
}
|
||||
|
||||
/// Serializes the modulus to a byte string.
|
||||
pub fn toBytes(self: Self, bytes: []u8, comptime endian: builtin.Endian) OverflowError!void {
|
||||
pub fn toBytes(self: Self, bytes: []u8, comptime endian: Endian) OverflowError!void {
|
||||
return self.v.toBytes(bytes, endian);
|
||||
}
|
||||
|
||||
@ -658,7 +659,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
|
||||
|
||||
// Returns x^e (mod m), with the exponent provided as a byte string.
|
||||
// `public` must be set to `false` if the exponent it secret.
|
||||
fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: builtin.Endian, comptime public: bool) NullExponentError!Fe {
|
||||
fn powWithEncodedExponentInternal(self: Self, x: Fe, e: []const u8, endian: Endian, comptime public: bool) NullExponentError!Fe {
|
||||
var acc: u8 = 0;
|
||||
for (e) |b| acc |= b;
|
||||
if (acc == 0) return error.NullExponent;
|
||||
@ -801,7 +802,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
|
||||
/// doesn't have to be created if a serialized representation is already available.
|
||||
///
|
||||
/// If the exponent is public, `powWithEncodedPublicExponent()` can be used instead for a slight speedup.
|
||||
pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe {
|
||||
pub fn powWithEncodedExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe {
|
||||
return self.powWithEncodedExponentInternal(x, e, endian, false);
|
||||
}
|
||||
|
||||
@ -810,7 +811,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type {
|
||||
/// doesn't have to be created if a serialized representation is already available.
|
||||
///
|
||||
/// If the exponent is secret, `powWithEncodedExponent` must be used instead.
|
||||
pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: builtin.Endian) NullExponentError!Fe {
|
||||
pub fn powWithEncodedPublicExponent(self: Self, x: Fe, e: []const u8, endian: Endian) NullExponentError!Fe {
|
||||
return self.powWithEncodedExponentInternal(x, e, endian, true);
|
||||
}
|
||||
};
|
||||
@ -912,10 +913,8 @@ const ct_unprotected = struct {
|
||||
};
|
||||
|
||||
test {
|
||||
switch (@import("builtin").zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const M = Modulus(256);
|
||||
const m = try M.fromPrimitive(u256, 3429938563481314093726330772853735541133072814650493833233);
|
||||
|
||||
@ -478,10 +478,8 @@ pub const AffineCoordinates = struct {
|
||||
};
|
||||
|
||||
test {
|
||||
switch (@import("builtin").zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
_ = @import("tests/p384.zig");
|
||||
}
|
||||
|
||||
@ -556,10 +556,8 @@ pub const AffineCoordinates = struct {
|
||||
};
|
||||
|
||||
test {
|
||||
switch (@import("builtin").zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
_ = @import("tests/secp256k1.zig");
|
||||
}
|
||||
|
||||
@ -196,8 +196,6 @@ pub const Poly1305 = struct {
|
||||
};
|
||||
|
||||
test "poly1305 rfc7439 vector1" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const expected_mac = "\xa8\x06\x1d\xc1\x30\x51\x36\xc6\xc2\x2b\x8b\xaf\x0c\x01\x27\xa9";
|
||||
|
||||
const msg = "Cryptographic Forum Research Group";
|
||||
|
||||
@ -623,8 +623,6 @@ test "xsalsa20poly1305 sealedbox" {
|
||||
}
|
||||
|
||||
test "secretbox twoblocks" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const key = [_]u8{ 0xc9, 0xc9, 0x4d, 0xcf, 0x68, 0xbe, 0x00, 0xe4, 0x7f, 0xe6, 0x13, 0x26, 0xfc, 0xc4, 0x2f, 0xd0, 0xdb, 0x93, 0x91, 0x1c, 0x09, 0x94, 0x89, 0xe1, 0x1b, 0x88, 0x63, 0x18, 0x86, 0x64, 0x8b, 0x7b };
|
||||
const nonce = [_]u8{ 0xa4, 0x33, 0xe9, 0x0a, 0x07, 0x68, 0x6e, 0x9a, 0x2b, 0x6d, 0xd4, 0x59, 0x04, 0x72, 0x3e, 0xd3, 0x8a, 0x67, 0x55, 0xc7, 0x9e, 0x3e, 0x77, 0xdc };
|
||||
const msg = [_]u8{'a'} ** 97;
|
||||
|
||||
@ -238,7 +238,7 @@ fn Sha2x32(comptime params: Sha2Params32) type {
|
||||
return;
|
||||
},
|
||||
// C backend doesn't currently support passing vectors to inline asm.
|
||||
.x86_64 => if (builtin.zig_backend != .stage2_c and builtin.zig_backend != .stage2_x86_64 and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
|
||||
.x86_64 => if (builtin.zig_backend != .stage2_c and comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) {
|
||||
var x: v4u32 = [_]u32{ d.s[5], d.s[4], d.s[1], d.s[0] };
|
||||
var y: v4u32 = [_]u32{ d.s[7], d.s[6], d.s[3], d.s[2] };
|
||||
const s_v = @as(*[16]v4u32, @ptrCast(&s));
|
||||
|
||||
@ -3248,9 +3248,7 @@ test {
|
||||
_ = &makeDirAbsolute;
|
||||
_ = &makeDirAbsoluteZ;
|
||||
_ = ©FileAbsolute;
|
||||
if (builtin.zig_backend != .stage2_x86_64) {
|
||||
_ = &updateFileAbsolute;
|
||||
}
|
||||
_ = &updateFileAbsolute;
|
||||
}
|
||||
_ = &Dir.copyFile;
|
||||
_ = @import("fs/test.zig");
|
||||
|
||||
@ -1460,8 +1460,6 @@ test "walker without fully iterating" {
|
||||
test ". and .. in fs.Dir functions" {
|
||||
if (builtin.os.tag == .wasi and builtin.link_libc) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.os.tag == .windows and builtin.cpu.arch == .aarch64) {
|
||||
// https://github.com/ziglang/zig/issues/17134
|
||||
return error.SkipZigTest;
|
||||
@ -1502,8 +1500,6 @@ test ". and .. in fs.Dir functions" {
|
||||
test ". and .. in absolute functions" {
|
||||
if (builtin.os.tag == .wasi) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
|
||||
@ -161,8 +161,6 @@ test "setEndPos" {
|
||||
}
|
||||
|
||||
test "updateTimes" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var tmp = tmpDir(.{});
|
||||
defer tmp.cleanup();
|
||||
|
||||
|
||||
@ -764,8 +764,6 @@ test "y_number_simple_real.json" {
|
||||
try ok("[123.456789]");
|
||||
}
|
||||
test "y_object.json" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try ok("{\"asd\":\"sdf\", \"dfg\":\"fgh\"}");
|
||||
}
|
||||
test "y_object_basic.json" {
|
||||
@ -787,13 +785,9 @@ test "y_object_escaped_null_in_key.json" {
|
||||
try ok("{\"foo\\u0000bar\": 42}");
|
||||
}
|
||||
test "y_object_extreme_numbers.json" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try ok("{ \"min\": -1.0e+28, \"max\": 1.0e+28 }");
|
||||
}
|
||||
test "y_object_long_strings.json" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try ok("{\"x\":[{\"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}], \"id\": \"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\"}");
|
||||
}
|
||||
test "y_object_simple.json" {
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const mem = std.mem;
|
||||
const testing = std.testing;
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
@ -19,8 +18,6 @@ const jsonReader = @import("scanner.zig").reader;
|
||||
const JsonReader = @import("scanner.zig").Reader;
|
||||
|
||||
test "json.parser.dynamic" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const s =
|
||||
\\{
|
||||
\\ "Image": {
|
||||
@ -75,8 +72,6 @@ test "json.parser.dynamic" {
|
||||
|
||||
const writeStream = @import("./stringify.zig").writeStream;
|
||||
test "write json then parse it" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var out_buffer: [1000]u8 = undefined;
|
||||
|
||||
var fixed_buffer_stream = std.io.fixedBufferStream(&out_buffer);
|
||||
@ -143,8 +138,6 @@ test "Value.array allocator should still be usable after parsing" {
|
||||
}
|
||||
|
||||
test "integer after float has proper type" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
|
||||
defer arena_allocator.deinit();
|
||||
const parsed = try testParse(arena_allocator.allocator(),
|
||||
@ -157,8 +150,6 @@ test "integer after float has proper type" {
|
||||
}
|
||||
|
||||
test "escaped characters" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var arena_allocator = std.heap.ArenaAllocator.init(std.testing.allocator);
|
||||
defer arena_allocator.deinit();
|
||||
const input =
|
||||
@ -238,8 +229,6 @@ test "Value.jsonStringify" {
|
||||
}
|
||||
|
||||
test "parseFromValue(std.json.Value,...)" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const str =
|
||||
\\{
|
||||
\\ "int": 32,
|
||||
@ -328,8 +317,6 @@ test "ParseOptions.max_value_len" {
|
||||
}
|
||||
|
||||
test "many object keys" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const doc =
|
||||
\\{
|
||||
\\ "k1": "v1",
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const testing = std.testing;
|
||||
|
||||
const ArrayHashMap = @import("hashmap.zig").ArrayHashMap;
|
||||
@ -19,8 +18,6 @@ const T = struct {
|
||||
};
|
||||
|
||||
test "parse json hashmap" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const doc =
|
||||
\\{
|
||||
\\ "abc": {"i": 0, "s": "d"},
|
||||
@ -36,8 +33,6 @@ test "parse json hashmap" {
|
||||
}
|
||||
|
||||
test "parse json hashmap while streaming" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const doc =
|
||||
\\{
|
||||
\\ "abc": {"i": 0, "s": "d"},
|
||||
@ -63,8 +58,6 @@ test "parse json hashmap while streaming" {
|
||||
}
|
||||
|
||||
test "parse json hashmap duplicate fields" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var arena = std.heap.ArenaAllocator.init(std.testing.allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
@ -93,8 +86,6 @@ test "parse json hashmap duplicate fields" {
|
||||
}
|
||||
|
||||
test "stringify json hashmap" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var value = ArrayHashMap(T){};
|
||||
defer value.deinit(testing.allocator);
|
||||
{
|
||||
@ -132,8 +123,6 @@ test "stringify json hashmap" {
|
||||
}
|
||||
|
||||
test "stringify json hashmap whitespace" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var value = ArrayHashMap(T){};
|
||||
defer value.deinit(testing.allocator);
|
||||
try value.map.put(testing.allocator, "abc", .{ .i = 0, .s = "d" });
|
||||
@ -158,8 +147,6 @@ test "stringify json hashmap whitespace" {
|
||||
}
|
||||
|
||||
test "json parse from value hashmap" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const doc =
|
||||
\\{
|
||||
\\ "abc": {"i": 0, "s": "d"},
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const testing = std.testing;
|
||||
const ArenaAllocator = std.heap.ArenaAllocator;
|
||||
const Allocator = std.mem.Allocator;
|
||||
@ -786,7 +785,7 @@ test "max_value_len" {
|
||||
}
|
||||
|
||||
test "parse into vector" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const T = struct {
|
||||
vec_i32: @Vector(4, i32),
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const mem = std.mem;
|
||||
const testing = std.testing;
|
||||
|
||||
@ -16,8 +15,6 @@ const writeStreamMaxDepth = @import("stringify.zig").writeStreamMaxDepth;
|
||||
const writeStreamArbitraryDepth = @import("stringify.zig").writeStreamArbitraryDepth;
|
||||
|
||||
test "json write stream" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var out_buf: [1024]u8 = undefined;
|
||||
var slice_stream = std.io.fixedBufferStream(&out_buf);
|
||||
const out = slice_stream.writer();
|
||||
|
||||
@ -34,8 +34,6 @@ fn testHighLevelDynamicParser(s: []const u8) !void {
|
||||
|
||||
// Additional tests not part of test JSONTestSuite.
|
||||
test "y_trailing_comma_after_empty" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try roundTrip(
|
||||
\\{"1":[],"2":{},"3":"4"}
|
||||
);
|
||||
|
||||
@ -517,8 +517,6 @@ test "big.int add multi-single" {
|
||||
}
|
||||
|
||||
test "big.int add multi-multi" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u128 = 0xefefefef7f7f7f7f;
|
||||
var op2: u128 = 0xfefefefe9f9f9f9f;
|
||||
var a = try Managed.initSet(testing.allocator, op1);
|
||||
@ -633,8 +631,6 @@ test "big.int subWrap single-single, unsigned" {
|
||||
}
|
||||
|
||||
test "big.int addWrap multi-multi, unsigned, limb aligned" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb));
|
||||
defer a.deinit();
|
||||
|
||||
@ -687,8 +683,6 @@ test "big.int subWrap single-single, signed" {
|
||||
}
|
||||
|
||||
test "big.int addWrap multi-multi, signed, limb aligned" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, maxInt(SignedDoubleLimb));
|
||||
defer a.deinit();
|
||||
|
||||
@ -739,8 +733,6 @@ test "big.int subSat single-single, unsigned" {
|
||||
}
|
||||
|
||||
test "big.int addSat multi-multi, unsigned, limb aligned" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, maxInt(DoubleLimb));
|
||||
defer a.deinit();
|
||||
|
||||
@ -826,8 +818,6 @@ test "big.int sub single-single" {
|
||||
}
|
||||
|
||||
test "big.int sub multi-single" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, maxInt(Limb) + 1);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, 1);
|
||||
@ -841,8 +831,6 @@ test "big.int sub multi-single" {
|
||||
}
|
||||
|
||||
test "big.int sub multi-multi" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u128 = 0xefefefefefefefefefefefef;
|
||||
var op2: u128 = 0xabababababababababababab;
|
||||
|
||||
@ -927,10 +915,8 @@ test "big.int mul multi-single" {
|
||||
}
|
||||
|
||||
test "big.int mul multi-multi" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u256 = 0x998888efefefefefefefef;
|
||||
var op2: u256 = 0x333000abababababababab;
|
||||
@ -1053,10 +1039,8 @@ test "big.int mulWrap single-single signed" {
|
||||
}
|
||||
|
||||
test "big.int mulWrap multi-multi unsigned" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u256 = 0x998888efefefefefefefef;
|
||||
var op2: u256 = 0x333000abababababababab;
|
||||
@ -1182,8 +1166,6 @@ test "big.int div single-single with rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi-single no rem" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u128 = 0xffffeeeeddddcccc;
|
||||
var op2: u128 = 34;
|
||||
|
||||
@ -1203,8 +1185,6 @@ test "big.int div multi-single no rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi-single with rem" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u128 = 0xffffeeeeddddcccf;
|
||||
var op2: u128 = 34;
|
||||
|
||||
@ -1224,8 +1204,6 @@ test "big.int div multi-single with rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi>2-single" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var op1: u128 = 0xfefefefefefefefefefefefefefefefe;
|
||||
var op2: u128 = 0xefab8;
|
||||
|
||||
@ -1405,8 +1383,6 @@ test "big.int div trunc single-single -/-" {
|
||||
}
|
||||
|
||||
test "big.int divTrunc #15535" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var one = try Managed.initSet(testing.allocator, 1);
|
||||
defer one.deinit();
|
||||
var x = try Managed.initSet(testing.allocator, std.math.pow(u128, 2, 64));
|
||||
@ -1420,8 +1396,6 @@ test "big.int divTrunc #15535" {
|
||||
}
|
||||
|
||||
test "big.int divFloor #10932" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -1446,8 +1420,6 @@ test "big.int divFloor #10932" {
|
||||
}
|
||||
|
||||
test "big.int divFloor #11166" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -1475,8 +1447,6 @@ test "big.int divFloor #11166" {
|
||||
}
|
||||
|
||||
test "big.int gcd #10932" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -1668,10 +1638,7 @@ test "big.int div floor positive close to zero" {
|
||||
}
|
||||
|
||||
test "big.int div multi-multi with rem" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeeddddccccbbbbaaaa9999);
|
||||
defer a.deinit();
|
||||
@ -1689,10 +1656,7 @@ test "big.int div multi-multi with rem" {
|
||||
}
|
||||
|
||||
test "big.int div multi-multi no rem" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x8888999911110000ffffeeeedb4fec200ee3a4286361);
|
||||
defer a.deinit();
|
||||
@ -1728,10 +1692,8 @@ test "big.int div multi-multi (2 branch)" {
|
||||
}
|
||||
|
||||
test "big.int div multi-multi (3.1/3.3 branch)" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x11111111111111111111111111111111111111111111111111111111111111);
|
||||
defer a.deinit();
|
||||
@ -1790,10 +1752,7 @@ test "big.int div multi-multi zero-limb trailing (with rem)" {
|
||||
}
|
||||
|
||||
test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count > divisor zero-limb count" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x8666666655555555888888877777777611111111111111110000000000000000);
|
||||
defer a.deinit();
|
||||
@ -1814,10 +1773,7 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li
|
||||
}
|
||||
|
||||
test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-limb count < divisor zero-limb count" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x86666666555555558888888777777776111111111111111100000000000000000000000000000000);
|
||||
defer a.deinit();
|
||||
@ -1840,8 +1796,6 @@ test "big.int div multi-multi zero-limb trailing (with rem) and dividend zero-li
|
||||
}
|
||||
|
||||
test "big.int div multi-multi fuzz case #1" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Managed.init(testing.allocator);
|
||||
@ -1938,8 +1892,6 @@ test "big.int truncate multi to multi unsigned" {
|
||||
}
|
||||
|
||||
test "big.int truncate multi to multi signed" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 3 << @bitSizeOf(Limb));
|
||||
defer a.deinit();
|
||||
|
||||
@ -1949,8 +1901,6 @@ test "big.int truncate multi to multi signed" {
|
||||
}
|
||||
|
||||
test "big.int truncate negative multi to single" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, -@as(SignedDoubleLimb, maxInt(Limb) + 1));
|
||||
defer a.deinit();
|
||||
|
||||
@ -2057,8 +2007,6 @@ test "big.int shift-right multi" {
|
||||
}
|
||||
|
||||
test "big.int shift-left single" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0xffff);
|
||||
defer a.deinit();
|
||||
try a.shiftLeft(&a, 16);
|
||||
@ -2103,8 +2051,6 @@ test "big.int sat shift-left simple unsigned" {
|
||||
}
|
||||
|
||||
test "big.int sat shift-left simple unsigned no sat" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 1);
|
||||
defer a.deinit();
|
||||
try a.shiftLeftSat(&a, 16, .unsigned, 21);
|
||||
@ -2362,8 +2308,6 @@ test "big.int bitwise xor simple" {
|
||||
}
|
||||
|
||||
test "big.int bitwise xor multi-limb" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var x: DoubleLimb = maxInt(Limb) + 1;
|
||||
var y: DoubleLimb = maxInt(Limb);
|
||||
var a = try Managed.initSet(testing.allocator, x);
|
||||
@ -2538,8 +2482,6 @@ test "big.int var args" {
|
||||
}
|
||||
|
||||
test "big.int gcd non-one small" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 17);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, 97);
|
||||
@ -2553,8 +2495,6 @@ test "big.int gcd non-one small" {
|
||||
}
|
||||
|
||||
test "big.int gcd non-one medium" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 4864);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, 3458);
|
||||
@ -2568,8 +2508,6 @@ test "big.int gcd non-one medium" {
|
||||
}
|
||||
|
||||
test "big.int gcd non-one large" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0xffffffffffffffff);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, 0xffffffffffffffff7777);
|
||||
@ -2583,10 +2521,8 @@ test "big.int gcd non-one large" {
|
||||
}
|
||||
|
||||
test "big.int gcd large multi-limb result" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x12345678123456781234567812345678123456781234567812345678);
|
||||
defer a.deinit();
|
||||
@ -2602,8 +2538,6 @@ test "big.int gcd large multi-limb result" {
|
||||
}
|
||||
|
||||
test "big.int gcd one large" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 1897056385327307);
|
||||
defer a.deinit();
|
||||
var b = try Managed.initSet(testing.allocator, 2251799813685248);
|
||||
@ -2695,8 +2629,6 @@ test "big.int pow" {
|
||||
}
|
||||
|
||||
test "big.int sqrt" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var r = try Managed.init(testing.allocator);
|
||||
defer r.deinit();
|
||||
var a = try Managed.init(testing.allocator);
|
||||
@ -2727,8 +2659,6 @@ test "big.int sqrt" {
|
||||
}
|
||||
|
||||
test "big.int regression test for 1 limb overflow with alias" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// Note these happen to be two consecutive Fibonacci sequence numbers, the
|
||||
// first two whose sum exceeds 2**64.
|
||||
var a = try Managed.initSet(testing.allocator, 7540113804746346429);
|
||||
@ -2743,8 +2673,6 @@ test "big.int regression test for 1 limb overflow with alias" {
|
||||
}
|
||||
|
||||
test "big.int regression test for realloc with alias" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
// Note these happen to be two consecutive Fibonacci sequence numbers, the
|
||||
// second of which is the first such number to exceed 2**192.
|
||||
var a = try Managed.initSet(testing.allocator, 5611500259351924431073312796924978741056961814867751431689);
|
||||
@ -2759,8 +2687,6 @@ test "big.int regression test for realloc with alias" {
|
||||
}
|
||||
|
||||
test "big int popcount" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -3126,8 +3052,6 @@ fn byteSwapTest(comptime T: type, comptime input: comptime_int, comptime expecte
|
||||
}
|
||||
|
||||
test "big int byte swap" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff);
|
||||
defer a.deinit();
|
||||
|
||||
@ -3172,8 +3096,6 @@ test "big int byte swap" {
|
||||
}
|
||||
|
||||
test "big.int mul multi-multi alias r with a and b" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb));
|
||||
defer a.deinit();
|
||||
|
||||
@ -3190,8 +3112,6 @@ test "big.int mul multi-multi alias r with a and b" {
|
||||
}
|
||||
|
||||
test "big.int sqr multi alias r with a" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Managed.initSet(testing.allocator, 2 * maxInt(Limb));
|
||||
defer a.deinit();
|
||||
|
||||
|
||||
@ -514,8 +514,6 @@ test "big.rational extractLowBits" {
|
||||
}
|
||||
|
||||
test "big.rational set" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -545,8 +543,6 @@ test "big.rational set" {
|
||||
}
|
||||
|
||||
test "big.rational setFloat" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -572,8 +568,6 @@ test "big.rational setFloat" {
|
||||
}
|
||||
|
||||
test "big.rational setFloatString" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -585,8 +579,6 @@ test "big.rational setFloatString" {
|
||||
}
|
||||
|
||||
test "big.rational toFloat" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -600,8 +592,6 @@ test "big.rational toFloat" {
|
||||
}
|
||||
|
||||
test "big.rational set/to Float round-trip" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var prng = std.rand.DefaultPrng.init(0x5EED);
|
||||
@ -615,8 +605,6 @@ test "big.rational set/to Float round-trip" {
|
||||
}
|
||||
|
||||
test "big.rational copy" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -681,8 +669,6 @@ test "big.rational abs" {
|
||||
}
|
||||
|
||||
test "big.rational swap" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -707,8 +693,6 @@ test "big.rational swap" {
|
||||
}
|
||||
|
||||
test "big.rational order" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -724,8 +708,6 @@ test "big.rational order" {
|
||||
}
|
||||
|
||||
test "big.rational order/orderAbs with negative" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -738,8 +720,6 @@ test "big.rational order/orderAbs with negative" {
|
||||
}
|
||||
|
||||
test "big.rational add single-limb" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -755,8 +735,6 @@ test "big.rational add single-limb" {
|
||||
}
|
||||
|
||||
test "big.rational add" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -773,8 +751,6 @@ test "big.rational add" {
|
||||
}
|
||||
|
||||
test "big.rational sub" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -791,8 +767,6 @@ test "big.rational sub" {
|
||||
}
|
||||
|
||||
test "big.rational mul" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
var b = try Rational.init(testing.allocator);
|
||||
@ -809,8 +783,6 @@ test "big.rational mul" {
|
||||
}
|
||||
|
||||
test "big.rational div" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
{
|
||||
var a = try Rational.init(testing.allocator);
|
||||
defer a.deinit();
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
// https://git.musl-libc.org/cgit/musl/tree/src/math/ilogb.c
|
||||
|
||||
const std = @import("../std.zig");
|
||||
const builtin = @import("builtin");
|
||||
const math = std.math;
|
||||
const expect = std.testing.expect;
|
||||
const maxInt = std.math.maxInt;
|
||||
@ -109,7 +108,7 @@ test "64" {
|
||||
}
|
||||
|
||||
test "80" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
try expect(ilogbX(f80, 0.0) == fp_ilogb0);
|
||||
try expect(ilogbX(f80, 0.5) == -1);
|
||||
|
||||
@ -1025,8 +1025,6 @@ pub fn indexOfSentinel(comptime T: type, comptime sentinel: T, p: [*:sentinel]co
|
||||
}
|
||||
|
||||
test "indexOfSentinel vector paths" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const Types = [_]type{ u8, u16, u32, u64 };
|
||||
const allocator = std.testing.allocator;
|
||||
|
||||
@ -4661,10 +4659,8 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice
|
||||
}
|
||||
|
||||
test "read/write(Var)PackedInt" {
|
||||
switch (builtin.zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
switch (builtin.cpu.arch) {
|
||||
// This test generates too much code to execute on WASI.
|
||||
|
||||
@ -107,7 +107,6 @@ test "parse and render UNIX addresses" {
|
||||
}
|
||||
|
||||
test "resolve DNS" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.os.tag == .wasi) return error.SkipZigTest;
|
||||
|
||||
if (builtin.os.tag == .windows) {
|
||||
|
||||
@ -2212,8 +2212,6 @@ test "sendmsg/recvmsg" {
|
||||
test "timeout (after a relative time)" {
|
||||
if (builtin.os.tag != .linux) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var ring = IO_Uring.init(1, 0) catch |err| switch (err) {
|
||||
error.SystemOutdated => return error.SkipZigTest,
|
||||
error.PermissionDenied => return error.SkipZigTest,
|
||||
@ -2278,8 +2276,6 @@ test "timeout (after a number of completions)" {
|
||||
test "timeout_remove" {
|
||||
if (builtin.os.tag != .linux) return error.SkipZigTest;
|
||||
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var ring = IO_Uring.init(2, 0) catch |err| switch (err) {
|
||||
error.SystemOutdated => return error.SkipZigTest,
|
||||
error.PermissionDenied => return error.SkipZigTest,
|
||||
|
||||
@ -90,10 +90,8 @@ pub fn fill(self: *Xoshiro256, buf: []u8) void {
|
||||
}
|
||||
|
||||
test "xoroshiro sequence" {
|
||||
switch (@import("builtin").zig_backend) {
|
||||
.stage2_c, .stage2_x86_64 => return error.SkipZigTest,
|
||||
else => {},
|
||||
}
|
||||
if (@import("builtin").zig_backend == .stage2_c) return error.SkipZigTest;
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var r = Xoshiro256.init(0);
|
||||
|
||||
|
||||
@ -436,7 +436,7 @@ pub fn prefixScan(comptime op: std.builtin.ReduceOp, comptime hop: isize, vec: a
|
||||
}
|
||||
|
||||
test "vector prefix scan" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isMIPS()) {
|
||||
return error.SkipZigTest;
|
||||
|
||||
@ -122,8 +122,6 @@ pub fn nanoTimestamp() i128 {
|
||||
}
|
||||
|
||||
test "timestamp" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
const margin = ns_per_ms * 50;
|
||||
|
||||
const time_0 = milliTimestamp();
|
||||
|
||||
@ -350,8 +350,6 @@ const TestTreap = Treap(u64, std.math.order);
|
||||
const TestNode = TestTreap.Node;
|
||||
|
||||
test "std.Treap: insert, find, replace, remove" {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
var treap = TestTreap{};
|
||||
var nodes: [10]TestNode = undefined;
|
||||
|
||||
|
||||
@ -4102,7 +4102,5 @@ const TokenIndex = Ast.TokenIndex;
|
||||
const Token = std.zig.Token;
|
||||
|
||||
test {
|
||||
if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
_ = @import("parser_test.zig");
|
||||
}
|
||||
|
||||
@ -2293,7 +2293,11 @@ fn genLazy(self: *Self, lazy_sym: link.File.LazySymbol) InnerError!void {
|
||||
}
|
||||
}
|
||||
|
||||
fn getValue(self: *Self, value: MCValue, inst: ?Air.Inst.Index) void {
|
||||
fn getValue(self: *Self, value: MCValue, inst: ?Air.Inst.Index) !void {
|
||||
for (value.getRegs()) |reg| try self.register_manager.getReg(reg, inst);
|
||||
}
|
||||
|
||||
fn getValueIfFree(self: *Self, value: MCValue, inst: ?Air.Inst.Index) void {
|
||||
for (value.getRegs()) |reg| if (self.register_manager.isRegFree(reg))
|
||||
self.register_manager.getRegAssumeFree(reg, inst);
|
||||
}
|
||||
@ -2341,7 +2345,7 @@ fn finishAirResult(self: *Self, inst: Air.Inst.Index, result: MCValue) void {
|
||||
// In some cases, an operand may be reused as the result.
|
||||
// If that operand died and was a register, it was freed by
|
||||
// processDeath, so we have to "re-allocate" the register.
|
||||
self.getValue(result, inst);
|
||||
self.getValueIfFree(result, inst);
|
||||
}
|
||||
self.finishAirBookkeeping();
|
||||
}
|
||||
@ -3221,6 +3225,7 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
|
||||
.Float, .Vector => break :result try self.genBinOp(inst, tag, bin_op.lhs, bin_op.rhs),
|
||||
else => {},
|
||||
}
|
||||
const dst_abi_size: u32 = @intCast(dst_ty.abiSize(mod));
|
||||
|
||||
const dst_info = dst_ty.intInfo(mod);
|
||||
const src_ty = try mod.intType(dst_info.signedness, switch (tag) {
|
||||
@ -3232,12 +3237,153 @@ fn airMulDivBinOp(self: *Self, inst: Air.Inst.Index) !void {
|
||||
),
|
||||
.div_trunc, .div_floor, .div_exact, .rem, .mod => dst_info.bits,
|
||||
});
|
||||
const src_abi_size: u32 = @intCast(src_ty.abiSize(mod));
|
||||
|
||||
if (dst_abi_size == 16 and src_abi_size == 16) switch (tag) {
|
||||
else => unreachable,
|
||||
.mul, .mul_wrap => {},
|
||||
.div_trunc, .div_floor, .div_exact, .rem, .mod => {
|
||||
const signed = dst_ty.isSignedInt(mod);
|
||||
var callee_buf: ["__udiv?i3".len]u8 = undefined;
|
||||
const signed_div_floor_state: struct {
|
||||
frame_index: FrameIndex,
|
||||
reloc: Mir.Inst.Index,
|
||||
} = if (signed and tag == .div_floor) state: {
|
||||
const frame_index = try self.allocFrameIndex(FrameAlloc.initType(Type.usize, mod));
|
||||
try self.asmMemoryImmediate(
|
||||
.{ ._, .mov },
|
||||
Memory.sib(.qword, .{ .base = .{ .frame = frame_index } }),
|
||||
Immediate.u(0),
|
||||
);
|
||||
|
||||
const tmp_reg = try self.register_manager.allocReg(null, abi.RegisterClass.gp);
|
||||
const tmp_lock = self.register_manager.lockRegAssumeUnused(tmp_reg);
|
||||
defer self.register_manager.unlockReg(tmp_lock);
|
||||
|
||||
const lhs_mcv = try self.resolveInst(bin_op.lhs);
|
||||
if (lhs_mcv.isMemory()) try self.asmRegisterMemory(
|
||||
.{ ._, .mov },
|
||||
tmp_reg,
|
||||
lhs_mcv.address().offset(8).deref().mem(.qword),
|
||||
) else try self.asmRegisterRegister(
|
||||
.{ ._, .mov },
|
||||
tmp_reg,
|
||||
lhs_mcv.register_pair[1],
|
||||
);
|
||||
|
||||
const rhs_mcv = try self.resolveInst(bin_op.rhs);
|
||||
if (rhs_mcv.isMemory()) try self.asmRegisterMemory(
|
||||
.{ ._, .xor },
|
||||
tmp_reg,
|
||||
rhs_mcv.address().offset(8).deref().mem(.qword),
|
||||
) else try self.asmRegisterRegister(
|
||||
.{ ._, .xor },
|
||||
tmp_reg,
|
||||
rhs_mcv.register_pair[1],
|
||||
);
|
||||
const reloc = try self.asmJccReloc(.ns, undefined);
|
||||
|
||||
break :state .{ .frame_index = frame_index, .reloc = reloc };
|
||||
} else undefined;
|
||||
const call_mcv = try self.genCall(
|
||||
.{ .lib = .{
|
||||
.return_type = dst_ty.toIntern(),
|
||||
.param_types = &.{ src_ty.toIntern(), src_ty.toIntern() },
|
||||
.callee = std.fmt.bufPrint(&callee_buf, "__{s}{s}{c}i3", .{
|
||||
if (signed) "" else "u",
|
||||
switch (tag) {
|
||||
.div_trunc, .div_exact => "div",
|
||||
.div_floor => if (signed) "mod" else "div",
|
||||
.rem, .mod => "mod",
|
||||
else => unreachable,
|
||||
},
|
||||
intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))),
|
||||
}) catch unreachable,
|
||||
} },
|
||||
&.{ src_ty, src_ty },
|
||||
&.{ .{ .air_ref = bin_op.lhs }, .{ .air_ref = bin_op.rhs } },
|
||||
);
|
||||
break :result if (signed) switch (tag) {
|
||||
.div_floor => {
|
||||
try self.asmRegisterRegister(
|
||||
.{ ._, .@"or" },
|
||||
call_mcv.register_pair[0],
|
||||
call_mcv.register_pair[1],
|
||||
);
|
||||
try self.asmSetccMemory(.nz, Memory.sib(.byte, .{
|
||||
.base = .{ .frame = signed_div_floor_state.frame_index },
|
||||
}));
|
||||
try self.performReloc(signed_div_floor_state.reloc);
|
||||
const dst_mcv = try self.genCall(
|
||||
.{ .lib = .{
|
||||
.return_type = dst_ty.toIntern(),
|
||||
.param_types = &.{ src_ty.toIntern(), src_ty.toIntern() },
|
||||
.callee = std.fmt.bufPrint(&callee_buf, "__div{c}i3", .{
|
||||
intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))),
|
||||
}) catch unreachable,
|
||||
} },
|
||||
&.{ src_ty, src_ty },
|
||||
&.{ .{ .air_ref = bin_op.lhs }, .{ .air_ref = bin_op.rhs } },
|
||||
);
|
||||
try self.asmRegisterMemory(
|
||||
.{ ._, .sub },
|
||||
dst_mcv.register_pair[0],
|
||||
Memory.sib(.qword, .{
|
||||
.base = .{ .frame = signed_div_floor_state.frame_index },
|
||||
}),
|
||||
);
|
||||
try self.asmRegisterImmediate(
|
||||
.{ ._, .sbb },
|
||||
dst_mcv.register_pair[1],
|
||||
Immediate.u(0),
|
||||
);
|
||||
try self.freeValue(
|
||||
.{ .load_frame = .{ .index = signed_div_floor_state.frame_index } },
|
||||
);
|
||||
break :result dst_mcv;
|
||||
},
|
||||
.mod => {
|
||||
const dst_regs = call_mcv.register_pair;
|
||||
const dst_locks = self.register_manager.lockRegsAssumeUnused(2, dst_regs);
|
||||
defer for (dst_locks) |lock| self.register_manager.unlockReg(lock);
|
||||
|
||||
const tmp_regs =
|
||||
try self.register_manager.allocRegs(2, .{null} ** 2, abi.RegisterClass.gp);
|
||||
const tmp_locks = self.register_manager.lockRegsAssumeUnused(2, tmp_regs);
|
||||
defer for (tmp_locks) |lock| self.register_manager.unlockReg(lock);
|
||||
|
||||
const rhs_mcv = try self.resolveInst(bin_op.rhs);
|
||||
|
||||
for (tmp_regs, dst_regs) |tmp_reg, dst_reg|
|
||||
try self.asmRegisterRegister(.{ ._, .mov }, tmp_reg, dst_reg);
|
||||
if (rhs_mcv.isMemory()) {
|
||||
try self.asmRegisterMemory(.{ ._, .add }, tmp_regs[0], rhs_mcv.mem(.qword));
|
||||
try self.asmRegisterMemory(
|
||||
.{ ._, .adc },
|
||||
tmp_regs[1],
|
||||
rhs_mcv.address().offset(8).deref().mem(.qword),
|
||||
);
|
||||
} else for (
|
||||
[_]Mir.Inst.Tag{ .add, .adc },
|
||||
tmp_regs,
|
||||
rhs_mcv.register_pair,
|
||||
) |op, tmp_reg, rhs_reg|
|
||||
try self.asmRegisterRegister(.{ ._, op }, tmp_reg, rhs_reg);
|
||||
try self.asmRegisterRegister(.{ ._, .@"test" }, dst_regs[1], dst_regs[1]);
|
||||
for (dst_regs, tmp_regs) |dst_reg, tmp_reg|
|
||||
try self.asmCmovccRegisterRegister(.s, dst_reg, tmp_reg);
|
||||
break :result call_mcv;
|
||||
},
|
||||
else => call_mcv,
|
||||
} else call_mcv;
|
||||
},
|
||||
};
|
||||
|
||||
try self.spillEflagsIfOccupied();
|
||||
try self.spillRegisters(&.{ .rax, .rdx });
|
||||
const lhs = try self.resolveInst(bin_op.lhs);
|
||||
const rhs = try self.resolveInst(bin_op.rhs);
|
||||
break :result try self.genMulDivBinOp(tag, inst, dst_ty, src_ty, lhs, rhs);
|
||||
const lhs_mcv = try self.resolveInst(bin_op.lhs);
|
||||
const rhs_mcv = try self.resolveInst(bin_op.rhs);
|
||||
break :result try self.genMulDivBinOp(tag, inst, dst_ty, src_ty, lhs_mcv, rhs_mcv);
|
||||
};
|
||||
return self.finishAir(inst, result, .{ bin_op.lhs, bin_op.rhs, .none });
|
||||
}
|
||||
@ -4594,6 +4740,7 @@ fn airArrayElemVal(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
// TODO we could allocate register here, but need to expect addr register and potentially
|
||||
// offset register.
|
||||
try self.spillEflagsIfOccupied();
|
||||
const dst_mcv = try self.allocRegOrMem(inst, false);
|
||||
try self.genBinOpMir(
|
||||
.{ ._, .add },
|
||||
@ -7201,37 +7348,7 @@ fn genMulDivBinOp(
|
||||
assert(self.eflags_inst == null);
|
||||
|
||||
if (dst_abi_size == 16 and src_abi_size == 16) {
|
||||
switch (tag) {
|
||||
else => unreachable,
|
||||
.mul, .mul_wrap => {},
|
||||
.div_trunc, .div_floor, .div_exact, .rem, .mod => {
|
||||
const signed = dst_ty.isSignedInt(mod);
|
||||
if (signed) switch (tag) {
|
||||
.div_floor, .mod => return self.fail(
|
||||
"TODO implement genMulDivBinOp for {s} from {} to {}",
|
||||
.{ @tagName(tag), src_ty.fmt(mod), dst_ty.fmt(mod) },
|
||||
),
|
||||
else => {},
|
||||
};
|
||||
var callee_buf: ["__udiv?i3".len]u8 = undefined;
|
||||
return try self.genCall(.{ .lib = .{
|
||||
.return_type = dst_ty.toIntern(),
|
||||
.param_types = &.{ src_ty.toIntern(), src_ty.toIntern() },
|
||||
.callee = std.fmt.bufPrint(&callee_buf, "__{s}{s}{c}i3", .{
|
||||
if (signed) "" else "u",
|
||||
switch (tag) {
|
||||
.div_trunc, .div_exact => "div",
|
||||
.div_floor => if (signed) unreachable else "div",
|
||||
.rem => "mod",
|
||||
.mod => if (signed) unreachable else "mod",
|
||||
else => unreachable,
|
||||
},
|
||||
intCompilerRtAbiName(@intCast(dst_ty.bitSize(mod))),
|
||||
}) catch unreachable,
|
||||
} }, &.{ src_ty, src_ty }, &.{ lhs_mcv, rhs_mcv });
|
||||
},
|
||||
}
|
||||
|
||||
assert(tag == .mul or tag == .mul_wrap);
|
||||
const reg_locks = self.register_manager.lockRegsAssumeUnused(2, .{ .rax, .rdx });
|
||||
defer for (reg_locks) |lock| self.register_manager.unlockReg(lock);
|
||||
|
||||
@ -9436,6 +9553,7 @@ fn genBinOpMir(
|
||||
fn genIntMulComplexOpMir(self: *Self, dst_ty: Type, dst_mcv: MCValue, src_mcv: MCValue) InnerError!void {
|
||||
const mod = self.bin_file.options.module.?;
|
||||
const abi_size: u32 = @intCast(dst_ty.abiSize(mod));
|
||||
try self.spillEflagsIfOccupied();
|
||||
switch (dst_mcv) {
|
||||
.none,
|
||||
.unreach,
|
||||
@ -10509,8 +10627,6 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
const else_body = self.air.extra[extra.end + then_body.len ..][0..extra.data.else_body_len];
|
||||
const liveness_cond_br = self.liveness.getCondBr(inst);
|
||||
|
||||
const reloc = try self.genCondBrMir(cond_ty, cond);
|
||||
|
||||
// If the condition dies here in this condbr instruction, process
|
||||
// that death now instead of later as this has an effect on
|
||||
// whether it needs to be spilled in the branches
|
||||
@ -10520,6 +10636,7 @@ fn airCondBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
|
||||
self.scope_generation += 1;
|
||||
const state = try self.saveState();
|
||||
const reloc = try self.genCondBrMir(cond_ty, cond);
|
||||
|
||||
for (liveness_cond_br.then_deaths) |death| try self.processDeath(death);
|
||||
try self.genBody(then_body);
|
||||
@ -10905,7 +11022,7 @@ fn airBlock(self: *Self, inst: Air.Inst.Index) !void {
|
||||
if (std.debug.runtime_safety) assert(self.inst_tracking.getIndex(inst).? == inst_tracking_i);
|
||||
const tracking = &self.inst_tracking.values()[inst_tracking_i];
|
||||
if (self.liveness.isUnused(inst)) try tracking.die(self, inst);
|
||||
self.getValue(tracking.short, inst);
|
||||
self.getValueIfFree(tracking.short, inst);
|
||||
self.finishAirBookkeeping();
|
||||
}
|
||||
|
||||
@ -11019,7 +11136,7 @@ fn airBr(self: *Self, inst: Air.Inst.Index) !void {
|
||||
}
|
||||
|
||||
const dst_mcv = if (first_br) try self.allocRegOrMem(br.block_inst, true) else dst: {
|
||||
self.getValue(block_tracking.short, br.block_inst);
|
||||
try self.getValue(block_tracking.short, br.block_inst);
|
||||
break :dst block_tracking.short;
|
||||
};
|
||||
try self.genCopy(block_ty, dst_mcv, src_mcv);
|
||||
@ -13248,6 +13365,7 @@ fn airMemset(self: *Self, inst: Air.Inst.Index, safety: bool) !void {
|
||||
defer self.register_manager.unlockReg(len_lock);
|
||||
|
||||
try self.genSetReg(len_reg, Type.usize, len);
|
||||
try self.asmRegisterRegister(.{ ._, .@"test" }, len_reg, len_reg);
|
||||
|
||||
const skip_reloc = try self.asmJccReloc(.z, undefined);
|
||||
try self.store(slice_ptr_ty, ptr, src_val);
|
||||
@ -14768,6 +14886,7 @@ fn truncateRegister(self: *Self, ty: Type, reg: Register) !void {
|
||||
.bits = @intCast(ty.bitSize(mod)),
|
||||
};
|
||||
const max_reg_bit_width = Register.rax.bitSize();
|
||||
try self.spillEflagsIfOccupied();
|
||||
switch (int_info.signedness) {
|
||||
.signed => {
|
||||
const shift: u6 = @intCast(max_reg_bit_width - int_info.bits);
|
||||
|
||||
66
src/main.zig
66
src/main.zig
@ -3774,7 +3774,9 @@ fn serve(
|
||||
try comp.makeBinFileWritable();
|
||||
}
|
||||
|
||||
{
|
||||
if (builtin.single_threaded) {
|
||||
try comp.update(main_progress_node);
|
||||
} else {
|
||||
var reset: std.Thread.ResetEvent = .{};
|
||||
|
||||
var progress_thread = try std.Thread.spawn(.{}, progressThread, .{
|
||||
@ -4920,6 +4922,17 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
var child_argv = std.ArrayList([]const u8).init(arena);
|
||||
var reference_trace: ?u32 = null;
|
||||
var debug_compile_errors = false;
|
||||
var verbose_link = (builtin.os.tag != .wasi or builtin.link_libc) and
|
||||
EnvVar.ZIG_VERBOSE_LINK.isSet();
|
||||
var verbose_cc = (builtin.os.tag != .wasi or builtin.link_libc) and
|
||||
EnvVar.ZIG_VERBOSE_CC.isSet();
|
||||
var verbose_air = false;
|
||||
var verbose_intern_pool = false;
|
||||
var verbose_generic_instances = false;
|
||||
var verbose_llvm_ir: ?[]const u8 = null;
|
||||
var verbose_llvm_bc: ?[]const u8 = null;
|
||||
var verbose_cimport = false;
|
||||
var verbose_llvm_cpu_features = false;
|
||||
var fetch_only = false;
|
||||
|
||||
const argv_index_exe = child_argv.items.len;
|
||||
@ -4956,7 +4969,7 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
|
||||
i += 1;
|
||||
override_lib_dir = args[i];
|
||||
try child_argv.appendSlice(&[_][]const u8{ arg, args[i] });
|
||||
try child_argv.appendSlice(&.{ arg, args[i] });
|
||||
continue;
|
||||
} else if (mem.eql(u8, arg, "--build-runner")) {
|
||||
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
|
||||
@ -4974,22 +4987,52 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
override_global_cache_dir = args[i];
|
||||
continue;
|
||||
} else if (mem.eql(u8, arg, "-freference-trace")) {
|
||||
try child_argv.append(arg);
|
||||
reference_trace = 256;
|
||||
} else if (mem.eql(u8, arg, "--fetch")) {
|
||||
fetch_only = true;
|
||||
} else if (mem.startsWith(u8, arg, "-freference-trace=")) {
|
||||
try child_argv.append(arg);
|
||||
const num = arg["-freference-trace=".len..];
|
||||
reference_trace = std.fmt.parseUnsigned(u32, num, 10) catch |err| {
|
||||
fatal("unable to parse reference_trace count '{s}': {s}", .{ num, @errorName(err) });
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "-fno-reference-trace")) {
|
||||
try child_argv.append(arg);
|
||||
reference_trace = null;
|
||||
} else if (mem.eql(u8, arg, "--debug-log")) {
|
||||
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
|
||||
try child_argv.appendSlice(args[i .. i + 2]);
|
||||
i += 1;
|
||||
if (!build_options.enable_logging) {
|
||||
std.log.warn("Zig was compiled without logging enabled (-Dlog). --debug-log has no effect.", .{});
|
||||
} else {
|
||||
try log_scopes.append(gpa, args[i]);
|
||||
}
|
||||
continue;
|
||||
} else if (mem.eql(u8, arg, "--debug-compile-errors")) {
|
||||
try child_argv.append(arg);
|
||||
debug_compile_errors = true;
|
||||
if (!crash_report.is_enabled) {
|
||||
std.log.warn("Zig was compiled in a release mode. --debug-compile-errors has no effect.", .{});
|
||||
} else {
|
||||
debug_compile_errors = true;
|
||||
}
|
||||
} else if (mem.eql(u8, arg, "--verbose-link")) {
|
||||
verbose_link = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-cc")) {
|
||||
verbose_cc = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-air")) {
|
||||
verbose_air = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-intern-pool")) {
|
||||
verbose_intern_pool = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-generic-instances")) {
|
||||
verbose_generic_instances = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-llvm-ir")) {
|
||||
verbose_llvm_ir = "-";
|
||||
} else if (mem.startsWith(u8, arg, "--verbose-llvm-ir=")) {
|
||||
verbose_llvm_ir = arg["--verbose-llvm-ir=".len..];
|
||||
} else if (mem.startsWith(u8, arg, "--verbose-llvm-bc=")) {
|
||||
verbose_llvm_bc = arg["--verbose-llvm-bc=".len..];
|
||||
} else if (mem.eql(u8, arg, "--verbose-cimport")) {
|
||||
verbose_cimport = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-llvm-cpu-features")) {
|
||||
verbose_llvm_cpu_features = true;
|
||||
} else if (mem.eql(u8, arg, "--seed")) {
|
||||
if (i + 1 >= args.len) fatal("expected argument after '{s}'", .{arg});
|
||||
i += 1;
|
||||
@ -5264,6 +5307,15 @@ pub fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !voi
|
||||
.optimize_mode = .Debug,
|
||||
.self_exe_path = self_exe_path,
|
||||
.thread_pool = &thread_pool,
|
||||
.verbose_cc = verbose_cc,
|
||||
.verbose_link = verbose_link,
|
||||
.verbose_air = verbose_air,
|
||||
.verbose_intern_pool = verbose_intern_pool,
|
||||
.verbose_generic_instances = verbose_generic_instances,
|
||||
.verbose_llvm_ir = verbose_llvm_ir,
|
||||
.verbose_llvm_bc = verbose_llvm_bc,
|
||||
.verbose_cimport = verbose_cimport,
|
||||
.verbose_llvm_cpu_features = verbose_llvm_cpu_features,
|
||||
.cache_mode = .whole,
|
||||
.reference_trace = reference_trace,
|
||||
.debug_compile_errors = debug_compile_errors,
|
||||
|
||||
@ -282,7 +282,7 @@ test "@min/@max notices bounds from vector types when element of comptime-known
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_x86_64 and
|
||||
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .sse4_1)) return error.SkipZigTest;
|
||||
!comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest;
|
||||
|
||||
var x: @Vector(2, u32) = .{ 1_000_000, 12345 };
|
||||
const y: @Vector(2, u16) = .{ 10, undefined };
|
||||
|
||||
@ -73,6 +73,10 @@ static void assert_or_panic(bool ok) {
|
||||
#define ZIG_NO_RAW_F16
|
||||
#endif
|
||||
|
||||
#ifdef ZIG_BACKEND_STAGE2_X86_64
|
||||
#define ZIG_NO_COMPLEX
|
||||
#endif
|
||||
|
||||
#ifdef __i386__
|
||||
#define ZIG_NO_RAW_F16
|
||||
#endif
|
||||
@ -274,7 +278,7 @@ void run_c_tests(void) {
|
||||
zig_u32(0xfffffffd);
|
||||
zig_u64(0xfffffffffffffffc);
|
||||
|
||||
#ifndef ZIG_NO_I128
|
||||
#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64
|
||||
{
|
||||
struct u128 s = {0xfffffffffffffffc};
|
||||
zig_struct_u128(s);
|
||||
@ -288,7 +292,7 @@ void run_c_tests(void) {
|
||||
zig_i32(-3);
|
||||
zig_i64(-4);
|
||||
|
||||
#ifndef ZIG_NO_I128
|
||||
#if !defined ZIG_NO_I128 && !defined ZIG_BACKEND_STAGE2_X86_64
|
||||
{
|
||||
struct i128 s = {-6};
|
||||
zig_struct_i128(s);
|
||||
@ -429,7 +433,7 @@ void run_c_tests(void) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined __mips__ && !defined ZIG_PPC32
|
||||
#if !defined __mips__ && !defined ZIG_PPC32 && !defined ZIG_BACKEND_STAGE2_X86_64
|
||||
{
|
||||
struct FloatRect r1 = {1, 21, 16, 4};
|
||||
struct FloatRect r2 = {178, 189, 21, 15};
|
||||
|
||||
@ -49,6 +49,8 @@ export fn zig_five_integers(a: i32, b: i32, c: i32, d: i32, e: i32) void {
|
||||
}
|
||||
|
||||
test "C ABI integers" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
c_u8(0xff);
|
||||
c_u16(0xfffe);
|
||||
c_u32(0xfffffffd);
|
||||
@ -185,6 +187,8 @@ const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.is
|
||||
!builtin.cpu.arch.isARM() and !builtin.cpu.arch.isPPC() and !builtin.cpu.arch.isRISCV();
|
||||
|
||||
test "C ABI complex float" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (!complex_abi_compatible) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch == .x86_64) return error.SkipZigTest; // See https://github.com/ziglang/zig/issues/8465
|
||||
|
||||
@ -197,6 +201,8 @@ test "C ABI complex float" {
|
||||
}
|
||||
|
||||
test "C ABI complex float by component" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (!complex_abi_compatible) return error.SkipZigTest;
|
||||
|
||||
const a = ComplexFloat{ .real = 1.25, .imag = 2.6 };
|
||||
@ -208,6 +214,8 @@ test "C ABI complex float by component" {
|
||||
}
|
||||
|
||||
test "C ABI complex double" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (!complex_abi_compatible) return error.SkipZigTest;
|
||||
|
||||
const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };
|
||||
@ -219,6 +227,8 @@ test "C ABI complex double" {
|
||||
}
|
||||
|
||||
test "C ABI complex double by component" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (!complex_abi_compatible) return error.SkipZigTest;
|
||||
|
||||
const a = ComplexDouble{ .real = 1.25, .imag = 2.6 };
|
||||
@ -230,6 +240,8 @@ test "C ABI complex double by component" {
|
||||
}
|
||||
|
||||
export fn zig_cmultf(a: ComplexFloat, b: ComplexFloat) ComplexFloat {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
expect(a.real == 1.25) catch @panic("test failure: zig_cmultf 1");
|
||||
expect(a.imag == 2.6) catch @panic("test failure: zig_cmultf 2");
|
||||
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 {
|
||||
}
|
||||
|
||||
export fn zig_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
expect(a.real == 1.25) catch @panic("test failure: zig_cmultd 1");
|
||||
expect(a.imag == 2.6) catch @panic("test failure: zig_cmultd 2");
|
||||
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 {
|
||||
}
|
||||
|
||||
export fn zig_cmultf_comp(a_r: f32, a_i: f32, b_r: f32, b_i: f32) ComplexFloat {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
expect(a_r == 1.25) catch @panic("test failure: zig_cmultf_comp 1");
|
||||
expect(a_i == 2.6) catch @panic("test failure: zig_cmultf_comp 2");
|
||||
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 {
|
||||
}
|
||||
|
||||
export fn zig_cmultd_comp(a_r: f64, a_i: f64, b_r: f64, b_i: f64) ComplexDouble {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
expect(a_r == 1.25) catch @panic("test failure: zig_cmultd_comp 1");
|
||||
expect(a_i == 2.6) catch @panic("test failure: zig_cmultd_comp 2");
|
||||
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;
|
||||
extern fn c_ret_med_struct_mixed() MedStructMixed;
|
||||
|
||||
test "C ABI medium struct of ints and floats" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -402,6 +422,8 @@ extern fn c_med_struct_ints(MedStructInts) void;
|
||||
extern fn c_ret_med_struct_ints() MedStructInts;
|
||||
|
||||
test "C ABI medium struct of ints" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -509,6 +531,8 @@ extern fn c_split_struct_mixed(SplitStructMixed) void;
|
||||
extern fn c_ret_split_struct_mixed() SplitStructMixed;
|
||||
|
||||
test "C ABI split struct of ints and floats" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -590,6 +614,8 @@ const Vector5 = extern struct {
|
||||
extern fn c_big_struct_floats(Vector5) void;
|
||||
|
||||
test "C ABI structs of floats as parameter" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
|
||||
@ -657,6 +683,8 @@ const FloatRect = extern struct {
|
||||
};
|
||||
|
||||
export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
expect(x.left == 1) catch @panic("test failure");
|
||||
expect(x.right == 21) catch @panic("test failure");
|
||||
expect(x.top == 16) catch @panic("test failure");
|
||||
@ -668,6 +696,8 @@ export fn zig_multiple_struct_floats(x: FloatRect, y: FloatRect) void {
|
||||
}
|
||||
|
||||
test "C ABI structs of floats as multiple parameters" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
|
||||
@ -724,6 +754,8 @@ export fn zig_ret_small_struct_ints() SmallStructInts {
|
||||
}
|
||||
|
||||
export fn zig_ret_med_struct_ints() MedStructInts {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
return .{
|
||||
.x = 1,
|
||||
.y = 2,
|
||||
@ -732,6 +764,8 @@ export fn zig_ret_med_struct_ints() MedStructInts {
|
||||
}
|
||||
|
||||
export fn zig_ret_med_struct_mixed() MedStructMixed {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
return .{
|
||||
.a = 1234,
|
||||
.b = 100.0,
|
||||
@ -740,6 +774,8 @@ export fn zig_ret_med_struct_mixed() MedStructMixed {
|
||||
}
|
||||
|
||||
export fn zig_ret_split_struct_mixed() SplitStructMixed {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
return .{
|
||||
.a = 1234,
|
||||
.b = 100,
|
||||
@ -780,6 +816,8 @@ extern fn c_struct_with_array(StructWithArray) void;
|
||||
extern fn c_ret_struct_with_array() StructWithArray;
|
||||
|
||||
test "Struct with array as padding." {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -851,6 +889,8 @@ extern fn c_medium_vec(MediumVec) void;
|
||||
extern fn c_ret_medium_vec() MediumVec;
|
||||
|
||||
test "medium simd vector" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
|
||||
|
||||
c_medium_vec(.{ 1, 2, 3, 4 });
|
||||
@ -868,6 +908,8 @@ extern fn c_big_vec(BigVec) void;
|
||||
extern fn c_ret_big_vec() BigVec;
|
||||
|
||||
test "big simd vector" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC64()) return error.SkipZigTest;
|
||||
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;
|
||||
extern fn c_ret_ptr_size_float_struct() Vector2;
|
||||
|
||||
test "C ABI pointer sized float struct" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
|
||||
@ -914,6 +958,8 @@ pub inline fn expectOk(c_err: c_int) !void {
|
||||
/// Tests for Double + Char struct
|
||||
const DC = extern struct { v1: f64, v2: u8 };
|
||||
test "DC: Zig passes to C" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -921,6 +967,8 @@ test "DC: Zig passes to C" {
|
||||
try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
|
||||
}
|
||||
test "DC: Zig returns to C" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
|
||||
@ -929,6 +977,8 @@ test "DC: Zig returns to C" {
|
||||
try expectOk(c_assert_ret_DC());
|
||||
}
|
||||
test "DC: C passes to Zig" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -936,6 +986,8 @@ test "DC: C passes to Zig" {
|
||||
try expectOk(c_send_DC());
|
||||
}
|
||||
test "DC: C returns to Zig" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
|
||||
@ -949,6 +1001,8 @@ pub extern fn c_assert_ret_DC() c_int;
|
||||
pub extern fn c_send_DC() c_int;
|
||||
pub extern fn c_ret_DC() DC;
|
||||
pub export fn zig_assert_DC(lv: DC) c_int {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
var err: c_int = 0;
|
||||
if (lv.v1 != -0.25) err = 1;
|
||||
if (lv.v2 != 15) err = 2;
|
||||
@ -956,6 +1010,8 @@ pub export fn zig_assert_DC(lv: DC) c_int {
|
||||
return err;
|
||||
}
|
||||
pub export fn zig_ret_DC() DC {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
return .{ .v1 = -0.25, .v2 = 15 };
|
||||
}
|
||||
|
||||
@ -963,6 +1019,8 @@ pub export fn zig_ret_DC() DC {
|
||||
const CFF = extern struct { v1: u8, v2: f32, v3: f32 };
|
||||
|
||||
test "CFF: Zig passes to C" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -970,6 +1028,8 @@ test "CFF: Zig passes to C" {
|
||||
try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
|
||||
}
|
||||
test "CFF: Zig returns to C" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -977,6 +1037,8 @@ test "CFF: Zig returns to C" {
|
||||
try expectOk(c_assert_ret_CFF());
|
||||
}
|
||||
test "CFF: C passes to Zig" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isRISCV() and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
@ -987,6 +1049,8 @@ test "CFF: C passes to Zig" {
|
||||
try expectOk(c_send_CFF());
|
||||
}
|
||||
test "CFF: C returns to Zig" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch == .x86 and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (builtin.cpu.arch == .aarch64 and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
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;
|
||||
pub extern fn c_send_CFF() c_int;
|
||||
pub extern fn c_ret_CFF() CFF;
|
||||
pub export fn zig_assert_CFF(lv: CFF) c_int {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
var err: c_int = 0;
|
||||
if (lv.v1 != 39) err = 1;
|
||||
if (lv.v2 != 0.875) err = 2;
|
||||
@ -1008,6 +1074,8 @@ pub export fn zig_assert_CFF(lv: CFF) c_int {
|
||||
return err;
|
||||
}
|
||||
pub export fn zig_ret_CFF() CFF {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
return .{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 };
|
||||
}
|
||||
|
||||
@ -1015,6 +1083,8 @@ pub export fn zig_ret_CFF() CFF {
|
||||
const PD = extern struct { v1: ?*anyopaque, v2: f64 };
|
||||
|
||||
test "PD: Zig passes to C" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -1022,6 +1092,8 @@ test "PD: Zig passes to C" {
|
||||
try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
|
||||
}
|
||||
test "PD: Zig returns to C" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -1029,6 +1101,8 @@ test "PD: Zig returns to C" {
|
||||
try expectOk(c_assert_ret_PD());
|
||||
}
|
||||
test "PD: C passes to Zig" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS()) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -1036,6 +1110,8 @@ test "PD: C passes to Zig" {
|
||||
try expectOk(c_send_PD());
|
||||
}
|
||||
test "PD: C returns to Zig" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isMIPS() and builtin.mode != .Debug) return error.SkipZigTest;
|
||||
if (comptime builtin.cpu.arch.isPPC()) return error.SkipZigTest;
|
||||
@ -1047,6 +1123,8 @@ pub extern fn c_assert_ret_PD() c_int;
|
||||
pub extern fn c_send_PD() c_int;
|
||||
pub extern fn c_ret_PD() PD;
|
||||
pub export fn zig_c_assert_PD(lv: PD) c_int {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
var err: c_int = 0;
|
||||
if (lv.v1 != null) err = 1;
|
||||
if (lv.v2 != 0.5) err = 2;
|
||||
@ -1054,9 +1132,13 @@ pub export fn zig_c_assert_PD(lv: PD) c_int {
|
||||
return err;
|
||||
}
|
||||
pub export fn zig_ret_PD() PD {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
return .{ .v1 = null, .v2 = 0.5 };
|
||||
}
|
||||
pub export fn zig_assert_PD(lv: PD) c_int {
|
||||
if (builtin.zig_backend == .stage2_x86_64) @panic("error.SkipZigTest");
|
||||
|
||||
var err: c_int = 0;
|
||||
if (lv.v1 != null) err = 1;
|
||||
if (lv.v2 != 0.5) err = 2;
|
||||
@ -1146,6 +1228,8 @@ const f80_struct = extern struct {
|
||||
};
|
||||
extern fn c_f80_struct(f80_struct) f80_struct;
|
||||
test "f80 struct" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (!has_f80) return error.SkipZigTest;
|
||||
if (builtin.target.cpu.arch == .x86) return error.SkipZigTest;
|
||||
if (builtin.mode != .Debug) return error.SkipZigTest;
|
||||
@ -1233,6 +1317,8 @@ test "Stdcall ABI big union" {
|
||||
|
||||
extern fn c_explict_win64(ByRef) callconv(.Win64) ByRef;
|
||||
test "explicit SysV calling convention" {
|
||||
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
|
||||
|
||||
if (builtin.cpu.arch != .x86_64) return error.SkipZigTest;
|
||||
|
||||
const res = c_explict_win64(.{ .val = 1, .arr = undefined });
|
||||
|
||||
190
test/tests.zig
190
test/tests.zig
@ -94,6 +94,26 @@ const test_targets = blk: {
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
|
||||
.os_tag = .linux,
|
||||
.abi = .none,
|
||||
},
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
|
||||
.os_tag = .linux,
|
||||
.abi = .none,
|
||||
},
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
},
|
||||
// Doesn't support new liveness
|
||||
//.{
|
||||
// .target = .{
|
||||
@ -470,62 +490,123 @@ const test_targets = blk: {
|
||||
};
|
||||
};
|
||||
|
||||
const c_abi_targets = [_]CrossTarget{
|
||||
const CAbiTarget = struct {
|
||||
target: CrossTarget = .{},
|
||||
use_llvm: ?bool = null,
|
||||
use_lld: ?bool = null,
|
||||
c_defines: []const []const u8 = &.{},
|
||||
};
|
||||
|
||||
const c_abi_targets = [_]CAbiTarget{
|
||||
.{},
|
||||
.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .x86,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
.c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
.c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .arm,
|
||||
.os_tag = .linux,
|
||||
.abi = .musleabihf,
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
.use_llvm = false,
|
||||
.use_lld = false,
|
||||
.c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .mips,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .x86,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .riscv64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .wasm32,
|
||||
.os_tag = .wasi,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .arm,
|
||||
.os_tag = .linux,
|
||||
.abi = .musleabihf,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .powerpc,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .mips,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .powerpc64le,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
.target = .{
|
||||
.cpu_arch = .riscv64,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .x86,
|
||||
.os_tag = .windows,
|
||||
.abi = .gnu,
|
||||
.target = .{
|
||||
.cpu_arch = .wasm32,
|
||||
.os_tag = .wasi,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .windows,
|
||||
.abi = .gnu,
|
||||
.target = .{
|
||||
.cpu_arch = .powerpc,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .powerpc64le,
|
||||
.os_tag = .linux,
|
||||
.abi = .musl,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .x86,
|
||||
.os_tag = .windows,
|
||||
.abi = .gnu,
|
||||
},
|
||||
},
|
||||
.{
|
||||
.target = .{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .windows,
|
||||
.abi = .gnu,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@ -1017,6 +1098,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
||||
|
||||
const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
|
||||
const triple_txt = test_target.target.zigTriple(b.allocator) catch @panic("OOM");
|
||||
const model_txt = test_target.target.getCpuModel().name;
|
||||
|
||||
// wasm32-wasi builds need more RAM, idk why
|
||||
const max_rss = if (test_target.target.getOs().tag == .wasi)
|
||||
@ -1054,9 +1136,10 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
||||
these_tests.stack_size = 2 * 1024 * 1024;
|
||||
}
|
||||
|
||||
const qualified_name = b.fmt("{s}-{s}-{s}{s}{s}{s}{s}", .{
|
||||
const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}", .{
|
||||
options.name,
|
||||
triple_txt,
|
||||
model_txt,
|
||||
@tagName(test_target.optimize_mode),
|
||||
libc_suffix,
|
||||
single_threaded_suffix,
|
||||
@ -1144,33 +1227,50 @@ pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *S
|
||||
if (optimize_mode != .Debug and skip_release) continue;
|
||||
|
||||
for (c_abi_targets) |c_abi_target| {
|
||||
if (skip_non_native and !c_abi_target.isNative()) continue;
|
||||
if (skip_non_native and !c_abi_target.target.isNative()) continue;
|
||||
|
||||
if (c_abi_target.isWindows() and c_abi_target.getCpuArch() == .aarch64) {
|
||||
if (c_abi_target.target.isWindows() and c_abi_target.target.getCpuArch() == .aarch64) {
|
||||
// https://github.com/ziglang/zig/issues/14908
|
||||
continue;
|
||||
}
|
||||
|
||||
const triple_prefix = c_abi_target.zigTriple(b.allocator) catch @panic("OOM");
|
||||
if (c_abi_target.use_llvm == false and optimize_mode == .ReleaseFast) {
|
||||
// panic: unrecognized command line argument
|
||||
continue;
|
||||
}
|
||||
|
||||
const test_step = b.addTest(.{
|
||||
.root_source_file = .{ .path = "test/c_abi/main.zig" },
|
||||
.optimize = optimize_mode,
|
||||
.target = c_abi_target,
|
||||
.name = b.fmt("test-c-abi-{s}-{s}", .{
|
||||
triple_prefix, @tagName(optimize_mode),
|
||||
.name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}", .{
|
||||
c_abi_target.target.zigTriple(b.allocator) catch @panic("OOM"),
|
||||
c_abi_target.target.getCpuModel().name,
|
||||
@tagName(optimize_mode),
|
||||
if (c_abi_target.use_llvm == true)
|
||||
"-llvm"
|
||||
else if (c_abi_target.target.ofmt == std.Target.ObjectFormat.c)
|
||||
"-cbe"
|
||||
else if (c_abi_target.use_llvm == false)
|
||||
"-selfhosted"
|
||||
else
|
||||
"",
|
||||
if (c_abi_target.use_lld == false) "-no-lld" else "",
|
||||
}),
|
||||
.root_source_file = .{ .path = "test/c_abi/main.zig" },
|
||||
.target = c_abi_target.target,
|
||||
.optimize = optimize_mode,
|
||||
.link_libc = true,
|
||||
.use_llvm = c_abi_target.use_llvm,
|
||||
.use_lld = c_abi_target.use_lld,
|
||||
});
|
||||
if (c_abi_target.abi != null and c_abi_target.abi.?.isMusl()) {
|
||||
if (c_abi_target.target.abi != null and c_abi_target.target.abi.?.isMusl()) {
|
||||
// TODO NativeTargetInfo insists on dynamically linking musl
|
||||
// for some reason?
|
||||
test_step.target_info.dynamic_linker.max_byte = null;
|
||||
}
|
||||
test_step.linkLibC();
|
||||
test_step.addCSourceFile(.{
|
||||
.file = .{ .path = "test/c_abi/cfuncs.c" },
|
||||
.flags = &.{"-std=c99"},
|
||||
});
|
||||
for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);
|
||||
|
||||
// This test is intentionally trying to check if the external ABI is
|
||||
// done properly. LTO would be a hindrance to this.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user