@zigc/lib 0.17.0-dev.269 → 0.17.0-dev.292
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/compiler/aro/aro/CodeGen.zig +2 -2
- package/compiler/resinator/errors.zig +7 -7
- package/compiler_rt/addf3.zig +1 -1
- package/compiler_rt/comparef.zig +3 -3
- package/compiler_rt/count0bits.zig +1 -1
- package/compiler_rt/divdf3.zig +2 -2
- package/compiler_rt/divsf3.zig +1 -1
- package/compiler_rt/divtf3.zig +1 -1
- package/compiler_rt/divxf3.zig +1 -1
- package/compiler_rt/extendf.zig +5 -5
- package/compiler_rt/fabs.zig +1 -1
- package/compiler_rt/float_from_int.zig +3 -4
- package/compiler_rt/fmax.zig +1 -1
- package/compiler_rt/fmin.zig +1 -1
- package/compiler_rt/fmod.zig +2 -2
- package/compiler_rt/mulf3.zig +2 -2
- package/compiler_rt/truncf.zig +3 -3
- package/compiler_rt.zig +4 -4
- package/package.json +1 -1
- package/std/Build/Watch/FsEvents.zig +1 -1
- package/std/Build/abi.zig +1 -1
- package/std/Io/Dir.zig +2 -2
- package/std/Io/Dispatch.zig +2 -2
- package/std/Io/Threaded.zig +5 -5
- package/std/Io/Uring.zig +2 -2
- package/std/Io/Writer.zig +2 -2
- package/std/Random.zig +6 -6
- package/std/Target.zig +1 -1
- package/std/bit_set.zig +3 -3
- package/std/c.zig +7 -6
- package/std/compress/zstd/Decompress.zig +5 -5
- package/std/crypto/aes_ccm.zig +2 -2
- package/std/crypto/cmac.zig +1 -1
- package/std/crypto/codecs/asn1/der/Encoder.zig +1 -1
- package/std/crypto/ff.zig +2 -3
- package/std/crypto/keccak_p.zig +1 -1
- package/std/crypto/ml_dsa.zig +6 -6
- package/std/crypto/ml_kem.zig +6 -6
- package/std/crypto/modes.zig +1 -1
- package/std/crypto/pcurves/common.zig +4 -5
- package/std/crypto/timing_safe.zig +5 -5
- package/std/debug.zig +4 -1
- package/std/enums.zig +5 -5
- package/std/fmt/parse_float.zig +1 -1
- package/std/fmt.zig +1 -6
- package/std/hash/wyhash.zig +1 -1
- package/std/hash_map.zig +20 -1
- package/std/heap/debug_allocator.zig +1 -1
- package/std/{builtin.zig → lang.zig} +1 -1
- package/std/leb128.zig +2 -2
- package/std/math/big/int.zig +2 -2
- package/std/math/big.zig +4 -4
- package/std/math/copysign.zig +1 -1
- package/std/math/frexp.zig +4 -4
- package/std/math/ilogb.zig +1 -1
- package/std/math/isfinite.zig +1 -1
- package/std/math/isinf.zig +1 -1
- package/std/math/isnan.zig +1 -2
- package/std/math/isnormal.zig +2 -2
- package/std/math/iszero.zig +2 -2
- package/std/math/ldexp.zig +2 -2
- package/std/math/nextafter.zig +2 -2
- package/std/math/pow.zig +1 -1
- package/std/math.zig +8 -8
- package/std/mem/Allocator.zig +0 -6
- package/std/mem.zig +21 -21
- package/std/meta/trailer_flags.zig +1 -1
- package/std/meta.zig +3 -35
- package/std/os/emscripten.zig +4 -4
- package/std/os/linux/bpf.zig +6 -0
- package/std/os/linux/ioctl.zig +2 -2
- package/std/os/linux.zig +14 -12
- package/std/os/plan9.zig +1 -1
- package/std/os/uefi/tables/runtime_services.zig +1 -1
- package/std/posix.zig +1 -1
- package/std/process/Environ.zig +1 -1
- package/std/process.zig +2 -2
- package/std/std.zig +4 -1
- package/std/testing.zig +1 -1
- package/std/zig/Ast.zig +2 -2
- package/std/zig/AstGen.zig +37 -37
- package/std/zig/LibCInstallation.zig +3 -3
- package/std/zig/Zir.zig +15 -15
- package/std/zig/llvm/Builder.zig +16 -6
- package/std/zig/llvm/bitcode_writer.zig +3 -3
- package/std/zig/llvm/ir.zig +8 -8
- package/std/zig/target.zig +1 -3
- package/std/zig.zig +2 -2
- /package/std/{builtin → lang}/assembly.zig +0 -0
package/std/math/nextafter.zig
CHANGED
|
@@ -90,7 +90,7 @@ fn nextAfterFloat(comptime T: type, x: T, y: T) T {
|
|
|
90
90
|
|
|
91
91
|
return x_parts.toFloat();
|
|
92
92
|
} else {
|
|
93
|
-
const Bits =
|
|
93
|
+
const Bits = @Int(.unsigned, @bitSizeOf(T));
|
|
94
94
|
var x_bits: Bits = @bitCast(x);
|
|
95
95
|
if ((x > 0.0) == (y > x)) {
|
|
96
96
|
x_bits += 1;
|
|
@@ -320,6 +320,6 @@ test "float" {
|
|
|
320
320
|
/// Helps ensure that 0.0 doesn't compare equal to -0.0.
|
|
321
321
|
fn bitwiseEqual(comptime T: type, x: T, y: T) bool {
|
|
322
322
|
comptime assert(@typeInfo(T) == .float);
|
|
323
|
-
const Bits =
|
|
323
|
+
const Bits = @Int(.unsigned, @bitSizeOf(T));
|
|
324
324
|
return @as(Bits, @bitCast(x)) == @as(Bits, @bitCast(y));
|
|
325
325
|
}
|
package/std/math/pow.zig
CHANGED
|
@@ -147,7 +147,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
|
|
|
147
147
|
var xe = r2.exponent;
|
|
148
148
|
var x1 = r2.significand;
|
|
149
149
|
|
|
150
|
-
var i = @as(
|
|
150
|
+
var i = @as(@Int(.signed, @typeInfo(T).float.bits), @intFromFloat(yi));
|
|
151
151
|
while (i != 0) : (i >>= 1) {
|
|
152
152
|
const overflow_shift = math.floatExponentBits(T) + 1;
|
|
153
153
|
if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {
|
package/std/math.zig
CHANGED
|
@@ -779,7 +779,7 @@ pub fn Log2Int(comptime T: type) type {
|
|
|
779
779
|
if (T == comptime_int) return comptime_int;
|
|
780
780
|
const bits: u16 = @typeInfo(T).int.bits;
|
|
781
781
|
const log2_bits = 16 - @clz(bits - 1);
|
|
782
|
-
return
|
|
782
|
+
return @Int(.unsigned, log2_bits);
|
|
783
783
|
}
|
|
784
784
|
|
|
785
785
|
/// Returns an unsigned int type that can hold the number of bits in T.
|
|
@@ -788,7 +788,7 @@ pub fn Log2IntCeil(comptime T: type) type {
|
|
|
788
788
|
if (T == comptime_int) return comptime_int;
|
|
789
789
|
const bits: u16 = @typeInfo(T).int.bits;
|
|
790
790
|
const log2_bits = 16 - @clz(bits);
|
|
791
|
-
return
|
|
791
|
+
return @Int(.unsigned, log2_bits);
|
|
792
792
|
}
|
|
793
793
|
|
|
794
794
|
/// Returns the smallest integer type that can hold both from and to.
|
|
@@ -1048,10 +1048,10 @@ fn testRem() !void {
|
|
|
1048
1048
|
|
|
1049
1049
|
/// Returns the negation of the integer parameter.
|
|
1050
1050
|
/// Result is a signed integer.
|
|
1051
|
-
pub fn negateCast(x: anytype)
|
|
1051
|
+
pub fn negateCast(x: anytype) !@Int(.signed, @bitSizeOf(@TypeOf(x))) {
|
|
1052
1052
|
if (@typeInfo(@TypeOf(x)).int.signedness == .signed) return negate(x);
|
|
1053
1053
|
|
|
1054
|
-
const int =
|
|
1054
|
+
const int = @Int(.signed, @bitSizeOf(@TypeOf(x)));
|
|
1055
1055
|
if (x > -minInt(int)) return error.Overflow;
|
|
1056
1056
|
|
|
1057
1057
|
if (x == -minInt(int)) return minInt(int);
|
|
@@ -1177,7 +1177,7 @@ pub inline fn floor(value: anytype) @TypeOf(value) {
|
|
|
1177
1177
|
/// Returns the nearest power of two less than or equal to value, or
|
|
1178
1178
|
/// zero if value is less than or equal to zero.
|
|
1179
1179
|
pub fn floorPowerOfTwo(comptime T: type, value: T) T {
|
|
1180
|
-
const uT =
|
|
1180
|
+
const uT = @Int(.unsigned, @typeInfo(T).int.bits);
|
|
1181
1181
|
if (value <= 0) return 0;
|
|
1182
1182
|
return @as(T, 1) << log2_int(uT, @as(uT, @intCast(value)));
|
|
1183
1183
|
}
|
|
@@ -1212,7 +1212,7 @@ pub inline fn ceil(value: anytype) @TypeOf(value) {
|
|
|
1212
1212
|
/// Returns the next power of two (if the value is not already a power of two).
|
|
1213
1213
|
/// Only unsigned integers can be used. Zero is not an allowed input.
|
|
1214
1214
|
/// Result is a type with 1 more bit than the input type.
|
|
1215
|
-
pub fn ceilPowerOfTwoPromote(comptime T: type, value: T)
|
|
1215
|
+
pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) @Int(@typeInfo(T).int.signedness, @typeInfo(T).int.bits + 1) {
|
|
1216
1216
|
comptime assert(@typeInfo(T) == .int);
|
|
1217
1217
|
comptime assert(@typeInfo(T).int.signedness == .unsigned);
|
|
1218
1218
|
assert(value != 0);
|
|
@@ -1497,11 +1497,11 @@ test "max value type" {
|
|
|
1497
1497
|
|
|
1498
1498
|
/// Multiply a and b. Return type is wide enough to guarantee no
|
|
1499
1499
|
/// overflow.
|
|
1500
|
-
pub fn mulWide(comptime T: type, a: T, b: T)
|
|
1500
|
+
pub fn mulWide(comptime T: type, a: T, b: T) @Int(
|
|
1501
1501
|
@typeInfo(T).int.signedness,
|
|
1502
1502
|
@typeInfo(T).int.bits * 2,
|
|
1503
1503
|
) {
|
|
1504
|
-
const ResultInt =
|
|
1504
|
+
const ResultInt = @Int(
|
|
1505
1505
|
@typeInfo(T).int.signedness,
|
|
1506
1506
|
@typeInfo(T).int.bits * 2,
|
|
1507
1507
|
);
|
package/std/mem/Allocator.zig
CHANGED
|
@@ -456,12 +456,6 @@ pub fn dupe(allocator: Allocator, comptime T: type, m: []const T) Error![]T {
|
|
|
456
456
|
return new_buf;
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
/// Deprecated in favor of `dupeSentinel`
|
|
460
|
-
/// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory.
|
|
461
|
-
pub fn dupeZ(allocator: Allocator, comptime T: type, m: []const T) Error![:0]T {
|
|
462
|
-
return allocator.dupeSentinel(T, m, 0);
|
|
463
|
-
}
|
|
464
|
-
|
|
465
459
|
/// Copies `m` to newly allocated memory, with a null-terminated element. Caller owns the memory.
|
|
466
460
|
pub fn dupeSentinel(
|
|
467
461
|
allocator: Allocator,
|
package/std/mem.zig
CHANGED
|
@@ -1777,7 +1777,7 @@ pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian)
|
|
|
1777
1777
|
assert(@typeInfo(ReturnType).int.bits >= bytes.len * 8);
|
|
1778
1778
|
const bits = @typeInfo(ReturnType).int.bits;
|
|
1779
1779
|
const signedness = @typeInfo(ReturnType).int.signedness;
|
|
1780
|
-
const WorkType =
|
|
1780
|
+
const WorkType = @Int(signedness, @max(16, bits));
|
|
1781
1781
|
var result: WorkType = 0;
|
|
1782
1782
|
switch (endian) {
|
|
1783
1783
|
.big => {
|
|
@@ -1828,8 +1828,8 @@ pub fn readVarPackedInt(
|
|
|
1828
1828
|
endian: std.builtin.Endian,
|
|
1829
1829
|
signedness: std.builtin.Signedness,
|
|
1830
1830
|
) T {
|
|
1831
|
-
const uN =
|
|
1832
|
-
const iN =
|
|
1831
|
+
const uN = @Int(.unsigned, @bitSizeOf(T));
|
|
1832
|
+
const iN = @Int(.signed, @bitSizeOf(T));
|
|
1833
1833
|
const Log2N = std.math.Log2Int(T);
|
|
1834
1834
|
|
|
1835
1835
|
const read_size = (bit_count + (bit_offset % 8) + 7) / 8;
|
|
@@ -1921,7 +1921,7 @@ test readInt {
|
|
|
1921
1921
|
}
|
|
1922
1922
|
|
|
1923
1923
|
fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T {
|
|
1924
|
-
const uN =
|
|
1924
|
+
const uN = @Int(.unsigned, @bitSizeOf(T));
|
|
1925
1925
|
const Log2N = std.math.Log2Int(T);
|
|
1926
1926
|
|
|
1927
1927
|
const bit_count = @as(usize, @bitSizeOf(T));
|
|
@@ -1929,7 +1929,7 @@ fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T
|
|
|
1929
1929
|
|
|
1930
1930
|
const load_size = (bit_count + 7) / 8;
|
|
1931
1931
|
const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count));
|
|
1932
|
-
const LoadInt =
|
|
1932
|
+
const LoadInt = @Int(.unsigned, load_size * 8);
|
|
1933
1933
|
|
|
1934
1934
|
if (bit_count == 0)
|
|
1935
1935
|
return 0;
|
|
@@ -1947,7 +1947,7 @@ fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T
|
|
|
1947
1947
|
}
|
|
1948
1948
|
|
|
1949
1949
|
fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {
|
|
1950
|
-
const uN =
|
|
1950
|
+
const uN = @Int(.unsigned, @bitSizeOf(T));
|
|
1951
1951
|
const Log2N = std.math.Log2Int(T);
|
|
1952
1952
|
|
|
1953
1953
|
const bit_count = @as(usize, @bitSizeOf(T));
|
|
@@ -1956,7 +1956,7 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T {
|
|
|
1956
1956
|
|
|
1957
1957
|
const load_size = (bit_count + 7) / 8;
|
|
1958
1958
|
const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count));
|
|
1959
|
-
const LoadInt =
|
|
1959
|
+
const LoadInt = @Int(.unsigned, load_size * 8);
|
|
1960
1960
|
|
|
1961
1961
|
if (bit_count == 0)
|
|
1962
1962
|
return 0;
|
|
@@ -2061,7 +2061,7 @@ test writeInt {
|
|
|
2061
2061
|
}
|
|
2062
2062
|
|
|
2063
2063
|
fn writePackedIntLittle(comptime T: type, bytes: []u8, bit_offset: usize, value: T) void {
|
|
2064
|
-
const uN =
|
|
2064
|
+
const uN = @Int(.unsigned, @bitSizeOf(T));
|
|
2065
2065
|
const Log2N = std.math.Log2Int(T);
|
|
2066
2066
|
|
|
2067
2067
|
const bit_count = @as(usize, @bitSizeOf(T));
|
|
@@ -2069,7 +2069,7 @@ fn writePackedIntLittle(comptime T: type, bytes: []u8, bit_offset: usize, value:
|
|
|
2069
2069
|
|
|
2070
2070
|
const store_size = (@bitSizeOf(T) + 7) / 8;
|
|
2071
2071
|
const store_tail_bits = @as(u3, @intCast((store_size * 8) - bit_count));
|
|
2072
|
-
const StoreInt =
|
|
2072
|
+
const StoreInt = @Int(.unsigned, store_size * 8);
|
|
2073
2073
|
|
|
2074
2074
|
if (bit_count == 0)
|
|
2075
2075
|
return;
|
|
@@ -2094,7 +2094,7 @@ fn writePackedIntLittle(comptime T: type, bytes: []u8, bit_offset: usize, value:
|
|
|
2094
2094
|
}
|
|
2095
2095
|
|
|
2096
2096
|
fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T) void {
|
|
2097
|
-
const uN =
|
|
2097
|
+
const uN = @Int(.unsigned, @bitSizeOf(T));
|
|
2098
2098
|
const Log2N = std.math.Log2Int(T);
|
|
2099
2099
|
|
|
2100
2100
|
const bit_count = @as(usize, @bitSizeOf(T));
|
|
@@ -2103,7 +2103,7 @@ fn writePackedIntBig(comptime T: type, bytes: []u8, bit_offset: usize, value: T)
|
|
|
2103
2103
|
|
|
2104
2104
|
const store_size = (@bitSizeOf(T) + 7) / 8;
|
|
2105
2105
|
const store_tail_bits = @as(u3, @intCast((store_size * 8) - bit_count));
|
|
2106
|
-
const StoreInt =
|
|
2106
|
+
const StoreInt = @Int(.unsigned, store_size * 8);
|
|
2107
2107
|
|
|
2108
2108
|
if (bit_count == 0)
|
|
2109
2109
|
return;
|
|
@@ -2160,7 +2160,7 @@ test writePackedInt {
|
|
|
2160
2160
|
/// If negative, the written value is sign-extended.
|
|
2161
2161
|
pub fn writeVarPackedInt(bytes: []u8, bit_offset: usize, bit_count: usize, value: anytype, endian: std.builtin.Endian) void {
|
|
2162
2162
|
const T = @TypeOf(value);
|
|
2163
|
-
const uN =
|
|
2163
|
+
const uN = @Int(.unsigned, @bitSizeOf(T));
|
|
2164
2164
|
|
|
2165
2165
|
const bit_shift = @as(u3, @intCast(bit_offset % 8));
|
|
2166
2166
|
const write_size = (bit_count + bit_shift + 7) / 8;
|
|
@@ -2242,7 +2242,7 @@ pub fn byteSwapAllFieldsAligned(comptime S: type, comptime a: Alignment, ptr: *a
|
|
|
2242
2242
|
},
|
|
2243
2243
|
.bool => {},
|
|
2244
2244
|
.float => |float_info| {
|
|
2245
|
-
@field(ptr, f.name) = @bitCast(@byteSwap(@as(
|
|
2245
|
+
@field(ptr, f.name) = @bitCast(@byteSwap(@as(@Int(.unsigned, float_info.bits), @bitCast(@field(ptr, f.name)))));
|
|
2246
2246
|
},
|
|
2247
2247
|
else => {
|
|
2248
2248
|
@field(ptr, f.name) = @byteSwap(@field(ptr, f.name));
|
|
@@ -2262,7 +2262,7 @@ pub fn byteSwapAllFieldsAligned(comptime S: type, comptime a: Alignment, ptr: *a
|
|
|
2262
2262
|
}
|
|
2263
2263
|
}
|
|
2264
2264
|
|
|
2265
|
-
const BackingInt =
|
|
2265
|
+
const BackingInt = @Int(.unsigned, @bitSizeOf(S));
|
|
2266
2266
|
ptr.* = @bitCast(@byteSwap(@as(BackingInt, @bitCast(ptr.*))));
|
|
2267
2267
|
},
|
|
2268
2268
|
.array => |info| {
|
|
@@ -2370,7 +2370,7 @@ pub fn byteSwapAllElements(comptime Elem: type, slice: []Elem) void {
|
|
|
2370
2370
|
},
|
|
2371
2371
|
.bool => {},
|
|
2372
2372
|
.float => |float_info| {
|
|
2373
|
-
elem.* = @bitCast(@byteSwap(@as(
|
|
2373
|
+
elem.* = @bitCast(@byteSwap(@as(@Int(.unsigned, float_info.bits), @bitCast(elem.*))));
|
|
2374
2374
|
},
|
|
2375
2375
|
else => {
|
|
2376
2376
|
elem.* = @byteSwap(elem.*);
|
|
@@ -4800,7 +4800,7 @@ pub fn doNotOptimizeAway(val: anytype) void {
|
|
|
4800
4800
|
const bits = t.int.bits;
|
|
4801
4801
|
if (bits <= max_gp_register_bits and builtin.zig_backend != .stage2_c) {
|
|
4802
4802
|
const val2 = @as(
|
|
4803
|
-
|
|
4803
|
+
@Int(t.int.signedness, @max(8, std.math.ceilPowerOfTwoAssert(u16, bits))),
|
|
4804
4804
|
val,
|
|
4805
4805
|
);
|
|
4806
4806
|
asm volatile (""
|
|
@@ -4964,7 +4964,7 @@ test isAligned {
|
|
|
4964
4964
|
}
|
|
4965
4965
|
|
|
4966
4966
|
test "freeing empty string with null-terminated sentinel" {
|
|
4967
|
-
const empty_string = try testing.allocator.
|
|
4967
|
+
const empty_string = try testing.allocator.dupeSentinel(u8, "", 0);
|
|
4968
4968
|
testing.allocator.free(empty_string);
|
|
4969
4969
|
}
|
|
4970
4970
|
|
|
@@ -5035,8 +5035,8 @@ test "read/write(Var)PackedInt" {
|
|
|
5035
5035
|
if (@bitSizeOf(PackedType) > @bitSizeOf(BackingType))
|
|
5036
5036
|
continue;
|
|
5037
5037
|
|
|
5038
|
-
const iPackedType =
|
|
5039
|
-
const uPackedType =
|
|
5038
|
+
const iPackedType = @Int(.signed, @bitSizeOf(PackedType));
|
|
5039
|
+
const uPackedType = @Int(.unsigned, @bitSizeOf(PackedType));
|
|
5040
5040
|
const Log2T = std.math.Log2Int(BackingType);
|
|
5041
5041
|
|
|
5042
5042
|
const offset_at_end = @bitSizeOf(BackingType) - @bitSizeOf(PackedType);
|
|
@@ -5103,8 +5103,8 @@ test "read/write(Var)PackedInt" {
|
|
|
5103
5103
|
}
|
|
5104
5104
|
|
|
5105
5105
|
const signedness = @typeInfo(PackedType).int.signedness;
|
|
5106
|
-
const NextPowerOfTwoInt =
|
|
5107
|
-
const ui64 =
|
|
5106
|
+
const NextPowerOfTwoInt = @Int(signedness, try std.math.ceilPowerOfTwo(u16, @bitSizeOf(PackedType)));
|
|
5107
|
+
const ui64 = @Int(signedness, 64);
|
|
5108
5108
|
inline for ([_]type{ PackedType, NextPowerOfTwoInt, ui64 }) |U| {
|
|
5109
5109
|
{ // Variable-size Read/Write (Native-endian)
|
|
5110
5110
|
|
|
@@ -13,7 +13,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
|
|
|
13
13
|
return struct {
|
|
14
14
|
bits: Int,
|
|
15
15
|
|
|
16
|
-
pub const Int =
|
|
16
|
+
pub const Int = @Int(.unsigned, bit_count);
|
|
17
17
|
pub const bit_count = @typeInfo(Fields).@"struct".fields.len;
|
|
18
18
|
|
|
19
19
|
pub const FieldEnum = std.meta.FieldEnum(Fields);
|
package/std/meta.zig
CHANGED
|
@@ -751,11 +751,6 @@ pub fn fieldIndex(comptime T: type, comptime name: []const u8) ?comptime_int {
|
|
|
751
751
|
return null;
|
|
752
752
|
}
|
|
753
753
|
|
|
754
|
-
/// Deprecated: use @Int
|
|
755
|
-
pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type {
|
|
756
|
-
return @Int(signedness, bit_count);
|
|
757
|
-
}
|
|
758
|
-
|
|
759
754
|
pub fn Float(comptime bit_count: u8) type {
|
|
760
755
|
return switch (bit_count) {
|
|
761
756
|
16 => f16,
|
|
@@ -796,14 +791,7 @@ pub fn ArgsTuple(comptime Function: type) type {
|
|
|
796
791
|
argument_field_list[i] = T;
|
|
797
792
|
}
|
|
798
793
|
|
|
799
|
-
return Tuple(&argument_field_list);
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
/// Deprecated; use `@Tuple` instead.
|
|
803
|
-
///
|
|
804
|
-
/// To be removed after Zig 0.16.0 releases.
|
|
805
|
-
pub fn Tuple(comptime types: []const type) type {
|
|
806
|
-
return @Tuple(types);
|
|
794
|
+
return @Tuple(&argument_field_list);
|
|
807
795
|
}
|
|
808
796
|
|
|
809
797
|
const TupleTester = struct {
|
|
@@ -839,33 +827,13 @@ test ArgsTuple {
|
|
|
839
827
|
TupleTester.assertTuple(.{u32}, ArgsTuple(fn (comptime a: u32) []const u8));
|
|
840
828
|
}
|
|
841
829
|
|
|
842
|
-
test Tuple {
|
|
843
|
-
TupleTester.assertTuple(.{}, Tuple(&[_]type{}));
|
|
844
|
-
TupleTester.assertTuple(.{u32}, Tuple(&[_]type{u32}));
|
|
845
|
-
TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 }));
|
|
846
|
-
TupleTester.assertTuple(.{ u32, f16, []const u8, void }, Tuple(&[_]type{ u32, f16, []const u8, void }));
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
test "Tuple deduplication" {
|
|
850
|
-
const T1 = std.meta.Tuple(&.{ u32, f32, i8 });
|
|
851
|
-
const T2 = std.meta.Tuple(&.{ u32, f32, i8 });
|
|
852
|
-
const T3 = std.meta.Tuple(&.{ u32, f32, i7 });
|
|
853
|
-
|
|
854
|
-
if (T1 != T2) {
|
|
855
|
-
@compileError("std.meta.Tuple doesn't deduplicate tuple types.");
|
|
856
|
-
}
|
|
857
|
-
if (T1 == T3) {
|
|
858
|
-
@compileError("std.meta.Tuple fails to generate different types.");
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
|
|
862
830
|
test "ArgsTuple forwarding" {
|
|
863
|
-
const T1 =
|
|
831
|
+
const T1 = @Tuple(&.{ u32, f32, i8 });
|
|
864
832
|
const T2 = std.meta.ArgsTuple(fn (u32, f32, i8) void);
|
|
865
833
|
const T3 = std.meta.ArgsTuple(fn (u32, f32, i8) callconv(.c) noreturn);
|
|
866
834
|
|
|
867
835
|
if (T1 != T2) {
|
|
868
|
-
@compileError("std.meta.ArgsTuple produces different types than
|
|
836
|
+
@compileError("std.meta.ArgsTuple produces different types than @Tuple");
|
|
869
837
|
}
|
|
870
838
|
if (T1 != T3) {
|
|
871
839
|
@compileError("std.meta.ArgsTuple produces different types for the same argument lists.");
|
package/std/os/emscripten.zig
CHANGED
|
@@ -17,7 +17,7 @@ pub const CLOCK = linux.CLOCK;
|
|
|
17
17
|
|
|
18
18
|
pub const CPU_SETSIZE = 128;
|
|
19
19
|
pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
|
|
20
|
-
pub const cpu_count_t =
|
|
20
|
+
pub const cpu_count_t = @Int(.unsigned, std.math.log2(CPU_SETSIZE * 8));
|
|
21
21
|
|
|
22
22
|
pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
|
|
23
23
|
var sum: cpu_count_t = 0;
|
|
@@ -467,8 +467,8 @@ pub const SHUT = struct {
|
|
|
467
467
|
pub const SIG = linux.SIG;
|
|
468
468
|
|
|
469
469
|
pub const Sigaction = extern struct {
|
|
470
|
-
pub const handler_fn = *align(1) const fn (
|
|
471
|
-
pub const sigaction_fn = *const fn (
|
|
470
|
+
pub const handler_fn = *align(1) const fn (SIG) callconv(.c) void;
|
|
471
|
+
pub const sigaction_fn = *const fn (SIG, *const siginfo_t, ?*anyopaque) callconv(.c) void;
|
|
472
472
|
|
|
473
473
|
handler: extern union {
|
|
474
474
|
handler: ?handler_fn,
|
|
@@ -484,7 +484,7 @@ pub fn sigemptyset() sigset_t {
|
|
|
484
484
|
return @splat(0);
|
|
485
485
|
}
|
|
486
486
|
pub const siginfo_t = extern struct {
|
|
487
|
-
signo:
|
|
487
|
+
signo: SIG,
|
|
488
488
|
errno: i32,
|
|
489
489
|
code: i32,
|
|
490
490
|
fields: siginfo_fields_union,
|
package/std/os/linux/bpf.zig
CHANGED
|
@@ -58,6 +58,12 @@ pub const JGT = 0x20;
|
|
|
58
58
|
pub const JGE = 0x30;
|
|
59
59
|
pub const JSET = 0x40;
|
|
60
60
|
|
|
61
|
+
// misc fields
|
|
62
|
+
/// copy A into X
|
|
63
|
+
pub const TAX = 0x00;
|
|
64
|
+
/// copy X into A
|
|
65
|
+
pub const TXA = 0x80;
|
|
66
|
+
|
|
61
67
|
//#define BPF_SRC(code) ((code) & 0x08)
|
|
62
68
|
pub const K = 0x00;
|
|
63
69
|
pub const X = 0x08;
|
package/std/os/linux/ioctl.zig
CHANGED
|
@@ -15,12 +15,12 @@ const bits = switch (@import("builtin").cpu.arch) {
|
|
|
15
15
|
else => .{ .size = 14, .dir = 2, .none = 0, .read = 2, .write = 1 },
|
|
16
16
|
};
|
|
17
17
|
|
|
18
|
-
const Direction =
|
|
18
|
+
const Direction = @Int(.unsigned, bits.dir);
|
|
19
19
|
|
|
20
20
|
pub const Request = packed struct {
|
|
21
21
|
nr: u8,
|
|
22
22
|
io_type: u8,
|
|
23
|
-
size:
|
|
23
|
+
size: @Int(.unsigned, bits.size),
|
|
24
24
|
dir: Direction,
|
|
25
25
|
};
|
|
26
26
|
|
package/std/os/linux.zig
CHANGED
|
@@ -1256,21 +1256,23 @@ pub fn munlockall() usize {
|
|
|
1256
1256
|
}
|
|
1257
1257
|
|
|
1258
1258
|
pub fn poll(fds: [*]pollfd, n: nfds_t, timeout: i32) usize {
|
|
1259
|
-
|
|
1260
|
-
return syscall3(.poll, @intFromPtr(fds), n, @as(u32, @bitCast(timeout)))
|
|
1261
|
-
else
|
|
1262
|
-
|
|
1259
|
+
if (@hasField(SYS, "poll")) {
|
|
1260
|
+
return syscall3(.poll, @intFromPtr(fds), n, @as(u32, @bitCast(timeout)));
|
|
1261
|
+
} else {
|
|
1262
|
+
var ts: timespec = if (timeout >= 0)
|
|
1263
|
+
.{
|
|
1264
|
+
.sec = @divTrunc(timeout, 1000),
|
|
1265
|
+
.nsec = @rem(timeout, 1000) * 1000000,
|
|
1266
|
+
}
|
|
1267
|
+
else
|
|
1268
|
+
undefined;
|
|
1269
|
+
return ppoll(
|
|
1263
1270
|
fds,
|
|
1264
1271
|
n,
|
|
1265
|
-
if (timeout >= 0)
|
|
1266
|
-
@constCast(×pec{
|
|
1267
|
-
.sec = @divTrunc(timeout, 1000),
|
|
1268
|
-
.nsec = @rem(timeout, 1000) * 1000000,
|
|
1269
|
-
})
|
|
1270
|
-
else
|
|
1271
|
-
null,
|
|
1272
|
+
if (timeout >= 0) &ts else null,
|
|
1272
1273
|
null,
|
|
1273
1274
|
);
|
|
1275
|
+
}
|
|
1274
1276
|
}
|
|
1275
1277
|
|
|
1276
1278
|
pub fn ppoll(fds: [*]pollfd, n: nfds_t, timeout: ?*timespec, sigmask: ?*const sigset_t) usize {
|
|
@@ -6291,7 +6293,7 @@ pub const dl_phdr_info = extern struct {
|
|
|
6291
6293
|
|
|
6292
6294
|
pub const CPU_SETSIZE = 128;
|
|
6293
6295
|
pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
|
|
6294
|
-
pub const cpu_count_t =
|
|
6296
|
+
pub const cpu_count_t = @Int(.unsigned, std.math.log2(CPU_SETSIZE * 8));
|
|
6295
6297
|
|
|
6296
6298
|
pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
|
|
6297
6299
|
var sum: cpu_count_t = 0;
|
package/std/os/plan9.zig
CHANGED
|
@@ -299,7 +299,7 @@ pub fn openat(dirfd: i32, path: [*:0]const u8, flags: u32, _: mode_t) usize {
|
|
|
299
299
|
const dir_path = std.mem.span(@as([*:0]u8, @ptrCast(&dir_path_buf)));
|
|
300
300
|
const total_path = std.fs.path.join(alloc, &.{ dir_path, std.mem.span(path) }) catch unreachable; // the allocation shouldn't fail because it should not exceed max_path_bytes
|
|
301
301
|
fba.reset();
|
|
302
|
-
const total_path_z = alloc.
|
|
302
|
+
const total_path_z = alloc.dupeSentinel(u8, total_path, 0) catch unreachable; // should not exceed max_path_bytes + 1
|
|
303
303
|
return open(total_path_z.ptr, flags);
|
|
304
304
|
}
|
|
305
305
|
|
|
@@ -419,7 +419,7 @@ pub const RuntimeServices = extern struct {
|
|
|
419
419
|
pub const DebugDisposition = enum(usize) {
|
|
420
420
|
const Bits = packed struct(usize) {
|
|
421
421
|
optional_ptr: bool = false,
|
|
422
|
-
_pad:
|
|
422
|
+
_pad: @Int(.unsigned, @bitSizeOf(usize) - 1) = 0,
|
|
423
423
|
};
|
|
424
424
|
|
|
425
425
|
pointer = @bitCast(Bits{}),
|
package/std/posix.zig
CHANGED
|
@@ -803,7 +803,7 @@ pub fn dl_iterate_phdr(
|
|
|
803
803
|
}
|
|
804
804
|
}.callbackC, @ptrCast(@constCast(&context)))) {
|
|
805
805
|
0 => return,
|
|
806
|
-
else => |err| return @as(Error, @errorCast(@errorFromInt(@as(
|
|
806
|
+
else => |err| return @as(Error, @errorCast(@errorFromInt(@as(@Int(.unsigned, @bitSizeOf(anyerror)), @intCast(err))))),
|
|
807
807
|
}
|
|
808
808
|
}
|
|
809
809
|
|
package/std/process/Environ.zig
CHANGED
package/std/process.zig
CHANGED
|
@@ -86,7 +86,7 @@ pub fn currentPathAlloc(io: Io, allocator: Allocator) CurrentPathAllocError![:0]
|
|
|
86
86
|
error.NameTooLong => unreachable,
|
|
87
87
|
else => |e| return e,
|
|
88
88
|
};
|
|
89
|
-
return allocator.
|
|
89
|
+
return allocator.dupeSentinel(u8, buffer[0..n], 0);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
test currentPathAlloc {
|
|
@@ -735,7 +735,7 @@ pub fn executablePathAlloc(io: Io, allocator: Allocator) ExecutablePathAllocErro
|
|
|
735
735
|
error.NameTooLong => unreachable,
|
|
736
736
|
else => |e| return e,
|
|
737
737
|
};
|
|
738
|
-
return allocator.
|
|
738
|
+
return allocator.dupeSentinel(u8, buffer[0..n], 0);
|
|
739
739
|
}
|
|
740
740
|
|
|
741
741
|
pub const ExecutablePathError = ExecutablePathBaseError || error{NameTooLong};
|
package/std/std.zig
CHANGED
|
@@ -65,8 +65,11 @@ pub const array_hash_map = @import("array_hash_map.zig");
|
|
|
65
65
|
pub const atomic = @import("atomic.zig");
|
|
66
66
|
pub const base64 = @import("base64.zig");
|
|
67
67
|
pub const bit_set = @import("bit_set.zig");
|
|
68
|
+
/// Deprecated; use `lang`.
|
|
69
|
+
///
|
|
70
|
+
/// To be removed after Zig 0.17.0.
|
|
68
71
|
pub const builtin = lang;
|
|
69
|
-
pub const lang = @import("
|
|
72
|
+
pub const lang = @import("lang.zig");
|
|
70
73
|
pub const c = @import("c.zig");
|
|
71
74
|
pub const coff = @import("coff.zig");
|
|
72
75
|
pub const compress = @import("compress.zig");
|
package/std/testing.zig
CHANGED
|
@@ -163,7 +163,7 @@ fn expectEqualInner(comptime T: type, expected: T, actual: T) !void {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
const BackingInt =
|
|
166
|
+
const BackingInt = @Int(.unsigned, @bitSizeOf(T));
|
|
167
167
|
return expectEqual(
|
|
168
168
|
@as(BackingInt, @bitCast(expected)),
|
|
169
169
|
@as(BackingInt, @bitCast(actual)),
|
package/std/zig/Ast.zig
CHANGED
|
@@ -2103,7 +2103,7 @@ fn fullFnProtoComponents(tree: Ast, info: full.FnProto.Components) full.FnProto
|
|
|
2103
2103
|
}
|
|
2104
2104
|
|
|
2105
2105
|
fn fullPtrTypeComponents(tree: Ast, info: full.PtrType.Components) full.PtrType {
|
|
2106
|
-
const size: std.
|
|
2106
|
+
const size: std.lang.Type.Pointer.Size = switch (tree.tokenTag(info.main_token)) {
|
|
2107
2107
|
.asterisk => .one,
|
|
2108
2108
|
.l_bracket => switch (tree.tokenTag(info.main_token + 1)) {
|
|
2109
2109
|
.asterisk => if (tree.tokenTag(info.main_token + 2) == .identifier) .c else .many,
|
|
@@ -2726,7 +2726,7 @@ pub const full = struct {
|
|
|
2726
2726
|
};
|
|
2727
2727
|
|
|
2728
2728
|
pub const PtrType = struct {
|
|
2729
|
-
size: std.
|
|
2729
|
+
size: std.lang.Type.Pointer.Size,
|
|
2730
2730
|
allowzero_token: ?TokenIndex,
|
|
2731
2731
|
const_token: ?TokenIndex,
|
|
2732
2732
|
volatile_token: ?TokenIndex,
|