authorgravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2022-04-26 17:08:54+02:00
committergravatar for mail@isaacfreund.comIsaac Freund <mail@isaacfreund.com> 2022-04-27 11:10:52+02:00
log6f4343b61afe36a709e713735947561a2b76bce8
tree19517971ce99ed10afeac53ed4e19c97c60da7cc
parent6c0719fd5f29f524b789d5038fdc9fc0878f2e6a

std: replace usage of std.meta.bitCount() with @bitSizeOf()


13 files changed, 22 insertions(+), 22 deletions(-)

lib/std/Thread/RwLock.zig+2-2
......@@ -167,10 +167,10 @@ pub const DefaultRwLock = struct {
167167
168168 const IS_WRITING: usize = 1;
169169 const WRITER: usize = 1 << 1;
170 const READER: usize = 1 << (1 + std.meta.bitCount(Count));
170 const READER: usize = 1 << (1 + @bitSizeOf(Count));
171171 const WRITER_MASK: usize = std.math.maxInt(Count) << @ctz(usize, WRITER);
172172 const READER_MASK: usize = std.math.maxInt(Count) << @ctz(usize, READER);
173 const Count = std.meta.Int(.unsigned, @divFloor(std.meta.bitCount(usize) - 1, 2));
173 const Count = std.meta.Int(.unsigned, @divFloor(@bitSizeOf(usize) - 1, 2));
174174
175175 pub fn tryLock(rwl: *DefaultRwLock) bool {
176176 if (rwl.mutex.tryLock()) {
lib/std/atomic/Atomic.zig+3-3
......@@ -542,7 +542,7 @@ test "Atomic.bitSet" {
542542 inline for (atomicIntTypes()) |Int| {
543543 inline for (atomic_rmw_orderings) |ordering| {
544544 var x = Atomic(Int).init(0);
545 const bit_array = @as([std.meta.bitCount(Int)]void, undefined);
545 const bit_array = @as([@bitSizeOf(Int)]void, undefined);
546546
547547 for (bit_array) |_, bit_index| {
548548 const bit = @intCast(std.math.Log2Int(Int), bit_index);
......@@ -572,7 +572,7 @@ test "Atomic.bitReset" {
572572 inline for (atomicIntTypes()) |Int| {
573573 inline for (atomic_rmw_orderings) |ordering| {
574574 var x = Atomic(Int).init(0);
575 const bit_array = @as([std.meta.bitCount(Int)]void, undefined);
575 const bit_array = @as([@bitSizeOf(Int)]void, undefined);
576576
577577 for (bit_array) |_, bit_index| {
578578 const bit = @intCast(std.math.Log2Int(Int), bit_index);
......@@ -603,7 +603,7 @@ test "Atomic.bitToggle" {
603603 inline for (atomicIntTypes()) |Int| {
604604 inline for (atomic_rmw_orderings) |ordering| {
605605 var x = Atomic(Int).init(0);
606 const bit_array = @as([std.meta.bitCount(Int)]void, undefined);
606 const bit_array = @as([@bitSizeOf(Int)]void, undefined);
607607
608608 for (bit_array) |_, bit_index| {
609609 const bit = @intCast(std.math.Log2Int(Int), bit_index);
lib/std/crypto/pcurves/common.zig+1-1
......@@ -235,7 +235,7 @@ pub fn Field(comptime params: FieldParams) type {
235235 }
236236 var v_opp: Limbs = undefined;
237237 fiat.opp(&v_opp, v);
238 fiat.selectznz(&v, @truncate(u1, f[f.len - 1] >> (meta.bitCount(Word) - 1)), v, v_opp);
238 fiat.selectznz(&v, @truncate(u1, f[f.len - 1] >> (@bitSizeOf(Word) - 1)), v, v_opp);
239239 var fe: Fe = undefined;
240240 fiat.mul(&fe.limbs, v, precomp);
241241 return fe;
lib/std/crypto/scrypt.zig+1-1
......@@ -348,7 +348,7 @@ const crypt_format = struct {
348348 }
349349 }
350350
351 fn intDecode(comptime T: type, src: *const [(meta.bitCount(T) + 5) / 6]u8) !T {
351 fn intDecode(comptime T: type, src: *const [(@bitSizeOf(T) + 5) / 6]u8) !T {
352352 var v: T = 0;
353353 for (src) |x, i| {
354354 const vi = mem.indexOfScalar(u8, &map64, x) orelse return EncodingError.InvalidEncoding;
lib/std/event/wait_group.zig+1-1
......@@ -14,7 +14,7 @@ const Loop = std.event.Loop;
1414/// `begin` will return error.Overflow when the limit is reached, even
1515/// if the integer type has not has not overflowed.
1616/// By default `max_value` is set to std.math.maxInt(CounterType).
17pub const WaitGroup = WaitGroupGeneric(std.meta.bitCount(usize));
17pub const WaitGroup = WaitGroupGeneric(@bitSizeOf(usize));
1818
1919pub fn WaitGroupGeneric(comptime counter_size: u16) type {
2020 const CounterType = std.meta.Int(.unsigned, counter_size);
lib/std/fmt.zig+1-1
......@@ -1121,7 +1121,7 @@ pub fn formatFloatHexadecimal(
11211121 }
11221122
11231123 const T = @TypeOf(value);
1124 const TU = std.meta.Int(.unsigned, std.meta.bitCount(T));
1124 const TU = std.meta.Int(.unsigned, @bitSizeOf(T));
11251125
11261126 const mantissa_bits = math.floatMantissaBits(T);
11271127 const fractional_bits = math.floatFractionalBits(T);
lib/std/heap.zig+1-1
......@@ -1181,7 +1181,7 @@ pub fn testAllocatorLargeAlignment(base_allocator: mem.Allocator) !void {
11811181 // very near usize?
11821182 if (mem.page_size << 2 > maxInt(usize)) return;
11831183
1184 const USizeShift = std.meta.Int(.unsigned, std.math.log2(std.meta.bitCount(usize)));
1184 const USizeShift = std.meta.Int(.unsigned, std.math.log2(@bitSizeOf(usize)));
11851185 const large_align = @as(u29, mem.page_size << 2);
11861186
11871187 var align_mask: usize = undefined;
lib/std/io/bit_reader.zig+4-4
......@@ -17,9 +17,9 @@ pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type {
1717 pub const Reader = io.Reader(*Self, Error, read);
1818
1919 const Self = @This();
20 const u8_bit_count = meta.bitCount(u8);
21 const u7_bit_count = meta.bitCount(u7);
22 const u4_bit_count = meta.bitCount(u4);
20 const u8_bit_count = @bitSizeOf(u8);
21 const u7_bit_count = @bitSizeOf(u7);
22 const u4_bit_count = @bitSizeOf(u4);
2323
2424 pub fn init(forward_reader: ReaderType) Self {
2525 return Self{
......@@ -47,7 +47,7 @@ pub fn BitReader(endian: std.builtin.Endian, comptime ReaderType: type) type {
4747
4848 //by extending the buffer to a minimum of u8 we can cover a number of edge cases
4949 // related to shifting and casting.
50 const u_bit_count = comptime meta.bitCount(U);
50 const u_bit_count = @bitSizeOf(U);
5151 const buf_bit_count = bc: {
5252 assert(u_bit_count >= bits);
5353 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
lib/std/io/bit_writer.zig+3-3
......@@ -17,8 +17,8 @@ pub fn BitWriter(endian: std.builtin.Endian, comptime WriterType: type) type {
1717 pub const Writer = io.Writer(*Self, Error, write);
1818
1919 const Self = @This();
20 const u8_bit_count = meta.bitCount(u8);
21 const u4_bit_count = meta.bitCount(u4);
20 const u8_bit_count = @bitSizeOf(u8);
21 const u4_bit_count = @bitSizeOf(u4);
2222
2323 pub fn init(forward_writer: WriterType) Self {
2424 return Self{
......@@ -39,7 +39,7 @@ pub fn BitWriter(endian: std.builtin.Endian, comptime WriterType: type) type {
3939
4040 //by extending the buffer to a minimum of u8 we can cover a number of edge cases
4141 // related to shifting and casting.
42 const u_bit_count = comptime meta.bitCount(U);
42 const u_bit_count = @bitSizeOf(U);
4343 const buf_bit_count = bc: {
4444 assert(u_bit_count >= bits);
4545 break :bc if (u_bit_count <= u8_bit_count) u8_bit_count else u_bit_count;
lib/std/math.zig+2-2
......@@ -947,10 +947,10 @@ test "absCast" {
947947
948948/// Returns the negation of the integer parameter.
949949/// Result is a signed integer.
950pub fn negateCast(x: anytype) !std.meta.Int(.signed, std.meta.bitCount(@TypeOf(x))) {
950pub fn negateCast(x: anytype) !std.meta.Int(.signed, @bitSizeOf(@TypeOf(x))) {
951951 if (@typeInfo(@TypeOf(x)).Int.signedness == .signed) return negate(x);
952952
953 const int = std.meta.Int(.signed, std.meta.bitCount(@TypeOf(x)));
953 const int = std.meta.Int(.signed, @bitSizeOf(@TypeOf(x)));
954954 if (x > -minInt(int)) return error.Overflow;
955955
956956 if (x == -minInt(int)) return minInt(int);
lib/std/os.zig+1-1
......@@ -5561,7 +5561,7 @@ pub fn res_mkquery(
55615561 // Make a reasonably unpredictable id
55625562 var ts: timespec = undefined;
55635563 clock_gettime(CLOCK.REALTIME, &ts) catch {};
5564 const UInt = std.meta.Int(.unsigned, std.meta.bitCount(@TypeOf(ts.tv_nsec)));
5564 const UInt = std.meta.Int(.unsigned, @bitSizeOf(@TypeOf(ts.tv_nsec)));
55655565 const unsec = @bitCast(UInt, ts.tv_nsec);
55665566 const id = @truncate(u32, unsec + unsec / 65536);
55675567 q[0] = @truncate(u8, id / 256);
src/codegen/spirv.zig+1-1
......@@ -341,7 +341,7 @@ pub const DeclGen = struct {
341341 // We can just use toSignedInt/toUnsignedInt here as it returns u64 - a type large enough to hold any
342342 // SPIR-V native type (up to i/u64 with Int64). If SPIR-V ever supports native ints of a larger size, this
343343 // might need to be updated.
344 assert(self.largestSupportedIntBits() <= std.meta.bitCount(u64));
344 assert(self.largestSupportedIntBits() <= @bitSizeOf(u64));
345345
346346 // Note, value is required to be sign-extended, so we don't need to mask off the upper bits.
347347 // See https://www.khronos.org/registry/SPIR-V/specs/unified1/SPIRV.html#Literal
src/codegen/spirv/Section.zig+1-1
......@@ -170,7 +170,7 @@ fn writeString(section: *Section, str: []const u8) void {
170170
171171 var j: usize = 0;
172172 while (j < @sizeOf(Word) and i + j < str.len) : (j += 1) {
173 word |= @as(Word, str[i + j]) << @intCast(Log2Word, j * std.meta.bitCount(u8));
173 word |= @as(Word, str[i + j]) << @intCast(Log2Word, j * @bitSizeOf(u8));
174174 }
175175
176176 section.instructions.appendAssumeCapacity(word);