| author | |
| committer | |
| log | aadccc4206ea605719de789bc7c9c48557d02331 |
| tree | 631f4d25f6c8bf6cefdcbe58f3ac9f61434b6402 |
| parent | 245d98d32dd29e80de9732f415a4731748008acf |
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 { |
| 826 | 826 | os.exit(1); |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | const ErrInt = std.meta.Int(false, @sizeOf(anyerror) * 8); | |
| 829 | const ErrInt = std.meta.Int(.unsigned, @sizeOf(anyerror) * 8); | |
| 830 | 830 | |
| 831 | 831 | fn writeIntFd(fd: i32, value: ErrInt) !void { |
| 832 | 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 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 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 | 59 | /// The provided slice reference will be updated to point to the byte after the last byte read. |
| 60 | 60 | pub fn readULEB128Mem(comptime T: type, ptr: *[]const u8) !T { |
| 61 | 61 | var buf = std.io.fixedBufferStream(ptr.*); |
| ... | ... | @@ -78,7 +78,7 @@ pub fn writeULEB128Mem(ptr: []u8, uint_value: anytype) !usize { |
| 78 | 78 | /// or error.Overflow if the value cannot fit. |
| 79 | 79 | pub fn readILEB128(comptime T: type, reader: anytype) !T { |
| 80 | 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 | 82 | const ShiftU = std.math.Log2Int(U); |
| 83 | 83 | |
| 84 | 84 | const max_group = (@typeInfo(U).Int.bits + 6) / 7; |
| ... | ... | @@ -128,7 +128,7 @@ pub fn readILEB128(comptime T: type, reader: anytype) !T { |
| 128 | 128 | pub fn writeILEB128(writer: anytype, int_value: anytype) !void { |
| 129 | 129 | const T = @TypeOf(int_value); |
| 130 | 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); | |
| 132 | 132 | |
| 133 | 133 | var value = @intCast(S, int_value); |
| 134 | 134 | |
| ... | ... | @@ -171,7 +171,7 @@ pub fn writeILEB128Mem(ptr: []u8, int_value: anytype) !usize { |
| 171 | 171 | /// An example use case of this is in emitting DWARF info where one wants to make a ULEB128 field |
| 172 | 172 | /// "relocatable", meaning that it becomes possible to later go back and patch the number to be a |
| 173 | 173 | /// different value without shifting all the following code. |
| 174 | pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(false, l * 7)) void { | |
| 174 | pub fn writeUnsignedFixed(comptime l: usize, ptr: *[l]u8, int: std.meta.Int(.unsigned, l * 7)) void { | |
| 175 | 175 | const T = @TypeOf(int); |
| 176 | 176 | const U = if (@typeInfo(T).Int.bits < 8) u8 else T; |
| 177 | 177 | var value = @intCast(U, int); |
| ... | ... | @@ -347,6 +347,7 @@ test "deserialize unsigned LEB128" { |
| 347 | 347 | fn test_write_leb128(value: anytype) !void { |
| 348 | 348 | const T = @TypeOf(value); |
| 349 | 349 | const t_signed = @typeInfo(T).Int.is_signed; |
| 350 | const signedness = if (t_signed) .signed else .unsigned; | |
| 350 | 351 | |
| 351 | 352 | const writeStream = if (t_signed) writeILEB128 else writeULEB128; |
| 352 | 353 | const writeMem = if (t_signed) writeILEB128Mem else writeULEB128Mem; |
| ... | ... | @@ -356,10 +357,10 @@ fn test_write_leb128(value: anytype) !void { |
| 356 | 357 | // decode to a larger bit size too, to ensure sign extension |
| 357 | 358 | // is working as expected |
| 358 | 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); | |
| 360 | 361 | |
| 361 | 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 | 364 | if (@typeInfo(T).Int.bits <= 7) break :bn @as(u16, 1); |
| 364 | 365 | |
| 365 | 366 | const unused_bits = if (value < 0) @clz(T, ~value) else @clz(T, value); |
| ... | ... | @@ -412,10 +413,10 @@ test "serialize unsigned LEB128" { |
| 412 | 413 | |
| 413 | 414 | comptime var t = 0; |
| 414 | 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 | 417 | const min = std.math.minInt(T); |
| 417 | 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); | |
| 419 | 420 | |
| 420 | 421 | while (i <= max) : (i += 1) try test_write_leb128(@intCast(T, i)); |
| 421 | 422 | } |
| ... | ... | @@ -430,10 +431,10 @@ test "serialize signed LEB128" { |
| 430 | 431 | |
| 431 | 432 | comptime var t = 1; |
| 432 | 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 | 435 | const min = std.math.minInt(T); |
| 435 | 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); | |
| 437 | 438 | |
| 438 | 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 | 22 | pub const WaitGroup = WaitGroupGeneric(std.meta.bitCount(usize)); |
| 23 | 23 | |
| 24 | 24 | pub 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); | |
| 26 | 26 | |
| 27 | 27 | const global_event_loop = Loop.instance orelse |
| 28 | 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 | 950 | // The type must have the same size as `base` or be wider in order for the |
| 951 | 951 | // division to work |
| 952 | 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); | |
| 954 | 954 | |
| 955 | 955 | const abs_value = math.absCast(int_value); |
| 956 | 956 | // 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 | 374 | const epsilon = 1e-7; |
| 375 | 375 | |
| 376 | 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); | |
| 378 | 378 | |
| 379 | 379 | testing.expectError(error.InvalidCharacter, parseFloat(T, "")); |
| 380 | 380 | testing.expectError(error.InvalidCharacter, parseFloat(T, " 1")); |
lib/std/hash/wyhash.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ const primes = [_]u64{ |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | fn 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 | 19 | return mem.readIntLittle(T, data[0..bytes]); |
| 20 | 20 | } |
| 21 | 21 |
lib/std/heap.zig+1-1| ... | ... | @@ -963,7 +963,7 @@ pub fn testAllocatorLargeAlignment(base_allocator: *mem.Allocator) mem.Allocator |
| 963 | 963 | // very near usize? |
| 964 | 964 | if (mem.page_size << 2 > maxInt(usize)) return; |
| 965 | 965 | |
| 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 | 967 | const large_align = @as(u29, mem.page_size << 2); |
| 968 | 968 | |
| 969 | 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 | 107 | const StackTrace = std.builtin.StackTrace; |
| 108 | 108 | |
| 109 | 109 | /// Integer type for pointing to slots in a small allocation |
| 110 | const SlotIndex = std.meta.Int(false, math.log2(page_size) + 1); | |
| 110 | const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1); | |
| 111 | 111 | |
| 112 | 112 | const sys_can_stack_trace = switch (std.Target.current.cpu.arch) { |
| 113 | 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 | 60 | assert(u_bit_count >= bits); |
| 61 | 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 | 64 | const BufShift = math.Log2Int(Buf); |
| 65 | 65 | |
| 66 | 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 | 52 | assert(u_bit_count >= bits); |
| 53 | 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 | 56 | const BufShift = math.Log2Int(Buf); |
| 57 | 57 | |
| 58 | 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 | 58 | const u8_bit_count = 8; |
| 59 | 59 | const t_bit_count = comptime meta.bitCount(T); |
| 60 | 60 | |
| 61 | const U = std.meta.Int(false, t_bit_count); | |
| 61 | const U = std.meta.Int(.unsigned, t_bit_count); | |
| 62 | 62 | const Log2U = math.Log2Int(U); |
| 63 | 63 | const int_size = (t_bit_count + 7) / 8; |
| 64 | 64 | |
| ... | ... | @@ -73,7 +73,7 @@ pub fn Deserializer(comptime endian: builtin.Endian, comptime packing: Packing, |
| 73 | 73 | |
| 74 | 74 | if (int_size == 1) { |
| 75 | 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 | 77 | return @truncate(T, @bitCast(PossiblySignedByte, buffer[0])); |
| 78 | 78 | } |
| 79 | 79 | |
| ... | ... | @@ -245,7 +245,7 @@ pub fn Serializer(comptime endian: builtin.Endian, comptime packing: Packing, co |
| 245 | 245 | const t_bit_count = comptime meta.bitCount(T); |
| 246 | 246 | const u8_bit_count = comptime meta.bitCount(u8); |
| 247 | 247 | |
| 248 | const U = std.meta.Int(false, t_bit_count); | |
| 248 | const U = std.meta.Int(.unsigned, t_bit_count); | |
| 249 | 249 | const Log2U = math.Log2Int(U); |
| 250 | 250 | const int_size = (t_bit_count + 7) / 8; |
| 251 | 251 | |
| ... | ... | @@ -381,8 +381,8 @@ fn testIntSerializerDeserializer(comptime endian: builtin.Endian, comptime packi |
| 381 | 381 | |
| 382 | 382 | comptime var i = 0; |
| 383 | 383 | 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); | |
| 386 | 386 | try _serializer.serializeInt(@as(U, i)); |
| 387 | 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 | 390 | |
| 391 | 391 | i = 0; |
| 392 | 392 | 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); | |
| 395 | 395 | const x = try _deserializer.deserializeInt(U); |
| 396 | 396 | const y = try _deserializer.deserializeInt(S); |
| 397 | 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 | 448 | count += 1; |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | return std.meta.Int(false, count); | |
| 451 | return std.meta.Int(.unsigned, count); | |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | pub 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 | 456 | if (from == 0 and to == 0) { |
| 457 | 457 | return u0; |
| 458 | 458 | } |
| 459 | const is_signed = from < 0; | |
| 459 | const sign: std.meta.Signedness = if (from < 0) .signed else .unsigned; | |
| 460 | 460 | const largest_positive_integer = max(if (from < 0) (-from) - 1 else from, to); // two's complement |
| 461 | 461 | const base = log2(largest_positive_integer); |
| 462 | 462 | const upper = (1 << base) - 1; |
| 463 | 463 | var magnitude_bits = if (upper >= largest_positive_integer) base else base + 1; |
| 464 | if (is_signed) { | |
| 464 | if (sign == .signed) { | |
| 465 | 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 | } |
| 469 | 469 | |
| 470 | 470 | test "math.IntFittingRange" { |
| ... | ... | @@ -729,7 +729,7 @@ fn testRem() void { |
| 729 | 729 | /// Result is an unsigned integer. |
| 730 | 730 | pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { |
| 731 | 731 | .ComptimeInt => comptime_int, |
| 732 | .Int => |intInfo| std.meta.Int(false, intInfo.bits), | |
| 732 | .Int => |intInfo| std.meta.Int(.unsigned, intInfo.bits), | |
| 733 | 733 | else => @compileError("absCast only accepts integers"), |
| 734 | 734 | } { |
| 735 | 735 | switch (@typeInfo(@TypeOf(x))) { |
| ... | ... | @@ -741,7 +741,7 @@ pub fn absCast(x: anytype) switch (@typeInfo(@TypeOf(x))) { |
| 741 | 741 | } |
| 742 | 742 | }, |
| 743 | 743 | .Int => |intInfo| { |
| 744 | const Uint = std.meta.Int(false, intInfo.bits); | |
| 744 | const Uint = std.meta.Int(.unsigned, intInfo.bits); | |
| 745 | 745 | if (x < 0) { |
| 746 | 746 | return ~@bitCast(Uint, x +% -1); |
| 747 | 747 | } else { |
| ... | ... | @@ -762,10 +762,10 @@ test "math.absCast" { |
| 762 | 762 | |
| 763 | 763 | /// Returns the negation of the integer parameter. |
| 764 | 764 | /// Result is a signed integer. |
| 765 | pub fn negateCast(x: anytype) !std.meta.Int(true, std.meta.bitCount(@TypeOf(x))) { | |
| 765 | pub fn negateCast(x: anytype) !std.meta.Int(.signed, std.meta.bitCount(@TypeOf(x))) { | |
| 766 | 766 | if (@typeInfo(@TypeOf(x)).Int.is_signed) return negate(x); |
| 767 | 767 | |
| 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 | 769 | if (x > -minInt(int)) return error.Overflow; |
| 770 | 770 | |
| 771 | 771 | if (x == -minInt(int)) return minInt(int); |
| ... | ... | @@ -852,11 +852,11 @@ fn testFloorPowerOfTwo() void { |
| 852 | 852 | /// Returns the next power of two (if the value is not already a power of two). |
| 853 | 853 | /// Only unsigned integers can be used. Zero is not an allowed input. |
| 854 | 854 | /// Result is a type with 1 more bit than the input type. |
| 855 | pub fn ceilPowerOfTwoPromote(comptime T: type, value: T) std.meta.Int(@typeInfo(T).Int.is_signed, @typeInfo(T).Int.bits + 1) { | |
| 855 | pub 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 | 856 | comptime assert(@typeInfo(T) == .Int); |
| 857 | 857 | comptime assert(!@typeInfo(T).Int.is_signed); |
| 858 | 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 | 860 | comptime const shiftType = std.math.Log2Int(PromotedType); |
| 861 | 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 | 868 | comptime assert(@typeInfo(T) == .Int); |
| 869 | 869 | const info = @typeInfo(T).Int; |
| 870 | 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 | 872 | comptime const overflowBit = @as(PromotedType, 1) << info.bits; |
| 873 | 873 | var x = ceilPowerOfTwoPromote(T, value); |
| 874 | 874 | if (overflowBit & x != 0) { |
| ... | ... | @@ -1014,8 +1014,8 @@ test "max value type" { |
| 1014 | 1014 | testing.expect(x == 2147483647); |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | pub 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); | |
| 1017 | pub 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); | |
| 1019 | 1019 | return @as(ResultInt, a) * @as(ResultInt, b); |
| 1020 | 1020 | } |
| 1021 | 1021 |
lib/std/math/big.zig+2-2| ... | ... | @@ -10,8 +10,8 @@ pub const Rational = @import("big/rational.zig").Rational; |
| 10 | 10 | pub const int = @import("big/int.zig"); |
| 11 | 11 | pub const Limb = usize; |
| 12 | 12 | const limb_info = @typeInfo(Limb).Int; |
| 13 | pub const DoubleLimb = std.meta.IntType(false, 2 * limb_info.bits); | |
| 14 | pub const SignedDoubleLimb = std.meta.IntType(true, 2 * limb_info.bits); | |
| 13 | pub const DoubleLimb = std.meta.Int(.unsigned, 2 * limb_info.bits); | |
| 14 | pub const SignedDoubleLimb = std.meta.Int(.signed, 2 * limb_info.bits); | |
| 15 | 15 | pub const Log2Limb = std.math.Log2Int(Limb); |
| 16 | 16 | |
| 17 | 17 | comptime { |
lib/std/math/big/int.zig+3-3| ... | ... | @@ -24,7 +24,7 @@ pub fn calcLimbLen(scalar: anytype) usize { |
| 24 | 24 | const T = @TypeOf(scalar); |
| 25 | 25 | switch (@typeInfo(T)) { |
| 26 | 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 | 28 | return @sizeOf(UT) / @sizeOf(Limb); |
| 29 | 29 | }, |
| 30 | 30 | .ComptimeInt => { |
| ... | ... | @@ -187,7 +187,7 @@ pub const Mutable = struct { |
| 187 | 187 | |
| 188 | 188 | switch (@typeInfo(T)) { |
| 189 | 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; | |
| 191 | 191 | |
| 192 | 192 | const needed_limbs = @sizeOf(UT) / @sizeOf(Limb); |
| 193 | 193 | assert(needed_limbs <= self.limbs.len); // value too big |
| ... | ... | @@ -1092,7 +1092,7 @@ pub const Const = struct { |
| 1092 | 1092 | pub fn to(self: Const, comptime T: type) ConvertError!T { |
| 1093 | 1093 | switch (@typeInfo(T)) { |
| 1094 | 1094 | .Int => |info| { |
| 1095 | const UT = std.meta.Int(false, info.bits); | |
| 1095 | const UT = std.meta.Int(.unsigned, info.bits); | |
| 1096 | 1096 | |
| 1097 | 1097 | if (self.bitCountTwosComp() > info.bits) { |
| 1098 | 1098 | return error.TargetTooSmall; |
lib/std/math/big/rational.zig+2-2| ... | ... | @@ -136,7 +136,7 @@ pub const Rational = struct { |
| 136 | 136 | // Translated from golang.go/src/math/big/rat.go. |
| 137 | 137 | debug.assert(@typeInfo(T) == .Float); |
| 138 | 138 | |
| 139 | const UnsignedInt = std.meta.Int(false, @typeInfo(T).Float.bits); | |
| 139 | const UnsignedInt = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 140 | 140 | const f_bits = @bitCast(UnsignedInt, f); |
| 141 | 141 | |
| 142 | 142 | const exponent_bits = math.floatExponentBits(T); |
| ... | ... | @@ -195,7 +195,7 @@ pub const Rational = struct { |
| 195 | 195 | debug.assert(@typeInfo(T) == .Float); |
| 196 | 196 | |
| 197 | 197 | const fsize = @typeInfo(T).Float.bits; |
| 198 | const BitReprType = std.meta.Int(false, fsize); | |
| 198 | const BitReprType = std.meta.Int(.unsigned, fsize); | |
| 199 | 199 | |
| 200 | 200 | const msize = math.floatMantissaBits(T); |
| 201 | 201 | const msize1 = msize + 1; |
lib/std/math/cos.zig+1-1| ... | ... | @@ -49,7 +49,7 @@ const pi4c = 2.69515142907905952645E-15; |
| 49 | 49 | const m4pi = 1.273239544735162542821171882678754627704620361328125; |
| 50 | 50 | |
| 51 | 51 | fn 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); | |
| 53 | 53 | |
| 54 | 54 | var x = x_; |
| 55 | 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 | 150 | var xe = r2.exponent; |
| 151 | 151 | var x1 = r2.significand; |
| 152 | 152 | |
| 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 | 154 | while (i != 0) : (i >>= 1) { |
| 155 | 155 | const overflow_shift = math.floatExponentBits(T) + 1; |
| 156 | 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 | 50 | const m4pi = 1.273239544735162542821171882678754627704620361328125; |
| 51 | 51 | |
| 52 | 52 | fn 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); | |
| 54 | 54 | |
| 55 | 55 | var x = x_; |
| 56 | 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 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | fn sqrt_int(comptime T: type, value: T) std.meta.Int(false, @typeInfo(T).Int.bits / 2) { | |
| 39 | fn sqrt_int(comptime T: type, value: T) std.meta.Int(.unsigned, @typeInfo(T).Int.bits / 2) { | |
| 40 | 40 | var op = value; |
| 41 | 41 | var res: T = 0; |
| 42 | 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 | 55 | one >>= 2; |
| 56 | 56 | } |
| 57 | 57 | |
| 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 | 59 | return @intCast(ResultType, res); |
| 60 | 60 | } |
| 61 | 61 | |
| ... | ... | @@ -71,7 +71,7 @@ test "math.sqrt_int" { |
| 71 | 71 | /// Returns the return type `sqrt` will return given an operand of type `T`. |
| 72 | 72 | pub fn Sqrt(comptime T: type) type { |
| 73 | 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 | 75 | else => T, |
| 76 | 76 | }; |
| 77 | 77 | } |
lib/std/math/tan.zig+1-1| ... | ... | @@ -43,7 +43,7 @@ const pi4c = 2.69515142907905952645E-15; |
| 43 | 43 | const m4pi = 1.273239544735162542821171882678754627704620361328125; |
| 44 | 44 | |
| 45 | 45 | fn 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); | |
| 47 | 47 | |
| 48 | 48 | var x = x_; |
| 49 | 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 | 1106 | return set(u8, buffer, 0); |
| 1107 | 1107 | |
| 1108 | 1108 | // 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 | 1110 | var bits = @truncate(uint, value); |
| 1111 | 1111 | for (buffer) |*b| { |
| 1112 | 1112 | b.* = @truncate(u8, bits); |
| ... | ... | @@ -1126,7 +1126,7 @@ pub fn writeIntSliceBig(comptime T: type, buffer: []u8, value: T) void { |
| 1126 | 1126 | return set(u8, buffer, 0); |
| 1127 | 1127 | |
| 1128 | 1128 | // 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 | 1130 | var bits = @truncate(uint, value); |
| 1131 | 1131 | var index: usize = buffer.len; |
| 1132 | 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 | 678 | /// Deprecated: use Int |
| 679 | 679 | pub const IntType = Int; |
| 680 | 680 | |
| 681 | pub fn Int(comptime is_signed: bool, comptime bit_count: u16) type { | |
| 681 | pub const Signedness = enum { | |
| 682 | unsigned, | |
| 683 | signed, | |
| 684 | }; | |
| 685 | ||
| 686 | pub fn Int(comptime signedness: Signedness, comptime bit_count: u16) type { | |
| 682 | 687 | return @Type(TypeInfo{ |
| 683 | 688 | .Int = .{ |
| 684 | .is_signed = is_signed, | |
| 689 | .is_signed = signedness == .signed, | |
| 685 | 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 | 18 | return struct { |
| 19 | 19 | bits: Int, |
| 20 | 20 | |
| 21 | pub const Int = meta.Int(false, bit_count); | |
| 21 | pub const Int = meta.Int(.unsigned, bit_count); | |
| 22 | 22 | pub const bit_count = @typeInfo(Fields).Struct.fields.len; |
| 23 | 23 | |
| 24 | 24 | pub const FieldEnum = blk: { |
lib/std/os.zig+1-1| ... | ... | @@ -4494,7 +4494,7 @@ pub fn res_mkquery( |
| 4494 | 4494 | // Make a reasonably unpredictable id |
| 4495 | 4495 | var ts: timespec = undefined; |
| 4496 | 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 | 4498 | const unsec = @bitCast(UInt, ts.tv_nsec); |
| 4499 | 4499 | const id = @truncate(u32, unsec + unsec / 65536); |
| 4500 | 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 | 1073 | |
| 1074 | 1074 | pub const CPU_SETSIZE = 128; |
| 1075 | 1075 | pub const cpu_set_t = [CPU_SETSIZE / @sizeOf(usize)]usize; |
| 1076 | pub const cpu_count_t = std.meta.Int(false, std.math.log2(CPU_SETSIZE * 8)); | |
| 1076 | pub const cpu_count_t = std.meta.Int(.unsigned, std.math.log2(CPU_SETSIZE * 8)); | |
| 1077 | 1077 | |
| 1078 | 1078 | pub fn CPU_COUNT(set: cpu_set_t) cpu_count_t { |
| 1079 | 1079 | 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 { |
| 39 | 39 | |
| 40 | 40 | //we bitcast the desired Int type to an unsigned version of itself |
| 41 | 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); | |
| 43 | 43 | |
| 44 | 44 | //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); | |
| 46 | 46 | |
| 47 | 47 | //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); | |
| 49 | 49 | |
| 50 | 50 | return struct { |
| 51 | 51 | pub fn get(bytes: []const u8, index: usize, bit_offset: u7) Int { |
| ... | ... | @@ -416,7 +416,7 @@ test "PackedIntSlice of PackedInt(Array/Slice)" { |
| 416 | 416 | |
| 417 | 417 | comptime var bits = 0; |
| 418 | 418 | inline while (bits <= max_bits) : (bits += 1) { |
| 419 | const Int = std.meta.Int(false, bits); | |
| 419 | const Int = std.meta.Int(.unsigned, bits); | |
| 420 | 420 | |
| 421 | 421 | const PackedArray = PackedIntArray(Int, int_count); |
| 422 | 422 | var packed_array = @as(PackedArray, undefined); |
lib/std/rand.zig+10-10| ... | ... | @@ -52,8 +52,8 @@ pub const Random = struct { |
| 52 | 52 | /// `i` is evenly distributed. |
| 53 | 53 | pub fn int(r: *Random, comptime T: type) T { |
| 54 | 54 | 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); | |
| 57 | 57 | |
| 58 | 58 | var rand_bytes: [@sizeOf(ByteAlignedT)]u8 = undefined; |
| 59 | 59 | r.bytes(rand_bytes[0..]); |
| ... | ... | @@ -95,9 +95,9 @@ pub const Random = struct { |
| 95 | 95 | assert(0 < less_than); |
| 96 | 96 | // Small is typically u32 |
| 97 | 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 | 99 | // Large is typically u64 |
| 100 | const Large = std.meta.Int(false, small_bits * 2); | |
| 100 | const Large = std.meta.Int(.unsigned, small_bits * 2); | |
| 101 | 101 | |
| 102 | 102 | // adapted from: |
| 103 | 103 | // http://www.pcg-random.org/posts/bounded-rands.html |
| ... | ... | @@ -109,7 +109,7 @@ pub const Random = struct { |
| 109 | 109 | // TODO: workaround for https://github.com/ziglang/zig/issues/1770 |
| 110 | 110 | // should be: |
| 111 | 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))); | |
| 113 | 113 | |
| 114 | 114 | if (t >= less_than) { |
| 115 | 115 | t -= less_than; |
| ... | ... | @@ -156,7 +156,7 @@ pub const Random = struct { |
| 156 | 156 | const info = @typeInfo(T).Int; |
| 157 | 157 | if (info.is_signed) { |
| 158 | 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 | 160 | const lo = @bitCast(UnsignedT, at_least); |
| 161 | 161 | const hi = @bitCast(UnsignedT, less_than); |
| 162 | 162 | const result = lo +% r.uintLessThanBiased(UnsignedT, hi -% lo); |
| ... | ... | @@ -175,7 +175,7 @@ pub const Random = struct { |
| 175 | 175 | const info = @typeInfo(T).Int; |
| 176 | 176 | if (info.is_signed) { |
| 177 | 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 | 179 | const lo = @bitCast(UnsignedT, at_least); |
| 180 | 180 | const hi = @bitCast(UnsignedT, less_than); |
| 181 | 181 | const result = lo +% r.uintLessThan(UnsignedT, hi -% lo); |
| ... | ... | @@ -193,7 +193,7 @@ pub const Random = struct { |
| 193 | 193 | const info = @typeInfo(T).Int; |
| 194 | 194 | if (info.is_signed) { |
| 195 | 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 | 197 | const lo = @bitCast(UnsignedT, at_least); |
| 198 | 198 | const hi = @bitCast(UnsignedT, at_most); |
| 199 | 199 | const result = lo +% r.uintAtMostBiased(UnsignedT, hi -% lo); |
| ... | ... | @@ -212,7 +212,7 @@ pub const Random = struct { |
| 212 | 212 | const info = @typeInfo(T).Int; |
| 213 | 213 | if (info.is_signed) { |
| 214 | 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 | 216 | const lo = @bitCast(UnsignedT, at_least); |
| 217 | 217 | const hi = @bitCast(UnsignedT, at_most); |
| 218 | 218 | const result = lo +% r.uintAtMost(UnsignedT, hi -% lo); |
| ... | ... | @@ -290,7 +290,7 @@ pub const Random = struct { |
| 290 | 290 | pub fn limitRangeBiased(comptime T: type, random_int: T, less_than: T) T { |
| 291 | 291 | comptime assert(@typeInfo(T).Int.is_signed == false); |
| 292 | 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); | |
| 294 | 294 | |
| 295 | 295 | // adapted from: |
| 296 | 296 | // 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 | 652 | @setRuntimeSafety(false); |
| 653 | 653 | |
| 654 | 654 | const bits = @typeInfo(T).Float.bits; |
| 655 | const uint = std.meta.Int(false, bits); | |
| 655 | const uint = std.meta.Int(.unsigned, bits); | |
| 656 | 656 | const log2uint = math.Log2Int(uint); |
| 657 | 657 | const digits = if (T == f32) 23 else 52; |
| 658 | 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 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 |
| 62 | fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 { | |
| 62 | fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | |
| 63 | 63 | 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)); | |
| 66 | 66 | const significandBits = std.math.floatMantissaBits(T); |
| 67 | 67 | const implicitBit = @as(Z, 1) << significandBits; |
| 68 | 68 | |
| 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 | 70 | significand.* <<= @intCast(S, shift); |
| 71 | 71 | return 1 - shift; |
| 72 | 72 | } |
| ... | ... | @@ -74,8 +74,8 @@ fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Fl |
| 74 | 74 | // TODO: restore inline keyword, see: https://github.com/ziglang/zig/issues/2154 |
| 75 | 75 | fn addXf3(comptime T: type, a: T, b: T) T { |
| 76 | 76 | 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)); | |
| 79 | 79 | |
| 80 | 80 | const typeWidth = bits; |
| 81 | 81 | const significandBits = std.math.floatMantissaBits(T); |
| ... | ... | @@ -189,7 +189,7 @@ fn addXf3(comptime T: type, a: T, b: T) T { |
| 189 | 189 | // If partial cancellation occured, we need to left-shift the result |
| 190 | 190 | // and adjust the exponent: |
| 191 | 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 | 193 | aSignificand <<= @intCast(S, shift); |
| 194 | 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 | 28 | @setRuntimeSafety(builtin.is_test); |
| 29 | 29 | |
| 30 | 30 | 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); | |
| 33 | 33 | |
| 34 | 34 | const significandBits = std.math.floatMantissaBits(T); |
| 35 | 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 | 74 | pub fn unordcmp(comptime T: type, a: T, b: T) i32 { |
| 75 | 75 | @setRuntimeSafety(builtin.is_test); |
| 76 | 76 | |
| 77 | const rep_t = std.meta.Int(false, @typeInfo(T).Float.bits); | |
| 77 | const rep_t = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 78 | 78 | |
| 79 | 79 | const significandBits = std.math.floatMantissaBits(T); |
| 80 | 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 | 12 | |
| 13 | 13 | pub fn __divdf3(a: f64, b: f64) callconv(.C) f64 { |
| 14 | 14 | @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); | |
| 17 | 17 | |
| 18 | 18 | const significandBits = std.math.floatMantissaBits(f64); |
| 19 | 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 | 316 | } |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | pub fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 { | |
| 319 | pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | |
| 320 | 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 | 322 | const significandBits = std.math.floatMantissaBits(T); |
| 323 | 323 | const implicitBit = @as(Z, 1) << significandBits; |
| 324 | 324 |
lib/std/special/compiler_rt/divsf3.zig+3-3| ... | ... | @@ -12,7 +12,7 @@ const builtin = @import("builtin"); |
| 12 | 12 | |
| 13 | 13 | pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 14 | 14 | @setRuntimeSafety(builtin.is_test); |
| 15 | const Z = std.meta.Int(false, 32); | |
| 15 | const Z = std.meta.Int(.unsigned, 32); | |
| 16 | 16 | |
| 17 | 17 | const significandBits = std.math.floatMantissaBits(f32); |
| 18 | 18 | const exponentBits = std.math.floatExponentBits(f32); |
| ... | ... | @@ -189,9 +189,9 @@ pub fn __divsf3(a: f32, b: f32) callconv(.C) f32 { |
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 { | |
| 192 | fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | |
| 193 | 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 | 195 | const significandBits = std.math.floatMantissaBits(T); |
| 196 | 196 | const implicitBit = @as(Z, 1) << significandBits; |
| 197 | 197 |
lib/std/special/compiler_rt/divtf3.zig+2-2| ... | ... | @@ -11,8 +11,8 @@ const wideMultiply = @import("divdf3.zig").wideMultiply; |
| 11 | 11 | |
| 12 | 12 | pub fn __divtf3(a: f128, b: f128) callconv(.C) f128 { |
| 13 | 13 | @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); | |
| 16 | 16 | |
| 17 | 17 | const significandBits = std.math.floatMantissaBits(f128); |
| 18 | 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 | 35 | |
| 36 | 36 | const CHAR_BIT = 8; |
| 37 | 37 | |
| 38 | fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(false, @typeInfo(src_t).Float.bits)) dst_t { | |
| 38 | fn extendXfYf2(comptime dst_t: type, comptime src_t: type, a: std.meta.Int(.unsigned, @typeInfo(src_t).Float.bits)) dst_t { | |
| 39 | 39 | @setRuntimeSafety(builtin.is_test); |
| 40 | 40 | |
| 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); | |
| 43 | 43 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 44 | 44 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 45 | 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 | 51 | |
| 52 | 52 | // The unsigned result needs to be large enough to handle an fixint_t or rep_t |
| 53 | 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 | 55 | const UintResultType = if (fixint_bits > typeWidth) fixuint_t else rep_t; |
| 56 | 56 | var uint_result: UintResultType = undefined; |
| 57 | 57 |
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 | 16 | else => unreachable, |
| 17 | 17 | }; |
| 18 | 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 | 20 | const significandBits = switch (fp_t) { |
| 21 | 21 | f32 => 23, |
| 22 | 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 | 13 | @setRuntimeSafety(builtin.is_test); |
| 14 | 14 | |
| 15 | 15 | 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)); | |
| 18 | 18 | |
| 19 | 19 | if (arg == 0) { |
| 20 | 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 | 11 | @setRuntimeSafety(builtin.is_test); |
| 12 | 12 | |
| 13 | 13 | 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)); | |
| 16 | 16 | |
| 17 | 17 | if (a == 0) { |
| 18 | 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 | 34 | fn mulXf3(comptime T: type, a: T, b: T) T { |
| 35 | 35 | @setRuntimeSafety(builtin.is_test); |
| 36 | 36 | const typeWidth = @typeInfo(T).Float.bits; |
| 37 | const Z = std.meta.Int(false, typeWidth); | |
| 37 | const Z = std.meta.Int(.unsigned, typeWidth); | |
| 38 | 38 | |
| 39 | 39 | const significandBits = std.math.floatMantissaBits(T); |
| 40 | 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 | 269 | } |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | fn normalize(comptime T: type, significand: *std.meta.Int(false, @typeInfo(T).Float.bits)) i32 { | |
| 272 | fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeInfo(T).Float.bits)) i32 { | |
| 273 | 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 | 275 | const significandBits = std.math.floatMantissaBits(T); |
| 276 | 276 | const implicitBit = @as(Z, 1) << significandBits; |
| 277 | 277 |
lib/std/special/compiler_rt/negXf2.zig+1-1| ... | ... | @@ -24,7 +24,7 @@ pub fn __aeabi_dneg(arg: f64) callconv(.AAPCS) f64 { |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | fn 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); | |
| 28 | 28 | |
| 29 | 29 | const significandBits = std.math.floatMantissaBits(T); |
| 30 | 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 | 10 | fn Dwords(comptime T: type, comptime signed_half: bool) type { |
| 11 | 11 | return extern union { |
| 12 | 12 | 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); | |
| 15 | 15 | pub const HalfT = if (signed_half) HalfTS else HalfTU; |
| 16 | 16 | |
| 17 | 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 | 41 | } |
| 42 | 42 | |
| 43 | 43 | fn 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); | |
| 46 | 46 | const srcSigBits = std.math.floatMantissaBits(src_t); |
| 47 | 47 | const dstSigBits = std.math.floatMantissaBits(dst_t); |
| 48 | 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 | 17 | |
| 18 | 18 | const double_int_bits = @typeInfo(DoubleInt).Int.bits; |
| 19 | 19 | 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); | |
| 22 | 22 | const Log2SingleInt = @import("std").math.Log2Int(SingleInt); |
| 23 | 23 | |
| 24 | 24 | 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 | 554 | pub const needed_bit_count = 168; |
| 555 | 555 | pub const byte_count = (needed_bit_count + 7) / 8; |
| 556 | 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 | 558 | pub const ShiftInt = std.math.Log2Int(usize); |
| 559 | 559 | |
| 560 | 560 | pub const empty = Set{ .ints = [1]usize{0} ** usize_count }; |