std.c: fix incorrect return types

Closes #12964
This commit is contained in:
Ali Chraghi 2022-09-28 20:21:33 +03:30 committed by Veikka Tuominen
parent 6af0eeb58d
commit fb366f3cd4
2 changed files with 14 additions and 6 deletions

View File

@ -80,11 +80,11 @@ pub extern "c" fn posix_memalign(memptr: *?*anyopaque, alignment: usize, size: u
pub const posix_spawnattr_t = *opaque {};
pub const posix_spawn_file_actions_t = *opaque {};
pub extern "c" fn posix_spawnattr_init(attr: *posix_spawnattr_t) c_int;
pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) void;
pub extern "c" fn posix_spawnattr_destroy(attr: *posix_spawnattr_t) c_int;
pub extern "c" fn posix_spawnattr_setflags(attr: *posix_spawnattr_t, flags: c_short) c_int;
pub extern "c" fn posix_spawnattr_getflags(attr: *const posix_spawnattr_t, flags: *c_short) c_int;
pub extern "c" fn posix_spawn_file_actions_init(actions: *posix_spawn_file_actions_t) c_int;
pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) void;
pub extern "c" fn posix_spawn_file_actions_destroy(actions: *posix_spawn_file_actions_t) c_int;
pub extern "c" fn posix_spawn_file_actions_addclose(actions: *posix_spawn_file_actions_t, filedes: fd_t) c_int;
pub extern "c" fn posix_spawn_file_actions_addopen(
actions: *posix_spawn_file_actions_t,

View File

@ -47,8 +47,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
}
pub fn deinit(self: *Attr) void {
system.posix_spawnattr_destroy(&self.attr);
self.* = undefined;
defer self.* = undefined;
switch (errno(system.posix_spawnattr_destroy(&self.attr))) {
.SUCCESS => return,
.INVAL => unreachable, // Invalid parameters.
else => unreachable,
}
}
pub fn get(self: Attr) Error!u16 {
@ -83,8 +87,12 @@ const posix_spawn = if (builtin.target.isDarwin()) struct {
}
pub fn deinit(self: *Actions) void {
system.posix_spawn_file_actions_destroy(&self.actions);
self.* = undefined;
defer self.* = undefined;
switch (errno(system.posix_spawn_file_actions_destroy(&self.actions))) {
.SUCCESS => return,
.INVAL => unreachable, // Invalid parameters.
else => unreachable,
}
}
pub fn open(self: *Actions, fd: fd_t, path: []const u8, flags: u32, mode: mode_t) Error!void {