authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-01 15:46:28+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-05-01 15:46:28+02:00
log718b43504eae6af063f8b9cf5803a82758c7e37b
treef2562920ce2921b3495a6fc1332a6d9d93d6aee9
parent69a9c1488d901e45440c195d42e7837a4c247f2b

std: Fix pwrite/pread syscalls on SPARC targets


1 files changed, 9 insertions(+), 5 deletions(-)

lib/std/os/linux.zig+9-5
......@@ -386,7 +386,7 @@ pub fn symlinkat(existing: [*:0]const u8, newfd: i32, newpath: [*:0]const u8) us
386386}
387387
388388pub 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) {
390390 const offset_halves = splitValue64(offset);
391391 if (require_aligned_register_pair) {
392392 return syscall6(
......@@ -409,8 +409,10 @@ pub fn pread(fd: i32, buf: [*]u8, count: usize, offset: u64) usize {
409409 );
410410 }
411411 } 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;
412414 return syscall4(
413 .pread,
415 S,
414416 @bitCast(usize, @as(isize, fd)),
415417 @ptrToInt(buf),
416418 count,
......@@ -450,7 +452,7 @@ pub fn write(fd: i32, buf: [*]const u8, count: usize) usize {
450452}
451453
452454pub fn ftruncate(fd: i32, length: u64) usize {
453 if (@hasField(SYS, "ftruncate64")) {
455 if (@hasField(SYS, "ftruncate64") and usize_bits < 64) {
454456 const length_halves = splitValue64(length);
455457 if (require_aligned_register_pair) {
456458 return syscall4(
......@@ -478,7 +480,7 @@ pub fn ftruncate(fd: i32, length: u64) usize {
478480}
479481
480482pub 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) {
482484 const offset_halves = splitValue64(offset);
483485
484486 if (require_aligned_register_pair) {
......@@ -502,8 +504,10 @@ pub fn pwrite(fd: i32, buf: [*]const u8, count: usize, offset: u64) usize {
502504 );
503505 }
504506 } 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;
505509 return syscall4(
506 .pwrite,
510 S,
507511 @bitCast(usize, @as(isize, fd)),
508512 @ptrToInt(buf),
509513 count,