| 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 | symbol(&teeLinux, "tee"); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | fn fallocateLinux(fd: c_int, mode: c_int, offset: off_t, len: off_t) callconv(.c) c_int { |
| 20 | return errno(linux.fallocate(fd, @bitCast(mode), offset, len)); |
| 21 | } |
| 22 | |
| 23 | fn posix_fadviseLinux(fd: c_int, offset: off_t, len: off_t, advice: c_int) callconv(.c) c_int { |
| 24 | return errno(linux.fadvise(fd, offset, len, @intCast(advice))); |
| 25 | } |
| 26 | |
| 27 | fn posix_fallocateLinux(fd: c_int, offset: off_t, len: off_t) callconv(.c) c_int { |
| 28 | return errno(linux.fallocate(fd, 0, offset, len)); |
| 29 | } |
| 30 | |
| 31 | fn teeLinux(src: c_int, dest: c_int, len: usize, flags: c_uint) callconv(.c) isize { |
| 32 | return errno(linux.tee(src, dest, len, flags)); |
| 33 | } |