@zigc/lib 0.17.0-dev.224 → 0.17.0-dev.242
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/c/math.zig +31 -2
- package/compiler/build_runner.zig +1 -1
- package/compiler/reduce/Walk.zig +1 -6
- package/compiler/resinator/compile.zig +1 -1
- package/compiler/resinator/cvtres.zig +4 -4
- package/compiler/resinator/ico.zig +4 -4
- package/compiler/resinator/parse.zig +2 -2
- package/compiler/resinator/res.zig +1 -1
- package/compiler/translate-c/ast.zig +11 -21
- package/compiler_rt/atomics.zig +1 -1
- package/compiler_rt/cos.zig +1 -1
- package/compiler_rt/rem_pio2l.zig +1 -1
- package/compiler_rt/sin.zig +1 -1
- package/compiler_rt/sincos.zig +1 -1
- package/compiler_rt/ssp.zig +2 -2
- package/compiler_rt/tan.zig +1 -1
- package/docs/wasm/Walk.zig +1 -3
- package/docs/wasm/html_render.zig +1 -2
- package/package.json +1 -1
- package/std/Build/Step/ConfigHeader.zig +1 -1
- package/std/Io/Kqueue.zig +1 -1
- package/std/Io/Reader.zig +0 -5
- package/std/Io/Threaded.zig +4 -4
- package/std/Io/Writer.zig +1 -2
- package/std/Io/net/HostName.zig +11 -6
- package/std/Random/ChaCha.zig +2 -2
- package/std/Random/benchmark.zig +2 -2
- package/std/Thread.zig +2 -2
- package/std/base64.zig +5 -5
- package/std/bit_set.zig +83 -66
- package/std/c.zig +19 -19
- package/std/compress/flate/Decompress.zig +1 -1
- package/std/crypto/25519/curve25519.zig +2 -2
- package/std/crypto/25519/edwards25519.zig +3 -3
- package/std/crypto/25519/ristretto255.zig +2 -2
- package/std/crypto/25519/scalar.zig +6 -6
- package/std/crypto/25519/x25519.zig +1 -1
- package/std/crypto/Certificate.zig +1 -1
- package/std/crypto/Sha1.zig +1 -1
- package/std/crypto/aegis.zig +45 -39
- package/std/crypto/aes_ccm.zig +20 -20
- package/std/crypto/aes_gcm.zig +10 -12
- package/std/crypto/aes_ocb.zig +9 -9
- package/std/crypto/argon2.zig +15 -15
- package/std/crypto/bcrypt.zig +20 -10
- package/std/crypto/benchmark.zig +7 -7
- package/std/crypto/blake2.zig +100 -64
- package/std/crypto/cbc_mac.zig +1 -1
- package/std/crypto/chacha20.zig +10 -10
- package/std/crypto/cmac.zig +2 -2
- package/std/crypto/codecs/asn1.zig +1 -1
- package/std/crypto/codecs/base64_hex_ct.zig +1 -1
- package/std/crypto/ecdsa.zig +9 -9
- package/std/crypto/ff.zig +2 -2
- package/std/crypto/ghash_polyval.zig +4 -4
- package/std/crypto/hkdf.zig +1 -1
- package/std/crypto/isap.zig +3 -3
- package/std/crypto/kangarootwelve.zig +1 -1
- package/std/crypto/keccak_p.zig +7 -7
- package/std/crypto/md5.zig +1 -1
- package/std/crypto/ml_dsa.zig +33 -33
- package/std/crypto/ml_kem.zig +4 -4
- package/std/crypto/modes.zig +1 -1
- package/std/crypto/pbkdf2.zig +1 -1
- package/std/crypto/pcurves/p256/scalar.zig +3 -3
- package/std/crypto/pcurves/p384/scalar.zig +2 -2
- package/std/crypto/pcurves/secp256k1/scalar.zig +3 -3
- package/std/crypto/pcurves/tests/p256.zig +5 -5
- package/std/crypto/pcurves/tests/p384.zig +5 -5
- package/std/crypto/pcurves/tests/secp256k1.zig +3 -3
- package/std/crypto/salsa20.zig +8 -8
- package/std/crypto/sha2.zig +2 -2
- package/std/crypto/sha3.zig +2 -2
- package/std/crypto/siphash.zig +1 -1
- package/std/crypto/timing_safe.zig +5 -4
- package/std/crypto/tls/Client.zig +10 -9
- package/std/crypto.zig +3 -3
- package/std/debug/Dwarf.zig +1 -1
- package/std/debug.zig +6 -4
- package/std/elf.zig +1 -1
- package/std/enums.zig +3 -3
- package/std/fmt/parse_float/decimal.zig +1 -1
- package/std/fmt.zig +5 -1
- package/std/fs/path.zig +1 -1
- package/std/hash/Adler32.zig +3 -3
- package/std/hash/benchmark.zig +2 -2
- package/std/hash/wyhash.zig +1 -1
- package/std/heap/debug_allocator.zig +1 -1
- package/std/http.zig +1 -1
- package/std/json/static.zig +2 -2
- package/std/math/big/int.zig +3 -3
- package/std/math/float.zig +62 -0
- package/std/math/nextafter.zig +1 -2
- package/std/math/powi.zig +2 -3
- package/std/math/signbit.zig +0 -1
- package/std/math.zig +13 -18
- package/std/mem.zig +9 -8
- package/std/meta.zig +1 -1
- package/std/os/emscripten.zig +2 -2
- package/std/os/linux.zig +4 -4
- package/std/os/uefi/hii.zig +1 -1
- package/std/std.zig +3 -0
- package/std/tar/Writer.zig +39 -33
- package/std/tar.zig +8 -4
- package/std/testing.zig +1 -1
- package/std/unicode.zig +13 -8
- package/std/zig/Ast/Render.zig +1 -25
- package/std/zig/Ast.zig +5 -28
- package/std/zig/AstGen.zig +75 -184
- package/std/zig/AstRlAnnotate.zig +1 -11
- package/std/zig/AstSmith.zig +5 -11
- package/std/zig/LibCInstallation.zig +1 -1
- package/std/zig/Parse.zig +4 -69
- package/std/zig/TokenSmith.zig +0 -6
- package/std/zig/WindowsSdk.zig +1 -1
- package/std/zig/Zir.zig +0 -54
- package/std/zig/ZonGen.zig +0 -1
- package/std/zig/llvm/Builder.zig +3 -7
- package/std/zig/tokenizer.zig +4 -43
- package/std/zig.zig +0 -2
- package/compiler_rt/long_double.zig +0 -37
- package/libc/mingw/math/lrintl.c +0 -18
- package/libc/mingw/math/rintl.c +0 -16
- package/libc/musl/src/math/i386/lrintl.c +0 -8
- package/libc/musl/src/math/i386/rintl.c +0 -7
- package/libc/musl/src/math/lrintl.c +0 -36
- package/libc/musl/src/math/rintl.c +0 -29
- package/libc/musl/src/math/s390x/rintl.c +0 -15
- package/libc/musl/src/math/x32/lrintl.s +0 -7
- package/libc/musl/src/math/x32/rintl.s +0 -6
- package/libc/musl/src/math/x86_64/lrintl.c +0 -8
- package/libc/musl/src/math/x86_64/rintl.c +0 -7
|
@@ -207,8 +207,8 @@ test "eql (vectors)" {
|
|
|
207
207
|
|
|
208
208
|
test compare {
|
|
209
209
|
const expectEqual = std.testing.expectEqual;
|
|
210
|
-
var a
|
|
211
|
-
var b
|
|
210
|
+
var a: [32]u8 = @splat(10);
|
|
211
|
+
var b: [32]u8 = @splat(10);
|
|
212
212
|
try expectEqual(compare(u8, &a, &b, .big), .eq);
|
|
213
213
|
try expectEqual(compare(u8, &a, &b, .little), .eq);
|
|
214
214
|
a[31] = 1;
|
|
@@ -228,7 +228,7 @@ test "add and sub" {
|
|
|
228
228
|
var a: [len]u8 = undefined;
|
|
229
229
|
var b: [len]u8 = undefined;
|
|
230
230
|
var c: [len]u8 = undefined;
|
|
231
|
-
const zero
|
|
231
|
+
const zero: [len]u8 = @splat(0);
|
|
232
232
|
var iterations: usize = 100;
|
|
233
233
|
while (iterations != 0) : (iterations -= 1) {
|
|
234
234
|
io.random(&a);
|
|
@@ -262,7 +262,8 @@ test classify {
|
|
|
262
262
|
declassify(&out);
|
|
263
263
|
|
|
264
264
|
// Comparing public data in non-constant time is acceptable.
|
|
265
|
-
|
|
265
|
+
const zeroes: [out.len]u8 = @splat(0);
|
|
266
|
+
try expect(!std.mem.eql(u8, &out, &zeroes));
|
|
266
267
|
|
|
267
268
|
// Comparing secret data must be done in constant time. The result
|
|
268
269
|
// is going to be considered as secret as well.
|
|
@@ -375,7 +375,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
375
375
|
const auth_tag = record_decoder.array(P.AEAD.tag_length).*;
|
|
376
376
|
const nonce = nonce: {
|
|
377
377
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
378
|
-
const pad
|
|
378
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
379
379
|
const operand: V = pad ++ @as([8]u8, @bitCast(big(read_seq)));
|
|
380
380
|
break :nonce @as(V, pv.server_handshake_iv) ^ operand;
|
|
381
381
|
};
|
|
@@ -415,7 +415,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
415
415
|
comptime std.math.shl(u64, std.math.maxInt(u64), 8 * P.record_iv_length);
|
|
416
416
|
const nonce: [P.AEAD.nonce_length]u8 = nonce: {
|
|
417
417
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
418
|
-
const pad
|
|
418
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
419
419
|
const operand: V = pad ++ @as([8]u8, @bitCast(big(masked_read_seq)));
|
|
420
420
|
break :nonce @as(V, pv.app_cipher.server_write_IV ++ record_iv) ^ operand;
|
|
421
421
|
};
|
|
@@ -539,7 +539,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
539
539
|
const p = &@field(handshake_cipher, @tagName(tag.with()));
|
|
540
540
|
const P = @TypeOf(p.*).A;
|
|
541
541
|
const hello_hash = p.transcript_hash.peek();
|
|
542
|
-
const zeroes
|
|
542
|
+
const zeroes: [P.Hash.digest_length]u8 = @splat(0);
|
|
543
543
|
const early_secret = P.Hkdf.extract(&[1]u8{0}, &zeroes);
|
|
544
544
|
const empty_hash = tls.emptyHash(P.Hash);
|
|
545
545
|
p.version = .{ .tls_1_3 = undefined };
|
|
@@ -791,7 +791,7 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
791
791
|
const pv = &p.version.tls_1_2;
|
|
792
792
|
const nonce: [P.AEAD.nonce_length]u8 = nonce: {
|
|
793
793
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
794
|
-
const pad
|
|
794
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
795
795
|
const operand: V = pad ++ @as([8]u8, @bitCast(big(write_seq)));
|
|
796
796
|
break :nonce @as(V, pv.app_cipher.client_write_IV ++ pv.app_cipher.client_salt) ^ operand;
|
|
797
797
|
};
|
|
@@ -832,8 +832,9 @@ pub fn init(input: *Reader, output: *Writer, options: Options) InitError!Client
|
|
|
832
832
|
}
|
|
833
833
|
switch (handshake_cipher) {
|
|
834
834
|
inline else => |*p| {
|
|
835
|
+
const pad: [64]u8 = @splat(' ');
|
|
835
836
|
try main_cert_pub_key.verifySignature(&hsd, &.{
|
|
836
|
-
|
|
837
|
+
pad ++ "TLS 1.3, server CertificateVerify\x00",
|
|
837
838
|
&p.transcript_hash.peek(),
|
|
838
839
|
});
|
|
839
840
|
p.transcript_hash.update(wrapped_handshake);
|
|
@@ -1066,7 +1067,7 @@ fn prepareCiphertextRecord(
|
|
|
1066
1067
|
ciphertext_end += auth_tag.len;
|
|
1067
1068
|
const nonce = nonce: {
|
|
1068
1069
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
1069
|
-
const pad
|
|
1070
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
1070
1071
|
const operand: V = pad ++ mem.toBytes(big(c.write_seq));
|
|
1071
1072
|
break :nonce @as(V, pv.client_iv) ^ operand;
|
|
1072
1073
|
};
|
|
@@ -1103,7 +1104,7 @@ fn prepareCiphertextRecord(
|
|
|
1103
1104
|
ciphertext_end += P.record_iv_length;
|
|
1104
1105
|
const nonce: [P.AEAD.nonce_length]u8 = nonce: {
|
|
1105
1106
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
1106
|
-
const pad
|
|
1107
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
1107
1108
|
const operand: V = pad ++ @as([8]u8, @bitCast(big(c.write_seq)));
|
|
1108
1109
|
break :nonce @as(V, pv.client_write_IV ++ pv.client_salt) ^ operand;
|
|
1109
1110
|
};
|
|
@@ -1185,7 +1186,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
|
|
1185
1186
|
const auth_tag = (input.takeArray(P.AEAD.tag_length) catch unreachable).*; // already peeked
|
|
1186
1187
|
const nonce = nonce: {
|
|
1187
1188
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
1188
|
-
const pad
|
|
1189
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
1189
1190
|
const operand: V = pad ++ mem.toBytes(big(c.read_seq));
|
|
1190
1191
|
break :nonce @as(V, pv.server_iv) ^ operand;
|
|
1191
1192
|
};
|
|
@@ -1211,7 +1212,7 @@ fn readIndirect(c: *Client) Reader.Error!usize {
|
|
|
1211
1212
|
comptime std.math.shl(u64, std.math.maxInt(u64), 8 * P.record_iv_length);
|
|
1212
1213
|
const nonce: [P.AEAD.nonce_length]u8 = nonce: {
|
|
1213
1214
|
const V = @Vector(P.AEAD.nonce_length, u8);
|
|
1214
|
-
const pad
|
|
1215
|
+
const pad: [P.AEAD.nonce_length - 8]u8 = @splat(0);
|
|
1215
1216
|
const operand: V = pad ++ @as([8]u8, @bitCast(big(masked_read_seq)));
|
|
1216
1217
|
break :nonce @as(V, pv.server_write_IV ++ record_iv) ^ operand;
|
|
1217
1218
|
};
|
package/std/crypto.zig
CHANGED
|
@@ -394,7 +394,7 @@ test "issue #4532: no index out of bounds" {
|
|
|
394
394
|
};
|
|
395
395
|
|
|
396
396
|
inline for (types) |Hasher| {
|
|
397
|
-
var block
|
|
397
|
+
var block: [Hasher.block_length]u8 = @splat('#');
|
|
398
398
|
var out1: [Hasher.digest_length]u8 = undefined;
|
|
399
399
|
var out2: [Hasher.digest_length]u8 = undefined;
|
|
400
400
|
const h0 = Hasher.init(.{});
|
|
@@ -417,8 +417,8 @@ pub fn secureZero(comptime T: type, s: []volatile T) void {
|
|
|
417
417
|
}
|
|
418
418
|
|
|
419
419
|
test secureZero {
|
|
420
|
-
var a
|
|
421
|
-
var b
|
|
420
|
+
var a: [8]u8 = @splat(0xFE);
|
|
421
|
+
var b: [8]u8 = @splat(0xFE);
|
|
422
422
|
|
|
423
423
|
@memset(&a, 0);
|
|
424
424
|
secureZero(u8, &b);
|
package/std/debug/Dwarf.zig
CHANGED
package/std/debug.zig
CHANGED
|
@@ -1381,7 +1381,7 @@ test printLineFromFile {
|
|
|
1381
1381
|
try writer.flush();
|
|
1382
1382
|
|
|
1383
1383
|
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 });
|
|
1384
|
-
try expectEqualStrings((
|
|
1384
|
+
try expectEqualStrings(&@as([overlap]u8, @splat('a')) ++ "\n", aw.written());
|
|
1385
1385
|
aw.clearRetainingCapacity();
|
|
1386
1386
|
}
|
|
1387
1387
|
{
|
|
@@ -1395,7 +1395,7 @@ test printLineFromFile {
|
|
|
1395
1395
|
try writer.splatByteAll('a', std.heap.page_size_max);
|
|
1396
1396
|
|
|
1397
1397
|
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
|
1398
|
-
try expectEqualStrings((
|
|
1398
|
+
try expectEqualStrings(&@as([std.heap.page_size_max]u8, @splat('a')) ++ "\n", aw.written());
|
|
1399
1399
|
aw.clearRetainingCapacity();
|
|
1400
1400
|
}
|
|
1401
1401
|
{
|
|
@@ -1410,14 +1410,16 @@ test printLineFromFile {
|
|
|
1410
1410
|
|
|
1411
1411
|
try expectError(error.EndOfStream, printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 }));
|
|
1412
1412
|
|
|
1413
|
+
const many_a: [3 * std.heap.page_size_max]u8 = @splat('a');
|
|
1414
|
+
|
|
1413
1415
|
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
|
1414
|
-
try expectEqualStrings(
|
|
1416
|
+
try expectEqualStrings(&many_a ++ "\n", aw.written());
|
|
1415
1417
|
aw.clearRetainingCapacity();
|
|
1416
1418
|
|
|
1417
1419
|
try writer.writeAll("a\na");
|
|
1418
1420
|
|
|
1419
1421
|
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 1, .column = 0 });
|
|
1420
|
-
try expectEqualStrings(
|
|
1422
|
+
try expectEqualStrings(&many_a ++ "a\n", aw.written());
|
|
1421
1423
|
aw.clearRetainingCapacity();
|
|
1422
1424
|
|
|
1423
1425
|
try printLineFromFile(io, output_stream, .{ .file_name = path, .line = 2, .column = 0 });
|
package/std/elf.zig
CHANGED
|
@@ -3054,7 +3054,7 @@ pub const ar_hdr = extern struct {
|
|
|
3054
3054
|
fn genSpecialMemberName(comptime name: []const u8) *const [16]u8 {
|
|
3055
3055
|
assert(name.len <= 16);
|
|
3056
3056
|
const padding = 16 - name.len;
|
|
3057
|
-
return name ++
|
|
3057
|
+
return name ++ @as([padding]u8, @splat(0x20));
|
|
3058
3058
|
}
|
|
3059
3059
|
|
|
3060
3060
|
// Archive files start with the ARMAG identifying string. Then follows a
|
package/std/enums.zig
CHANGED
|
@@ -166,7 +166,7 @@ pub fn directEnumArrayDefault(
|
|
|
166
166
|
init_values: EnumFieldStruct(E, Data, default),
|
|
167
167
|
) [directEnumArrayLen(E, max_unused_slots)]Data {
|
|
168
168
|
const len = comptime directEnumArrayLen(E, max_unused_slots);
|
|
169
|
-
var result: [len]Data =
|
|
169
|
+
var result: [len]Data = @splat(default orelse undefined);
|
|
170
170
|
inline for (@typeInfo(@TypeOf(init_values)).@"struct".fields) |f| {
|
|
171
171
|
const enum_value = @field(E, f.name);
|
|
172
172
|
const index = @as(usize, @intCast(@intFromEnum(enum_value)));
|
|
@@ -247,7 +247,7 @@ pub fn EnumSet(comptime E: type) type {
|
|
|
247
247
|
/// The element type for this set.
|
|
248
248
|
pub const Key = Indexer.Key;
|
|
249
249
|
|
|
250
|
-
const BitSet = std.
|
|
250
|
+
const BitSet = std.bit_set.Static(Indexer.count);
|
|
251
251
|
|
|
252
252
|
/// The maximum number of items in this set.
|
|
253
253
|
pub const len = Indexer.count;
|
|
@@ -445,7 +445,7 @@ pub fn EnumMap(comptime E: type, comptime V: type) type {
|
|
|
445
445
|
/// The number of possible keys in the map
|
|
446
446
|
pub const len = Indexer.count;
|
|
447
447
|
|
|
448
|
-
const BitSet = std.
|
|
448
|
+
const BitSet = std.bit_set.Static(Indexer.count);
|
|
449
449
|
|
|
450
450
|
/// Bits determining whether items are in the map
|
|
451
451
|
bits: BitSet = .empty,
|
package/std/fmt.zig
CHANGED
|
@@ -1194,8 +1194,12 @@ test bytesToHex {
|
|
|
1194
1194
|
}
|
|
1195
1195
|
|
|
1196
1196
|
test hexToBytes {
|
|
1197
|
+
const repeated: []const u8 = repeated: {
|
|
1198
|
+
const buf: [32][2]u8 = @splat("90".*);
|
|
1199
|
+
break :repeated @ptrCast(&buf);
|
|
1200
|
+
};
|
|
1197
1201
|
var buf: [32]u8 = undefined;
|
|
1198
|
-
try expectFmt(
|
|
1202
|
+
try expectFmt(repeated, "{X}", .{try hexToBytes(&buf, repeated)});
|
|
1199
1203
|
try expectFmt("ABCD", "{X}", .{try hexToBytes(&buf, "ABCD")});
|
|
1200
1204
|
try expectFmt("", "{X}", .{try hexToBytes(&buf, "")});
|
|
1201
1205
|
try std.testing.expectError(error.InvalidCharacter, hexToBytes(&buf, "012Z"));
|
package/std/fs/path.zig
CHANGED
|
@@ -897,7 +897,7 @@ pub fn resolveWindows(allocator: Allocator, paths: []const []const u8) Allocator
|
|
|
897
897
|
var buf: [3]usize = undefined;
|
|
898
898
|
var bit_set_allocator_state: std.heap.BufferFirstAllocator = .init(@ptrCast(&buf), allocator);
|
|
899
899
|
const bit_set_allocator = bit_set_allocator_state.allocator();
|
|
900
|
-
var relevant_paths = try
|
|
900
|
+
var relevant_paths: std.bit_set.Dynamic = try .initEmpty(bit_set_allocator, paths.len);
|
|
901
901
|
defer relevant_paths.deinit(bit_set_allocator);
|
|
902
902
|
|
|
903
903
|
// Iterate the paths backwards, marking the relevant paths along the way.
|
package/std/hash/Adler32.zig
CHANGED
|
@@ -88,15 +88,15 @@ test "sanity" {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
test "long" {
|
|
91
|
-
const long1
|
|
91
|
+
const long1: [1024]u8 = @splat(1);
|
|
92
92
|
try testing.expectEqual(@as(u32, 0x06780401), hash(long1[0..]));
|
|
93
93
|
|
|
94
|
-
const long2
|
|
94
|
+
const long2: [1025]u8 = @splat(1);
|
|
95
95
|
try testing.expectEqual(@as(u32, 0x0a7a0402), hash(long2[0..]));
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
test "very long" {
|
|
99
|
-
const long
|
|
99
|
+
const long: [5553]u8 = @splat(1);
|
|
100
100
|
try testing.expectEqual(@as(u32, 0x707f15b2), hash(long[0..]));
|
|
101
101
|
}
|
|
102
102
|
|
package/std/hash/benchmark.zig
CHANGED
|
@@ -93,13 +93,13 @@ const hashes = [_]Hash{
|
|
|
93
93
|
.ty = hash.SipHash64(1, 3),
|
|
94
94
|
.name = "siphash64",
|
|
95
95
|
.has_crypto_api = true,
|
|
96
|
-
.init_u8s =
|
|
96
|
+
.init_u8s = &@as([16]u8, @splat(0)),
|
|
97
97
|
},
|
|
98
98
|
Hash{
|
|
99
99
|
.ty = hash.SipHash128(1, 3),
|
|
100
100
|
.name = "siphash128",
|
|
101
101
|
.has_crypto_api = true,
|
|
102
|
-
.init_u8s =
|
|
102
|
+
.init_u8s = &@as([16]u8, @splat(0)),
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
105
|
|
package/std/hash/wyhash.zig
CHANGED
|
@@ -164,7 +164,7 @@ pub fn DebugAllocator(comptime config: Config) type {
|
|
|
164
164
|
return struct {
|
|
165
165
|
backing_allocator: Allocator = std.heap.page_allocator,
|
|
166
166
|
/// Tracks the active bucket, which is the one that has free slots in it.
|
|
167
|
-
buckets: [small_bucket_count]?*BucketHeader =
|
|
167
|
+
buckets: [small_bucket_count]?*BucketHeader = @splat(null),
|
|
168
168
|
large_allocations: LargeAllocTable = .empty,
|
|
169
169
|
total_requested_bytes: @TypeOf(total_requested_bytes_init) = total_requested_bytes_init,
|
|
170
170
|
requested_memory_limit: @TypeOf(requested_memory_limit_init) = requested_memory_limit_init,
|
package/std/http.zig
CHANGED
|
@@ -749,7 +749,7 @@ pub const BodyWriter = struct {
|
|
|
749
749
|
/// How many zeroes to reserve for hex-encoded chunk length.
|
|
750
750
|
const chunk_len_digits = 8;
|
|
751
751
|
const max_chunk_len: usize = std.math.pow(u64, 16, chunk_len_digits) - 1;
|
|
752
|
-
const chunk_header_template = (
|
|
752
|
+
const chunk_header_template = @as([chunk_len_digits]u8, @splat('0')) ++ "\r\n";
|
|
753
753
|
|
|
754
754
|
comptime {
|
|
755
755
|
assert(max_chunk_len == std.math.maxInt(u32));
|
package/std/json/static.zig
CHANGED
|
@@ -334,7 +334,7 @@ pub fn innerParse(
|
|
|
334
334
|
if (.object_begin != try source.next()) return error.UnexpectedToken;
|
|
335
335
|
|
|
336
336
|
var r: T = undefined;
|
|
337
|
-
var fields_seen
|
|
337
|
+
var fields_seen: [structInfo.fields.len]bool = @splat(false);
|
|
338
338
|
|
|
339
339
|
while (true) {
|
|
340
340
|
var name_token: ?Token = try source.nextAllocMax(allocator, .alloc_if_needed, options.max_value_len.?);
|
|
@@ -649,7 +649,7 @@ pub fn innerParseFromValue(
|
|
|
649
649
|
if (source != .object) return error.UnexpectedToken;
|
|
650
650
|
|
|
651
651
|
var r: T = undefined;
|
|
652
|
-
var fields_seen
|
|
652
|
+
var fields_seen: [structInfo.fields.len]bool = @splat(false);
|
|
653
653
|
|
|
654
654
|
var it = source.object.iterator();
|
|
655
655
|
while (it.next()) |kv| {
|
package/std/math/big/int.zig
CHANGED
|
@@ -29,8 +29,8 @@ const Constants = struct {
|
|
|
29
29
|
};
|
|
30
30
|
const constants: Constants = blk: {
|
|
31
31
|
@setEvalBranchQuota(2000);
|
|
32
|
-
var digits_per_limb
|
|
33
|
-
var bases
|
|
32
|
+
var digits_per_limb: [37]u8 = @splat(0);
|
|
33
|
+
var bases: [37]Limb = @splat(0);
|
|
34
34
|
for (2..37) |base| {
|
|
35
35
|
digits_per_limb[base] = @intCast(math.log(Limb, base, math.maxInt(Limb)));
|
|
36
36
|
bases[base] = std.math.pow(Limb, base, digits_per_limb[base]);
|
|
@@ -2391,7 +2391,7 @@ pub const Const = struct {
|
|
|
2391
2391
|
var limbs: [calcToStringLimbsBufferLen(available_len, 10)]Limb = undefined;
|
|
2392
2392
|
|
|
2393
2393
|
const biggest: Const = .{
|
|
2394
|
-
.limbs =
|
|
2394
|
+
.limbs = &@as([available_len]Limb, @splat(comptime math.maxInt(Limb))),
|
|
2395
2395
|
.positive = false,
|
|
2396
2396
|
};
|
|
2397
2397
|
var buf: [biggest.sizeInBaseUpperBound(2)]u8 = undefined;
|
package/std/math/float.zig
CHANGED
|
@@ -4,6 +4,68 @@ const assert = std.debug.assert;
|
|
|
4
4
|
const expect = std.testing.expect;
|
|
5
5
|
const expectEqual = std.testing.expectEqual;
|
|
6
6
|
|
|
7
|
+
/// A namespace for functions that deal with floats that provide greater than
|
|
8
|
+
/// double precision (`f80`, `f128`, `c_longdouble`). Commonly referred to as
|
|
9
|
+
/// `long double` in C.
|
|
10
|
+
pub const long_double = struct {
|
|
11
|
+
const U80 = @Int(.unsigned, 80);
|
|
12
|
+
|
|
13
|
+
inline fn bitWidth(x: anytype) u16 {
|
|
14
|
+
const T = @TypeOf(x);
|
|
15
|
+
return switch (T) {
|
|
16
|
+
f80, f128, c_longdouble => @typeInfo(T).float.bits,
|
|
17
|
+
else => @compileError("Unsupported type: " ++ @typeName(T) ++ "\nPass a `f80`, `f128`, or `c_longdouble`."),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// Returns the sign + exponent bits of a `long double`.
|
|
22
|
+
pub fn signExponent(x: anytype) u16 {
|
|
23
|
+
const bit_width = bitWidth(x);
|
|
24
|
+
switch (bit_width) {
|
|
25
|
+
80 => {
|
|
26
|
+
const bits: U80 = @bitCast(x);
|
|
27
|
+
return @intCast(bits >> 64);
|
|
28
|
+
},
|
|
29
|
+
128 => {
|
|
30
|
+
const bits: u128 = @bitCast(x);
|
|
31
|
+
return @intCast(bits >> 112);
|
|
32
|
+
},
|
|
33
|
+
// `c_longdouble` can have <80 bits on some targets, we want to error on that
|
|
34
|
+
else => @compileError(std.fmt.comptimePrint("`signExponent` supports floats of only `80` and `128` bit width, got bit width: {d}", .{bit_width})),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
test "signExponent" {
|
|
39
|
+
try expectEqual(signExponent(@as(f80, -0.0)), 0x8000);
|
|
40
|
+
try expectEqual(signExponent(@as(f128, 0.0)), 0x0000);
|
|
41
|
+
try expectEqual(signExponent(@as(f128, 42.0)), 0x4004);
|
|
42
|
+
try expectEqual(signExponent(nan(c_longdouble)), 0x7FFF);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/// Takes the top 16 bits of a `long double`'s mantissa.
|
|
46
|
+
pub fn mantissaTop(x: anytype) u16 {
|
|
47
|
+
const bit_width = bitWidth(x);
|
|
48
|
+
switch (bit_width) {
|
|
49
|
+
80 => {
|
|
50
|
+
const bits: U80 = @bitCast(x);
|
|
51
|
+
return @intCast((bits >> 48) & 0xFFFF);
|
|
52
|
+
},
|
|
53
|
+
128 => {
|
|
54
|
+
const bits: u128 = @bitCast(x);
|
|
55
|
+
return @intCast((bits >> 96) & 0xFFFF);
|
|
56
|
+
},
|
|
57
|
+
// `c_longdouble` can have <80 bits on some targets, we want to error on that
|
|
58
|
+
else => @compileError(std.fmt.comptimePrint("`mantissaTop` supports floats of only `80` and `128` bit width, got bit width: {d}", .{bit_width})),
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
test "mantissaTop" {
|
|
63
|
+
try expectEqual(mantissaTop(@as(f80, -0.0)), 0x0000);
|
|
64
|
+
try expectEqual(mantissaTop(nan(f128)), 0x8000);
|
|
65
|
+
try expectEqual(mantissaTop(@as(f128, 42.0)), 0x5000);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
7
69
|
pub fn FloatRepr(comptime Float: type) type {
|
|
8
70
|
const fractional_bits = floatFractionalBits(Float);
|
|
9
71
|
const exponent_bits = floatExponentBits(Float);
|
package/std/math/nextafter.zig
CHANGED
|
@@ -23,7 +23,7 @@ pub fn nextAfter(comptime T: type, x: T, y: T) T {
|
|
|
23
23
|
fn nextAfterInt(comptime T: type, x: T, y: T) T {
|
|
24
24
|
comptime assert(@typeInfo(T) == .int or @typeInfo(T) == .comptime_int);
|
|
25
25
|
return if (@typeInfo(T) == .int and @bitSizeOf(T) < 2)
|
|
26
|
-
// Special case for `
|
|
26
|
+
// Special case for `u0`, `i1`, and `u1`.
|
|
27
27
|
y
|
|
28
28
|
else if (y > x)
|
|
29
29
|
x + 1
|
|
@@ -102,7 +102,6 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
test "int" {
|
|
105
|
-
try expect(nextAfter(i0, 0, 0) == 0);
|
|
106
105
|
try expect(nextAfter(u0, 0, 0) == 0);
|
|
107
106
|
try expect(nextAfter(i1, 0, 0) == 0);
|
|
108
107
|
try expect(nextAfter(i1, 0, -1) == -1);
|
package/std/math/powi.zig
CHANGED
|
@@ -15,12 +15,12 @@ const testing = std.testing;
|
|
|
15
15
|
/// - Underflow: Absolute value of result smaller than 1
|
|
16
16
|
///
|
|
17
17
|
/// Edge case rules ordered by precedence:
|
|
18
|
-
/// - powi(T, x, 0) = 1 unless T is i1,
|
|
18
|
+
/// - powi(T, x, 0) = 1 unless T is i1, u0
|
|
19
19
|
/// - powi(T, 0, x) = 0 when x > 0
|
|
20
20
|
/// - powi(T, 0, x) = Overflow
|
|
21
21
|
/// - powi(T, 1, y) = 1
|
|
22
22
|
/// - powi(T, -1, y) = -1 for y an odd integer
|
|
23
|
-
/// - powi(T, -1, y) = 1 unless T is i1,
|
|
23
|
+
/// - powi(T, -1, y) = 1 unless T is i1, u0
|
|
24
24
|
/// - powi(T, -1, y) = Overflow
|
|
25
25
|
/// - powi(T, x, y) = Overflow when y >= @bitSizeOf(x)
|
|
26
26
|
/// - powi(T, x, y) = Underflow when y < 0
|
|
@@ -189,7 +189,6 @@ test "powi.special" {
|
|
|
189
189
|
|
|
190
190
|
test "powi.narrow" {
|
|
191
191
|
try testing.expectError(error.Overflow, powi(u0, 0, 0));
|
|
192
|
-
try testing.expectError(error.Overflow, powi(i0, 0, 0));
|
|
193
192
|
try testing.expectError(error.Overflow, powi(i1, 0, 0));
|
|
194
193
|
try testing.expectError(error.Overflow, powi(i1, -1, 0));
|
|
195
194
|
try testing.expectError(error.Overflow, powi(i1, 0, -1));
|
package/std/math/signbit.zig
CHANGED
package/std/math.zig
CHANGED
|
@@ -58,6 +58,7 @@ pub const floatMax = float.floatMax;
|
|
|
58
58
|
pub const floatEps = float.floatEps;
|
|
59
59
|
pub const floatEpsAt = float.floatEpsAt;
|
|
60
60
|
pub const inf = float.inf;
|
|
61
|
+
pub const long_double = float.long_double;
|
|
61
62
|
pub const nan = float.nan;
|
|
62
63
|
pub const snan = float.snan;
|
|
63
64
|
|
|
@@ -1140,13 +1141,11 @@ test isPowerOfTwo {
|
|
|
1140
1141
|
pub fn ByteAlignedInt(comptime T: type) type {
|
|
1141
1142
|
const info = @typeInfo(T).int;
|
|
1142
1143
|
const bits = (info.bits + 7) / 8 * 8;
|
|
1143
|
-
|
|
1144
|
-
return extended_type;
|
|
1144
|
+
return @Int(info.signedness, bits);
|
|
1145
1145
|
}
|
|
1146
1146
|
|
|
1147
1147
|
test ByteAlignedInt {
|
|
1148
1148
|
try testing.expect(ByteAlignedInt(u0) == u0);
|
|
1149
|
-
try testing.expect(ByteAlignedInt(i0) == i0);
|
|
1150
1149
|
try testing.expect(ByteAlignedInt(u3) == u8);
|
|
1151
1150
|
try testing.expect(ByteAlignedInt(u8) == u8);
|
|
1152
1151
|
try testing.expect(ByteAlignedInt(i111) == i112);
|
|
@@ -1217,7 +1216,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(
|
|
|
1217
1216
|
comptime assert(@typeInfo(T) == .int);
|
|
1218
1217
|
comptime assert(@typeInfo(T).int.signedness == .unsigned);
|
|
1219
1218
|
assert(value != 0);
|
|
1220
|
-
const PromotedType =
|
|
1219
|
+
const PromotedType = @Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1);
|
|
1221
1220
|
const ShiftType = std.math.Log2Int(PromotedType);
|
|
1222
1221
|
return @as(PromotedType, 1) << @as(ShiftType, @intCast(@typeInfo(T).int.bits - @clz(value - 1)));
|
|
1223
1222
|
}
|
|
@@ -1229,7 +1228,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
|
|
|
1229
1228
|
comptime assert(@typeInfo(T) == .int);
|
|
1230
1229
|
const info = @typeInfo(T).int;
|
|
1231
1230
|
comptime assert(info.signedness == .unsigned);
|
|
1232
|
-
const PromotedType =
|
|
1231
|
+
const PromotedType = @Int(info.signedness, info.bits + 1);
|
|
1233
1232
|
const overflowBit = @as(PromotedType, 1) << info.bits;
|
|
1234
1233
|
const x = ceilPowerOfTwoPromote(T, value);
|
|
1235
1234
|
if (overflowBit & x != 0) {
|
|
@@ -1441,19 +1440,17 @@ test lerp {
|
|
|
1441
1440
|
|
|
1442
1441
|
/// Returns the maximum value of integer type T.
|
|
1443
1442
|
pub fn maxInt(comptime T: type) comptime_int {
|
|
1444
|
-
const info = @typeInfo(T);
|
|
1445
|
-
|
|
1446
|
-
if (bit_count == 0) return 0;
|
|
1447
|
-
return (1 << (bit_count - @intFromBool(info.int.signedness == .signed))) - 1;
|
|
1443
|
+
const info = @typeInfo(T).int;
|
|
1444
|
+
return (1 << (info.bits - @intFromBool(info.signedness == .signed))) - 1;
|
|
1448
1445
|
}
|
|
1449
1446
|
|
|
1450
1447
|
/// Returns the minimum value of integer type T.
|
|
1451
1448
|
pub fn minInt(comptime T: type) comptime_int {
|
|
1452
|
-
const info = @typeInfo(T);
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1449
|
+
const info = @typeInfo(T).int;
|
|
1450
|
+
return switch (info.signedness) {
|
|
1451
|
+
.unsigned => 0,
|
|
1452
|
+
.signed => -(1 << (info.bits - 1)),
|
|
1453
|
+
};
|
|
1457
1454
|
}
|
|
1458
1455
|
|
|
1459
1456
|
test maxInt {
|
|
@@ -1465,7 +1462,6 @@ test maxInt {
|
|
|
1465
1462
|
try testing.expect(maxInt(u64) == 18446744073709551615);
|
|
1466
1463
|
try testing.expect(maxInt(u128) == 340282366920938463463374607431768211455);
|
|
1467
1464
|
|
|
1468
|
-
try testing.expect(maxInt(i0) == 0);
|
|
1469
1465
|
try testing.expect(maxInt(i1) == 0);
|
|
1470
1466
|
try testing.expect(maxInt(i8) == 127);
|
|
1471
1467
|
try testing.expect(maxInt(i16) == 32767);
|
|
@@ -1485,7 +1481,6 @@ test minInt {
|
|
|
1485
1481
|
try testing.expect(minInt(u64) == 0);
|
|
1486
1482
|
try testing.expect(minInt(u128) == 0);
|
|
1487
1483
|
|
|
1488
|
-
try testing.expect(minInt(i0) == 0);
|
|
1489
1484
|
try testing.expect(minInt(i1) == -1);
|
|
1490
1485
|
try testing.expect(minInt(i8) == -128);
|
|
1491
1486
|
try testing.expect(minInt(i16) == -32768);
|
|
@@ -1709,8 +1704,8 @@ pub inline fn boolMask(comptime MaskInt: type, value: bool) MaskInt {
|
|
|
1709
1704
|
if (@typeInfo(MaskInt) != .int)
|
|
1710
1705
|
@compileError("boolMask requires an integer mask type.");
|
|
1711
1706
|
|
|
1712
|
-
if (MaskInt == u0
|
|
1713
|
-
@compileError("boolMask cannot convert to u0
|
|
1707
|
+
if (MaskInt == u0)
|
|
1708
|
+
@compileError("boolMask cannot convert to u0, it is too small.");
|
|
1714
1709
|
|
|
1715
1710
|
// The u1 and i1 cases tend to overflow,
|
|
1716
1711
|
// so we special case them here.
|
package/std/mem.zig
CHANGED
|
@@ -359,7 +359,10 @@ test zeroes {
|
|
|
359
359
|
var a = zeroes(C_struct);
|
|
360
360
|
|
|
361
361
|
// Extern structs should have padding zeroed out.
|
|
362
|
-
|
|
362
|
+
{
|
|
363
|
+
const num_bytes = @sizeOf(@TypeOf(a));
|
|
364
|
+
try testing.expectEqualSlices(u8, &@as([num_bytes]u8, @splat(0)), @ptrCast(&a));
|
|
365
|
+
}
|
|
363
366
|
|
|
364
367
|
a.y += 10;
|
|
365
368
|
|
|
@@ -370,7 +373,6 @@ test zeroes {
|
|
|
370
373
|
comptime comptime_field: u8 = 5,
|
|
371
374
|
|
|
372
375
|
integral_types: struct {
|
|
373
|
-
integer_0: i0,
|
|
374
376
|
integer_8: i8,
|
|
375
377
|
integer_16: i16,
|
|
376
378
|
integer_32: i32,
|
|
@@ -405,7 +407,6 @@ test zeroes {
|
|
|
405
407
|
|
|
406
408
|
const b = zeroes(ZigStruct);
|
|
407
409
|
try testing.expectEqual(@as(u8, 5), b.comptime_field);
|
|
408
|
-
try testing.expectEqual(@as(i8, 0), b.integral_types.integer_0);
|
|
409
410
|
try testing.expectEqual(@as(i8, 0), b.integral_types.integer_8);
|
|
410
411
|
try testing.expectEqual(@as(i16, 0), b.integral_types.integer_16);
|
|
411
412
|
try testing.expectEqual(@as(i32, 0), b.integral_types.integer_32);
|
|
@@ -1589,7 +1590,7 @@ test find {
|
|
|
1589
1590
|
test "find multibyte" {
|
|
1590
1591
|
{
|
|
1591
1592
|
// make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
|
|
1592
|
-
const haystack = [
|
|
1593
|
+
const haystack = @as([100]u16, @splat(0)) ++ [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff };
|
|
1593
1594
|
const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
|
|
1594
1595
|
try testing.expectEqual(findPos(u16, &haystack, 0, &needle), 100);
|
|
1595
1596
|
|
|
@@ -1602,7 +1603,7 @@ test "find multibyte" {
|
|
|
1602
1603
|
|
|
1603
1604
|
{
|
|
1604
1605
|
// make haystack and needle long enough to trigger Boyer-Moore-Horspool algorithm
|
|
1605
|
-
const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ [
|
|
1606
|
+
const haystack = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee, 0x00ff } ++ @as([100]u16, @splat(0));
|
|
1606
1607
|
const needle = [_]u16{ 0xbbaa, 0xccbb, 0xddcc, 0xeedd, 0xffee };
|
|
1607
1608
|
try testing.expectEqual(lastIndexOf(u16, &haystack, &needle), 0);
|
|
1608
1609
|
|
|
@@ -4647,7 +4648,7 @@ test "sliceAsBytes with sentinel slice" {
|
|
|
4647
4648
|
}
|
|
4648
4649
|
|
|
4649
4650
|
test "sliceAsBytes with zero-bit element type" {
|
|
4650
|
-
const lots_of_nothing
|
|
4651
|
+
const lots_of_nothing: [10_000]void = @splat({});
|
|
4651
4652
|
const bytes = sliceAsBytes(&lots_of_nothing);
|
|
4652
4653
|
try testing.expect(bytes.len == 0);
|
|
4653
4654
|
}
|
|
@@ -4865,8 +4866,8 @@ test doNotOptimizeAway {
|
|
|
4865
4866
|
doNotOptimizeAway(@as(u200, 0));
|
|
4866
4867
|
doNotOptimizeAway(@as(f32, 0.0));
|
|
4867
4868
|
doNotOptimizeAway(@as(f64, 0.0));
|
|
4868
|
-
doNotOptimizeAway([
|
|
4869
|
-
doNotOptimizeAway([
|
|
4869
|
+
doNotOptimizeAway(@as([4]u8, @splat(0)));
|
|
4870
|
+
doNotOptimizeAway(@as([100]u8, @splat(0)));
|
|
4870
4871
|
doNotOptimizeAway(@as(std.builtin.Endian, .little));
|
|
4871
4872
|
}
|
|
4872
4873
|
|
package/std/meta.zig
CHANGED
|
@@ -1067,7 +1067,7 @@ test hasUniqueRepresentation {
|
|
|
1067
1067
|
|
|
1068
1068
|
try testing.expect(!hasUniqueRepresentation(TestUnion4));
|
|
1069
1069
|
|
|
1070
|
-
inline for ([_]type{
|
|
1070
|
+
inline for ([_]type{ u8, i16, u32, i64 }) |T| {
|
|
1071
1071
|
try testing.expect(hasUniqueRepresentation(T));
|
|
1072
1072
|
try testing.expect(hasUniqueRepresentation(enum(T) { _ }));
|
|
1073
1073
|
}
|