Skip to content

Commit d4080d1

Browse files
committedFeb 13, 2021
Auto merge of #1975 - skrap:feature/move-uclibc-under-linux, r=JohnTitor
Move uclibc under linux This is a first cut at moving uclibc under linux, alongside `musl` and `gnu`. All tests pass on a vexpress a9 running in qemu. I am working on testing the other tier 3 uclibc targets: `mips-unknown-linux-uclibc` and `mipsel-unknown-linux-uclibc`. ~Not having access to these platforms, I am working on getting them running in qemu, but it may take a bit.~ The style check doesn't pass. I would appreciate some direction here. Many of these constants are defined under 2-of-3 out of musl/glibc/uclibc, so I'm not sure whether I should transform: ```rust #[cfg(not(target_env = "uclibc"))] pub fn foo(); ``` into 2 separate declarations, one each in `musl/mod.rs` and `gnu/mod.rs` or use a `cfg_if` block for each one (which explodes 2 lines into 5). - [x] Help me choose which fix to use for the items defined in musl and gnu but not uclibc. It's my guess that exploding into the `cfg_if` block is better for long-term maintainability, but I'd really appreciate opinions from the maintainers.
2 parents db71a57 + 3378f0c commit d4080d1

File tree

26 files changed

+905
-3143
lines changed

26 files changed

+905
-3143
lines changed
 

‎libc-test/build.rs

Lines changed: 41 additions & 3 deletions
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| {
@@ -2651,6 +2655,15 @@ fn test_linux(target: &str) {
26512655
| "CAN_RAW_FILTER_MAX"
26522656
| "CAN_NPROTO" => true,
26532657

2658+
"MS_RMT_MASK" if uclibc => true, // updated in glibc 2.22 and musl 1.1.13
2659+
2660+
// These are not defined in uclibc but will be passed through to the kernel
2661+
// so they will be supported if the kernel supports them. Otherwise the
2662+
// kernel will return runtime errors. Since they're required for tokio
2663+
// support, we except them from the tests here.
2664+
// See https://github.com/rust-lang/libc/pull/2019#issuecomment-754351482
2665+
"EPOLLEXCLUSIVE" | "EPOLLWAKEUP" if uclibc => true,
2666+
26542667
// FIXME: Requires recent kernel headers (5.8):
26552668
"STATX_MNT_ID" => true,
26562669

@@ -2698,6 +2711,31 @@ fn test_linux(target: &str) {
26982711
// FIXME: It now takes c_void instead of timezone since glibc 2.31.
26992712
"gettimeofday" if gnu => true,
27002713

2714+
// These are all implemented as static inline functions in uclibc, so
2715+
// they cannot be linked against.
2716+
// If implementations are required, they might need to be implemented
2717+
// in this crate.
2718+
"posix_spawnattr_init" if uclibc => true,
2719+
"posix_spawnattr_destroy" if uclibc => true,
2720+
"posix_spawnattr_getsigdefault" if uclibc => true,
2721+
"posix_spawnattr_setsigdefault" if uclibc => true,
2722+
"posix_spawnattr_getsigmask" if uclibc => true,
2723+
"posix_spawnattr_setsigmask" if uclibc => true,
2724+
"posix_spawnattr_getflags" if uclibc => true,
2725+
"posix_spawnattr_setflags" if uclibc => true,
2726+
"posix_spawnattr_getpgroup" if uclibc => true,
2727+
"posix_spawnattr_setpgroup" if uclibc => true,
2728+
"posix_spawnattr_getschedpolicy" if uclibc => true,
2729+
"posix_spawnattr_setschedpolicy" if uclibc => true,
2730+
"posix_spawnattr_getschedparam" if uclibc => true,
2731+
"posix_spawnattr_setschedparam" if uclibc => true,
2732+
"posix_spawn_file_actions_init" if uclibc => true,
2733+
"posix_spawn_file_actions_destroy" if uclibc => true,
2734+
2735+
// uclibc defines the flags type as a uint, but dependent crates
2736+
// assume it's a int instead.
2737+
"getnameinfo" if uclibc => true,
2738+
27012739
_ => false,
27022740
}
27032741
});

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

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,19 @@ s! {
287287
__re_nsub: ::size_t,
288288
__bitfield: u8,
289289
}
290+
291+
pub struct Elf64_Chdr {
292+
pub ch_type: ::Elf64_Word,
293+
pub ch_reserved: ::Elf64_Word,
294+
pub ch_size: ::Elf64_Xword,
295+
pub ch_addralign: ::Elf64_Xword,
296+
}
297+
298+
pub struct Elf32_Chdr {
299+
pub ch_type: ::Elf32_Word,
300+
pub ch_size: ::Elf32_Word,
301+
pub ch_addralign: ::Elf32_Word,
302+
}
290303
}
291304

292305
impl siginfo_t {
@@ -620,6 +633,22 @@ pub const TCP_FASTOPEN: ::c_int = 23;
620633
pub const TCP_TIMESTAMP: ::c_int = 24;
621634
pub const TCP_FASTOPEN_CONNECT: ::c_int = 30;
622635

636+
pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
637+
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
638+
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
639+
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
640+
641+
pub const AF_IB: ::c_int = 27;
642+
pub const AF_MPLS: ::c_int = 28;
643+
pub const AF_NFC: ::c_int = 39;
644+
pub const AF_VSOCK: ::c_int = 40;
645+
pub const AF_XDP: ::c_int = 44;
646+
pub const PF_IB: ::c_int = AF_IB;
647+
pub const PF_MPLS: ::c_int = AF_MPLS;
648+
pub const PF_NFC: ::c_int = AF_NFC;
649+
pub const PF_VSOCK: ::c_int = AF_VSOCK;
650+
pub const PF_XDP: ::c_int = AF_XDP;
651+
623652
/* DCCP socket options */
624653
pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
625654
pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
@@ -646,6 +675,7 @@ pub const SIGEV_THREAD_ID: ::c_int = 4;
646675
pub const BUFSIZ: ::c_uint = 8192;
647676
pub const TMP_MAX: ::c_uint = 238328;
648677
pub const FOPEN_MAX: ::c_uint = 16;
678+
pub const FILENAME_MAX: ::c_uint = 4096;
649679
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
650680
pub const _SC_EQUIV_CLASS_MAX: ::c_int = 41;
651681
pub const _SC_CHARCLASS_NAME_MAX: ::c_int = 45;
@@ -857,11 +887,6 @@ pub const PTRACE_INTERRUPT: ::c_uint = 0x4207;
857887
pub const PTRACE_LISTEN: ::c_uint = 0x4208;
858888
pub const PTRACE_PEEKSIGINFO: ::c_uint = 0x4209;
859889

860-
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
861-
862-
pub const SEEK_DATA: ::c_int = 3;
863-
pub const SEEK_HOLE: ::c_int = 4;
864-
865890
// linux/fs.h
866891

867892
// Flags for preadv2/pwritev2

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

Lines changed: 181 additions & 175 deletions
Large diffs are not rendered by default.

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

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,19 @@ s! {
236236
pub e_termination: ::c_short,
237237
pub e_exit: ::c_short,
238238
}
239+
240+
pub struct Elf64_Chdr {
241+
pub ch_type: ::Elf64_Word,
242+
pub ch_reserved: ::Elf64_Word,
243+
pub ch_size: ::Elf64_Xword,
244+
pub ch_addralign: ::Elf64_Xword,
245+
}
246+
247+
pub struct Elf32_Chdr {
248+
pub ch_type: ::Elf32_Word,
249+
pub ch_size: ::Elf32_Word,
250+
pub ch_addralign: ::Elf32_Word,
251+
}
239252
}
240253

