authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:45:54 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-02-15 16:45:54 -08:00
logeb05de73bf3d846d89c75177a6180760b83d434f
tree11873eca64f2eae95943c3c7325c576e6bfbac64
parentb60f398ce8bf942dbe93c6809c78be2debb76665

add memfd_create


2 files changed, 8 insertions(+), 0 deletions(-)

mod.zig+7
...@@ -2632,6 +2632,7 @@ pub const libc = struct {...@@ -2632,6 +2632,7 @@ pub const libc = struct {
2632 pub extern fn __errno_location() *c_int;2632 pub extern fn __errno_location() *c_int;
2633 pub extern fn gettid() pid_t;2633 pub extern fn gettid() pid_t;
2634 pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int;2634 pub extern fn accept4(socket: c_int, noalias address: ?*struct_sockaddr, noalias address_len: *socklen_t, flags: c_int) c_int;
2635 pub extern fn memfd_create(name: [*:0]const u8, flags: c_uint) c_int;
2635};2636};
26362637
2637pub const clock_t = c_long;2638pub const clock_t = c_long;
...@@ -3130,3 +3131,9 @@ pub fn clock_gettime(clock_id: clockid_t) !struct_timespec {...@@ -3130,3 +3131,9 @@ pub fn clock_gettime(clock_id: clockid_t) !struct_timespec {
3130 std.debug.assert(rc == 0);3131 std.debug.assert(rc == 0);
3131 return tp;3132 return tp;
3132}3133}
3134pub fn memfd_create(name: [*:0]const u8, flags: c_uint) !c_int {
3135 const rc = libc.memfd_create(name, flags);
3136 if (rc == -1) return errno.fromInt(errno.fromLibC());
3137 std.debug.assert(rc >= 0);
3138 return rc;
3139}
test.zig+1
...@@ -28,4 +28,5 @@ test {...@@ -28,4 +28,5 @@ test {
28 _ = &linux.getaddrinfo;28 _ = &linux.getaddrinfo;
29 _ = &linux.freeaddrinfo;29 _ = &linux.freeaddrinfo;
30 _ = &linux.clock_gettime;30 _ = &linux.clock_gettime;
31 _ = &linux.memfd_create;
31}32}