| 1 |
// In-sync with ../linux/musl/lfs64.rs except for fallocate64, prlimit64 and sendfile64 |
| 2 |
|
| 3 |
#[inline] |
| 4 |
pub unsafe extern "C" fn creat64(path: *const ::c_char, mode: ::mode_t) -> ::c_int { |
| 5 |
::creat(path, mode) |
| 6 |
} |
| 7 |
|
| 8 |
#[inline] |
| 9 |
pub unsafe extern "C" fn fgetpos64(stream: *mut ::FILE, pos: *mut ::fpos64_t) -> ::c_int { |
| 10 |
::fgetpos(stream, pos as *mut _) |
| 11 |
} |
| 12 |
|
| 13 |
#[inline] |
| 14 |
pub unsafe extern "C" fn fopen64(pathname: *const ::c_char, mode: *const ::c_char) -> *mut ::FILE { |
| 15 |
::fopen(pathname, mode) |
| 16 |
} |
| 17 |
|
| 18 |
#[inline] |
| 19 |
pub unsafe extern "C" fn freopen64( |
| 20 |
pathname: *const ::c_char, |
| 21 |
mode: *const ::c_char, |
| 22 |
stream: *mut ::FILE, |
| 23 |
) -> *mut ::FILE { |
| 24 |
::freopen(pathname, mode, stream) |
| 25 |
} |
| 26 |
|
| 27 |
#[inline] |
| 28 |
pub unsafe extern "C" fn fseeko64( |
| 29 |
stream: *mut ::FILE, |
| 30 |
offset: ::off64_t, |
| 31 |
whence: ::c_int, |
| 32 |
) -> ::c_int { |
| 33 |
::fseeko(stream, offset, whence) |
| 34 |
} |
| 35 |
|
| 36 |
#[inline] |
| 37 |
pub unsafe extern "C" fn fsetpos64(stream: *mut ::FILE, pos: *const ::fpos64_t) -> ::c_int { |
| 38 |
::fsetpos(stream, pos as *mut _) |
| 39 |
} |
| 40 |
|
| 41 |
#[inline] |
| 42 |
pub unsafe extern "C" fn fstat64(fildes: ::c_int, buf: *mut ::stat64) -> ::c_int { |
| 43 |
::fstat(fildes, buf as *mut _) |
| 44 |
} |
| 45 |
|
| 46 |
#[inline] |
| 47 |
pub unsafe extern "C" fn fstatat64( |
| 48 |
fd: ::c_int, |
| 49 |
path: *const ::c_char, |
| 50 |
buf: *mut ::stat64, |
| 51 |
flag: ::c_int, |
| 52 |
) -> ::c_int { |
| 53 |
::fstatat(fd, path, buf as *mut _, flag) |
| 54 |
} |
| 55 |
|
| 56 |
#[inline] |
| 57 |
pub unsafe extern "C" fn fstatfs64(fd: ::c_int, buf: *mut ::statfs64) -> ::c_int { |
| 58 |
::fstatfs(fd, buf as *mut _) |
| 59 |
} |
| 60 |
|
| 61 |
#[inline] |
| 62 |
pub unsafe extern "C" fn fstatvfs64(fd: ::c_int, buf: *mut ::statvfs64) -> ::c_int { |
| 63 |
::fstatvfs(fd, buf as *mut _) |
| 64 |
} |
| 65 |
|
| 66 |
#[inline] |
| 67 |
pub unsafe extern "C" fn ftello64(stream: *mut ::FILE) -> ::off64_t { |
| 68 |
::ftello(stream) |
| 69 |
} |
| 70 |
|
| 71 |
#[inline] |
| 72 |
pub unsafe extern "C" fn ftruncate64(fd: ::c_int, length: ::off64_t) -> ::c_int { |
| 73 |
::ftruncate(fd, length) |
| 74 |
} |
| 75 |
|
| 76 |
#[inline] |
| 77 |
pub unsafe extern "C" fn getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int { |
| 78 |
::getrlimit(resource, rlim as *mut _) |
| 79 |
} |
| 80 |
|
| 81 |
#[inline] |
| 82 |
pub unsafe extern "C" fn lseek64(fd: ::c_int, offset: ::off64_t, whence: ::c_int) -> ::off64_t { |
| 83 |
::lseek(fd, offset, whence) |
| 84 |
} |
| 85 |
|
| 86 |
#[inline] |
| 87 |
pub unsafe extern "C" fn lstat64(path: *const ::c_char, buf: *mut ::stat64) -> ::c_int { |
| 88 |
::lstat(path, buf as *mut _) |
| 89 |
} |
| 90 |
|
| 91 |
#[inline] |
| 92 |
pub unsafe extern "C" fn mmap64( |
| 93 |
addr: *mut ::c_void, |
| 94 |
length: ::size_t, |
| 95 |
prot: ::c_int, |
| 96 |
flags: ::c_int, |
| 97 |
fd: ::c_int, |
| 98 |
offset: ::off64_t, |
| 99 |
) -> *mut ::c_void { |
| 100 |
::mmap(addr, length, prot, flags, fd, offset) |
| 101 |
} |
| 102 |
|
| 103 |
// These functions are variadic in the C ABI since the `mode` argument is "optional". Variadic |
| 104 |
// `extern "C"` functions are unstable in Rust so we cannot write a shim function for these |
| 105 |
// entrypoints. See https://github.com/rust-lang/rust/issues/44930. |
| 106 |
// |
| 107 |
// These aliases are mostly fine though, neither function takes a LFS64-namespaced type as an |
| 108 |
// argument, nor do their names clash with any declared types. |
| 109 |
pub use open as open64; |
| 110 |
pub use openat as openat64; |
| 111 |
|
| 112 |
#[inline] |
| 113 |
pub unsafe extern "C" fn posix_fadvise64( |
| 114 |
fd: ::c_int, |
| 115 |
offset: ::off64_t, |
| 116 |
len: ::off64_t, |
| 117 |
advice: ::c_int, |
| 118 |
) -> ::c_int { |
| 119 |
::posix_fadvise(fd, offset, len, advice) |
| 120 |
} |
| 121 |
|
| 122 |
#[inline] |
| 123 |
pub unsafe extern "C" fn posix_fallocate64( |
| 124 |
fd: ::c_int, |
| 125 |
offset: ::off64_t, |
| 126 |
len: ::off64_t, |
| 127 |
) -> ::c_int { |
| 128 |
::posix_fallocate(fd, offset, len) |
| 129 |
} |
| 130 |
|
| 131 |
#[inline] |
| 132 |
pub unsafe extern "C" fn pread64( |
| 133 |
fd: ::c_int, |
| 134 |
buf: *mut ::c_void, |
| 135 |
count: ::size_t, |
| 136 |
offset: ::off64_t, |
| 137 |
) -> ::ssize_t { |
| 138 |
::pread(fd, buf, count, offset) |
| 139 |
} |
| 140 |
|
| 141 |
#[inline] |
| 142 |
pub unsafe extern "C" fn preadv64( |
| 143 |
fd: ::c_int, |
| 144 |
iov: *const ::iovec, |
| 145 |
iovcnt: ::c_int, |
| 146 |
offset: ::off64_t, |
| 147 |
) -> ::ssize_t { |
| 148 |
::preadv(fd, iov, iovcnt, offset) |
| 149 |
} |
| 150 |
|
| 151 |
#[inline] |
| 152 |
pub unsafe extern "C" fn pwrite64( |
| 153 |
fd: ::c_int, |
| 154 |
buf: *const ::c_void, |
| 155 |
count: ::size_t, |
| 156 |
offset: ::off64_t, |
| 157 |
) -> ::ssize_t { |
| 158 |
::pwrite(fd, buf, count, offset) |
| 159 |
} |
| 160 |
|
| 161 |
#[inline] |
| 162 |
pub unsafe extern "C" fn pwritev64( |
| 163 |
fd: ::c_int, |
| 164 |
iov: *const ::iovec, |
| 165 |
iovcnt: ::c_int, |
| 166 |
offset: ::off64_t, |
| 167 |
) -> ::ssize_t { |
| 168 |
::pwritev(fd, iov, iovcnt, offset) |
| 169 |
} |
| 170 |
|
| 171 |
#[inline] |
| 172 |
pub unsafe extern "C" fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64 { |
| 173 |
::readdir(dirp) as *mut _ |
| 174 |
} |
| 175 |
|
| 176 |
#[inline] |
| 177 |
pub unsafe extern "C" fn readdir64_r( |
| 178 |
dirp: *mut ::DIR, |
| 179 |
entry: *mut ::dirent64, |
| 180 |
result: *mut *mut ::dirent64, |
| 181 |
) -> ::c_int { |
| 182 |
::readdir_r(dirp, entry as *mut _, result as *mut _) |
| 183 |
} |
| 184 |
|
| 185 |
#[inline] |
| 186 |
pub unsafe extern "C" fn setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int { |
| 187 |
::setrlimit(resource, rlim as *mut _) |
| 188 |
} |
| 189 |
|
| 190 |
#[inline] |
| 191 |
pub unsafe extern "C" fn stat64(pathname: *const ::c_char, statbuf: *mut ::stat64) -> ::c_int { |
| 192 |
::stat(pathname, statbuf as *mut _) |
| 193 |
} |
| 194 |
|
| 195 |
#[inline] |
| 196 |
pub unsafe extern "C" fn statfs64(pathname: *const ::c_char, buf: *mut ::statfs64) -> ::c_int { |
| 197 |
::statfs(pathname, buf as *mut _) |
| 198 |
} |
| 199 |
|
| 200 |
#[inline] |
| 201 |
pub unsafe extern "C" fn statvfs64(path: *const ::c_char, buf: *mut ::statvfs64) -> ::c_int { |
| 202 |
::statvfs(path, buf as *mut _) |
| 203 |
} |
| 204 |
|
| 205 |
#[inline] |
| 206 |
pub unsafe extern "C" fn tmpfile64() -> *mut ::FILE { |
| 207 |
::tmpfile() |
| 208 |
} |
| 209 |
|
| 210 |
#[inline] |
| 211 |
pub unsafe extern "C" fn truncate64(path: *const ::c_char, length: ::off64_t) -> ::c_int { |
| 212 |
::truncate(path, length) |
| 213 |
} |