Skip to content

Commit 03e6ffc

Browse files
authored
Merge pull request #4396 from tgross35/backport-serrano
[0.2] Backports
2 parents ae44b25 + f9a47ac commit 03e6ffc

File tree

20 files changed

+411
-111
lines changed

20 files changed

+411
-111
lines changed

build.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
3232
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin",
3333
],
3434
),
35-
("target_env", &["illumos", "wasi", "aix", "ohos"]),
35+
(
36+
"target_env",
37+
&["illumos", "wasi", "aix", "ohos", "nto71_iosock", "nto80"],
38+
),
3639
(
3740
"target_arch",
3841
&["loongarch64", "mips32r6", "mips64r6", "csky"],

libc-test/build.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3307,6 +3307,20 @@ fn test_neutrino(target: &str) {
33073307
assert!(target.contains("nto-qnx"));
33083308

33093309
let mut cfg = ctest_cfg();
3310+
if target.ends_with("_iosock") {
3311+
let qnx_target_val = std::env::var("QNX_TARGET")
3312+
.unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into());
3313+
3314+
cfg.include(qnx_target_val + "/usr/include/io-sock");
3315+
headers! { cfg:
3316+
"io-sock.h",
3317+
"sys/types.h",
3318+
"sys/socket.h",
3319+
"sys/sysctl.h",
3320+
"net/if.h",
3321+
"net/if_arp.h"
3322+
}
3323+
}
33103324

33113325
headers! { cfg:
33123326
"ctype.h",
@@ -3464,6 +3478,9 @@ fn test_neutrino(target: &str) {
34643478
// Does not exist in Neutrino
34653479
"locale_t" => true,
34663480

3481+
// FIXME: "'__uint128' undeclared" in C
3482+
"__uint128" => true,
3483+
34673484
_ => false,
34683485
}
34693486
});
@@ -3527,6 +3544,9 @@ fn test_neutrino(target: &str) {
35273544
// stack unwinding bug.
35283545
"__my_thread_exit" => true,
35293546

3547+
// Wrong const-ness
3548+
"dl_iterate_phdr" => true,
3549+
35303550
_ => false,
35313551
}
35323552
});
@@ -4178,6 +4198,9 @@ fn test_linux(target: &str) {
41784198
// FIXME(linux): Requires >= 6.12 kernel headers.
41794199
"dmabuf_cmsg" | "dmabuf_token" => true,
41804200

4201+
// FIXME(linux): Requires >= 6.4 kernel headers.
4202+
"ptrace_sud_config" => true,
4203+
41814204
_ => false,
41824205
}
41834206
});
@@ -4602,6 +4625,8 @@ fn test_linux(target: &str) {
46024625
| "SO_DEVMEM_DONTNEED"
46034626
| "SCM_DEVMEM_LINEAR"
46044627
| "SCM_DEVMEM_DMABUF" => true,
4628+
// FIXME(linux): Requires >= 6.4 kernel headers.
4629+
"PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true,
46054630

46064631
_ => false,
46074632
}

libc-test/semver/android.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,7 @@ SOL_X25
24462446
SOMAXCONN
24472447
SO_ACCEPTCONN
24482448
SO_BINDTODEVICE
2449+
SO_BINDTOIFINDEX
24492450
SO_BROADCAST
24502451
SO_BSDCOMPAT
24512452
SO_BUSY_POLL

libc-test/semver/cygwin.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,12 @@ posix_fadvise
734734
posix_fallocate
735735
posix_madvise
736736
posix_spawn
737+
posix_spawn_file_actions_addchdir
738+
posix_spawn_file_actions_addchdir_np
737739
posix_spawn_file_actions_addclose
738740
posix_spawn_file_actions_adddup2
741+
posix_spawn_file_actions_addfchdir
742+
posix_spawn_file_actions_addfchdir_np
739743
posix_spawn_file_actions_addopen
740744
posix_spawn_file_actions_destroy
741745
posix_spawn_file_actions_init

