| author | |
| committer | |
| log | aaba36ff763a7f016bba1afc4eff758302538362 |
| tree | 8cd7dfb6338f477fbceb3a1fce122268c9db6af3 |
| parent | 50cc3b91a5b325b645b0c5c81f3401600b15c92a |
This commit removes `posix_fadvise`, `posix_fallocate`, and `fallocate`
from the bundled musl by forwarding to Zig's wrappers. `musl`'s
implemenation does not use `__syscall_cp`, so I assume trivially
replacing these functions is okay.
For `posix_fadvise`, `musl` notes that the arguments are reordered
for ARM and other architectures. Zig's wrapper already handles this
case.
Contributes toward: #309786 files changed, 29 insertions(+), 36 deletions(-)
lib/c.zig+1| ... | @@ -63,6 +63,7 @@ pub fn errno(syscall_return_value: usize) c_int { | ... | @@ -63,6 +63,7 @@ pub fn errno(syscall_return_value: usize) c_int { |
| 63 | 63 | ||
| 64 | comptime { | 64 | comptime { |
| 65 | _ = @import("c/ctype.zig"); | 65 | _ = @import("c/ctype.zig"); |
| 66 | _ = @import("c/fcntl.zig"); | ||
| 66 | _ = @import("c/inttypes.zig"); | 67 | _ = @import("c/inttypes.zig"); |
| 67 | if (!builtin.target.isMinGW()) { | 68 | if (!builtin.target.isMinGW()) { |
| 68 | _ = @import("c/malloc.zig"); | 69 | _ = @import("c/malloc.zig"); |
lib/c/fcntl.zig created+28| ... | @@ -0,0 +1,28 @@ | ||
| 1 | const builtin = @import("builtin"); | ||
| 2 | |||
| 3 | const std = @import("std"); | ||
| 4 | const linux = std.os.linux; | ||
| 5 | const off_t = linux.off_t; | ||
| 6 | |||
| 7 | const symbol = @import("../c.zig").symbol; | ||
| 8 | const errno = @import("../c.zig").errno; | ||
| 9 | |||
| 10 | comptime { | ||
| 11 | if (builtin.target.isMuslLibC()) { | ||
| 12 | symbol(&fallocateLinux, "fallocate"); | ||
| 13 | symbol(&posix_fadviseLinux, "posix_fadvise"); | ||
| 14 | symbol(&posix_fallocateLinux, "posix_fallocate"); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | fn fallocateLinux(fd: c_int, mode: c_int, offset: off_t, len: off_t) callconv(.c) c_int { | ||
| 19 | return errno(linux.fallocate(fd, mode, offset, len)); | ||
| 20 | } | ||
| 21 | |||
| 22 | fn posix_fadviseLinux(fd: c_int, offset: off_t, len: off_t, advice: c_int) callconv(.c) c_int { | ||
| 23 | return errno(linux.fadvise(fd, offset, len, @intCast(advice))); | ||
| 24 | } | ||
| 25 | |||
| 26 | fn posix_fallocateLinux(fd: c_int, offset: off_t, len: off_t) callconv(.c) c_int { | ||
| 27 | return errno(linux.fallocate(fd, 0, offset, len)); | ||
| 28 | } | ||
lib/libc/musl/src/fcntl/posix_fadvise.c deleted-16| ... | @@ -1,16 +0,0 @@ | ||
| 1 | #include <fcntl.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int posix_fadvise(int fd, off_t base, off_t len, int advice) | ||
| 5 | { | ||
| 6 | #if defined(SYSCALL_FADVISE_6_ARG) | ||
| 7 | 	/* Some archs, at least arm and powerpc, have the syscall | ||
| 8 | 	 * arguments reordered to avoid needing 7 argument registers | ||
| 9 | 	 * due to 64-bit argument alignment. */ | ||
| 10 | 	return -__syscall(SYS_fadvise, fd, advice, | ||
| 11 | 		__SYSCALL_LL_E(base), __SYSCALL_LL_E(len)); | ||
| 12 | #else | ||
| 13 | 	return -__syscall(SYS_fadvise, fd, __SYSCALL_LL_O(base), | ||
| 14 | 		__SYSCALL_LL_E(len), advice); | ||
| 15 | #endif | ||
| 16 | } | ||
lib/libc/musl/src/fcntl/posix_fallocate.c deleted-8| ... | @@ -1,8 +0,0 @@ | ||
| 1 | #include <fcntl.h> | ||
| 2 | #include "syscall.h" | ||
| 3 | |||
| 4 | int posix_fallocate(int fd, off_t base, off_t len) | ||
| 5 | { | ||
| 6 | 	return -__syscall(SYS_fallocate, fd, 0, __SYSCALL_LL_E(base), | ||
| 7 | 		__SYSCALL_LL_E(len)); | ||
| 8 | } | ||
lib/libc/musl/src/linux/fallocate.c deleted-9| ... | @@ -1,9 +0,0 @@ | ||
| 1 | #define _GNU_SOURCE | ||
| 2 | #include <fcntl.h> | ||
| 3 | #include "syscall.h" | ||
| 4 | |||
| 5 | int fallocate(int fd, int mode, off_t base, off_t len) | ||
| 6 | { | ||
| 7 | 	return syscall(SYS_fallocate, fd, mode, __SYSCALL_LL_E(base), | ||
| 8 | 		__SYSCALL_LL_E(len)); | ||
| 9 | } | ||
src/libs/musl.zig-3| ... | @@ -589,8 +589,6 @@ const src_files = [_][]const u8{ | ... | @@ -589,8 +589,6 @@ const src_files = [_][]const u8{ |
| 589 | "musl/src/fcntl/fcntl.c", | 589 | "musl/src/fcntl/fcntl.c", |
| 590 | "musl/src/fcntl/openat.c", | 590 | "musl/src/fcntl/openat.c", |
| 591 | "musl/src/fcntl/open.c", | 591 | "musl/src/fcntl/open.c", |
| 592 | "musl/src/fcntl/posix_fadvise.c", | ||
| 593 | "musl/src/fcntl/posix_fallocate.c", | ||
| 594 | "musl/src/fenv/aarch64/fenv.s", | 592 | "musl/src/fenv/aarch64/fenv.s", |
| 595 | "musl/src/fenv/arm/fenv.c", | 593 | "musl/src/fenv/arm/fenv.c", |
| 596 | "musl/src/fenv/arm/fenv-hf.S", | 594 | "musl/src/fenv/arm/fenv-hf.S", |
| ... | @@ -708,7 +706,6 @@ const src_files = [_][]const u8{ | ... | @@ -708,7 +706,6 @@ const src_files = [_][]const u8{ |
| 708 | "musl/src/linux/copy_file_range.c", | 706 | "musl/src/linux/copy_file_range.c", |
| 709 | "musl/src/linux/epoll.c", | 707 | "musl/src/linux/epoll.c", |
| 710 | "musl/src/linux/eventfd.c", | 708 | "musl/src/linux/eventfd.c", |
| 711 | "musl/src/linux/fallocate.c", | ||
| 712 | "musl/src/linux/fanotify.c", | 709 | "musl/src/linux/fanotify.c", |
| 713 | "musl/src/linux/getdents.c", | 710 | "musl/src/linux/getdents.c", |
| 714 | "musl/src/linux/getrandom.c", | 711 | "musl/src/linux/getrandom.c", |