Skip to content

Commit dff2c13

Browse files
committed
refactor: change file offset bitwidths in android
This patch updates the exposed file offset bindings to Android targets. At present, all target triples provide LFS64 types and routines, even though it is only on platforms with a 32-bit ABI that this is required. The Android upstream documentation mentions that these symbols are not really necessary in platforms with a 64-bit ABI [1]. We currently also expose those. Following the trend towards providing a single, 64-bit unsuffixed symbol in the `libc` crate, this patch deprecates all such symbols. The deprecation note advises use of the memory-wise equivalent, unsuffixed types. [1]: https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md
1 parent 413bb61 commit dff2c13

6 files changed

Lines changed: 362 additions & 11 deletions

File tree

src/unix/linux_like/android/b64/aarch64/mod.rs

Lines changed: 8 additions & 3 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 wchar_t = u32;
@@ -15,7 +14,7 @@ s! {
1514
pub st_gid: crate::gid_t,
1615
pub st_rdev: crate::dev_t,
1716
__pad1: Padding<c_ulong>,
18-
pub st_size: off64_t,
17+
pub st_size: crate::off_t,
1918
pub st_blksize: c_int,
2019
__pad2: Padding<c_int>,
2120
pub st_blocks: c_long,
@@ -29,6 +28,12 @@ s! {
2928
__unused5: Padding<c_uint>,
3029
}
3130

31+
#[deprecated(
32+
since = "0.2.187",
33+
note = "Use `stat` instead. Under 64-bit ABIs, Android aliases these types, and the `libc` \
34+
crate is phasing out support for suffixed types in favor of a single, fixed-width unsuffixed type."
35+
)]
36+
#[allow(deprecated)]
3237
pub struct stat64 {
3338
pub st_dev: crate::dev_t,
3439
pub st_ino: crate::ino_t,
@@ -38,7 +43,7 @@ s! {
3843
pub st_gid: crate::gid_t,
3944
pub st_rdev: crate::dev_t,
4045
__pad1: Padding<c_ulong>,
41-
pub st_size: off64_t,
46+
pub st_size: crate::off64_t,
4247
pub st_blksize: c_int,
4348
__pad2: Padding<c_int>,
4449
pub st_blocks: c_long,

src/unix/linux_like/android/b64/mod.rs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ use crate::prelude::*;
44
// but may be wrong for mips64
55

66
pub type mode_t = u32;
7-
pub type off64_t = i64;
87
pub type socklen_t = u32;
98

9+
#[deprecated(
10+
since = "0.2.187",
11+
note = "Use `off_t` instead. Under 64-bit ABIs, Android just aliases these two types, and the \
12+
`libc` crate is phasing out support for suffixed types in favor of exposing a single, \
13+
fixed-width unsuffixed type."
14+
)]
15+
pub type off64_t = i64;
16+
1017
s! {
1118
pub struct sigset_t {
1219
__val: [c_ulong; 1],
@@ -21,6 +28,12 @@ s! {
2128
pub sa_restorer: Option<extern "C" fn()>,
2229
}
2330

31+
#[deprecated(
32+
since = "0.2.187",
33+
note = "Use `rlimit` instead. Under 64-bit ABIs, Android aliases these types, and the \
34+
`libc` crate is phasing out support for suffixed variants in favor of a single, \
35+
fixed-width suffixed type."
36+
)]
2437
pub struct rlimit64 {
2538
pub rlim_cur: c_ulonglong,
2639
pub rlim_max: c_ulonglong,
@@ -78,6 +91,12 @@ s! {
7891
pub _f: [c_char; 0],
7992
}
8093

94+
#[deprecated(
95+
since = "0.2.187",
96+
note = "Use `statfs` instead. Under 64-bit ABIs, Android aliases these types, and the \
97+
`libc` crate is phasing out support for suffixed types in favor of a single \
98+
unsuffixed type with a fixed bit width."
99+
)]
81100
pub struct statfs64 {
82101
pub f_type: u64,
83102
pub f_bsize: u64,
@@ -93,6 +112,12 @@ s! {
93112
pub f_spare: [u64; 4],
94113
}
95114

115+
#[deprecated(
116+
since = "0.2.187",
117+
note = "Use `statfs` instead. Under 64-bit ABIs, Android aliases these types, and the \
118+
`libc` crate is phasing out support for suffixed types in favor of a single \
119+
unsuffixed type with a fixed bit width."
120+
)]
96121
pub struct statvfs64 {
97122
pub f_bsize: c_ulong,
98123
pub f_frsize: c_ulong,
@@ -135,6 +160,12 @@ s! {
135160
__reserved: Padding<[c_char; 36]>,
136161
}
137162

163+
#[deprecated(
164+
since = "0.2.187",
165+
note = "Use `sigset_t` instead. Under 64-bit ABIs, Android aliases these types, and the \
166+
`libc` crate is phasing out support for suffixed variants in favor of a single, \
167+
unsuffixed type with a fixed bit width."
168+
)]
138169
pub struct sigset64_t {
139170
__bits: [c_ulong; 1],
140171
}