libc-test/semver/linux-gnu.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,8 @@ PR_SET_VMA
348348
PR_SET_VMA_ANON_NAME
349349
PTHREAD_MUTEX_ADAPTIVE_NP
350350
PTRACE_GET_SYSCALL_INFO
351+
PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG
352+
PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG
351353
PTRACE_SYSCALL_INFO_ENTRY
352354
PTRACE_SYSCALL_INFO_EXIT
353355
PTRACE_SYSCALL_INFO_NONE
@@ -652,6 +654,7 @@ pthread_rwlockattr_getkind_np
652654
pthread_rwlockattr_getpshared
653655
pthread_rwlockattr_setkind_np
654656
ptrace_peeksiginfo_args
657+
ptrace_sud_config
655658
ptrace_syscall_info
656659
putgrent
657660
putpwent

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/bsd/freebsdlike/freebsd/freebsd11/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ s! {
5151
// This is normally "struct vnode".
5252
/// Pointer to executable file.
5353
pub ki_textvp: *mut c_void,
54-
// This is normally "struct filedesc".
5554
/// Pointer to open file info.
56-
pub ki_fd: *mut c_void,
55+
pub ki_fd: *mut crate::filedesc,
5756
// This is normally "struct vmspace".
5857
/// Pointer to kernel vmspace struct.
5958
pub ki_vmspace: *mut c_void,

src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ s! {
5959
// This is normally "struct vnode".
6060
/// Pointer to executable file.
6161
pub ki_textvp: *mut c_void,
62-
// This is normally "struct filedesc".
6362
/// Pointer to open file info.
64-
pub ki_fd: *mut c_void,
63+
pub ki_fd: *mut crate::filedesc,
6564
// This is normally "struct vmspace".
6665
/// Pointer to kernel vmspace struct.
6766
pub ki_vmspace: *mut c_void,

src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ s! {
6969
// This is normally "struct vnode".
7070
/// Pointer to executable file.
7171
pub ki_textvp: *mut c_void,
72-
// This is normally "struct filedesc".
7372
/// Pointer to open file info.
74-
pub ki_fd: *mut c_void,
73+
pub ki_fd: *mut crate::filedesc,
7574
// This is normally "struct vmspace".
7675
/// Pointer to kernel vmspace struct.
7776
pub ki_vmspace: *mut c_void,

src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ s! {
6969
// This is normally "struct vnode".
7070
/// Pointer to executable file.
7171
pub ki_textvp: *mut c_void,
72-
// This is normally "struct filedesc".
7372
/// Pointer to open file info.
74-
pub ki_fd: *mut c_void,
73+
pub ki_fd: *mut crate::filedesc,
7574
// This is normally "struct vmspace".
7675
/// Pointer to kernel vmspace struct.
7776
pub ki_vmspace: *mut c_void,

src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ s! {
6969
// This is normally "struct vnode".
7070
/// Pointer to executable file.
7171
pub ki_textvp: *mut c_void,
72-
// This is normally "struct filedesc".
7372
/// Pointer to open file info.
74-
pub ki_fd: *mut c_void,
73+
pub ki_fd: *mut crate::filedesc,
7574
// This is normally "struct vmspace".
7675
/// Pointer to kernel vmspace struct.
7776
pub ki_vmspace: *mut c_void,

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,47 @@ s! {
13571357
pub strchange_instrms: u16,
13581358
pub strchange_outstrms: u16,
13591359
}
1360+
1361+
pub struct filedesc {
1362+
pub fd_files: *mut fdescenttbl,
1363+
pub fd_map: *mut c_ulong,
1364+
pub fd_freefile: c_int,
1365+
pub fd_refcnt: c_int,
1366+
pub fd_holdcnt: c_int,
1367+
fd_sx: sx,
1368+
fd_kqlist: kqlist,
1369+
pub fd_holdleaderscount: c_int,
1370+
pub fd_holdleaderswakeup: c_int,
1371+
}
1372+
1373+
pub struct fdescenttbl {
1374+
pub fdt_nfiles: c_int,
1375+
fdt_ofiles: [*mut c_void; 0],
1376+
}
1377+
1378+
// FIXME: Should be private.
1379+
#[doc(hidden)]
1380+
pub struct sx {
1381+
lock_object: lock_object,
1382+
sx_lock: crate::uintptr_t,
1383+
}
1384+
1385+
// FIXME: Should be private.
1386+
#[doc(hidden)]
1387+
pub struct lock_object {
1388+
lo_name: *const c_char,
1389+
lo_flags: c_uint,
1390+
lo_data: c_uint,
1391+
// This is normally `struct witness`.
1392+
lo_witness: *mut c_void,
1393+
}
1394+
1395+
// FIXME: Should be private.
1396+
#[doc(hidden)]
1397+
pub struct kqlist {
1398+
tqh_first: *mut c_void,
1399+
tqh_last: *mut *mut c_void,
1400+
}
13601401
}
13611402

13621403
s_no_extra_traits! {

src/unix/cygwin/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2479,6 +2479,22 @@ extern "C" {
24792479
fd: c_int,
24802480
newfd: c_int,
24812481
) -> c_int;
2482+
pub fn posix_spawn_file_actions_addchdir(
2483+
actions: *mut crate::posix_spawn_file_actions_t,
2484+
path: *const c_char,
2485+
) -> c_int;
2486+
pub fn posix_spawn_file_actions_addfchdir(
2487+
actions: *mut crate::posix_spawn_file_actions_t,
2488+
fd: c_int,
2489+
) -> c_int;
2490+
pub fn posix_spawn_file_actions_addchdir_np(
2491+
actions: *mut crate::posix_spawn_file_actions_t,
2492+
path: *const c_char,
2493+
) -> c_int;
2494+
pub fn posix_spawn_file_actions_addfchdir_np(
2495+
actions: *mut crate::posix_spawn_file_actions_t,
2496+
fd: c_int,
2497+
) -> c_int;
24822498

24832499
pub fn forkpty(
24842500
amaster: *mut c_int,

src/unix/linux_like/android/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,6 +1555,7 @@ pub const SO_PEEK_OFF: c_int = 42;
15551555
pub const SO_BUSY_POLL: c_int = 46;
15561556
pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54;
15571557
pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58;
1558+
pub const SO_BINDTOIFINDEX: c_int = 62;
15581559
pub const SO_TIMESTAMP_NEW: c_int = 63;
15591560
pub const SO_TIMESTAMPNS_NEW: c_int = 64;
15601561
pub const SO_TIMESTAMPING_NEW: c_int = 65;

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,13 @@ s! {
332332
pub u: __c_anonymous_ptrace_syscall_info_data,
333333
}
334334

335+
pub struct ptrace_sud_config {
336+
pub mode: crate::__u64,
337+
pub selector: crate::__u64,
338+
pub offset: crate::__u64,
339+
pub len: crate::__u64,
340+
}
341+
335342
pub struct iocb {
336343
pub aio_data: crate::__u64,
337344
#[cfg(target_endian = "little")]
@@ -933,6 +940,8 @@ pub const PTRACE_SYSCALL_INFO_NONE: crate::__u8 = 0;
933940
pub const PTRACE_SYSCALL_INFO_ENTRY: crate::__u8 = 1;
934941
pub const PTRACE_SYSCALL_INFO_EXIT: crate::__u8 = 2;
935942
pub const PTRACE_SYSCALL_INFO_SECCOMP: crate::__u8 = 3;
943+
pub const PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4210;
944+
pub const PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4211;
936945

937946
// linux/fs.h
938947

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

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

659659
pub const SFD_CLOEXEC: c_int = 0x080000;
660660

@@ -886,6 +886,10 @@ pub const _CS_V7_ENV: c_int = 1149;
886886

887887
pub const CLONE_NEWTIME: c_int = 0x80;
888888

889+
pub const UT_HOSTSIZE: usize = 256;
890+
pub const UT_LINESIZE: usize = 32;
891+
pub const UT_NAMESIZE: usize = 32;
892+
889893
cfg_if! {
890894
if #[cfg(target_arch = "s390x")] {
891895
pub const POSIX_FADV_DONTNEED: c_int = 6;
@@ -985,12 +989,41 @@ extern "C" {
985989
fd: c_int,
986990
) -> c_int;
987991

992+
#[deprecated(
993+
since = "0.2.172",
994+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
995+
)]
988996
pub fn getutxent() -> *mut utmpx;
997+
#[deprecated(
998+
since = "0.2.172",
999+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1000+
)]
9891001
pub fn getutxid(ut: *const utmpx) -> *mut utmpx;
1002+
#[deprecated(
1003+
since = "0.2.172",
1004+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1005+
)]
9901006
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
1007+
#[deprecated(
1008+
since = "0.2.172",
1009+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1010+
)]
9911011
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
1012+
#[deprecated(
1013+
since = "0.2.172",
1014+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1015+
)]
9921016
pub fn setutxent();
1017+
#[deprecated(
1018+
since = "0.2.172",
1019+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1020+
)]
9931021
pub fn endutxent();
1022+
#[deprecated(
1023+
since = "0.2.172",
1024+
note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html"
1025+
)]
1026+
pub fn utmpxname(file: *const c_char) -> c_int;
9941027
}
9951028

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

