Skip to content

Commit 59f8ad5

Browse files
committed
refactor: deprecate lfs64 bindings in linux musl
These types are defined upstream in terms of their unsuffixed types, and a large part of the surface API in the exposed bindings does the same. The `libc` crate is moving towards providing unsuffixed types and routines that avoid the need for aliases. This intent was expressed on Windows platforms in #5032. This patch altogether deprecates all items under Linux musl that are conditionally exposed upstream under the `_LARGEFILE64_SOURCE` feature test macro.
1 parent 204104b commit 59f8ad5

18 files changed

Lines changed: 112 additions & 29 deletions

File tree

src/unix/linux_like/linux/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ pub type dev_t = u64;
1212
pub type socklen_t = u32;
1313
pub type mode_t = u32;
1414
pub type ino64_t = u64;
15+
#[cfg_attr(
16+
any(target_env = "musl", target_env = "ohos"),
17+
deprecated(
18+
since = "0.2.187",
19+
note = "Use `off_t` instead. This type is `#define`d as an alias to `off_t` in upstream \
20+
musl and support for the suffixed variants is phasing out in `libc`."
21+
)
22+
)]
1523
pub type off64_t = i64;
1624
pub type blkcnt64_t = i64;
1725
pub type rlim64_t = u64;
@@ -4115,7 +4123,10 @@ extern "C" {
41154123
pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int;
41164124
#[cfg_attr(gnu_file_offset_bits64, link_name = "posix_fallocate64")]
41174125
pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int;
4126+
#[cfg(not(any(target_env = "musl", target_env = "ohos")))]
41184127
pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t;
4128+
#[cfg(any(target_env = "musl", target_env = "ohos"))]
4129+
pub fn readahead(fd: c_int, offset: off_t, count: size_t) -> ssize_t;
41194130
pub fn getxattr(
41204131
path: *const c_char,
41214132
name: *const c_char,
@@ -4203,7 +4214,10 @@ extern "C" {
42034214

42044215
// Not available now on Android
42054216
pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int;
4217+
#[cfg(not(any(target_env = "musl", target_env = "ohos")))]
42064218
pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int;
4219+
#[cfg(any(target_env = "musl", target_env = "ohos"))]
4220+
pub fn sync_file_range(fd: c_int, offset: off_t, nbytes: off_t, flags: c_uint) -> c_int;
42074221

42084222
pub fn posix_madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int;
42094223

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::prelude::*;
33

44
pub type wchar_t = u32;
55

6-
pub type stat64 = stat;
7-
86
s! {
97
pub struct stat {
108
pub st_dev: crate::dev_t,

src/unix/linux_like/linux/musl/b32/hexagon.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::prelude::*;
22

33
pub type wchar_t = u32;
4-
pub type stat64 = crate::stat;
54

65
s! {
76
pub struct stat {

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::prelude::*;
33

44
pub type wchar_t = c_int;
55

6-
pub type stat64 = stat;
7-
86
s! {
97
pub struct stat {
108
pub st_dev: crate::dev_t,
@@ -140,6 +138,11 @@ s! {
140138
pub f_spare: [c_ulong; 5],
141139
}
142140

141+
#[deprecated(
142+
since = "0.2.187",
143+
note = "Use `statfs` instead. This type is defined as an alias to the unsuffixed type \
144+
upstream, and support for suffixed types is phasing out in the `libc` crate."
145+
)]
143146
pub struct statfs64 {
144147
pub f_type: c_ulong,
145148
pub f_bsize: c_ulong,

src/unix/linux_like/linux/musl/b32/powerpc.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::prelude::*;
33

44
pub type wchar_t = i32;
55

6-
pub type stat64 = stat;
7-
86
s! {
97
pub struct termios {
108
pub c_iflag: crate::tcflag_t,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ use crate::prelude::*;
55

66
pub type wchar_t = c_int;
77

8-
pub type stat64 = stat;
9-
108
s! {
119
pub struct stat {
1210
pub st_dev: crate::dev_t,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use crate::prelude::*;
33

44
pub type wchar_t = i32;
55

6-
pub type stat64 = stat;
7-
86
s! {
97
pub struct stat {
108
pub st_dev: crate::dev_t,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ pub type wchar_t = u32;
77
pub type nlink_t = u32;
88
pub type blksize_t = c_int;
99

10-
pub type stat64 = stat;
11-
1210
s! {
1311
pub struct stat {
1412
pub st_dev: crate::dev_t,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ pub type blksize_t = c_int;
1010
pub type __u64 = c_ulonglong;
1111
pub type __s64 = c_longlong;
1212

13-
pub type stat64 = stat;
14-
1513
s! {
1614
pub struct stat {
1715
pub st_dev: crate::dev_t,

src/unix/linux_like/linux/musl/b64/mips64.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ pub type __s64 = c_long;
77
pub type nlink_t = c_uint;
88
pub type blksize_t = i64;
99

10-
pub type stat64 = stat;
11-
1210
s! {
1311
pub struct stat {
1412
pub st_dev: crate::dev_t,
@@ -91,6 +89,11 @@ s! {
9189
pub f_spare: [c_ulong; 5],
9290
}
9391

92+
#[deprecated(
93+
since = "0.2.187",
94+
note = "Use `statfs` instead. This type is defined as an alias to the unsuffixed type \
95+
upstream, and support for suffixed types is phasing out in the `libc` crate."
96+
)]
9497
pub struct statfs64 {
9598
pub f_type: c_ulong,
9699
pub f_bsize: c_ulong,

0 commit comments

Comments
 (0)