src/unix/linux_like/android/b64/riscv64/mod.rs

Lines changed: 9 additions & 3 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 wchar_t = u32;
@@ -16,7 +15,7 @@ s! {
1615
pub st_gid: crate::gid_t,
1716
pub st_rdev: crate::dev_t,
1817
__pad1: Padding<c_ulong>,
19-
pub st_size: off64_t,
18+
pub st_size: crate::off_t,
2019
pub st_blksize: c_int,
2120
__pad2: Padding<c_int>,
2221
pub st_blocks: c_long,
@@ -30,6 +29,13 @@ s! {
3029
__unused5: Padding<c_uint>,
3130
}
3231

32+
#[deprecated(
33+
since = "0.2.187",
34+
note = "Use `stat` instead. Under 64-bit ABIs, Android aliases these types, and the `libc` \
35+
crate is phasing out support for suffixed types in favor of a single unsuffixed \
36+
type with a fixed bit width."
37+
)]
38+
#[allow(deprecated)]
3339
pub struct stat64 {
3440
pub st_dev: crate::dev_t,
3541
pub st_ino: crate::ino_t,
@@ -39,7 +45,7 @@ s! {
3945
pub st_gid: crate::gid_t,
4046
pub st_rdev: crate::dev_t,
4147
__pad1: Padding<c_ulong>,
42-
pub st_size: off64_t,
48+
pub st_size: crate::off64_t,
4349
pub st_blksize: c_int,
4450
__pad2: Padding<c_int>,
4551
pub st_blocks: c_long,

src/unix/linux_like/android/b64/x86_64/mod.rs

Lines changed: 10 additions & 3 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 wchar_t = i32;
@@ -15,7 +14,7 @@ s! {
1514
pub st_uid: crate::uid_t,
1615
pub st_gid: crate::gid_t,
1716
pub st_rdev: crate::dev_t,
18-
pub st_size: off64_t,
17+
pub st_size: crate::off_t,
1918
pub st_blksize: c_long,
2019
pub st_blocks: c_long,
2120
pub st_atime: c_long,
@@ -27,6 +26,13 @@ s! {
2726
__unused: Padding<[c_long; 3]>,
2827
}
2928

29+
#[deprecated(
30+
since = "0.2.187",
31+
note = "Use `stat` instead. Under 64-bit ABIs, Android aliases these types, and the `libc` \
32+
crate is phasing out support for suffixed types in favor of a single, unsuffixed, \
33+
fixed-width type."
34+
)]
35+
#[allow(deprecated)]
3036
pub struct stat64 {
3137
pub st_dev: crate::dev_t,
3238
pub st_ino: crate::ino_t,
@@ -35,7 +41,7 @@ s! {
3541
pub st_uid: crate::uid_t,
3642
pub st_gid: crate::gid_t,
3743
pub st_rdev: crate::dev_t,
38-
pub st_size: off64_t,
44+
pub st_size: crate::off64_t,
3945
pub st_blksize: c_long,
4046
pub st_blocks: c_long,
4147
pub st_atime: c_long,
@@ -156,6 +162,7 @@ s! {
156162
}
157163

158164
s_no_extra_traits! {
165+
#[allow(deprecated)]
159166
pub union __c_anonymous_uc_sigmask {
160167
uc_sigmask: crate::sigset_t,
161168
uc_sigmask64: crate::sigset64_t,

src/unix/linux_like/android/mod.rs

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ pub type nfds_t = c_uint;
3434
pub type rlim_t = c_ulong;
3535
pub type dev_t = c_ulong;
3636
pub type ino_t = c_ulong;
37-
pub type ino64_t = u64;
3837
pub type __CPU_BITTYPE = c_ulong;
3938
pub type idtype_t = c_int;
4039
pub type loff_t = c_longlong;
@@ -48,6 +47,17 @@ pub type __u32 = c_uint;
4847
pub type __s32 = c_int;
4948
pub type __be16 = __u16;
5049

50+
#[cfg_attr(
51+
target_pointer_width = "64",
52+
deprecated(
53+
since = "0.2.187",
54+
note = "Use `ino_t` instead. Under 64-bit ABIs, Android aliases these types and the `libc` \
55+
crate is phasing out support for suffixed variants in favor of a single, \
56+
fixed-width unsuffixed type."
57+
)
58+
)]
59+
pub type ino64_t = u64;
60+
5161
// linux/elf.h
5262

5363
pub type Elf32_Addr = u32;
@@ -119,6 +129,15 @@ s! {
119129
pub l_pid: crate::pid_t,
120130
}
121131

132+
#[cfg_attr(
133+
target_pointer_width = "64",
134+
deprecated(
135+
since = "0.2.187",
136+
note = "Use `flock` instead. Under 64-bit ABIs, Android aliases these types, and the \
137+
`libc` crate is phasing out support for suffixed variants in favor of a single, \
138+
unsuffixed, fixed-width symbol."
139+
)
140+
)]
122141
pub struct flock64 {
123142
pub l_type: c_short,
124143
pub l_whence: c_short,
@@ -511,6 +530,12 @@ s! {
511530
pub d_name: [c_char; 256],
512531
}
513532

533+
#[deprecated(
534+
since = "0.2.187",
535+
note = "Use `dirent` instead. This type is defined as an alias to it and the `libc` crate \
536+
is phasing out support for suffixed types in favor of a single, fixed-width \
537+
unsuffixed type."
538+
)]
514539
pub struct dirent64 {
515540
pub d_ino: u64,
516541
pub d_off: i64,
@@ -3385,7 +3410,27 @@ extern "C" {
33853410
pub fn setgrent();
33863411
pub fn endgrent();
33873412
pub fn getgrent() -> *mut crate::group;
3413+
#[cfg_attr(
3414+
target_pointer_width = "64",
3415+
deprecated(
3416+
since = "0.2.187",
3417+
note = "Use `getrlimit` instead. Under 64-bit ABIs, Android aliases these types and the \
3418+
`libc` crate is phasing out support for suffixed variants in favor of a single, \
3419+
fixed-width, unsuffixed type."
3420+
),
3421+
allow(deprecated)
3422+
)]
33883423
pub fn getrlimit64(resource: c_int, rlim: *mut rlimit64) -> c_int;
3424+
#[cfg_attr(
3425+
target_pointer_width = "64",
3426+
deprecated(
3427+
since = "0.2.187",
3428+
note = "Use `setrlimit` instead. Under 64-bit ABIs, Android aliases these types and the \
3429+
`libc` crate is phasing out support for suffixed variants in favor of a single, \
3430+
fixed-width, unsuffixed type."
3431+
),
3432+
allow(deprecated)
3433+
)]
33893434
pub fn setrlimit64(resource: c_int, rlim: *const rlimit64) -> c_int;
33903435
pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int;
33913436
pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int;
@@ -3395,6 +3440,16 @@ extern "C" {
33953440
new_limit: *const crate::rlimit,
33963441
old_limit: *mut crate::rlimit,
33973442
) -> c_int;
3443+
#[cfg_attr(
3444+
target_pointer_width = "64",
3445+
deprecated(
3446+
since = "0.2.187",
3447+
note = "Use `prlimit` instead. Under 64-bit ABIs, Android aliases these types and the \
3448+
`libc` crate is phasing out support for suffixed variants in favor of a single, \
3449+
fixed-width, unsuffixed type."
3450+
),
3451+
allow(deprecated)
3452+
)]
33983453
pub fn prlimit64(
33993454
pid: crate::pid_t,
34003455
resource: c_int,
@@ -3455,8 +3510,28 @@ extern "C" {
34553510
pub fn seekdir(dirp: *mut crate::DIR, loc: c_long);
34563511
pub fn telldir(dirp: *mut crate::DIR) -> c_long;
34573512
pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int;
3513+
#[cfg_attr(
3514+
target_pointer_width = "64",
3515+
deprecated(
3516+
since = "0.2.187",
3517+
note = "Use `fallocate` instead. Under 64-bit ABIs, Android aliases these types and \
3518+
the `libc` crate is phasing out support for suffixed variants in favor of a \
3519+
fixed-width unsuffixed type."
3520+
),
3521+
allow(deprecated)
3522+
)]
34583523
pub fn fallocate64(fd: c_int, mode: c_int, offset: off64_t, len: off64_t) -> c_int;
34593524
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
3525+
#[cfg_attr(
3526+
target_pointer_width = "64",
3527+
deprecated(
3528+
since = "0.2.187",
3529+
note = "Use `posix_fallocate` instead. Under 64-bit ABIs, Android aliases these types \
3530+
and the `libc` crate is phasing out support for suffixed variants in favor of \
3531+
a fixed-width unsuffixed type."
3532+
),
3533+
allow(deprecated)
3534+
)]
34603535
pub fn posix_fallocate64(fd: c_int, offset: off64_t, len: off64_t) -> c_int;
34613536
pub fn getxattr(
34623537
path: *const c_char,
@@ -3613,6 +3688,16 @@ extern "C" {
36133688
param: *const crate::sched_param,
36143689
) -> c_int;
36153690
pub fn sendfile(out_fd: c_int, in_fd: c_int, offset: *mut off_t, count: size_t) -> ssize_t;
3691+
#[cfg_attr(
3692+
target_pointer_width = "64",
3693+
deprecated(
3694+
since = "0.2.187",
3695+
note = "Use `sendfile` instead. Under 64-bit ABIs, Android aliases these types and the \
3696+
`libc` crate is phasing out support for suffixed variants in favor of a single \
3697+
unsuffixed type with a fixed bit-width."
3698+
),
3699+
allow(deprecated)
3700+
)]
36163701
pub fn sendfile64(out_fd: c_int, in_fd: c_int, offset: *mut off64_t, count: size_t) -> ssize_t;
36173702
pub fn setfsgid(gid: crate::gid_t) -> c_int;
36183703
pub fn setfsuid(uid: crate::uid_t) -> c_int;

0 commit comments

Comments
 (0)