Skip to content

Commit eea022d

Browse files
committed
Provide shim functions to backfill LFS64 ABI
1 parent 5719564 commit eea022d

File tree

5 files changed

+277
-129
lines changed

5 files changed

+277
-129
lines changed

src/unix/linux_like/linux/mod.rs

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,12 @@ pub type iconv_t = *mut ::c_void;
5151
// linux/sctp.h
5252
pub type sctp_assoc_t = ::__s32;
5353

54-
cfg_if! {
55-
if #[cfg(not(target_env = "musl"))] {
56-
#[cfg_attr(feature = "extra_traits", derive(Debug))]
57-
pub enum fpos64_t {} // FIXME: fill this out with a struct
58-
impl ::Copy for fpos64_t {}
59-
impl ::Clone for fpos64_t {
60-
fn clone(&self) -> fpos64_t {
61-
*self
62-
}
63-
}
54+
#[cfg_attr(feature = "extra_traits", derive(Debug))]
55+
pub enum fpos64_t {} // FIXME: fill this out with a struct
56+
impl ::Copy for fpos64_t {}
57+
impl ::Clone for fpos64_t {
58+
fn clone(&self) -> fpos64_t {
59+
*self
6460
}
6561
}
6662

@@ -684,16 +680,10 @@ s! {
684680
pub struct sctp_authinfo {
685681
pub auth_keynumber: ::__u16,
686682
}
687-
}
688683

689-
cfg_if! {
690-
if #[cfg(not(target_env = "musl"))] {
691-
s! {
692-
pub struct rlimit64 {
693-
pub rlim_cur: rlim64_t,
694-
pub rlim_max: rlim64_t,
695-
}
696-
}
684+
pub struct rlimit64 {
685+
pub rlim_cur: rlim64_t,
686+
pub rlim_max: rlim64_t,
697687
}
698688
}
699689

@@ -806,19 +796,13 @@ s_no_extra_traits! {
806796
pub tx_type: ::c_int,
807797
pub rx_filter: ::c_int,
808798
}
809-
}
810799

811-
cfg_if! {
812-
if #[cfg(not(target_env = "musl"))] {
813-
s_no_extra_traits! {
814-
pub struct dirent64 {
815-
pub d_ino: ::ino64_t,
816-
pub d_off: ::off64_t,
817-
pub d_reclen: ::c_ushort,
818-
pub d_type: ::c_uchar,
819-
pub d_name: [::c_char; 256],
820-
}
821-
}
800+
pub struct dirent64 {
801+
pub d_ino: ::ino64_t,
802+
pub d_off: ::off64_t,
803+
pub d_reclen: ::c_ushort,
804+
pub d_type: ::c_uchar,
805+
pub d_name: [::c_char; 256],
822806
}
823807
}
824808

src/unix/linux_like/linux/musl/b32/riscv32/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,6 @@ s! {
184184
__pad1: ::c_ulong,
185185
__pad2: ::c_ulong,
186186
}
187-
188-
pub struct flock {
189-
pub l_type: ::c_short,
190-
pub l_whence: ::c_short,
191-
pub l_start: ::off_t,
192-
pub l_len: ::off_t,
193-
pub l_pid: ::pid_t,
194-
}
195-
196-
pub struct flock64 {
197-
pub l_type: ::c_short,
198-
pub l_whence: ::c_short,
199-
pub l_start: ::off64_t,
200-
pub l_len: ::off64_t,
201-
pub l_pid: ::pid_t,
202-
}
203187
}
204188

205189
//pub const RLIM_INFINITY: ::rlim_t = !0;

src/unix/linux_like/linux/musl/b64/riscv64/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,6 @@ s! {
173173
__unused5: ::c_ulong,
174174
__unused6: ::c_ulong,
175175
}
176-
177-
pub struct flock {
178-
pub l_type: ::c_short,
179-
pub l_whence: ::c_short,
180-
pub l_start: ::off_t,
181-
pub l_len: ::off_t,
182-
pub l_pid: ::pid_t,
183-
}
184-
185-
pub struct flock64 {
186-
pub l_type: ::c_short,
187-
pub l_whence: ::c_short,
188-
pub l_start: ::off64_t,
189-
pub l_len: ::off64_t,
190-
pub l_pid: ::pid_t,
191-
}
192176
}
193177