src/unix/mod.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,13 @@ pub const ATF_PERM: c_int = 0x04;
334334
pub const ATF_PUBL: c_int = 0x08;
335335
pub const ATF_USETRAILERS: c_int = 0x10;
336336

337-
pub const FNM_PERIOD: c_int = 1 << 2;
337+
cfg_if! {
338+
if #[cfg(target_os = "nto")] {
339+
pub const FNM_PERIOD: c_int = 1 << 1;
340+
} else {
341+
pub const FNM_PERIOD: c_int = 1 << 2;
342+
}
343+
}
338344
pub const FNM_NOMATCH: c_int = 1;
339345

340346
cfg_if! {
@@ -354,9 +360,22 @@ cfg_if! {
354360
target_os = "cygwin",
355361
))] {
356362
pub const FNM_PATHNAME: c_int = 1 << 1;
357-
pub const FNM_NOESCAPE: c_int = 1 << 0;
358363
} else {
359364
pub const FNM_PATHNAME: c_int = 1 << 0;
365+
}
366+
}
367+
368+
cfg_if! {
369+
if #[cfg(any(
370+
target_os = "macos",
371+
target_os = "freebsd",
372+
target_os = "android",
373+
target_os = "openbsd",
374+
))] {
375+
pub const FNM_NOESCAPE: c_int = 1 << 0;
376+
} else if #[cfg(target_os = "nto")] {
377+
pub const FNM_NOESCAPE: c_int = 1 << 2;
378+
} else {
360379
pub const FNM_NOESCAPE: c_int = 1 << 1;
361380
}
362381
}

0 commit comments

Comments
 (0)