Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
38 changes: 34 additions & 4 deletions src/unix/linux_like/l4re/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ pub type pthread_t = *mut c_void;
pub type dev_t = u64;
pub type socklen_t = u32;
pub type mode_t = u32;
pub type ino64_t = u64;
pub type off64_t = i64;
pub type blkcnt64_t = i64;
pub type rlim64_t = u64;
pub type nfds_t = c_ulong;
pub type nl_item = c_int;
pub type idtype_t = c_uint;
Expand All @@ -22,6 +18,40 @@ pub type pthread_key_t = c_uint;
pub type pthread_once_t = c_int;
pub type pthread_spinlock_t = c_int;

#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `ino_t` instead. LFS is being phased out, see rust-lang/libc#4805."
)
)]
pub type ino64_t = u64;
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `off_t` instead. LFS is being phased out, see rust-lang/libc#4805."
)
)]
pub type off64_t = i64;
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `blkcnt_t` instead. LFS is being phased out, see
rust-lang/libc#4805."
)
)]
pub type blkcnt64_t = i64;
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `rlim_t` instead. LFS is being phased out, see rust-lang/libc#4805."
)
)]
pub type rlim64_t = u64;

s! {
/// CPU sets.
pub struct l4_sched_cpu_set_t {
Expand Down
103 changes: 62 additions & 41 deletions src/unix/linux_like/l4re/uclibc/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::off64_t;
use crate::prelude::*;

pub type shmatt_t = c_ulong;
Expand All @@ -10,6 +9,12 @@ pub type __priority_which_t = c_uint;
pub type _pthread_descr = *mut c_void;
pub type __pthread_cond_align_t = c_long;

#[cfg(target_pointer_width = "64")]
pub type __sword_type = c_long;

#[cfg(target_pointer_width = "32")]
pub type __sword_type = c_int;

cfg_if! {
if #[cfg(doc)] {
// Used in `linux::arch` to define ioctl constants.
Expand Down Expand Up @@ -44,48 +49,33 @@ s! {
}

pub struct statfs {
pub f_type: fsword_t,
pub f_bsize: fsword_t,
pub f_type: __sword_type,
pub f_bsize: __sword_type,
pub f_blocks: crate::fsblkcnt_t,
pub f_bfree: crate::fsblkcnt_t,
pub f_bavail: crate::fsblkcnt_t,
pub f_files: crate::fsfilcnt_t,
pub f_ffree: crate::fsfilcnt_t,
pub f_fsid: crate::fsid_t,
pub f_namelen: fsword_t,
pub f_frsize: fsword_t,
pub f_flags: fsword_t,
pub f_spare: [fsword_t; 4],
pub f_namelen: __sword_type,
pub f_frsize: __sword_type,
pub f_flags: __sword_type,
pub f_spare: [__sword_type; 4],
}

pub struct statfs64 {
pub f_type: fsword_t,
pub f_bsize: fsword_t,
pub f_type: __sword_type,
pub f_bsize: __sword_type,
pub f_blocks: crate::fsblkcnt64_t,
pub f_bfree: crate::fsblkcnt64_t,
pub f_bavail: crate::fsblkcnt64_t,
pub f_files: crate::fsfilcnt64_t,
pub f_ffree: crate::fsfilcnt64_t,
pub f_fsid: crate::fsid_t,
pub f_namelen: fsword_t,
pub f_frsize: fsword_t,
pub f_flags: fsword_t,
pub f_spare: [fsword_t; 4],
}

pub struct statvfs64 {
pub f_bsize: c_ulong,
pub f_frsize: c_ulong,
pub f_blocks: crate::fsfilcnt64_t,
pub f_bfree: crate::fsfilcnt64_t,
pub f_bavail: crate::fsfilcnt64_t,
pub f_files: crate::fsfilcnt64_t,
pub f_ffree: crate::fsfilcnt64_t,
pub f_favail: crate::fsfilcnt64_t,
pub f_fsid: c_ulong,
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
pub __f_spare: [c_int; 6],
pub f_namelen: __sword_type,
pub f_frsize: __sword_type,
pub f_flags: __sword_type,
pub f_spare: [__sword_type; 4],
}

pub struct ipc_perm {
Expand All @@ -99,11 +89,11 @@ s! {
#[cfg(target_pointer_width = "64")]
pub mode: c_uint,
#[cfg(target_pointer_width = "32")]
__pad1: c_ushort,
__pad1: Padding<c_ushort>,
pub __seq: c_ushort,
__pad2: c_ushort,
__unused1: c_ulong,
__unused2: c_ulong,
__pad2: Padding<c_ushort>,
__unused1: Padding<c_ulong>,
__unused2: Padding<c_ulong>,
}

pub struct statvfs {
Expand All @@ -116,15 +106,30 @@ s! {
pub f_files: crate::fsfilcnt_t,
pub f_ffree: crate::fsfilcnt_t,
pub f_favail: crate::fsfilcnt_t,
#[cfg(target_endian = "little")]
pub f_fsid: c_ulong,
#[cfg(target_pointer_width = "32")]
__f_unused: c_int,
#[cfg(target_endian = "big")]
__f_unused: Padding<c_int>,
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
__f_spare: Padding<[c_int; 6]>,
}

pub struct statvfs64 {
// Different than GNU!
pub f_bsize: c_ulong,
pub f_frsize: c_ulong,
pub f_blocks: crate::fsblkcnt64_t,
pub f_bfree: crate::fsblkcnt64_t,
pub f_bavail: crate::fsblkcnt64_t,
pub f_files: crate::fsfilcnt64_t,
pub f_ffree: crate::fsfilcnt64_t,
pub f_favail: crate::fsfilcnt64_t,
pub f_fsid: c_ulong,
#[cfg(target_pointer_width = "32")]
__f_unused: Padding<c_int>,
pub f_flag: c_ulong,
pub f_namemax: c_ulong,
__f_spare: [c_int; 6],
__f_spare: Padding<[c_int; 6]>,
}

pub struct sysinfo {
Expand Down Expand Up @@ -300,8 +305,8 @@ s! {
pub shm_cpid: crate::pid_t,
pub shm_lpid: crate::pid_t,
pub shm_nattch: crate::shmatt_t,
__unused4: c_ulong,
__unused5: c_ulong,
__unused4: Padding<c_ulong>,
__unused5: Padding<c_ulong>,
}
}

Expand Down Expand Up @@ -536,10 +541,26 @@ extern "C" {
flags: c_int,
) -> c_int;

pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off64_t) -> ssize_t;

pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;
pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t;

#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `getrlimit` instead. LFS is being phased out, see rust-lang/libc#4805."
),
allow(deprecated)
)]
pub fn getrlimit64(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit64) -> c_int;
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `setrlimit` instead. LFS is being phased out, see rust-lang/libc#4805."
),
allow(deprecated)
)]
pub fn setrlimit64(resource: crate::__rlimit_resource_t, rlim: *const crate::rlimit64)
-> c_int;
pub fn getrlimit(resource: crate::__rlimit_resource_t, rlim: *mut crate::rlimit) -> c_int;
Expand Down
38 changes: 26 additions & 12 deletions src/unix/linux_like/l4re/uclibc/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,55 @@ pub type suseconds_t = c_long;
pub type blksize_t = c_long;
pub type blkcnt_t = c_long;

