authorgravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-11-03 06:03:38+02:00
committergravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-11-03 06:03:38+02:00
log8193f558200da27531304b77c1e80c16bb728420
treefdba778a4f15ff7063b210dc3206336d9b5b18e7
parent78e9e131e02bba1949aab67b63e7fe94ae8b33bb

Support 32-bit big-endian targets


2 files changed, 8 insertions(+), 9 deletions(-)

lib/std/os/linux.zig+8-6
...@@ -121,16 +121,18 @@ pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, fl...@@ -121,16 +121,18 @@ pub fn utimensat(dirfd: i32, path: ?[*:0]const u8, times: *const [2]timespec, fl
121 return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);121 return syscall4(.utimensat, @bitCast(usize, @as(isize, dirfd)), @ptrToInt(path), @ptrToInt(times), flags);
122}122}
123123
124pub fn fallocate(fd: i32, mode: i32, offset: u64, len: u64) usize {124pub fn fallocate(fd: i32, mode: i32, offset: u64, length: u64) usize {
125 if (@sizeOf(usize) == 4) {125 if (@sizeOf(usize) == 4) {
126 const offset_halves = splitValue64(offset);
127 const length_halves = splitValue64(length);
126 return syscall6(128 return syscall6(
127 .fallocate,129 .fallocate,
128 @bitCast(usize, @as(isize, fd)),130 @bitCast(usize, @as(isize, fd)),
129 @bitCast(usize, @as(isize, mode)),131 @bitCast(usize, @as(isize, mode)),
130 @truncate(usize, offset),132 offset_halves[0],
131 @truncate(usize, offset >> 32),133 offset_halves[1],
132 @truncate(usize, len),134 length_halves[0],
133 @truncate(usize, len >> 32),135 length_halves[1],
134 );136 );
135 } else {137 } else {
136 return syscall4(138 return syscall4(
...@@ -138,7 +140,7 @@ pub fn fallocate(fd: i32, mode: i32, offset: u64, len: u64) usize {...@@ -138,7 +140,7 @@ pub fn fallocate(fd: i32, mode: i32, offset: u64, len: u64) usize {
138 @bitCast(usize, @as(isize, fd)),140 @bitCast(usize, @as(isize, fd)),
139 @bitCast(usize, @as(isize, mode)),141 @bitCast(usize, @as(isize, mode)),
140 offset,142 offset,
141 len,143 length,
142 );144 );
143 }145 }
144}146}
lib/std/os/linux/test.zig-3
...@@ -12,9 +12,6 @@ const expect = std.testing.expect;...@@ -12,9 +12,6 @@ const expect = std.testing.expect;
12const fs = std.fs;12const fs = std.fs;
1313
14test "fallocate" {14test "fallocate" {
15 // TODO https://github.com/ziglang/zig/issues/5127
16 if (std.Target.current.cpu.arch == .mips) return error.SkipZigTest;
17
18 const path = "test_fallocate";15 const path = "test_fallocate";
19 const file = try fs.cwd().createFile(path, .{ .truncate = true, .mode = 0o666 });16 const file = try fs.cwd().createFile(path, .{ .truncate = true, .mode = 0o666 });
20 defer file.close();17 defer file.close();