Skip to content

Commit

Permalink
upgrade to 0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
krichprollsch committed Feb 12, 2025
1 parent a3a0145 commit 530d949
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
4 changes: 2 additions & 2 deletions checksum.zig
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test "checksum test vectors" {
}

test "checksum simple fuzzing" {
var prng = std.rand.DefaultPrng.init(42);
var prng = std.Random.DefaultPrng.init(42);

const msg_min = 1;
const msg_max = 1 * 1024 * 1024;
Expand Down Expand Up @@ -180,7 +180,7 @@ test "checksum stability" {
}

// Pseudo-random data from a specific PRNG of various lengths.
var prng = std.rand.Xoshiro256.init(92);
var prng = std.Random.Xoshiro256.init(92);
subcase = 0;
while (subcase < 256) : (subcase += 1) {
const message = buf[0 .. subcase + 13];
Expand Down
13 changes: 6 additions & 7 deletions io/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ pub const IO = struct {
// We must use the same clock source used by io_uring (CLOCK_MONOTONIC) since we specify the
// timeout below as an absolute value. Otherwise, we may deadlock if the clock sources are
// dramatically different. Any kernel that supports io_uring will support CLOCK_MONOTONIC.
var current_ts: posix.timespec = undefined;
posix.clock_gettime(posix.CLOCK.MONOTONIC, &current_ts) catch unreachable;
const current_ts = posix.clock_gettime(posix.CLOCK.MONOTONIC) catch unreachable;
// The absolute CLOCK_MONOTONIC time after which we may return from this function:
const timeout_ts: os.linux.kernel_timespec = .{
.tv_sec = current_ts.tv_sec,
.tv_nsec = current_ts.tv_nsec + nanoseconds,
.sec = current_ts.sec,
.nsec = current_ts.nsec + nanoseconds,
};
var timeouts: usize = 0;
var etime = false;
Expand Down Expand Up @@ -175,8 +174,8 @@ pub const IO = struct {
// 2) potentially queues more SQEs to take advantage more of the next flush_submissions().
while (self.completed.pop()) |completion| {
if (completion.operation == .timeout and
completion.operation.timeout.timespec.tv_sec == 0 and
completion.operation.timeout.timespec.tv_nsec == 0)
completion.operation.timeout.timespec.sec == 0 and
completion.operation.timeout.timespec.nsec == 0)
{
// Zero-duration timeouts are a special case, and aren't listed in `awaiting`.
maybe(self.awaiting.empty());
Expand Down Expand Up @@ -1359,7 +1358,7 @@ pub const IO = struct {
}.wrapper,
.operation = .{
.timeout = .{
.timespec = .{ .tv_sec = 0, .tv_nsec = nanoseconds },
.timespec = .{ .sec = 0, .nsec = nanoseconds },
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion list.zig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn DoublyLinkedListType(
comptime field_back_enum: std.meta.FieldEnum(Node),
comptime field_next_enum: std.meta.FieldEnum(Node),
) type {
assert(@typeInfo(Node) == .Struct);
assert(@typeInfo(Node) == .@"struct");
assert(field_back_enum != field_next_enum);
assert(std.meta.FieldType(Node, field_back_enum) == ?*Node);
assert(std.meta.FieldType(Node, field_next_enum) == ?*Node);
Expand Down
2 changes: 1 addition & 1 deletion stdx.zig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub const log = if (builtin.is_test)
// Downgrade `err` to `warn` for tests.
// Zig fails any test that does `log.err`, but we want to test those code paths here.
struct {
pub fn scoped(comptime scope: @Type(.EnumLiteral)) type {
pub fn scoped(comptime scope: @Type(.enum_literal)) type {
const base = std.log.scoped(scope);
return struct {
pub const err = warn;
Expand Down
7 changes: 3 additions & 4 deletions time.zig
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ pub const Time = struct {
// CLOCK_BOOTTIME is the same as CLOCK_MONOTONIC but includes elapsed time during a suspend.
// For more detail and why CLOCK_MONOTONIC_RAW is even worse than CLOCK_MONOTONIC,
// see https://github.com/ziglang/zig/pull/933#discussion_r656021295.
var ts: std.posix.timespec = undefined;
std.posix.clock_gettime(std.posix.CLOCK.BOOTTIME, &ts) catch @panic("CLOCK_BOOTTIME required");
break :blk @as(u64, @intCast(ts.tv_sec)) * std.time.ns_per_s + @as(u64, @intCast(ts.tv_nsec));
const ts = std.posix.clock_gettime(std.posix.CLOCK.BOOTTIME) catch @panic("CLOCK_BOOTTIME required");
break :blk @as(u64, @intCast(ts.sec)) * std.time.ns_per_s + @as(u64, @intCast(ts.nsec));
};

// "Oops!...I Did It Again"
Expand Down Expand Up @@ -105,7 +104,7 @@ pub const Time = struct {

var ts: std.posix.timespec = undefined;
std.posix.clock_gettime(std.posix.CLOCK.REALTIME, &ts) catch unreachable;
return @as(i64, ts.tv_sec) * std.time.ns_per_s + ts.tv_nsec;
return @as(i64, ts.sec) * std.time.ns_per_s + ts.nsec;
}

pub fn tick(_: *Self) void {}
Expand Down

0 comments on commit 530d949

Please sign in to comment.