chore: update to latest builtin syntax
This commit is contained in:
parent
e616cf09e5
commit
322c798e38
14
src/lib.zig
14
src/lib.zig
|
@ -101,7 +101,7 @@ pub fn Channel(comptime T: type, comptime N: usize) type {
|
|||
};
|
||||
|
||||
fn mask(idx: Index) Index {
|
||||
return idx & (@intCast(Index, N) - 1);
|
||||
return idx & (@as(Index, @intCast(N)) - 1);
|
||||
}
|
||||
|
||||
pub fn init(allocator: Allocator) !Channel(T, N) {
|
||||
|
@ -123,9 +123,9 @@ pub fn Channel(comptime T: type, comptime N: usize) type {
|
|||
}
|
||||
|
||||
pub fn deinit(self: *Channel(T, N), allocator: Allocator) void {
|
||||
const indicies: []Index = @ptrCast([*]Index, self.tx.read)[0..2];
|
||||
const indicies: [*]Index = @ptrCast(self.tx.read);
|
||||
|
||||
allocator.free(indicies);
|
||||
allocator.free(indicies[0..2]);
|
||||
allocator.free(self.tx.ptr);
|
||||
|
||||
self.* = undefined;
|
||||
|
@ -221,7 +221,7 @@ pub fn RingBuffer(comptime T: type) type {
|
|||
|
||||
/// Returns the number of entries read
|
||||
pub fn copy(self: *const Self, cpy: []T) Index {
|
||||
const count = std.math.min(self.len(), cpy.len);
|
||||
const count = @min(self.len(), cpy.len);
|
||||
var start: Index = self.read;
|
||||
|
||||
for (cpy, 0..) |*v, i| {
|
||||
|
@ -259,9 +259,9 @@ pub fn sext(comptime T: type, comptime U: type, value: T) T {
|
|||
|
||||
const iT = std.meta.Int(.signed, @typeInfo(T).Int.bits);
|
||||
const ExtU = if (@typeInfo(U).Int.signedness == .unsigned) T else iT;
|
||||
const shift_amt = @intCast(Log2Int(T), @typeInfo(T).Int.bits - @typeInfo(U).Int.bits);
|
||||
const shift_amt: Log2Int(T) = @intCast(@typeInfo(T).Int.bits - @typeInfo(U).Int.bits);
|
||||
|
||||
return @bitCast(T, @bitCast(iT, @as(ExtU, @truncate(U, value)) << shift_amt) >> shift_amt);
|
||||
return @bitCast(@as(iT, @bitCast(@as(ExtU, @as(U, @truncate(value))) << shift_amt)) >> shift_amt);
|
||||
}
|
||||
|
||||
/// See https://godbolt.org/z/W3en9Eche
|
||||
|
@ -269,6 +269,6 @@ pub inline fn rotr(comptime T: type, x: T, r: anytype) T {
|
|||
if (@typeInfo(T).Int.signedness == .signed)
|
||||
@compileError("cannot rotate signed integer");
|
||||
|
||||
const ar = @intCast(Log2Int(T), @mod(r, @typeInfo(T).Int.bits));
|
||||
const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits));
|
||||
return x >> ar | x << (1 +% ~ar);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue