Skip to content

Commit c8f396c

Browse files
committed
l4re: deprecate lfs bindings
Add deprecation warnings to LFS64 bindings under L4Re uClibc. This patch adds notices to types and routines. The only supported target is 64-bits wide. Its suffixed and unsuffixed types should always be equivalent.
1 parent 1a8e71f commit c8f396c

5 files changed

Lines changed: 190 additions & 57 deletions

File tree

src/unix/linux_like/l4re/mod.rs

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ pub type pthread_t = *mut c_void;
1010
pub type dev_t = u64;
1111
pub type socklen_t = u32;
1212
pub type mode_t = u32;
13-
pub type ino64_t = u64;
14-
pub type off64_t = i64;
15-
pub type blkcnt64_t = i64;
16-
pub type rlim64_t = u64;
1713
pub type nfds_t = c_ulong;
1814
pub type nl_item = c_int;
1915
pub type idtype_t = c_uint;
@@ -22,6 +18,40 @@ pub type pthread_key_t = c_uint;
2218
pub type pthread_once_t = c_int;
2319
pub type pthread_spinlock_t = c_int;
2420

21+
#[cfg_attr(
22+
all(target_os = "l4re", target_pointer_width = "64"),
23+
deprecated(
24+
since = "0.2.190",
25+
note = "Use `ino_t` instead. LFS is being phased out, see rust-lang/libc#4805."
26+
)
27+
)]
28+
pub type ino64_t = u64;
29+
#[cfg_attr(
30+
all(target_os = "l4re", target_pointer_width = "64"),
31+
deprecated(
32+
since = "0.2.190",
33+
note = "Use `off_t` instead. LFS is being phased out, see rust-lang/libc#4805."
34+
)
35+
)]
36+
pub type off64_t = i64;
37+
#[cfg_attr(
38+
all(target_os = "l4re", target_pointer_width = "64"),
39+
deprecated(
40+
since = "0.2.190",
41+
note = "Use `blkcnt_t` instead. LFS is being phased out, see
42+
rust-lang/libc#4805."
43+
)
44+
)]
45+
pub type blkcnt64_t = i64;
46+
#[cfg_attr(
47+
all(target_os = "l4re", target_pointer_width = "64"),
48+
deprecated(
49+
since = "0.2.190",
50+
note = "Use `rlim_t` instead. LFS is being phased out, see rust-lang/libc#4805."
51+
)
52+
)]
53+
pub type rlim64_t = u64;
54+
2555
s! {
2656
/// CPU sets.
2757
pub struct l4_sched_cpu_set_t {

src/unix/linux_like/l4re/uclibc/mod.rs

Lines changed: 62 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::off64_t;
21
use crate::prelude::*;
32

43
pub type shmatt_t = c_ulong;
@@ -10,6 +9,12 @@ pub type __priority_which_t = c_uint;
109
pub type _pthread_descr = *mut c_void;
1110
pub type __pthread_cond_align_t = c_long;
1211

12+
#[cfg(target_pointer_width = "64")]
13+
pub type __sword_type = c_long;
14+
15+
#[cfg(target_pointer_width = "32")]
16+
pub type __sword_type = c_int;
17+
1318
cfg_if! {
1419
if #[cfg(doc)] {
1520
// Used in `linux::arch` to define ioctl constants.
@@ -44,48 +49,33 @@ s! {
4449
}
4550

4651
pub struct statfs {
47-
pub f_type: fsword_t,
48-
pub f_bsize: fsword_t,
52+
pub f_type: __sword_type,
53+
pub f_bsize: __sword_type,
4954
pub f_blocks: crate::fsblkcnt_t,
5055
pub f_bfree: crate::fsblkcnt_t,
5156
pub f_bavail: crate::fsblkcnt_t,
5257
pub f_files: crate::fsfilcnt_t,
5358
pub f_ffree: crate::fsfilcnt_t,
5459
pub f_fsid: crate::fsid_t,
55-
pub f_namelen: fsword_t,
56-
pub f_frsize: fsword_t,
57-
pub f_flags: fsword_t,
58-
pub f_spare: [fsword_t; 4],
60+
pub f_namelen: __sword_type,
61+
pub f_frsize: __sword_type,
62+
pub f_flags: __sword_type,
63+
pub f_spare: [__sword_type; 4],
5964
}
6065

6166
pub struct statfs64 {
62-
pub f_type: fsword_t,
63-
pub f_bsize: fsword_t,
67+
pub f_type: __sword_type,
68+
pub f_bsize: __sword_type,
6469
pub f_blocks: crate::fsblkcnt64_t,
6570
pub f_bfree: crate::fsblkcnt64_t,
6671
pub f_bavail: crate::fsblkcnt64_t,
6772
pub f_files: crate::fsfilcnt64_t,
6873
pub f_ffree: crate::fsfilcnt64_t,
6974
pub f_fsid: crate::fsid_t,
70-
pub f_namelen: fsword_t,
71-
pub f_frsize: fsword_t,
72-
pub f_flags: fsword_t,
73-
pub f_spare: [fsword_t; 4],
74-
}
75-
76-
pub struct statvfs64 {
77-
pub f_bsize: c_ulong,
78-
pub f_frsize: c_ulong,
79-
pub f_blocks: crate::fsfilcnt64_t,
80-
pub f_bfree: crate::fsfilcnt64_t,
81-
pub f_bavail: crate::fsfilcnt64_t,
82-
pub f_files: crate::fsfilcnt64_t,
83-
pub f_ffree: crate::fsfilcnt64_t,
84-
pub f_favail: crate::fsfilcnt64_t,
85-
pub f_fsid: c_ulong,
86-
pub f_flag: c_ulong,
87-
pub f_namemax: c_ulong,
88-
pub __f_spare: [c_int; 6],
75+
pub f_namelen: __sword_type,
76+
pub f_frsize: __sword_type,
77+
pub f_flags: __sword_type,
78+
pub f_spare: [__sword_type; 4],
8979
}
9080

9181
pub struct ipc_perm {
@@ -99,11 +89,11 @@ s! {
9989
#[cfg(target_pointer_width = "64")]
10090
pub mode: c_uint,
10191
#[cfg(target_pointer_width = "32")]
102-
__pad1: c_ushort,
92+
__pad1: Padding<c_ushort>,
10393
pub __seq: c_ushort,
104-
__pad2: c_ushort,
105-
__unused1: c_ulong,
106-
__unused2: c_ulong,
94+
__pad2: Padding<c_ushort>,
95+
__unused1: Padding<c_ulong>,
96+
__unused2: Padding<c_ulong>,
10797
}
10898

10999
pub struct statvfs {
@@ -116,15 +106,30 @@ s! {
116106
pub f_files: crate::fsfilcnt_t,
117107
pub f_ffree: crate::fsfilcnt_t,
118108
pub f_favail: crate::fsfilcnt_t,
119-
#[cfg(target_endian = "little")]
120109
pub f_fsid: c_ulong,
121110
#[cfg(target_pointer_width = "32")]
122-
__f_unused: c_int,
123-
#[cfg(target_endian = "big")]
111+
__f_unused: Padding<c_int>,
112+
pub f_flag: c_ulong,
113+
pub f_namemax: c_ulong,
114+
__f_spare: Padding<[c_int; 6]>,
115+
}
116+
117+
pub struct statvfs64 {
118+
// Different than GNU!
119+
pub f_bsize: c_ulong,
120+
pub f_frsize: c_ulong,
121+
pub f_blocks: crate::fsblkcnt64_t,
122+
pub f_bfree: crate::fsblkcnt64_t,
123+
pub f_bavail: crate::fsblkcnt64_t,
124+
pub f_files: crate::fsfilcnt64_t,
125+
pub f_ffree: crate::fsfilcnt64_t,
126+
pub f_favail: crate::fsfilcnt64_t,
124127
pub f_fsid: c_ulong,
128+
#[cfg(target_pointer_width = "32")]
129+
__f_unused: Padding<c_int>,
125130
pub f_flag: c_ulong,
126131
pub f_namemax: c_ulong,
127-
__f_spare: [c_int; 6],
132+
__f_spare: Padding<[c_int; 6]>,
128133
}
129134

130135
pub struct sysinfo {
@@ -300,8 +305,8 @@ s! {
300305
pub shm_cpid: crate::pid_t,
301306
pub shm_lpid: crate::pid_t,
302307
pub shm_nattch: crate::shmatt_t,
303-
__unused4: c_ulong,
304-
__unused5: c_ulong,
308+
__unused4: Padding<c_ulong>,
309+
__unused5: Padding<c_ulong>,
305310
}
306311
}
307312

@@ -536,10 +541,26 @@ extern "C" {
536541
flags: c_int,
537542
) -> c_int;
538543

539-
pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
540-
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
541-
544+
pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
545+
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
546+
547+
#[cfg_attr(
548+
all(target_os = "l4re", target_pointer_width = "64"),
549+
deprecated(
550+
since = "0.2.190",
551+
note = "Use `getrlimit` instead. LFS is being phased out, see rust-lang/libc#4805."
552+
),
553+
allow(deprecated)
554+
)]
542555
pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int;
556+
#[cfg_attr(
557+
all(target_os = "l4re", target_pointer_width = "64"),
558+
deprecated(
559+
since = "0.2.190",
560+
note = "Use `setrlimit` instead. LFS is being phased out, see rust-lang/libc#4805."
561+
),
562+
allow(deprecated)
563+
)]
543564
pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64)
544565
-> c_int;
545566
pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int;

