| ... | ... | @@ -440,26 +440,30 @@ pub fn read(fd: i32, buf: [*]u8, count: usize) usize { |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | pub fn preadv(fd: i32, iov: [*]const iovec, count: usize, offset: i64) usize { |
| 443 | | const offset_halves = splitValueLE64(offset); |
| 443 | const offset_u = @bitCast(u64, offset); |
| 444 | 444 | return syscall5( |
| 445 | 445 | .preadv, |
| 446 | 446 | @bitCast(usize, @as(isize, fd)), |
| 447 | 447 | @ptrToInt(iov), |
| 448 | 448 | count, |
| 449 | | offset_halves[0], |
| 450 | | offset_halves[1], |
| 449 | // Kernel expects the offset is splitted into largest natural word-size. |
| 450 | // See following link for detail: |
| 451 | // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=601cc11d054ae4b5e9b5babec3d8e4667a2cb9b5 |
| 452 | @truncate(usize, offset_u), |
| 453 | if (usize_bits < 64) @truncate(usize, offset_u >> 32) else 0, |
| 451 | 454 | ); |
| 452 | 455 | } |
| 453 | 456 | |
| 454 | 457 | pub fn preadv2(fd: i32, iov: [*]const iovec, count: usize, offset: i64, flags: kernel_rwf) usize { |
| 455 | | const offset_halves = splitValue64(offset); |
| 458 | const offset_u = @bitCast(u64, offset); |
| 456 | 459 | return syscall6( |
| 457 | 460 | .preadv2, |
| 458 | 461 | @bitCast(usize, @as(isize, fd)), |
| 459 | 462 | @ptrToInt(iov), |
| 460 | 463 | count, |
| 461 | | offset_halves[0], |
| 462 | | offset_halves[1], |
| 464 | // See comments in preadv |
| 465 | @truncate(usize, offset_u), |
| 466 | if (usize_bits < 64) @truncate(usize, offset_u >> 32) else 0, |
| 463 | 467 | flags, |
| 464 | 468 | ); |
| 465 | 469 | } |
| ... | ... | @@ -473,26 +477,28 @@ pub fn writev(fd: i32, iov: [*]const iovec_const, count: usize) usize { |
| 473 | 477 | } |
| 474 | 478 | |
| 475 | 479 | pub fn pwritev(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64) usize { |
| 476 | | const offset_halves = splitValueLE64(offset); |
| 480 | const offset_u = @bitCast(u64, offset); |
| 477 | 481 | return syscall5( |
| 478 | 482 | .pwritev, |
| 479 | 483 | @bitCast(usize, @as(isize, fd)), |
| 480 | 484 | @ptrToInt(iov), |
| 481 | 485 | count, |
| 482 | | offset_halves[0], |
| 483 | | offset_halves[1], |
| 486 | // See comments in preadv |
| 487 | @truncate(usize, offset_u), |
| 488 | if (usize_bits < 64) @truncate(usize, offset_u >> 32) else 0, |
| 484 | 489 | ); |
| 485 | 490 | } |
| 486 | 491 | |
| 487 | 492 | pub fn pwritev2(fd: i32, iov: [*]const iovec_const, count: usize, offset: i64, flags: kernel_rwf) usize { |
| 488 | | const offset_halves = splitValue64(offset); |
| 493 | const offset_u = @bitCast(u64, offset); |
| 489 | 494 | return syscall6( |
| 490 | 495 | .pwritev2, |
| 491 | 496 | @bitCast(usize, @as(isize, fd)), |
| 492 | 497 | @ptrToInt(iov), |
| 493 | 498 | count, |
| 494 | | offset_halves[0], |
| 495 | | offset_halves[1], |
| 499 | // See comments in preadv |
| 500 | @truncate(usize, offset_u), |
| 501 | if (usize_bits < 64) @truncate(usize, offset_u >> 32) else 0, |
| 496 | 502 | flags, |
| 497 | 503 | ); |
| 498 | 504 | } |