diff options
author | 2022-11-12 01:13:35 +0100 | |
---|---|---|
committer | 2022-11-12 01:13:35 +0100 | |
commit | 00ca7a91c11afb9cd69c28931bf762a34470ab67 (patch) | |
tree | 048b13a7181b9f54c9ef7d6a251f146b336d44ee | |
parent | bfee0961d7beb8946b9cc98868ddad1a0db9e49c (diff) | |
download | bun-00ca7a91c11afb9cd69c28931bf762a34470ab67.tar.gz bun-00ca7a91c11afb9cd69c28931bf762a34470ab67.tar.zst bun-00ca7a91c11afb9cd69c28931bf762a34470ab67.zip |
Fix: @ctz/@popCount - expected 1 argument, found 2
-rw-r--r-- | src/http/websocket.zig | 2 | ||||
-rw-r--r-- | src/http/websocket_http_client.zig | 2 | ||||
-rw-r--r-- | src/install/bit_set.zig | 28 | ||||
-rw-r--r-- | src/string_immutable.zig | 6 |
4 files changed, 19 insertions, 19 deletions
diff --git a/src/http/websocket.zig b/src/http/websocket.zig index 12348f83c..8e0b84682 100644 --- a/src/http/websocket.zig +++ b/src/http/websocket.zig @@ -190,7 +190,7 @@ pub const Websocket = struct { // Close and send the status pub fn close(self: *Websocket, code: u16) !void { - const c = if (native_endian == .Big) code else @byteSwap(u16, code); + const c = if (native_endian == .Big) code else @byteSwap(@as(u16, code)); const data = @bitCast([2]u8, c); _ = try self.writeMessage(.Close, &data); } diff --git a/src/http/websocket_http_client.zig b/src/http/websocket_http_client.zig index 1f2f7f5d6..24aeaf472 100644 --- a/src/http/websocket_http_client.zig +++ b/src/http/websocket_http_client.zig @@ -639,7 +639,7 @@ fn parseWebSocketHeader( // + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // | Payload Data continued ... | // +---------------------------------------------------------------+ - const header = @bitCast(WebsocketHeader, @byteSwap(u16, @bitCast(u16, bytes))); + const header = @bitCast(WebsocketHeader, @byteSwap(@as(u16, @bitCast(u16, bytes)))); const payload = @as(usize, header.len); payload_length.* = payload; receiving_type.* = header.opcode; diff --git a/src/install/bit_set.zig b/src/install/bit_set.zig index 64903c9e9..bb23b4e01 100644 --- a/src/install/bit_set.zig +++ b/src/install/bit_set.zig @@ -91,7 +91,7 @@ pub fn IntegerBitSet(comptime size: u16) type { /// Returns the total number of set bits in this bit set. pub fn count(self: Self) usize { - return @popCount(MaskInt, self.mask); + return @popCount(@as(MaskInt, self.mask)); } /// Changes the value of the specified bit of the bit @@ -154,7 +154,7 @@ pub fn IntegerBitSet(comptime size: u16) type { pub fn findFirstSet(self: Self) ?usize { const mask = self.mask; if (mask == 0) return null; - return @ctz(MaskInt, mask); + return @ctz(@as(MaskInt, mask)); } /// Finds the index of the first set bit, and unsets it. @@ -162,7 +162,7 @@ pub fn IntegerBitSet(comptime size: u16) type { pub fn toggleFirstSet(self: *Self) ?usize { const mask = self.mask; if (mask == 0) return null; - const index = @ctz(MaskInt, mask); + const index = @ctz(@as(MaskInt, mask)); self.mask = mask & (mask - 1); return index; } @@ -197,12 +197,12 @@ pub fn IntegerBitSet(comptime size: u16) type { switch (direction) { .forward => { - const next_index = @ctz(MaskInt, self.bits_remain); + const next_index = @ctz(@as(MaskInt, self.bits_remain)); self.bits_remain &= self.bits_remain - 1; return next_index; }, .reverse => { - const leading_zeroes = @clz(MaskInt, self.bits_remain); + const leading_zeroes = @clz(@as(MaskInt, self.bits_remain)); const top_bit = (@bitSizeOf(MaskInt) - 1) - leading_zeroes; self.bits_remain &= (@as(MaskInt, 1) << @intCast(ShiftInt, top_bit)) - 1; return top_bit; @@ -322,7 +322,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { pub fn count(self: Self) usize { var total: usize = 0; for (self.masks) |mask| { - total += @popCount(MaskInt, mask); + total += @popCount(@as(MaskInt, mask)); } return total; } @@ -405,7 +405,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { if (mask != 0) break mask; offset += @bitSizeOf(MaskInt); } else return null; - return offset + @ctz(MaskInt, mask); + return offset + @ctz(@as(MaskInt, mask)); } /// Finds the index of the first set bit, and unsets it. @@ -416,7 +416,7 @@ pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type { if (mask.* != 0) break mask; offset += @bitSizeOf(MaskInt); } else return null; - const index = @ctz(MaskInt, mask.*); + const index = @ctz(@as(MaskInt, mask.*)); mask.* &= (mask.* - 1); return offset + index; } @@ -587,7 +587,7 @@ pub const DynamicBitSetUnmanaged = struct { var total: usize = 0; for (self.masks[0..num_masks]) |mask| { // Note: This is where we depend on padding bits being zero - total += @popCount(MaskInt, mask); + total += @popCount(@as(MaskInt, mask)); } return total; } @@ -712,7 +712,7 @@ pub const DynamicBitSetUnmanaged = struct { mask += 1; offset += @bitSizeOf(MaskInt); } else return null; - return offset + @ctz(MaskInt, mask[0]); + return offset + @ctz(@as(MaskInt, mask[0])); } /// Finds the index of the first set bit, and unsets it. @@ -725,7 +725,7 @@ pub const DynamicBitSetUnmanaged = struct { mask += 1; offset += @bitSizeOf(MaskInt); } else return null; - const index = @ctz(MaskInt, mask[0]); + const index = @ctz(@as(MaskInt, mask[0])); mask[0] &= (mask[0] - 1); return offset + index; } @@ -929,7 +929,7 @@ pub const IteratorOptions = struct { // The iterator is reusable between several bit set types fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) type { - const ShiftInt = std.math.Log2Int(MaskInt); + //const ShiftInt = std.math.Log2Int(MaskInt); const kind = options.kind; const direction = options.direction; return struct { @@ -978,12 +978,12 @@ fn BitSetIterator(comptime MaskInt: type, comptime options: IteratorOptions) typ switch (direction) { .forward => { - const next_index = @ctz(MaskInt, self.bits_remain) + self.bit_offset; + const next_index = @ctz(@as(MaskInt, self.bits_remain)) + self.bit_offset; self.bits_remain &= self.bits_remain - 1; return next_index; }, .reverse => { - const leading_zeroes = @clz(MaskInt, self.bits_remain); + const leading_zeroes = @clz(@as(MaskInt, self.bits_remain)); const top_bit = (@bitSizeOf(MaskInt) - 1) - leading_zeroes; const no_top_bit_mask = (@as(MaskInt, 1) << @intCast(ShiftInt, top_bit)) - 1; self.bits_remain &= no_top_bit_mask; diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 1ebe7d5bf..2978d94f3 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -583,7 +583,7 @@ pub fn countChar(self: string, char: u8) usize { while (remaining.len >= 16) { const vec: AsciiVector = remaining[0..ascii_vector_size].*; - const cmp = @popCount(std.meta.Int(.unsigned, ascii_vector_size), @bitCast(@Vector(ascii_vector_size, u1), vec == splatted)); + const cmp = @popCount(@as(std.meta.Int(.unsigned, ascii_vector_size), @bitCast(@Vector(ascii_vector_size, u1), vec == splatted))); total += @as(usize, @reduce(.Add, cmp)); remaining = remaining[ascii_vector_size..]; } @@ -1506,7 +1506,7 @@ pub fn elementLengthLatin1IntoUTF8(comptime Type: type, latin1_: Type) usize { @bitCast(Int, latin1[size .. 2 * size].*) & 0x8080808080808080, }; - const non_ascii_count = ((@popCount(Int, bytes[0]) / 8) + (@popCount(Int, bytes[1]) / 8)); + const non_ascii_count = ((@popCount(@as(Int, bytes[0])) / 8) + (@popCount(@as(Int, bytes[1])) / 8)); total_non_ascii_count += non_ascii_count; } @@ -1516,7 +1516,7 @@ pub fn elementLengthLatin1IntoUTF8(comptime Type: type, latin1_: Type) usize { if (latin1.len >= 8) { const bytes = @bitCast(u64, latin1[0..8].*) & 0x8080808080808080; - total_non_ascii_count += @popCount(u64, bytes) / 8; + total_non_ascii_count += @popCount(@as(u64, bytes)) / 8; latin1 = latin1[8..]; } |