194178
pub const SYS_read: ::c_long = 63;
Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
#[no_mangle]
2+
pub unsafe extern "C" fn creat64(path: *const ::c_char, mode: ::mode_t) -> ::c_int {
3+
::creat(path, mode)
4+
}
5+
6+
#[no_mangle]
7+
pub unsafe extern "C" fn fallocate64(
8+
fd: ::c_int,
9+
mode: ::c_int,
10+
offset: ::off64_t,
11+
len: ::off64_t,
12+
) -> ::c_int {
13+
::fallocate(fd, mode, offset, len)
14+
}
15+
16+
#[no_mangle]
17+
pub unsafe extern "C" fn fgetpos64(stream: *mut ::FILE, pos: *mut ::fpos64_t) -> ::c_int {
18+
::fgetpos(stream, pos.cast())
19+
}
20+
21+
#[no_mangle]
22+
pub unsafe extern "C" fn fopen64(pathname: *const ::c_char, mode: *const ::c_char) -> *mut ::FILE {
23+
::fopen(pathname, mode)
24+
}
25+
26+
#[no_mangle]
27+
pub unsafe extern "C" fn freopen64(
28+
pathname: *const ::c_char,
29+
mode: *const ::c_char,
30+
stream: *mut ::FILE,
31+
) -> *mut ::FILE {
32+
::freopen(pathname, mode, stream)
33+
}
34+
35+
#[no_mangle]
36+
pub unsafe extern "C" fn fseeko64(
37+
stream: *mut ::FILE,
38+
offset: ::off64_t,
39+
whence: ::c_int,
40+
) -> ::c_int {
41+
::fseeko(stream, offset, whence)
42+
}
43+
44+
#[no_mangle]
45+
pub unsafe extern "C" fn fsetpos64(stream: *mut ::FILE, pos: *const ::fpos64_t) -> ::c_int {
46+
::fsetpos(stream, pos.cast())
47+
}
48+
49+
#[no_mangle]
50+
pub unsafe extern "C" fn fstat64(fildes: ::c_int, buf: *mut ::stat64) -> ::c_int {
51+
::fstat(fildes, buf.cast())
52+
}
53+
54+
#[no_mangle]
55+
pub unsafe extern "C" fn fstatat64(
56+
fd: ::c_int,
57+
path: *const ::c_char,
58+
buf: *mut ::stat64,
59+
flag: ::c_int,
60+
) -> ::c_int {
61+
::fstatat(fd, path, buf.cast(), flag)
62+
}
63+
64+
#[no_mangle]
65+
pub unsafe extern "C" fn fstatfs64(fd: ::c_int, buf: *mut ::statfs64) -> ::c_int {
66+
::fstatfs(fd, buf.cast())
67+
}
68+
69+
#[no_mangle]
70+
pub unsafe extern "C" fn fstatvfs64(fd: ::c_int, buf: *mut ::statvfs64) -> ::c_int {
71+
::fstatvfs(fd, buf.cast())
72+
}
73+
74+
#[no_mangle]
75+
pub unsafe extern "C" fn ftello64(stream: *mut ::FILE) -> ::off64_t {
76+
::ftello(stream)
77+
}
78+
79+
#[no_mangle]
80+
pub unsafe extern "C" fn ftruncate64(fd: ::c_int, length: ::off64_t) -> ::c_int {
81+
::ftruncate(fd, length)
82+
}
83+
84+
#[no_mangle]
85+
pub unsafe extern "C" fn getrlimit64(resource: ::c_int, rlim: *mut ::rlimit64) -> ::c_int {
86+
::getrlimit(resource, rlim.cast())
87+
}
88+
89+
#[no_mangle]
90+
pub unsafe extern "C" fn lseek64(fd: ::c_int, offset: ::off64_t, whence: ::c_int) -> ::off64_t {
91+
::lseek(fd, offset, whence)
92+
}
93+
94+
#[no_mangle]
95+
pub unsafe extern "C" fn lstat64(path: *const ::c_char, buf: *mut ::stat64) -> ::c_int {
96+
::lstat(path, buf.cast())
97+
}
98+
99+
#[no_mangle]
100+
pub unsafe extern "C" fn mmap64(
101+
addr: *mut ::c_void,
102+
length: ::size_t,
103+
prot: ::c_int,
104+
flags: ::c_int,
105+
fd: ::c_int,
106+
offset: ::off64_t,
107+
) -> *mut ::c_void {
108+
::mmap(addr, length, prot, flags, fd, offset)
109+
}
110+
111+
#[no_mangle]
112+
pub unsafe extern "C" fn open64(
113+
pathname: *const ::c_char,
114+
flags: ::c_int,
115+
mode: ::mode_t,
116+
) -> ::c_int {
117+
::open(pathname, flags | ::O_LARGEFILE, mode)
118+
}
119+
120+
#[no_mangle]
121+
pub unsafe extern "C" fn openat64(
122+
dirfd: ::c_int,
123+
pathname: *const ::c_char,
124+
flags: ::c_int,
125+
mode: ::mode_t,
126+
) -> ::c_int {
127+
::openat(dirfd, pathname, flags | ::O_LARGEFILE, mode)
128+
}
129+
130+
#[no_mangle]
131+
pub unsafe extern "C" fn posix_fadvise64(
132+
fd: ::c_int,
133+
offset: ::off64_t,
134+
len: ::off64_t,
135+
advice: ::c_int,
136+
) -> ::c_int {
137+
::posix_fadvise(fd, offset, len, advice)
138+
}
139+
140+
#[no_mangle]
141+
pub unsafe extern "C" fn posix_fallocate64(
142+
fd: ::c_int,
143+
offset: ::off64_t,
144+
len: ::off64_t,
145+
) -> ::c_int {
146+
::posix_fallocate(fd, offset, len)
147+
}
148+
149+
#[no_mangle]
150+
pub unsafe extern "C" fn pread64(
151+
fd: ::c_int,
152+
buf: *mut ::c_void,
153+
count: ::size_t,
154+
offset: ::off64_t,
155+
) -> ::ssize_t {
156+
::pread(fd, buf, count, offset)
157+
}
158+
159+
#[no_mangle]
160+
pub unsafe extern "C" fn preadv64(
161+
fd: ::c_int,
162+
iov: *const ::iovec,
163+
iovcnt: ::c_int,
164+
offset: ::off64_t,
165+
) -> ::ssize_t {
166+
::preadv(fd, iov, iovcnt, offset)
167+
}
168+
169+
#[no_mangle]
170+
pub unsafe extern "C" fn prlimit64(
171+
pid: ::pid_t,
172+
resource: ::c_int,
173+
new_limit: *const ::rlimit64,
174+
old_limit: *mut ::rlimit64,
175+
) -> ::c_int {
176+
::prlimit(pid, resource, new_limit.cast(), old_limit.cast())
177+
}
178+
179+
#[no_mangle]
180+
pub unsafe extern "C" fn pwrite64(
181+
fd: ::c_int,
182+
buf: *const ::c_void,
183+
count: ::size_t,
184+
offset: ::off64_t,
185+
) -> ::ssize_t {
186+
::pwrite(fd, buf, count, offset)
187+
}
188+
189+
#[no_mangle]
190+
pub unsafe extern "C" fn pwritev64(
191+
fd: ::c_int,
192+
iov: *const ::iovec,
193+
iovcnt: ::c_int,
194+
offset: ::off64_t,
195+
) -> ::ssize_t {
196+
::pwritev(fd, iov, iovcnt, offset)
197+
}
198+
199+
#[no_mangle]
200+
pub unsafe extern "C" fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64 {
201+
::readdir(dirp).cast()
202+
}
203+
204+
#[no_mangle]
205+
pub unsafe extern "C" fn readdir64_r(
206+
dirp: *mut ::DIR,
207+
entry: *mut ::dirent64,
208+
result: *mut *mut ::dirent64,
209+
) -> ::c_int {
210+
::readdir_r(dirp, entry.cast(), result.cast())
211+
}
212+
213+
#[no_mangle]
214+
pub unsafe extern "C" fn sendfile64(
215+
out_fd: ::c_int,
216+
in_fd: ::c_int,
217+
offset: *mut ::off64_t,
218+
count: ::size_t,
219+
) -> ::ssize_t {
220+
::sendfile(out_fd, in_fd, offset, count)
221+
}
222+
223+
#[no_mangle]
224+
pub unsafe extern "C" fn setrlimit64(resource: ::c_int, rlim: *const ::rlimit64) -> ::c_int {
225+
::setrlimit(resource, rlim.cast())
226+
}
227+
228+
#[no_mangle]
229+
pub unsafe extern "C" fn stat64(pathname: *const ::c_char, statbuf: *mut ::stat64) -> ::c_int {
230+
::stat(pathname, statbuf.cast())
231+
}
232+
233+
#[no_mangle]
234+
pub unsafe extern "C" fn statfs64(pathname: *const ::c_char, buf: *mut ::statfs64) -> ::c_int {
235+
::statfs(pathname, buf.cast())
236+
}
237+
238+
#[no_mangle]
239+
pub unsafe extern "C" fn statvfs64(path: *const ::c_char, buf: *mut ::statvfs64) -> ::c_int {
240+
::statvfs(path, buf.cast())
241+
}
242+
243+
#[no_mangle]
244+
pub unsafe extern "C" fn tmpfile64() -> *mut ::FILE {
245+
::tmpfile()
246+
}
247+
248+
#[no_mangle]
249+
pub unsafe extern "C" fn truncate64(path: *const ::c_char, length: ::off64_t) -> ::c_int {
250+
::truncate(path, length)
251+
}

0 commit comments

Comments
 (0)