| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | | const builtin = @import("builtin"); |
| 3 | 2 | const linux = std.os.linux; |
| 3 | const builtin = @import("builtin"); |
| 4 | 4 | |
| 5 | 5 | comptime { |
| 6 | 6 | std.debug.assert(builtin.target.os.tag == .linux); |
| ... | ... | @@ -2781,6 +2781,21 @@ pub const libc = struct { |
| 2781 | 2781 | pub extern fn futimens(fd: c_int, times: *const [2]struct_timespec) c_int; |
| 2782 | 2782 | }; |
| 2783 | 2783 | |
| 2784 | comptime { |
| 2785 | const C = struct { |
| 2786 | fn getdents(dirfd: c_int, buf: [*]u8, nbytes: usize) callconv(.c) c_int { |
| 2787 | const rc = std.os.linux.syscall3(.getdents64, @intCast(dirfd), @intFromPtr(buf), nbytes); |
| 2788 | const signed_r: isize = @bitCast(rc); |
| 2789 | if (signed_r < 0 and signed_r > -4096) { |
| 2790 | libc.__errno_location().* = @intCast(-signed_r); |
| 2791 | return -1; |
| 2792 | } |
| 2793 | return @intCast(rc); |
| 2794 | } |
| 2795 | }; |
| 2796 | if (builtin.abi.isGnu()) @export(&C.getdents, .{ .name = "getdents", .linkage = .weak }); // glibc chooses to only expose this as getdents64 |
| 2797 | } |
| 2798 | |
| 2784 | 2799 | pub const clock_t = c_long; |
| 2785 | 2800 | pub const pid_t = c_int; |
| 2786 | 2801 | pub const gid_t = c_uint; |