Skip to content

Commit 10c5418

Browse files
committed
uclibc -> linux-like/linux: Manual consolitation of redundant structs and fns.
1 parent fe8470b commit 10c5418

File tree

14 files changed

+467
-866
lines changed

14 files changed

+467
-866
lines changed

libc-test/build.rs

+30-3
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,7 @@ fn test_linux(target: &str) {
22672267
let gnuabihf = target.contains("gnueabihf");
22682268
let x86_64_gnux32 = target.contains("gnux32") && x86_64;
22692269
let riscv64 = target.contains("riscv64");
2270+
let uclibc = target.contains("uclibc");
22702271

22712272
let mut cfg = ctest_cfg();
22722273
cfg.define("_GNU_SOURCE", None);
@@ -2377,7 +2378,8 @@ fn test_linux(target: &str) {
23772378
[!(x32 || musl || gnu)]: "sys/sysctl.h",
23782379
// <execinfo.h> is not supported by musl:
23792380
// https://www.openwall.com/lists/musl/2015/04/09/3
2380-
[!musl]: "execinfo.h",
2381+
// <execinfo.h> is not present on uclibc.
2382+
[!(musl || uclibc)]: "execinfo.h",
23812383
}
23822384

23832385
// Include linux headers at the end:
@@ -2419,16 +2421,18 @@ fn test_linux(target: &str) {
24192421
"linux/sockios.h",
24202422
"linux/vm_sockets.h",
24212423
"linux/wait.h",
2422-
"sys/auxv.h",
24232424
"sys/fanotify.h",
2425+
// <sys/auxv.h> is not present on uclibc
2426+
[!uclibc]: "sys/auxv.h",
24242427
}
24252428

24262429
// note: aio.h must be included before sys/mount.h
24272430
headers! {
24282431
cfg:
24292432
"sys/xattr.h",
24302433
"sys/sysinfo.h",
2431-
"aio.h",
2434+
// AIO is not supported by uclibc:
2435+
[!uclibc]: "aio.h",
24322436
}
24332437

24342438
cfg.type_name(move |ty, is_struct, is_union| {
@@ -2650,6 +2654,8 @@ fn test_linux(target: &str) {
26502654
| "CAN_J1939"
26512655
| "CAN_RAW_FILTER_MAX"
26522656
| "CAN_NPROTO" => true,
2657+
2658+
"MS_RMT_MASK" if uclibc => true, // updated in glibc 2.22 and musl 1.1.13
26532659

26542660
// FIXME: Requires recent kernel headers (5.8):
26552661
"STATX_MNT_ID" => true,
@@ -2698,6 +2704,27 @@ fn test_linux(target: &str) {
26982704
// FIXME: It now takes c_void instead of timezone since glibc 2.31.
26992705
"gettimeofday" if gnu => true,
27002706

2707+
// These are all implemented as static inline functions in uclibc, so
2708+
// they cannot be linked against.
2709+
// If implementations are required, they might need to be implemented
2710+
// in this crate.
2711+
"posix_spawnattr_init" if uclibc => true,
2712+
"posix_spawnattr_destroy" if uclibc => true,
2713+
"posix_spawnattr_getsigdefault" if uclibc => true,
2714+
"posix_spawnattr_setsigdefault" if uclibc => true,
2715+
"posix_spawnattr_getsigmask" if uclibc => true,
2716+
"posix_spawnattr_setsigmask" if uclibc => true,
2717+
"posix_spawnattr_getflags" if uclibc => true,
2718+
"posix_spawnattr_setflags" if uclibc => true,
2719+
"posix_spawnattr_getpgroup" if uclibc => true,
2720+
"posix_spawnattr_setpgroup" if uclibc => true,
2721+
"posix_spawnattr_getschedpolicy" if uclibc => true,
2722+
"posix_spawnattr_setschedpolicy" if uclibc => true,
2723+
"posix_spawnattr_getschedparam" if uclibc => true,
2724+
"posix_spawnattr_setschedparam" if uclibc => true,
2725+
"posix_spawn_file_actions_init" if uclibc => true,
2726+
"posix_spawn_file_actions_destroy" if uclibc => true,
2727+
27012728
_ => false,
27022729
}
27032730
});

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

+17-3
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,22 @@ pub const TCP_FASTOPEN: ::c_int = 23;
620620
pub const TCP_TIMESTAMP: ::c_int = 24;
621621
pub const TCP_FASTOPEN_CONNECT: ::c_int = 30;
622622

623+
pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
624+
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
625+
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
626+
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
627+
628+
pub const AF_IB: ::c_int = 27;
629+
pub const AF_MPLS: ::c_int = 28;
630+
pub const AF_NFC: ::c_int = 39;
631+
pub const AF_VSOCK: ::c_int = 40;
632+
pub const AF_XDP: ::c_int = 44;
633+
pub const PF_IB: ::c_int = AF_IB;
634+
pub const PF_MPLS: ::c_int = AF_MPLS;
635+
pub const PF_NFC: ::c_int = AF_NFC;
636+
pub const PF_VSOCK: ::c_int = AF_VSOCK;
637+
pub const PF_XDP: ::c_int = AF_XDP;
638+
623639
/* DCCP socket options */
624640
pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
625641
pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
@@ -646,6 +662,7 @@ pub const SIGEV_THREAD_ID: ::c_int = 4;
646662
pub const BUFSIZ: ::c_uint = 8192;
647663
pub const TMP_MAX: ::c_uint = 238328;
648664
pub const FOPEN_MAX: ::c_uint = 16;
665+
pub const FILENAME_MAX: ::c_uint = 4096;
649666
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
650667
pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
651668
pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
@@ -859,9 +876,6 @@ pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
859876

860877
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
861878

862-
pub const SEEK_DATA: ::c_int = 3;
863-
pub const SEEK_HOLE: ::c_int = 4;
864-
865879
// linux/fs.h
866880

867881
// Flags for preadv2/pwritev2

0 commit comments

Comments
 (0)