| author | |
| committer | |
| log | 3729a53eec1951376c01c7e799b439b1a84694b5 |
| tree | df577ec853092443383a641da73cdc5b905d901e |
| parent | 5652288e5d86e906e1558a7fdfc26126e96e9d82 |
| parent | 73ed3510220d387e17d4a4a25837cb982373f12c |
Reviewed-on: https://codeberg.org/ziglang/zig/pulls/30993
Reviewed-by: Andrew Kelley <andrew@ziglang.org>57 files changed, 322 insertions(+), 479 deletions(-)
lib/c.zig+1| ... | @@ -26,6 +26,7 @@ comptime { | ... | @@ -26,6 +26,7 @@ comptime { |
| 26 | _ = @import("c/wchar.zig"); | 26 | _ = @import("c/wchar.zig"); |
| 27 | 27 | ||
| 28 | _ = @import("c/sys.zig"); | 28 | _ = @import("c/sys.zig"); |
| 29 | _ = @import("c/unistd.zig"); | ||
| 29 | 30 | ||
| 30 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { | 31 | if (builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) { |
| 31 | // Files specific to musl and wasi-libc. | 32 | // Files specific to musl and wasi-libc. |
lib/c/sys.zig+4| ... | @@ -1,3 +1,7 @@ | ... | @@ -1,3 +1,7 @@ |
| 1 | comptime { | 1 | comptime { |
| 2 | _ = @import("sys/mman.zig"); | ||
| 3 | _ = @import("sys/file.zig"); | ||
| 4 | _ = @import("sys/reboot.zig"); | ||
| 5 | _ = @import("sys/capability.zig"); | ||
| 2 | _ = @import("sys/utsname.zig"); | 6 | _ = @import("sys/utsname.zig"); |
| 3 | } | 7 | } |
lib/c/sys/capability.zig created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | |||
| 5 | comptime { | ||
| 6 | if (builtin.target.isMuslLibC()) { | ||
| 7 | @export(&capsetLinux, .{ .name = "capset", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 8 | @export(&capgetLinux, .{ .name = "capget", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 9 | } | ||
| 10 | } | ||
| 11 | |||
| 12 | fn capsetLinux(hdrp: *anyopaque, datap: *anyopaque) callconv(.c) c_int { | ||
| 13 | return common.errno(std.os.linux.capset(@ptrCast(@alignCast(hdrp)), @ptrCast(@alignCast(datap)))); | ||
| 14 | } | ||
| 15 | |||
| 16 | fn capgetLinux(hdrp: *anyopaque, datap: *anyopaque) callconv(.c) c_int { | ||
| 17 | return common.errno(std.os.linux.capget(@ptrCast(@alignCast(hdrp)), @ptrCast(@alignCast(datap)))); | ||
| 18 | } | ||
lib/c/sys/file.zig created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | |||
| 5 | comptime { | ||
| 6 | if (builtin.target.isMuslLibC()) { | ||
| 7 | @export(&flockLinux, .{ .name = "flock", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 8 | } | ||
| 9 | } | ||
| 10 | |||
| 11 | fn flockLinux(fd: c_int, operation: c_int) callconv(.c) c_int { | ||
| 12 | return common.errno(std.os.linux.flock(fd, operation)); | ||
| 13 | } | ||
lib/c/sys/mman.zig created+59| ... | @@ -0,0 +1,59 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | |||
| 5 | comptime { | ||
| 6 | if (builtin.target.isMuslLibC()) { | ||
| 7 | @export(&madviseLinux, .{ .name = "madvise", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 8 | @export(&madviseLinux, .{ .name = "__madvise", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 9 | |||
| 10 | @export(&mincoreLinux, .{ .name = "mincore", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 11 | |||
| 12 | @export(&mlockLinux, .{ .name = "mlock", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 13 | @export(&mlockallLinux, .{ .name = "mlockall", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 14 | |||
| 15 | @export(&mprotectLinux, .{ .name = "mprotect", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 16 | @export(&mprotectLinux, .{ .name = "__mprotect", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 17 | |||
| 18 | @export(&munlockLinux, .{ .name = "munlock", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 19 | @export(&munlockallLinux, .{ .name = "munlockall", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 20 | |||
| 21 | @export(&posix_madviseLinux, .{ .name = "posix_madvise", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | fn madviseLinux(addr: *anyopaque, len: usize, advice: c_int) callconv(.c) c_int { | ||
| 26 | return common.errno(std.os.linux.madvise(@ptrCast(addr), len, @bitCast(advice))); | ||
| 27 | } | ||
| 28 | |||
| 29 | fn mincoreLinux(addr: *anyopaque, len: usize, vec: [*]u8) callconv(.c) c_int { | ||
| 30 | return common.errno(std.os.linux.mincore(@ptrCast(addr), len, vec)); | ||
| 31 | } | ||
| 32 | |||
| 33 | fn mlockLinux(addr: *const anyopaque, len: usize) callconv(.c) c_int { | ||
| 34 | return common.errno(std.os.linux.mlock(@ptrCast(addr), len)); | ||
| 35 | } | ||
| 36 | |||
| 37 | fn mlockallLinux(flags: c_int) callconv(.c) c_int { | ||
| 38 | return common.errno(std.os.linux.mlockall(@bitCast(flags))); | ||
| 39 | } | ||
| 40 | |||
| 41 | fn mprotectLinux(addr: *anyopaque, len: usize, prot: c_int) callconv(.c) c_int { | ||
| 42 | const page_size = std.heap.pageSize(); | ||
| 43 | const start = std.mem.alignBackward(usize, @intFromPtr(addr), page_size); | ||
| 44 | const aligned_len = std.mem.alignForward(usize, len, page_size); | ||
| 45 | return common.errno(std.os.linux.mprotect(@ptrFromInt(start), aligned_len, @bitCast(prot))); | ||
| 46 | } | ||
| 47 | |||
| 48 | fn munlockLinux(addr: *const anyopaque, len: usize) callconv(.c) c_int { | ||
| 49 | return common.errno(std.os.linux.munlock(@ptrCast(addr), len)); | ||
| 50 | } | ||
| 51 | |||
| 52 | fn munlockallLinux() callconv(.c) c_int { | ||
| 53 | return common.errno(std.os.linux.munlockall()); | ||
| 54 | } | ||
| 55 | |||
| 56 | fn posix_madviseLinux(addr: *anyopaque, len: usize, advice: c_int) callconv(.c) c_int { | ||
| 57 | if (advice == std.os.linux.MADV.DONTNEED) return 0; | ||
| 58 | return @intCast(-@as(isize, @bitCast(std.os.linux.madvise(@ptrCast(addr), len, @bitCast(advice))))); | ||
| 59 | } | ||
lib/c/sys/reboot.zig created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("../common.zig"); | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | |||
| 5 | comptime { | ||
| 6 | if (builtin.target.isMuslLibC()) { | ||
| 7 | @export(&rebootLinux, .{ .name = "reboot", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 8 | } | ||
| 9 | } | ||
| 10 | |||
| 11 | fn rebootLinux(cmd: c_int) callconv(.c) c_int { | ||
| 12 | return common.errno(std.os.linux.reboot(.MAGIC1, .MAGIC2, @enumFromInt(cmd), null)); | ||
| 13 | } | ||
lib/c/unistd.zig created+183| ... | @@ -0,0 +1,183 @@ | ||
| 1 | const std = @import("std"); | ||
| 2 | const common = @import("common.zig"); | ||
| 3 | const builtin = @import("builtin"); | ||
| 4 | const linux = std.os.linux; | ||
| 5 | |||
| 6 | comptime { | ||
| 7 | if (builtin.target.isMuslLibC()) { | ||
| 8 | @export(&_exit, .{ .name = "_exit", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 9 | |||
| 10 | @export(&accessLinux, .{ .name = "access", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 11 | @export(&acctLinux, .{ .name = "acct", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 12 | @export(&chdirLinux, .{ .name = "chdir", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 13 | @export(&chownLinux, .{ .name = "chown", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 14 | @export(&fchownatLinux, .{ .name = "fchownat", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 15 | @export(&lchownLinux, .{ .name = "lchown", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 16 | @export(&chrootLinux, .{ .name = "chroot", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 17 | @export(&ctermidLinux, .{ .name = "ctermid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 18 | @export(&dupLinux, .{ .name = "dup", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 19 | |||
| 20 | @export(&getegidLinux, .{ .name = "getegid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 21 | @export(&geteuidLinux, .{ .name = "geteuid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 22 | @export(&getgidLinux, .{ .name = "getgid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 23 | @export(&getgroupsLinux, .{ .name = "getgroups", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 24 | @export(&getpgidLinux, .{ .name = "getpgid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 25 | @export(&getpgrpLinux, .{ .name = "getpgrp", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 26 | @export(&setpgidLinux, .{ .name = "setpgid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 27 | @export(&setpgrpLinux, .{ .name = "setpgrp", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 28 | @export(&getsidLinux, .{ .name = "getsid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 29 | @export(&getpidLinux, .{ .name = "getpid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 30 | @export(&getppidLinux, .{ .name = "getppid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 31 | @export(&getuidLinux, .{ .name = "getuid", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 32 | |||
| 33 | @export(&rmdirLinux, .{ .name = "rmdir", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 34 | @export(&linkLinux, .{ .name = "link", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 35 | @export(&linkatLinux, .{ .name = "linkat", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 36 | @export(&pipeLinux, .{ .name = "pipe", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 37 | @export(&renameatLinux, .{ .name = "renameat", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 38 | @export(&symlinkLinux, .{ .name = "symlink", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 39 | @export(&symlinkatLinux, .{ .name = "symlinkat", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 40 | @export(&syncLinux, .{ .name = "sync", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 41 | @export(&unlinkLinux, .{ .name = "unlink", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 42 | @export(&unlinkatLinux, .{ .name = "unlinkat", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 43 | |||
| 44 | @export(&execveLinux, .{ .name = "execve", .linkage = common.linkage, .visibility = common.visibility }); | ||
| 45 | } | ||
| 46 | } | ||
| 47 | |||
| 48 | fn _exit(exit_code: c_int) callconv(.c) noreturn { | ||
| 49 | std.c._Exit(exit_code); | ||
| 50 | } | ||
| 51 | |||
| 52 | fn accessLinux(path: [*:0]const c_char, amode: c_int) callconv(.c) c_int { | ||
| 53 | return common.errno(linux.access(@ptrCast(path), @bitCast(amode))); | ||
| 54 | } | ||
| 55 | |||
| 56 | fn acctLinux(path: [*:0]const c_char) callconv(.c) c_int { | ||
| 57 | return common.errno(linux.acct(@ptrCast(path))); | ||
| 58 | } | ||
| 59 | |||
| 60 | fn chdirLinux(path: [*:0]const c_char) callconv(.c) c_int { | ||
| 61 | return common.errno(linux.chdir(@ptrCast(path))); | ||
| 62 | } | ||
| 63 | |||
| 64 | fn chownLinux(path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t) callconv(.c) c_int { | ||
| 65 | return common.errno(linux.chown(@ptrCast(path), uid, gid)); | ||
| 66 | } | ||
| 67 | |||
| 68 | fn fchownatLinux(fd: c_int, path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t, flags: c_int) callconv(.c) c_int { | ||
| 69 | return common.errno(linux.fchownat(fd, @ptrCast(path), uid, gid, @bitCast(flags))); | ||
| 70 | } | ||
| 71 | |||
| 72 | fn lchownLinux(path: [*:0]const c_char, uid: linux.uid_t, gid: linux.gid_t) callconv(.c) c_int { | ||
| 73 | return common.errno(linux.lchown(@ptrCast(path), uid, gid)); | ||
| 74 | } | ||
| 75 | |||
| 76 | fn chrootLinux(path: [*:0]const c_char) callconv(.c) c_int { | ||
| 77 | return common.errno(linux.chroot(@ptrCast(path))); | ||
| 78 | } | ||
| 79 | |||
| 80 | fn ctermidLinux(maybe_path: ?[*]c_char) callconv(.c) [*:0]c_char { | ||
| 81 | const default_tty = "/dev/tty"; | ||
| 82 | |||
| 83 | return if (maybe_path) |path| blk: { | ||
| 84 | path[0..(default_tty.len + 1)].* = @bitCast(default_tty.*); | ||
| 85 | break :blk path[0..default_tty.len :0].ptr; | ||
| 86 | } else @ptrCast(@constCast(default_tty)); | ||
| 87 | } | ||
| 88 | |||
| 89 | fn dupLinux(fd: c_int) callconv(.c) c_int { | ||
| 90 | return common.errno(linux.dup(fd)); | ||
| 91 | } | ||
| 92 | |||
| 93 | fn getegidLinux() callconv(.c) linux.gid_t { | ||
| 94 | return linux.getegid(); | ||
| 95 | } | ||
| 96 | |||
| 97 | fn geteuidLinux() callconv(.c) linux.uid_t { | ||
| 98 | return linux.geteuid(); | ||
| 99 | } | ||
| 100 | |||
| 101 | fn getgidLinux() callconv(.c) linux.gid_t { | ||
| 102 | return linux.getgid(); | ||
| 103 | } | ||
| 104 | |||
| 105 | fn getgroupsLinux(size: c_int, list: ?[*]linux.gid_t) callconv(.c) c_int { | ||
| 106 | return common.errno(linux.getgroups(@intCast(size), list)); | ||
| 107 | } | ||
| 108 | |||
| 109 | fn getpgidLinux(pid: linux.pid_t) callconv(.c) linux.pid_t { | ||
| 110 | return common.errno(linux.getpgid(pid)); | ||
| 111 | } | ||
| 112 | |||
| 113 | fn getpgrpLinux() callconv(.c) linux.pid_t { | ||
| 114 | return @intCast(linux.getpgid(0)); // @intCast as it cannot fail | ||
| 115 | } | ||
| 116 | |||
| 117 | fn setpgidLinux(pid: linux.pid_t, pgid: linux.pid_t) callconv(.c) c_int { | ||
| 118 | return common.errno(linux.setpgid(pid, pgid)); | ||
| 119 | } | ||
| 120 | |||
| 121 | fn setpgrpLinux() callconv(.c) linux.pid_t { | ||
| 122 | return @intCast(linux.setpgid(0, 0)); // @intCast as it cannot fail | ||
| 123 | } | ||
| 124 | |||
| 125 | fn getpidLinux() callconv(.c) linux.pid_t { | ||
| 126 | return linux.getpid(); | ||
| 127 | } | ||
| 128 | |||
| 129 | fn getppidLinux() callconv(.c) linux.pid_t { | ||
| 130 | return linux.getppid(); | ||
| 131 | } | ||
| 132 | |||
| 133 | fn getsidLinux(pid: linux.pid_t) callconv(.c) linux.pid_t { | ||
| 134 | return common.errno(linux.getsid(pid)); | ||
| 135 | } | ||
| 136 | |||
| 137 | fn getuidLinux() callconv(.c) linux.uid_t { | ||
| 138 | return linux.getuid(); | ||
| 139 | } | ||
| 140 | |||
| 141 | fn linkLinux(old: [*:0]const c_char, new: [*:0]const c_char) callconv(.c) c_int { | ||
| 142 | return common.errno(linux.link(@ptrCast(old), @ptrCast(new))); | ||
| 143 | } | ||
| 144 | |||
| 145 | fn linkatLinux(old_fd: c_int, old: [*:0]const c_char, new_fd: c_int, new: [*:0]const c_char, flags: c_int) callconv(.c) c_int { | ||
| 146 | return common.errno(linux.linkat(old_fd, @ptrCast(old), new_fd, @ptrCast(new), @bitCast(flags))); | ||
| 147 | } | ||
| 148 | |||
| 149 | fn pipeLinux(fd: *[2]c_int) callconv(.c) c_int { | ||
| 150 | return common.errno(linux.pipe(@ptrCast(fd))); | ||
| 151 | } | ||
| 152 | |||
| 153 | fn renameatLinux(old_fd: c_int, old: [*:0]const c_char, new_fd: c_int, new: [*:0]const c_char) callconv(.c) c_int { | ||
| 154 | return common.errno(linux.renameat(old_fd, @ptrCast(old), new_fd, @ptrCast(new))); | ||
| 155 | } | ||
| 156 | |||
| 157 | fn rmdirLinux(path: [*:0]const c_char) callconv(.c) c_int { | ||
| 158 | return common.errno(linux.rmdir(@ptrCast(path))); | ||
| 159 | } | ||
| 160 | |||
| 161 | fn symlinkLinux(existing: [*:0]const c_char, new: [*:0]const c_char) callconv(.c) c_int { | ||
| 162 | return common.errno(linux.symlink(@ptrCast(existing), @ptrCast(new))); | ||
| 163 | } | ||
| 164 | |||
| 165 | fn symlinkatLinux(existing: [*:0]const c_char, fd: c_int, new: [*:0]const c_char) callconv(.c) c_int { | ||
| 166 | return common.errno(linux.symlinkat(@ptrCast(existing), fd, @ptrCast(new))); | ||
| 167 | } | ||
| 168 | |||
| 169 | fn syncLinux() callconv(.c) void { | ||
| 170 | linux.sync(); | ||
| 171 | } | ||
| 172 | |||
| 173 | fn unlinkLinux(path: [*:0]const c_char) callconv(.c) c_int { | ||
| 174 | return common.errno(linux.unlink(@ptrCast(path))); | ||
| 175 | } | ||
| 176 | |||
| 177 | fn unlinkatLinux(fd: c_int, path: [*:0]const c_char, flags: c_int) callconv(.c) c_int { | ||
| 178 | return common.errno(linux.unlinkat(fd, @ptrCast(path), @bitCast(flags))); | ||
| 179 | } | ||
| 180 | |||
| 181 | fn execveLinux(path: [*:0]const c_char, argv: [*:null]const ?[*:0]c_char, envp: [*:null]const ?[*:0]c_char) callconv(.c) c_int { | ||
| 182 | return common.errno(linux.execve(@ptrCast(path), @ptrCast(argv), @ptrCast(envp))); | ||
| 183 | } | ||
lib/libc/musl/src/linux/cap.c deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | #include "syscall.h" | ||
| 2 | |||
| 3 | int capset(void *a, void *b) | ||
| 4 | { | ||
| 5 | 	return syscall(SYS_capset, a, b); | ||
| 6 | } | ||
| 7 | |||
| 8 | int capget(void *a, void *b) | ||
| 9 | { | ||
| 10 | 	return syscall(SYS_capget, a, b); | ||
| 11 | } | ||
lib/libc/musl/src/linux/chroot.c deleted-8| ... | @@ -1,8 +0,0 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <unistd.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int chroot(const char *path) | ||
| 6 | { | ||
| 7 | 	return syscall(SYS_chroot, path); | ||
| 8 | } | ||
lib/libc/musl/src/linux/flock.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <sys/file.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int flock(int fd, int op) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_flock, fd, op); | ||
| 7 | } | ||
lib/libc/musl/src/linux/reboot.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <sys/reboot.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int reboot(int type) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_reboot, 0xfee1dead, 672274793, type); | ||
| 7 | } | ||
lib/libc/musl/src/mman/madvise.c deleted-9| ... | @@ -1,9 +0,0 @@ | ||
| 1 | #include <sys/mman.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int __madvise(void *addr, size_t len, int advice) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_madvise, addr, len, advice); | ||
| 7 | } | ||
| 8 | |||
| 9 | weak_alias(__madvise, madvise); | ||
lib/libc/musl/src/mman/mincore.c deleted-8| ... | @@ -1,8 +0,0 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <sys/mman.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int mincore (void *addr, size_t len, unsigned char *vec) | ||
| 6 | { | ||
| 7 | 	return syscall(SYS_mincore, addr, len, vec); | ||
| 8 | } | ||
lib/libc/musl/src/mman/mlock.c deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | #include <sys/mman.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int mlock(const void *addr, size_t len) | ||
| 5 | { | ||
| 6 | #ifdef SYS_mlock | ||
| 7 | 	return syscall(SYS_mlock, addr, len); | ||
| 8 | #else | ||
| 9 | 	return syscall(SYS_mlock2, addr, len, 0); | ||
| 10 | #endif | ||
| 11 | } | ||
lib/libc/musl/src/mman/mlockall.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <sys/mman.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int mlockall(int flags) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_mlockall, flags); | ||
| 7 | } | ||
lib/libc/musl/src/mman/mprotect.c deleted-13| ... | @@ -1,13 +0,0 @@ | ||
| 1 | #include <sys/mman.h> | ||
| 2 | #include "libc.h" | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int __mprotect(void *addr, size_t len, int prot) | ||
| 6 | { | ||
| 7 | 	size_t start, end; | ||
| 8 | 	start = (size_t)addr & -PAGE_SIZE; | ||
| 9 | 	end = (size_t)((char *)addr + len + PAGE_SIZE-1) & -PAGE_SIZE; | ||
| 10 | 	return syscall(SYS_mprotect, start, end-start, prot); | ||
| 11 | } | ||
| 12 | |||
| 13 | weak_alias(__mprotect, mprotect); | ||
lib/libc/musl/src/mman/munlock.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <sys/mman.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int munlock(const void *addr, size_t len) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_munlock, addr, len); | ||
| 7 | } | ||
lib/libc/musl/src/mman/munlockall.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <sys/mman.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int munlockall(void) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_munlockall); | ||
| 7 | } | ||
lib/libc/musl/src/mman/posix_madvise.c deleted-9| ... | @@ -1,9 +0,0 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <sys/mman.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int posix_madvise(void *addr, size_t len, int advice) | ||
| 6 | { | ||
| 7 | 	if (advice == MADV_DONTNEED) return 0; | ||
| 8 | 	return -__syscall(SYS_madvise, addr, len, advice); | ||
| 9 | } | ||
lib/libc/musl/src/process/execve.c deleted-8| ... | @@ -1,8 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int execve(const char *path, char *const argv[], char *const envp[]) | ||
| 5 | { | ||
| 6 | 	/* do we need to use environ if envp is null? */ | ||
| 7 | 	return syscall(SYS_execve, path, argv, envp); | ||
| 8 | } | ||
lib/libc/musl/src/unistd/_exit.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | |||
| 4 | _Noreturn void _exit(int status) | ||
| 5 | { | ||
| 6 | 	_Exit(status); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/access.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int access(const char *filename, int amode) | ||
| 6 | { | ||
| 7 | #ifdef SYS_access | ||
| 8 | 	return syscall(SYS_access, filename, amode); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_faccessat, AT_FDCWD, filename, amode, 0); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/acct.c deleted-8| ... | @@ -1,8 +0,0 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <unistd.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int acct(const char *filename) | ||
| 6 | { | ||
| 7 | 	return syscall(SYS_acct, filename); | ||
| 8 | } | ||
lib/libc/musl/src/unistd/chdir.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int chdir(const char *path) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_chdir, path); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/chown.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int chown(const char *path, uid_t uid, gid_t gid) | ||
| 6 | { | ||
| 7 | #ifdef SYS_chown | ||
| 8 | 	return syscall(SYS_chown, path, uid, gid); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_fchownat, AT_FDCWD, path, uid, gid, 0); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/ctermid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <stdio.h> | ||
| 2 | #include <string.h> | ||
| 3 | |||
| 4 | char *ctermid(char *s) | ||
| 5 | { | ||
| 6 | 	return s ? strcpy(s, "/dev/tty") : "/dev/tty"; | ||
| 7 | } | ||
lib/libc/musl/src/unistd/dup.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int dup(int fd) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_dup, fd); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/fchownat.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int fchownat(int fd, const char *path, uid_t uid, gid_t gid, int flag) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_fchownat, fd, path, uid, gid, flag); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getegid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | gid_t getegid(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_getegid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/geteuid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | uid_t geteuid(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_geteuid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getgid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | gid_t getgid(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_getgid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getgroups.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int getgroups(int count, gid_t list[]) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_getgroups, count, list); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getpgid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | pid_t getpgid(pid_t pid) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_getpgid, pid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getpgrp.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | pid_t getpgrp(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_getpgid, 0); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getpid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | pid_t getpid(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_getpid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getppid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | pid_t getppid(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_getppid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getsid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | pid_t getsid(pid_t pid) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_getsid, pid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/getuid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | uid_t getuid(void) | ||
| 5 | { | ||
| 6 | 	return __syscall(SYS_getuid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/lchown.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int lchown(const char *path, uid_t uid, gid_t gid) | ||
| 6 | { | ||
| 7 | #ifdef SYS_lchown | ||
| 8 | 	return syscall(SYS_lchown, path, uid, gid); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_fchownat, AT_FDCWD, path, uid, gid, AT_SYMLINK_NOFOLLOW); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/link.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int link(const char *existing, const char *new) | ||
| 6 | { | ||
| 7 | #ifdef SYS_link | ||
| 8 | 	return syscall(SYS_link, existing, new); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_linkat, AT_FDCWD, existing, AT_FDCWD, new, 0); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/linkat.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int linkat(int fd1, const char *existing, int fd2, const char *new, int flag) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_linkat, fd1, existing, fd2, new, flag); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/mips/pipe.s deleted-20| ... | @@ -1,20 +0,0 @@ | ||
| 1 | .set noreorder | ||
| 2 | |||
| 3 | .global pipe | ||
| 4 | .type pipe,@function | ||
| 5 | pipe: | ||
| 6 | 	lui $gp, %hi(_gp_disp) | ||
| 7 | 	addiu $gp, %lo(_gp_disp) | ||
| 8 | 	addu $gp, $gp, $25 | ||
| 9 | 	li $2, 4042 | ||
| 10 | 	syscall | ||
| 11 | 	beq $7, $0, 1f | ||
| 12 | 	nop | ||
| 13 | 	lw $25, %call16(__syscall_ret)($gp) | ||
| 14 | 	jr $25 | ||
| 15 | 	subu $4, $0, $2 | ||
| 16 | 1:	sw $2, 0($4) | ||
| 17 | 	sw $3, 4($4) | ||
| 18 | 	move $2, $0 | ||
| 19 | 	jr $ra | ||
| 20 | 	nop | ||
lib/libc/musl/src/unistd/mips64/pipe.s deleted-19| ... | @@ -1,19 +0,0 @@ | ||
| 1 | .set	noreorder | ||
| 2 | .global	pipe | ||
| 3 | .type	pipe,@function | ||
| 4 | pipe: | ||
| 5 | 	lui	$3, %hi(%neg(%gp_rel(pipe))) | ||
| 6 | 	daddiu	$3, $3, %lo(%neg(%gp_rel(pipe))) | ||
| 7 | 	daddu	$3, $3, $25 | ||
| 8 | 	li	$2, 5021 | ||
| 9 | 	syscall | ||
| 10 | 	beq	$7, $0, 1f | ||
| 11 | 	nop | ||
| 12 | 	ld	$25, %got_disp(__syscall_ret)($3) | ||
| 13 | 	jr	$25 | ||
| 14 | 	dsubu	$4, $0, $2 | ||
| 15 | 1:	sw	$2, 0($4) | ||
| 16 | 	sw	$3, 4($4) | ||
| 17 | 	move	$2, $0 | ||
| 18 | 	jr	$ra | ||
| 19 | 	nop | ||
lib/libc/musl/src/unistd/mipsn32/pipe.s deleted-19| ... | @@ -1,19 +0,0 @@ | ||
| 1 | .set	noreorder | ||
| 2 | .global	pipe | ||
| 3 | .type	pipe,@function | ||
| 4 | pipe: | ||
| 5 | 	lui	$3, %hi(%neg(%gp_rel(pipe))) | ||
| 6 | 	addiu	$3, $3, %lo(%neg(%gp_rel(pipe))) | ||
| 7 | 	addu	$3, $3, $25 | ||
| 8 | 	li	$2, 6021 | ||
| 9 | 	syscall | ||
| 10 | 	beq	$7, $0, 1f | ||
| 11 | 	nop | ||
| 12 | 	lw	$25, %got_disp(__syscall_ret)($3) | ||
| 13 | 	jr	$25 | ||
| 14 | 	subu	$4, $0, $2 | ||
| 15 | 1:	sw	$2, 0($4) | ||
| 16 | 	sw	$3, 4($4) | ||
| 17 | 	move	$2, $0 | ||
| 18 | 	jr	$ra | ||
| 19 | 	nop | ||
lib/libc/musl/src/unistd/pipe.c deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int pipe(int fd[2]) | ||
| 5 | { | ||
| 6 | #ifdef SYS_pipe | ||
| 7 | 	return syscall(SYS_pipe, fd); | ||
| 8 | #else | ||
| 9 | 	return syscall(SYS_pipe2, fd, 0); | ||
| 10 | #endif | ||
| 11 | } | ||
lib/libc/musl/src/unistd/renameat.c deleted-11| ... | @@ -1,11 +0,0 @@ | ||
| 1 | #include <stdio.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int renameat(int oldfd, const char *old, int newfd, const char *new) | ||
| 5 | { | ||
| 6 | #ifdef SYS_renameat | ||
| 7 | 	return syscall(SYS_renameat, oldfd, old, newfd, new); | ||
| 8 | #else | ||
| 9 | 	return syscall(SYS_renameat2, oldfd, old, newfd, new, 0); | ||
| 10 | #endif | ||
| 11 | } | ||
lib/libc/musl/src/unistd/rmdir.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int rmdir(const char *path) | ||
| 6 | { | ||
| 7 | #ifdef SYS_rmdir | ||
| 8 | 	return syscall(SYS_rmdir, path); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_unlinkat, AT_FDCWD, path, AT_REMOVEDIR); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/setpgid.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int setpgid(pid_t pid, pid_t pgid) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_setpgid, pid, pgid); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/setpgrp.c deleted-6| ... | @@ -1,6 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | |||
| 3 | pid_t setpgrp(void) | ||
| 4 | { | ||
| 5 | 	return setpgid(0, 0); | ||
| 6 | } | ||
lib/libc/musl/src/unistd/symlink.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int symlink(const char *existing, const char *new) | ||
| 6 | { | ||
| 7 | #ifdef SYS_symlink | ||
| 8 | 	return syscall(SYS_symlink, existing, new); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_symlinkat, existing, AT_FDCWD, new); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/symlinkat.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int symlinkat(const char *existing, int fd, const char *new) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_symlinkat, existing, fd, new); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/sync.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | void sync(void) | ||
| 5 | { | ||
| 6 | 	__syscall(SYS_sync); | ||
| 7 | } | ||
lib/libc/musl/src/unistd/unlink.c deleted-12| ... | @@ -1,12 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int unlink(const char *path) | ||
| 6 | { | ||
| 7 | #ifdef SYS_unlink | ||
| 8 | 	return syscall(SYS_unlink, path); | ||
| 9 | #else | ||
| 10 | 	return syscall(SYS_unlinkat, AT_FDCWD, path, 0); | ||
| 11 | #endif | ||
| 12 | } | ||
lib/libc/musl/src/unistd/unlinkat.c deleted-7| ... | @@ -1,7 +0,0 @@ | ||
| 1 | #include <unistd.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int unlinkat(int fd, const char *path, int flag) | ||
| 5 | { | ||
| 6 | 	return syscall(SYS_unlinkat, fd, path, flag); | ||
| 7 | } | ||
lib/std/c.zig+1| ... | @@ -10649,6 +10649,7 @@ pub extern "c" fn fread(noalias ptr: [*]u8, size_of_type: usize, item_count: usi | ... | @@ -10649,6 +10649,7 @@ pub extern "c" fn fread(noalias ptr: [*]u8, size_of_type: usize, item_count: usi |
| 10649 | pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; | 10649 | pub extern "c" fn printf(format: [*:0]const u8, ...) c_int; |
| 10650 | pub extern "c" fn abort() noreturn; | 10650 | pub extern "c" fn abort() noreturn; |
| 10651 | pub extern "c" fn exit(code: c_int) noreturn; | 10651 | pub extern "c" fn exit(code: c_int) noreturn; |
| 10652 | pub extern "c" fn _Exit(code: c_int) noreturn; | ||
| 10652 | pub extern "c" fn _exit(code: c_int) noreturn; | 10653 | pub extern "c" fn _exit(code: c_int) noreturn; |
| 10653 | pub extern "c" fn isatty(fd: fd_t) c_int; | 10654 | pub extern "c" fn isatty(fd: fd_t) c_int; |
| 10654 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; | 10655 | pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: whence_t) off_t; |
lib/std/os/linux.zig+30-2| ... | @@ -1391,6 +1391,10 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { | ... | @@ -1391,6 +1391,10 @@ pub fn faccessat(dirfd: i32, path: [*:0]const u8, mode: u32, flags: u32) usize { |
| 1391 | return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags); | 1391 | return syscall4(.faccessat2, @as(usize, @bitCast(@as(isize, dirfd))), @intFromPtr(path), mode, flags); |
| 1392 | } | 1392 | } |
| 1393 | 1393 | ||
| 1394 | pub fn acct(path: [*:0]const u8) usize { | ||
| 1395 | return syscall1(.acct, @intFromPtr(path)); | ||
| 1396 | } | ||
| 1397 | |||
| 1394 | pub fn pipe(fd: *[2]i32) usize { | 1398 | pub fn pipe(fd: *[2]i32) usize { |
| 1395 | if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) { | 1399 | if (comptime (native_arch.isMIPS() or native_arch.isSPARC())) { |
| 1396 | return syscall_pipe(fd); | 1400 | return syscall_pipe(fd); |
| ... | @@ -1601,11 +1605,27 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize { | ... | @@ -1601,11 +1605,27 @@ pub fn fchown(fd: i32, owner: uid_t, group: gid_t) usize { |
| 1601 | } | 1605 | } |
| 1602 | } | 1606 | } |
| 1603 | 1607 | ||
| 1608 | pub fn fchownat(fd: i32, path: [*:0]const u8, owner: uid_t, group: gid_t, flags: u32) usize { | ||
| 1609 | return syscall5(.fchownat, @as(usize, @bitCast(@as(isize, fd))), @intFromPtr(path), owner, group, flags); | ||
| 1610 | } | ||
| 1611 | |||
| 1604 | pub fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize { | 1612 | pub fn chown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize { |
| 1605 | if (@hasField(SYS, "chown32")) { | 1613 | if (@hasField(SYS, "chown32")) { |
| 1606 | return syscall3(.chown32, @intFromPtr(path), owner, group); | 1614 | return syscall3(.chown32, @intFromPtr(path), owner, group); |
| 1607 | } else { | 1615 | } else if (@hasField(SYS, "chown")) { |
| 1608 | return syscall3(.chown, @intFromPtr(path), owner, group); | 1616 | return syscall3(.chown, @intFromPtr(path), owner, group); |
| 1617 | } else { | ||
| 1618 | return fchownat(AT.FDCWD, path, owner, group, 0); | ||
| 1619 | } | ||
| 1620 | } | ||
| 1621 | |||
| 1622 | pub fn lchown(path: [*:0]const u8, owner: uid_t, group: gid_t) usize { | ||
| 1623 | if (@hasField(SYS, "lchown32")) { | ||
| 1624 | return syscall3(.lchown32, @intFromPtr(path), owner, group); | ||
| 1625 | } else if (@hasField(SYS, "lchown")) { | ||
| 1626 | return syscall3(.lchown, @intFromPtr(path), owner, group); | ||
| 1627 | } else { | ||
| 1628 | return fchownat(AT.FDCWD, path, owner, group, AT.SYMLINK_NOFOLLOW); | ||
| 1609 | } | 1629 | } |
| 1610 | } | 1630 | } |
| 1611 | 1631 | ||
| ... | @@ -2064,7 +2084,11 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) usize { | ... | @@ -2064,7 +2084,11 @@ pub fn setpgid(pid: pid_t, pgid: pid_t) usize { |
| 2064 | return syscall2(.setpgid, @intCast(pid), @intCast(pgid)); | 2084 | return syscall2(.setpgid, @intCast(pid), @intCast(pgid)); |
| 2065 | } | 2085 | } |
| 2066 | 2086 | ||
| 2067 | pub fn getgroups(size: usize, list: ?*gid_t) usize { | 2087 | pub fn getpgid(pid: pid_t) usize { |
| 2088 | return syscall1(.getpgid, @intCast(pid)); | ||
| 2089 | } | ||
| 2090 | |||
| 2091 | pub fn getgroups(size: usize, list: ?[*]gid_t) usize { | ||
| 2068 | if (@hasField(SYS, "getgroups32")) { | 2092 | if (@hasField(SYS, "getgroups32")) { |
| 2069 | return syscall2(.getgroups32, size, @intFromPtr(list)); | 2093 | return syscall2(.getgroups32, size, @intFromPtr(list)); |
| 2070 | } else { | 2094 | } else { |
| ... | @@ -2084,6 +2108,10 @@ pub fn setsid() usize { | ... | @@ -2084,6 +2108,10 @@ pub fn setsid() usize { |
| 2084 | return syscall0(.setsid); | 2108 | return syscall0(.setsid); |
| 2085 | } | 2109 | } |
| 2086 | 2110 | ||
| 2111 | pub fn getsid(pid: pid_t) usize { | ||
| 2112 | return syscall1(.getsid, @intCast(pid)); | ||
| 2113 | } | ||
| 2114 | |||
| 2087 | pub fn getpid() pid_t { | 2115 | pub fn getpid() pid_t { |
| 2088 | // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail | 2116 | // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail |
| 2089 | return @intCast(@as(u32, @truncate(syscall0(.getpid)))); | 2117 | return @intCast(@as(u32, @truncate(syscall0(.getpid)))); |
src/libs/musl.zig-47| ... | @@ -704,8 +704,6 @@ const src_files = [_][]const u8{ | ... | @@ -704,8 +704,6 @@ const src_files = [_][]const u8{ |
| 704 | "musl/src/linux/arch_prctl.c", | 704 | "musl/src/linux/arch_prctl.c", |
| 705 | "musl/src/linux/brk.c", | 705 | "musl/src/linux/brk.c", |
| 706 | "musl/src/linux/cache.c", | 706 | "musl/src/linux/cache.c", |
| 707 | "musl/src/linux/cap.c", | ||
| 708 | "musl/src/linux/chroot.c", | ||
| 709 | "musl/src/linux/clock_adjtime.c", | 707 | "musl/src/linux/clock_adjtime.c", |
| 710 | "musl/src/linux/clone.c", | 708 | "musl/src/linux/clone.c", |
| 711 | "musl/src/linux/copy_file_range.c", | 709 | "musl/src/linux/copy_file_range.c", |
| ... | @@ -713,7 +711,6 @@ const src_files = [_][]const u8{ | ... | @@ -713,7 +711,6 @@ const src_files = [_][]const u8{ |
| 713 | "musl/src/linux/eventfd.c", | 711 | "musl/src/linux/eventfd.c", |
| 714 | "musl/src/linux/fallocate.c", | 712 | "musl/src/linux/fallocate.c", |
| 715 | "musl/src/linux/fanotify.c", | 713 | "musl/src/linux/fanotify.c", |
| 716 | "musl/src/linux/flock.c", | ||
| 717 | "musl/src/linux/getdents.c", | 714 | "musl/src/linux/getdents.c", |
| 718 | "musl/src/linux/getrandom.c", | 715 | "musl/src/linux/getrandom.c", |
| 719 | "musl/src/linux/gettid.c", | 716 | "musl/src/linux/gettid.c", |
| ... | @@ -738,7 +735,6 @@ const src_files = [_][]const u8{ | ... | @@ -738,7 +735,6 @@ const src_files = [_][]const u8{ |
| 738 | "musl/src/linux/pwritev2.c", | 735 | "musl/src/linux/pwritev2.c", |
| 739 | "musl/src/linux/quotactl.c", | 736 | "musl/src/linux/quotactl.c", |
| 740 | "musl/src/linux/readahead.c", | 737 | "musl/src/linux/readahead.c", |
| 741 | "musl/src/linux/reboot.c", | ||
| 742 | "musl/src/linux/remap_file_pages.c", | 738 | "musl/src/linux/remap_file_pages.c", |
| 743 | "musl/src/linux/sbrk.c", | 739 | "musl/src/linux/sbrk.c", |
| 744 | "musl/src/linux/sendfile.c", | 740 | "musl/src/linux/sendfile.c", |
| ... | @@ -1157,18 +1153,10 @@ const src_files = [_][]const u8{ | ... | @@ -1157,18 +1153,10 @@ const src_files = [_][]const u8{ |
| 1157 | "musl/src/misc/syscall.c", | 1153 | "musl/src/misc/syscall.c", |
| 1158 | "musl/src/misc/syslog.c", | 1154 | "musl/src/misc/syslog.c", |
| 1159 | "musl/src/misc/wordexp.c", | 1155 | "musl/src/misc/wordexp.c", |
| 1160 | "musl/src/mman/madvise.c", | ||
| 1161 | "musl/src/mman/mincore.c", | ||
| 1162 | "musl/src/mman/mlockall.c", | ||
| 1163 | "musl/src/mman/mlock.c", | ||
| 1164 | "musl/src/mman/mmap.c", | 1156 | "musl/src/mman/mmap.c", |
| 1165 | "musl/src/mman/mprotect.c", | ||
| 1166 | "musl/src/mman/mremap.c", | 1157 | "musl/src/mman/mremap.c", |
| 1167 | "musl/src/mman/msync.c", | 1158 | "musl/src/mman/msync.c", |
| 1168 | "musl/src/mman/munlockall.c", | ||
| 1169 | "musl/src/mman/munlock.c", | ||
| 1170 | "musl/src/mman/munmap.c", | 1159 | "musl/src/mman/munmap.c", |
| 1171 | "musl/src/mman/posix_madvise.c", | ||
| 1172 | "musl/src/mman/shm_open.c", | 1160 | "musl/src/mman/shm_open.c", |
| 1173 | "musl/src/mq/mq_close.c", | 1161 | "musl/src/mq/mq_close.c", |
| 1174 | "musl/src/mq/mq_getattr.c", | 1162 | "musl/src/mq/mq_getattr.c", |
| ... | @@ -1304,7 +1292,6 @@ const src_files = [_][]const u8{ | ... | @@ -1304,7 +1292,6 @@ const src_files = [_][]const u8{ |
| 1304 | "musl/src/process/execle.c", | 1292 | "musl/src/process/execle.c", |
| 1305 | "musl/src/process/execlp.c", | 1293 | "musl/src/process/execlp.c", |
| 1306 | "musl/src/process/execv.c", | 1294 | "musl/src/process/execv.c", |
| 1307 | "musl/src/process/execve.c", | ||
| 1308 | "musl/src/process/execvp.c", | 1295 | "musl/src/process/execvp.c", |
| 1309 | "musl/src/process/fexecve.c", | 1296 | "musl/src/process/fexecve.c", |
| 1310 | "musl/src/process/fork.c", | 1297 | "musl/src/process/fork.c", |
| ... | @@ -1871,51 +1858,26 @@ const src_files = [_][]const u8{ | ... | @@ -1871,51 +1858,26 @@ const src_files = [_][]const u8{ |
| 1871 | "musl/src/time/utime.c", | 1858 | "musl/src/time/utime.c", |
| 1872 | "musl/src/time/wcsftime.c", | 1859 | "musl/src/time/wcsftime.c", |
| 1873 | "musl/src/time/__year_to_secs.c", | 1860 | "musl/src/time/__year_to_secs.c", |
| 1874 | "musl/src/unistd/access.c", | ||
| 1875 | "musl/src/unistd/acct.c", | ||
| 1876 | "musl/src/unistd/alarm.c", | 1861 | "musl/src/unistd/alarm.c", |
| 1877 | "musl/src/unistd/chdir.c", | ||
| 1878 | "musl/src/unistd/chown.c", | ||
| 1879 | "musl/src/unistd/close.c", | 1862 | "musl/src/unistd/close.c", |
| 1880 | "musl/src/unistd/ctermid.c", | ||
| 1881 | "musl/src/unistd/dup2.c", | 1863 | "musl/src/unistd/dup2.c", |
| 1882 | "musl/src/unistd/dup3.c", | 1864 | "musl/src/unistd/dup3.c", |
| 1883 | "musl/src/unistd/dup.c", | ||
| 1884 | "musl/src/unistd/_exit.c", | ||
| 1885 | "musl/src/unistd/faccessat.c", | 1865 | "musl/src/unistd/faccessat.c", |
| 1886 | "musl/src/unistd/fchdir.c", | 1866 | "musl/src/unistd/fchdir.c", |
| 1887 | "musl/src/unistd/fchownat.c", | ||
| 1888 | "musl/src/unistd/fchown.c", | 1867 | "musl/src/unistd/fchown.c", |
| 1889 | "musl/src/unistd/fdatasync.c", | 1868 | "musl/src/unistd/fdatasync.c", |
| 1890 | "musl/src/unistd/fsync.c", | 1869 | "musl/src/unistd/fsync.c", |
| 1891 | "musl/src/unistd/ftruncate.c", | 1870 | "musl/src/unistd/ftruncate.c", |
| 1892 | "musl/src/unistd/getcwd.c", | 1871 | "musl/src/unistd/getcwd.c", |
| 1893 | "musl/src/unistd/getegid.c", | ||
| 1894 | "musl/src/unistd/geteuid.c", | ||
| 1895 | "musl/src/unistd/getgid.c", | ||
| 1896 | "musl/src/unistd/getgroups.c", | ||
| 1897 | "musl/src/unistd/gethostname.c", | 1872 | "musl/src/unistd/gethostname.c", |
| 1898 | "musl/src/unistd/getlogin.c", | 1873 | "musl/src/unistd/getlogin.c", |
| 1899 | "musl/src/unistd/getlogin_r.c", | 1874 | "musl/src/unistd/getlogin_r.c", |
| 1900 | "musl/src/unistd/getpgid.c", | ||
| 1901 | "musl/src/unistd/getpgrp.c", | ||
| 1902 | "musl/src/unistd/getpid.c", | ||
| 1903 | "musl/src/unistd/getppid.c", | ||
| 1904 | "musl/src/unistd/getsid.c", | ||
| 1905 | "musl/src/unistd/getuid.c", | ||
| 1906 | "musl/src/unistd/isatty.c", | 1875 | "musl/src/unistd/isatty.c", |
| 1907 | "musl/src/unistd/lchown.c", | ||
| 1908 | "musl/src/unistd/linkat.c", | ||
| 1909 | "musl/src/unistd/link.c", | ||
| 1910 | "musl/src/unistd/lseek.c", | 1876 | "musl/src/unistd/lseek.c", |
| 1911 | "musl/src/unistd/mips64/pipe.s", | ||
| 1912 | "musl/src/unistd/mipsn32/lseek.c", | 1877 | "musl/src/unistd/mipsn32/lseek.c", |
| 1913 | "musl/src/unistd/mipsn32/pipe.s", | ||
| 1914 | "musl/src/unistd/mips/pipe.s", | ||
| 1915 | "musl/src/unistd/nice.c", | 1878 | "musl/src/unistd/nice.c", |
| 1916 | "musl/src/unistd/pause.c", | 1879 | "musl/src/unistd/pause.c", |
| 1917 | "musl/src/unistd/pipe2.c", | 1880 | "musl/src/unistd/pipe2.c", |
| 1918 | "musl/src/unistd/pipe.c", | ||
| 1919 | "musl/src/unistd/posix_close.c", | 1881 | "musl/src/unistd/posix_close.c", |
| 1920 | "musl/src/unistd/pread.c", | 1882 | "musl/src/unistd/pread.c", |
| 1921 | "musl/src/unistd/preadv.c", | 1883 | "musl/src/unistd/preadv.c", |
| ... | @@ -1925,13 +1887,9 @@ const src_files = [_][]const u8{ | ... | @@ -1925,13 +1887,9 @@ const src_files = [_][]const u8{ |
| 1925 | "musl/src/unistd/readlinkat.c", | 1887 | "musl/src/unistd/readlinkat.c", |
| 1926 | "musl/src/unistd/readlink.c", | 1888 | "musl/src/unistd/readlink.c", |
| 1927 | "musl/src/unistd/readv.c", | 1889 | "musl/src/unistd/readv.c", |
| 1928 | "musl/src/unistd/renameat.c", | ||
| 1929 | "musl/src/unistd/rmdir.c", | ||
| 1930 | "musl/src/unistd/setegid.c", | 1890 | "musl/src/unistd/setegid.c", |
| 1931 | "musl/src/unistd/seteuid.c", | 1891 | "musl/src/unistd/seteuid.c", |
| 1932 | "musl/src/unistd/setgid.c", | 1892 | "musl/src/unistd/setgid.c", |
| 1933 | "musl/src/unistd/setpgid.c", | ||
| 1934 | "musl/src/unistd/setpgrp.c", | ||
| 1935 | "musl/src/unistd/setregid.c", | 1893 | "musl/src/unistd/setregid.c", |
| 1936 | "musl/src/unistd/setresgid.c", | 1894 | "musl/src/unistd/setresgid.c", |
| 1937 | "musl/src/unistd/setresuid.c", | 1895 | "musl/src/unistd/setresuid.c", |
| ... | @@ -1940,17 +1898,12 @@ const src_files = [_][]const u8{ | ... | @@ -1940,17 +1898,12 @@ const src_files = [_][]const u8{ |
| 1940 | "musl/src/unistd/setuid.c", | 1898 | "musl/src/unistd/setuid.c", |
| 1941 | "musl/src/unistd/setxid.c", | 1899 | "musl/src/unistd/setxid.c", |
| 1942 | "musl/src/unistd/sleep.c", | 1900 | "musl/src/unistd/sleep.c", |
| 1943 | "musl/src/unistd/symlinkat.c", | ||
| 1944 | "musl/src/unistd/symlink.c", | ||
| 1945 | "musl/src/unistd/sync.c", | ||
| 1946 | "musl/src/unistd/tcgetpgrp.c", | 1901 | "musl/src/unistd/tcgetpgrp.c", |
| 1947 | "musl/src/unistd/tcsetpgrp.c", | 1902 | "musl/src/unistd/tcsetpgrp.c", |
| 1948 | "musl/src/unistd/truncate.c", | 1903 | "musl/src/unistd/truncate.c", |
| 1949 | "musl/src/unistd/ttyname.c", | 1904 | "musl/src/unistd/ttyname.c", |
| 1950 | "musl/src/unistd/ttyname_r.c", | 1905 | "musl/src/unistd/ttyname_r.c", |
| 1951 | "musl/src/unistd/ualarm.c", | 1906 | "musl/src/unistd/ualarm.c", |
| 1952 | "musl/src/unistd/unlinkat.c", | ||
| 1953 | "musl/src/unistd/unlink.c", | ||
| 1954 | "musl/src/unistd/usleep.c", | 1907 | "musl/src/unistd/usleep.c", |
| 1955 | "musl/src/unistd/write.c", | 1908 | "musl/src/unistd/write.c", |
| 1956 | "musl/src/unistd/writev.c", | 1909 | "musl/src/unistd/writev.c", |