Skip to content

Commit

Permalink
chore!: update for zig 0.14.0-dev+0fe3fd01d
Browse files Browse the repository at this point in the history
  • Loading branch information
dweiller committed Sep 2, 2024
1 parent 346d074 commit 0ec36fa
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/strided_array.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ pub const ViewError = error{
};

pub fn StridedArrayView(comptime T: type, comptime num_dims: usize) type {
const bit_size = @typeInfo(usize).Int.bits / 2;
return StridedArrayViewIdx(T, num_dims, @Type(.{ .Int = .{ .bits = bit_size, .signedness = .unsigned } }));
const bit_size = @typeInfo(usize).int.bits / 2;
return StridedArrayViewIdx(T, num_dims, @Type(.{
.int = .{ .bits = bit_size, .signedness = .unsigned },
}));
}

pub fn StridedArrayViewIdx(comptime T: type, comptime num_dims: usize, comptime IndexType: type) type {
Expand All @@ -29,16 +31,19 @@ pub fn StridedArrayViewIdx(comptime T: type, comptime num_dims: usize, comptime

const info = @typeInfo(IndexType);
comptime {
if (info != .Int or info.Int.signedness == .signed) {
if (info != .int or info.int.signedness == .signed) {
@compileError("StridedArrayView IndexType must be an unsigned integer type");
}
if (info.Int.bits > 64) {
@compileError(std.fmt.comptimePrint("Maximum allowed bit size is for IndexType is 64; got {d}-bit type", .{info.Int.bits}));
if (info.int.bits > 64) {
@compileError(std.fmt.comptimePrint(
"Maximum allowed bit size is for IndexType is 64; got {d}-bit type",
.{info.int.bits},
));
}
}

pub const Indices = [num_dims]IndexType;
pub const StrideType = @Type(.{ .Int = .{ .bits = 2 * info.Int.bits, .signedness = .signed } });
pub const StrideType = @Type(.{ .int = .{ .bits = 2 * info.int.bits, .signedness = .signed } });
pub const Stride = [num_dims]StrideType;

pub const dim_count = num_dims;
Expand Down

0 comments on commit 0ec36fa

Please sign in to comment.