Skip to content

Commit e16db76

Browse files
committed
l4re: change bitwidths of file offset types
This patch makes a few changes to the file offset types and routines that are made available under the `unix/linux_like/l4re` module. The current upstream definitions under x86_64 and AArch64 are unconditionally 64-bit. Then there's the fact there's only one target officially supported by rustc under L4Re, and that's x86_64.
1 parent 413bb61 commit e16db76

6 files changed

Lines changed: 353 additions & 113 deletions

File tree

src/unix/linux_like/l4re/mod.rs

Lines changed: 22 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,28 @@ 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+
#[deprecated(
22+
since = "0.2.187",
23+
note = "Use `ino_t` instead. 64-bit targets alias both types."
24+
)]
25+
pub type ino64_t = u64;
26+
#[deprecated(
27+
since = "0.2.187",
28+
note = "Use `off_t` instead. No matter the target platform, off_t is always 64-bits wide, and \
29+
the `libc` crate is phasing out support for unsuffixed types."
30+
)]
31+
pub type off64_t = i64;
32+
#[deprecated(
33+
since = "0.2.187",
34+
note = "Use `blkcnt_t` instead. 64-bit targets alias both types."
35+
)]
36+
pub type blkcnt64_t = i64;
37+
#[deprecated(
38+
since = "0.2.187",
39+
note = "Use `rlim_t` instead. 64-bit targets alias both types."
40+
)]
41+
pub type rlim64_t = u64;
42+
2543
s! {
2644
/// CPU sets.
2745
pub struct l4_sched_cpu_set_t {

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

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,64 +15,58 @@ pub type suseconds_t = c_long;
1515
pub type blksize_t = c_long;
1616
pub type blkcnt_t = c_long;
1717

18+
#[deprecated(
19+
since = "0.2.187",
20+
note = "Use `fsblkcnt_t` instead. The unsuffixed type is defined in terms of the suffixed type \
21+
upstream under the current target architecture (x86_64,) and support for suffixed \
22+
types is phasing out in the `libc` crate."
23+
)]
1824
pub type fsblkcnt64_t = c_ulong;
25+
#[deprecated(
26+
since = "0.2.187",
27+
note = "Use `fsfilcnt_t` instead. The unsuffixed type is defined in terms of the suffixed type \
28+
upstream under the current target architecture (x86_64,) and support for suffixed \
29+
types is phasing out in the `libc` crate."
30+
)]
1931
pub type fsfilcnt64_t = c_ulong;
2032
pub type __u64 = c_ulong;
2133

