From 463286a1a17a629939c7290243150a7a60df586a Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 21 Apr 2023 20:25:58 +0100 Subject: [PATCH] utmpx api for linux musl + musl few build fixes. close #3190 --- libc-test/semver/linux-gnu.txt | 2 +- libc-test/semver/linux-musl.txt | 18 ++++++++++++------ src/unix/linux_like/linux/arch/generic/mod.rs | 8 +++++++- .../linux_like/linux/musl/b64/x86_64/mod.rs | 2 +- src/unix/linux_like/linux/musl/mod.rs | 9 ++++++++- 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 1a5f6ab25af84..44fc31ee00c70 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -575,12 +575,12 @@ dlinfo dlmopen endutxent explicit_bzero +fgetgrent_r fgetspent_r futimes getauxval getentropy getgrent_r -fgetgrent_r getloadavg getpt getpwent_r diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 09c461350f9a5..fc55519f64249 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -32,13 +32,22 @@ aio_return aio_suspend aio_write aiocb +asctime_r +basename clock_adjtime copy_file_range ctermid +dirname +eaccess +endutxent +euidaccess explicit_bzero futimes getauxval getloadavg +getutxent +getutxid +getutxline lio_listio ntptimeval open_wmemstream @@ -47,13 +56,10 @@ prlimit prlimit64 process_vm_readv process_vm_writev +pututxline pwritev64 reallocarray -timex -euidaccess -eaccess -asctime_r +setutxent strftime strptime -dirname -basename +timex diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 4693978311948..d7c7761dd420b 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -279,7 +279,6 @@ cfg_if! { pub const RLIMIT_NICE: ::c_int = 13; pub const RLIMIT_RTPRIO: ::c_int = 14; pub const RLIMIT_RTTIME: ::c_int = 15; - pub const RLIM_NLIMITS: ::c_int = 15; pub const RLIMIT_NLIMITS: ::c_int = RLIM_NLIMITS; } } @@ -291,6 +290,13 @@ cfg_if! { else if #[cfg(target_env = "uclibc")] { pub const RLIM_NLIMITS: ::__rlimit_resource_t = 15; } + else if #[cfg(target_env = "ohos")] { + // FIXME: is it ? + pub const RLIM_NLIMITS: ::c_int = 15; + } + else if #[cfg(target_env = "musl")] { + pub const RLIM_NLIMITS: ::c_int = 16; + } } pub const RLIM_INFINITY: ::rlim_t = !0; diff --git a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs index 8198dc2f35168..4bace9d1ef60d 100644 --- a/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/x86_64/mod.rs @@ -671,7 +671,7 @@ pub const MAP_32BIT: ::c_int = 0x0040; pub const O_APPEND: ::c_int = 1024; pub const O_DIRECT: ::c_int = 0x4000; pub const O_DIRECTORY: ::c_int = 0x10000; -pub const O_LARGEFILE: ::c_int = 0; +pub const O_LARGEFILE: ::c_int = 0x8000; pub const O_NOFOLLOW: ::c_int = 0x20000; pub const O_CREAT: ::c_int = 64; pub const O_EXCL: ::c_int = 128; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 37a8ca2aff2fe..9e4c94616176d 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -303,7 +303,7 @@ s_no_extra_traits! { pub ut_exit: __exit_status, #[cfg(target_env = "musl")] - pub ut_session: ::c_long, + pub ut_session: ::c_int, #[cfg(target_env = "ohos")] #[cfg(target_endian = "little")] @@ -782,6 +782,13 @@ extern "C" { pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; + + pub fn getutxent() -> *mut utmpx; + pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + pub fn setutxent(); + pub fn endutxent(); } cfg_if! {