aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-05-05 10:48:22 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-05-05 10:48:22 -0700
commitfc40d2372335e69be175972ffabb55bc7fb77230 (patch)
tree184daa7845a95f54da0c8c5c6ffba0feffa01b6c /lib/std/os/linux.zig
parent7a27f0d80c5ce9d596b2b43699e131ab387e1317 (diff)
parent9d409233b2c62e1d24635165ac6b3b7686ffd5e4 (diff)
downloadzig-fc40d2372335e69be175972ffabb55bc7fb77230.tar.gz
zig-fc40d2372335e69be175972ffabb55bc7fb77230.zip
Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts: * build.zig * lib/std/array_list.zig * lib/std/c/ast.zig * lib/std/c/parse.zig * lib/std/os/bits/linux.zig
Diffstat (limited to 'lib/std/os/linux.zig')
-rw-r--r--lib/std/os/linux.zig14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index d34e7d16af..5e5fde2b97 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -387,7 +387,7 @@ pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) us
}
pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
- if (@hasField(SYS, "pread64")) {
+ if (@hasField(SYS, "pread64") and usize_bits < 64) {
const offset_halves = splitValue64(offset);
if (require_aligned_register_pair) {
return syscall6(
@@ -410,8 +410,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
);
}
} else {
+ // Some architectures (eg. 64bit SPARC) pread is called pread64.
+ const S = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64")) .pread64 else .pread;
return syscall4(
- .pread,
+ S,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,
@@ -451,7 +453,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
}
pub fn ftruncate(fd: i32, length: u64) usize {
- if (@hasField(SYS, "ftruncate64")) {
+ if (@hasField(SYS, "ftruncate64") and usize_bits < 64) {
const length_halves = splitValue64(length);
if (require_aligned_register_pair) {
return syscall4(
@@ -479,7 +481,7 @@ pub fn ftruncate(fd: i32, length: u64) usize {
}
pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {
- if (@hasField(SYS, "pwrite64")) {
+ if (@hasField(SYS, "pwrite64") and usize_bits < 64) {
const offset_halves = splitValue64(offset);
if (require_aligned_register_pair) {
@@ -503,8 +505,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {
);
}
} else {
+ // Some architectures (eg. 64bit SPARC) pwrite is called pwrite64.
+ const S = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64")) .pwrite64 else .pwrite;
return syscall4(
- .pwrite,
+ S,
@bitCast(usize, @as(isize, fd)),
@ptrToInt(buf),
count,