authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-17 18:55:25-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-10-17 18:55:25-04:00
log9052e0b1377e4c4cd23b979b4a486df27a3444bd
treebbba594e6093bbe420968882de3c345e82470794
parentfa17447090500b67c515c023376ab66201f8f088
parent132813849ce593db232751e55c0d0fe7636d87f1
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #6713 from jprudil/close-6697

Make std.meta.Int accept a signedness parameter

45 files changed, 126 insertions(+), 120 deletions(-)

lib/std/child_process.zig+1-1
...@@ -826,7 +826,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {...@@ -826,7 +826,7 @@ fn forkChildErrReport(fd: i32, err: ChildProcess.SpawnError) noreturn {
826 os.exit(1);826 os.exit(1);
827}827}
828828
829const ErrInt = std.meta.Int(false, @sizeOf(anyerror) * 8);829const ErrInt = std.meta.Int(.unsigned, @sizeOf(anyerror) * 8);
830830
831fn writeIntFd(fd: i32, value: ErrInt) !void {831fn writeIntFd(fd: i32, value: ErrInt) !void {
832 const file = File{832 const file = File{
lib/std/debug/leb128.zig+11-10
...@@ -55,7 +55,7 @@ pub fn writeULEB128(writer: anytype, uint_value: anytype) !void {...@@ -55,7 +55,7 @@ pub fn writeULEB128(writer: anytype, uint_value: anytype) !void {
55 }55 }
56}56}
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.
59/// The provided slice reference will be updated to point to the byte after the last byte read.59/// The provided slice reference will be updated to point to the byte after the last byte read.
60pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T {60pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T {
61 var buf = std.io.fixedBufferStream(ptr.*);61 var buf = std.io.fixedBufferStream(ptr.*);
...@@ -78,7 +78,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize {...@@ -78,7 +78,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize {
78/// or error.Overflow if the value cannot fit.78/// or error.Overflow if the value cannot fit.
79pub fn readILEB128(comptime T: type, reader: anytype) !T {79pub fn readILEB128(comptime T: type, reader: anytype) !T {
80 const S = if (@typeInfo(T).Int.bits < 8) i8 else T;80 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);
82 const ShiftU = std.math.Log2Int(U);82 const ShiftU = std.math.Log2Int(U);
8383
84 const max_group = (@typeInfo(U).Int.bits + 6) / 7;84 const max_group = (@typeInfo(U).Int.bits + 6) / 7;
...@@ -128,7 +128,7 @@ pub fn readILEB128(comptime T: type, reader: anytype) !T {...@@ -128,7 +128,7 @@ pub fn readILEB128(comptime T: type, reader: anytype) !T {
128pub fn writeILEB128(writer: anytype, int_value: anytype) !void {128pub fn writeILEB128(writer: anytype, int_value: anytype) !void {
129 const T = @TypeOf(int_value);129 const T = @TypeOf(int_value);
130 const S = if (@typeInfo(T).Int.bits < 8) i8 else T;130 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
133 var value = @intCast(S, int_value);133 var value = @intCast(S, int_value);
134134
...@@ -171,7 +171,7 @@ pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize {...@@ -171,7 +171,7 @@ pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize {
171/// An example use case of this is in emitting DWARF info where one wants to make a ULEB128 field171/// An example use case of this is in emitting DWARF info where one wants to make a ULEB128 field
172/// "relocatable", meaning that it becomes possible to later go back and patch the number to be a172/// "relocatable", meaning that it becomes possible to later go back and patch the number to be a
173/// different value without shifting all the following code.173/// 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 {
175 const T = @TypeOf(int);175 const T = @TypeOf(int);
176 const U = if (@typeInfo(T).Int.bits < 8) u8 else T;176 const U = if (@typeInfo(T).Int.bits < 8) u8 else T;
177 var value = @intCast(U, int);177 var value = @intCast(U, int);
...@@ -347,6 +347,7 @@ test "deserialize unsigned LEB128" {...@@ -347,6 +347,7 @@ test "deserialize unsigned LEB128" {
347fn test_write_leb128(value: anytype) !void {347fn test_write_leb128(value: anytype) !void {
348 const T = @TypeOf(value);348 const T = @TypeOf(value);
349 const t_signed = @typeInfo(T).Int.is_signed;349 const t_signed = @typeInfo(T).Int.is_signed;
350 const signedness = if (t_signed) .signed else .unsigned;
350351
351 const writeStream = if (t_signed) writeILEB128 else writeULEB128;352 const writeStream = if (t_signed) writeILEB128 else writeULEB128;
352 const writeMem = if (t_signed) writeILEB128Mem else writeULEB128Mem;353 const writeMem = if (t_signed) writeILEB128Mem else writeULEB128Mem;
...@@ -356,10 +357,10 @@ fn test_write_leb128(value: anytype) !void {...@@ -356,10 +357,10 @@ fn test_write_leb128(value: anytype) !void {
356 // decode to a larger bit size too, to ensure sign extension357 // decode to a larger bit size too, to ensure sign extension
357 // is working as expected358 // is working as expected
358 const larger_type_bits = ((@typeInfo(T).Int.bits + 8) / 8) * 8;359 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
361 const bytes_needed = bn: {362 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);
363 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);364 if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1);
364365
365 const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value);366 const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value);
...@@ -412,10 +413,10 @@ test "serialize unsigned LEB128" {...@@ -412,10 +413,10 @@ test "serialize unsigned LEB128" {
412413
413 comptime var t = 0;414 comptime var t = 0;
414 inline while (t <= max_bits) : (t += 1) {415 inline while (t <= max_bits) : (t += 1) {
415 const T = std.meta.Int(false, t);416 const T = std.meta.Int(.unsigned, t);
416 const min = std.math.minInt(T);417 const min = std.math.minInt(T);
417 const max = std.math.maxInt(T);418 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
420 while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i));421 while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i));
421 }422 }
...@@ -430,10 +431,10 @@ test "serialize signed LEB128" {...@@ -430,10 +431,10 @@ test "serialize signed LEB128" {
430431
431 comptime var t = 1;432 comptime var t = 1;
432 inline while (t <= max_bits) : (t += 1) {433 inline while (t <= max_bits) : (t += 1) {
433 const T = std.meta.Int(true, t);434 const T = std.meta.Int(.signed, t);
434 const min = std.math.minInt(T);435 const min = std.math.minInt(T);
435 const max = std.math.maxInt(T);436 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
438 while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i));439 while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i));
439 }440 }
lib/std/event/wait_group.zig+1-1
...@@ -22,7 +22,7 @@ const Loop = std.event.Loop;...@@ -22,7 +22,7 @@ const Loop = std.event.Loop;
22pub const WaitGroup = WaitGroupGeneric(std.meta.bitCount(usize));22pub const WaitGroup = WaitGroupGeneric(std.meta.bitCount(usize));
2323
24pub fn WaitGroupGeneric(comptime counter_size: u16) type {24pub 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
27 const global_event_loop = Loop.instance orelse27 const global_event_loop = Loop.instance orelse
28 @compileError("std.event.WaitGroup currently only works with event-based I/O");28 @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(...@@ -950,7 +950,7 @@ pub fn formatInt(
950 // The type must have the same size as `base` or be wider in order for the950 // The type must have the same size as `base` or be wider in order for the
951 // division to work951 // division to work
952 const min_int_bits = comptime math.max(value_info.bits, 8);952 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
955 const abs_value = math.absCast(int_value);955 const abs_value = math.absCast(int_value);
956 // The worst case in terms of space needed is base 2, plus 1 for the sign956 // 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" {...@@ -374,7 +374,7 @@ test "fmt.parseFloat" {
374 const epsilon = 1e-7;374 const epsilon = 1e-7;
375375
376 inline for ([_]type{ f16, f32, f64, f128 }) |T| {376 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
379 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));379 testing.expectError(error.InvalidCharacter, parseFloat(T, ""));
380 testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));380 testing.expectError(error.InvalidCharacter, parseFloat(T, " 1"));
lib/std/hash/wyhash.zig+1-1
...@@ -15,7 +15,7 @@ const primes = [_]u64{...@@ -15,7 +15,7 @@ const primes = [_]u64{
15};15};
1616
17fn read_bytes(comptime bytes: u8, data: []const u8) u64 {17fn 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);
19 return mem.readIntLittle(T, data[0..bytes]);19 return mem.readIntLittle(T, data[0..bytes]);
20}20}
2121
lib/std/heap.zig+1-1
...@@ -963,7 +963,7 @@ pub fn testAllocatorLargeAlignment(base_allocator: *mem.Allocator) mem.Allocator...@@ -963,7 +963,7 @@ pub fn testAllocatorLargeAlignment(base_allocator: *mem.Allocator) mem.Allocator
963 // very near usize?963 // very near usize?
964 if (mem.page_size << 2 > maxInt(usize)) return;964 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)));
967 const large_align = @as(u29, mem.page_size << 2);967 const large_align = @as(u29, mem.page_size << 2);
968968
969 var align_mask: usize = undefined;969 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;...@@ -107,7 +107,7 @@ const page_size = std.mem.page_size;
107const StackTrace = std.builtin.StackTrace;107const StackTrace = std.builtin.StackTrace;
108108
109/// Integer type for pointing to slots in a small allocation109/// 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
112const sys_can_stack_trace = switch (std.Target.current.cpu.arch) {112const sys_can_stack_trace = switch (std.Target.current.cpu.arch) {
113 // Observed to go into an infinite loop.113 // 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 {...@@ -60,7 +60,7 @@ pub fn BitReader(endian: builtin.Endian, comptime ReaderType: type) type {
60 assert(u_bit_count >= bits);60 assert(u_bit_count >= bits);
61 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;61 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
62 };62 };
63 const Buf = std.meta.Int(false, buf_bit_count);63 const Buf = std.meta.Int(.unsigned, buf_bit_count);
64 const BufShift = math.Log2Int(Buf);64 const BufShift = math.Log2Int(Buf);
6565
66 out_bits.* = @as(usize, 0);66 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 {...@@ -52,7 +52,7 @@ pub fn BitWriter(endian: builtin.Endian, comptime WriterType: type) type {
52 assert(u_bit_count >= bits);52 assert(u_bit_count >= bits);
53 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;53 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
54 };54 };
55 const Buf = std.meta.Int(false, buf_bit_count);55 const Buf = std.meta.Int(.unsigned, buf_bit_count);
56 const BufShift = math.Log2Int(Buf);56 const BufShift = math.Log2Int(Buf);
5757
58 const buf_value = @intCast(Buf, value);58 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,...@@ -58,7 +58,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
58 const u8_bit_count = 8;58 const u8_bit_count = 8;
59 const t_bit_count = comptime meta.bitCount(T);59 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);
62 const Log2U = math.Log2Int(U);62 const Log2U = math.Log2Int(U);
63 const int_size = (t_bit_count + 7) / 8;63 const int_size = (t_bit_count + 7) / 8;
6464
...@@ -73,7 +73,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,...@@ -73,7 +73,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing,
7373
74 if (int_size == 1) {74 if (int_size == 1) {
75 if (t_bit_count == 8) return @bitCast(T, buffer[0]);75 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);
77 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));77 return @truncate(T, @bitCast(PossiblySignedByte, buffer[0]));
78 }78 }
7979
...@@ -245,7 +245,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co...@@ -245,7 +245,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co
245 const t_bit_count = comptime meta.bitCount(T);245 const t_bit_count = comptime meta.bitCount(T);
246 const u8_bit_count = comptime meta.bitCount(u8);246 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);
249 const Log2U = math.Log2Int(U);249 const Log2U = math.Log2Int(U);
250 const int_size = (t_bit_count + 7) / 8;250 const int_size = (t_bit_count + 7) / 8;
251251
...@@ -381,8 +381,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi...@@ -381,8 +381,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
381381
382 comptime var i = 0;382 comptime var i = 0;
383 inline while (i <= max_test_bitsize) : (i += 1) {383 inline while (i <= max_test_bitsize) : (i += 1) {
384 const U = std.meta.Int(false, i);384 const U = std.meta.Int(.unsigned, i);
385 const S = std.meta.Int(true, i);385 const S = std.meta.Int(.signed, i);
386 try _serializer.serializeInt(@as(U, i));386 try _serializer.serializeInt(@as(U, i));
387 if (i != 0) try _serializer.serializeInt(@as(S, -1)) else try _serializer.serialize(@as(S, 0));387 if (i != 0) try _serializer.serializeInt(@as(S, -1)) else try _serializer.serialize(@as(S, 0));
388 }388 }
...@@ -390,8 +390,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi...@@ -390,8 +390,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi
390390
391 i = 0;391 i = 0;
392 inline while (i <= max_test_bitsize) : (i += 1) {392 inline while (i <= max_test_bitsize) : (i += 1) {
393 const U = std.meta.Int(false, i);393 const U = std.meta.Int(.unsigned, i);
394 const S = std.meta.Int(true, i);394 const S = std.meta.Int(.signed, i);
395 const x = try _deserializer.deserializeInt(U);395 const x = try _deserializer.deserializeInt(U);
396 const y = try _deserializer.deserializeInt(S);396 const y = try _deserializer.deserializeInt(S);
397 testing.expect(x == @as(U, i));397 testing.expect(x == @as(U, i));
lib/std/math.zig+13-13
...@@ -448,7 +448,7 @@ pub fn Log2Int(comptime T: type) type {...@@ -448,7 +448,7 @@ pub fn Log2Int(comptime T: type) type {
448 count += 1;448 count += 1;
449 }449 }
450450
451 return std.meta.Int(false, count);451 return std.meta.Int(.unsigned, count);
452}452}
453453
454pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) type {454pub 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...@@ -456,15 +456,15 @@ pub fn IntFittingRange(comptime from: comptime_int, comptime to: comptime_int) t
456 if (from == 0 and to == 0) {456 if (from == 0 and to == 0) {
457 return u0;457 return u0;
458 }458 }
459 const is_signed = from < 0;459 const sign: std.meta.Signedness = if (from < 0) .signed else .unsigned;
460 const largest_positive_integer = max(if (from < 0) (-from) - 1 else from, to); // two's complement460 const largest_positive_integer = max(if (from < 0) (-from) - 1 else from, to); // two's complement
461 const base = log2(largest_positive_integer);461 const base = log2(largest_positive_integer);
462 const upper = (1 << base) - 1;462 const upper = (1 << base) - 1;
463 var magnitude_bits = if (upper >= largest_positive_integer) base else base + 1;463 var magnitude_bits = if (upper >= largest_positive_integer) base else base + 1;
464 if (is_signed) {464 if (sign == .signed) {
465 magnitude_bits += 1;465 magnitude_bits += 1;
466 }466 }
467 return std.meta.Int(is_signed, magnitude_bits);467 return std.meta.Int(sign, magnitude_bits);
468}468}
469469
470test "math.IntFittingRange" {470test "math.IntFittingRange" {
...@@ -729,7 +729,7 @@ fn testRem() void {...@@ -729,7 +729,7 @@ fn testRem() void {
729/// Result is an unsigned integer.729/// Result is an unsigned integer.
730pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {730pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
731 .ComptimeInt => comptime_int,731 .ComptimeInt => comptime_int,
732 .Int => |intInfo| std.meta.Int(false, intInfo.bits),732 .Int => |intInfo| std.meta.Int(.unsigned, intInfo.bits),
733 else => @compileError("absCast only accepts integers"),733 else => @compileError("absCast only accepts integers"),
734} {734} {
735 switch (@typeInfo(@TypeOf(x))) {735 switch (@typeInfo(@TypeOf(x))) {
...@@ -741,7 +741,7 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {...@@ -741,7 +741,7 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) {
741 }741 }
742 },742 },
743 .Int => |intInfo| {743 .Int => |intInfo| {
744 const Uint = std.meta.Int(false, intInfo.bits);744 const Uint = std.meta.Int(.unsigned, intInfo.bits);
745 if (x < 0) {745 if (x < 0) {
746 return ~@bitCast(Uint, x +% -1);746 return ~@bitCast(Uint, x +% -1);
747 } else {747 } else {
...@@ -762,10 +762,10 @@ test "math.absCast" {...@@ -762,10 +762,10 @@ test "math.absCast" {
762762
763/// Returns the negation of the integer parameter.763/// Returns the negation of the integer parameter.
764/// Result is a signed integer.764/// 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))) {
766 if (@typeInfo(@TypeOf(x)).Int.is_signed) return negate(x);766 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)));
769 if (x > -minInt(int)) return error.Overflow;769 if (x > -minInt(int)) return error.Overflow;
770770
771 if (x == -minInt(int)) return minInt(int);771 if (x == -minInt(int)) return minInt(int);
...@@ -852,11 +852,11 @@ fn testFloorPowerOfTwo() void {...@@ -852,11 +852,11 @@ fn testFloorPowerOfTwo() void {
852/// Returns the next power of two (if the value is not already a power of two).852/// Returns the next power of two (if the value is not already a power of two).
853/// Only unsigned integers can be used. Zero is not an allowed input.853/// Only unsigned integers can be used. Zero is not an allowed input.
854/// Result is a type with 1 more bit than the input type.854/// 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) {
856 comptime assert(@typeInfo(T) == .Int);856 comptime assert(@typeInfo(T) == .Int);
857 comptime assert(!@typeInfo(T).Int.is_signed);857 comptime assert(!@typeInfo(T).Int.is_signed);
858 assert(value != 0);858 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);
860 comptime const shiftType = std.math.Log2Int(PromotedType);860 comptime const shiftType = std.math.Log2Int(PromotedType);
861 return @as(PromotedType, 1) << @intCast(shiftType, @typeInfo(T).Int.bits - @clz(T, value - 1));861 return @as(PromotedType, 1) << @intCast(shiftType, @typeInfo(T).Int.bits - @clz(T, value - 1));
862}862}
...@@ -868,7 +868,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {...@@ -868,7 +868,7 @@ pub fn ceilPowerOfTwo(comptime T: type, value: T) (error{Overflow}!T) {
868 comptime assert(@typeInfo(T) == .Int);868 comptime assert(@typeInfo(T) == .Int);
869 const info = @typeInfo(T).Int;869 const info = @typeInfo(T).Int;
870 comptime assert(!info.is_signed);870 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);
872 comptime const overflowBit = @as(PromotedType, 1) << info.bits;872 comptime const overflowBit = @as(PromotedType, 1) << info.bits;
873 var x = ceilPowerOfTwoPromote(T, value);873 var x = ceilPowerOfTwoPromote(T, value);
874 if (overflowBit & x != 0) {874 if (overflowBit & x != 0) {
...@@ -1014,8 +1014,8 @@ test "max value type" {...@@ -1014,8 +1014,8 @@ test "max value type" {
1014 testing.expect(x == 2147483647);1014 testing.expect(x == 2147483647);
1015}1015}
10161016
1017pub fn mulWide(comptime T: type, a: T, b: T) 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(@typeInfo(T).Int.is_signed, @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);
1019 return @as(ResultInt, a) * @as(ResultInt, b);1019 return @as(ResultInt, a) * @as(ResultInt, b);
1020}1020}
10211021
lib/std/math/big.zig+2-2
...@@ -10,8 +10,8 @@ pub const Rational = @import("big/rational.zig").Rational;...@@ -10,8 +10,8 @@ pub const Rational = @import("big/rational.zig").Rational;
10pub const int = @import("big/int.zig");10pub const int = @import("big/int.zig");
11pub const Limb = usize;11pub const Limb = usize;
12const limb_info = @typeInfo(Limb).Int;12const limb_info = @typeInfo(Limb).Int;
13pub const DoubleLimb = std.meta.IntType(false, 2 * limb_info.bits);13pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits);
14pub const SignedDoubleLimb = std.meta.IntType(true, 2 * limb_info.bits);14pub const SignedDoubleLimb = std.meta.Int(.signed, 2 * limb_info.bits);
15pub const Log2Limb = std.math.Log2Int(Limb);15pub const Log2Limb = std.math.Log2Int(Limb);
1616
17comptime {17comptime {
lib/std/math/big/int.zig+3-3
...@@ -24,7 +24,7 @@ pub fn calcLimbLen(scalar: anytype) usize {...@@ -24,7 +24,7 @@ pub fn calcLimbLen(scalar: anytype) usize {
24 const T = @TypeOf(scalar);24 const T = @TypeOf(scalar);
25 switch (@typeInfo(T)) {25 switch (@typeInfo(T)) {
26 .Int => |info| {26 .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;
28 return @sizeOf(UT) / @sizeOf(Limb);28 return @sizeOf(UT) / @sizeOf(Limb);
29 },29 },
30 .ComptimeInt => {30 .ComptimeInt => {
...@@ -187,7 +187,7 @@ pub const Mutable = struct {...@@ -187,7 +187,7 @@ pub const Mutable = struct {
187187
188 switch (@typeInfo(T)) {188 switch (@typeInfo(T)) {
189 .Int => |info| {189 .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
192 const needed_limbs = @sizeOf(UT) / @sizeOf(Limb);192 const needed_limbs = @sizeOf(UT) / @sizeOf(Limb);
193 assert(needed_limbs <= self.limbs.len); // value too big193 assert(needed_limbs <= self.limbs.len); // value too big
...@@ -1092,7 +1092,7 @@ pub const Const = struct {...@@ -1092,7 +1092,7 @@ pub const Const = struct {
1092 pub fn to(self: Const, comptime T: type) ConvertError!T {1092 pub fn to(self: Const, comptime T: type) ConvertError!T {
1093 switch (@typeInfo(T)) {1093 switch (@typeInfo(T)) {
1094 .Int => |info| {1094 .Int => |info| {
1095 const UT = std.meta.Int(false, info.bits);1095 const UT = std.meta.Int(.unsigned, info.bits);
10961096
1097 if (self.bitCountTwosComp() > info.bits) {1097 if (self.bitCountTwosComp() > info.bits) {
1098 return error.TargetTooSmall;1098 return error.TargetTooSmall;
lib/std/math/big/rational.zig+2-2
...@@ -136,7 +136,7 @@ pub const Rational = struct {...@@ -136,7 +136,7 @@ pub const Rational = struct {
136 // Translated from golang.go/src/math/big/rat.go.136 // Translated from golang.go/src/math/big/rat.go.
137 debug.assert(@typeInfo(T) == .Float);137 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);
140 const f_bits = @bitCast(UnsignedInt, f);140 const f_bits = @bitCast(UnsignedInt, f);
141141
142 const exponent_bits = math.floatExponentBits(T);142 const exponent_bits = math.floatExponentBits(T);
...@@ -195,7 +195,7 @@ pub const Rational = struct {...@@ -195,7 +195,7 @@ pub const Rational = struct {
195 debug.assert(@typeInfo(T) == .Float);195 debug.assert(@typeInfo(T) == .Float);
196196
197 const fsize = @typeInfo(T).Float.bits;197 const fsize = @typeInfo(T).Float.bits;
198 const BitReprType = std.meta.Int(false, fsize);198 const BitReprType = std.meta.Int(.unsigned, fsize);
199199
200 const msize = math.floatMantissaBits(T);200 const msize = math.floatMantissaBits(T);
201 const msize1 = msize + 1;201 const msize1 = msize + 1;
lib/std/math/cos.zig+1-1
...@@ -49,7 +49,7 @@ const pi4c = 2.69515142907905952645E-15;...@@ -49,7 +49,7 @@ const pi4c = 2.69515142907905952645E-15;
49const m4pi = 1.273239544735162542821171882678754627704620361328125;49const m4pi = 1.273239544735162542821171882678754627704620361328125;
5050
51fn cos_(comptime T: type, x_: T) T {51fn 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
54 var x = x_;54 var x = x_;
55 if (math.isNan(x) or math.isInf(x)) {55 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 {...@@ -150,7 +150,7 @@ pub fn pow(comptime T: type, x: T, y: T) T {
150 var xe = r2.exponent;150 var xe = r2.exponent;
151 var x1 = r2.significand;151 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);
154 while (i != 0) : (i >>= 1) {154 while (i != 0) : (i >>= 1) {
155 const overflow_shift = math.floatExponentBits(T) + 1;155 const overflow_shift = math.floatExponentBits(T) + 1;
156 if (xe < -(1 << overflow_shift) or (1 << overflow_shift) < xe) {156 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;...@@ -50,7 +50,7 @@ const pi4c = 2.69515142907905952645E-15;
50const m4pi = 1.273239544735162542821171882678754627704620361328125;50const m4pi = 1.273239544735162542821171882678754627704620361328125;
5151
52fn sin_(comptime T: type, x_: T) T {52fn 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
55 var x = x_;55 var x = x_;
56 if (x == 0 or math.isNan(x)) {56 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)) {...@@ -36,7 +36,7 @@ pub fn sqrt(x: anytype) Sqrt(@TypeOf(x)) {
36 }36 }
37}37}
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) {
40 var op = value;40 var op = value;
41 var res: T = 0;41 var res: T = 0;
42 var one: T = 1 << (@typeInfo(T).Int.bits - 2);42 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...@@ -55,7 +55,7 @@ fn sqrt_int(comptime T: type, value: T) std.meta.Int(false, @typeInfo(T).Int.bit
55 one >>= 2;55 one >>= 2;
56 }56 }
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);
59 return @intCast(ResultType, res);59 return @intCast(ResultType, res);
60}60}
6161
...@@ -71,7 +71,7 @@ test "math.sqrt_int" {...@@ -71,7 +71,7 @@ test "math.sqrt_int" {
71/// Returns the return type `sqrt` will return given an operand of type `T`.71/// Returns the return type `sqrt` will return given an operand of type `T`.
72pub fn Sqrt(comptime T: type) type {72pub fn Sqrt(comptime T: type) type {
73 return switch (@typeInfo(T)) {73 return switch (@typeInfo(T)) {
74 .Int => |int| std.meta.Int(false, int.bits / 2),74 .Int => |int| std.meta.Int(.unsigned, int.bits / 2),
75 else => T,75 else => T,
76 };76 };
77}77}
lib/std/math/tan.zig+1-1
...@@ -43,7 +43,7 @@ const pi4c = 2.69515142907905952645E-15;...@@ -43,7 +43,7 @@ const pi4c = 2.69515142907905952645E-15;
43const m4pi = 1.273239544735162542821171882678754627704620361328125;43const m4pi = 1.273239544735162542821171882678754627704620361328125;
4444
45fn tan_(comptime T: type, x_: T) T {45fn 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
48 var x = x_;48 var x = x_;
49 if (x == 0 or math.isNan(x)) {49 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 {...@@ -1106,7 +1106,7 @@ pub fn writeIntSliceLittle(comptime T: type, buffer: []u8, value: T) void {
1106 return set(u8, buffer, 0);1106 return set(u8, buffer, 0);
11071107
1108 // TODO I want to call writeIntLittle here but comptime eval facilities aren't good enough1108 // 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);
1110 var bits = @truncate(uint, value);1110 var bits = @truncate(uint, value);
1111 for (buffer) |*b| {1111 for (buffer) |*b| {
1112 b.* = @truncate(u8, bits);1112 b.* = @truncate(u8, bits);
...@@ -1126,7 +1126,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {...@@ -1126,7 +1126,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void {
1126 return set(u8, buffer, 0);1126 return set(u8, buffer, 0);
11271127
1128 // TODO I want to call writeIntBig here but comptime eval facilities aren't good enough1128 // 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);
1130 var bits = @truncate(uint, value);1130 var bits = @truncate(uint, value);
1131 var index: usize = buffer.len;1131 var index: usize = buffer.len;
1132 while (index != 0) {1132 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...@@ -678,10 +678,15 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
678/// Deprecated: use Int678/// Deprecated: use Int
679pub const IntType = Int;679pub 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 {
682 return @Type(TypeInfo{687 return @Type(TypeInfo{
683 .Int = .{688 .Int = .{
684 .is_signed = is_signed,689 .is_signed = signedness == .signed,
685 .bits = bit_count,690 .bits = bit_count,
686 },691 },
687 });692 });
lib/std/meta/trailer_flags.zig+1-1
...@@ -18,7 +18,7 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -18,7 +18,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
18 return struct {18 return struct {
19 bits: Int,19 bits: Int,
2020
21 pub const Int = meta.Int(false, bit_count);21 pub const Int = meta.Int(.unsigned, bit_count);
22 pub const bit_count = @typeInfo(Fields).Struct.fields.len;22 pub const bit_count = @typeInfo(Fields).Struct.fields.len;
2323
24 pub const FieldEnum = blk: {24 pub const FieldEnum = blk: {
lib/std/os.zig+1-1
...@@ -4494,7 +4494,7 @@ pub fn res_mkquery(...@@ -4494,7 +4494,7 @@ pub fn res_mkquery(
4494 // Make a reasonably unpredictable id4494 // Make a reasonably unpredictable id
4495 var ts: timespec = undefined;4495 var ts: timespec = undefined;
4496 clock_gettime(CLOCK_REALTIME, &ts) catch {};4496 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)));
4498 const unsec = @bitCast(UInt, ts.tv_nsec);4498 const unsec = @bitCast(UInt, ts.tv_nsec);
4499 const id = @truncate(u32, unsec + unsec / 65536);4499 const id = @truncate(u32, unsec + unsec / 65536);
4500 q[0] = @truncate(u8, id / 256);4500 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 {...@@ -1073,7 +1073,7 @@ pub const dl_phdr_info = extern struct {
10731073
1074pub const CPU_SETSIZE = 128;1074pub const CPU_SETSIZE = 128;
1075pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize;1075pub 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
1078pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {1078pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t {
1079 var sum: cpu_count_t = 0;1079 var sum: cpu_count_t = 0;
lib/std/packed_int_array.zig+8-8
...@@ -39,13 +39,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {...@@ -39,13 +39,13 @@ pub fn PackedIntIo(comptime Int: type, comptime endian: builtin.Endian) type {
3939
40 //we bitcast the desired Int type to an unsigned version of itself40 //we bitcast the desired Int type to an unsigned version of itself
41 // to avoid issues with shifting signed ints.41 // 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
44 //The maximum container int type44 //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
47 //The minimum container int type47 //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
50 return struct {50 return struct {
51 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {51 pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int {
...@@ -332,8 +332,8 @@ test "PackedIntArray" {...@@ -332,8 +332,8 @@ test "PackedIntArray" {
332 comptime var bits = 0;332 comptime var bits = 0;
333 inline while (bits <= max_bits) : (bits += 1) {333 inline while (bits <= max_bits) : (bits += 1) {
334 //alternate unsigned and signed334 //alternate unsigned and signed
335 const even = bits % 2 == 0;335 const sign: std.meta.Signedness = if (bits % 2 == 0) .signed else .unsigned;
336 const I = std.meta.Int(even, bits);336 const I = std.meta.Int(sign, bits);
337337
338 const PackedArray = PackedIntArray(I, int_count);338 const PackedArray = PackedIntArray(I, int_count);
339 const expected_bytes = ((bits * int_count) + 7) / 8;339 const expected_bytes = ((bits * int_count) + 7) / 8;
...@@ -384,8 +384,8 @@ test "PackedIntSlice" {...@@ -384,8 +384,8 @@ test "PackedIntSlice" {
384 comptime var bits = 0;384 comptime var bits = 0;
385 inline while (bits <= max_bits) : (bits += 1) {385 inline while (bits <= max_bits) : (bits += 1) {
386 //alternate unsigned and signed386 //alternate unsigned and signed
387 const even = bits % 2 == 0;387 const sign: std.meta.Signedness = if (bits % 2 == 0) .signed else .unsigned;
388 const I = std.meta.Int(even, bits);388 const I = std.meta.Int(sign, bits);
389 const P = PackedIntSlice(I);389 const P = PackedIntSlice(I);
390390
391 var data = P.init(&buffer, int_count);391 var data = P.init(&buffer, int_count);
...@@ -416,7 +416,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {...@@ -416,7 +416,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" {
416416
417 comptime var bits = 0;417 comptime var bits = 0;
418 inline while (bits <= max_bits) : (bits += 1) {418 inline while (bits <= max_bits) : (bits += 1) {
419 const Int = std.meta.Int(false, bits);419 const Int = std.meta.Int(.unsigned, bits);
420420
421 const PackedArray = PackedIntArray(Int, int_count);421 const PackedArray = PackedIntArray(Int, int_count);
422 var packed_array = @as(PackedArray, undefined);422 var packed_array = @as(PackedArray, undefined);
lib/std/rand.zig+10-10
...@@ -52,8 +52,8 @@ pub const Random = struct {...@@ -52,8 +52,8 @@ pub const Random = struct {
52 /// `i` is evenly distributed.52 /// `i` is evenly distributed.
53 pub fn int(r: *Random, comptime T: type) T {53 pub fn int(r: *Random, comptime T: type) T {
54 const bits = @typeInfo(T).Int.bits;54 const bits = @typeInfo(T).Int.bits;
55 const UnsignedT = std.meta.Int(false, bits);55 const UnsignedT = std.meta.Int(.unsigned, bits);
56 const ByteAlignedT = std.meta.Int(false, @divTrunc(bits + 7, 8) * 8);56 const ByteAlignedT = std.meta.Int(.unsigned, @divTrunc(bits + 7, 8) * 8);
5757
58 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;58 var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined;
59 r.bytes(rand_bytes[0..]);59 r.bytes(rand_bytes[0..]);
...@@ -95,9 +95,9 @@ pub const Random = struct {...@@ -95,9 +95,9 @@ pub const Random = struct {
95 assert(0 < less_than);95 assert(0 < less_than);
96 // Small is typically u3296 // Small is typically u32
97 const small_bits = @divTrunc(bits + 31, 32) * 32;97 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);
99 // Large is typically u6499 // 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
102 // adapted from:102 // adapted from:
103 // http://www.pcg-random.org/posts/bounded-rands.html103 // http://www.pcg-random.org/posts/bounded-rands.html
...@@ -109,7 +109,7 @@ pub const Random = struct {...@@ -109,7 +109,7 @@ pub const Random = struct {
109 // TODO: workaround for https://github.com/ziglang/zig/issues/1770109 // TODO: workaround for https://github.com/ziglang/zig/issues/1770
110 // should be:110 // should be:
111 // var t: Small = -%less_than;111 // 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
114 if (t >= less_than) {114 if (t >= less_than) {
115 t -= less_than;115 t -= less_than;
...@@ -156,7 +156,7 @@ pub const Random = struct {...@@ -156,7 +156,7 @@ pub const Random = struct {
156 const info = @typeInfo(T).Int;156 const info = @typeInfo(T).Int;
157 if (info.is_signed) {157 if (info.is_signed) {
158 // Two's complement makes this math pretty easy.158 // 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);
160 const lo = @bitCast(UnsignedT, at_least);160 const lo = @bitCast(UnsignedT, at_least);
161 const hi = @bitCast(UnsignedT, less_than);161 const hi = @bitCast(UnsignedT, less_than);
162 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);162 const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo);
...@@ -175,7 +175,7 @@ pub const Random = struct {...@@ -175,7 +175,7 @@ pub const Random = struct {
175 const info = @typeInfo(T).Int;175 const info = @typeInfo(T).Int;
176 if (info.is_signed) {176 if (info.is_signed) {
177 // Two's complement makes this math pretty easy.177 // 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);
179 const lo = @bitCast(UnsignedT, at_least);179 const lo = @bitCast(UnsignedT, at_least);
180 const hi = @bitCast(UnsignedT, less_than);180 const hi = @bitCast(UnsignedT, less_than);
181 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);181 const result = lo +% r.uintLessThan(UnsignedT, hi -% lo);
...@@ -193,7 +193,7 @@ pub const Random = struct {...@@ -193,7 +193,7 @@ pub const Random = struct {
193 const info = @typeInfo(T).Int;193 const info = @typeInfo(T).Int;
194 if (info.is_signed) {194 if (info.is_signed) {
195 // Two's complement makes this math pretty easy.195 // 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);
197 const lo = @bitCast(UnsignedT, at_least);197 const lo = @bitCast(UnsignedT, at_least);
198 const hi = @bitCast(UnsignedT, at_most);198 const hi = @bitCast(UnsignedT, at_most);
199 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);199 const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo);
...@@ -212,7 +212,7 @@ pub const Random = struct {...@@ -212,7 +212,7 @@ pub const Random = struct {
212 const info = @typeInfo(T).Int;212 const info = @typeInfo(T).Int;
213 if (info.is_signed) {213 if (info.is_signed) {
214 // Two's complement makes this math pretty easy.214 // 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);
216 const lo = @bitCast(UnsignedT, at_least);216 const lo = @bitCast(UnsignedT, at_least);
217 const hi = @bitCast(UnsignedT, at_most);217 const hi = @bitCast(UnsignedT, at_most);
218 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);218 const result = lo +% r.uintAtMost(UnsignedT, hi -% lo);
...@@ -290,7 +290,7 @@ pub const Random = struct {...@@ -290,7 +290,7 @@ pub const Random = struct {
290pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {290pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T {
291 comptime assert(@typeInfo(T).Int.is_signed == false);291 comptime assert(@typeInfo(T).Int.is_signed == false);
292 const bits = @typeInfo(T).Int.bits;292 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
295 // adapted from:295 // adapted from:
296 // http://www.pcg-random.org/posts/bounded-rands.html296 // 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 {...@@ -652,7 +652,7 @@ fn generic_fmod(comptime T: type, x: T, y: T) T {
652 @setRuntimeSafety(false);652 @setRuntimeSafety(false);
653653
654 const bits = @typeInfo(T).Float.bits;654 const bits = @typeInfo(T).Float.bits;
655 const uint = std.meta.Int(false, bits);655 const uint = std.meta.Int(.unsigned, bits);
656 const log2uint = math.Log2Int(uint);656 const log2uint = math.Log2Int(uint);
657 const digits = if (T == f32) 23 else 52;657 const digits = if (T == f32) 23 else 52;
658 const exp_bits = if (T == f32) 9 else 12;658 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 {...@@ -59,14 +59,14 @@ pub fn __aeabi_dsub(a: f64, b: f64) callconv(.AAPCS) f64 {
59}59}
6060
61// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/215461// 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 {
63 const bits = @typeInfo(T).Float.bits;63 const bits = @typeInfo(T).Float.bits;
64 const Z = std.meta.Int(false, bits);64 const Z = std.meta.Int(.unsigned, bits);
65 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));65 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
66 const significandBits = std.math.floatMantissaBits(T);66 const significandBits = std.math.floatMantissaBits(T);
67 const implicitBit = @as(Z, 1) << significandBits;67 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);
70 significand.* <<= @intCast(S, shift);70 significand.* <<= @intCast(S, shift);
71 return 1 - shift;71 return 1 - shift;
72}72}
...@@ -74,8 +74,8 @@ fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Fl...@@ -74,8 +74,8 @@ fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Fl
74// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/215474// TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154
75fn addXf3(comptime T: type, a: T, b: T) T {75fn addXf3(comptime T: type, a: T, b: T) T {
76 const bits = @typeInfo(T).Float.bits;76 const bits = @typeInfo(T).Float.bits;
77 const Z = std.meta.Int(false, bits);77 const Z = std.meta.Int(.unsigned, bits);
78 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));78 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
7979
80 const typeWidth = bits;80 const typeWidth = bits;
81 const significandBits = std.math.floatMantissaBits(T);81 const significandBits = std.math.floatMantissaBits(T);
...@@ -189,7 +189,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {...@@ -189,7 +189,7 @@ fn addXf3(comptime T: type, a: T, b: T) T {
189 // If partial cancellation occured, we need to left-shift the result189 // If partial cancellation occured, we need to left-shift the result
190 // and adjust the exponent:190 // and adjust the exponent:
191 if (aSignificand < implicitBit << 3) {191 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));
193 aSignificand <<= @intCast(S, shift);193 aSignificand <<= @intCast(S, shift);
194 aExponent -= shift;194 aExponent -= shift;
195 }195 }
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 {...@@ -28,8 +28,8 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
28 @setRuntimeSafety(builtin.is_test);28 @setRuntimeSafety(builtin.is_test);
2929
30 const bits = @typeInfo(T).Float.bits;30 const bits = @typeInfo(T).Float.bits;
31 const srep_t = std.meta.Int(true, bits);31 const srep_t = std.meta.Int(.signed, bits);
32 const rep_t = std.meta.Int(false, bits);32 const rep_t = std.meta.Int(.unsigned, bits);
3333
34 const significandBits = std.math.floatMantissaBits(T);34 const significandBits = std.math.floatMantissaBits(T);
35 const exponentBits = std.math.floatExponentBits(T);35 const exponentBits = std.math.floatExponentBits(T);
...@@ -74,7 +74,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {...@@ -74,7 +74,7 @@ pub fn cmp(comptime T: type, comptime RT: type, a: T, b: T) RT {
74pub fn unordcmp(comptime T: type, a: T, b: T) i32 {74pub fn unordcmp(comptime T: type, a: T, b: T) i32 {
75 @setRuntimeSafety(builtin.is_test);75 @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
79 const significandBits = std.math.floatMantissaBits(T);79 const significandBits = std.math.floatMantissaBits(T);
80 const exponentBits = std.math.floatExponentBits(T);80 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/divdf3.zig+4-4
...@@ -12,8 +12,8 @@ const builtin = @import("builtin");...@@ -12,8 +12,8 @@ const builtin = @import("builtin");
1212
13pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {13pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 {
14 @setRuntimeSafety(builtin.is_test);14 @setRuntimeSafety(builtin.is_test);
15 const Z = std.meta.Int(false, 64);15 const Z = std.meta.Int(.unsigned, 64);
16 const SignedZ = std.meta.Int(true, 64);16 const SignedZ = std.meta.Int(.signed, 64);
1717
18 const significandBits = std.math.floatMantissaBits(f64);18 const significandBits = std.math.floatMantissaBits(f64);
19 const exponentBits = std.math.floatExponentBits(f64);19 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 {...@@ -316,9 +316,9 @@ pub fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
316 }316 }
317}317}
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 {
320 @setRuntimeSafety(builtin.is_test);320 @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);
322 const significandBits = std.math.floatMantissaBits(T);322 const significandBits = std.math.floatMantissaBits(T);
323 const implicitBit = @as(Z, 1) << significandBits;323 const implicitBit = @as(Z, 1) << significandBits;
324324
lib/std/special/compiler_rt/divsf3.zig+3-3
...@@ -12,7 +12,7 @@ const builtin = @import("builtin");...@@ -12,7 +12,7 @@ const builtin = @import("builtin");
1212
13pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {13pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
14 @setRuntimeSafety(builtin.is_test);14 @setRuntimeSafety(builtin.is_test);
15 const Z = std.meta.Int(false, 32);15 const Z = std.meta.Int(.unsigned, 32);
1616
17 const significandBits = std.math.floatMantissaBits(f32);17 const significandBits = std.math.floatMantissaBits(f32);
18 const exponentBits = std.math.floatExponentBits(f32);18 const exponentBits = std.math.floatExponentBits(f32);
...@@ -189,9 +189,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {...@@ -189,9 +189,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 {
189 }189 }
190}190}
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 {
193 @setRuntimeSafety(builtin.is_test);193 @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);
195 const significandBits = std.math.floatMantissaBits(T);195 const significandBits = std.math.floatMantissaBits(T);
196 const implicitBit = @as(Z, 1) << significandBits;196 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;...@@ -11,8 +11,8 @@ const wideMultiply = @import("divdf3.zig").wideMultiply;
1111
12pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {12pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 {
13 @setRuntimeSafety(builtin.is_test);13 @setRuntimeSafety(builtin.is_test);
14 const Z = std.meta.Int(false, 128);14 const Z = std.meta.Int(.unsigned, 128);
15 const SignedZ = std.meta.Int(true, 128);15 const SignedZ = std.meta.Int(.signed, 128);
1616
17 const significandBits = std.math.floatMantissaBits(f128);17 const significandBits = std.math.floatMantissaBits(f128);
18 const exponentBits = std.math.floatExponentBits(f128);18 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 {...@@ -35,11 +35,11 @@ pub fn __aeabi_f2d(arg: f32) callconv(.AAPCS) f64 {
3535
36const CHAR_BIT = 8;36const 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 {
39 @setRuntimeSafety(builtin.is_test);39 @setRuntimeSafety(builtin.is_test);
4040
41 const src_rep_t = std.meta.Int(false, @typeInfo(src_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(false, @typeInfo(dst_t).Float.bits);42 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
43 const srcSigBits = std.math.floatMantissaBits(src_t);43 const srcSigBits = std.math.floatMantissaBits(src_t);
44 const dstSigBits = std.math.floatMantissaBits(dst_t);44 const dstSigBits = std.math.floatMantissaBits(dst_t);
45 const SrcShift = std.math.Log2Int(src_rep_t);45 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 {...@@ -51,7 +51,7 @@ pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
5151
52 // The unsigned result needs to be large enough to handle an fixint_t or rep_t52 // The unsigned result needs to be large enough to handle an fixint_t or rep_t
53 const fixint_bits = @typeInfo(fixint_t).Int.bits;53 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);
55 const UintResultType = if (fixint_bits > typeWidth) fixuint_t else rep_t;55 const UintResultType = if (fixint_bits > typeWidth) fixuint_t else rep_t;
56 var uint_result: UintResultType = undefined;56 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...@@ -16,7 +16,7 @@ pub fn fixuint(comptime fp_t: type, comptime fixuint_t: type, a: fp_t) fixuint_t
16 else => unreachable,16 else => unreachable,
17 };17 };
18 const typeWidth = @typeInfo(rep_t).Int.bits;18 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);
20 const significandBits = switch (fp_t) {20 const significandBits = switch (fp_t) {
21 f32 => 23,21 f32 => 23,
22 f64 => 52,22 f64 => 52,
lib/std/special/compiler_rt/floatXisf.zig+2-2
...@@ -13,8 +13,8 @@ fn __floatXisf(comptime T: type, arg: T) f32 {...@@ -13,8 +13,8 @@ fn __floatXisf(comptime T: type, arg: T) f32 {
13 @setRuntimeSafety(builtin.is_test);13 @setRuntimeSafety(builtin.is_test);
1414
15 const bits = @typeInfo(T).Int.bits;15 const bits = @typeInfo(T).Int.bits;
16 const Z = std.meta.Int(false, bits);16 const Z = std.meta.Int(.unsigned, bits);
17 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));17 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
1818
19 if (arg == 0) {19 if (arg == 0) {
20 return @as(f32, 0.0);20 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 {...@@ -11,8 +11,8 @@ fn floatsiXf(comptime T: type, a: i32) T {
11 @setRuntimeSafety(builtin.is_test);11 @setRuntimeSafety(builtin.is_test);
1212
13 const bits = @typeInfo(T).Float.bits;13 const bits = @typeInfo(T).Float.bits;
14 const Z = std.meta.Int(false, bits);14 const Z = std.meta.Int(.unsigned, bits);
15 const S = std.meta.Int(false, bits - @clz(Z, @as(Z, bits) - 1));15 const S = std.meta.Int(.unsigned, bits - @clz(Z, @as(Z, bits) - 1));
1616
17 if (a == 0) {17 if (a == 0) {
18 return @as(T, 0.0);18 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 {...@@ -34,7 +34,7 @@ pub fn __aeabi_dmul(a: f64, b: f64) callconv(.C) f64 {
34fn mulXf3(comptime T: type, a: T, b: T) T {34fn mulXf3(comptime T: type, a: T, b: T) T {
35 @setRuntimeSafety(builtin.is_test);35 @setRuntimeSafety(builtin.is_test);
36 const typeWidth = @typeInfo(T).Float.bits;36 const typeWidth = @typeInfo(T).Float.bits;
37 const Z = std.meta.Int(false, typeWidth);37 const Z = std.meta.Int(.unsigned, typeWidth);
3838
39 const significandBits = std.math.floatMantissaBits(T);39 const significandBits = std.math.floatMantissaBits(T);
40 const exponentBits = std.math.floatExponentBits(T);40 const exponentBits = std.math.floatExponentBits(T);
...@@ -269,9 +269,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {...@@ -269,9 +269,9 @@ fn wideMultiply(comptime Z: type, a: Z, b: Z, hi: *Z, lo: *Z) void {
269 }269 }
270}270}
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 {
273 @setRuntimeSafety(builtin.is_test);273 @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);
275 const significandBits = std.math.floatMantissaBits(T);275 const significandBits = std.math.floatMantissaBits(T);
276 const implicitBit = @as(Z, 1) << significandBits;276 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 {...@@ -24,7 +24,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 {
24}24}
2525
26fn negXf2(comptime T: type, a: T) T {26fn 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
29 const significandBits = std.math.floatMantissaBits(T);29 const significandBits = std.math.floatMantissaBits(T);
30 const exponentBits = std.math.floatExponentBits(T);30 const exponentBits = std.math.floatExponentBits(T);
lib/std/special/compiler_rt/shift.zig+2-2
...@@ -10,8 +10,8 @@ const Log2Int = std.math.Log2Int;...@@ -10,8 +10,8 @@ const Log2Int = std.math.Log2Int;
10fn Dwords(comptime T: type, comptime signed_half: bool) type {10fn Dwords(comptime T: type, comptime signed_half: bool) type {
11 return extern union {11 return extern union {
12 pub const bits = @divExact(@typeInfo(T).Int.bits, 2);12 pub const bits = @divExact(@typeInfo(T).Int.bits, 2);
13 pub const HalfTU = std.meta.Int(false, bits);13 pub const HalfTU = std.meta.Int(.unsigned, bits);
14 pub const HalfTS = std.meta.Int(true, bits);14 pub const HalfTS = std.meta.Int(.signed, bits);
15 pub const HalfT = if (signed_half) HalfTS else HalfTU;15 pub const HalfT = if (signed_half) HalfTS else HalfTU;
1616
17 all: T,17 all: T,
lib/std/special/compiler_rt/truncXfYf2.zig+2-2
...@@ -41,8 +41,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {...@@ -41,8 +41,8 @@ pub fn __aeabi_f2h(a: f32) callconv(.AAPCS) u16 {
41}41}
4242
43fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {43fn 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);44 const src_rep_t = std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits);
45 const dst_rep_t = std.meta.Int(false, @typeInfo(dst_t).Float.bits);45 const dst_rep_t = std.meta.Int(.unsigned, @typeInfo(dst_t).Float.bits);
46 const srcSigBits = std.math.floatMantissaBits(src_t);46 const srcSigBits = std.math.floatMantissaBits(src_t);
47 const dstSigBits = std.math.floatMantissaBits(dst_t);47 const dstSigBits = std.math.floatMantissaBits(dst_t);
48 const SrcShift = std.math.Log2Int(src_rep_t);48 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:...@@ -17,8 +17,8 @@ pub fn udivmod(comptime DoubleInt: type, a: DoubleInt, b: DoubleInt, maybe_rem:
1717
18 const double_int_bits = @typeInfo(DoubleInt).Int.bits;18 const double_int_bits = @typeInfo(DoubleInt).Int.bits;
19 const single_int_bits = @divExact(double_int_bits, 2);19 const single_int_bits = @divExact(double_int_bits, 2);
20 const SingleInt = @import("std").meta.Int(false, single_int_bits);20 const SingleInt = @import("std").meta.Int(.unsigned, single_int_bits);
21 const SignedDoubleInt = @import("std").meta.Int(true, double_int_bits);21 const SignedDoubleInt = @import("std").meta.Int(.signed, double_int_bits);
22 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);22 const Log2SingleInt = @import("std").math.Log2Int(SingleInt);
2323
24 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #42124 const n = @ptrCast(*const [2]SingleInt, &a).*; // TODO issue #421
lib/std/target.zig+1-1
...@@ -554,7 +554,7 @@ pub const Target = struct {...@@ -554,7 +554,7 @@ pub const Target = struct {
554 pub const needed_bit_count = 168;554 pub const needed_bit_count = 168;
555 pub const byte_count = (needed_bit_count + 7) / 8;555 pub const byte_count = (needed_bit_count + 7) / 8;
556 pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize);556 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)));
558 pub const ShiftInt = std.math.Log2Int(usize);558 pub const ShiftInt = std.math.Log2Int(usize);
559559
560 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };560 pub const empty = Set{ .ints = [1]usize{0} ** usize_count };
test/stage1/behavior/bit_shifting.zig+2-2
...@@ -3,10 +3,10 @@ const expect = std.testing.expect;...@@ -3,10 +3,10 @@ const expect = std.testing.expect;
33
4fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {4fn ShardedTable(comptime Key: type, comptime mask_bit_count: comptime_int, comptime V: type) type {
5 const key_bits = @typeInfo(Key).Int.bits;5 const key_bits = @typeInfo(Key).Int.bits;
6 expect(Key == std.meta.Int(false, key_bits));6 expect(Key == std.meta.Int(.unsigned, key_bits));
7 expect(key_bits >= mask_bit_count);7 expect(key_bits >= mask_bit_count);
8 const shard_key_bits = mask_bit_count;8 const shard_key_bits = mask_bit_count;
9 const ShardKey = std.meta.Int(false, mask_bit_count);9 const ShardKey = std.meta.Int(.unsigned, mask_bit_count);
10 const shift_amount = key_bits - shard_key_bits;10 const shift_amount = key_bits - shard_key_bits;
11 return struct {11 return struct {
12 const Self = @This();12 const Self = @This();