authorgravatar for 57442prudil@sstebrno.euJan Prudil <57442prudil@sstebrno.eu> 2020-10-17 14:09:59+02:00
committergravatar for 57442prudil@sstebrno.euJan Prudil <57442prudil@sstebrno.eu> 2020-10-17 14:09:59+02:00
logaadccc4206ea605719de789bc7c9c48557d02331
tree631f4d25f6c8bf6cefdcbe58f3ac9f61434b6402
parent245d98d32dd29e80de9732f415a4731748008acf

Make std.meta.Int accept a signedness parameter


44 files changed, 120 insertions(+), 114 deletions(-)

lib/std/child_process.zig+1-1
......@@ -826,7 +826,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
826826 os.exit(1);
827827}
828828
829const ErrInt = std.meta.Int(false, @sizeOf(anyerror) * 8);
829const ErrInt = std.meta.Int(.unsigned, @sizeOf(anyerror) * 8);
830830
831831fn writeIntFd(fd: i32, value: ErrInt) !void {
832832 const file = File{
lib/std/debug/leb128.zig+11-10
......@@ -55,7 +55,7 @@ pub fn writeULEB128(writer: anytype, uint_value: anytype) !void {
5555 }
5656}
5757
58/// Read a single unsinged integer from the given memory as type T.
58/// Read a single unsigned integer from the given memory as type T.
5959/// The provided slice reference will be updated to point to the byte after the last byte read.
6060pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T {
6161 var buf = std.io.fixedBufferStream(ptr.*);
......@@ -78,7 +78,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize {
7878/// or error.Overflow if the value cannot fit.
7979pub fn readILEB128(comptime T: type, reader: anytype) !T {
8080 const S = if (@typeInfo(T).Int.bits < 8) i8 else T;
81 const U = std.meta.Int(false, @typeInfo(S).Int.bits);
81 const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits);
8282 const ShiftU = std.math.Log2Int(U);
8383
8484 const max_group = (@typeInfo(U).Int.bits + 6) / 7;
......@@ -128,7 +128,7 @@ pub fn readILEB128(comptime T: type, reader: anytype) !T {
128128pub fn writeILEB128(writer: anytype, int_value: anytype) !void {
129129 const T = @TypeOf(int_value);
130130 const S = if (@typeInfo(T).Int.bits < 8) i8 else T;
131 const U = std.meta.Int(false, @typeInfo(S).Int.bits);
131 const U = std.meta.Int(.unsigned, @typeInfo(S).Int.bits);
132132
133133 var value = @intCast(S, int_value);
134134
......@@ -171,7 +171,7 @@ pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize {
171171/// An example use case of this is in emitting DWARF info where one wants to make a ULEB128 field
172172/// "relocatable", meaning that it becomes possible to later go back and patch the number to be a
173173/// different value without shifting all the following code.
174pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(false, l * 7)) void {
174pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.unsigned, l * 7)) void {
175175 const T = @TypeOf(int);
176176 const U = if (@typeInfo(T).Int.bits < 8) u8 else T;
177177 var value = @intCast(U, int);
......@@ -347,6 +347,7 @@ test "deserialize unsigned LEB128" {
347347fn test_write_leb128(value: anytype) !void {
348348 const T = @TypeOf(value);
349349 const t_signed = @typeInfo(T).Int.is_signed;
350 const signedness = if (t_signed) .signed else .unsigned;
350351
351352 const writeStream = if (t_signed) writeILEB128 else writeULEB128;
352353 const writeMem = if (t_signed) writeILEB128Mem else writeULEB128Mem;
......@@ -356,10 +357,10 @@ fn test_write_leb128(value: anytype) !void {
356357 // decode to a larger bit size too, to ensure sign extension
357358 // is working as expected
358359 const larger_type_bits = ((@typeInfo(T).Int.bits + 8) / 8) * 8;
359 const B = std.meta.Int(t_signed, larger_type_bits);
360 const B = std.meta.Int(signedness, larger_type_bits);
360361
361362 const bytes_needed = bn: {
362 const S = std.meta.Int(t_signed, @sizeOf(T) * 8);
363 const S = std.meta.Int(signedness, @sizeOf(T) * 8);
363364 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);
364365
365366 const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value);
......@@ -412,10 +413,10 @@ test "serialize unsigned LEB128" {
412413
413414 comptime var t = 0;
414415 inline while (t <= max_bits) : (t += 1) {
415 const T = std.meta.Int(false, t);
416 const T = std.meta.Int(.unsigned, t);
416417 const min = std.math.minInt(T);
417418 const max = std.math.maxInt(T);
418 var i = @as(std.meta.Int(false, @typeInfo(T).Int.bits + 1), min);
419 var i = @as(std.meta.Int(.unsigned, @typeInfo(T).Int.bits + 1), min);
419420
420421 while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i));
421422 }
......@@ -430,10 +431,10 @@ test "serialize signed LEB128" {
430431
431432 comptime var t = 1;
432433 inline while (t <= max_bits) : (t += 1) {
433 const T = std.meta.Int(true, t);
434 const T = std.meta.Int(.signed, t);
434435 const min = std.math.minInt(T);
435436 const max = std.math.maxInt(T);
436 var i = @as(std.meta.Int(true, @typeInfo(T).Int.bits + 1), min);
437 var i = @as(std.meta.Int(.signed, @typeInfo(T).Int.bits + 1), min);
437438
438439 while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i));
439440 }
lib/std/event/wait_group.zig+1-1
......@@ -22,7 +22,7 @@ const Loop = std.event.Loop;
2222pub const WaitGroup = WaitGroupGeneric(std.meta.bitCount(usize));
2323
2424pub fn WaitGroupGeneric(comptime counter_size: u16) type {
25 const CounterType = std.meta.Int(false, counter_size);
25 const CounterType = std.meta.Int(.unsigned, counter_size);
2626
2727 const global_event_loop = Loop.instance orelse
2828 @compileError("std.event.WaitGroup currently only works with event-based I/O");
lib/std/fmt.zig+1-1
......@@ -950,7 +950,7 @@ pub fn formatInt(
950950 // The type must have the same size as `base` or be wider in order for the
951951 // division to work
952952 const min_int_bits = comptime math.max(value_info.bits, 8);
953 const MinInt = std.meta.Int(false, min_int_bits);
953 const MinInt = std.meta.Int(.unsigned, min_int_bits);
954954
955955 const abs_value = math.absCast(int_value);
956956 // The worst case in terms of space needed is base 2, plus 1 for the sign
lib/std/fmt/parse_float.zig+1-1
......@@ -374,7 +374,7 @@ test "fmt.parseFloat" {
374374 const epsilon = 1e-7;
375375
376376 inline for ([_]type{ f16, f32, f64, f128 }) |T| {
377 const Z = std.meta.Int(false, @typeInfo(T).Float.bits);
377 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
378378
379379 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
380380 testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
lib/std/hash/wyhash.zig+1-1
......@@ -15,7 +15,7 @@ const primes = [_]u64{
1515};
1616
1717fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
18 const T = std.meta.Int(false, 8 * bytes);
18 const T = std.meta.Int(.unsigned, 8 * bytes);
1919 return mem.readIntLittle(T, data[0..bytes]);
2020}
2121
lib/std/heap.zig+1-1
......@@ -963,7 +963,7 @@ pub fn testAllocatorLargeAlignment(base_allocator: *mem.Allocator) mem.Allocator
963963 // very near usize?
964964 if (mem.page_size << 2 > maxInt(usize)) return;
965965
966 const USizeShift = std.meta.Int(false, std.math.log2(std.meta.bitCount(usize)));
966 const USizeShift = std.meta.Int(.unsigned, std.math.log2(std.meta.bitCount(usize)));
967967 const large_align = @as(u29, mem.page_size << 2);
968968
969969 var align_mask: usize = undefined;
lib/std/heap/general_purpose_allocator.zig+1-1
......@@ -107,7 +107,7 @@ const page_size = std.mem.page_size;
107107const StackTrace = std.builtin.StackTrace;
108108
109109/// Integer type for pointing to slots in a small allocation
110const SlotIndex = std.meta.Int(false, math.log2(page_size) + 1);
110const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1);
111111
112112const sys_can_stack_trace = switch (std.Target.current.cpu.arch) {
113113 // Observed to go into an infinite loop.
lib/std/io/bit_reader.zig+1-1
......@@ -60,7 +60,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
6060 assert(u_bit_count >= bits);
6161 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
6262 };
63 const Buf = std.meta.Int(false, buf_bit_count);
63 const Buf = std.meta.Int(.unsigned, buf_bit_count);
6464 const BufShift = math.Log2Int(Buf);
6565
6666 out_bits.* = @as(usize, 0);
lib/std/io/bit_writer.zig+1-1
......@@ -52,7 +52,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
5252 assert(u_bit_count >= bits);
5353 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
5454 };
55 const Buf = std.meta.Int(false, buf_bit_count);
55 const Buf = std.meta.Int(.unsigned, buf_bit_count);
5656 const BufShift = math.Log2Int(Buf);
5757
5858 const buf_value = @intCast(Buf, value);
lib/std/io/serialization.zig+7-7
......@@ -58,7 +58,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
5858 const u8_bit_count = 8;
5959 const t_bit_count = comptime meta.bitCount(T);
6060
61 const U = std.meta.Int(false, t_bit_count);
61 const U = std.meta.Int(.unsigned, t_bit_count);
6262 const Log2U = math.Log2Int(U);
6363 const int_size = (t_bit_count + 7) / 8;
6464
......@@ -73,7 +73,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
7373
7474 if (int_size == 1) {
7575 if (t_bit_count == 8) return @bitCast(T, buffer[0]);
76 const PossiblySignedByte = std.meta.Int(@typeInfo(T).Int.is_signed, 8);
76 const PossiblySignedByte = std.meta.Int(if (@typeInfo(T).Int.is_signed) .signed else .unsigned, 8);
7777 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));
7878 }
7979
......@@ -245,7 +245,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
245245 const t_bit_count = comptime meta.bitCount(T);
246246 const u8_bit_count = comptime meta.bitCount(u8);
247247
248 const U = std.meta.Int(false, t_bit_count);
248 const U = std.meta.Int(.unsigned, t_bit_count);
249249 const Log2U = math.Log2Int(U);
250250 const int_size = (t_bit_count + 7) / 8;
251251
......@@ -381,8 +381,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
381381
382382 comptime var i = 0;
383383 inline while (i <= max_test_bitsize) : (i += 1) {
384 const U = std.meta.Int(false, i);
385 const S = std.meta.Int(true, i);
384 const U = std.meta.Int(.unsigned, i);
385 const S = std.meta.Int(.signed, i);
386386 try _serializer.serializeInt(@as(U, i));
387387 if (i != 0) try _serializer.serializeInt(@as(S, -1)) else try _serializer.serialize(@as(S, 0));
388388 }
......@@ -390,8 +390,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
390390
391391 i = 0;
392392 inline while (i <= max_test_bitsize) : (i += 1) {
393 const U = std.meta.Int(false, i);
394 const S = std.meta.Int(true, i);
393 const U = std.meta.Int(.unsigned, i);
394 const S = std.meta.Int(.signed, i);
395395 const x = try _deserializer.deserializeInt(U);
396396 const y = try _deserializer.deserializeInt(S);
397397 testing.expect(x == @as(U, i));
lib/std/math.zig+13-13
......@@ -448,7 +448,7 @@ pub fn Log2Int(comptime T: type) type {
448448 count += 1;
449449 }
450450
451 return std.meta.Int(false, count);
451 return std.meta.Int(.unsigned, count);
452452}
453453
454454pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type {
......@@ -456,15 +456,15 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
456456 if (from == 0 and to == 0) {
457457 return u0;
458458 }
459 const is_signed = from < 0;
459 const sign: std.meta.Signedness = if (from < 0) .signed else .unsigned;
460460 const largest_positive_integer = max(if (from < 0) (-from) - 1 else from, to); // two's complement
461461 const base = log2(largest_positive_integer);
462462 const upper = (1 << base) - 1;
463463 var magnitude_bits = if (upper >= largest_positive_integer) base else base + 1;
464 if (is_signed) {
464 if (sign == .signed) {
465465 magnitude_bits += 1;
466466 }
467 return std.meta.Int(is_signed, magnitude_bits);
467 return std.meta.Int(sign, magnitude_bits);
468468}
469469
470470test "math.IntFittingRange" {
......@@ -729,7 +729,7 @@ fn testRem() void {
729729/// Result is an unsigned integer.
730730pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
731731 .ComptimeInt => comptime_int,
732 .Int => |intInfo| std.meta.Int(false, intInfo.bits),
732 .Int => |intInfo| std.meta.Int(.unsigned, intInfo.bits),
733733 else => @compileError("absCast only accepts integers"),
734734} {
735735 switch (@typeInfo(@TypeOf(x))) {
......@@ -741,7 +741,7 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
741741 }
742742 },
743743 .Int => |intInfo| {
744 const Uint = std.meta.Int(false, intInfo.bits);
744 const Uint = std.meta.Int(.unsigned, intInfo.bits);
745745 if (x < 0) {
746746 return ~@bitCast(Uint, x +% -1);
747747 } else {
......@@ -762,10 +762,10 @@ test "math.absCast" {
762762
763763/// Returns the negation of the integer parameter.
764764/// Result is a signed integer.
765pub fn negateCast(x: anytype) !std.meta.Int(true, std.meta.bitCount(@TypeOf(x))) {
765pub fn negateCast(x: anytype) !std.meta.Int(.signed, std.meta.bitCount(@TypeOf(x))) {
766766 if (@typeInfo(@TypeOf(x)).Int.is_signed) return negate(x);
767767
768 const int = std.meta.Int(true, std.meta.bitCount(@TypeOf(x)));
768 const int = std.meta.Int(.signed, std.meta.bitCount(@TypeOf(x)));
769769 if (x > -minInt(int)) return error.Overflow;
770770
771771 if (x == -minInt(int)) return minInt(int);
......@@ -852,11 +852,11 @@ fn testFloorPowerOfTwo() void {
852852/// Returns the next power of two (if the value is not already a power of two).
853853/// Only unsigned integers can be used. Zero is not an allowed input.
854854/// Result is a type with 1 more bit than the input type.
855pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).Int.is_signed, @typeInfo(T).Int.bits + 1) {
855pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(if (@typeInfo(T).Int.is_signed) .signed else .unsigned, @typeInfo(T).Int.bits + 1) {
856856 comptime assert(@typeInfo(T) == .Int);
857857 comptime assert(!@typeInfo(T).Int.is_signed);
858858 assert(value != 0);
859 comptime const PromotedType = std.meta.Int(@typeInfo(T).Int.is_signed, @typeInfo(T).Int.bits + 1);
859 comptime const PromotedType = std.meta.Int(if (@typeInfo(T).Int.is_signed) .signed else .unsigned, @typeInfo(T).Int.bits + 1);
860860 comptime const shiftType = std.math.Log2Int(PromotedType);
861861 return @as(PromotedType, 1) << @intCast(shiftType, @typeInfo(T).Int.bits - @clz(T, value - 1));
862862}
......@@ -868,7 +868,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
868868 comptime assert(@typeInfo(T) == .Int);
869869 const info = @typeInfo(T).Int;
870870 comptime assert(!info.is_signed);
871 comptime const PromotedType = std.meta.Int(info.is_signed, info.bits + 1);
871 comptime const PromotedType = std.meta.Int(if (info.is_signed) .signed else .unsigned, info.bits + 1);
872872 comptime const overflowBit = @as(PromotedType, 1) << info.bits;
873873 var x = ceilPowerOfTwoPromote(T, value);
874874 if (overflowBit & x != 0) {
......@@ -1014,8 +1014,8 @@ test "max value type" {
10141014 testing.expect(x == 2147483647);
10151015}
10161016
1017pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(@typeInfo(T).Int.is_signed, @typeInfo(T).Int.bits * 2) {
1018 const ResultInt = std.meta.Int(@typeInfo(T).Int.is_signed, @typeInfo(T).Int.bits * 2);
1017pub fn mulWide(comptime T: type, a: T, b: T) std.meta.Int(if (@typeInfo(T).Int.is_signed) .signed else .unsigned, @typeInfo(T).Int.bits * 2) {
1018 const ResultInt = std.meta.Int(if (@typeInfo(T).Int.is_signed) .signed else .unsigned, @typeInfo(T).Int.bits * 2);
10191019 return @as(ResultInt, a) * @as(ResultInt, b);
10201020}
10211021
lib/std/math/big.zig+2-2
......@@ -10,8 +10,8 @@ pub const Rational = @import("big/rational.zig").Rational;
1010pub const int = @import("big/int.zig");
1111pub const Limb = usize;
1212const limb_info = @typeInfo(Limb).Int;
13pub const DoubleLimb = std.meta.IntType(false, 2 * limb_info.bits);
14pub const SignedDoubleLimb = std.meta.IntType(true, 2 * limb_info.bits);
13pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits);
14pub const SignedDoubleLimb = std.meta.Int(.signed, 2 * limb_info.bits);
1515pub const Log2Limb = std.math.Log2Int(Limb);
1616
1717comptime {
lib/std/math/big/int.zig+3-3
......@@ -24,7 +24,7 @@ pub fn calcLimbLen(scalar: anytype) usize {
2424 const T = @TypeOf(scalar);
2525 switch (@typeInfo(T)) {
2626 .Int => |info| {
27 const UT = if (info.is_signed) std.meta.Int(false, info.bits - 1) else T;
27 const UT = if (info.is_signed) std.meta.Int(.unsigned, info.bits - 1) else T;
2828 return @sizeOf(UT) / @sizeOf(Limb);
2929 },
3030 .ComptimeInt => {
......@@ -187,7 +187,7 @@ pub const Mutable = struct {
187187
188188 switch (@typeInfo(T)) {
189189 .Int => |info| {
190 const UT = if (info.is_signed) std.meta.Int(false, info.bits - 1) else T;
190 const UT = if (info.is_signed) std.meta.Int(.unsigned, info.bits - 1) else T;
191191
192192 const needed_limbs = @sizeOf(UT) / @sizeOf(Limb);
193193 assert(needed_limbs <= self.limbs.len); // value too big
......@@ -1092,7 +1092,7 @@ pub const Const = struct {
10921092 pub fn to(self: Const, comptime T: type) ConvertError!T {
10931093 switch (@typeInfo(T)) {
10941094 .Int => |info| {
1095 const UT = std.meta.Int(false, info.bits);
1095 const UT = std.meta.Int(.unsigned, info.bits);
10961096
10971097 if (self.bitCountTwosComp() > info.bits) {
10981098 return error.TargetTooSmall;
lib/std/math/big/rational.zig+2-2
......@@ -136,7 +136,7 @@ pub const Rational = struct {
136136 // Translated from golang.go/src/math/big/rat.go.
137137 debug.assert(@typeInfo(T) == .Float);
138138
139 const UnsignedInt = std.meta.Int(false, @typeInfo(T).Float.bits);
139 const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
140140 const f_bits = @bitCast(UnsignedInt, f);
141141
142142 const exponent_bits = math.floatExponentBits(T);
......@@ -195,7 +195,7 @@ pub const Rational = struct {
195195 debug.assert(@typeInfo(T) == .Float);
196196
197197 const fsize = @typeInfo(T).Float.bits;
198 const BitReprType = std.meta.Int(false, fsize);
198 const BitReprType = std.meta.Int(.unsigned, fsize);
199199
200200 const msize = math.floatMantissaBits(T);
201201 const msize1 = msize + 1;
lib/std/math/cos.zig+1-1
......@@ -49,7 +49,7 @@ const pi4c = 2.69515142907905952645E-15;
4949const m4pi = 1.273239544735162542821171882678754627704620361328125;
5050
5151fn cos_(comptime T: type, x_: T) T {
52 const I = std.meta.Int(true, @typeInfo(T).Float.bits);
52 const I = std.meta.Int(.signed, @typeInfo(T).Float.bits);
5353
5454 var x = x_;
5555 if (math.isNan(x) or math.isInf(x)) {
lib/std/math/pow.zig+1-1
......@@ -150,7 +150,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
150150 var xe = r2.exponent;
151151 var x1 = r2.significand;
152152
153 var i = @floatToInt(std.meta.Int(true, @typeInfo(T).Float.bits), yi);
153 var i = @floatToInt(std.meta.Int(.signed, @typeInfo(T).Float.bits), yi);
154154 while (i != 0) : (i >>= 1) {
155155 const overflow_shift = math.floatExponentBits(T) + 1;
156156 if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {
lib/std/math/sin.zig+1-1
......@@ -50,7 +50,7 @@ const pi4c = 2.69515142907905952645E-15;
5050const m4pi = 1.273239544735162542821171882678754627704620361328125;
5151
5252fn sin_(comptime T: type, x_: T) T {
53 const I = std.meta.Int(true, @typeInfo(T).Float.bits);
53 const I = std.meta.Int(.signed, @typeInfo(T).Float.bits);
5454
5555 var x = x_;
5656 if (x == 0 or math.isNan(x)) {
lib/std/math/sqrt.zig+3-3
......@@ -36,7 +36,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
3636 }
3737}
3838
39fn sqrt_int(comptime T: type, value: T) std.meta.Int(false, @typeInfo(T).Int.bits / 2) {
39fn sqrt_int(comptime T: type, value: T) std.meta.Int(.unsigned, @typeInfo(T).Int.bits / 2) {
4040 var op = value;
4141 var res: T = 0;
4242 var one: T = 1 << (@typeInfo(T).Int.bits - 2);
......@@ -55,7 +55,7 @@ fn sqrt_int(comptime T: type, value: T) std.meta.Int(false, @typeInfo(T).Int.bit
5555 one >>= 2;
5656 }
5757
58 const ResultType = std.meta.Int(false, @typeInfo(T).Int.bits / 2);
58 const ResultType = std.meta.Int(.unsigned, @typeInfo(T).Int.bits / 2);
5959 return @intCast(ResultType, res);
6060}
6161
......@@ -71,7 +71,7 @@ test "math.sqrt_int" {
7171/// Returns the return type `sqrt` will return given an operand of type `T`.
7272pub fn Sqrt(comptime T: type) type {
7373 return switch (@typeInfo(T)) {
74 .Int => |int| std.meta.Int(false, int.bits / 2),
74 .Int => |int| std.meta.Int(.unsigned, int.bits / 2),
7575 else => T,
7676 };
7777}
lib/std/math/tan.zig+1-1
......@@ -43,7 +43,7 @@ const pi4c = 2.69515142907905952645E-15;
4343const m4pi = 1.273239544735162542821171882678754627704620361328125;
4444
4545fn tan_(comptime T: type, x_: T) T {
46 const I = std.meta.Int(true, @typeInfo(T).Float.bits);
46 const I = std.meta.Int(.signed, @typeInfo(T).Float.bits);
4747
4848 var x = x_;
4949 if (x == 0 or math.isNan(x)) {
lib/std/mem.zig+2-2
......@@ -1106,7 +1106,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
11061106 return set(u8, buffer, 0);
11071107
11081108 // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough
1109 const uint = std.meta.Int(false, @typeInfo(T).Int.bits);
1109 const uint = std.meta.Int(.unsigned, @typeInfo(T).Int.bits);
11101110 var bits = @truncate(uint, value);
11111111 for (buffer) |*b| {
11121112 b.* = @truncate(u8, bits);
......@@ -1126,7 +1126,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
11261126 return set(u8, buffer, 0);
11271127
11281128 // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough
1129 const uint = std.meta.Int(false, @typeInfo(T).Int.bits);
1129 const uint = std.meta.Int(.unsigned, @typeInfo(T).Int.bits);
11301130 var bits = @truncate(uint, value);
11311131 var index: usize = buffer.len;
11321132 while (index != 0) {
lib/std/meta.zig+7-2
......@@ -678,10 +678,15 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
678678/// Deprecated: use Int
679679pub const IntType = Int;
680680
681pub fn Int(comptime is_signed: bool, comptime bit_count: u16) type {
681pub const Signedness = enum {
682 unsigned,
683 signed,
684};
685
686pub fn Int(comptime signedness: Signedness, comptime bit_count: u16) type {
682687 return @Type(TypeInfo{
683688 .Int = .{
684 .is_signed = is_signed,
689 .is_signed = signedness == .signed,
685690 .bits = bit_count,
686691 },
687692 });
lib/std/meta/trailer_flags.zig+1-1
......@@ -18,7 +18,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
1818 return struct {
1919 bits: Int,
2020
21 pub const Int = meta.Int(false, bit_count);
21 pub const Int = meta.Int(.unsigned, bit_count);
2222 pub const bit_count = @typeInfo(Fields).Struct.fields.len;
2323
2424 pub const FieldEnum = blk: {
lib/std/os.zig+1-1
......@@ -4494,7 +4494,7 @@ pub fn res_mkquery(
44944494 // Make a reasonably unpredictable id
44954495 var ts: timespec = undefined;
44964496 clock_gettime(CLOCK_REALTIME, &ts) catch {};
4497 const UInt = std.meta.Int(false, std.meta.bitCount(@TypeOf(ts.tv_nsec)));
4497 const UInt = std.meta.Int(.unsigned, std.meta.bitCount(@TypeOf(ts.tv_nsec)));
44984498 const unsec = @bitCast(UInt, ts.tv_nsec);
44994499 const id = @truncate(u32, unsec + unsec / 65536);
45004500 q[0] = @truncate(u8, id / 256);
lib/std/os/bits/linux.zig+1-1
......@@ -1073,7 +1073,7 @@ pub const dl_phdr_info = extern struct {
10731073
10741074pub const CPU_SETSIZE = 128;
10751075pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;
1076pub const cpu_count_t = std.meta.Int(false, std.math.log2(CPU_SETSIZE * 8));
1076pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8));
10771077
10781078pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
10791079 var sum: cpu_count_t = 0;
lib/std/packed_int_array.zig+4-4
......@@ -39,13 +39,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
3939
4040 //we bitcast the desired Int type to an unsigned version of itself
4141 // to avoid issues with shifting signed ints.
42 const UnInt = std.meta.Int(false, int_bits);
42 const UnInt = std.meta.Int(.unsigned, int_bits);
4343
4444 //The maximum container int type
45 const MinIo = std.meta.Int(false, min_io_bits);
45 const MinIo = std.meta.Int(.unsigned, min_io_bits);
4646
4747 //The minimum container int type
48 const MaxIo = std.meta.Int(false, max_io_bits);
48 const MaxIo = std.meta.Int(.unsigned, max_io_bits);
4949
5050 return struct {
5151 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {
......@@ -416,7 +416,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {
416416
417417 comptime var bits = 0;
418418 inline while (bits <= max_bits) : (bits += 1) {
419 const Int = std.meta.Int(false, bits);
419 const Int = std.meta.Int(.unsigned, bits);
420420
421421 const PackedArray = PackedIntArray(Int, int_count);
422422 var packed_array = @as(PackedArray, undefined);
lib/std/rand.zig+10-10
......@@ -52,8 +52,8 @@ pub const Random = struct {
5252 /// `i` is evenly distributed.
5353 pub fn int(r: *Random, comptime T: type) T {
5454 const bits = @typeInfo(T).Int.bits;
55 const UnsignedT = std.meta.Int(false, bits);
56 const ByteAlignedT = std.meta.Int(false, @divTrunc(bits + 7, 8) * 8);
55 const UnsignedT = std.meta.Int(.unsigned, bits);
56 const ByteAlignedT = std.meta.Int(.unsigned, @divTrunc(bits + 7, 8) * 8);
5757
5858 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;
5959 r.bytes(rand_bytes[0..]);
......@@ -95,9 +95,9 @@ pub const Random = struct {
9595 assert(0 < less_than);
9696 // Small is typically u32
9797 const small_bits = @divTrunc(bits + 31, 32) * 32;
98 const Small = std.meta.Int(false, small_bits);
98 const Small = std.meta.Int(.unsigned, small_bits);
9999 // Large is typically u64
100 const Large = std.meta.Int(false, small_bits * 2);
100 const Large = std.meta.Int(.unsigned, small_bits * 2);
101101
102102 // adapted from:
103103 // http://www.pcg-random.org/posts/bounded-rands.html
......@@ -109,7 +109,7 @@ pub const Random = struct {
109109 // TODO: workaround for https://github.com/ziglang/zig/issues/1770
110110 // should be:
111111 // var t: Small = -%less_than;
112 var t: Small = @bitCast(Small, -%@bitCast(std.meta.Int(true, small_bits), @as(Small, less_than)));
112 var t: Small = @bitCast(Small, -%@bitCast(std.meta.Int(.signed, small_bits), @as(Small, less_than)));
113113
114114 if (t >= less_than) {
115115 t -= less_than;
......@@ -156,7 +156,7 @@ pub const Random = struct {
156156 const info = @typeInfo(T).Int;
157157 if (info.is_signed) {
158158 // Two's complement makes this math pretty easy.
159 const UnsignedT = std.meta.Int(false, info.bits);
159 const UnsignedT = std.meta.Int(.unsigned, info.bits);
160160 const lo = @bitCast(UnsignedT, at_least);
161161 const hi = @bitCast(UnsignedT, less_than);
162162 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);
......@@ -175,7 +175,7 @@ pub const Random = struct {
175175 const info = @typeInfo(T).Int;
176176 if (info.is_signed) {
177177 // Two's complement makes this math pretty easy.
178 const UnsignedT = std.meta.Int(false, info.bits);
178 const UnsignedT = std.meta.Int(.unsigned, info.bits);
179179 const lo = @bitCast(UnsignedT, at_least);
180180 const hi = @bitCast(UnsignedT, less_than);
181181 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);
......@@ -193,7 +193,7 @@ pub const Random = struct {
193193 const info = @typeInfo(T).Int;
194194 if (info.is_signed) {
195195 // Two's complement makes this math pretty easy.
196 const UnsignedT = std.meta.Int(false, info.bits);
196 const UnsignedT = std.meta.Int(.unsigned, info.bits);
197197 const lo = @bitCast(UnsignedT, at_least);
198198 const hi = @bitCast(UnsignedT, at_most);
199199 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);
......@@ -212,7 +212,7 @@ pub const Random = struct {
212212 const info = @typeInfo(T).Int;
213213 if (info.is_signed) {
214214 // Two's complement makes this math pretty easy.
215 const UnsignedT = std.meta.Int(false, info.bits);
215 const UnsignedT = std.meta.Int(.unsigned, info.bits);
216216 const lo = @bitCast(UnsignedT, at_least);
217217 const hi = @bitCast(UnsignedT, at_most);
218218 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);
......@@ -290,7 +290,7 @@ pub const Random = struct {
290290pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
291291 comptime assert(@typeInfo(T).Int.is_signed == false);
292292 const bits = @typeInfo(T).Int.bits;
293 const T2 = std.meta.Int(false, bits * 2);
293 const T2 = std.meta.Int(.unsigned, bits * 2);
294294
295295 // adapted from:
296296 // http://www.pcg-random.org/posts/bounded-rands.html
lib/std/special/c.zig+1-1
......@@ -652,7 +652,7 @@ fn generic_fmod(comptime T: type, x: T, y: T) T {
652652 @setRuntimeSafety(false);
653653
654654 const bits = @typeInfo(T).Float.bits;
655 const uint = std.meta.Int(false, bits);
655 const uint = std.meta.Int(.unsigned, bits);
656656 const log2uint = math.Log2Int(uint);
657657 const digits = if (T == f32) 23 else 52;
658658 const exp_bits = if (T == f32) 9 else 12;
lib/std/special/compiler_rt/addXf3.zig+7-7
......@@ -59,14 +59,14 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
5959}
6060
6161// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
62fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 {
62fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
6363 const bits = @typeInfo(T).Float.bits;
64 const Z = std.meta.Int(false, bits);
65 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));
64 const Z = std.meta.Int(.unsigned, bits);
65 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
6666 const significandBits = std.math.floatMantissaBits(T);
6767 const implicitBit = @as(Z, 1) << significandBits;
6868
69 const shift = @clz(std.meta.Int(false, bits), significand.*) - @clz(Z, implicitBit);
69 const shift = @clz(std.meta.Int(.unsigned, bits), significand.*) - @clz(Z, implicitBit);
7070 significand.* <<= @intCast(S, shift);
7171 return 1 - shift;
7272}
......@@ -74,8 +74,8 @@ fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Fl
7474// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
7575fn addXf3(comptime T: type, a: T, b: T) T {
7676 const bits = @typeInfo(T).Float.bits;
77 const Z = std.meta.Int(false, bits);
78 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));
77 const Z = std.meta.Int(.unsigned, bits);
78 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
7979
8080 const typeWidth = bits;
8181 const significandBits = std.math.floatMantissaBits(T);
......@@ -189,7 +189,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
189189 // If partial cancellation occured, we need to left-shift the result
190190 // and adjust the exponent:
191191 if (aSignificand < implicitBit << 3) {
192 const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.Int(false, bits), implicitBit << 3));
192 const shift = @intCast(i32, @clz(Z, aSignificand)) - @intCast(i32, @clz(std.meta.Int(.unsigned, bits), implicitBit << 3));
193193 aSignificand <<= @intCast(S, shift);
194194 aExponent -= shift;
195195 }
lib/std/special/compiler_rt/compareXf2.zig+3-3
......@@ -28,8 +28,8 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
2828 @setRuntimeSafety(builtin.is_test);
2929
3030 const bits = @typeInfo(T).Float.bits;
31 const srep_t = std.meta.Int(true, bits);
32 const rep_t = std.meta.Int(false, bits);
31 const srep_t = std.meta.Int(.signed, bits);
32 const rep_t = std.meta.Int(.unsigned, bits);
3333
3434 const significandBits = std.math.floatMantissaBits(T);
3535 const exponentBits = std.math.floatExponentBits(T);
......@@ -74,7 +74,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
7474pub fn unordcmp(comptime T: type, a: T, b: T) i32 {
7575 @setRuntimeSafety(builtin.is_test);
7676
77 const rep_t = std.meta.Int(false, @typeInfo(T).Float.bits);
77 const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
7878
7979 const significandBits = std.math.floatMantissaBits(T);
8080 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/divdf3.zig+4-4
......@@ -12,8 +12,8 @@ const builtin = @import("builtin");
1212
1313pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
1414 @setRuntimeSafety(builtin.is_test);
15 const Z = std.meta.Int(false, 64);
16 const SignedZ = std.meta.Int(true, 64);
15 const Z = std.meta.Int(.unsigned, 64);
16 const SignedZ = std.meta.Int(.signed, 64);
1717
1818 const significandBits = std.math.floatMantissaBits(f64);
1919 const exponentBits = std.math.floatExponentBits(f64);
......@@ -316,9 +316,9 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
316316 }
317317}
318318
319pub fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 {
319pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
320320 @setRuntimeSafety(builtin.is_test);
321 const Z = std.meta.Int(false, @typeInfo(T).Float.bits);
321 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
322322 const significandBits = std.math.floatMantissaBits(T);
323323 const implicitBit = @as(Z, 1) << significandBits;
324324
lib/std/special/compiler_rt/divsf3.zig+3-3
......@@ -12,7 +12,7 @@ const builtin = @import("builtin");
1212
1313pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
1414 @setRuntimeSafety(builtin.is_test);
15 const Z = std.meta.Int(false, 32);
15 const Z = std.meta.Int(.unsigned, 32);
1616
1717 const significandBits = std.math.floatMantissaBits(f32);
1818 const exponentBits = std.math.floatExponentBits(f32);
......@@ -189,9 +189,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
189189 }
190190}
191191
192fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 {
192fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
193193 @setRuntimeSafety(builtin.is_test);
194 const Z = std.meta.Int(false, @typeInfo(T).Float.bits);
194 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
195195 const significandBits = std.math.floatMantissaBits(T);
196196 const implicitBit = @as(Z, 1) << significandBits;
197197
lib/std/special/compiler_rt/divtf3.zig+2-2
......@@ -11,8 +11,8 @@ const wideMultiply = @import("divdf3.zig").wideMultiply;
1111
1212pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
1313 @setRuntimeSafety(builtin.is_test);
14 const Z = std.meta.Int(false, 128);
15 const SignedZ = std.meta.Int(true, 128);
14 const Z = std.meta.Int(.unsigned, 128);
15 const SignedZ = std.meta.Int(.signed, 128);
1616
1717 const significandBits = std.math.floatMantissaBits(f128);
1818 const exponentBits = std.math.floatExponentBits(f128);
lib/std/special/compiler_rt/extendXfYf2.zig+3-3
......@@ -35,11 +35,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
3535
3636const CHAR_BIT = 8;
3737
38fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(false, @typeInfo(src_t).Float.bits)) dst_t {
38fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits)) dst_t {
3939 @setRuntimeSafety(builtin.is_test);
4040
41 const src_rep_t = std.meta.Int(false, @typeInfo(src_t).Float.bits);
42 const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits);
41 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits);
42 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
4343 const srcSigBits = std.math.floatMantissaBits(src_t);
4444 const dstSigBits = std.math.floatMantissaBits(dst_t);
4545 const SrcShift = std.math.Log2Int(src_rep_t);
lib/std/special/compiler_rt/fixint.zig+1-1
......@@ -51,7 +51,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
5151
5252 // The unsigned result needs to be large enough to handle an fixint_t or rep_t
5353 const fixint_bits = @typeInfo(fixint_t).Int.bits;
54 const fixuint_t = std.meta.Int(false, fixint_bits);
54 const fixuint_t = std.meta.Int(.unsigned, fixint_bits);
5555 const UintResultType = if (fixint_bits > typeWidth) fixuint_t else rep_t;
5656 var uint_result: UintResultType = undefined;
5757
lib/std/special/compiler_rt/fixuint.zig+1-1
......@@ -16,7 +16,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
1616 else => unreachable,
1717 };
1818 const typeWidth = @typeInfo(rep_t).Int.bits;
19 const srep_t = @import("std").meta.Int(true, typeWidth);
19 const srep_t = @import("std").meta.Int(.signed, typeWidth);
2020 const significandBits = switch (fp_t) {
2121 f32 => 23,
2222 f64 => 52,
lib/std/special/compiler_rt/floatXisf.zig+2-2
......@@ -13,8 +13,8 @@ fn __floatXisf(comptime T: type, arg: T) f32 {
1313 @setRuntimeSafety(builtin.is_test);
1414
1515 const bits = @typeInfo(T).Int.bits;
16 const Z = std.meta.Int(false, bits);
17 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));
16 const Z = std.meta.Int(.unsigned, bits);
17 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
1818
1919 if (arg == 0) {
2020 return @as(f32, 0.0);
lib/std/special/compiler_rt/floatsiXf.zig+2-2
......@@ -11,8 +11,8 @@ fn floatsiXf(comptime T: type, a: i32) T {
1111 @setRuntimeSafety(builtin.is_test);
1212
1313 const bits = @typeInfo(T).Float.bits;
14 const Z = std.meta.Int(false, bits);
15 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));
14 const Z = std.meta.Int(.unsigned, bits);
15 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
1616
1717 if (a == 0) {
1818 return @as(T, 0.0);
lib/std/special/compiler_rt/mulXf3.zig+3-3
......@@ -34,7 +34,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
3434fn mulXf3(comptime T: type, a: T, b: T) T {
3535 @setRuntimeSafety(builtin.is_test);
3636 const typeWidth = @typeInfo(T).Float.bits;
37 const Z = std.meta.Int(false, typeWidth);
37 const Z = std.meta.Int(.unsigned, typeWidth);
3838
3939 const significandBits = std.math.floatMantissaBits(T);
4040 const exponentBits = std.math.floatExponentBits(T);
......@@ -269,9 +269,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
269269 }
270270}
271271
272fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 {
272fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 {
273273 @setRuntimeSafety(builtin.is_test);
274 const Z = std.meta.Int(false, @typeInfo(T).Float.bits);
274 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
275275 const significandBits = std.math.floatMantissaBits(T);
276276 const implicitBit = @as(Z, 1) << significandBits;
277277
lib/std/special/compiler_rt/negXf2.zig+1-1
......@@ -24,7 +24,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
2424}
2525
2626fn negXf2(comptime T: type, a: T) T {
27 const Z = std.meta.Int(false, @typeInfo(T).Float.bits);
27 const Z = std.meta.Int(.unsigned, @typeInfo(T).Float.bits);
2828
2929 const significandBits = std.math.floatMantissaBits(T);
3030 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/shift.zig+2-2
......@@ -10,8 +10,8 @@ const Log2Int = std.math.Log2Int;
1010fn Dwords(comptime T: type, comptime signed_half: bool) type {
1111 return extern union {
1212 pub const bits = @divExact(@typeInfo(T).Int.bits, 2);
13 pub const HalfTU = std.meta.Int(false, bits);
14 pub const HalfTS = std.meta.Int(true, bits);
13 pub const HalfTU = std.meta.Int(.unsigned, bits);
14 pub const HalfTS = std.meta.Int(.signed, bits);
1515 pub const HalfT = if (signed_half) HalfTS else HalfTU;
1616
1717 all: T,
lib/std/special/compiler_rt/truncXfYf2.zig+2-2
......@@ -41,8 +41,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
4141}
4242
4343fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
44 const src_rep_t = std.meta.Int(false, @typeInfo(src_t).Float.bits);
45 const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits);
44 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits);
45 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
4646 const srcSigBits = std.math.floatMantissaBits(src_t);
4747 const dstSigBits = std.math.floatMantissaBits(dst_t);
4848 const SrcShift = std.math.Log2Int(src_rep_t);
lib/std/special/compiler_rt/udivmod.zig+2-2
......@@ -17,8 +17,8 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
1717
1818 const double_int_bits = @typeInfo(DoubleInt).Int.bits;
1919 const single_int_bits = @divExact(double_int_bits, 2);
20 const SingleInt = @import("std").meta.Int(false, single_int_bits);
21 const SignedDoubleInt = @import("std").meta.Int(true, double_int_bits);
20 const SingleInt = @import("std").meta.Int(.unsigned, single_int_bits);
21 const SignedDoubleInt = @import("std").meta.Int(.signed, double_int_bits);
2222 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
2323
2424 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
lib/std/target.zig+1-1
......@@ -554,7 +554,7 @@ pub const Target = struct {
554554 pub const needed_bit_count = 168;
555555 pub const byte_count = (needed_bit_count + 7) / 8;
556556 pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);
557 pub const Index = std.math.Log2Int(std.meta.Int(false, usize_count * @bitSizeOf(usize)));
557 pub const Index = std.math.Log2Int(std.meta.Int(.unsigned, usize_count * @bitSizeOf(usize)));
558558 pub const ShiftInt = std.math.Log2Int(usize);
559559
560560 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };