Skip to content

Commit

Permalink
fix @fieldParentPtr
Browse files Browse the repository at this point in the history
  • Loading branch information
psnszsn committed Apr 1, 2024
1 parent 0f73adf commit 3aa5358
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ThreadPool.zig
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ const Thread = struct {
thread_pool.notify(is_waking);
is_waking = false;

const task = @fieldParentPtr(Task, "node", result.node);
const task: *Task = @fieldParentPtr("node", result.node);
(task.callback)(task);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/epoll.zig
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ pub const Loop = struct {
/// This is the main callback for the threadpool to perform work
/// on completions for the loop.
fn thread_perform(t: *ThreadPool.Task) void {
const c = @fieldParentPtr(Completion, "task", t);
const c: *Completion = @fieldParentPtr("task", t);

// Do our task
c.task_result = c.perform();
Expand Down
2 changes: 1 addition & 1 deletion src/backend/iocp.zig
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ pub const Loop = struct {
continue;
}

break :completion @fieldParentPtr(Completion, "overlapped", overlapped_ptr.?);
break :completion @fieldParentPtr("overlapped", overlapped_ptr.?);
} else completion: {
// JobObjects are a special case where the OVERLAPPED_ENTRY fields are interpreted differently.
// When JOBOBJECT_ASSOCIATE_COMPLETION_PORT is used, lpOverlapped actually contains the message
Expand Down
2 changes: 1 addition & 1 deletion src/backend/kqueue.zig
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ pub const Loop = struct {
/// This is the main callback for the threadpool to perform work
/// on completions for the loop.
fn thread_perform(t: *ThreadPool.Task) void {
const c = @fieldParentPtr(Completion, "task", t);
const c: *Completion = @fieldParentPtr("task", t);

// Do our task
c.result = c.perform(null);
Expand Down
4 changes: 2 additions & 2 deletions src/build/ScdocStep.zig
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn init(builder: *Build) ScdocStep {
fn make(step: *std.Build.Step, progress: *std.Progress.Node) !void {
_ = progress;

const self = @fieldParentPtr(ScdocStep, "step", step);
const self: *ScdocStep = @fieldParentPtr("step", step);

// Create our cache path
// TODO(mitchellh): ideally this would be pure zig
Expand Down Expand Up @@ -129,7 +129,7 @@ const InstallStep = struct {
}

fn make(step: *Step, progress: *std.Progress.Node) !void {
const self = @fieldParentPtr(InstallStep, "step", step);
const self: *InstallStep = @fieldParentPtr("step", step);

// Get our absolute output path
var path = self.scdoc.out_path;
Expand Down
6 changes: 3 additions & 3 deletions src/c_api.zig
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ export fn xev_threadpool_task_init(
t.* = .{
.callback = (struct {
fn callback(inner_t: *xev.ThreadPool.Task) void {
@fieldParentPtr(
Task,
const task: *Task = @alignCast(@fieldParentPtr(
"data",
@as(*Task.Data, @ptrCast(inner_t)),
).c_callback(inner_t);
));
task.c_callback(inner_t);
}
}).callback,
};
Expand Down
2 changes: 1 addition & 1 deletion src/watcher/stream.zig
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ pub fn Writeable(comptime xev: type, comptime T: type, comptime options: Options
/// originally is from a write request. This is useful for getting
/// the WriteRequest back in a callback from queuedWrite.
pub fn from(c: *xev.Completion) *WriteRequest {
return @fieldParentPtr(WriteRequest, "completion", c);
return @fieldParentPtr("completion", c);
}
};

Expand Down

0 comments on commit 3aa5358

Please sign in to comment.