241254
s_no_extra_traits! {
@@ -484,6 +497,7 @@ pub const EFD_CLOEXEC: ::c_int = 0x80000;
484497
pub const BUFSIZ: ::c_uint = 1024;
485498
pub const TMP_MAX: ::c_uint = 10000;
486499
pub const FOPEN_MAX: ::c_uint = 1000;
500+
pub const FILENAME_MAX: ::c_uint = 4096;
487501
pub const O_PATH: ::c_int = 0o10000000;
488502
pub const O_EXEC: ::c_int = 0o10000000;
489503
pub const O_SEARCH: ::c_int = 0o10000000;
@@ -555,10 +569,21 @@ pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
555569
pub const PTRACE_LISTEN: ::c_int = 0x4208;
556570
pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209;
557571

558-
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
559-
560-
pub const SEEK_DATA: ::c_int = 3;
561-
pub const SEEK_HOLE: ::c_int = 4;
572+
pub const FAN_MARK_INODE: ::c_uint = 0x0000_0000;
573+
pub const FAN_MARK_MOUNT: ::c_uint = 0x0000_0010;
574+
// NOTE: FAN_MARK_FILESYSTEM requires Linux Kernel >= 4.20.0
575+
pub const FAN_MARK_FILESYSTEM: ::c_uint = 0x0000_0100;
576+
577+
pub const AF_IB: ::c_int = 27;
578+
pub const AF_MPLS: ::c_int = 28;
579+
pub const AF_NFC: ::c_int = 39;
580+
pub const AF_VSOCK: ::c_int = 40;
581+
pub const AF_XDP: ::c_int = 44;
582+
pub const PF_IB: ::c_int = AF_IB;
583+
pub const PF_MPLS: ::c_int = AF_MPLS;
584+
pub const PF_NFC: ::c_int = AF_NFC;
585+
pub const PF_VSOCK: ::c_int = AF_VSOCK;
586+
pub const PF_XDP: ::c_int = AF_XDP;
562587

563588
pub const EFD_NONBLOCK: ::c_int = ::O_NONBLOCK;
564589

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
macro_rules! expand_align {
2+
() => {
3+
s! {
4+
#[cfg_attr(any(target_pointer_width = "32",
5+
target_arch = "x86_64",
6+
target_arch = "powerpc64",
7+
target_arch = "mips64",
8+
target_arch = "s390x",
9+
target_arch = "sparc64"),
10+
repr(align(4)))]
11+
#[cfg_attr(not(any(target_pointer_width = "32",
12+
target_arch = "x86_64",
13+
target_arch = "powerpc64",
14+
target_arch = "mips64",
15+
target_arch = "s390x",
16+
target_arch = "sparc64")),
17+
repr(align(8)))]
18+
pub struct pthread_mutexattr_t {
19+
size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T],
20+
}
21+
22+
#[repr(align(4))]
23+
pub struct pthread_condattr_t {
24+
size: [u8; ::__SIZEOF_PTHREAD_CONDATTR_T],
25+
}
26+
}
27+
};
28+
}

‎src/unix/uclibc/arm/mod.rs renamed to ‎src/unix/linux_like/linux/uclibc/arm/mod.rs

Lines changed: 97 additions & 214 deletions
Large diffs are not rendered by default.

‎src/unix/uclibc/mips/mips32/mod.rs renamed to ‎src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ pub type blksize_t = i32;
1212
pub type nlink_t = u32;
1313
pub type fsblkcnt_t = ::c_ulong;
1414
pub type fsfilcnt_t = ::c_ulong;
15-
pub type rlim_t = c_ulong;
15+
pub type rlim_t = ::c_ulong;
16+
pub type __u64 = ::c_ulonglong;
17+
pub type fsblkcnt64_t = u64;
18+
pub type fsfilcnt64_t = u64;
1619

