authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-07 18:09:52+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-11 12:33:48+02:00
log780f510ac0137512ad2923835e4ecdb22a81028e
treec05bbb4594d5bd85602786f5e540d6a98ff84357
parentc065e12dbefcde1a48926405bd4f401eadecaca2

std: Fix fallocate offset type


2 files changed, 5 insertions(+), 5 deletions(-)

lib/std/os/linux.zig+4-4
...@@ -142,8 +142,8 @@ pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, fl...@@ -142,8 +142,8 @@ pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, fl
142 return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);142 return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);
143}143}
144144
145pub fn fallocate(fd: i32, mode: i32, offset: u64, length: u64) usize {145pub fn fallocate(fd: i32, mode: i32, offset: i64, length: i64) usize {
146 if (@sizeOf(usize) == 4) {146 if (usize_bits < 64) {
147 const offset_halves = splitValue64(offset);147 const offset_halves = splitValue64(offset);
148 const length_halves = splitValue64(length);148 const length_halves = splitValue64(length);
149 return syscall6(149 return syscall6(
...@@ -160,8 +160,8 @@ pub fn fallocate(fd: i32, mode: i32, offset: u64, length: u64) usize {...@@ -160,8 +160,8 @@ pub fn fallocate(fd: i32, mode: i32, offset: u64, length: u64) usize {
160 .fallocate,160 .fallocate,
161 @bitCast(usize, @as(isize, fd)),161 @bitCast(usize, @as(isize, fd)),
162 @bitCast(usize, @as(isize, mode)),162 @bitCast(usize, @as(isize, mode)),
163 offset,163 @bitCast(u64, offset),
164 length,164 @bitCast(u64, length),
165 );165 );
166 }166 }
167}167}
lib/std/os/linux/test.zig+1-1
...@@ -20,7 +20,7 @@ test "fallocate" {...@@ -20,7 +20,7 @@ test "fallocate" {
2020
21 try expect((try file.stat()).size == 0);21 try expect((try file.stat()).size == 0);
2222
23 const len: u64 = 65536;23 const len: i64 = 65536;
24 switch (linux.getErrno(linux.fallocate(file.handle, 0, 0, len))) {24 switch (linux.getErrno(linux.fallocate(file.handle, 0, 0, len))) {
25 0 => {},25 0 => {},
26 linux.ENOSYS => return error.SkipZigTest,26 linux.ENOSYS => return error.SkipZigTest,