| ... | @@ -386,7 +386,7 @@ pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) us | ... | @@ -386,7 +386,7 @@ pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) us |
| 386 | } | 386 | } |
| 387 | | 387 | |
| 388 | pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize { | 388 | pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize { |
| 389 | if (@hasField(SYS, "pread64")) { | 389 | if (@hasField(SYS, "pread64") and usize_bits < 64) { |
| 390 | const offset_halves = splitValue64(offset); | 390 | const offset_halves = splitValue64(offset); |
| 391 | if (require_aligned_register_pair) { | 391 | if (require_aligned_register_pair) { |
| 392 | return syscall6( | 392 | return syscall6( |
| ... | @@ -409,8 +409,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize { | ... | @@ -409,8 +409,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize { |
| 409 | ); | 409 | ); |
| 410 | } | 410 | } |
| 411 | } else { | 411 | } else { |
| | 412 | // Some architectures (eg. 64bit SPARC) pread is called pread64. |
| | 413 | const S = if (!@hasField(SYS, "pread") and @hasField(SYS, "pread64")) .pread64 else .pread; |
| 412 | return syscall4( | 414 | return syscall4( |
| 413 | .pread, | 415 | S, |
| 414 | @bitCast(usize, @as(isize, fd)), | 416 | @bitCast(usize, @as(isize, fd)), |
| 415 | @ptrToInt(buf), | 417 | @ptrToInt(buf), |
| 416 | count, | 418 | count, |
| ... | @@ -450,7 +452,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { | ... | @@ -450,7 +452,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize { |
| 450 | } | 452 | } |
| 451 | | 453 | |
| 452 | pub fn ftruncate(fd: i32, length: u64) usize { | 454 | pub fn ftruncate(fd: i32, length: u64) usize { |
| 453 | if (@hasField(SYS, "ftruncate64")) { | 455 | if (@hasField(SYS, "ftruncate64") and usize_bits < 64) { |
| 454 | const length_halves = splitValue64(length); | 456 | const length_halves = splitValue64(length); |
| 455 | if (require_aligned_register_pair) { | 457 | if (require_aligned_register_pair) { |
| 456 | return syscall4( | 458 | return syscall4( |
| ... | @@ -478,7 +480,7 @@ pub fn ftruncate(fd: i32, length: u64) usize { | ... | @@ -478,7 +480,7 @@ pub fn ftruncate(fd: i32, length: u64) usize { |
| 478 | } | 480 | } |
| 479 | | 481 | |
| 480 | pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize { | 482 | pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize { |
| 481 | if (@hasField(SYS, "pwrite64")) { | 483 | if (@hasField(SYS, "pwrite64") and usize_bits < 64) { |
| 482 | const offset_halves = splitValue64(offset); | 484 | const offset_halves = splitValue64(offset); |
| 483 | | 485 | |
| 484 | if (require_aligned_register_pair) { | 486 | if (require_aligned_register_pair) { |
| ... | @@ -502,8 +504,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize { | ... | @@ -502,8 +504,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize { |
| 502 | ); | 504 | ); |
| 503 | } | 505 | } |
| 504 | } else { | 506 | } else { |
| | 507 | // Some architectures (eg. 64bit SPARC) pwrite is called pread64. |
| | 508 | const S = if (!@hasField(SYS, "pwrite") and @hasField(SYS, "pwrite64")) .pwrite64 else .pwrite; |
| 505 | return syscall4( | 509 | return syscall4( |
| 506 | .pwrite, | 510 | S, |
| 507 | @bitCast(usize, @as(isize, fd)), | 511 | @bitCast(usize, @as(isize, fd)), |
| 508 | @ptrToInt(buf), | 512 | @ptrToInt(buf), |
| 509 | count, | 513 | count, |