mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 15:13:08 +00:00
os: use system for memfd_create
- os: update flags type for memfd_create
This commit is contained in:
parent
997812e8fb
commit
f0cbf63e1a
@ -3282,12 +3282,9 @@ pub fn setsockopt(fd: fd_t, level: u32, optname: u32, opt: []const u8) SetSockOp
|
||||
}
|
||||
}
|
||||
|
||||
// TODO support for non-null terminated strings?
|
||||
pub fn memfd_createC(name: [*:0]const u8, flags: usize) !fd_t {
|
||||
if (builtin.os != .linux) @compileError("memfd_create() not implemented for this target");
|
||||
|
||||
const rc = linux.memfd_create(name, flags);
|
||||
switch (linux.getErrno(rc)) {
|
||||
pub fn memfd_createC(name: [*:0]const u8, flags: u32) !fd_t {
|
||||
const rc = system.memfd_create(name, flags);
|
||||
switch (errno(rc)) {
|
||||
0 => return @intCast(fd_t, rc),
|
||||
EFAULT => unreachable, // name has invalid memory
|
||||
EINVAL => unreachable, // name/flags are faulty
|
||||
@ -3309,7 +3306,7 @@ fn toMemFdPath(name: []const u8) ![MFD_MAX_NAME_LEN:0]u8 {
|
||||
return path_with_null;
|
||||
}
|
||||
|
||||
pub fn memfd_create(name: []const u8, flags: usize) !fd_t {
|
||||
pub fn memfd_create(name: []const u8, flags: u32) !fd_t {
|
||||
const name_t = try toMemFdPath(name);
|
||||
return try memfd_createC(&name_t, flags);
|
||||
}
|
||||
|
||||
@ -1110,7 +1110,7 @@ pub fn io_uring_register(fd: i32, opcode: u32, arg: ?*const c_void, nr_args: u32
|
||||
return syscall4(SYS_io_uring_register, @bitCast(usize, @as(isize, fd)), opcode, @ptrToInt(arg), nr_args);
|
||||
}
|
||||
|
||||
pub fn memfd_create(name: [*:0]const u8, flags: usize) usize {
|
||||
pub fn memfd_create(name: [*:0]const u8, flags: u32) usize {
|
||||
return syscall2(SYS_memfd_create, @ptrToInt(name), flags);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user