34+
pub type flock64 = flock;
35+
pub type stat64 = stat;
36+
2237
s! {
2338
pub struct stat {
24-
pub st_dev: c_ulong,
25-
pub __pad1: c_ushort,
39+
pub st_dev: crate::dev_t,
2640
pub st_ino: crate::ino_t,
27-
pub st_mode: crate::mode_t,
2841
pub st_nlink: nlink_t,
29-
pub st_uid: crate::uid_t,
30-
pub st_gid: crate::gid_t,
31-
pub st_rdev: c_ulong,
32-
pub __pad2: c_ushort,
33-
pub st_size: crate::off64_t,
34-
pub st_blksize: blksize_t,
35-
pub st_blocks: crate::blkcnt64_t,
36-
pub st_atim: crate::timespec,
37-
pub st_mtim: crate::timespec,
38-
pub st_ctim: crate::timespec,
39-
pub __uclibc_unused4: c_ulong,
40-
pub __uclibc_unused5: c_ulong,
41-
}
42-
43-
pub struct stat64 {
44-
pub st_dev: c_ulong,
45-
pub __pad1: c_uint,
46-
pub __st_ino: crate::ino_t,
4742
pub st_mode: crate::mode_t,
48-
pub st_nlink: nlink_t,
4943
pub st_uid: crate::uid_t,
5044
pub st_gid: crate::gid_t,
51-
pub st_rdev: c_ulong,
52-
pub __pad2: c_uint,
53-
pub st_size: crate::off64_t,
54-
pub st_blksize: blksize_t,
55-
pub st_blocks: crate::blkcnt64_t,
45+
__pad0: Padding<c_int>,
46+
pub st_rdev: crate::dev_t,
47+
pub st_size: crate::off_t,
48+
pub st_blksize: crate::blksize_t,
49+
pub st_blocks: crate::blkcnt_t,
5650
pub st_atim: crate::timespec,
5751
pub st_mtim: crate::timespec,
5852
pub st_ctim: crate::timespec,
59-
pub st_ino: crate::ino64_t,
53+
__uclibc_unused: Padding<[c_long; 3]>,
6054
}
6155

6256
pub struct shmid_ds {
6357
pub shm_perm: crate::ipc_perm,
6458
pub shm_segsz: crate::size_t,
6559
pub shm_atime: crate::time_t,
66-
__unused1: c_ulong,
60+
__unused1: Padding<c_ulong>,
6761
pub shm_dtime: crate::time_t,
68-
__unused2: c_ulong,
62+
__unused2: Padding<c_ulong>,
6963
pub shm_ctime: crate::time_t,
70-
__unused3: c_ulong,
64+
__unused3: Padding<c_ulong>,
7165
pub shm_cpid: crate::pid_t,
7266
pub shm_lpid: crate::pid_t,
7367
pub shm_nattch: crate::shmatt_t,
74-
__unused4: c_ulong,
75-
__unused5: c_ulong,
68+
__unused4: Padding<c_ulong>,
69+
__unused5: Padding<c_ulong>,
7670
}
7771

7872
#[allow(unpredictable_function_pointer_comparisons)]

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

Lines changed: 31 additions & 48 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,9 @@ 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+
pub type statfs64 = statfs;
13+
pub type statvfs64 = statvfs;
14+
1315
cfg_if! {
1416
if #[cfg(doc)] {
1517
// Used in `linux::arch` to define ioctl constants.
@@ -44,48 +46,18 @@ s! {
4446
}
4547

4648
pub struct statfs {
47-
pub f_type: fsword_t,
48-
pub f_bsize: fsword_t,
49+
pub f_type: c_long,
50+
pub f_bsize: c_long,
4951
pub f_blocks: crate::fsblkcnt_t,
5052
pub f_bfree: crate::fsblkcnt_t,
5153
pub f_bavail: crate::fsblkcnt_t,
5254
pub f_files: crate::fsfilcnt_t,
5355
pub f_ffree: crate::fsfilcnt_t,
5456
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],
59-
}
60-
61-
pub struct statfs64 {
62-
pub f_type: fsword_t,
63-
pub f_bsize: fsword_t,
64-
pub f_blocks: crate::fsblkcnt64_t,
65-
pub f_bfree: crate::fsblkcnt64_t,
66-
pub f_bavail: crate::fsblkcnt64_t,
67-
pub f_files: crate::fsfilcnt64_t,
68-
pub f_ffree: crate::fsfilcnt64_t,
69-
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],
57+
pub f_namelen: c_long,
58+
pub f_frsize: c_long,
59+
pub f_flags: c_long,
60+
pub f_spare: [c_long; 4],
8961
}
9062