1720
s! {
1821
pub struct stat {
@@ -61,6 +64,22 @@ s! {
6164
st_pad5: [::c_long; 14],
6265
}
6366

67+
pub struct statvfs64 {
68+
pub f_bsize: ::c_ulong,
69+
pub f_frsize: ::c_ulong,
70+
pub f_blocks: ::fsblkcnt64_t,
71+
pub f_bfree: ::fsblkcnt64_t,
72+
pub f_bavail: ::fsblkcnt64_t,
73+
pub f_files: ::fsfilcnt64_t,
74+
pub f_ffree: ::fsfilcnt64_t,
75+
pub f_favail: ::fsfilcnt64_t,
76+
pub f_fsid: ::c_ulong,
77+
pub __f_unused: ::c_int,
78+
pub f_flag: ::c_ulong,
79+
pub f_namemax: ::c_ulong,
80+
pub __f_spare: [::c_int; 6],
81+
}
82+
6483
pub struct pthread_attr_t {
6584
__size: [u32; 9]
6685
}
@@ -169,6 +188,21 @@ s! {
169188
f_spare: [::c_long; 6],
170189
}
171190

191+
pub struct statfs64 {
192+
pub f_type: ::c_long,
193+
pub f_bsize: ::c_long,
194+
pub f_frsize: ::c_long,
195+
pub f_blocks: ::fsblkcnt64_t,
196+
pub f_bfree: ::fsblkcnt64_t,
197+
pub f_files: ::fsblkcnt64_t,
198+
pub f_ffree: ::fsblkcnt64_t,
199+
pub f_bavail: ::fsblkcnt64_t,
200+
pub f_fsid: ::fsid_t,
201+
pub f_namelen: ::c_long,
202+
pub f_flags: ::c_long,
203+
pub f_spare: [::c_long; 5],
204+
}
205+
172206
pub struct msghdr {
173207
pub msg_name: *mut ::c_void,
174208
pub msg_namelen: ::socklen_t,
@@ -222,10 +256,14 @@ s! {
222256
}
223257
}
224258

225-
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
259+
pub const __SIZEOF_PTHREAD_ATTR_T: usize = 36;
226260
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
227-
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
228261
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
262+
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
263+
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
264+
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
265+
pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20;
266+
pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
229267

230268
pub const RLIM_INFINITY: ::rlim_t = 0x7fffffff;
231269

@@ -599,7 +637,6 @@ extern "C" {
599637
newlen: ::size_t,
600638
) -> ::c_int;
601639
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
602-
pub fn backtrace(buf: *mut *mut ::c_void, sz: ::c_int) -> ::c_int;
603640
pub fn glob64(
604641
pattern: *const ::c_char,
605642
flags: ::c_int,
@@ -609,7 +646,6 @@ extern "C" {
609646
pglob: *mut glob64_t,
610647
) -> ::c_int;
611648
pub fn globfree64(pglob: *mut glob64_t);
612-
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
613649
pub fn pthread_attr_getaffinity_np(
614650
attr: *const ::pthread_attr_t,
615651
cpusetsize: ::size_t,

‎src/unix/uclibc/mips/mod.rs renamed to ‎src/unix/linux_like/linux/uclibc/mips/mod.rs

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,19 @@ pub const SA_RESETHAND: ::c_int = 0x80000000;
2828
pub const SA_RESTART: ::c_int = 0x10000000;
2929
pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
3030

31-
pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000; // from linux/mod.rs
32-
pub const EPOLLWAKEUP: ::c_int = 0x20000000; // from linux/other/mod.rs
3331
pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
3432

3533
pub const EFD_CLOEXEC: ::c_int = 0x80000;
3634

3735
pub const BUFSIZ: ::c_uint = 4096;
3836
pub const TMP_MAX: ::c_uint = 238328;
3937
pub const FOPEN_MAX: ::c_uint = 16;
40-
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
41-
pub const POSIX_FADV_NOREUSE: ::c_int = 5;
4238
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
4339
pub const _SC_2_C_VERSION: ::c_int = 96;
4440
pub const O_ACCMODE: ::c_int = 3;
4541
pub const O_DIRECT: ::c_int = 0x8000;
4642
pub const O_DIRECTORY: ::c_int = 0x10000;
4743
pub const O_NOFOLLOW: ::c_int = 0x20000;
48-
pub const ST_RELATIME: ::c_ulong = 4096;
4944
pub const NI_MAXHOST: ::socklen_t = 1025;
5045

5146
pub const RLIMIT_NOFILE: ::c_int = 5;
@@ -115,7 +110,6 @@ pub const ENOPROTOOPT: ::c_int = 99;
115110
pub const EPROTONOSUPPORT: ::c_int = 120;
116111
pub const ESOCKTNOSUPPORT: ::c_int = 121;
117112
pub const EOPNOTSUPP: ::c_int = 122;
118-
pub const ENOTSUP: ::c_int = EOPNOTSUPP;
119113
pub const EPFNOSUPPORT: ::c_int = 123;
120114
pub const EAFNOSUPPORT: ::c_int = 124;
121115
pub const EADDRINUSE: ::c_int = 125;
@@ -204,16 +198,13 @@ pub const SO_DETACH_FILTER: ::c_int = 27;
204198
pub const SO_GET_FILTER: ::c_int = SO_ATTACH_FILTER;
205199
pub const SO_PEERNAME: ::c_int = 28;
206200
pub const SO_TIMESTAMP: ::c_int = 29;
207-
pub const SCM_TIMESTAMP: ::c_int = SO_TIMESTAMP;
208201
pub const SO_PEERSEC: ::c_int = 30;
209202
pub const SO_SNDBUFFORCE: ::c_int = 31;
210203
pub const SO_RCVBUFFORCE: ::c_int = 33;
211204
pub const SO_PASSSEC: ::c_int = 34;
212205
pub const SO_TIMESTAMPNS: ::c_int = 35;
213206
pub const SCM_TIMESTAMPNS: ::c_int = SO_TIMESTAMPNS;
214207
pub const SO_MARK: ::c_int = 36;
215-
pub const SO_TIMESTAMPING: ::c_int = 37;
216-
pub const SCM_TIMESTAMPING: ::c_int = SO_TIMESTAMPING;
217208
pub const SO_RXQ_OVFL: ::c_int = 40;
218209
pub const SO_WIFI_STATUS: ::c_int = 41;
219210
pub const SCM_WIFI_STATUS: ::c_int = SO_WIFI_STATUS;
@@ -256,78 +247,24 @@ pub const SIG_SETMASK: ::c_int = 3;
256247
pub const SIG_BLOCK: ::c_int = 0x1;
257248
pub const SIG_UNBLOCK: ::c_int = 0x2;
258249

259-
pub const POLLRDNORM: ::c_short = 0x040;
260250
pub const POLLWRNORM: ::c_short = 0x004;
261-
pub const POLLRDBAND: ::c_short = 0x080;
262251
pub const POLLWRBAND: ::c_short = 0x100;
263252

264253
pub const PTHREAD_STACK_MIN: ::size_t = 16384;
265254

266-
pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
267-
pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
268-
pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
269-
pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
270-
pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
271-
pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
272-
pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
273-
pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
274-
pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
275-
pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
276-
pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
277-
pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
278-
pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
279-
pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
280-
pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
281-
pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
282-
pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
283-
pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
284-
pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
285-
pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
286-
pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
287-
pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
288-
pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
289-
pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
290-
pub const TMPFS_MAGIC: ::c_long = 0x01021994;
291-
pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
292-
293255
pub const VEOF: usize = 16;
294256
pub const VEOL: usize = 17;
295257
pub const VEOL2: usize = 6;
296258
pub const VMIN: usize = 4;
297259
pub const IEXTEN: ::tcflag_t = 0x00000100;
298260
pub const TOSTOP: ::tcflag_t = 0x00008000;
299261
pub const FLUSHO: ::tcflag_t = 0x00002000;
300-
pub const IUTF8: ::tcflag_t = 0x00004000;
301262
pub const TCSANOW: ::c_int = 0x540e;
302263
pub const TCSADRAIN: ::c_int = 0x540f;
303264
pub const TCSAFLUSH: ::c_int = 0x5410;
304265

305266
pub const CPU_SETSIZE: ::c_int = 0x400;
306267

307-
pub const PTRACE_TRACEME: ::c_uint = 0;
308-
pub const PTRACE_PEEKTEXT: ::c_uint = 1;
309-
pub const PTRACE_PEEKDATA: ::c_uint = 2;
310-
pub const PTRACE_PEEKUSER: ::c_uint = 3;
311-
pub const PTRACE_POKETEXT: ::c_uint = 4;
312-
pub const PTRACE_POKEDATA: ::c_uint = 5;
313-
pub const PTRACE_POKEUSER: ::c_uint = 6;
314-
pub const PTRACE_CONT: ::c_uint = 7;
315-
pub const PTRACE_KILL: ::c_uint = 8;
316-
pub const PTRACE_SINGLESTEP: ::c_uint = 9;
317-
pub const PTRACE_ATTACH: ::c_uint = 16;
318-
pub const PTRACE_DETACH: ::c_uint = 17;
319-
pub const PTRACE_SYSCALL: ::c_uint = 24;
320-
pub const PTRACE_SETOPTIONS: ::c_uint = 0x4200;
321-
pub const PTRACE_GETEVENTMSG: ::c_uint = 0x4201;
322-
pub const PTRACE_GETSIGINFO: ::c_uint = 0x4202;
323-
pub const PTRACE_SETSIGINFO: ::c_uint = 0x4203;
324-
pub const PTRACE_GETFPREGS: ::c_uint = 14;
325-
pub const PTRACE_SETFPREGS: ::c_uint = 15;
326-
pub const PTRACE_GETFPXREGS: ::c_uint = 18;
327-
pub const PTRACE_SETFPXREGS: ::c_uint = 19;
328-
pub const PTRACE_GETREGS: ::c_uint = 12;
329-
pub const PTRACE_SETREGS: ::c_uint = 13;
330-
331268
pub const EFD_NONBLOCK: ::c_int = 0x80;
332269

333270
pub const F_GETLK: ::c_int = 14;
@@ -370,28 +307,9 @@ pub const TIOCMSET: ::c_ulong = 0x741a;
370307
pub const FIONREAD: ::c_ulong = 0x467f;
371308
pub const TIOCCONS: ::c_ulong = 0x80047478;
372309

373-
pub const RTLD_DEEPBIND: ::c_int = 0x10;
374310
pub const RTLD_GLOBAL: ::c_int = 0x4;
375311
pub const RTLD_NOLOAD: ::c_int = 0x8;
376312

377-
pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
378-
pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
379-
pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
380-
pub const LINUX_REBOOT_MAGIC2B: ::c_int = 369367448;
381-
pub const LINUX_REBOOT_MAGIC2C: ::c_int = 537993216;
382-
383-
pub const LINUX_REBOOT_CMD_RESTART: ::c_int = 0x01234567;
384-
pub const LINUX_REBOOT_CMD_HALT: ::c_int = 0xCDEF0123;
385-
pub const LINUX_REBOOT_CMD_CAD_ON: ::c_int = 0x89ABCDEF;
386-
pub const LINUX_REBOOT_CMD_CAD_OFF: ::c_int = 0x00000000;
387-
pub const LINUX_REBOOT_CMD_POWER_OFF: ::c_int = 0x4321FEDC;
388-
pub const LINUX_REBOOT_CMD_RESTART2: ::c_int = 0xA1B2C3D4;
389-
pub const LINUX_REBOOT_CMD_SW_SUSPEND: ::c_int = 0xD000FCE2;
390-
pub const LINUX_REBOOT_CMD_KEXEC: ::c_int = 0x45584543;
391-
392-
pub const MCL_CURRENT: ::c_int = 0x0001;
393-
pub const MCL_FUTURE: ::c_int = 0x0002;
394-
395313
pub const SIGSTKSZ: ::size_t = 8192;
396314
pub const CBAUD: ::tcflag_t = 0o0010017;
397315
pub const TAB1: ::tcflag_t = 0x00000800;
Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
1+
pub type shmatt_t = ::c_ulong;
2+
pub type msgqnum_t = ::c_ulong;
3+
pub type msglen_t = ::c_ulong;
4+
pub type regoff_t = ::c_int;
5+
6+
s! {
7+
pub struct statvfs { // Different than GNU!
8+
pub f_bsize: ::c_ulong,
9+
pub f_frsize: ::c_ulong,
10+
pub f_blocks: ::fsblkcnt_t,
11+
pub f_bfree: ::fsblkcnt_t,
12+
pub f_bavail: ::fsblkcnt_t,
13+
pub f_files: ::fsfilcnt_t,
14+
pub f_ffree: ::fsfilcnt_t,
15+
pub f_favail: ::fsfilcnt_t,
16+
#[cfg(target_endian = "little")]
17+
pub f_fsid: ::c_ulong,
18+
#[cfg(target_pointer_width = "32")]
19+
__f_unused: ::c_int,
20+
#[cfg(target_endian = "big")]
21+
pub f_fsid: ::c_ulong,
22+
pub f_flag: ::c_ulong,
23+
pub f_namemax: ::c_ulong,
24+
__f_spare: [::c_int; 6],
25+
}
26+
27+
pub struct regex_t {
28+
__buffer: *mut ::c_void,
29+
__allocated: ::size_t,
30+
__used: ::size_t,
31+
__syntax: ::c_ulong,
32+
__fastmap: *mut ::c_char,
33+
__translate: *mut ::c_char,
34+
__re_nsub: ::size_t,
35+
__bitfield: u8,
36+
}
37+
}
38+
39+
pub const MCL_CURRENT: ::c_int = 0x0001;
40+
pub const MCL_FUTURE: ::c_int = 0x0002;
41+
42+
pub const SIGEV_THREAD_ID: ::c_int = 4;
43+
44+
pub const ADFS_SUPER_MAGIC: ::c_long = 0x0000adf5;
45+
pub const AFFS_SUPER_MAGIC: ::c_long = 0x0000adff;
46+
pub const AFS_SUPER_MAGIC: ::c_long = 0x5346414f;
47+
pub const AUTOFS_SUPER_MAGIC: ::c_long = 0x0187;
48+
pub const BINDERFS_SUPER_MAGIC: ::c_long = 0x6c6f6f70;
49+
pub const BPF_FS_MAGIC: ::c_long = 0xcafe4a11;
50+
pub const BTRFS_SUPER_MAGIC: ::c_long = 0x9123683e;
51+
pub const CGROUP2_SUPER_MAGIC: ::c_long = 0x63677270;
52+
pub const CGROUP_SUPER_MAGIC: ::c_long = 0x27e0eb;
53+
pub const CODA_SUPER_MAGIC: ::c_long = 0x73757245;
54+
pub const CRAMFS_MAGIC: ::c_long = 0x28cd3d45;
55+
pub const DEBUGFS_MAGIC: ::c_long = 0x64626720;
56+
pub const DEVPTS_SUPER_MAGIC: ::c_long = 0x1cd1;
57+
pub const ECRYPTFS_SUPER_MAGIC: ::c_long = 0xf15f;
58+
pub const EFS_SUPER_MAGIC: ::c_long = 0x00414a53;
59+
pub const EXT2_SUPER_MAGIC: ::c_long = 0x0000ef53;
60+
pub const EXT3_SUPER_MAGIC: ::c_long = 0x0000ef53;
61+
pub const EXT4_SUPER_MAGIC: ::c_long = 0x0000ef53;
62+
pub const F2FS_SUPER_MAGIC: ::c_long = 0xf2f52010;
63+
pub const FUTEXFS_SUPER_MAGIC: ::c_long = 0xbad1dea;
64+
pub const HOSTFS_SUPER_MAGIC: ::c_long = 0x00c0ffee;
65+
pub const HPFS_SUPER_MAGIC: ::c_long = 0xf995e849;
66+
pub const HUGETLBFS_MAGIC: ::c_long = 0x958458f6;
67+
pub const ISOFS_SUPER_MAGIC: ::c_long = 0x00009660;
68+
pub const JFFS2_SUPER_MAGIC: ::c_long = 0x000072b6;
69+
pub const MINIX2_SUPER_MAGIC2: ::c_long = 0x00002478;
70+
pub const MINIX2_SUPER_MAGIC: ::c_long = 0x00002468;
71+
pub const MINIX3_SUPER_MAGIC: ::c_long = 0x4d5a;
72+
pub const MINIX_SUPER_MAGIC2: ::c_long = 0x0000138f;
73+
pub const MINIX_SUPER_MAGIC: ::c_long = 0x0000137f;
74+
pub const MSDOS_SUPER_MAGIC: ::c_long = 0x00004d44;
75+
pub const NCP_SUPER_MAGIC: ::c_long = 0x0000564c;
76+
pub const NFS_SUPER_MAGIC: ::c_long = 0x00006969;
77+
pub const NILFS_SUPER_MAGIC: ::c_long = 0x3434;
78+
pub const OCFS2_SUPER_MAGIC: ::c_long = 0x7461636f;
79+
pub const OPENPROM_SUPER_MAGIC: ::c_long = 0x00009fa1;
80+
pub const OVERLAYFS_SUPER_MAGIC: ::c_long = 0x794c7630;
81+
pub const PROC_SUPER_MAGIC: ::c_long = 0x00009fa0;
82+
pub const QNX4_SUPER_MAGIC: ::c_long = 0x0000002f;
83+
pub const QNX6_SUPER_MAGIC: ::c_long = 0x68191122;
84+
pub const RDTGROUP_SUPER_MAGIC: ::c_long = 0x7655821;
85+
pub const REISERFS_SUPER_MAGIC: ::c_long = 0x52654973;
86+
pub const SMB_SUPER_MAGIC: ::c_long = 0x0000517b;
87+
pub const SYSFS_MAGIC: ::c_long = 0x62656572;
88+
pub const TMPFS_MAGIC: ::c_long = 0x01021994;
89+
pub const TRACEFS_MAGIC: ::c_long = 0x74726163;
90+
pub const UDF_SUPER_MAGIC: ::c_long = 0x15013346;
91+
pub const USBDEVICE_SUPER_MAGIC: ::c_long = 0x00009fa2;
92+
pub const XENFS_SUPER_MAGIC: ::c_long = 0xabba1974;
93+
pub const XFS_SUPER_MAGIC: ::c_long = 0x58465342;
94+
95+
pub const PTRACE_TRACEME: ::c_int = 0;
96+
pub const PTRACE_PEEKTEXT: ::c_int = 1;
97+
pub const PTRACE_PEEKDATA: ::c_int = 2;
98+
pub const PTRACE_PEEKUSER: ::c_int = 3;
99+
pub const PTRACE_POKETEXT: ::c_int = 4;
100+
pub const PTRACE_POKEDATA: ::c_int = 5;
101+
pub const PTRACE_POKEUSER: ::c_int = 6;
102+
pub const PTRACE_CONT: ::c_int = 7;
103+
pub const PTRACE_KILL: ::c_int = 8;
104+
pub const PTRACE_SINGLESTEP: ::c_int = 9;
105+
pub const PTRACE_GETREGS: ::c_int = 12;
106+
pub const PTRACE_SETREGS: ::c_int = 13;
107+
pub const PTRACE_GETFPREGS: ::c_int = 14;
108+
pub const PTRACE_SETFPREGS: ::c_int = 15;
109+
pub const PTRACE_ATTACH: ::c_int = 16;
110+
pub const PTRACE_DETACH: ::c_int = 17;
111+
pub const PTRACE_GETFPXREGS: ::c_int = 18;
112+
pub const PTRACE_SETFPXREGS: ::c_int = 19;
113+
pub const PTRACE_SYSCALL: ::c_int = 24;
114+
pub const PTRACE_SETOPTIONS: ::c_int = 0x4200;
115+
pub const PTRACE_GETEVENTMSG: ::c_int = 0x4201;
116+
pub const PTRACE_GETSIGINFO: ::c_int = 0x4202;
117+
pub const PTRACE_SETSIGINFO: ::c_int = 0x4203;
118+
pub const PTRACE_GETREGSET: ::c_int = 0x4204;
119+
pub const PTRACE_SETREGSET: ::c_int = 0x4205;
120+
pub const PTRACE_SEIZE: ::c_int = 0x4206;
121+
pub const PTRACE_INTERRUPT: ::c_int = 0x4207;
122+
pub const PTRACE_LISTEN: ::c_int = 0x4208;
123+
pub const PTRACE_O_MASK: ::c_int = 0x000000ff;
124+
125+
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
126+
pub const POSIX_FADV_NOREUSE: ::c_int = 5;
127+
128+
pub const RLIMIT_CPU: ::c_int = 0;
129+
pub const RLIMIT_FSIZE: ::c_int = 1;
130+
pub const RLIMIT_DATA: ::c_int = 2;
131+
pub const RLIMIT_STACK: ::c_int = 3;
132+
pub const RLIMIT_CORE: ::c_int = 4;
133+
pub const RLIMIT_LOCKS: ::c_int = 10;
134+
pub const RLIMIT_SIGPENDING: ::c_int = 11;
135+
pub const RLIMIT_MSGQUEUE: ::c_int = 12;
136+
pub const RLIMIT_NICE: ::c_int = 13;
137+
pub const RLIMIT_RTPRIO: ::c_int = 14;
138+
139+
// These are different than GNU!
140+
pub const LC_CTYPE: ::c_int = 0;
141+
pub const LC_NUMERIC: ::c_int = 1;
142+
pub const LC_TIME: ::c_int = 3;
143+
pub const LC_COLLATE: ::c_int = 4;
144+
pub const LC_MONETARY: ::c_int = 2;
145+
pub const LC_MESSAGES: ::c_int = 5;
146+
pub const LC_ALL: ::c_int = 6;
147+
// end different section
148+
149+
// MS_ flags for mount(2)
150+
pub const MS_RMT_MASK: ::c_ulong =
151+
::MS_RDONLY | ::MS_SYNCHRONOUS | ::MS_MANDLOCK | ::MS_I_VERSION;
152+
153+
pub const ENOTSUP: ::c_int = EOPNOTSUPP;
154+
155+
pub const IPV6_JOIN_GROUP: ::c_int = 20;
156+
pub const IPV6_LEAVE_GROUP: ::c_int = 21;
157+
158+
// These are different from GNU
159+
pub const ABDAY_1: ::nl_item = 0x300;
160+
pub const ABDAY_2: ::nl_item = 0x301;
161+
pub const ABDAY_3: ::nl_item = 0x302;
162+
pub const ABDAY_4: ::nl_item = 0x303;
163+
pub const ABDAY_5: ::nl_item = 0x304;
164+
pub const ABDAY_6: ::nl_item = 0x305;
165+
pub const ABDAY_7: ::nl_item = 0x306;
166+
pub const DAY_1: ::nl_item = 0x307;
167+
pub const DAY_2: ::nl_item = 0x308;
168+
pub const DAY_3: ::nl_item = 0x309;
169+
pub const DAY_4: ::nl_item = 0x30A;
170+
pub const DAY_5: ::nl_item = 0x30B;
171+
pub const DAY_6: ::nl_item = 0x30C;
172+
pub const DAY_7: ::nl_item = 0x30D;
173+
pub const ABMON_1: ::nl_item = 0x30E;
174+
pub const ABMON_2: ::nl_item = 0x30F;
175+
pub const ABMON_3: ::nl_item = 0x310;
176+
pub const ABMON_4: ::nl_item = 0x311;
177+
pub const ABMON_5: ::nl_item = 0x312;
178+
pub const ABMON_6: ::nl_item = 0x313;
179+
pub const ABMON_7: ::nl_item = 0x314;
180+
pub const ABMON_8: ::nl_item = 0x315;
181+
pub const ABMON_9: ::nl_item = 0x316;
182+
pub const ABMON_10: ::nl_item = 0x317;
183+
pub const ABMON_11: ::nl_item = 0x318;
184+
pub const ABMON_12: ::nl_item = 0x319;
185+
pub const MON_1: ::nl_item = 0x31A;
186+
pub const MON_2: ::nl_item = 0x31B;
187+
pub const MON_3: ::nl_item = 0x31C;
188+
pub const MON_4: ::nl_item = 0x31D;
189+
pub const MON_5: ::nl_item = 0x31E;
190+
pub const MON_6: ::nl_item = 0x31F;
191+
pub const MON_7: ::nl_item = 0x320;
192+
pub const MON_8: ::nl_item = 0x321;
193+
pub const MON_9: ::nl_item = 0x322;
194+
pub const MON_10: ::nl_item = 0x323;
195+
pub const MON_11: ::nl_item = 0x324;
196+
pub const MON_12: ::nl_item = 0x325;
197+
pub const AM_STR: ::nl_item = 0x326;
198+
pub const PM_STR: ::nl_item = 0x327;
199+
pub const D_T_FMT: ::nl_item = 0x328;
200+
pub const D_FMT: ::nl_item = 0x329;
201+
pub const T_FMT: ::nl_item = 0x32A;
202+
pub const T_FMT_AMPM: ::nl_item = 0x32B;
203+
pub const ERA: ::nl_item = 0x32C;
204+
pub const ERA_D_FMT: ::nl_item = 0x32E;
205+
pub const ALT_DIGITS: ::nl_item = 0x32F;
206+
pub const ERA_D_T_FMT: ::nl_item = 0x330;
207+
pub const ERA_T_FMT: ::nl_item = 0x331;
208+
pub const CODESET: ::nl_item = 10;
209+
pub const CRNCYSTR: ::nl_item = 0x215;
210+
pub const RADIXCHAR: ::nl_item = 0x100;
211+
pub const THOUSEP: ::nl_item = 0x101;
212+
pub const NOEXPR: ::nl_item = 0x501;
213+
pub const YESSTR: ::nl_item = 0x502;
214+
pub const NOSTR: ::nl_item = 0x503;
215+
216+
// Different than Gnu.
217+
pub const FILENAME_MAX: ::c_uint = 4095;
218+
219+
pub const PRIO_PROCESS: ::c_int = 0;
220+
pub const PRIO_PGRP: ::c_int = 1;
221+
pub const PRIO_USER: ::c_int = 2;
222+
223+
pub const ST_RELATIME: ::c_ulong = 4096;
224+
225+
extern "C" {
226+
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
227+
228+
pub fn pthread_rwlockattr_getkind_np(
229+
attr: *const ::pthread_rwlockattr_t,
230+
val: *mut ::c_int,
231+
) -> ::c_int;
232+
pub fn pthread_rwlockattr_setkind_np(
233+
attr: *mut ::pthread_rwlockattr_t,
234+
val: ::c_int,
235+
) -> ::c_int;
236+
237+
pub fn ptrace(request: ::c_uint, ...) -> ::c_long;
238+
239+
pub fn sendmmsg(
240+
sockfd: ::c_int,
241+
msgvec: *mut ::mmsghdr,
242+
vlen: ::c_uint,
243+
flags: ::c_int,
244+
) -> ::c_int;
245+
pub fn recvmmsg(
246+
sockfd: ::c_int,
247+
msgvec: *mut ::mmsghdr,
248+
vlen: ::c_uint,
249+
flags: ::c_int,
250+
timeout: *mut ::timespec,
251+
) -> ::c_int;
252+
253+
pub fn openpty(
254+
amaster: *mut ::c_int,
255+
aslave: *mut ::c_int,
256+
name: *mut ::c_char,
257+
termp: *mut termios,
258+
winp: *mut ::winsize,
259+
) -> ::c_int;
260+
pub fn forkpty(
261+
amaster: *mut ::c_int,
262+
name: *mut ::c_char,
263+
termp: *mut termios,
264+
winp: *mut ::winsize,
265+
) -> ::pid_t;
266+
267+
pub fn getnameinfo(
268+
sa: *const ::sockaddr,
269+
salen: ::socklen_t,
270+
host: *mut ::c_char,
271+
hostlen: ::socklen_t,
272+
serv: *mut ::c_char,
273+
sevlen: ::socklen_t,
274+
flags: ::c_int,
275+
) -> ::c_int;
276+
277+
pub fn pwritev(
278+
fd: ::c_int,
279+
iov: *const ::iovec,
280+
iovcnt: ::c_int,
281+
offset: ::off64_t,
282+
) -> ::ssize_t;
283+
pub fn preadv(
284+
fd: ::c_int,
285+
iov: *const ::iovec,
286+
iovcnt: ::c_int,
287+
offset: ::off64_t,
288+
) -> ::ssize_t;
289+
}
290+
291+
cfg_if! {
292+
if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] {
293+
mod mips;
294+
pub use self::mips::*;
295+
} else if #[cfg(target_arch = "x86_64")] {
296+
mod x86_64;
297+
pub use self::x86_64::*;
298+
} else if #[cfg(target_arch = "arm")] {
299+
mod arm;
300+
pub use self::arm::*;
301+
} else {
302+
pub use unsupported_target;
303+
}
304+
}

‎src/unix/uclibc/x86_64/mod.rs renamed to ‎src/unix/linux_like/linux/uclibc/x86_64/mod.rs

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@ pub type ino_t = ::c_ulong;
1212
pub type nlink_t = ::c_uint;
1313
pub type off_t = ::c_long;
1414
pub type rlim_t = c_ulong;
15-
pub type rlim64_t = u64;
1615
// [uClibc docs] Note stat64 has the same shape as stat for x86-64.
1716
pub type stat64 = stat;
1817
pub type suseconds_t = ::c_long;
1918
pub type time_t = ::c_int;
2019
pub type wchar_t = ::c_int;
2120

21+
pub type fsblkcnt64_t = u64;
22+
pub type fsfilcnt64_t = u64;
23+
pub type __u64 = ::c_ulong;
24+
2225
s! {
2326
pub struct ipc_perm {
2427
pub __key: ::key_t,
@@ -143,7 +146,7 @@ s! {
143146
pub struct sigaction {
144147
pub sa_handler: ::sighandler_t,
145148
pub sa_flags: ::c_ulong,
146-
pub sa_restorer: *mut ::c_void,
149+
pub sa_restorer: ::Option<extern fn()>,
147150
pub sa_mask: ::sigset_t,
148151
}
149152

@@ -167,6 +170,37 @@ s! {
167170
f_spare: [fsword_t; 5],
168171
}
169172

173+
pub struct statfs64 {
174+
pub f_type: ::c_int,
175+
pub f_bsize: ::c_int,
176+
pub f_blocks: ::fsblkcnt64_t,
177+
pub f_bfree: ::fsblkcnt64_t,
178+
pub f_bavail: ::fsblkcnt64_t,
179+
pub f_files: ::fsfilcnt64_t,
180+
pub f_ffree: ::fsfilcnt64_t,
181+
pub f_fsid: ::fsid_t,
182+
pub f_namelen: ::c_int,
183+
pub f_frsize: ::c_int,
184+
pub f_flags: ::c_int,
185+
pub f_spare: [::c_int; 4],
186+
}
187+
188+
pub struct statvfs64 {
189+
pub f_bsize: ::c_ulong,
190+
pub f_frsize: ::c_ulong,
191+
pub f_blocks: u64,
192+
pub f_bfree: u64,
193+
pub f_bavail: u64,
194+
pub f_files: u64,
195+
pub f_ffree: u64,
196+
pub f_favail: u64,
197+
pub f_fsid: ::c_ulong,
198+
__f_unused: ::c_int,
199+
pub f_flag: ::c_ulong,
200+
pub f_namemax: ::c_ulong,
201+
__f_spare: [::c_int; 6],
202+
}
203+
170204
pub struct msghdr { // FIXME
171205
pub msg_name: *mut ::c_void,
172206
pub msg_namelen: ::socklen_t,
@@ -219,11 +253,6 @@ s! {
219253
__unused5: *mut ::c_void,
220254
}
221255

222-
pub struct rlimit64 { // FIXME
223-
pub rlim_cur: rlim64_t,
224-
pub rlim_max: rlim64_t,
225-
}
226-
227256
pub struct cpu_set_t { // FIXME
228257
#[cfg(target_pointer_width = "32")]
229258
bits: [u32; 32],
@@ -234,6 +263,21 @@ s! {
234263
pub struct fsid_t { // FIXME
235264
__val: [::c_int; 2],
236265
}
266+
267+
// FIXME this is actually a union
268+
pub struct sem_t {
269+
#[cfg(target_pointer_width = "32")]
270+
__size: [::c_char; 16],
271+
#[cfg(target_pointer_width = "64")]
272+
__size: [::c_char; 32],
273+
__align: [::c_long; 0],
274+
}
275+
276+
pub struct cmsghdr {
277+
pub cmsg_len: ::size_t,
278+
pub cmsg_level: ::c_int,
279+
pub cmsg_type: ::c_int,
280+
}
237281
}
238282

239283
s_no_extra_traits! {
@@ -245,14 +289,6 @@ s_no_extra_traits! {
245289
pub d_type: u8,
246290
pub d_name: [::c_char; 256],
247291
}
248-
#[allow(missing_debug_implementations)]
249-
pub struct dirent64 {
250-
pub d_ino: ::ino64_t,
251-
pub d_off: ::off64_t,
252-
pub d_reclen: u16,
253-
pub d_type: u8,
254-
pub d_name: [::c_char; 256],
255-
}
256292
}
257293

258294
// constants
@@ -265,6 +301,8 @@ pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur
265301
pub const ENOSYS: ::c_int = 38; // Function not implemented
266302
pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected
267303
pub const ETIMEDOUT: ::c_int = 110; // connection timed out
304+
pub const EOPNOTSUPP: ::c_int = 0x5f;
305+
pub const ENODATA: ::c_int = 0x3d;
268306
pub const O_APPEND: ::c_int = 02000;
269307
pub const O_ACCMODE: ::c_int = 0003;
270308
pub const O_CLOEXEC: ::c_int = 0x80000;
@@ -285,10 +323,12 @@ pub const SOL_SOCKET: ::c_int = 1;
285323
pub const SO_RCVTIMEO: ::c_int = 20;
286324
pub const SO_REUSEADDR: ::c_int = 2;
287325
pub const SO_SNDTIMEO: ::c_int = 21;
326+
pub const SO_TIMESTAMP: ::c_int = 0x1d;
288327
pub const RLIM_INFINITY: u64 = 0xffffffffffffffff;
289328
pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
290329
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
291330
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
331+
pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
292332

293333
cfg_if! {
294334
if #[cfg(target_os = "l4re")] {
@@ -299,14 +339,3 @@ cfg_if! {
299339
pub use other::*;
300340
}
301341
}
302-
303-
cfg_if! {
304-
if #[cfg(libc_align)] {
305-
#[macro_use]
306-
mod align;
307-
} else {
308-
#[macro_use]
309-
mod no_align;
310-
}
311-
}
312-
expand_align!();

‎src/unix/linux_like/mod.rs

Lines changed: 73 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -546,13 +546,18 @@ pub const PROT_READ: ::c_int = 1;
546546
pub const PROT_WRITE: ::c_int = 2;
547547
pub const PROT_EXEC: ::c_int = 4;
548548

549-
pub const LC_CTYPE: ::c_int = 0;
550-
pub const LC_NUMERIC: ::c_int = 1;
551-
pub const LC_TIME: ::c_int = 2;
552-
pub const LC_COLLATE: ::c_int = 3;
553-
pub const LC_MONETARY: ::c_int = 4;
554-
pub const LC_MESSAGES: ::c_int = 5;
555-
pub const LC_ALL: ::c_int = 6;
549+
cfg_if! {
550+
if #[cfg(not(target_env = "uclibc"))] {
551+
pub const LC_CTYPE: ::c_int = 0;
552+
pub const LC_NUMERIC: ::c_int = 1;
553+
pub const LC_TIME: ::c_int = 2;
554+
pub const LC_COLLATE: ::c_int = 3;
555+
pub const LC_MONETARY: ::c_int = 4;
556+
pub const LC_MESSAGES: ::c_int = 5;
557+
pub const LC_ALL: ::c_int = 6;
558+
}
559+
}
560+
556561
pub const LC_CTYPE_MASK: ::c_int = 1 << LC_CTYPE;
557562
pub const LC_NUMERIC_MASK: ::c_int = 1 << LC_NUMERIC;
558563
pub const LC_TIME_MASK: ::c_int = 1 << LC_TIME;
@@ -855,7 +860,6 @@ pub const IPPROTO_NONE: ::c_int = 59;
855860
/// IP6 destination option
856861
pub const IPPROTO_DSTOPTS: ::c_int = 60;
857862
pub const IPPROTO_MTP: ::c_int = 92;
858-
pub const IPPROTO_BEETPH: ::c_int = 94;
859863
/// encapsulation header
860864
pub const IPPROTO_ENCAP: ::c_int = 98;
861865
/// Protocol indep. multicast
@@ -866,7 +870,6 @@ pub const IPPROTO_COMP: ::c_int = 108;
866870
pub const IPPROTO_SCTP: ::c_int = 132;
867871
pub const IPPROTO_MH: ::c_int = 135;
868872
pub const IPPROTO_UDPLITE: ::c_int = 136;
869-
pub const IPPROTO_MPLS: ::c_int = 137;
870873
/// raw IP packet
871874
pub const IPPROTO_RAW: ::c_int = 255;
872875

@@ -905,7 +908,6 @@ pub const IPV6_JOIN_ANYCAST: ::c_int = 27;
905908
pub const IPV6_LEAVE_ANYCAST: ::c_int = 28;
906909
pub const IPV6_IPSEC_POLICY: ::c_int = 34;
907910
pub const IPV6_XFRM_POLICY: ::c_int = 35;
908-
pub const IPV6_HDRINCL: ::c_int = 36;
909911
pub const IPV6_RECVPKTINFO: ::c_int = 49;
910912
pub const IPV6_PKTINFO: ::c_int = 50;
911913
pub const IPV6_RECVHOPLIMIT: ::c_int = 51;
@@ -941,8 +943,6 @@ pub const IPV6_PMTUDISC_DONT: ::c_int = 0;
941943
pub const IPV6_PMTUDISC_WANT: ::c_int = 1;
942944
pub const IPV6_PMTUDISC_DO: ::c_int = 2;
943945
pub const IPV6_PMTUDISC_PROBE: ::c_int = 3;
944-
pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4;
945-
pub const IPV6_PMTUDISC_OMIT: ::c_int = 5;
946946

947947
pub const TCP_NODELAY: ::c_int = 1;
948948
pub const TCP_MAXSEG: ::c_int = 2;
@@ -1081,7 +1081,6 @@ pub const CLONE_NEWUSER: ::c_int = 0x10000000;
10811081
pub const CLONE_NEWPID: ::c_int = 0x20000000;
10821082
pub const CLONE_NEWNET: ::c_int = 0x40000000;
10831083
pub const CLONE_IO: ::c_int = 0x80000000;
1084-
pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
10851084

10861085
pub const WNOHANG: ::c_int = 0x00000001;
10871086
pub const WUNTRACED: ::c_int = 0x00000002;
@@ -1091,15 +1090,11 @@ pub const WCONTINUED: ::c_int = 0x00000008;
10911090
pub const WNOWAIT: ::c_int = 0x01000000;
10921091

10931092
// Options for personality(2).
1094-
pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000;
10951093
pub const MMAP_PAGE_ZERO: ::c_int = 0x0100000;
1096-
pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000;
1097-
pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000;
10981094
pub const ADDR_LIMIT_32BIT: ::c_int = 0x0800000;
10991095
pub const SHORT_INODE: ::c_int = 0x1000000;
11001096
pub const WHOLE_SECONDS: ::c_int = 0x2000000;
11011097
pub const STICKY_TIMEOUTS: ::c_int = 0x4000000;
1102-
pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000;
11031098

11041099
// Options set using PTRACE_SETOPTIONS.
11051100
pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001;
@@ -1110,9 +1105,6 @@ pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010;
11101105
pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020;
11111106
pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040;
11121107
pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080;
1113-
pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000;
1114-
pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000;
1115-
pub const PTRACE_O_MASK: ::c_int = 0x003000ff;
11161108

11171109
// Wait extended result codes for the above trace options.
11181110
pub const PTRACE_EVENT_FORK: ::c_int = 1;
@@ -1309,6 +1301,24 @@ pub const ARPHRD_IEEE802154: u16 = 804;
13091301
pub const ARPHRD_VOID: u16 = 0xFFFF;
13101302
pub const ARPHRD_NONE: u16 = 0xFFFE;
13111303

1304+
cfg_if! {
1305+
if #[cfg(not(target_env = "uclibc"))] {
1306+
pub const IPPROTO_BEETPH: ::c_int = 94;
1307+
pub const IPPROTO_MPLS: ::c_int = 137;
1308+
pub const IPV6_HDRINCL: ::c_int = 36;
1309+
pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4;
1310+
pub const IPV6_PMTUDISC_OMIT: ::c_int = 5;
1311+
pub const CLONE_NEWCGROUP: ::c_int = 0x02000000;
1312+
pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000;
1313+
pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000;
1314+
pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000;
1315+
pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000;
1316+
pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000;
1317+
pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000;
1318+
pub const PTRACE_O_MASK: ::c_int = 0x003000ff;
1319+
}
1320+
}
1321+
13121322
const_fn! {
13131323
{const} fn CMSG_ALIGN(len: usize) -> usize {
13141324
len + ::mem::size_of::<usize>() - 1 & !(::mem::size_of::<usize>() - 1)
@@ -1536,24 +1546,6 @@ extern "C" {
15361546
count: ::size_t,
15371547
offset: off64_t,
15381548
) -> ::ssize_t;
1539-
pub fn preadv64(
1540-
fd: ::c_int,
1541-
iov: *const ::iovec,
1542-
iovcnt: ::c_int,
1543-
offset: ::off64_t,
1544-
) -> ::ssize_t;
1545-
pub fn pwrite64(
1546-
fd: ::c_int,
1547-
buf: *const ::c_void,
1548-
count: ::size_t,
1549-
offset: off64_t,
1550-
) -> ::ssize_t;
1551-
pub fn pwritev64(
1552-
fd: ::c_int,
1553-
iov: *const ::iovec,
1554-
iovcnt: ::c_int,
1555-
offset: ::off64_t,
1556-
) -> ::ssize_t;
15571549
pub fn readdir64(dirp: *mut ::DIR) -> *mut ::dirent64;
15581550
pub fn readdir64_r(
15591551
dirp: *mut ::DIR,
@@ -1633,19 +1625,6 @@ extern "C" {
16331625
options: ::c_int,
16341626
rusage: *mut ::rusage,
16351627
) -> ::pid_t;
1636-
pub fn openpty(
1637-
amaster: *mut ::c_int,
1638-
aslave: *mut ::c_int,
1639-
name: *mut ::c_char,
1640-
termp: *const termios,
1641-
winp: *const ::winsize,
1642-
) -> ::c_int;
1643-
pub fn forkpty(
1644-
amaster: *mut ::c_int,
1645-
name: *mut ::c_char,
1646-
termp: *const termios,
1647-
winp: *const ::winsize,
1648-
) -> ::pid_t;
16491628
pub fn login_tty(fd: ::c_int) -> ::c_int;
16501629
pub fn execvpe(
16511630
file: *const ::c_char,
@@ -1689,13 +1668,56 @@ extern "C" {
16891668
pub fn uname(buf: *mut ::utsname) -> ::c_int;
16901669
}
16911670

1671+
cfg_if! {
1672+
if #[cfg(not(target_env = "uclibc"))] {
1673+
extern "C" {
1674+
pub fn preadv64(
1675+
fd: ::c_int,
1676+
iov: *const ::iovec,
1677+
iovcnt: ::c_int,
1678+
offset: ::off64_t,
1679+
) -> ::ssize_t;
1680+
pub fn pwrite64(
1681+
fd: ::c_int,
1682+
buf: *const ::c_void,
1683+
count: ::size_t,
1684+
offset: off64_t,
1685+
) -> ::ssize_t;
1686+
pub fn pwritev64(
1687+
fd: ::c_int,
1688+
iov: *const ::iovec,
1689+
iovcnt: ::c_int,
1690+
offset: ::off64_t,
1691+
) -> ::ssize_t;
1692+
// uclibc has separate non-const version of this function
1693+
pub fn forkpty(
1694+
amaster: *mut ::c_int,
1695+
name: *mut ::c_char,
1696+
termp: *const termios,
1697+
winp: *const ::winsize,
1698+
) -> ::pid_t;
1699+
// uclibc has separate non-const version of this function
1700+
pub fn openpty(
1701+
amaster: *mut ::c_int,
1702+
aslave: *mut ::c_int,
1703+
name: *mut ::c_char,
1704+
termp: *const termios,
1705+
winp: *const ::winsize,
1706+
) -> ::c_int;
1707+
}
1708+
}
1709+
}
1710+
16921711
cfg_if! {
16931712
if #[cfg(target_os = "emscripten")] {
16941713
mod emscripten;
16951714
pub use self::emscripten::*;
16961715
} else if #[cfg(target_os = "linux")] {
16971716
mod linux;
16981717
pub use self::linux::*;
1718+
} else if #[cfg(target_os = "l4re")] {
1719+
mod linux;
1720+
pub use self::linux::*;
16991721
} else if #[cfg(target_os = "android")] {
17001722
mod android;
17011723
pub use self::android::*;

‎src/unix/mod.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,7 @@ extern "C" {
458458
ptr: *mut *mut c_char,
459459
sizeloc: *mut size_t,
460460
) -> *mut FILE;
461-
pub fn open_wmemstream(
462-
ptr: *mut *mut wchar_t,
463-
sizeloc: *mut size_t,
464-
) -> *mut FILE;
461+
465462
pub fn fflush(file: *mut FILE) -> c_int;
466463
pub fn fclose(file: *mut FILE) -> c_int;
467464
pub fn remove(filename: *const c_char) -> c_int;
@@ -626,15 +623,24 @@ extern "C" {
626623
...
627624
) -> ::c_int;
628625
pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
629-
#[cfg_attr(target_os = "linux", link_name = "__isoc99_fscanf")]
626+
#[cfg_attr(
627+
all(target_os = "linux", not(target_env = "uclibc")),
628+
link_name = "__isoc99_fscanf"
629+
)]
630630
pub fn fscanf(
631631
stream: *mut ::FILE,
632632
format: *const ::c_char,
633633
...
634634
) -> ::c_int;
635-
#[cfg_attr(target_os = "linux", link_name = "__isoc99_scanf")]
635+
#[cfg_attr(
636+
all(target_os = "linux", not(target_env = "uclibc")),
637+
link_name = "__isoc99_scanf"
638+
)]
636639
pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
637-
#[cfg_attr(target_os = "linux", link_name = "__isoc99_sscanf")]
640+
#[cfg_attr(
641+
all(target_os = "linux", not(target_env = "uclibc")),
642+
link_name = "__isoc99_sscanf"
643+
)]
638644
pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...)
639645
-> ::c_int;
640646
pub fn getchar_unlocked() -> ::c_int;
@@ -1576,6 +1582,17 @@ extern "C" {
15761582
pub fn lockf(fd: ::c_int, cmd: ::c_int, len: ::off_t) -> ::c_int;
15771583
}
15781584

