diff options
Diffstat (limited to 'lib')
37 files changed, 66 insertions, 190 deletions
diff --git a/lib/std/Thread/Condition.zig b/lib/std/Thread/Condition.zig index ecbc25fdb0..898fc14520 100644 --- a/lib/std/Thread/Condition.zig +++ b/lib/std/Thread/Condition.zig @@ -324,8 +324,6 @@ test "Condition - wait and signal" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const num_threads = 4; const MultiWait = struct { @@ -371,8 +369,6 @@ test "Condition - signal" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const num_threads = 4; const SignalTest = struct { @@ -440,8 +436,6 @@ test "Condition - multi signal" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const num_threads = 4; const num_iterations = 4; @@ -504,8 +498,6 @@ test "Condition - broadcasting" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const num_threads = 10; const BroadcastTest = struct { @@ -573,8 +565,6 @@ test "Condition - broadcasting - wake all threads" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var num_runs: usize = 1; const num_threads = 10; diff --git a/lib/std/Thread/Mutex.zig b/lib/std/Thread/Mutex.zig index c6416113b5..0f618516b5 100644 --- a/lib/std/Thread/Mutex.zig +++ b/lib/std/Thread/Mutex.zig @@ -289,8 +289,6 @@ test "Mutex - many contended" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const num_threads = 4; const num_increments = 1000; diff --git a/lib/std/Thread/RwLock.zig b/lib/std/Thread/RwLock.zig index 2cd101f913..e77db10abb 100644 --- a/lib/std/Thread/RwLock.zig +++ b/lib/std/Thread/RwLock.zig @@ -297,8 +297,6 @@ test "RwLock - concurrent access" { if (builtin.single_threaded) return; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const num_writers: usize = 2; const num_readers: usize = 4; const num_writes: usize = 10000; diff --git a/lib/std/Thread/Semaphore.zig b/lib/std/Thread/Semaphore.zig index 0c04e8a859..1b182d4c2a 100644 --- a/lib/std/Thread/Semaphore.zig +++ b/lib/std/Thread/Semaphore.zig @@ -39,8 +39,6 @@ test "Thread.Semaphore" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const TestContext = struct { sem: *Semaphore, n: *i32, diff --git a/lib/std/atomic/Atomic.zig b/lib/std/atomic/Atomic.zig index 2abe7fc4ca..e38ada0c20 100644 --- a/lib/std/atomic/Atomic.zig +++ b/lib/std/atomic/Atomic.zig @@ -467,8 +467,6 @@ test "Atomic.fetchSub" { } test "Atomic.fetchMin" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - inline for (atomicIntTypes()) |Int| { inline for (atomic_rmw_orderings) |ordering| { var x = Atomic(Int).init(5); diff --git a/lib/std/atomic/queue.zig b/lib/std/atomic/queue.zig index c28daead1b..e8d37507d3 100644 --- a/lib/std/atomic/queue.zig +++ b/lib/std/atomic/queue.zig @@ -175,8 +175,6 @@ const puts_per_thread = 500; const put_thread_count = 3; test "std.atomic.Queue" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var plenty_of_memory = try std.heap.page_allocator.alloc(u8, 300 * 1024); defer std.heap.page_allocator.free(plenty_of_memory); diff --git a/lib/std/base64.zig b/lib/std/base64.zig index bca829de38..8d0effd05b 100644 --- a/lib/std/base64.zig +++ b/lib/std/base64.zig @@ -355,8 +355,6 @@ pub const Base64DecoderWithIgnore = struct { }; test "base64" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - @setEvalBranchQuota(8000); try testBase64(); try comptime testAllApis(standard, "comptime", "Y29tcHRpbWU="); @@ -377,8 +375,6 @@ test "base64 padding dest overflow" { } test "base64 url_safe_no_pad" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - @setEvalBranchQuota(8000); try testBase64UrlSafeNoPad(); try comptime testAllApis(url_safe_no_pad, "comptime", "Y29tcHRpbWU"); diff --git a/lib/std/bit_set.zig b/lib/std/bit_set.zig index d87c1d26f6..ee2a89cb68 100644 --- a/lib/std/bit_set.zig +++ b/lib/std/bit_set.zig @@ -1638,7 +1638,6 @@ fn testStaticBitSet(comptime Set: type) !void { test "IntegerBitSet" { if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; try testStaticBitSet(IntegerBitSet(0)); try testStaticBitSet(IntegerBitSet(1)); @@ -1651,8 +1650,6 @@ test "IntegerBitSet" { } test "ArrayBitSet" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| { try testStaticBitSet(ArrayBitSet(u8, size)); try testStaticBitSet(ArrayBitSet(u16, size)); diff --git a/lib/std/compress/zstandard.zig b/lib/std/compress/zstandard.zig index 10eb878a1c..401496ca28 100644 --- a/lib/std/compress/zstandard.zig +++ b/lib/std/compress/zstandard.zig @@ -264,8 +264,6 @@ fn testReader(data: []const u8, comptime expected: []const u8) !void { } test "zstandard decompression" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - const uncompressed = @embedFile("testdata/rfc8478.txt"); const compressed3 = @embedFile("testdata/rfc8478.txt.zst.3"); const compressed19 = @embedFile("testdata/rfc8478.txt.zst.19"); diff --git a/lib/std/crypto/25519/ed25519.zig b/lib/std/crypto/25519/ed25519.zig index faeab59a0b..c00ce4387e 100644 --- a/lib/std/crypto/25519/ed25519.zig +++ b/lib/std/crypto/25519/ed25519.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const crypto = std.crypto; const debug = std.debug; const fmt = std.fmt; @@ -276,8 +275,8 @@ pub const Ed25519 = struct { pub fn fromSecretKey(secret_key: SecretKey) (NonCanonicalError || EncodingError || IdentityElementError)!KeyPair { // It is critical for EdDSA to use the correct public key. // In order to enforce this, a SecretKey implicitly includes a copy of the public key. - // In Debug mode, we can still afford checking that the public key is correct for extra safety. - if (builtin.mode == .Debug) { + // With runtime safety, we can still afford checking that the public key is correct. + if (std.debug.runtime_safety) { const pk_p = try Curve.fromBytes(secret_key.publicKeyBytes()); const recomputed_kp = try create(secret_key.seed()); debug.assert(mem.eql(u8, &recomputed_kp.public_key.toBytes(), &pk_p.toBytes())); @@ -493,8 +492,6 @@ test "ed25519 key pair creation" { } test "ed25519 signature" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var seed: [32]u8 = undefined; _ = try fmt.hexToBytes(seed[0..], "8052030376d47112be7f73ed7a019293dd12ad910b654455798b4667d73de166"); const key_pair = try Ed25519.KeyPair.create(seed); @@ -507,8 +504,6 @@ test "ed25519 signature" { } test "ed25519 batch verification" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var i: usize = 0; while (i < 100) : (i += 1) { const key_pair = try Ed25519.KeyPair.create(null); @@ -538,8 +533,6 @@ test "ed25519 batch verification" { } test "ed25519 test vectors" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const Vec = struct { msg_hex: *const [64:0]u8, public_key_hex: *const [64:0]u8, @@ -642,8 +635,6 @@ test "ed25519 test vectors" { } test "ed25519 with blind keys" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const BlindKeyPair = Ed25519.key_blinding.BlindKeyPair; // Create a standard Ed25519 key pair @@ -667,8 +658,6 @@ test "ed25519 with blind keys" { } test "ed25519 signatures with streaming" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const kp = try Ed25519.KeyPair.create(null); var signer = try kp.signer(null); diff --git a/lib/std/crypto/Certificate.zig b/lib/std/crypto/Certificate.zig index b7d24de0d6..9303e3c522 100644 --- a/lib/std/crypto/Certificate.zig +++ b/lib/std/crypto/Certificate.zig @@ -614,18 +614,18 @@ const Date = struct { }; pub fn parseTimeDigits(text: *const [2]u8, min: u8, max: u8) !u8 { - const nn: @Vector(2, u16) = .{ text[0], text[1] }; - const zero: @Vector(2, u16) = .{ '0', '0' }; - const mm: @Vector(2, u16) = .{ 10, 1 }; - const result = @reduce(.Add, (nn -% zero) *% mm); + const result = if (use_vectors) result: { + const nn: @Vector(2, u16) = .{ text[0], text[1] }; + const zero: @Vector(2, u16) = .{ '0', '0' }; + const mm: @Vector(2, u16) = .{ 10, 1 }; + break :result @reduce(.Add, (nn -% zero) *% mm); + } else std.fmt.parseInt(u8, text, 10) catch return error.CertificateTimeInvalid; if (result < min) return error.CertificateTimeInvalid; if (result > max) return error.CertificateTimeInvalid; return @truncate(result); } test parseTimeDigits { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const expectEqual = std.testing.expectEqual; try expectEqual(@as(u8, 0), try parseTimeDigits("00", 0, 99)); try expectEqual(@as(u8, 99), try parseTimeDigits("99", 0, 99)); @@ -638,17 +638,17 @@ test parseTimeDigits { } pub fn parseYear4(text: *const [4]u8) !u16 { - const nnnn: @Vector(4, u32) = .{ text[0], text[1], text[2], text[3] }; - const zero: @Vector(4, u32) = .{ '0', '0', '0', '0' }; - const mmmm: @Vector(4, u32) = .{ 1000, 100, 10, 1 }; - const result = @reduce(.Add, (nnnn -% zero) *% mmmm); + const result = if (use_vectors) result: { + const nnnn: @Vector(4, u32) = .{ text[0], text[1], text[2], text[3] }; + const zero: @Vector(4, u32) = .{ '0', '0', '0', '0' }; + const mmmm: @Vector(4, u32) = .{ 1000, 100, 10, 1 }; + break :result @reduce(.Add, (nnnn -% zero) *% mmmm); + } else std.fmt.parseInt(u16, text, 10) catch return error.CertificateTimeInvalid; if (result > 9999) return error.CertificateTimeInvalid; return @truncate(result); } test parseYear4 { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const expectEqual = std.testing.expectEqual; try expectEqual(@as(u16, 0), try parseYear4("0000")); try expectEqual(@as(u16, 9999), try parseYear4("9999")); @@ -1124,4 +1124,4 @@ pub const rsa = struct { } }; -const builtin = @import("builtin"); +const use_vectors = @import("builtin").zig_backend != .stage2_x86_64; diff --git a/lib/std/crypto/Certificate/Bundle.zig b/lib/std/crypto/Certificate/Bundle.zig index 1bffa325bd..b5a3832115 100644 --- a/lib/std/crypto/Certificate/Bundle.zig +++ b/lib/std/crypto/Certificate/Bundle.zig @@ -318,8 +318,6 @@ const MapContext = struct { test "scan for OS-provided certificates" { if (builtin.os.tag == .wasi) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var bundle: Bundle = .{}; defer bundle.deinit(std.testing.allocator); diff --git a/lib/std/crypto/aes.zig b/lib/std/crypto/aes.zig index c4f709d631..d043099f50 100644 --- a/lib/std/crypto/aes.zig +++ b/lib/std/crypto/aes.zig @@ -28,8 +28,6 @@ pub const Aes128 = impl.Aes128; pub const Aes256 = impl.Aes256; test "ctr" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // NIST SP 800-38A pp 55-58 const ctr = @import("modes.zig").ctr; diff --git a/lib/std/crypto/aes_gcm.zig b/lib/std/crypto/aes_gcm.zig index e276c9dfd8..980a234c54 100644 --- a/lib/std/crypto/aes_gcm.zig +++ b/lib/std/crypto/aes_gcm.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const assert = std.debug.assert; const crypto = std.crypto; const debug = std.debug; @@ -42,7 +41,7 @@ fn AesGcm(comptime Aes: anytype) type { mac.pad(); mem.writeInt(u32, j[nonce_length..][0..4], 2, .big); - modes.ctr(@TypeOf(aes), aes, c, m, j, std.builtin.Endian.big); + modes.ctr(@TypeOf(aes), aes, c, m, j, .big); mac.update(c[0..m.len][0..]); mac.pad(); @@ -104,7 +103,7 @@ fn AesGcm(comptime Aes: anytype) type { } mem.writeInt(u32, j[nonce_length..][0..4], 2, .big); - modes.ctr(@TypeOf(aes), aes, m, c, j, std.builtin.Endian.big); + modes.ctr(@TypeOf(aes), aes, m, c, j, .big); } }; } @@ -113,8 +112,6 @@ const htest = @import("test.zig"); const testing = std.testing; test "Aes256Gcm - Empty message and no associated data" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const ad = ""; @@ -127,8 +124,6 @@ test "Aes256Gcm - Empty message and no associated data" { } test "Aes256Gcm - Associated data only" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const m = ""; @@ -141,8 +136,6 @@ test "Aes256Gcm - Associated data only" { } test "Aes256Gcm - Message only" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const m = "Test with message only"; @@ -160,8 +153,6 @@ test "Aes256Gcm - Message only" { } test "Aes256Gcm - Message and associated data" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key: [Aes256Gcm.key_length]u8 = [_]u8{0x69} ** Aes256Gcm.key_length; const nonce: [Aes256Gcm.nonce_length]u8 = [_]u8{0x42} ** Aes256Gcm.nonce_length; const m = "Test with message"; diff --git a/lib/std/crypto/argon2.zig b/lib/std/crypto/argon2.zig index 500bebd09c..4e6d391799 100644 --- a/lib/std/crypto/argon2.zig +++ b/lib/std/crypto/argon2.zig @@ -896,8 +896,6 @@ test "kdf" { } test "phc format hasher" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const allocator = std.testing.allocator; const password = "testpass"; @@ -913,8 +911,6 @@ test "phc format hasher" { } test "password hash and password verify" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const allocator = std.testing.allocator; const password = "testpass"; diff --git a/lib/std/crypto/bcrypt.zig b/lib/std/crypto/bcrypt.zig index 9fc2ecb63b..720f264d16 100644 --- a/lib/std/crypto/bcrypt.zig +++ b/lib/std/crypto/bcrypt.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const base64 = std.base64; const crypto = std.crypto; const debug = std.debug; @@ -754,8 +753,6 @@ pub fn strVerify( } test "bcrypt codec" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var salt: [salt_length]u8 = undefined; crypto.random.bytes(&salt); var salt_str: [salt_str_length]u8 = undefined; @@ -766,8 +763,6 @@ test "bcrypt codec" { } test "bcrypt crypt format" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var hash_options = HashOptions{ .params = .{ .rounds_log = 5 }, .encoding = .crypt, @@ -808,8 +803,6 @@ test "bcrypt crypt format" { } test "bcrypt phc format" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var hash_options = HashOptions{ .params = .{ .rounds_log = 5 }, .encoding = .phc, diff --git a/lib/std/crypto/cmac.zig b/lib/std/crypto/cmac.zig index 32ba7f4b99..902bac591c 100644 --- a/lib/std/crypto/cmac.zig +++ b/lib/std/crypto/cmac.zig @@ -1,5 +1,4 @@ const std = @import("std"); -const builtin = @import("builtin"); const crypto = std.crypto; const mem = std.mem; @@ -94,8 +93,6 @@ pub fn Cmac(comptime BlockCipher: type) type { const testing = std.testing; test "CmacAes128 - Example 1: len = 0" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, }; @@ -109,8 +106,6 @@ test "CmacAes128 - Example 1: len = 0" { } test "CmacAes128 - Example 2: len = 16" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, }; @@ -126,8 +121,6 @@ test "CmacAes128 - Example 2: len = 16" { } test "CmacAes128 - Example 3: len = 40" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, }; @@ -145,8 +138,6 @@ test "CmacAes128 - Example 3: len = 40" { } test "CmacAes128 - Example 4: len = 64" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{ 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, }; diff --git a/lib/std/crypto/ecdsa.zig b/lib/std/crypto/ecdsa.zig index e705fcf79b..6f8a32ea21 100644 --- a/lib/std/crypto/ecdsa.zig +++ b/lib/std/crypto/ecdsa.zig @@ -373,7 +373,6 @@ pub fn Ecdsa(comptime Curve: type, comptime Hash: type) type { test "ECDSA - Basic operations over EcdsaP384Sha384" { 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); @@ -407,7 +406,6 @@ test "ECDSA - Basic operations over Secp256k1" { test "ECDSA - Basic operations over EcdsaP384Sha256" { 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); @@ -424,7 +422,6 @@ test "ECDSA - Basic operations over EcdsaP384Sha256" { test "ECDSA - Verifying a existing signature with EcdsaP384Sha256" { 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 @@ -469,7 +466,6 @@ const TestVector = struct { test "ECDSA - Test vectors from Project Wycheproof" { 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 }, @@ -884,7 +880,6 @@ fn tvTry(vector: TestVector) !void { test "ECDSA - Sec1 encoding/decoding" { 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); diff --git a/lib/std/crypto/ghash_polyval.zig b/lib/std/crypto/ghash_polyval.zig index 6949553ad5..6ccbf1f228 100644 --- a/lib/std/crypto/ghash_polyval.zig +++ b/lib/std/crypto/ghash_polyval.zig @@ -422,8 +422,6 @@ fn Hash(comptime endian: std.builtin.Endian, comptime shift_key: bool) type { const htest = @import("test.zig"); test "ghash" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const key = [_]u8{0x42} ** 16; const m = [_]u8{0x69} ** 256; @@ -441,8 +439,6 @@ test "ghash" { } test "ghash2" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var key: [16]u8 = undefined; var i: usize = 0; while (i < key.len) : (i += 1) { diff --git a/lib/std/crypto/pcurves/p256.zig b/lib/std/crypto/pcurves/p256.zig index 37f16715f4..ec176f78c5 100644 --- a/lib/std/crypto/pcurves/p256.zig +++ b/lib/std/crypto/pcurves/p256.zig @@ -478,7 +478,5 @@ pub const AffineCoordinates = struct { }; test { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - _ = @import("tests/p256.zig"); } diff --git a/lib/std/crypto/phc_encoding.zig b/lib/std/crypto/phc_encoding.zig index 6ac8f66bb4..fecd7f1239 100644 --- a/lib/std/crypto/phc_encoding.zig +++ b/lib/std/crypto/phc_encoding.zig @@ -1,7 +1,6 @@ // https://github.com/P-H-C/phc-string-format const std = @import("std"); -const builtin = @import("builtin"); const fmt = std.fmt; const io = std.io; const mem = std.mem; @@ -264,8 +263,6 @@ fn kvSplit(str: []const u8) !struct { key: []const u8, value: []const u8 } { } test "phc format - encoding/decoding" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const Input = struct { str: []const u8, HashResult: type, diff --git a/lib/std/crypto/sha2.zig b/lib/std/crypto/sha2.zig index 31884c7381..10909cfaec 100644 --- a/lib/std/crypto/sha2.zig +++ b/lib/std/crypto/sha2.zig @@ -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 comptime std.Target.x86.featureSetHasAll(builtin.cpu.features, .{ .sha, .avx2 })) { + .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 })) { 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)); diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig index 00d19ea1c9..cdd11a6c59 100644 --- a/lib/std/fmt/parse_float.zig +++ b/lib/std/fmt/parse_float.zig @@ -83,8 +83,6 @@ test "fmt.parseFloat #11169" { } test "fmt.parseFloat hex.special" { - if (@import("builtin").zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testing.expect(math.isNan(try parseFloat(f32, "nAn"))); try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf"))); try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf"))); diff --git a/lib/std/hash/xxhash.zig b/lib/std/hash/xxhash.zig index 2e4c11e333..eef9c9654a 100644 --- a/lib/std/hash/xxhash.zig +++ b/lib/std/hash/xxhash.zig @@ -2,6 +2,7 @@ const std = @import("std"); const builtin = @import("builtin"); const mem = std.mem; const expectEqual = std.testing.expectEqual; +const native_endian = builtin.cpu.arch.endian(); const rotl = std.math.rotl; @@ -472,7 +473,7 @@ pub const XxHash3 = struct { } inline fn swap(x: anytype) @TypeOf(x) { - return if (builtin.cpu.arch.endian() == .big) @byteSwap(x) else x; + return if (native_endian == .big) @byteSwap(x) else x; } inline fn disableAutoVectorization(x: anytype) void { diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig index e8e0363c2e..eb9896d40a 100644 --- a/lib/std/http/Client.zig +++ b/lib/std/http/Client.zig @@ -9,6 +9,7 @@ const net = std.net; const Uri = std.Uri; const Allocator = mem.Allocator; const assert = std.debug.assert; +const use_vectors = builtin.zig_backend != .stage2_x86_64; const Client = @This(); const proto = @import("protocol.zig"); @@ -408,7 +409,7 @@ pub const Response = struct { else => return error.HttpHeadersInvalid, }; if (first_line[8] != ' ') return error.HttpHeadersInvalid; - const status = @as(http.Status, @enumFromInt(parseInt3(first_line[9..12].*))); + const status: http.Status = @enumFromInt(parseInt3(first_line[9..12])); const reason = mem.trimLeft(u8, first_line[12..], " "); res.version = version; @@ -481,20 +482,24 @@ pub const Response = struct { } inline fn int64(array: *const [8]u8) u64 { - return @as(u64, @bitCast(array.*)); + return @bitCast(array.*); } - fn parseInt3(nnn: @Vector(3, u8)) u10 { - const zero: @Vector(3, u8) = .{ '0', '0', '0' }; - const mmm: @Vector(3, u10) = .{ 100, 10, 1 }; - return @reduce(.Add, @as(@Vector(3, u10), nnn -% zero) *% mmm); + fn parseInt3(text: *const [3]u8) u10 { + if (use_vectors) { + const nnn: @Vector(3, u8) = text.*; + const zero: @Vector(3, u8) = .{ '0', '0', '0' }; + const mmm: @Vector(3, u10) = .{ 100, 10, 1 }; + return @reduce(.Add, @as(@Vector(3, u10), nnn -% zero) *% mmm); + } + return std.fmt.parseInt(u10, text, 10) catch unreachable; } test parseInt3 { const expectEqual = testing.expectEqual; - try expectEqual(@as(u10, 0), parseInt3("000".*)); - try expectEqual(@as(u10, 418), parseInt3("418".*)); - try expectEqual(@as(u10, 999), parseInt3("999".*)); + try expectEqual(@as(u10, 0), parseInt3("000")); + try expectEqual(@as(u10, 418), parseInt3("418")); + try expectEqual(@as(u10, 999), parseInt3("999")); } version: http.Version, @@ -1588,7 +1593,8 @@ test { if (builtin.os.tag == .wasi) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64 and + !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .avx)) return error.SkipZigTest; std.testing.refAllDecls(@This()); } diff --git a/lib/std/http/Server.zig b/lib/std/http/Server.zig index 055d16eb8a..6928606b1b 100644 --- a/lib/std/http/Server.zig +++ b/lib/std/http/Server.zig @@ -736,8 +736,6 @@ test "HTTP server handles a chunked transfer coding request" { return error.SkipZigTest; } - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const native_endian = comptime builtin.cpu.arch.endian(); if (builtin.zig_backend == .stage2_llvm and native_endian == .big) { // https://github.com/ziglang/zig/issues/13782 diff --git a/lib/std/http/protocol.zig b/lib/std/http/protocol.zig index 8e458ed09c..4fe9c80380 100644 --- a/lib/std/http/protocol.zig +++ b/lib/std/http/protocol.zig @@ -1,8 +1,10 @@ const std = @import("../std.zig"); +const builtin = @import("builtin"); const testing = std.testing; const mem = std.mem; const assert = std.debug.assert; +const use_vectors = builtin.zig_backend != .stage2_x86_64; pub const State = enum { /// Begin header parsing states. @@ -83,7 +85,7 @@ pub const HeadersParser = struct { /// first byte of content is located at `bytes[result]`. pub fn findHeadersEnd(r: *HeadersParser, bytes: []const u8) u32 { const vector_len: comptime_int = @max(std.simd.suggestVectorSize(u8) orelse 1, 8); - const len = @as(u32, @intCast(bytes.len)); + const len: u32 = @intCast(bytes.len); var index: u32 = 0; while (true) { @@ -175,18 +177,27 @@ pub const HeadersParser = struct { continue; }, else => { - const Vector = @Vector(vector_len, u8); - // const BoolVector = @Vector(vector_len, bool); - const BitVector = @Vector(vector_len, u1); - const SizeVector = @Vector(vector_len, u8); - const chunk = bytes[index..][0..vector_len]; - const v: Vector = chunk.*; - const matches_r = @as(BitVector, @bitCast(v == @as(Vector, @splat('\r')))); - const matches_n = @as(BitVector, @bitCast(v == @as(Vector, @splat('\n')))); - const matches_or: SizeVector = matches_r | matches_n; - - const matches = @reduce(.Add, matches_or); + const matches = if (use_vectors) matches: { + const Vector = @Vector(vector_len, u8); + // const BoolVector = @Vector(vector_len, bool); + const BitVector = @Vector(vector_len, u1); + const SizeVector = @Vector(vector_len, u8); + + const v: Vector = chunk.*; + const matches_r: BitVector = @bitCast(v == @as(Vector, @splat('\r'))); + const matches_n: BitVector = @bitCast(v == @as(Vector, @splat('\n'))); + const matches_or: SizeVector = matches_r | matches_n; + + break :matches @reduce(.Add, matches_or); + } else matches: { + var matches: u8 = 0; + for (chunk) |byte| switch (byte) { + '\r', '\n' => matches += 1, + else => {}, + }; + break :matches matches; + }; switch (matches) { 0 => {}, 1 => switch (chunk[vector_len - 1]) { diff --git a/lib/std/math.zig b/lib/std/math.zig index f110efa0af..b18d5bc3ed 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -492,8 +492,6 @@ pub fn shl(comptime T: type, a: T, shift_amt: anytype) T { } test "shl" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { // https://github.com/ziglang/zig/issues/12012 return error.SkipZigTest; @@ -539,8 +537,6 @@ pub fn shr(comptime T: type, a: T, shift_amt: anytype) T { } test "shr" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { // https://github.com/ziglang/zig/issues/12012 return error.SkipZigTest; @@ -587,8 +583,6 @@ pub fn rotr(comptime T: type, x: T, r: anytype) T { } test "rotr" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { // https://github.com/ziglang/zig/issues/12012 return error.SkipZigTest; @@ -634,8 +628,6 @@ pub fn rotl(comptime T: type, x: T, r: anytype) T { } test "rotl" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .aarch64) { // https://github.com/ziglang/zig/issues/12012 return error.SkipZigTest; @@ -764,8 +756,6 @@ pub fn divTrunc(comptime T: type, numerator: T, denominator: T) !T { } test "divTrunc" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDivTrunc(); try comptime testDivTrunc(); } @@ -790,8 +780,6 @@ pub fn divFloor(comptime T: type, numerator: T, denominator: T) !T { } test "divFloor" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDivFloor(); try comptime testDivFloor(); } @@ -829,8 +817,6 @@ pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { } test "divCeil" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDivCeil(); try comptime testDivCeil(); } @@ -875,8 +861,6 @@ pub fn divExact(comptime T: type, numerator: T, denominator: T) !T { } test "divExact" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testDivExact(); try comptime testDivExact(); } @@ -903,8 +887,6 @@ pub fn mod(comptime T: type, numerator: T, denominator: T) !T { } test "mod" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testMod(); try comptime testMod(); } @@ -931,8 +913,6 @@ pub fn rem(comptime T: type, numerator: T, denominator: T) !T { } test "rem" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testRem(); try comptime testRem(); } @@ -1285,7 +1265,8 @@ pub fn lerp(a: anytype, b: anytype, t: anytype) @TypeOf(a, b, t) { } test "lerp" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_x86_64 and + !comptime std.Target.x86.featureSetHas(builtin.cpu.features, .fma)) return error.SkipZigTest; try testing.expectEqual(@as(f64, 75), lerp(50, 100, 0.5)); try testing.expectEqual(@as(f32, 43.75), lerp(50, 25, 0.25)); diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 4051a8cd31..ce73c0c648 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -1318,7 +1318,7 @@ pub const Mutable = struct { /// /// `limbs_buffer` is used for temporary storage. /// The amount required is given by `calcPowLimbsBufferLen`. - pub fn pow(r: *Mutable, a: Const, b: u32, limbs_buffer: []Limb) !void { + pub fn pow(r: *Mutable, a: Const, b: u32, limbs_buffer: []Limb) void { assert(r.limbs.ptr != a.limbs.ptr); // illegal aliasing // Handle all the trivial cases first @@ -3213,7 +3213,7 @@ pub const Managed = struct { var m = try Managed.initCapacity(rma.allocator, needed_limbs); errdefer m.deinit(); var m_mut = m.toMutable(); - try m_mut.pow(a.toConst(), b, limbs_buffer); + m_mut.pow(a.toConst(), b, limbs_buffer); m.setMetadata(m_mut.positive, m_mut.len); rma.deinit(); @@ -3221,7 +3221,7 @@ pub const Managed = struct { } else { try rma.ensureCapacity(needed_limbs); var rma_mut = rma.toMutable(); - try rma_mut.pow(a.toConst(), b, limbs_buffer); + rma_mut.pow(a.toConst(), b, limbs_buffer); rma.setMetadata(rma_mut.positive, rma_mut.len); } } diff --git a/lib/std/math/big/int_test.zig b/lib/std/math/big/int_test.zig index 4a3bf10fcd..da8fb98c5c 100644 --- a/lib/std/math/big/int_test.zig +++ b/lib/std/math/big/int_test.zig @@ -2568,8 +2568,6 @@ test "big.int const to managed" { } test "big.int pow" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - { var a = try Managed.initSet(testing.allocator, -3); defer a.deinit(); @@ -2763,8 +2761,6 @@ fn popCountTest(val: *const Managed, bit_count: usize, expected: usize) !void { } test "big int conversion read/write twos complement" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, (1 << 493) - 1); defer a.deinit(); var b = try Managed.initSet(testing.allocator, (1 << 493) - 1); @@ -2863,8 +2859,6 @@ test "big int write twos complement +/- zero" { } test "big int conversion write twos complement with padding" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var a = try Managed.initSet(testing.allocator, 0x01_ffffffff_ffffffff_ffffffff); defer a.deinit(); diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 420e461ae5..73fe2e7757 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -315,8 +315,6 @@ pub fn zeroes(comptime T: type) T { } test "zeroes" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const C_struct = extern struct { x: u32, y: u32 align(128), @@ -4342,8 +4340,6 @@ pub fn alignInSlice(slice: anytype, comptime new_alignment: usize) ?AlignedSlice } test "read/write(Var)PackedInt" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - switch (builtin.cpu.arch) { // This test generates too much code to execute on WASI. // LLVM backend fails with "too many locals: locals exceed maximum" diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 11dec78036..5ff5144028 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -106,7 +106,7 @@ pub fn MultiArrayList(comptime T: type) type { } pub fn toMultiArrayList(self: Slice) Self { - if (self.ptrs.len == 0) { + if (self.ptrs.len == 0 or self.capacity == 0) { return .{}; } const unaligned_ptr = self.ptrs[sizes.fields[0]]; diff --git a/lib/std/net/test.zig b/lib/std/net/test.zig index fd92c64f35..0fe53a7b9f 100644 --- a/lib/std/net/test.zig +++ b/lib/std/net/test.zig @@ -60,7 +60,7 @@ test "parse and render IPv6 addresses" { } test "invalid but parseable IPv6 scope ids" { - if (builtin.os.tag != .linux or comptime !builtin.os.tag.isDarwin()) { + if (builtin.os.tag != .linux and comptime !builtin.os.tag.isDarwin()) { // Currently, resolveIp6 with alphanumerical scope IDs only works on Linux. // TODO Make this test pass on other operating systems. return error.SkipZigTest; diff --git a/lib/std/once.zig b/lib/std/once.zig index 87f81ee59c..f012e017dd 100644 --- a/lib/std/once.zig +++ b/lib/std/once.zig @@ -46,8 +46,6 @@ fn incr() void { } test "Once executes its function just once" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - if (builtin.single_threaded) { global_once.call(); global_once.call(); diff --git a/lib/std/os/test.zig b/lib/std/os/test.zig index b7c1b7b675..f4a67f1035 100644 --- a/lib/std/os/test.zig +++ b/lib/std/os/test.zig @@ -375,8 +375,6 @@ fn testThreadIdFn(thread_id: *Thread.Id) void { test "std.Thread.getCurrentId" { if (builtin.single_threaded) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var thread_current_id: Thread.Id = undefined; const thread = try Thread.spawn(.{}, testThreadIdFn, .{&thread_current_id}); thread.join(); @@ -420,8 +418,6 @@ test "cpu count" { test "thread local storage" { if (builtin.single_threaded) return error.SkipZigTest; - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - const thread1 = try Thread.spawn(.{}, testTls, .{}); const thread2 = try Thread.spawn(.{}, testTls, .{}); try testTls(); diff --git a/lib/std/rand/test.zig b/lib/std/rand/test.zig index e8a1d4de8a..d02c016357 100644 --- a/lib/std/rand/test.zig +++ b/lib/std/rand/test.zig @@ -1,5 +1,4 @@ const std = @import("../std.zig"); -const builtin = @import("builtin"); const math = std.math; const DefaultPrng = std.rand.DefaultPrng; const Random = std.rand.Random; @@ -200,8 +199,6 @@ fn testRandomIntLessThan() !void { } test "Random intAtMost" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - @setEvalBranchQuota(10000); try testRandomIntAtMost(); try comptime testRandomIntAtMost(); @@ -242,8 +239,6 @@ fn testRandomIntAtMost() !void { } test "Random Biased" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - var prng = DefaultPrng.init(0); const random = prng.random(); // Not thoroughly checking the logic here. @@ -452,8 +447,6 @@ test "CSPRNG" { } test "Random weightedIndex" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - // Make sure weightedIndex works for various integers and floats inline for (.{ u64, i4, f32, f64 }) |T| { var prng = DefaultPrng.init(0); diff --git a/lib/std/zig/tokenizer.zig b/lib/std/zig/tokenizer.zig index 59dcf29e16..72f65afb3a 100644 --- a/lib/std/zig/tokenizer.zig +++ b/lib/std/zig/tokenizer.zig @@ -1,5 +1,4 @@ const std = @import("../std.zig"); -const builtin = @import("builtin"); pub const Token = struct { tag: Tag, @@ -1450,8 +1449,6 @@ test "chars" { } test "invalid token characters" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTokenize("#", &.{.invalid}); try testTokenize("`", &.{.invalid}); try testTokenize("'c", &.{.invalid}); @@ -1571,8 +1568,6 @@ test "pipe and then invalid" { } test "line comment and doc comment" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTokenize("//", &.{}); try testTokenize("// a / b", &.{}); try testTokenize("// /", &.{}); @@ -1647,8 +1642,6 @@ test "range literals" { } test "number literals decimal" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTokenize("0", &.{.number_literal}); try testTokenize("1", &.{.number_literal}); try testTokenize("2", &.{.number_literal}); @@ -1897,8 +1890,6 @@ test "invalid token with unfinished escape right before eof" { } test "saturating operators" { - if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; - try testTokenize("<<", &.{.angle_bracket_angle_bracket_left}); try testTokenize("<<|", &.{.angle_bracket_angle_bracket_left_pipe}); try testTokenize("<<|=", &.{.angle_bracket_angle_bracket_left_pipe_equal}); |
