| ... | @@ -8,6 +8,7 @@ const syscall3 = sys.syscall3; | ... | @@ -8,6 +8,7 @@ const syscall3 = sys.syscall3; |
| 8 | const syscall4 = sys.syscall4; | 8 | const syscall4 = sys.syscall4; |
| 9 | const syscall5 = sys.syscall5; | 9 | const syscall5 = sys.syscall5; |
| 10 | const syscall6 = sys.syscall6; | 10 | const syscall6 = sys.syscall6; |
| | 11 | const pid_t = sys.pid_t; |
| 11 | | 12 | |
| 12 | fn _errno(rc: usize) enum(c_ushort) { ok, _ } { | 13 | fn _errno(rc: usize) enum(c_ushort) { ok, _ } { |
| 13 | const signed: isize = @bitCast(rc); | 14 | const signed: isize = @bitCast(rc); |
| ... | @@ -237,7 +238,13 @@ pub const setitimer = @compileError("TODO: setitimer"); | ... | @@ -237,7 +238,13 @@ pub const setitimer = @compileError("TODO: setitimer"); |
| 237 | // getpid | 238 | // getpid |
| 238 | // pid_t getpid(void); | 239 | // pid_t getpid(void); |
| 239 | // asmlinkage long sys_getpid(void); | 240 | // asmlinkage long sys_getpid(void); |
| 240 | pub const getpid = @compileError("TODO: getpid"); | 241 | pub fn getpid() errno.Error!pid_t { |
| | 242 | const r = syscall0(.getpid); |
| | 243 | return switch (_errno(r)) { |
| | 244 | .ok => @intCast(r), |
| | 245 | _ => |c| errno.errorFromInt(@intFromEnum(c)), |
| | 246 | }; |
| | 247 | } |
| 241 | | 248 | |
| 242 | // sendfile | 249 | // sendfile |
| 243 | // ssize_t sendfile(int out_fd, int in_fd, off_t *_Nullable offset, size_t count); | 250 | // ssize_t sendfile(int out_fd, int in_fd, off_t *_Nullable offset, size_t count); |