src/unix/linux_like/l4re/uclibc/x86_64/mod.rs

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,55 @@ pub type suseconds_t = c_long;
1717
pub type blksize_t = c_long;
1818
pub type blkcnt_t = c_long;
1919

20+
#[deprecated(
21+
since = "0.2.190",
22+
note = "Use `fsblkcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805."
23+
)]
2024
pub type fsblkcnt64_t = c_ulong;
25+
#[deprecated(
26+
since = "0.2.190",
27+
note = "Use `fsfilcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805."
28+
)]
2129
pub type fsfilcnt64_t = c_ulong;
2230

2331
pub type __u32 = c_uint;
2432
pub type __u64 = c_ulong;
2533

2634
s! {
2735
pub struct stat {
28-
pub st_dev: c_ulong,
36+
pub st_dev: crate::dev_t,
2937
pub st_ino: crate::ino_t,
30-
// According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of
31-
// nlink and mode are swapped on 64 bit systems.
3238
pub st_nlink: nlink_t,
3339
pub st_mode: crate::mode_t,
3440
pub st_uid: crate::uid_t,
3541
pub st_gid: crate::gid_t,
36-
__pad0: c_int,
37-
pub st_rdev: c_ulong,
42+
__pad0: Padding<c_int>,
43+
pub st_rdev: crate::dev_t,
3844
pub st_size: crate::off_t,
3945
pub st_blksize: crate::blksize_t,
40-
pub st_blocks: crate::blkcnt64_t,
46+
pub st_blocks: crate::blkcnt_t,
4147
pub st_atim: crate::timespec,
4248
pub st_mtim: crate::timespec,
4349
pub st_ctim: crate::timespec,
44-
__uclibc_unused: [c_long; 3],
50+
__uclibc_unused: Padding<[c_long; 3]>,
4551
}
4652

4753
pub struct stat64 {
48-
pub st_dev: c_ulong,
54+
pub st_dev: crate::dev_t,
4955
pub st_ino: crate::ino_t,
5056
pub st_nlink: nlink_t,
5157
pub st_mode: crate::mode_t,
5258
pub st_uid: crate::uid_t,
5359
pub st_gid: crate::gid_t,
54-
__pad0: c_int,
55-
pub st_rdev: c_ulong,
60+
__pad0: Padding<c_int>,
61+
pub st_rdev: crate::dev_t,
5662
pub st_size: crate::off_t,
5763
pub st_blksize: crate::blksize_t,
58-
pub st_blocks: crate::blkcnt64_t,
64+
pub st_blocks: crate::blkcnt_t,
5965
pub st_atim: crate::timespec,
6066
pub st_mtim: crate::timespec,
6167
pub st_ctim: crate::timespec,
62-
st_pad4: [c_long; 3],
68+
__uclibc_unused: Padding<[c_long; 3]>,
6369
}
6470

6571
#[allow(unpredictable_function_pointer_comparisons)]
@@ -96,6 +102,14 @@ s! {
96102
pub l_pid: crate::pid_t,
97103
}
98104

105+
pub struct flock64 {
106+
pub l_type: c_short,
107+
pub l_whence: c_short,
108+
pub l_start: off_t,
109+
pub l_len: off_t,
110+
pub l_pid: crate::pid_t,
111+
}
112+
99113
pub struct termios {
100114
pub c_iflag: crate::tcflag_t,
101115
pub c_oflag: crate::tcflag_t,

src/unix/linux_like/linux_l4re_shared.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,18 +1935,56 @@ extern "C" {
19351935
cfg_if! {
19361936
if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] {
19371937
extern "C" {
1938+
#[cfg_attr(
1939+
all(target_os = "l4re", target_pointer_width = "64",),
1940+
deprecated(
1941+
since = "0.2.190",
1942+
note = "Use `freopen` instead. LFS is being phased out, see \
1943+
rust-lang/libc#4805."
1944+
)
1945+
)]
19381946
pub fn freopen64(
19391947
filename: *const c_char,
19401948
mode: *const c_char,
19411949
file: *mut crate::FILE,
19421950
) -> *mut crate::FILE;
1951+
#[cfg_attr(
1952+
all(target_os = "l4re", target_pointer_width = "64"),
1953+
deprecated(
1954+
since = "0.2.190",
1955+
note = "Use `fseeko` instead. LFS is being phased out, see rust-lang/libc#4805."
1956+
)
1957+
)]
19431958
pub fn fseeko64(
19441959
stream: *mut crate::FILE,
1960+
#[cfg(any(
1961+
not(target_os = "l4re"),
1962+
all(target_os = "l4re", not(target_pointer_width = "64"))
1963+
))]
19451964
offset: crate::off64_t,
1965+
#[cfg(all(target_os = "l4re", target_pointer_width = "64"))] offset: crate::off_t,
19461966
whence: c_int,
19471967
) -> c_int;
1968+
#[cfg_attr(
1969+
all(target_os = "l4re", target_pointer_width = "64"),
1970+
deprecated(
1971+
since = "0.2.190",
1972+
note = "Use `fsetpos` instead. LFS is being phased out, see \
1973+
rust-lang/libc#4805."
1974+
)
1975+
)]
19481976
pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const crate::fpos64_t) -> c_int;
1977+
#[cfg(any(
1978+
not(target_os = "l4re"),
1979+
all(target_os = "l4re", not(target_pointer_width = "64"))
1980+
))]
19491981
pub fn ftello64(stream: *mut crate::FILE) -> crate::off64_t;
1982+
#[cfg(all(target_os = "l4re", target_pointer_width = "64"))]
1983+
#[deprecated(
1984+
since = "0.2.190",
1985+
note = "Use `ftello` instead. LFS is being phased out, see rust-lang/libc#4805."
1986+
)]
1987+
pub fn ftello64(stream: *mut crate::FILE) -> crate::off_t;
19501988
}
19511989
}
19521990
}

0 commit comments

Comments
 (0)