diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2016-10-14 14:19:41 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2016-10-14 14:19:41 +0200 |
| commit | 94aa08b66cb624155f2fb84f01fd5d9eab3c0c7a (patch) | |
| tree | 78a730fb27b1638d45459b7bbab47776241921fa /src/libstd/sys/unix | |
| parent | 744aecf7933210d1a94b58e33a3dea022b30d1aa (diff) | |
| download | rust-94aa08b66cb624155f2fb84f01fd5d9eab3c0c7a.tar.gz rust-94aa08b66cb624155f2fb84f01fd5d9eab3c0c7a.zip | |
Only use Android fallback for {ftruncate,pread,pwrite} on 32 bit
Diffstat (limited to 'src/libstd/sys/unix')
| -rw-r--r-- | src/libstd/sys/unix/android.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libstd/sys/unix/android.rs b/src/libstd/sys/unix/android.rs index 81f1a637ad5..8b11d077daf 100644 --- a/src/libstd/sys/unix/android.rs +++ b/src/libstd/sys/unix/android.rs @@ -98,6 +98,7 @@ pub unsafe fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t { // // If it doesn't we just fall back to `ftruncate`, generating an error for // too-large values. +#[cfg(target_pointer_width = "32")] pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> { weak!(fn ftruncate64(c_int, i64) -> c_int); @@ -116,6 +117,14 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> { } } +#[cfg(target_pointer_width = "64")] +pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> { + unsafe { + cvt_r(|| ftruncate(fd, size as i64)).map(|_| ()) + } +} + +#[cfg(target_pointer_width = "32")] pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64) -> io::Result<ssize_t> { @@ -130,6 +139,7 @@ pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i6 }) } +#[cfg(target_pointer_width = "32")] pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64) -> io::Result<ssize_t> { @@ -143,3 +153,17 @@ pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: } }) } + +#[cfg(target_pointer_width = "64")] +pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64) + -> io::Result<ssize_t> +{ + cvt(pread(fd, buf, count, offset)) +} + +#[cfg(target_pointer_width = "64")] +pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64) + -> io::Result<ssize_t> +{ + cvt(pwrite(fd, buf, count, offset)) +} |
