Skip to content

Commit 94aa08b

Browse files
committed
Only use Android fallback for {ftruncate,pread,pwrite} on 32 bit
1 parent 744aecf commit 94aa08b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/libstd/sys/unix/android.rs

+24
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ pub unsafe fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t {
9898
//
9999
// If it doesn't we just fall back to `ftruncate`, generating an error for
100100
// too-large values.
101+
#[cfg(target_pointer_width = "32")]
101102
pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
102103
weak!(fn ftruncate64(c_int, i64) -> c_int);
103104

@@ -116,6 +117,14 @@ pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
116117
}
117118
}
118119

120+
#[cfg(target_pointer_width = "64")]
121+
pub fn ftruncate64(fd: c_int, size: u64) -> io::Result<()> {
122+
unsafe {
123+
cvt_r(|| ftruncate(fd, size as i64)).map(|_| ())
124+
}
125+
}
126+
127+
#[cfg(target_pointer_width = "32")]
119128
pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64)
120129
-> io::Result<ssize_t>
121130
{
@@ -130,6 +139,7 @@ pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i6
130139
})
131140
}
132141

142+
#[cfg(target_pointer_width = "32")]
133143
pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64)
134144
-> io::Result<ssize_t>
135145
{
@@ -143,3 +153,17 @@ pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset:
143153
}
144154
})
145155
}
156+
157+
#[cfg(target_pointer_width = "64")]
158+
pub unsafe fn cvt_pread64(fd: c_int, buf: *mut c_void, count: size_t, offset: i64)
159+
-> io::Result<ssize_t>
160+
{
161+
cvt(pread(fd, buf, count, offset))
162+
}
163+
164+
#[cfg(target_pointer_width = "64")]
165+
pub unsafe fn cvt_pwrite64(fd: c_int, buf: *const c_void, count: size_t, offset: i64)
166+
-> io::Result<ssize_t>
167+
{
168+
cvt(pwrite(fd, buf, count, offset))
169+
}

0 commit comments

Comments
 (0)