@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
package/std/bit_set.zig
CHANGED
|
@@ -8,50 +8,55 @@
|
|
|
8
8
|
//!
|
|
9
9
|
//! There are five variants defined here:
|
|
10
10
|
//!
|
|
11
|
-
//!
|
|
11
|
+
//! Integer:
|
|
12
12
|
//! A bit set with static size, which is backed by a single integer.
|
|
13
13
|
//! This set is good for sets with a small size, but may generate
|
|
14
14
|
//! inefficient code for larger sets, especially in debug mode.
|
|
15
15
|
//!
|
|
16
|
-
//!
|
|
16
|
+
//! Array:
|
|
17
17
|
//! A bit set with static size, which is backed by an array of usize.
|
|
18
18
|
//! This set is good for sets with a larger size, but may use
|
|
19
19
|
//! more bytes than necessary if your set is small.
|
|
20
20
|
//!
|
|
21
|
-
//!
|
|
22
|
-
//! Picks either
|
|
21
|
+
//! Static:
|
|
22
|
+
//! Picks either Integer or Array depending on the requested
|
|
23
23
|
//! size. The interfaces of these two types match exactly, except for fields.
|
|
24
24
|
//!
|
|
25
|
-
//!
|
|
25
|
+
//! Dynamic:
|
|
26
26
|
//! A bit set with runtime-known size, backed by an allocated slice
|
|
27
27
|
//! of usize.
|
|
28
28
|
//!
|
|
29
|
-
//!
|
|
30
|
-
//! A variant of
|
|
31
|
-
//! allocator, in order to save space.
|
|
29
|
+
//! DynamicManaged:
|
|
30
|
+
//! A variant of Dynamic which stores an allocator, using it when needed.
|
|
32
31
|
|
|
33
32
|
const std = @import("std.zig");
|
|
34
33
|
const assert = std.debug.assert;
|
|
35
34
|
const Allocator = std.mem.Allocator;
|
|
36
35
|
const builtin = @import("builtin");
|
|
37
36
|
|
|
37
|
+
/// Deprecated: use `Static`.
|
|
38
|
+
pub const StaticBitSet = Static;
|
|
39
|
+
|
|
38
40
|
/// Returns the optimal static bit set type for the specified number
|
|
39
41
|
/// of elements: either `IntegerBitSet` or `ArrayBitSet`,
|
|
40
42
|
/// both of which fulfill the same interface.
|
|
41
43
|
/// The returned type will perform no allocations,
|
|
42
44
|
/// can be copied by value, and does not require deinitialization.
|
|
43
|
-
pub fn
|
|
45
|
+
pub fn Static(comptime size: usize) type {
|
|
44
46
|
if (size <= @bitSizeOf(usize)) {
|
|
45
|
-
return
|
|
47
|
+
return Integer(size);
|
|
46
48
|
} else {
|
|
47
|
-
return
|
|
49
|
+
return Array(usize, size);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
/// Deprecated: use `Integer`.
|
|
54
|
+
pub const IntegerBitSet = Integer;
|
|
55
|
+
|
|
51
56
|
/// A bit set with static size, which is backed by a single integer.
|
|
52
57
|
/// This set is good for sets with a small size, but may generate
|
|
53
58
|
/// inefficient code for larger sets, especially in debug mode.
|
|
54
|
-
pub fn
|
|
59
|
+
pub fn Integer(comptime size: u16) type {
|
|
55
60
|
return packed struct(MaskInt) {
|
|
56
61
|
const Self = @This();
|
|
57
62
|
|
|
@@ -328,21 +333,24 @@ pub fn IntegerBitSet(comptime size: u16) type {
|
|
|
328
333
|
};
|
|
329
334
|
}
|
|
330
335
|
|
|
336
|
+
/// Deprecated: use `Array`.
|
|
337
|
+
pub const ArrayBitSet = Array;
|
|
338
|
+
|
|
331
339
|
/// A bit set with static size, which is backed by an array of usize.
|
|
332
340
|
/// This set is good for sets with a larger size, but may use
|
|
333
341
|
/// more bytes than necessary if your set is small.
|
|
334
|
-
pub fn
|
|
342
|
+
pub fn Array(comptime MaskIntType: type, comptime size: usize) type {
|
|
335
343
|
const mask_info: std.builtin.Type = @typeInfo(MaskIntType);
|
|
336
344
|
|
|
337
345
|
// Make sure the mask int is indeed an int
|
|
338
|
-
if (mask_info != .int) @compileError("
|
|
346
|
+
if (mask_info != .int) @compileError("Array can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
|
|
339
347
|
|
|
340
348
|
// It must also be unsigned.
|
|
341
|
-
if (mask_info.int.signedness != .unsigned) @compileError("
|
|
349
|
+
if (mask_info.int.signedness != .unsigned) @compileError("Array requires an unsigned integer mask type, but was passed " ++ @typeName(MaskIntType));
|
|
342
350
|
|
|
343
351
|
// And it must not be empty.
|
|
344
352
|
if (MaskIntType == u0)
|
|
345
|
-
@compileError("
|
|
353
|
+
@compileError("Array requires a sized integer for its mask int. u0 does not work.");
|
|
346
354
|
|
|
347
355
|
const byte_size = std.mem.byte_size_in_bits;
|
|
348
356
|
|
|
@@ -352,7 +360,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
352
360
|
var desired_bits = std.math.ceilPowerOfTwoAssert(usize, @bitSizeOf(MaskIntType));
|
|
353
361
|
if (desired_bits < byte_size) desired_bits = byte_size;
|
|
354
362
|
const FixedMaskType = std.meta.Int(.unsigned, desired_bits);
|
|
355
|
-
@compileError("
|
|
363
|
+
@compileError("Array was passed integer type " ++ @typeName(MaskIntType) ++
|
|
356
364
|
", which is not a power of two. Please round this up to a power of two integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
|
|
357
365
|
}
|
|
358
366
|
|
|
@@ -363,7 +371,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
363
371
|
var desired_bits = @sizeOf(MaskIntType) * byte_size;
|
|
364
372
|
desired_bits = std.math.ceilPowerOfTwoAssert(usize, desired_bits);
|
|
365
373
|
const FixedMaskType = std.meta.Int(.unsigned, desired_bits);
|
|
366
|
-
@compileError("
|
|
374
|
+
@compileError("Array was passed integer type " ++ @typeName(MaskIntType) ++
|
|
367
375
|
", which contains padding bits. Please round this up to an unpadded integer size (i.e. " ++ @typeName(FixedMaskType) ++ ").");
|
|
368
376
|
}
|
|
369
377
|
|
|
@@ -398,24 +406,24 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
398
406
|
/// Deprecated: use `.empty`.
|
|
399
407
|
/// Creates a bit set with no elements present.
|
|
400
408
|
pub fn initEmpty() Self {
|
|
401
|
-
return .
|
|
409
|
+
return .empty;
|
|
402
410
|
}
|
|
403
411
|
|
|
404
412
|
/// Deprecated: use `.full`.
|
|
405
413
|
/// Creates a bit set with all elements present.
|
|
406
414
|
pub fn initFull() Self {
|
|
407
|
-
|
|
408
|
-
return .{ .masks = .{} };
|
|
409
|
-
} else {
|
|
410
|
-
return .{ .masks = [_]MaskInt{~@as(MaskInt, 0)} ** (num_masks - 1) ++ [_]MaskInt{last_item_mask} };
|
|
411
|
-
}
|
|
415
|
+
return .full;
|
|
412
416
|
}
|
|
413
417
|
|
|
414
418
|
/// A bit set with no elements present.
|
|
415
419
|
pub const empty: Self = .{ .masks = @splat(0) };
|
|
416
420
|
|
|
417
421
|
/// A bit set with all elements present.
|
|
418
|
-
pub const full: Self =
|
|
422
|
+
pub const full: Self = full: {
|
|
423
|
+
var masks: [num_masks]MaskInt = @splat(~@as(MaskInt, 0));
|
|
424
|
+
if (num_masks > 0) masks[num_masks - 1] = last_item_mask;
|
|
425
|
+
break :full .{ .masks = masks };
|
|
426
|
+
};
|
|
419
427
|
|
|
420
428
|
/// Returns the number of bits in this bit set
|
|
421
429
|
pub inline fn capacity(self: Self) usize {
|
|
@@ -673,7 +681,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
673
681
|
}
|
|
674
682
|
|
|
675
683
|
pub fn Iterator(comptime options: IteratorOptions) type {
|
|
676
|
-
return
|
|
684
|
+
return GenericIterator(MaskInt, options);
|
|
677
685
|
}
|
|
678
686
|
|
|
679
687
|
fn maskBit(index: usize) MaskInt {
|
|
@@ -688,9 +696,12 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
|
|
|
688
696
|
};
|
|
689
697
|
}
|
|
690
698
|
|
|
699
|
+
/// Deprecated: use `Dynamic`.
|
|
700
|
+
pub const DynamicBitSetUnmanaged = Dynamic;
|
|
701
|
+
|
|
691
702
|
/// A bit set with runtime-known size, backed by an allocated slice
|
|
692
703
|
/// of usize. The allocator must be tracked externally by the user.
|
|
693
|
-
pub const
|
|
704
|
+
pub const Dynamic = struct {
|
|
694
705
|
const Self = @This();
|
|
695
706
|
|
|
696
707
|
/// The integer type used to represent a mask in this bit set
|
|
@@ -1074,7 +1085,7 @@ pub const DynamicBitSetUnmanaged = struct {
|
|
|
1074
1085
|
}
|
|
1075
1086
|
|
|
1076
1087
|
pub fn Iterator(comptime options: IteratorOptions) type {
|
|
1077
|
-
return
|
|
1088
|
+
return GenericIterator(MaskInt, options);
|
|
1078
1089
|
}
|
|
1079
1090
|
|
|
1080
1091
|
fn maskBit(index: usize) MaskInt {
|
|
@@ -1091,10 +1102,16 @@ pub const DynamicBitSetUnmanaged = struct {
|
|
|
1091
1102
|
}
|
|
1092
1103
|
};
|
|
1093
1104
|
|
|
1105
|
+
/// Deprecated: use `DynamicManaged` or `Dynamic` (will need to update callsites).
|
|
1106
|
+
pub const DynamicBitSet = DynamicManaged;
|
|
1107
|
+
|
|
1094
1108
|
/// A bit set with runtime-known size, backed by an allocated slice
|
|
1095
|
-
/// of usize. Thin wrapper around
|
|
1109
|
+
/// of usize. Thin wrapper around Dynamic which keeps
|
|
1096
1110
|
/// track of the allocator instance.
|
|
1097
|
-
|
|
1111
|
+
///
|
|
1112
|
+
/// Deprecated in favor of `Dynamic` which accepts an `Allocator`
|
|
1113
|
+
/// as a parameter when needed instead of storing it.
|
|
1114
|
+
pub const DynamicManaged = struct {
|
|
1098
1115
|
const Self = @This();
|
|
1099
1116
|
|
|
1100
1117
|
/// The integer type used to represent a mask in this bit set
|
|
@@ -1104,12 +1121,12 @@ pub const DynamicBitSet = struct {
|
|
|
1104
1121
|
pub const ShiftInt = std.math.Log2Int(MaskInt);
|
|
1105
1122
|
|
|
1106
1123
|
allocator: Allocator,
|
|
1107
|
-
unmanaged:
|
|
1124
|
+
unmanaged: Dynamic = .{},
|
|
1108
1125
|
|
|
1109
1126
|
/// Creates a bit set with no elements present.
|
|
1110
1127
|
pub fn initEmpty(allocator: Allocator, bit_length: usize) !Self {
|
|
1111
1128
|
return Self{
|
|
1112
|
-
.unmanaged = try
|
|
1129
|
+
.unmanaged = try .initEmpty(allocator, bit_length),
|
|
1113
1130
|
.allocator = allocator,
|
|
1114
1131
|
};
|
|
1115
1132
|
}
|
|
@@ -1117,7 +1134,7 @@ pub const DynamicBitSet = struct {
|
|
|
1117
1134
|
/// Creates a bit set with all elements present.
|
|
1118
1135
|
pub fn initFull(allocator: Allocator, bit_length: usize) !Self {
|
|
1119
1136
|
return Self{
|
|
1120
|
-
.unmanaged = try
|
|
1137
|
+
.unmanaged = try .initFull(allocator, bit_length),
|
|
1121
1138
|
.allocator = allocator,
|
|
1122
1139
|
};
|
|
1123
1140
|
}
|
|
@@ -1247,7 +1264,7 @@ pub const DynamicBitSet = struct {
|
|
|
1247
1264
|
return self.unmanaged.iterator(options);
|
|
1248
1265
|
}
|
|
1249
1266
|
|
|
1250
|
-
pub const Iterator =
|
|
1267
|
+
pub const Iterator = Dynamic.Iterator;
|
|
1251
1268
|
};
|
|
1252
1269
|
|
|
1253
1270
|
/// Options for configuring an iterator over a bit set
|
|
@@ -1274,7 +1291,7 @@ pub const IteratorOptions = struct {
|
|
|
1274
1291
|
};
|
|
1275
1292
|
|
|
1276
1293
|
// The iterator is reusable between several bit set types
|
|
1277
|
-
fn
|
|
1294
|
+
fn GenericIterator(comptime MaskInt: type, comptime options: IteratorOptions) type {
|
|
1278
1295
|
const ShiftInt = std.math.Log2Int(MaskInt);
|
|
1279
1296
|
const kind = options.kind;
|
|
1280
1297
|
const direction = options.direction;
|
|
@@ -1713,37 +1730,37 @@ fn testStaticBitSet(comptime Set: type) !void {
|
|
|
1713
1730
|
try testPureBitSet(Set);
|
|
1714
1731
|
}
|
|
1715
1732
|
|
|
1716
|
-
test
|
|
1733
|
+
test Integer {
|
|
1717
1734
|
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
|
|
1718
1735
|
if (comptime builtin.cpu.has(.riscv, .v) and builtin.zig_backend == .stage2_llvm) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/24300
|
|
1719
1736
|
|
|
1720
|
-
try testStaticBitSet(
|
|
1721
|
-
try testStaticBitSet(
|
|
1722
|
-
try testStaticBitSet(
|
|
1723
|
-
try testStaticBitSet(
|
|
1724
|
-
try testStaticBitSet(
|
|
1725
|
-
try testStaticBitSet(
|
|
1726
|
-
try testStaticBitSet(
|
|
1727
|
-
try testStaticBitSet(
|
|
1737
|
+
try testStaticBitSet(Integer(0));
|
|
1738
|
+
try testStaticBitSet(Integer(1));
|
|
1739
|
+
try testStaticBitSet(Integer(2));
|
|
1740
|
+
try testStaticBitSet(Integer(5));
|
|
1741
|
+
try testStaticBitSet(Integer(8));
|
|
1742
|
+
try testStaticBitSet(Integer(32));
|
|
1743
|
+
try testStaticBitSet(Integer(64));
|
|
1744
|
+
try testStaticBitSet(Integer(127));
|
|
1728
1745
|
}
|
|
1729
1746
|
|
|
1730
|
-
test
|
|
1747
|
+
test Array {
|
|
1731
1748
|
inline for (.{ 0, 1, 2, 31, 32, 33, 63, 64, 65, 254, 500, 3000 }) |size| {
|
|
1732
|
-
try testStaticBitSet(
|
|
1733
|
-
try testStaticBitSet(
|
|
1734
|
-
try testStaticBitSet(
|
|
1735
|
-
try testStaticBitSet(
|
|
1736
|
-
try testStaticBitSet(
|
|
1749
|
+
try testStaticBitSet(Array(u8, size));
|
|
1750
|
+
try testStaticBitSet(Array(u16, size));
|
|
1751
|
+
try testStaticBitSet(Array(u32, size));
|
|
1752
|
+
try testStaticBitSet(Array(u64, size));
|
|
1753
|
+
try testStaticBitSet(Array(u128, size));
|
|
1737
1754
|
}
|
|
1738
1755
|
}
|
|
1739
1756
|
|
|
1740
|
-
test
|
|
1757
|
+
test Dynamic {
|
|
1741
1758
|
const allocator = std.testing.allocator;
|
|
1742
|
-
var a = try
|
|
1759
|
+
var a: Dynamic = try .initEmpty(allocator, 300);
|
|
1743
1760
|
try testing.expectEqual(@as(usize, 0), a.count());
|
|
1744
1761
|
a.deinit(allocator);
|
|
1745
1762
|
|
|
1746
|
-
a = try
|
|
1763
|
+
a = try .initEmpty(allocator, 0);
|
|
1747
1764
|
defer a.deinit(allocator);
|
|
1748
1765
|
for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {
|
|
1749
1766
|
const old_len = a.capacity();
|
|
@@ -1769,17 +1786,17 @@ test DynamicBitSetUnmanaged {
|
|
|
1769
1786
|
}
|
|
1770
1787
|
try testing.expectEqual(@as(usize, 0), empty.count());
|
|
1771
1788
|
|
|
1772
|
-
var full = try
|
|
1789
|
+
var full: Dynamic = try .initFull(allocator, size);
|
|
1773
1790
|
defer full.deinit(allocator);
|
|
1774
1791
|
try testing.expectEqual(@as(usize, size), full.count());
|
|
1775
1792
|
|
|
1776
1793
|
try testEql(empty, full, size);
|
|
1777
1794
|
{
|
|
1778
|
-
var even = try
|
|
1795
|
+
var even: Dynamic = try .initEmpty(allocator, size);
|
|
1779
1796
|
defer even.deinit(allocator);
|
|
1780
1797
|
fillEven(&even, size);
|
|
1781
1798
|
|
|
1782
|
-
var odd = try
|
|
1799
|
+
var odd: Dynamic = try .initEmpty(allocator, size);
|
|
1783
1800
|
defer odd.deinit(allocator);
|
|
1784
1801
|
fillOdd(&odd, size);
|
|
1785
1802
|
|
|
@@ -1790,13 +1807,13 @@ test DynamicBitSetUnmanaged {
|
|
|
1790
1807
|
}
|
|
1791
1808
|
}
|
|
1792
1809
|
|
|
1793
|
-
test
|
|
1810
|
+
test DynamicManaged {
|
|
1794
1811
|
const allocator = std.testing.allocator;
|
|
1795
|
-
var a = try
|
|
1812
|
+
var a: DynamicManaged = try .initEmpty(allocator, 300);
|
|
1796
1813
|
try testing.expectEqual(@as(usize, 0), a.count());
|
|
1797
1814
|
a.deinit();
|
|
1798
1815
|
|
|
1799
|
-
a = try
|
|
1816
|
+
a = try .initEmpty(allocator, 0);
|
|
1800
1817
|
defer a.deinit();
|
|
1801
1818
|
for ([_]usize{ 1, 2, 31, 32, 33, 0, 65, 64, 63, 500, 254, 3000 }) |size| {
|
|
1802
1819
|
const old_len = a.capacity();
|
|
@@ -1822,7 +1839,7 @@ test DynamicBitSet {
|
|
|
1822
1839
|
}
|
|
1823
1840
|
try testing.expectEqual(@as(usize, 0), tmp.count());
|
|
1824
1841
|
|
|
1825
|
-
var b = try
|
|
1842
|
+
var b: DynamicManaged = try .initFull(allocator, size);
|
|
1826
1843
|
defer b.deinit();
|
|
1827
1844
|
try testing.expectEqual(@as(usize, size), b.count());
|
|
1828
1845
|
|
|
@@ -1831,10 +1848,10 @@ test DynamicBitSet {
|
|
|
1831
1848
|
}
|
|
1832
1849
|
}
|
|
1833
1850
|
|
|
1834
|
-
test
|
|
1835
|
-
try testing.expectEqual(
|
|
1836
|
-
try testing.expectEqual(
|
|
1837
|
-
try testing.expectEqual(
|
|
1838
|
-
try testing.expectEqual(
|
|
1839
|
-
try testing.expectEqual(
|
|
1851
|
+
test Static {
|
|
1852
|
+
try testing.expectEqual(Integer(0), Static(0));
|
|
1853
|
+
try testing.expectEqual(Integer(5), Static(5));
|
|
1854
|
+
try testing.expectEqual(Integer(@bitSizeOf(usize)), Static(@bitSizeOf(usize)));
|
|
1855
|
+
try testing.expectEqual(Array(usize, @bitSizeOf(usize) + 1), Static(@bitSizeOf(usize) + 1));
|
|
1856
|
+
try testing.expectEqual(Array(usize, 500), Static(500));
|
|
1840
1857
|
}
|
package/std/c.zig
CHANGED
|
@@ -1664,12 +1664,12 @@ pub const MSF = switch (native_os) {
|
|
|
1664
1664
|
pub const ASYNC = 1;
|
|
1665
1665
|
pub const INVALIDATE = 2;
|
|
1666
1666
|
},
|
|
1667
|
-
.openbsd => struct {
|
|
1667
|
+
.openbsd, .haiku => struct {
|
|
1668
1668
|
pub const ASYNC = 1;
|
|
1669
1669
|
pub const SYNC = 2;
|
|
1670
1670
|
pub const INVALIDATE = 4;
|
|
1671
1671
|
},
|
|
1672
|
-
.
|
|
1672
|
+
.netbsd, .illumos => struct {
|
|
1673
1673
|
pub const ASYNC = 1;
|
|
1674
1674
|
pub const INVALIDATE = 2;
|
|
1675
1675
|
pub const SYNC = 4;
|
|
@@ -7914,7 +7914,7 @@ pub const pthread_spinlock_t = switch (native_os) {
|
|
|
7914
7914
|
|
|
7915
7915
|
pub const pthread_mutex_t = switch (native_os) {
|
|
7916
7916
|
.linux => extern struct {
|
|
7917
|
-
data: [data_len]u8 align(@alignOf(usize)) =
|
|
7917
|
+
data: [data_len]u8 align(@alignOf(usize)) = @splat(0),
|
|
7918
7918
|
|
|
7919
7919
|
const data_len = switch (native_abi) {
|
|
7920
7920
|
.musl, .musleabi, .musleabihf => if (@sizeOf(usize) == 8) 40 else 24,
|
|
@@ -7930,7 +7930,7 @@ pub const pthread_mutex_t = switch (native_os) {
|
|
|
7930
7930
|
},
|
|
7931
7931
|
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
|
|
7932
7932
|
sig: c_long = 0x32AAABA7,
|
|
7933
|
-
data: [data_len]u8 =
|
|
7933
|
+
data: [data_len]u8 = @splat(0),
|
|
7934
7934
|
|
|
7935
7935
|
const data_len = if (@sizeOf(usize) == 8) 56 else 40;
|
|
7936
7936
|
},
|
|
@@ -7966,10 +7966,10 @@ pub const pthread_mutex_t = switch (native_os) {
|
|
|
7966
7966
|
data: u64 = 0,
|
|
7967
7967
|
},
|
|
7968
7968
|
.fuchsia => extern struct {
|
|
7969
|
-
data: [40]u8 align(@alignOf(usize)) =
|
|
7969
|
+
data: [40]u8 align(@alignOf(usize)) = @splat(0),
|
|
7970
7970
|
},
|
|
7971
7971
|
.emscripten => extern struct {
|
|
7972
|
-
data: [24]u8 align(4) =
|
|
7972
|
+
data: [24]u8 align(4) = @splat(0),
|
|
7973
7973
|
},
|
|
7974
7974
|
// https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L68-L73
|
|
7975
7975
|
.serenity => extern struct {
|
|
@@ -7983,11 +7983,11 @@ pub const pthread_mutex_t = switch (native_os) {
|
|
|
7983
7983
|
|
|
7984
7984
|
pub const pthread_cond_t = switch (native_os) {
|
|
7985
7985
|
.linux => extern struct {
|
|
7986
|
-
data: [48]u8 align(@alignOf(usize)) =
|
|
7986
|
+
data: [48]u8 align(@alignOf(usize)) = @splat(0),
|
|
7987
7987
|
},
|
|
7988
7988
|
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
|
|
7989
7989
|
sig: c_long = 0x3CB0B1BB,
|
|
7990
|
-
data: [data_len]u8 =
|
|
7990
|
+
data: [data_len]u8 = @splat(0),
|
|
7991
7991
|
const data_len = if (@sizeOf(usize) == 8) 40 else 24;
|
|
7992
7992
|
},
|
|
7993
7993
|
.freebsd, .dragonfly, .openbsd => extern struct {
|
|
@@ -8012,13 +8012,13 @@ pub const pthread_cond_t = switch (native_os) {
|
|
|
8012
8012
|
lock: i32 = 0,
|
|
8013
8013
|
},
|
|
8014
8014
|
.illumos => extern struct {
|
|
8015
|
-
flag: [4]u8 =
|
|
8015
|
+
flag: [4]u8 = @splat(0),
|
|
8016
8016
|
type: u16 = 0,
|
|
8017
8017
|
magic: u16 = 0x4356,
|
|
8018
8018
|
data: u64 = 0,
|
|
8019
8019
|
},
|
|
8020
8020
|
.fuchsia, .emscripten => extern struct {
|
|
8021
|
-
data: [48]u8 align(@alignOf(usize)) =
|
|
8021
|
+
data: [48]u8 align(@alignOf(usize)) = @splat(0),
|
|
8022
8022
|
},
|
|
8023
8023
|
// https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L80-L84
|
|
8024
8024
|
.serenity => extern struct {
|
|
@@ -8033,20 +8033,20 @@ pub const pthread_rwlock_t = switch (native_os) {
|
|
|
8033
8033
|
.linux => switch (native_abi) {
|
|
8034
8034
|
.android, .androideabi => switch (@sizeOf(usize)) {
|
|
8035
8035
|
4 => extern struct {
|
|
8036
|
-
data: [40]u8 align(@alignOf(usize)) =
|
|
8036
|
+
data: [40]u8 align(@alignOf(usize)) = @splat(0),
|
|
8037
8037
|
},
|
|
8038
8038
|
8 => extern struct {
|
|
8039
|
-
data: [56]u8 align(@alignOf(usize)) =
|
|
8039
|
+
data: [56]u8 align(@alignOf(usize)) = @splat(0),
|
|
8040
8040
|
},
|
|
8041
8041
|
else => @compileError("impossible pointer size"),
|
|
8042
8042
|
},
|
|
8043
8043
|
else => extern struct {
|
|
8044
|
-
data: [56]u8 align(@alignOf(usize)) =
|
|
8044
|
+
data: [56]u8 align(@alignOf(usize)) = @splat(0),
|
|
8045
8045
|
},
|
|
8046
8046
|
},
|
|
8047
8047
|
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => extern struct {
|
|
8048
8048
|
sig: c_long = 0x2DA8B3B4,
|
|
8049
|
-
data: [192]u8 =
|
|
8049
|
+
data: [192]u8 = @splat(0),
|
|
8050
8050
|
},
|
|
8051
8051
|
.freebsd, .dragonfly, .openbsd => extern struct {
|
|
8052
8052
|
ptr: ?*anyopaque = null,
|
|
@@ -8079,10 +8079,10 @@ pub const pthread_rwlock_t = switch (native_os) {
|
|
|
8079
8079
|
writercv: pthread_cond_t = .{},
|
|
8080
8080
|
},
|
|
8081
8081
|
.fuchsia => extern struct {
|
|
8082
|
-
size: [56]u8 align(@alignOf(usize)) =
|
|
8082
|
+
size: [56]u8 align(@alignOf(usize)) = @splat(0),
|
|
8083
8083
|
},
|
|
8084
8084
|
.emscripten => extern struct {
|
|
8085
|
-
size: [32]u8 align(4) =
|
|
8085
|
+
size: [32]u8 align(4) = @splat(0),
|
|
8086
8086
|
},
|
|
8087
8087
|
// https://github.com/SerenityOS/serenity/blob/b98f537f117b341788023ab82e0c11ca9ae29a57/Kernel/API/POSIX/sys/types.h#L86
|
|
8088
8088
|
.serenity => extern struct {
|
|
@@ -8170,8 +8170,8 @@ pub const sem_t = switch (native_os) {
|
|
|
8170
8170
|
count: u32 = 0,
|
|
8171
8171
|
type: u16 = 0,
|
|
8172
8172
|
magic: u16 = 0x534d,
|
|
8173
|
-
__pad1: [3]u64 =
|
|
8174
|
-
__pad2: [2]u64 =
|
|
8173
|
+
__pad1: [3]u64 = @splat(0),
|
|
8174
|
+
__pad2: [2]u64 = @splat(0),
|
|
8175
8175
|
},
|
|
8176
8176
|
.openbsd, .netbsd, .dragonfly => ?*opaque {},
|
|
8177
8177
|
.haiku => extern struct {
|
|
@@ -8235,7 +8235,7 @@ pub const Kevent = switch (native_os) {
|
|
|
8235
8235
|
/// Opaque user data identifier.
|
|
8236
8236
|
udata: usize,
|
|
8237
8237
|
/// Future extensions.
|
|
8238
|
-
_ext: [4]u64 =
|
|
8238
|
+
_ext: [4]u64 = @splat(0),
|
|
8239
8239
|
},
|
|
8240
8240
|
.dragonfly => extern struct {
|
|
8241
8241
|
ident: usize,
|
|
@@ -723,7 +723,7 @@ fn HuffmanDecoder(
|
|
|
723
723
|
if (alphabet_size == 286)
|
|
724
724
|
if (lens[256] == 0) return error.MissingEndOfBlockCode;
|
|
725
725
|
|
|
726
|
-
var count
|
|
726
|
+
var count: [@as(usize, max_code_bits) + 1]u16 = @splat(0);
|
|
727
727
|
var max: usize = 0;
|
|
728
728
|
for (lens) |n| {
|
|
729
729
|
if (n == 0) continue;
|
|
@@ -41,7 +41,7 @@ pub const Curve25519 = struct {
|
|
|
41
41
|
|
|
42
42
|
/// Multiply a point by the cofactor, returning WeakPublicKey if the element is in a small-order group.
|
|
43
43
|
pub fn clearCofactor(p: Curve25519) WeakPublicKeyError!Curve25519 {
|
|
44
|
-
const cofactor = [_]u8{8} ++ [
|
|
44
|
+
const cofactor = [_]u8{8} ++ @as([31]u8, @splat(0));
|
|
45
45
|
return ladder(p, cofactor, 4) catch return error.WeakPublicKey;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -168,7 +168,7 @@ test "elligator2" {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
test "small order check" {
|
|
171
|
-
var s: [32]u8 = [_]u8{1} ++ [
|
|
171
|
+
var s: [32]u8 = [_]u8{1} ++ @as([31]u8, @splat(0));
|
|
172
172
|
const small_order_ss: [7][32]u8 = .{
|
|
173
173
|
.{
|
|
174
174
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 (order 4)
|
|
@@ -470,7 +470,7 @@ pub const Edwards25519 = struct {
|
|
|
470
470
|
st.final(&hctx);
|
|
471
471
|
xctx = hctx[0..];
|
|
472
472
|
}
|
|
473
|
-
const empty_block
|
|
473
|
+
const empty_block: [H.block_length]u8 = @splat(0);
|
|
474
474
|
var t = [3]u8{ 0, n * h_l, 0 };
|
|
475
475
|
var xctx_len_u8 = [1]u8{@as(u8, @intCast(xctx.len))};
|
|
476
476
|
var st = H.init(.{});
|
|
@@ -539,7 +539,7 @@ pub const Edwards25519 = struct {
|
|
|
539
539
|
const htest = @import("../test.zig");
|
|
540
540
|
|
|
541
541
|
test "packing/unpacking" {
|
|
542
|
-
const s = [
|
|
542
|
+
const s = [1]u8{170} ++ @as([31]u8, @splat(0));
|
|
543
543
|
var b = Edwards25519.basePoint;
|
|
544
544
|
const pk = try b.mul(s);
|
|
545
545
|
var buf: [128]u8 = undefined;
|
|
@@ -609,7 +609,7 @@ test "hash-to-curve operation" {
|
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
test "implicit reduction of invalid scalars" {
|
|
612
|
-
const s = [
|
|
612
|
+
const s = @as([31]u8, @splat(0)) ++ [1]u8{255};
|
|
613
613
|
const p1 = try Edwards25519.basePoint.mulPublic(s);
|
|
614
614
|
const p2 = try Edwards25519.basePoint.mul(s);
|
|
615
615
|
const p3 = try p1.mulPublic(s);
|
|
@@ -183,13 +183,13 @@ test "ristretto255" {
|
|
|
183
183
|
q = q.dbl().add(p);
|
|
184
184
|
try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&q.toBytes()}), "E882B131016B52C1D3337080187CF768423EFCCBB517BB495AB812C4160FF44E");
|
|
185
185
|
|
|
186
|
-
const s = [_]u8{15} ++ [
|
|
186
|
+
const s = [_]u8{15} ++ @as([31]u8, @splat(0));
|
|
187
187
|
const w = try p.mul(s);
|
|
188
188
|
try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&w.toBytes()}), "E0C418F7C8D9C4CDD7395B93EA124F3AD99021BB681DFC3302A9D99A2E53E64E");
|
|
189
189
|
|
|
190
190
|
try std.testing.expect(p.dbl().dbl().dbl().dbl().equivalent(w.add(p)));
|
|
191
191
|
|
|
192
|
-
const h = [
|
|
192
|
+
const h = @as([32]u8, @splat(69)) ++ @as([32]u8, @splat(42));
|
|
193
193
|
const ph = Ristretto255.fromUniform(h);
|
|
194
194
|
try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&ph.toBytes()}), "DCCA54E037A4311EFBEEF413ACD21D35276518970B7A61DC88F8587B493D5E19");
|
|
195
195
|
}
|
|
@@ -11,7 +11,7 @@ pub const field_order: u256 = 72370055773322622139731865630429942408571163593799
|
|
|
11
11
|
pub const CompressedScalar = [32]u8;
|
|
12
12
|
|
|
13
13
|
/// Zero
|
|
14
|
-
pub const zero
|
|
14
|
+
pub const zero: [32]u8 = @splat(0);
|
|
15
15
|
|
|
16
16
|
const field_order_s = s: {
|
|
17
17
|
var s: [32]u8 = undefined;
|
|
@@ -81,7 +81,7 @@ pub fn add(a: CompressedScalar, b: CompressedScalar) CompressedScalar {
|
|
|
81
81
|
|
|
82
82
|
/// Return -s (mod L)
|
|
83
83
|
pub fn neg(s: CompressedScalar) CompressedScalar {
|
|
84
|
-
const fs: [64]u8 = field_order_s ++ [
|
|
84
|
+
const fs: [64]u8 = field_order_s ++ @as([32]u8, @splat(0));
|
|
85
85
|
var sx: [64]u8 = undefined;
|
|
86
86
|
sx[0..32].* = s;
|
|
87
87
|
@memset(sx[32..], 0);
|
|
@@ -862,9 +862,9 @@ test "non-canonical scalar25519" {
|
|
|
862
862
|
}
|
|
863
863
|
|
|
864
864
|
test "mulAdd overflow check" {
|
|
865
|
-
const a: [32]u8 =
|
|
866
|
-
const b: [32]u8 =
|
|
867
|
-
const c: [32]u8 =
|
|
865
|
+
const a: [32]u8 = @splat(0xff);
|
|
866
|
+
const b: [32]u8 = @splat(0xff);
|
|
867
|
+
const c: [32]u8 = @splat(0xff);
|
|
868
868
|
const x = mulAdd(a, b, c);
|
|
869
869
|
var buf: [128]u8 = undefined;
|
|
870
870
|
try std.testing.expectEqualStrings(try std.fmt.bufPrint(&buf, "{X}", .{&x}), "D14DF91389432C25AD60FF9791B9FD1D67BEF517D273ECCE3D9A307C1B419903");
|
|
@@ -886,7 +886,7 @@ test "random scalar" {
|
|
|
886
886
|
}
|
|
887
887
|
|
|
888
888
|
test "64-bit reduction" {
|
|
889
|
-
const bytes = field_order_s ++ [
|
|
889
|
+
const bytes = field_order_s ++ @as([32]u8, @splat(0));
|
|
890
890
|
const x = Scalar.fromBytes64(bytes);
|
|
891
891
|
try std.testing.expect(x.isZero());
|
|
892
892
|
}
|
|
@@ -181,7 +181,7 @@ test "rfc7748 1,000,000 iterations" {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
test "edwards25519 -> curve25519 map" {
|
|
184
|
-
const ed_kp = try crypto.sign.Ed25519.KeyPair.generateDeterministic(
|
|
184
|
+
const ed_kp = try crypto.sign.Ed25519.KeyPair.generateDeterministic(@splat(0x42));
|
|
185
185
|
const mont_kp = try X25519.KeyPair.fromEd25519(ed_kp);
|
|
186
186
|
try htest.assertEqual("90e7595fc89e52fdfddce9c6a43d74dbf6047025ee0462d2d172e8b6a2841d6e", &mont_kp.secret_key);
|
|
187
187
|
try htest.assertEqual("cc4f2cdb695dd766f34118eb67b98652fed1d8bc49c330b119bbfa8a64989378", &mont_kp.public_key);
|
|
@@ -1092,7 +1092,7 @@ pub const rsa = struct {
|
|
|
1092
1092
|
}
|
|
1093
1093
|
var m_p_buf: [8 + Hash.digest_length + Hash.digest_length]u8 = undefined;
|
|
1094
1094
|
var m_p = m_p_buf[0 .. 8 + Hash.digest_length + sLen];
|
|
1095
|
-
std.mem.copyForwards(u8, m_p,
|
|
1095
|
+
std.mem.copyForwards(u8, m_p, @as(*const [8]u8, &@splat(0)));
|
|
1096
1096
|
std.mem.copyForwards(u8, m_p[8..], &mHash);
|
|
1097
1097
|
std.mem.copyForwards(u8, m_p[(8 + Hash.digest_length)..], salt);
|
|
1098
1098
|
|
package/std/crypto/Sha1.zig
CHANGED