| author | |
| committer | |
| log | efcaf6a72d19c6105b235e45dc79f70023d84ffc |
| tree | 26e239f5a047627b23b6bcf70baba7812f980463 |
| parent | 73f6d498fc83763054f62677f3a67871d3825136 |
20 files changed, 28 insertions(+), 40 deletions(-)
lib/compiler/Maker/WebServer.zig+1-1| ... | @@ -163,7 +163,7 @@ pub fn updateConfiguration(ws: *WebServer, maker: *Maker) !void { | ... | @@ -163,7 +163,7 @@ pub fn updateConfiguration(ws: *WebServer, maker: *Maker) !void { |
| 163 | assert(idx == step_names_trailing.len); | 163 | assert(idx == step_names_trailing.len); |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | const step_status_bits = try gpa.alloc(u8, std.math.divCeil(usize, all_steps.len, 4) catch unreachable); | 166 | const step_status_bits = try gpa.alloc(u8, @divCeil(all_steps.len, 4)); |
| 167 | errdefer gpa.free(step_status_bits); | 167 | errdefer gpa.free(step_status_bits); |
| 168 | @memset(step_status_bits, 0); | 168 | @memset(step_status_bits, 0); |
| 169 | 169 |
lib/compiler_rt/limb64.zig+1-2| ... | @@ -3,7 +3,6 @@ const testing = std.testing; | ... | @@ -3,7 +3,6 @@ const testing = std.testing; |
| 3 | const assert = std.debug.assert; | 3 | const assert = std.debug.assert; |
| 4 | const maxInt = std.math.maxInt; | 4 | const maxInt = std.math.maxInt; |
| 5 | const minInt = std.math.minInt; | 5 | const minInt = std.math.minInt; |
| 6 | const divCeil = std.math.divCeil; | ||
| 7 | 6 | ||
| 8 | const builtin = @import("builtin"); | 7 | const builtin = @import("builtin"); |
| 9 | const compiler_rt = @import("../compiler_rt.zig"); | 8 | const compiler_rt = @import("../compiler_rt.zig"); |
| ... | @@ -26,7 +25,7 @@ inline fn limbSet(limbs: []u64, i: usize, value: u64) void { | ... | @@ -26,7 +25,7 @@ inline fn limbSet(limbs: []u64, i: usize, value: u64) void { |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | fn usedLimbCount(bits: u16) u16 { | 27 | fn usedLimbCount(bits: u16) u16 { |
| 29 | return divCeil(u16, bits, 64) catch unreachable; | 28 | return @divCeil(bits, 64); |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | fn limbCount(bits: u16) u16 { | 31 | fn limbCount(bits: u16) u16 { |
lib/compiler_rt/udivmodei4.zig+1-1| ... | @@ -8,7 +8,7 @@ const shl = std.math.shl; | ... | @@ -8,7 +8,7 @@ const shl = std.math.shl; |
| 8 | const compiler_rt = @import("../compiler_rt.zig"); | 8 | const compiler_rt = @import("../compiler_rt.zig"); |
| 9 | const symbol = @import("../compiler_rt.zig").symbol; | 9 | const symbol = @import("../compiler_rt.zig").symbol; |
| 10 | 10 | ||
| 11 | const max_limbs = std.math.divCeil(usize, 65535, 32) catch unreachable; // max supported type is u65535 | 11 | const max_limbs = @divCeil(65535, 32); // max supported type is u65535 |
| 12 | 12 | ||
| 13 | comptime { | 13 | comptime { |
| 14 | symbol(&__udivei4, "__udivei4"); | 14 | symbol(&__udivei4, "__udivei4"); |
lib/fuzzer.zig+1-1| ... | @@ -52,7 +52,7 @@ var fuzzer: Fuzzer = undefined; | ... | @@ -52,7 +52,7 @@ var fuzzer: Fuzzer = undefined; |
| 52 | var current_test_name: ?[]const u8 = null; | 52 | var current_test_name: ?[]const u8 = null; |
| 53 | 53 | ||
| 54 | fn bitsetUsizes(elems: usize) usize { | 54 | fn bitsetUsizes(elems: usize) usize { |
| 55 | return math.divCeil(usize, elems, @bitSizeOf(usize)) catch unreachable; | 55 | return @divCeil(elems, @bitSizeOf(usize)); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | const Executable = struct { | 58 | const Executable = struct { |
lib/std/Random.zig+1-1| ... | @@ -126,7 +126,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty | ... | @@ -126,7 +126,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty |
| 126 | pub fn int(r: Random, comptime T: type) T { | 126 | pub fn int(r: Random, comptime T: type) T { |
| 127 | const bits = @typeInfo(T).int.bits; | 127 | const bits = @typeInfo(T).int.bits; |
| 128 | const UnsignedT = @Int(.unsigned, bits); | 128 | const UnsignedT = @Int(.unsigned, bits); |
| 129 | const ceil_bytes = comptime std.math.divCeil(u16, bits, 8) catch unreachable; | 129 | const ceil_bytes = @divCeil(bits, 8); |
| 130 | const ByteAlignedT = @Int(.unsigned, ceil_bytes * 8); | 130 | const ByteAlignedT = @Int(.unsigned, ceil_bytes * 8); |
| 131 | 131 | ||
| 132 | var rand_bytes: [ceil_bytes]u8 = undefined; | 132 | var rand_bytes: [ceil_bytes]u8 = undefined; |
lib/std/Target.zig+1-1| ... | @@ -1252,7 +1252,7 @@ pub const Cpu = struct { | ... | @@ -1252,7 +1252,7 @@ pub const Cpu = struct { |
| 1252 | ints: [usize_count]usize, | 1252 | ints: [usize_count]usize, |
| 1253 | 1253 | ||
| 1254 | pub const needed_bit_count = 347; | 1254 | pub const needed_bit_count = 347; |
| 1255 | pub const byte_count = (needed_bit_count + 7) / 8; | 1255 | pub const byte_count = @divCeil(needed_bit_count, 8); |
| 1256 | pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize); | 1256 | pub const usize_count = (byte_count + (@sizeOf(usize) - 1)) / @sizeOf(usize); |
| 1257 | pub const Index = std.math.Log2Int(@Int(.unsigned, usize_count * @bitSizeOf(usize))); | 1257 | pub const Index = std.math.Log2Int(@Int(.unsigned, usize_count * @bitSizeOf(usize))); |
| 1258 | pub const ShiftInt = std.math.Log2Int(usize); | 1258 | pub const ShiftInt = std.math.Log2Int(usize); |
lib/std/crypto/aes_gcm.zig+2-2| ... | @@ -39,7 +39,7 @@ fn AesGcm(comptime Aes: anytype) type { | ... | @@ -39,7 +39,7 @@ fn AesGcm(comptime Aes: anytype) type { |
| 39 | mem.writeInt(u32, j[nonce_length..][0..4], 1, .big); | 39 | mem.writeInt(u32, j[nonce_length..][0..4], 1, .big); |
| 40 | aes.encrypt(&t, &j); | 40 | aes.encrypt(&t, &j); |
| 41 | 41 | ||
| 42 | const block_count = (math.divCeil(usize, ad.len, Ghash.block_length) catch unreachable) + (math.divCeil(usize, c.len, Ghash.block_length) catch unreachable) + 1; | 42 | const block_count = @divCeil(ad.len, Ghash.block_length) + @divCeil(c.len, Ghash.block_length) + 1; |
| 43 | var mac = Ghash.initForBlockCount(&h, block_count); | 43 | var mac = Ghash.initForBlockCount(&h, block_count); |
| 44 | mac.update(ad); | 44 | mac.update(ad); |
| 45 | mac.pad(); | 45 | mac.pad(); |
| ... | @@ -81,7 +81,7 @@ fn AesGcm(comptime Aes: anytype) type { | ... | @@ -81,7 +81,7 @@ fn AesGcm(comptime Aes: anytype) type { |
| 81 | mem.writeInt(u32, j[nonce_length..][0..4], 1, .big); | 81 | mem.writeInt(u32, j[nonce_length..][0..4], 1, .big); |
| 82 | aes.encrypt(&t, &j); | 82 | aes.encrypt(&t, &j); |
| 83 | 83 | ||
| 84 | const block_count = (math.divCeil(usize, ad.len, Ghash.block_length) catch unreachable) + (math.divCeil(usize, c.len, Ghash.block_length) catch unreachable) + 1; | 84 | const block_count = @divCeil(ad.len, Ghash.block_length) + @divCeil(c.len, Ghash.block_length) + 1; |
| 85 | var mac = Ghash.initForBlockCount(&h, block_count); | 85 | var mac = Ghash.initForBlockCount(&h, block_count); |
| 86 | mac.update(ad); | 86 | mac.update(ad); |
| 87 | mac.pad(); | 87 | mac.pad(); |
lib/std/crypto/ascon.zig+1-1| ... | @@ -198,7 +198,7 @@ pub fn State(comptime endian: std.builtin.Endian) type { | ... | @@ -198,7 +198,7 @@ pub fn State(comptime endian: std.builtin.Endian) type { |
| 198 | /// | 198 | /// |
| 199 | /// Note: Clears complete words that contain the specified byte range | 199 | /// Note: Clears complete words that contain the specified byte range |
| 200 | pub fn clear(self: *Self, from: usize, to: usize) void { | 200 | pub fn clear(self: *Self, from: usize, to: usize) void { |
| 201 | @memset(self.st[from / 8 .. (to + 7) / 8], 0); | 201 | @memset(self.st[from / 8 .. @divCeil(to, 8)], 0); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | /// Clear the entire state, disabling compiler optimizations. | 204 | /// Clear the entire state, disabling compiler optimizations. |
lib/std/crypto/ff.zig+3-3| ... | @@ -61,14 +61,14 @@ pub fn Uint(comptime max_bits: comptime_int) type { | ... | @@ -61,14 +61,14 @@ pub fn Uint(comptime max_bits: comptime_int) type { |
| 61 | 61 | ||
| 62 | return struct { | 62 | return struct { |
| 63 | const Self = @This(); | 63 | const Self = @This(); |
| 64 | const max_limbs_count = math.divCeil(usize, max_bits, t_bits) catch unreachable; | 64 | const max_limbs_count = @divCeil(max_bits, t_bits); |
| 65 | 65 | ||
| 66 | limbs_buffer: [max_limbs_count]Limb, | 66 | limbs_buffer: [max_limbs_count]Limb, |
| 67 | /// The number of active limbs. | 67 | /// The number of active limbs. |
| 68 | limbs_len: usize, | 68 | limbs_len: usize, |
| 69 | 69 | ||
| 70 | /// Number of bytes required to serialize an integer. | 70 | /// Number of bytes required to serialize an integer. |
| 71 | pub const encoded_bytes = math.divCeil(usize, max_bits, 8) catch unreachable; | 71 | pub const encoded_bytes = @divCeil(max_bits, 8); |
| 72 | 72 | ||
| 73 | /// Constant slice of active limbs. | 73 | /// Constant slice of active limbs. |
| 74 | fn limbsConst(self: *const Self) []const Limb { | 74 | fn limbsConst(self: *const Self) []const Limb { |
| ... | @@ -847,7 +847,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { | ... | @@ -847,7 +847,7 @@ pub fn Modulus(comptime max_bits: comptime_int) type { |
| 847 | } | 847 | } |
| 848 | var e_normalized = Fe{ .v = e.v.normalize() }; | 848 | var e_normalized = Fe{ .v = e.v.normalize() }; |
| 849 | var buf_: [Fe.encoded_bytes]u8 = undefined; | 849 | var buf_: [Fe.encoded_bytes]u8 = undefined; |
| 850 | var buf = buf_[0 .. math.divCeil(usize, e_normalized.v.limbs_len * t_bits, 8) catch unreachable]; | 850 | var buf = buf_[0..@divCeil(e_normalized.v.limbs_len * t_bits, 8)]; |
| 851 | e_normalized.toBytes(buf, .little) catch unreachable; | 851 | e_normalized.toBytes(buf, .little) catch unreachable; |
| 852 | const leading = @clz(e_normalized.v.limbsConst()[e_normalized.v.limbs_len - carry_bits]); | 852 | const leading = @clz(e_normalized.v.limbsConst()[e_normalized.v.limbs_len - carry_bits]); |
| 853 | buf = buf[0 .. buf.len - leading / 8]; | 853 | buf = buf[0 .. buf.len - leading / 8]; |
lib/std/crypto/pbkdf2.zig+1-1| ... | @@ -74,7 +74,7 @@ pub fn pbkdf2(dk: []u8, password: []const u8, salt: []const u8, rounds: u32, com | ... | @@ -74,7 +74,7 @@ pub fn pbkdf2(dk: []u8, password: []const u8, salt: []const u8, rounds: u32, com |
| 74 | // block | 74 | // block |
| 75 | // | 75 | // |
| 76 | 76 | ||
| 77 | const blocks_count = @as(u32, @intCast(std.math.divCeil(usize, dk_len, h_len) catch unreachable)); | 77 | const blocks_count: u32 = @intCast(@divCeil(dk_len, h_len)); |
| 78 | var r = dk_len % h_len; | 78 | var r = dk_len % h_len; |
| 79 | if (r == 0) { | 79 | if (r == 0) { |
| 80 | r = h_len; | 80 | r = h_len; |
lib/std/crypto/sha2.zig+1-1| ... | @@ -474,7 +474,7 @@ fn Sha2x64(comptime iv: Iv64, digest_bits: comptime_int) type { | ... | @@ -474,7 +474,7 @@ fn Sha2x64(comptime iv: Iv64, digest_bits: comptime_int) type { |
| 474 | return struct { | 474 | return struct { |
| 475 | const Self = @This(); | 475 | const Self = @This(); |
| 476 | pub const block_length = 128; | 476 | pub const block_length = 128; |
| 477 | pub const digest_length = std.math.divCeil(comptime_int, digest_bits, 8) catch unreachable; | 477 | pub const digest_length = @divCeil(digest_bits, 8); |
| 478 | pub const Options = struct {}; | 478 | pub const Options = struct {}; |
| 479 | 479 | ||
| 480 | s: Iv64, | 480 | s: Iv64, |
lib/std/crypto/sha3.zig+2-2| ... | @@ -58,7 +58,7 @@ pub fn Keccak(comptime f: u11, comptime output_bits: u11, comptime default_delim | ... | @@ -58,7 +58,7 @@ pub fn Keccak(comptime f: u11, comptime output_bits: u11, comptime default_delim |
| 58 | st: State, | 58 | st: State, |
| 59 | 59 | ||
| 60 | /// The output length, in bytes. | 60 | /// The output length, in bytes. |
| 61 | pub const digest_length = std.math.divCeil(comptime_int, output_bits, 8) catch unreachable; | 61 | pub const digest_length: comptime_int = @divCeil(output_bits, 8); |
| 62 | /// The block length, or rate, in bytes. | 62 | /// The block length, or rate, in bytes. |
| 63 | pub const block_length = State.rate; | 63 | pub const block_length = State.rate; |
| 64 | /// The delimiter can be overwritten in the options. | 64 | /// The delimiter can be overwritten in the options. |
| ... | @@ -464,7 +464,7 @@ pub const NistLengthEncoding = enum { | ... | @@ -464,7 +464,7 @@ pub const NistLengthEncoding = enum { |
| 464 | /// Encode a length according to NIST SP 800-185. | 464 | /// Encode a length according to NIST SP 800-185. |
| 465 | pub fn encode(comptime encoding: NistLengthEncoding, len: usize) Length { | 465 | pub fn encode(comptime encoding: NistLengthEncoding, len: usize) Length { |
| 466 | const len_bits = @bitSizeOf(@TypeOf(len)) - @clz(len) + 3; | 466 | const len_bits = @bitSizeOf(@TypeOf(len)) - @clz(len) + 3; |
| 467 | const len_bytes = std.math.divCeil(usize, len_bits, 8) catch unreachable; | 467 | const len_bytes = @divCeil(len_bits, 8); |
| 468 | 468 | ||
| 469 | var res = Length{ .len = len_bytes + 1 }; | 469 | var res = Length{ .len = len_bytes + 1 }; |
| 470 | if (encoding == .right) { | 470 | if (encoding == .right) { |
lib/std/debug.zig+1-1| ... | @@ -349,7 +349,7 @@ pub fn dumpHexFallible(t: Io.Terminal, bytes: []const u8) !void { | ... | @@ -349,7 +349,7 @@ pub fn dumpHexFallible(t: Io.Terminal, bytes: []const u8) !void { |
| 349 | var chunks = mem.window(u8, bytes, 16, 16); | 349 | var chunks = mem.window(u8, bytes, 16, 16); |
| 350 | while (chunks.next()) |window| { | 350 | while (chunks.next()) |window| { |
| 351 | // 1. Print the address. | 351 | // 1. Print the address. |
| 352 | const address = (@intFromPtr(bytes.ptr) + 0x10 * (std.math.divCeil(usize, chunks.index orelse bytes.len, 16) catch unreachable)) - 0x10; | 352 | const address = (@intFromPtr(bytes.ptr) + 0x10 * @divCeil(chunks.index orelse bytes.len, 16) - 0x10); |
| 353 | try t.setColor(.dim); | 353 | try t.setColor(.dim); |
| 354 | // We print the address in lowercase and the bytes in uppercase hexadecimal to distinguish them more. | 354 | // We print the address in lowercase and the bytes in uppercase hexadecimal to distinguish them more. |
| 355 | // Also, make sure all lines are aligned by padding the address. | 355 | // Also, make sure all lines are aligned by padding the address. |
lib/std/enums.zig+1-1| ... | @@ -1391,7 +1391,7 @@ test "EnumIndexer non-exhaustive" { | ... | @@ -1391,7 +1391,7 @@ test "EnumIndexer non-exhaustive" { |
| 1391 | const max_index: comptime_int = std.math.maxInt(RangedType); | 1391 | const max_index: comptime_int = std.math.maxInt(RangedType); |
| 1392 | const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) { | 1392 | const number_zero_tag_index: usize = switch (@typeInfo(BackingInt).int.signedness) { |
| 1393 | .unsigned => 0, | 1393 | .unsigned => 0, |
| 1394 | .signed => std.math.divCeil(comptime_int, max_index, 2) catch unreachable, | 1394 | .signed => @divCeil(max_index, 2), |
| 1395 | }; | 1395 | }; |
| 1396 | 1396 | ||
| 1397 | try testing.expectEqual(E, Indexer.Key); | 1397 | try testing.expectEqual(E, Indexer.Key); |
lib/std/hash/auto_hash.zig+1-1| ... | @@ -99,7 +99,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { | ... | @@ -99,7 +99,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { |
| 99 | } else { | 99 | } else { |
| 100 | // Take only the part containing the key value, the remaining | 100 | // Take only the part containing the key value, the remaining |
| 101 | // bytes are undefined and must not be hashed! | 101 | // bytes are undefined and must not be hashed! |
| 102 | const byte_size = comptime std.math.divCeil(comptime_int, @bitSizeOf(Key), 8) catch unreachable; | 102 | const byte_size = @divCeil(@bitSizeOf(Key), 8); |
| 103 | @call(.always_inline, Hasher.update, .{ hasher, std.mem.asBytes(&key)[0..byte_size] }); | 103 | @call(.always_inline, Hasher.update, .{ hasher, std.mem.asBytes(&key)[0..byte_size] }); |
| 104 | } | 104 | } |
| 105 | }, | 105 | }, |
lib/std/math.zig+3-14| ... | @@ -922,21 +922,10 @@ fn testDivFloor() !void { | ... | @@ -922,21 +922,10 @@ fn testDivFloor() !void { |
| 922 | pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { | 922 | pub fn divCeil(comptime T: type, numerator: T, denominator: T) !T { |
| 923 | @setRuntimeSafety(false); | 923 | @setRuntimeSafety(false); |
| 924 | if (denominator == 0) return error.DivisionByZero; | 924 | if (denominator == 0) return error.DivisionByZero; |
| 925 | const info = @typeInfo(T); | 925 | if (@typeInfo(T) == .int and numerator == minInt(T) and denominator == -1) { |
| 926 | switch (info) { | 926 | return error.Overflow; |
| 927 | .comptime_float, .float => return @ceil(numerator / denominator), | ||
| 928 | .comptime_int, .int => { | ||
| 929 | if (numerator < 0 and denominator < 0) { | ||
| 930 | if (info == .int and numerator == minInt(T) and denominator == -1) | ||
| 931 | return error.Overflow; | ||
| 932 | return @divFloor(numerator + 1, denominator) + 1; | ||
| 933 | } | ||
| 934 | if (numerator > 0 and denominator > 0) | ||
| 935 | return @divFloor(numerator - 1, denominator) + 1; | ||
| 936 | return @divTrunc(numerator, denominator); | ||
| 937 | }, | ||
| 938 | else => @compileError("divCeil unsupported on " ++ @typeName(T)), | ||
| 939 | } | 927 | } |
| 928 | return @divCeil(numerator, denominator); | ||
| 940 | } | 929 | } |
| 941 | 930 | ||
| 942 | test divCeil { | 931 | test divCeil { |
lib/std/math/big/int.zig+1-1| ... | @@ -122,7 +122,7 @@ pub fn calcNonZeroTwosCompLimbCount(bit_count: usize) usize { | ... | @@ -122,7 +122,7 @@ pub fn calcNonZeroTwosCompLimbCount(bit_count: usize) usize { |
| 122 | /// Special cases `bit_count == 0` to return 1. Zero-bit integers can only store the value zero | 122 | /// Special cases `bit_count == 0` to return 1. Zero-bit integers can only store the value zero |
| 123 | /// and this big integer implementation stores zero using one limb. | 123 | /// and this big integer implementation stores zero using one limb. |
| 124 | pub fn calcTwosCompLimbCount(bit_count: usize) usize { | 124 | pub fn calcTwosCompLimbCount(bit_count: usize) usize { |
| 125 | return @max(std.math.divCeil(usize, bit_count, @bitSizeOf(Limb)) catch unreachable, 1); | 125 | return @max(@divCeil(bit_count, @bitSizeOf(Limb)), 1); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | /// a + b * c + *carry, sets carry to the overflow bits | 128 | /// a + b * c + *carry, sets carry to the overflow bits |
lib/std/mem.zig+3-3| ... | @@ -1937,7 +1937,7 @@ fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T | ... | @@ -1937,7 +1937,7 @@ fn readPackedIntLittle(comptime T: type, bytes: []const u8, bit_offset: usize) T |
| 1937 | const bit_count = @as(usize, @bitSizeOf(T)); | 1937 | const bit_count = @as(usize, @bitSizeOf(T)); |
| 1938 | const bit_shift = @as(u3, @intCast(bit_offset % 8)); | 1938 | const bit_shift = @as(u3, @intCast(bit_offset % 8)); |
| 1939 | 1939 | ||
| 1940 | const load_size = (bit_count + 7) / 8; | 1940 | const load_size = @divCeil(bit_count, 8); |
| 1941 | const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count)); | 1941 | const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count)); |
| 1942 | const LoadInt = @Int(.unsigned, load_size * 8); | 1942 | const LoadInt = @Int(.unsigned, load_size * 8); |
| 1943 | 1943 | ||
| ... | @@ -1964,9 +1964,9 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T { | ... | @@ -1964,9 +1964,9 @@ fn readPackedIntBig(comptime T: type, bytes: []const u8, bit_offset: usize) T { |
| 1964 | 1964 | ||
| 1965 | const bit_count = @as(usize, @bitSizeOf(T)); | 1965 | const bit_count = @as(usize, @bitSizeOf(T)); |
| 1966 | const bit_shift = @as(u3, @intCast(bit_offset % 8)); | 1966 | const bit_shift = @as(u3, @intCast(bit_offset % 8)); |
| 1967 | const byte_count = (@as(usize, bit_shift) + bit_count + 7) / 8; | 1967 | const byte_count = @divCeil(@as(usize, bit_shift) + bit_count, 8); |
| 1968 | 1968 | ||
| 1969 | const load_size = (bit_count + 7) / 8; | 1969 | const load_size = @divCeil(bit_count, 8); |
| 1970 | const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count)); | 1970 | const load_tail_bits = @as(u3, @intCast((load_size * 8) - bit_count)); |
| 1971 | const LoadInt = @Int(.unsigned, load_size * 8); | 1971 | const LoadInt = @Int(.unsigned, load_size * 8); |
| 1972 | 1972 |
lib/std/zig/AstGen.zig+1-1| ... | @@ -4896,7 +4896,7 @@ fn structDeclInner( | ... | @@ -4896,7 +4896,7 @@ fn structDeclInner( |
| 4896 | const field_default_body_lens = try scratch.addOptionalSlice(scan_result.any_field_values, scan_result.fields_len); | 4896 | const field_default_body_lens = try scratch.addOptionalSlice(scan_result.any_field_values, scan_result.fields_len); |
| 4897 | const field_comptime_bits = try scratch.addOptionalSlice( | 4897 | const field_comptime_bits = try scratch.addOptionalSlice( |
| 4898 | scan_result.any_comptime_fields, | 4898 | scan_result.any_comptime_fields, |
| 4899 | std.math.divCeil(u32, scan_result.fields_len, 32) catch unreachable, | 4899 | @divCeil(scan_result.fields_len, 32), |
| 4900 | ); | 4900 | ); |
| 4901 | if (field_comptime_bits) |bits| @memset(bits.get(astgen), 0); | 4901 | if (field_comptime_bits) |bits| @memset(bits.get(astgen), 0); |
| 4902 | 4902 |
lib/std/zig/Zir.zig+1-1| ... | @@ -5279,7 +5279,7 @@ pub fn getStructDecl(zir: *const Zir, struct_decl: Inst.Index) UnwrappedStructDe | ... | @@ -5279,7 +5279,7 @@ pub fn getStructDecl(zir: *const Zir, struct_decl: Inst.Index) UnwrappedStructDe |
| 5279 | break :lens @ptrCast(lens); | 5279 | break :lens @ptrCast(lens); |
| 5280 | } else null; | 5280 | } else null; |
| 5281 | const field_comptime_bits: ?[]const u32 = if (small.any_comptime_fields) bits: { | 5281 | const field_comptime_bits: ?[]const u32 = if (small.any_comptime_fields) bits: { |
| 5282 | const bits_len = std.math.divCeil(u32, fields_len, 32) catch unreachable; | 5282 | const bits_len = @divCeil(fields_len, 32); |
| 5283 | const bits = zir.extra[extra_index..][0..bits_len]; | 5283 | const bits = zir.extra[extra_index..][0..bits_len]; |
| 5284 | extra_index += bits_len; | 5284 | extra_index += bits_len; |
| 5285 | break :bits bits; | 5285 | break :bits bits; |