Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alias all LFS64 symbols to their non-LFS64 counterparts on musl #2935

Merged
merged 15 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3333,8 +3333,8 @@ fn test_linux(target: &str) {
"Ioctl" if gnu => "unsigned long".to_string(),
"Ioctl" => "int".to_string(),

// In MUSL `flock64` is a typedef to `flock`.
"flock64" if musl => format!("struct {}", ty),
// LFS64 types have been removed in musl 1.2.4+
"off64_t" if musl => "off_t".to_string(),

// typedefs don't need any keywords
t if t.ends_with("_t") => t.to_string(),
Expand Down Expand Up @@ -3399,7 +3399,14 @@ fn test_linux(target: &str) {
"priority_t" if musl => true,
"name_t" if musl => true,

_ => false,
t => {
if musl {
// LFS64 types have been removed in musl 1.2.4+
t.ends_with("64") || t.ends_with("64_t")
} else {
false
}
}
}
});

Expand All @@ -3411,6 +3418,10 @@ fn test_linux(target: &str) {
if musl && ty.starts_with("uinput_") {
return true;
}
// LFS64 types have been removed in musl 1.2.4+
if musl && (ty.ends_with("64") || ty.ends_with("64_t")) {
return true;
}
// FIXME: sparc64 CI has old headers
if sparc64 && (ty == "uinput_ff_erase" || ty == "uinput_abs_setup") {
return true;
Expand Down Expand Up @@ -3528,6 +3539,10 @@ fn test_linux(target: &str) {
{
return true;
}
// LFS64 types have been removed in musl 1.2.4+
if name.starts_with("RLIM64") {
return true;
}
}
match name {
// These constants are not available if gnu headers have been included
Expand Down
79 changes: 47 additions & 32 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ impl ::Clone for fpos64_t {
}

s! {
pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
}

pub struct glob_t {
pub gl_pathc: ::size_t,
pub gl_pathv: *mut *mut c_char,
Expand Down Expand Up @@ -685,6 +680,11 @@ s! {
pub struct sctp_authinfo {
pub auth_keynumber: ::__u16,
}

pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
}
}

s_no_extra_traits! {
Expand All @@ -703,14 +703,6 @@ s_no_extra_traits! {
pub d_name: [::c_char; 256],
}

pub struct dirent64 {
pub d_ino: ::ino64_t,
pub d_off: ::off64_t,
pub d_reclen: ::c_ushort,
pub d_type: ::c_uchar,
pub d_name: [::c_char; 256],
}

pub struct sockaddr_alg {
pub salg_family: ::sa_family_t,
pub salg_type: [::c_uchar; 14],
Expand Down Expand Up @@ -804,6 +796,14 @@ s_no_extra_traits! {
pub tx_type: ::c_int,
pub rx_filter: ::c_int,
}

pub struct dirent64 {
pub d_ino: ::ino64_t,
pub d_off: ::off64_t,
pub d_reclen: ::c_ushort,
pub d_type: ::c_uchar,
pub d_name: [::c_char; 256],
}
}

s_no_extra_traits! {
Expand Down Expand Up @@ -4299,21 +4299,8 @@ extern "C" {
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int;
pub fn __errno_location() -> *mut ::c_int;

pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut ::FILE;
pub fn freopen64(
filename: *const c_char,
mode: *const c_char,
file: *mut ::FILE,
) -> *mut ::FILE;
pub fn tmpfile64() -> *mut ::FILE;
pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
pub fn fseeko64(stream: *mut ::FILE, offset: ::off64_t, whence: ::c_int) -> ::c_int;
pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
pub fn fallocate(fd: ::c_int, mode: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
pub fn fallocate64(fd: ::c_int, mode: ::c_int, offset: ::off64_t, len: ::off64_t) -> ::c_int;
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
pub fn posix_fallocate64(fd: ::c_int, offset: ::off64_t, len: ::off64_t) -> ::c_int;
pub fn readahead(fd: ::c_int, offset: ::off64_t, count: ::size_t) -> ::ssize_t;
pub fn getxattr(
path: *const c_char,
Expand Down Expand Up @@ -4614,12 +4601,6 @@ extern "C" {
offset: *mut off_t,
count: ::size_t,
) -> ::ssize_t;
pub fn sendfile64(
out_fd: ::c_int,
in_fd: ::c_int,
offset: *mut off64_t,
count: ::size_t,
) -> ::ssize_t;
pub fn sigsuspend(mask: *const ::sigset_t) -> ::c_int;
pub fn getgrgid_r(
gid: ::gid_t,
Expand Down Expand Up @@ -4871,6 +4852,40 @@ extern "C" {
) -> ::ssize_t;
}

// LFS64 extensions
//
// * musl has 64-bit versions only so aliases the LFS64 symbols to the standard ones
cfg_if! {
if #[cfg(not(target_env = "musl"))] {
extern "C" {
pub fn fallocate64(
fd: ::c_int,
mode: ::c_int,
offset: ::off64_t,
len: ::off64_t
) -> ::c_int;
pub fn fgetpos64(stream: *mut ::FILE, ptr: *mut fpos64_t) -> ::c_int;
pub fn fopen64(filename: *const c_char, mode: *const c_char) -> *mut ::FILE;
pub fn freopen64(
filename: *const c_char,
mode: *const c_char,
file: *mut ::FILE,
) -> *mut ::FILE;
pub fn fseeko64(stream: *mut ::FILE, offset: ::off64_t, whence: ::c_int) -> ::c_int;
pub fn fsetpos64(stream: *mut ::FILE, ptr: *const fpos64_t) -> ::c_int;
pub fn ftello64(stream: *mut ::FILE) -> ::off64_t;
pub fn posix_fallocate64(fd: ::c_int, offset: ::off64_t, len: ::off64_t) -> ::c_int;
pub fn sendfile64(
out_fd: ::c_int,
in_fd: ::c_int,
offset: *mut off64_t,
count: ::size_t,
) -> ::ssize_t;
pub fn tmpfile64() -> *mut ::FILE;
}
}
}

cfg_if! {
if #[cfg(target_env = "uclibc")] {
mod uclibc;
Expand Down
16 changes: 0 additions & 16 deletions src/unix/linux_like/linux/musl/b32/riscv32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,6 @@ s! {
__pad1: ::c_ulong,
__pad2: ::c_ulong,
}

pub struct flock {
pub l_type: ::c_short,
pub l_whence: ::c_short,
pub l_start: ::off_t,
pub l_len: ::off_t,
pub l_pid: ::pid_t,
}

pub struct flock64 {
pub l_type: ::c_short,
pub l_whence: ::c_short,
pub l_start: ::off64_t,
pub l_len: ::off64_t,
pub l_pid: ::pid_t,
}
}

//pub const RLIM_INFINITY: ::rlim_t = !0;
Expand Down
16 changes: 0 additions & 16 deletions src/unix/linux_like/linux/musl/b64/riscv64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,22 +173,6 @@ s! {
__unused5: ::c_ulong,
__unused6: ::c_ulong,
}

pub struct flock {
pub l_type: ::c_short,
pub l_whence: ::c_short,
pub l_start: ::off_t,
pub l_len: ::off_t,
pub l_pid: ::pid_t,
}

pub struct flock64 {
pub l_type: ::c_short,
pub l_whence: ::c_short,
pub l_start: ::off64_t,
pub l_len: ::off64_t,
pub l_pid: ::pid_t,
}
}

pub const SYS_read: ::c_long = 63;
Expand Down
Loading