diff --git a/lib/std/child_process.zig b/lib/std/child_process.zig index 1bd0becfd0..12b76143ee 100644 --- a/lib/std/child_process.zig +++ b/lib/std/child_process.zig @@ -830,7 +830,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn { os.exit(1); } -const ErrInt = std.meta.IntType(false, @sizeOf(anyerror) * 8); +const ErrInt = std.meta.Int(false, @sizeOf(anyerror) * 8); fn writeIntFd(fd: i32, value: ErrInt) !void { const file = File{ diff --git a/lib/std/debug/leb128.zig b/lib/std/debug/leb128.zig index e2157335b5..ac278c4b1f 100644 --- a/lib/std/debug/leb128.zig +++ b/lib/std/debug/leb128.zig @@ -2,7 +2,7 @@ const std = @import("std"); const testing = std.testing; pub fn readULEB128(comptime T: type, in_stream: var) !T { - const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); + const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count)); var result: T = 0; var shift: usize = 0; @@ -27,7 +27,7 @@ pub fn readULEB128(comptime T: type, in_stream: var) !T { } pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T { - const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); + const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count)); var result: T = 0; var shift: usize = 0; @@ -55,8 +55,8 @@ pub fn readULEB128Mem(comptime T: type, ptr: *[*]const u8) !T { } pub fn readILEB128(comptime T: type, in_stream: var) !T { - const UT = std.meta.IntType(false, T.bit_count); - const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); + const UT = std.meta.Int(false, T.bit_count); + const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count)); var result: UT = 0; var shift: usize = 0; @@ -87,8 +87,8 @@ pub fn readILEB128(comptime T: type, in_stream: var) !T { } pub fn readILEB128Mem(comptime T: type, ptr: *[*]const u8) !T { - const UT = std.meta.IntType(false, T.bit_count); - const ShiftT = std.meta.IntType(false, std.math.log2(T.bit_count)); + const UT = std.meta.Int(false, T.bit_count); + const ShiftT = std.meta.Int(false, std.math.log2(T.bit_count)); var result: UT = 0; var shift: usize = 0; diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 242b668ef7..107b50e123 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -906,7 +906,7 @@ fn formatIntSigned( .fill = options.fill, }; const bit_count = @typeInfo(@TypeOf(value)).Int.bits; - const Uint = std.meta.IntType(false, bit_count); + const Uint = std.meta.Int(false, bit_count); if (value < 0) { try out_stream.writeAll("-"); const new_value = math.absCast(value); @@ -930,7 +930,7 @@ fn formatIntUnsigned( assert(base >= 2); var buf: [math.max(@TypeOf(value).bit_count, 1)]u8 = undefined; const min_int_bits = comptime math.max(@TypeOf(value).bit_count, @TypeOf(base).bit_count); - const MinInt = std.meta.IntType(@TypeOf(value).is_signed, min_int_bits); + const MinInt = std.meta.Int(@TypeOf(value).is_signed, min_int_bits); var a: MinInt = value; var index: usize = buf.len; diff --git a/lib/std/fmt/parse_float.zig b/lib/std/fmt/parse_float.zig index 2495a140d3..2ab245043c 100644 --- a/lib/std/fmt/parse_float.zig +++ b/lib/std/fmt/parse_float.zig @@ -367,7 +367,7 @@ test "fmt.parseFloat" { const epsilon = 1e-7; inline for ([_]type{ f16, f32, f64, f128 }) |T| { - const Z = std.meta.IntType(false, T.bit_count); + const Z = std.meta.Int(false, T.bit_count); testing.expectError(error.InvalidCharacter, parseFloat(T, "")); testing.expectError(error.InvalidCharacter, parseFloat(T, " 1")); diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig index ede44f1577..70c858098d 100644 --- a/lib/std/hash/auto_hash.zig +++ b/lib/std/hash/auto_hash.zig @@ -93,7 +93,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void { // TODO Check if the situation is better after #561 is resolved. .Int => @call(.{ .modifier = .always_inline }, hasher.update, .{std.mem.asBytes(&key)}), - .Float => |info| hash(hasher, @bitCast(std.meta.IntType(false, info.bits), key), strat), + .Float => |info| hash(hasher, @bitCast(std.meta.Int(false, info.bits), key), strat), .Bool => hash(hasher, @boolToInt(key), strat), .Enum => hash(hasher, @enumToInt(key), strat), diff --git a/lib/std/hash/wyhash.zig b/lib/std/hash/wyhash.zig index 8b7edd246f..ed2f03350c 100644 --- a/lib/std/hash/wyhash.zig +++ b/lib/std/hash/wyhash.zig @@ -10,7 +10,7 @@ const primes = [_]u64{ }; fn read_bytes(comptime bytes: u8, data: []const u8) u64 { - const T = std.meta.IntType(false, 8 * bytes); + const T = std.meta.Int(false, 8 * bytes); return mem.readIntLittle(T, data[0..bytes]); } diff --git a/lib/std/heap.zig b/lib/std/heap.zig index e4a409b218..3e00ca5d59 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -1015,7 +1015,7 @@ fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!vo // very near usize? if (mem.page_size << 2 > maxInt(usize)) return; - const USizeShift = std.meta.IntType(false, std.math.log2(usize.bit_count)); + const USizeShift = std.meta.Int(false, std.math.log2(usize.bit_count)); const large_align = @as(u29, mem.page_size << 2); var align_mask: usize = undefined; diff --git a/lib/std/io/bit_in_stream.zig b/lib/std/io/bit_in_stream.zig index 2b65523207..def42fd77e 100644 --- a/lib/std/io/bit_in_stream.zig +++ b/lib/std/io/bit_in_stream.zig @@ -53,7 +53,7 @@ pub fn BitInStream(endian: builtin.Endian, comptime InStreamType: type) type { assert(u_bit_count >= bits); break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count; }; - const Buf = std.meta.IntType(false, buf_bit_count); + const Buf = std.meta.Int(false, buf_bit_count); const BufShift = math.Log2Int(Buf); out_bits.* = @as(usize, 0); diff --git a/lib/std/io/bit_out_stream.zig b/lib/std/io/bit_out_stream.zig index 1a2bb62e7c..cffea26de6 100644 --- a/lib/std/io/bit_out_stream.zig +++ b/lib/std/io/bit_out_stream.zig @@ -45,7 +45,7 @@ pub fn BitOutStream(endian: builtin.Endian, comptime OutStreamType: type) type { assert(u_bit_count >= bits); break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count; }; - const Buf = std.meta.IntType(false, buf_bit_count); + const Buf = std.meta.Int(false, buf_bit_count); const BufShift = math.Log2Int(Buf); const buf_value = @intCast(Buf, value); diff --git a/lib/std/io/serialization.zig b/lib/std/io/serialization.zig index 6ce18b780c..90d6a2e7f2 100644 --- a/lib/std/io/serialization.zig +++ b/lib/std/io/serialization.zig @@ -51,7 +51,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, const u8_bit_count = 8; const t_bit_count = comptime meta.bitCount(T); - const U = std.meta.IntType(false, t_bit_count); + const U = std.meta.Int(false, t_bit_count); const Log2U = math.Log2Int(U); const int_size = (U.bit_count + 7) / 8; @@ -66,7 +66,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, if (int_size == 1) { if (t_bit_count == 8) return @bitCast(T, buffer[0]); - const PossiblySignedByte = std.meta.IntType(T.is_signed, 8); + const PossiblySignedByte = std.meta.Int(T.is_signed, 8); return @truncate(T, @bitCast(PossiblySignedByte, buffer[0])); } @@ -236,7 +236,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co const t_bit_count = comptime meta.bitCount(T); const u8_bit_count = comptime meta.bitCount(u8); - const U = std.meta.IntType(false, t_bit_count); + const U = std.meta.Int(false, t_bit_count); const Log2U = math.Log2Int(U); const int_size = (U.bit_count + 7) / 8; @@ -372,8 +372,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi comptime var i = 0; inline while (i <= max_test_bitsize) : (i += 1) { - const U = std.meta.IntType(false, i); - const S = std.meta.IntType(true, i); + const U = std.meta.Int(false, i); + const S = std.meta.Int(true, i); try _serializer.serializeInt(@as(U, i)); if (i != 0) try _serializer.serializeInt(@as(S, -1)) else try _serializer.serialize(@as(S, 0)); } @@ -381,8 +381,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi i = 0; inline while (i <= max_test_bitsize) : (i += 1) { - const U = std.meta.IntType(false, i); - const S = std.meta.IntType(true, i); + const U = std.meta.Int(false, i); + const S = std.meta.Int(true, i); const x = try _deserializer.deserializeInt(U); const y = try _deserializer.deserializeInt(S); testing.expect(x == @as(U, i)); diff --git a/lib/std/math.zig b/lib/std/math.zig index e6dfc53235..8c07f3c8be 100644 --- a/lib/std/math.zig +++ b/lib/std/math.zig @@ -458,7 +458,7 @@ pub fn Log2Int(comptime T: type) type { count += 1; } - return std.meta.IntType(false, count); + return std.meta.Int(false, count); } pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type { @@ -474,7 +474,7 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t if (is_signed) { magnitude_bits += 1; } - return std.meta.IntType(is_signed, magnitude_bits); + return std.meta.Int(is_signed, magnitude_bits); } test "math.IntFittingRange" { @@ -686,7 +686,7 @@ fn testRem() void { /// Result is an unsigned integer. pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) { .ComptimeInt => comptime_int, - .Int => |intInfo| std.meta.IntType(false, intInfo.bits), + .Int => |intInfo| std.meta.Int(false, intInfo.bits), else => @compileError("absCast only accepts integers"), } { switch (@typeInfo(@TypeOf(x))) { @@ -698,7 +698,7 @@ pub fn absCast(x: var) switch (@typeInfo(@TypeOf(x))) { } }, .Int => |intInfo| { - const Uint = std.meta.IntType(false, intInfo.bits); + const Uint = std.meta.Int(false, intInfo.bits); if (x < 0) { return ~@bitCast(Uint, x +% -1); } else { @@ -719,10 +719,10 @@ test "math.absCast" { /// Returns the negation of the integer parameter. /// Result is a signed integer. -pub fn negateCast(x: var) !std.meta.IntType(true, @TypeOf(x).bit_count) { +pub fn negateCast(x: var) !std.meta.Int(true, @TypeOf(x).bit_count) { if (@TypeOf(x).is_signed) return negate(x); - const int = std.meta.IntType(true, @TypeOf(x).bit_count); + const int = std.meta.Int(true, @TypeOf(x).bit_count); if (x > -minInt(int)) return error.Overflow; if (x == -minInt(int)) return minInt(int); @@ -808,11 +808,11 @@ fn testFloorPowerOfTwo() void { /// Returns the next power of two (if the value is not already a power of two). /// Only unsigned integers can be used. Zero is not an allowed input. /// Result is a type with 1 more bit than the input type. -pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_signed, T.bit_count + 1) { +pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(T.is_signed, T.bit_count + 1) { comptime assert(@typeInfo(T) == .Int); comptime assert(!T.is_signed); assert(value != 0); - comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1); + comptime const PromotedType = std.meta.Int(T.is_signed, T.bit_count + 1); comptime const shiftType = std.math.Log2Int(PromotedType); return @as(PromotedType, 1) << @intCast(shiftType, T.bit_count - @clz(T, value - 1)); } @@ -823,7 +823,7 @@ pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.IntType(T.is_s pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) { comptime assert(@typeInfo(T) == .Int); comptime assert(!T.is_signed); - comptime const PromotedType = std.meta.IntType(T.is_signed, T.bit_count + 1); + comptime const PromotedType = std.meta.Int(T.is_signed, T.bit_count + 1); comptime const overflowBit = @as(PromotedType, 1) << T.bit_count; var x = ceilPowerOfTwoPromote(T, value); if (overflowBit & x != 0) { @@ -965,8 +965,8 @@ test "max value type" { testing.expect(x == 2147483647); } -pub fn mulWide(comptime T: type, a: T, b: T) std.meta.IntType(T.is_signed, T.bit_count * 2) { - const ResultInt = std.meta.IntType(T.is_signed, T.bit_count * 2); +pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(T.is_signed, T.bit_count * 2) { + const ResultInt = std.meta.Int(T.is_signed, T.bit_count * 2); return @as(ResultInt, a) * @as(ResultInt, b); } diff --git a/lib/std/math/big/int.zig b/lib/std/math/big/int.zig index 693a360fa9..f5d65a6866 100644 --- a/lib/std/math/big/int.zig +++ b/lib/std/math/big/int.zig @@ -9,8 +9,8 @@ const maxInt = std.math.maxInt; const minInt = std.math.minInt; pub const Limb = usize; -pub const DoubleLimb = std.meta.IntType(false, 2 * Limb.bit_count); -pub const SignedDoubleLimb = std.meta.IntType(true, DoubleLimb.bit_count); +pub const DoubleLimb = std.meta.Int(false, 2 * Limb.bit_count); +pub const SignedDoubleLimb = std.meta.Int(true, DoubleLimb.bit_count); pub const Log2Limb = math.Log2Int(Limb); comptime { @@ -272,7 +272,7 @@ pub const Int = struct { switch (@typeInfo(T)) { .Int => |info| { - const UT = if (T.is_signed) std.meta.IntType(false, T.bit_count - 1) else T; + const UT = if (T.is_signed) std.meta.Int(false, T.bit_count - 1) else T; try self.ensureCapacity(@sizeOf(UT) / @sizeOf(Limb)); self.metadata = 0; @@ -335,7 +335,7 @@ pub const Int = struct { pub fn to(self: Int, comptime T: type) ConvertError!T { switch (@typeInfo(T)) { .Int => { - const UT = std.meta.IntType(false, T.bit_count); + const UT = std.meta.Int(false, T.bit_count); if (self.bitCountTwosComp() > T.bit_count) { return error.TargetTooSmall; diff --git a/lib/std/math/big/rational.zig b/lib/std/math/big/rational.zig index 21e89ff8c4..f5f2f53113 100644 --- a/lib/std/math/big/rational.zig +++ b/lib/std/math/big/rational.zig @@ -127,8 +127,8 @@ pub const Rational = struct { // Translated from golang.go/src/math/big/rat.go. debug.assert(@typeInfo(T) == .Float); - const UnsignedIntType = std.meta.IntType(false, T.bit_count); - const f_bits = @bitCast(UnsignedIntType, f); + const UnsignedInt = std.meta.Int(false, T.bit_count); + const f_bits = @bitCast(UnsignedInt, f); const exponent_bits = math.floatExponentBits(T); const exponent_bias = (1 << (exponent_bits - 1)) - 1; @@ -186,7 +186,7 @@ pub const Rational = struct { debug.assert(@typeInfo(T) == .Float); const fsize = T.bit_count; - const BitReprType = std.meta.IntType(false, T.bit_count); + const BitReprType = std.meta.Int(false, T.bit_count); const msize = math.floatMantissaBits(T); const msize1 = msize + 1; diff --git a/lib/std/math/cos.zig b/lib/std/math/cos.zig index 8a599aece4..aa336769b1 100644 --- a/lib/std/math/cos.zig +++ b/lib/std/math/cos.zig @@ -44,7 +44,7 @@ const pi4c = 2.69515142907905952645E-15; const m4pi = 1.273239544735162542821171882678754627704620361328125; fn cos_(comptime T: type, x_: T) T { - const I = std.meta.IntType(true, T.bit_count); + const I = std.meta.Int(true, T.bit_count); var x = x_; if (math.isNan(x) or math.isInf(x)) { diff --git a/lib/std/math/pow.zig b/lib/std/math/pow.zig index ac6aee4cce..cb39dd59e3 100644 --- a/lib/std/math/pow.zig +++ b/lib/std/math/pow.zig @@ -145,7 +145,7 @@ pub fn pow(comptime T: type, x: T, y: T) T { var xe = r2.exponent; var x1 = r2.significand; - var i = @floatToInt(std.meta.IntType(true, T.bit_count), yi); + var i = @floatToInt(std.meta.Int(true, T.bit_count), yi); while (i != 0) : (i >>= 1) { const overflow_shift = math.floatExponentBits(T) + 1; if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) { diff --git a/lib/std/math/sin.zig b/lib/std/math/sin.zig index 0c339ba1f2..e88f5eeeaf 100644 --- a/lib/std/math/sin.zig +++ b/lib/std/math/sin.zig @@ -45,7 +45,7 @@ const pi4c = 2.69515142907905952645E-15; const m4pi = 1.273239544735162542821171882678754627704620361328125; fn sin_(comptime T: type, x_: T) T { - const I = std.meta.IntType(true, T.bit_count); + const I = std.meta.Int(true, T.bit_count); var x = x_; if (x == 0 or math.isNan(x)) { diff --git a/lib/std/math/sqrt.zig b/lib/std/math/sqrt.zig index e5d8a822f5..097b0152f7 100644 --- a/lib/std/math/sqrt.zig +++ b/lib/std/math/sqrt.zig @@ -31,7 +31,7 @@ pub fn sqrt(x: var) Sqrt(@TypeOf(x)) { } } -fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2) { +fn sqrt_int(comptime T: type, value: T) std.meta.Int(false, T.bit_count / 2) { var op = value; var res: T = 0; var one: T = 1 << (T.bit_count - 2); @@ -50,7 +50,7 @@ fn sqrt_int(comptime T: type, value: T) std.meta.IntType(false, T.bit_count / 2) one >>= 2; } - const ResultType = std.meta.IntType(false, T.bit_count / 2); + const ResultType = std.meta.Int(false, T.bit_count / 2); return @intCast(ResultType, res); } @@ -66,7 +66,7 @@ test "math.sqrt_int" { /// Returns the return type `sqrt` will return given an operand of type `T`. pub fn Sqrt(comptime T: type) type { return switch (@typeInfo(T)) { - .Int => |int| std.meta.IntType(false, int.bits / 2), + .Int => |int| std.meta.Int(false, int.bits / 2), else => T, }; } diff --git a/lib/std/math/tan.zig b/lib/std/math/tan.zig index 737f5b0e09..86f473f448 100644 --- a/lib/std/math/tan.zig +++ b/lib/std/math/tan.zig @@ -38,7 +38,7 @@ const pi4c = 2.69515142907905952645E-15; const m4pi = 1.273239544735162542821171882678754627704620361328125; fn tan_(comptime T: type, x_: T) T { - const I = std.meta.IntType(true, T.bit_count); + const I = std.meta.Int(true, T.bit_count); var x = x_; if (x == 0 or math.isNan(x)) { diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 54b5a8a50e..5ba984ecdc 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -1065,7 +1065,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void { return set(u8, buffer, 0); // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough - const uint = std.meta.IntType(false, T.bit_count); + const uint = std.meta.Int(false, T.bit_count); var bits = @truncate(uint, value); for (buffer) |*b| { b.* = @truncate(u8, bits); @@ -1085,7 +1085,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void { return set(u8, buffer, 0); // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough - const uint = std.meta.IntType(false, T.bit_count); + const uint = std.meta.Int(false, T.bit_count); var bits = @truncate(uint, value); var index: usize = buffer.len; while (index != 0) { diff --git a/lib/std/os.zig b/lib/std/os.zig index 5e163e6708..06a4c12dfc 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -3681,7 +3681,7 @@ pub fn res_mkquery( // Make a reasonably unpredictable id var ts: timespec = undefined; clock_gettime(CLOCK_REALTIME, &ts) catch {}; - const UInt = std.meta.IntType(false, @TypeOf(ts.tv_nsec).bit_count); + const UInt = std.meta.Int(false, @TypeOf(ts.tv_nsec).bit_count); const unsec = @bitCast(UInt, ts.tv_nsec); const id = @truncate(u32, unsec + unsec / 65536); q[0] = @truncate(u8, id / 256); diff --git a/lib/std/os/bits/linux.zig b/lib/std/os/bits/linux.zig index 1d2a957036..750b487754 100644 --- a/lib/std/os/bits/linux.zig +++ b/lib/std/os/bits/linux.zig @@ -1037,7 +1037,7 @@ pub const dl_phdr_info = extern struct { pub const CPU_SETSIZE = 128; pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; -pub const cpu_count_t = std.meta.IntType(false, std.math.log2(CPU_SETSIZE * 8)); +pub const cpu_count_t = std.meta.Int(false, std.math.log2(CPU_SETSIZE * 8)); pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { var sum: cpu_count_t = 0; diff --git a/lib/std/packed_int_array.zig b/lib/std/packed_int_array.zig index 51be01315e..8a0dbfbf8d 100644 --- a/lib/std/packed_int_array.zig +++ b/lib/std/packed_int_array.zig @@ -34,13 +34,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type { //we bitcast the desired Int type to an unsigned version of itself // to avoid issues with shifting signed ints. - const UnInt = std.meta.IntType(false, int_bits); + const UnInt = std.meta.Int(false, int_bits); //The maximum container int type - const MinIo = std.meta.IntType(false, min_io_bits); + const MinIo = std.meta.Int(false, min_io_bits); //The minimum container int type - const MaxIo = std.meta.IntType(false, max_io_bits); + const MaxIo = std.meta.Int(false, max_io_bits); return struct { pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int { @@ -322,7 +322,7 @@ test "PackedIntArray" { inline while (bits <= 256) : (bits += 1) { //alternate unsigned and signed const even = bits % 2 == 0; - const I = std.meta.IntType(even, bits); + const I = std.meta.Int(even, bits); const PackedArray = PackedIntArray(I, int_count); const expected_bytes = ((bits * int_count) + 7) / 8; @@ -369,7 +369,7 @@ test "PackedIntSlice" { inline while (bits <= 256) : (bits += 1) { //alternate unsigned and signed const even = bits % 2 == 0; - const I = std.meta.IntType(even, bits); + const I = std.meta.Int(even, bits); const P = PackedIntSlice(I); var data = P.init(&buffer, int_count); @@ -399,7 +399,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" { comptime var bits = 0; inline while (bits <= max_bits) : (bits += 1) { - const Int = std.meta.IntType(false, bits); + const Int = std.meta.Int(false, bits); const PackedArray = PackedIntArray(Int, int_count); var packed_array = @as(PackedArray, undefined); diff --git a/lib/std/rand.zig b/lib/std/rand.zig index 299d87d39c..45a1172b3d 100644 --- a/lib/std/rand.zig +++ b/lib/std/rand.zig @@ -45,8 +45,8 @@ pub const Random = struct { /// Returns a random int `i` such that `0 <= i <= maxInt(T)`. /// `i` is evenly distributed. pub fn int(r: *Random, comptime T: type) T { - const UnsignedT = std.meta.IntType(false, T.bit_count); - const ByteAlignedT = std.meta.IntType(false, @divTrunc(T.bit_count + 7, 8) * 8); + const UnsignedT = std.meta.Int(false, T.bit_count); + const ByteAlignedT = std.meta.Int(false, @divTrunc(T.bit_count + 7, 8) * 8); var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined; r.bytes(rand_bytes[0..]); @@ -85,9 +85,9 @@ pub const Random = struct { comptime assert(T.bit_count <= 64); // TODO: workaround: LLVM ERROR: Unsupported library call operation! assert(0 < less_than); // Small is typically u32 - const Small = std.meta.IntType(false, @divTrunc(T.bit_count + 31, 32) * 32); + const Small = std.meta.Int(false, @divTrunc(T.bit_count + 31, 32) * 32); // Large is typically u64 - const Large = std.meta.IntType(false, Small.bit_count * 2); + const Large = std.meta.Int(false, Small.bit_count * 2); // adapted from: // http://www.pcg-random.org/posts/bounded-rands.html @@ -99,7 +99,7 @@ pub const Random = struct { // TODO: workaround for https://github.com/ziglang/zig/issues/1770 // should be: // var t: Small = -%less_than; - var t: Small = @bitCast(Small, -%@bitCast(std.meta.IntType(true, Small.bit_count), @as(Small, less_than))); + var t: Small = @bitCast(Small, -%@bitCast(std.meta.Int(true, Small.bit_count), @as(Small, less_than))); if (t >= less_than) { t -= less_than; @@ -145,7 +145,7 @@ pub const Random = struct { assert(at_least < less_than); if (T.is_signed) { // Two's complement makes this math pretty easy. - const UnsignedT = std.meta.IntType(false, T.bit_count); + const UnsignedT = std.meta.Int(false, T.bit_count); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, less_than); const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo); @@ -163,7 +163,7 @@ pub const Random = struct { assert(at_least < less_than); if (T.is_signed) { // Two's complement makes this math pretty easy. - const UnsignedT = std.meta.IntType(false, T.bit_count); + const UnsignedT = std.meta.Int(false, T.bit_count); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, less_than); const result = lo +% r.uintLessThan(UnsignedT, hi -% lo); @@ -180,7 +180,7 @@ pub const Random = struct { assert(at_least <= at_most); if (T.is_signed) { // Two's complement makes this math pretty easy. - const UnsignedT = std.meta.IntType(false, T.bit_count); + const UnsignedT = std.meta.Int(false, T.bit_count); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, at_most); const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo); @@ -198,7 +198,7 @@ pub const Random = struct { assert(at_least <= at_most); if (T.is_signed) { // Two's complement makes this math pretty easy. - const UnsignedT = std.meta.IntType(false, T.bit_count); + const UnsignedT = std.meta.Int(false, T.bit_count); const lo = @bitCast(UnsignedT, at_least); const hi = @bitCast(UnsignedT, at_most); const result = lo +% r.uintAtMost(UnsignedT, hi -% lo); @@ -275,7 +275,7 @@ pub const Random = struct { /// This function introduces a minor bias. pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { comptime assert(T.is_signed == false); - const T2 = std.meta.IntType(false, T.bit_count * 2); + const T2 = std.meta.Int(false, T.bit_count * 2); // adapted from: // http://www.pcg-random.org/posts/bounded-rands.html diff --git a/lib/std/special/c.zig b/lib/std/special/c.zig index 8bfd540858..c769bc358b 100644 --- a/lib/std/special/c.zig +++ b/lib/std/special/c.zig @@ -511,7 +511,7 @@ export fn roundf(a: f32) f32 { fn generic_fmod(comptime T: type, x: T, y: T) T { @setRuntimeSafety(false); - const uint = std.meta.IntType(false, T.bit_count); + const uint = std.meta.Int(false, T.bit_count); const log2uint = math.Log2Int(uint); const digits = if (T == f32) 23 else 52; const exp_bits = if (T == f32) 9 else 12; diff --git a/lib/std/special/compiler_rt/addXf3.zig b/lib/std/special/compiler_rt/addXf3.zig index 8bb9751378..849efa1cd2 100644 --- a/lib/std/special/compiler_rt/addXf3.zig +++ b/lib/std/special/compiler_rt/addXf3.zig @@ -54,21 +54,21 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 { } // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 -fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { - const Z = std.meta.IntType(false, T.bit_count); - const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); +fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 { + const Z = std.meta.Int(false, T.bit_count); + const S = std.meta.Int(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); const significandBits = std.math.floatMantissaBits(T); const implicitBit = @as(Z, 1) << significandBits; - const shift = @clz(std.meta.IntType(false, T.bit_count), significand.*) - @clz(Z, implicitBit); + const shift = @clz(std.meta.Int(false, T.bit_count), significand.*) - @clz(Z, implicitBit); significand.* <<= @intCast(S, shift); return 1 - shift; } // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 fn addXf3(comptime T: type, a: T, b: T) T { - const Z = std.meta.IntType(false, T.bit_count); - const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); + const Z = std.meta.Int(false, T.bit_count); + const S = std.meta.Int(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); const typeWidth = T.bit_count; const significandBits = std.math.floatMantissaBits(T); @@ -182,7 +182,7 @@ fn addXf3(comptime T: type, a: T, b: T) T { // If partial cancellation occured, we need to left-shift the result // and adjust the exponent: if (aSignificand < implicitBit << 3) { - const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.IntType(false, T.bit_count), implicitBit << 3)); + const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.Int(false, T.bit_count), implicitBit << 3)); aSignificand <<= @intCast(S, shift); aExponent -= shift; } diff --git a/lib/std/special/compiler_rt/compareXf2.zig b/lib/std/special/compiler_rt/compareXf2.zig index 34871a5025..6489d283ff 100644 --- a/lib/std/special/compiler_rt/compareXf2.zig +++ b/lib/std/special/compiler_rt/compareXf2.zig @@ -22,8 +22,8 @@ const GE = extern enum(i32) { pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT { @setRuntimeSafety(builtin.is_test); - const srep_t = std.meta.IntType(true, T.bit_count); - const rep_t = std.meta.IntType(false, T.bit_count); + const srep_t = std.meta.Int(true, T.bit_count); + const rep_t = std.meta.Int(false, T.bit_count); const significandBits = std.math.floatMantissaBits(T); const exponentBits = std.math.floatExponentBits(T); @@ -68,7 +68,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT { pub fn unordcmp(comptime T: type, a: T, b: T) i32 { @setRuntimeSafety(builtin.is_test); - const rep_t = std.meta.IntType(false, T.bit_count); + const rep_t = std.meta.Int(false, T.bit_count); const significandBits = std.math.floatMantissaBits(T); const exponentBits = std.math.floatExponentBits(T); diff --git a/lib/std/special/compiler_rt/divdf3.zig b/lib/std/special/compiler_rt/divdf3.zig index ed571e6024..8b7525e931 100644 --- a/lib/std/special/compiler_rt/divdf3.zig +++ b/lib/std/special/compiler_rt/divdf3.zig @@ -7,8 +7,8 @@ const builtin = @import("builtin"); pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, f64.bit_count); - const SignedZ = std.meta.IntType(true, f64.bit_count); + const Z = std.meta.Int(false, f64.bit_count); + const SignedZ = std.meta.Int(true, f64.bit_count); const typeWidth = f64.bit_count; const significandBits = std.math.floatMantissaBits(f64); @@ -312,9 +312,9 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { } } -pub fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { +pub fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, T.bit_count); + const Z = std.meta.Int(false, T.bit_count); const significandBits = std.math.floatMantissaBits(T); const implicitBit = @as(Z, 1) << significandBits; diff --git a/lib/std/special/compiler_rt/divsf3.zig b/lib/std/special/compiler_rt/divsf3.zig index 0cb149a610..62a6c56262 100644 --- a/lib/std/special/compiler_rt/divsf3.zig +++ b/lib/std/special/compiler_rt/divsf3.zig @@ -7,7 +7,7 @@ const builtin = @import("builtin"); pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, f32.bit_count); + const Z = std.meta.Int(false, f32.bit_count); const typeWidth = f32.bit_count; const significandBits = std.math.floatMantissaBits(f32); @@ -185,9 +185,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { } } -fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { +fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, T.bit_count); + const Z = std.meta.Int(false, T.bit_count); const significandBits = std.math.floatMantissaBits(T); const implicitBit = @as(Z, 1) << significandBits; diff --git a/lib/std/special/compiler_rt/divtf3.zig b/lib/std/special/compiler_rt/divtf3.zig index b95f0dba66..d177454ad2 100644 --- a/lib/std/special/compiler_rt/divtf3.zig +++ b/lib/std/special/compiler_rt/divtf3.zig @@ -6,8 +6,8 @@ const wideMultiply = @import("divdf3.zig").wideMultiply; pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, f128.bit_count); - const SignedZ = std.meta.IntType(true, f128.bit_count); + const Z = std.meta.Int(false, f128.bit_count); + const SignedZ = std.meta.Int(true, f128.bit_count); const typeWidth = f128.bit_count; const significandBits = std.math.floatMantissaBits(f128); diff --git a/lib/std/special/compiler_rt/extendXfYf2.zig b/lib/std/special/compiler_rt/extendXfYf2.zig index 58da88e586..6aca0ac98f 100644 --- a/lib/std/special/compiler_rt/extendXfYf2.zig +++ b/lib/std/special/compiler_rt/extendXfYf2.zig @@ -30,11 +30,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 { const CHAR_BIT = 8; -fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.IntType(false, @typeInfo(src_t).Float.bits)) dst_t { +fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(false, @typeInfo(src_t).Float.bits)) dst_t { @setRuntimeSafety(builtin.is_test); - const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits); - const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits); + const src_rep_t = std.meta.Int(false, @typeInfo(src_t).Float.bits); + const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); const SrcShift = std.math.Log2Int(src_rep_t); diff --git a/lib/std/special/compiler_rt/fixint.zig b/lib/std/special/compiler_rt/fixint.zig index 3a401c1e6a..daf7a1bdc7 100644 --- a/lib/std/special/compiler_rt/fixint.zig +++ b/lib/std/special/compiler_rt/fixint.zig @@ -45,7 +45,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t { if (exponent < 0) return 0; // The unsigned result needs to be large enough to handle an fixint_t or rep_t - const fixuint_t = std.meta.IntType(false, fixint_t.bit_count); + const fixuint_t = std.meta.Int(false, fixint_t.bit_count); const UintResultType = if (fixint_t.bit_count > rep_t.bit_count) fixuint_t else rep_t; var uint_result: UintResultType = undefined; diff --git a/lib/std/special/compiler_rt/fixuint.zig b/lib/std/special/compiler_rt/fixuint.zig index d8e3e9a0e0..1e96b7c283 100644 --- a/lib/std/special/compiler_rt/fixuint.zig +++ b/lib/std/special/compiler_rt/fixuint.zig @@ -10,7 +10,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t f128 => u128, else => unreachable, }; - const srep_t = @import("std").meta.IntType(true, rep_t.bit_count); + const srep_t = @import("std").meta.Int(true, rep_t.bit_count); const significandBits = switch (fp_t) { f32 => 23, f64 => 52, diff --git a/lib/std/special/compiler_rt/floatsiXf.zig b/lib/std/special/compiler_rt/floatsiXf.zig index 550a7ec246..6a1dc422b7 100644 --- a/lib/std/special/compiler_rt/floatsiXf.zig +++ b/lib/std/special/compiler_rt/floatsiXf.zig @@ -5,8 +5,8 @@ const maxInt = std.math.maxInt; fn floatsiXf(comptime T: type, a: i32) T { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, T.bit_count); - const S = std.meta.IntType(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); + const Z = std.meta.Int(false, T.bit_count); + const S = std.meta.Int(false, T.bit_count - @clz(Z, @as(Z, T.bit_count) - 1)); if (a == 0) { return @as(T, 0.0); diff --git a/lib/std/special/compiler_rt/mulXf3.zig b/lib/std/special/compiler_rt/mulXf3.zig index a40c0f1e70..af49d27952 100644 --- a/lib/std/special/compiler_rt/mulXf3.zig +++ b/lib/std/special/compiler_rt/mulXf3.zig @@ -28,7 +28,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 { fn mulXf3(comptime T: type, a: T, b: T) T { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, T.bit_count); + const Z = std.meta.Int(false, T.bit_count); const typeWidth = T.bit_count; const significandBits = std.math.floatMantissaBits(T); @@ -264,9 +264,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void { } } -fn normalize(comptime T: type, significand: *std.meta.IntType(false, T.bit_count)) i32 { +fn normalize(comptime T: type, significand: *std.meta.Int(false, T.bit_count)) i32 { @setRuntimeSafety(builtin.is_test); - const Z = std.meta.IntType(false, T.bit_count); + const Z = std.meta.Int(false, T.bit_count); const significandBits = std.math.floatMantissaBits(T); const implicitBit = @as(Z, 1) << significandBits; diff --git a/lib/std/special/compiler_rt/negXf2.zig b/lib/std/special/compiler_rt/negXf2.zig index d1038d6456..0739ecb83c 100644 --- a/lib/std/special/compiler_rt/negXf2.zig +++ b/lib/std/special/compiler_rt/negXf2.zig @@ -19,7 +19,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 { } fn negXf2(comptime T: type, a: T) T { - const Z = std.meta.IntType(false, T.bit_count); + const Z = std.meta.Int(false, T.bit_count); const typeWidth = T.bit_count; const significandBits = std.math.floatMantissaBits(T); diff --git a/lib/std/special/compiler_rt/shift.zig b/lib/std/special/compiler_rt/shift.zig index e21042e14e..f811c5124d 100644 --- a/lib/std/special/compiler_rt/shift.zig +++ b/lib/std/special/compiler_rt/shift.zig @@ -4,8 +4,8 @@ const Log2Int = std.math.Log2Int; fn Dwords(comptime T: type, comptime signed_half: bool) type { return extern union { - pub const HalfTU = std.meta.IntType(false, @divExact(T.bit_count, 2)); - pub const HalfTS = std.meta.IntType(true, @divExact(T.bit_count, 2)); + pub const HalfTU = std.meta.Int(false, @divExact(T.bit_count, 2)); + pub const HalfTS = std.meta.Int(true, @divExact(T.bit_count, 2)); pub const HalfT = if (signed_half) HalfTS else HalfTU; all: T, diff --git a/lib/std/special/compiler_rt/truncXfYf2.zig b/lib/std/special/compiler_rt/truncXfYf2.zig index cba5b85264..d345bf30a3 100644 --- a/lib/std/special/compiler_rt/truncXfYf2.zig +++ b/lib/std/special/compiler_rt/truncXfYf2.zig @@ -36,8 +36,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 { } fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t { - const src_rep_t = std.meta.IntType(false, @typeInfo(src_t).Float.bits); - const dst_rep_t = std.meta.IntType(false, @typeInfo(dst_t).Float.bits); + const src_rep_t = std.meta.Int(false, @typeInfo(src_t).Float.bits); + const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits); const srcSigBits = std.math.floatMantissaBits(src_t); const dstSigBits = std.math.floatMantissaBits(dst_t); const SrcShift = std.math.Log2Int(src_rep_t); diff --git a/lib/std/special/compiler_rt/udivmod.zig b/lib/std/special/compiler_rt/udivmod.zig index 9f0fb7d50f..7d519c34cb 100644 --- a/lib/std/special/compiler_rt/udivmod.zig +++ b/lib/std/special/compiler_rt/udivmod.zig @@ -10,8 +10,8 @@ const high = 1 - low; pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem: ?*DoubleInt) DoubleInt { @setRuntimeSafety(is_test); - const SingleInt = @import("std").meta.IntType(false, @divExact(DoubleInt.bit_count, 2)); - const SignedDoubleInt = @import("std").meta.IntType(true, DoubleInt.bit_count); + const SingleInt = @import("std").meta.Int(false, @divExact(DoubleInt.bit_count, 2)); + const SignedDoubleInt = @import("std").meta.Int(true, DoubleInt.bit_count); const Log2SingleInt = @import("std").math.Log2Int(SingleInt); const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421 diff --git a/lib/std/target.zig b/lib/std/target.zig index d5ef5c95ec..6e383ba4c7 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -459,7 +459,7 @@ pub const Target = struct { pub const needed_bit_count = 155; pub const byte_count = (needed_bit_count + 7) / 8; pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize); - pub const Index = std.math.Log2Int(std.meta.IntType(false, usize_count * @bitSizeOf(usize))); + pub const Index = std.math.Log2Int(std.meta.Int(false, usize_count * @bitSizeOf(usize))); pub const ShiftInt = std.math.Log2Int(usize); pub const empty = Set{ .ints = [1]usize{0} ** usize_count }; diff --git a/test/stage1/behavior/bit_shifting.zig b/test/stage1/behavior/bit_shifting.zig index c71b95e0cc..7306acba4a 100644 --- a/test/stage1/behavior/bit_shifting.zig +++ b/test/stage1/behavior/bit_shifting.zig @@ -2,9 +2,9 @@ const std = @import("std"); const expect = std.testing.expect; fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type { - expect(Key == std.meta.IntType(false, Key.bit_count)); + expect(Key == std.meta.Int(false, Key.bit_count)); expect(Key.bit_count >= mask_bit_count); - const ShardKey = std.meta.IntType(false, mask_bit_count); + const ShardKey = std.meta.Int(false, mask_bit_count); const shift_amount = Key.bit_count - ShardKey.bit_count; return struct { const Self = @This();