#[deprecated(
since = "0.2.190",
note = "Use `fsblkcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805."
)]
pub type fsblkcnt64_t = c_ulong;
#[deprecated(
since = "0.2.190",
note = "Use `fsfilcnt_t` instead. LFS is being phased out, see rust-lang/libc#4805."
)]
pub type fsfilcnt64_t = c_ulong;

pub type __u32 = c_uint;
pub type __u64 = c_ulong;

s! {
pub struct stat {
pub st_dev: c_ulong,
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
// According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of
// nlink and mode are swapped on 64 bit systems.
pub st_nlink: nlink_t,
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
pub st_rdev: c_ulong,
__pad0: Padding<c_int>,
pub st_rdev: crate::dev_t,
pub st_size: crate::off_t,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt64_t,
pub st_blocks: crate::blkcnt_t,
pub st_atim: crate::timespec,
pub st_mtim: crate::timespec,
pub st_ctim: crate::timespec,
__uclibc_unused: [c_long; 3],
__uclibc_unused: Padding<[c_long; 3]>,
}

pub struct stat64 {
pub st_dev: c_ulong,
pub st_dev: crate::dev_t,
pub st_ino: crate::ino_t,
pub st_nlink: nlink_t,
pub st_mode: crate::mode_t,
pub st_uid: crate::uid_t,
pub st_gid: crate::gid_t,
__pad0: c_int,
pub st_rdev: c_ulong,
__pad0: Padding<c_int>,
pub st_rdev: crate::dev_t,
pub st_size: crate::off_t,
pub st_blksize: crate::blksize_t,
pub st_blocks: crate::blkcnt64_t,
pub st_blocks: crate::blkcnt_t,
pub st_atim: crate::timespec,
pub st_mtim: crate::timespec,
pub st_ctim: crate::timespec,
st_pad4: [c_long; 3],
__uclibc_unused: Padding<[c_long; 3]>,
}

#[allow(unpredictable_function_pointer_comparisons)]
Expand Down Expand Up @@ -96,6 +102,14 @@ s! {
pub l_pid: crate::pid_t,
}

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

pub struct termios {
pub c_iflag: crate::tcflag_t,
pub c_oflag: crate::tcflag_t,
Expand Down
38 changes: 38 additions & 0 deletions src/unix/linux_like/linux_l4re_shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1935,18 +1935,56 @@ extern "C" {
cfg_if! {
if #[cfg(not(any(target_env = "musl", target_env = "ohos")))] {
extern "C" {
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64",),
deprecated(
since = "0.2.190",
note = "Use `freopen` instead. LFS is being phased out, see \
rust-lang/libc#4805."
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target_os = "l4re" is sufficient here, there's only uclibc and other libcs would probably act the same. Applies a few places.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

)]
pub fn freopen64(
filename: *const c_char,
mode: *const c_char,
file: *mut crate::FILE,
) -> *mut crate::FILE;
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `fseeko` instead. LFS is being phased out, see rust-lang/libc#4805."
)
)]
pub fn fseeko64(
stream: *mut crate::FILE,
#[cfg(any(
not(target_os = "l4re"),
all(target_os = "l4re", not(target_pointer_width = "64"))
))]
offset: crate::off64_t,
#[cfg(all(target_os = "l4re", target_pointer_width = "64"))] offset: crate::off_t,
whence: c_int,
) -> c_int;
#[cfg_attr(
all(target_os = "l4re", target_pointer_width = "64"),
deprecated(
since = "0.2.190",
note = "Use `fsetpos` instead. LFS is being phased out, see \
rust-lang/libc#4805."
)
)]
pub fn fsetpos64(stream: *mut crate::FILE, ptr: *const crate::fpos64_t) -> c_int;
#[cfg(any(
not(target_os = "l4re"),
all(target_os = "l4re", not(target_pointer_width = "64"))
))]
pub fn ftello64(stream: *mut crate::FILE) -> crate::off64_t;
#[cfg(all(target_os = "l4re", target_pointer_width = "64"))]
#[deprecated(
since = "0.2.190",
note = "Use `ftello` instead. LFS is being phased out, see rust-lang/libc#4805."
)]
pub fn ftello64(stream: *mut crate::FILE) -> crate::off_t;
}
}
}
Loading