1const builtin = @import("builtin");
2
3const std = @import("std");
4const linux = std.os.linux;
5const off_t = linux.off_t;
6
7const symbol = @import("../c.zig").symbol;
8const errno = @import("../c.zig").errno;
9
10comptime {
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
19fn 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
23fn 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
27fn 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
31fn 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}