Skip to content

Commit 42ead6d

Browse files
committed
Add missing utmpx apis for linux musl
Close rust-lang#4322 Also add a deprecation warning, because those functions are only implemented as stubs inside musl. Signed-off-by: Etienne Cordonnier <[email protected]>
1 parent 139801f commit 42ead6d

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

libc-test/semver/linux-musl.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ACCOUNTING
12
AF_IB
23
AF_MPLS
34
AF_XDP
@@ -37,6 +38,9 @@ RWF_HIPRI
3738
RWF_NOWAIT
3839
RWF_SYNC
3940
USER_PROCESS
41+
UT_HOSTSIZE
42+
UT_LINESIZE
43+
UT_NAMESIZE
4044
_CS_V6_ENV
4145
_CS_V7_ENV
4246
adjtimex
@@ -82,3 +86,4 @@ reallocarray
8286
setutxent
8387
tcp_info
8488
timex
89+
utmpxname

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ pub const INIT_PROCESS: c_short = 5;
656656
pub const LOGIN_PROCESS: c_short = 6;
657657
pub const USER_PROCESS: c_short = 7;
658658
pub const DEAD_PROCESS: c_short = 8;
659-
// musl does not define ACCOUNTING
659+
pub const ACCOUNTING: c_short = 9;
660660

661661
pub const SFD_CLOEXEC: c_int = 0x080000;
662662

@@ -888,6 +888,10 @@ pub const _CS_V7_ENV: c_int = 1149;
888888

889889
pub const CLONE_NEWTIME: c_int = 0x80;
890890

891+
pub const UT_HOSTSIZE: usize = 256;
892+
pub const UT_LINESIZE: usize = 32;
893+
pub const UT_NAMESIZE: usize = 32;
894+
891895
cfg_if! {
892896
if #[cfg(target_arch = "s390x")] {
893897
pub const POSIX_FADV_DONTNEED: c_int = 6;
@@ -987,12 +991,41 @@ extern "C" {
987991
fd: c_int,
988992
) -> c_int;
989993

994+
#[deprecated(
995+
since = "0.2.172",
996+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
997+
)]
990998
pub fn getutxent() -> *mut utmpx;
999+
#[deprecated(
1000+
since = "0.2.172",
1001+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1002+
)]
9911003
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1004+
#[deprecated(
1005+
since = "0.2.172",
1006+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1007+
)]
9921008
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1009+
#[deprecated(
1010+
since = "0.2.172",
1011+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1012+
)]
9931013
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1014+
#[deprecated(
1015+
since = "0.2.172",
1016+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1017+
)]
9941018
pub fn setutxent();
1019+
#[deprecated(
1020+
since = "0.2.172",
1021+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1022+
)]
9951023
pub fn endutxent();
1024+
#[deprecated(
1025+
since = "0.2.172",
1026+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1027+
)]
1028+
pub fn utmpxname(file: *const c_char) -> c_int;
9961029
}
9971030

9981031
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support

0 commit comments

Comments
 (0)