1585+
cfg_if! {
1586+
if #[cfg(not(target_env = "uclibc"))] {
1587+
extern "C" {
1588+
pub fn open_wmemstream(
1589+
ptr: *mut *mut wchar_t,
1590+
sizeloc: *mut size_t,
1591+
) -> *mut FILE;
1592+
}
1593+
}
1594+
}
1595+
15791596
cfg_if! {
15801597
if #[cfg(not(target_os = "redox"))] {
15811598
extern {
@@ -1631,13 +1648,11 @@ cfg_if! {
16311648
}
16321649

16331650
cfg_if! {
1634-
if #[cfg(target_env = "uclibc")] {
1635-
mod uclibc;
1636-
pub use self::uclibc::*;
1637-
} else if #[cfg(target_env = "newlib")] {
1651+
if #[cfg(target_env = "newlib")] {
16381652
mod newlib;
16391653
pub use self::newlib::*;
16401654
} else if #[cfg(any(target_os = "linux",
1655+
target_os = "l4re",
16411656
target_os = "android",
16421657
target_os = "emscripten"))] {
16431658
mod linux_like;

‎src/unix/uclibc/align.rs

Lines changed: 0 additions & 66 deletions
This file was deleted.

‎src/unix/uclibc/mod.rs

Lines changed: 0 additions & 2365 deletions
This file was deleted.

‎src/unix/uclibc/x86_64/align.rs

Lines changed: 0 additions & 77 deletions
This file was deleted.

‎src/unix/uclibc/x86_64/no_align.rs

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.