9163
pub struct ipc_perm {
@@ -99,11 +71,11 @@ s! {
9971
#[cfg(target_pointer_width = "64")]
10072
pub mode: c_uint,
10173
#[cfg(target_pointer_width = "32")]
102-
__pad1: c_ushort,
74+
__pad1: Padding<c_ushort>,
10375
pub __seq: c_ushort,
104-
__pad2: c_ushort,
105-
__unused1: c_ulong,
106-
__unused2: c_ulong,
76+
__pad2: Padding<c_ushort>,
77+
__unused1: Padding<c_ulong>,
78+
__unused2: Padding<c_ulong>,
10779
}
10880

10981
pub struct statvfs {
@@ -116,15 +88,12 @@ s! {
11688
pub f_files: crate::fsfilcnt_t,
11789
pub f_ffree: crate::fsfilcnt_t,
11890
pub f_favail: crate::fsfilcnt_t,
119-
#[cfg(target_endian = "little")]
12091
pub f_fsid: c_ulong,
12192
#[cfg(target_pointer_width = "32")]
122-
__f_unused: c_int,
123-
#[cfg(target_endian = "big")]
124-
pub f_fsid: c_ulong,
93+
__f_unused: Padding<c_int>,
12594
pub f_flag: c_ulong,
12695
pub f_namemax: c_ulong,
127-
__f_spare: [c_int; 6],
96+
__f_spare: Padding<[c_int; 6]>,
12897
}
12998

13099
pub struct sysinfo {
@@ -513,10 +482,24 @@ extern "C" {
513482
flags: c_int,
514483
) -> c_int;
515484

516-
pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
517-
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
485+
pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
486+
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
518487

488+
#[deprecated(
489+
since = "0.2.187",
490+
note = "Use `getrlimit` instead. Upstream `#define`s the unsuffixed variants in terms of \
491+
the suffixed variants under builds that use the default configurations. Support for \
492+
suffixed symbols is being phased out in the `libc` crate."
493+
)]
494+
#[allow(deprecated)]
519495
pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int;
496+
#[deprecated(
497+
since = "0.2.187",
498+
note = "Use `setrlimit` instead. Upstream `#define`s the unsuffixed variants in terms of \
499+
the suffixed variants under builds that use the default configurations. Support for \
500+
suffixed symbols is being phased out in the `libc` crate."
501+
)]
502+
#[allow(deprecated)]
520503
pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64)
521504
-> c_int;
522505
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: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,49 +17,44 @@ 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.187",
22+
note = "Use `fsblkcnt_t` instead. The unsuffixed type is defined in terms of the suffixed type \
23+
upstream under the current target architecture (x86_64,) and support for suffixed \
24+
types is phasing out in the `libc` crate."
25+
)]
2026
pub type fsblkcnt64_t = c_ulong;
27+
#[deprecated(
28+
since = "0.2.187",
29+
note = "Use `fsfilcnt_t` instead. The unsuffixed type is defined in terms of the suffixed type \
30+
upstream under the current target architecture (x86_64,) and support for suffixed \
31+
types is phasing out in the `libc` crate."
32+
)]
2133
pub type fsfilcnt64_t = c_ulong;
2234

2335
pub type __u32 = c_uint;
2436
pub type __u64 = c_ulong;
2537

38+
pub type stat64 = stat;
39+
pub type flock64 = flock;
40+
2641
s! {
2742
pub struct stat {
28-
pub st_dev: c_ulong,
29-
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.
32-
pub st_nlink: nlink_t,
33-
pub st_mode: crate::mode_t,
34-
pub st_uid: crate::uid_t,
35-
pub st_gid: crate::gid_t,
36-
__pad0: c_int,
37-
pub st_rdev: c_ulong,
38-
pub st_size: crate::off_t,
39-
pub st_blksize: crate::blksize_t,
40-
pub st_blocks: crate::blkcnt64_t,
41-
pub st_atim: crate::timespec,
42-
pub st_mtim: crate::timespec,
43-
pub st_ctim: crate::timespec,
44-
__uclibc_unused: [c_long; 3],
45-
}
46-
47-
pub struct stat64 {
48-
pub st_dev: c_ulong,
43+
pub st_dev: crate::dev_t,
4944
pub st_ino: crate::ino_t,
5045
pub st_nlink: nlink_t,
5146
pub st_mode: crate::mode_t,
5247
pub st_uid: crate::uid_t,
5348
pub st_gid: crate::gid_t,
54-
__pad0: c_int,
55-
pub st_rdev: c_ulong,
49+
__pad0: Padding<c_int>,
50+
pub st_rdev: crate::dev_t,
5651
pub st_size: crate::off_t,
5752
pub st_blksize: crate::blksize_t,
58-
pub st_blocks: crate::blkcnt64_t,
53+
pub st_blocks: crate::blkcnt_t,
5954
pub st_atim: crate::timespec,
6055
pub st_mtim: crate::timespec,
6156
pub st_ctim: crate::timespec,
62-
st_pad4: [c_long; 3],
57+
__uclibc_unused: Padding<[c_long; 3]>,
6358
}
6459

6560
pub struct shmid_ds {
@@ -71,8 +66,8 @@ s! {
7166
pub shm_cpid: crate::pid_t,
7267
pub shm_lpid: crate::pid_t,
7368
pub shm_nattch: crate::shmatt_t,
74-
__unused4: c_ulong,
75-
__unused5: c_ulong,
69+
__unused4: Padding<c_ulong>,
70+
__unused5: Padding<c_ulong>,
7671
}
7772

7873
#[allow(unpredictable_function_pointer_comparisons)]

0 commit comments

Comments
 (0)