diff options
31 files changed, 665 insertions, 181 deletions
diff --git a/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile new file mode 100644 index 0000000000..f868f65573 --- /dev/null +++ b/ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile @@ -0,0 +1,17 @@ +FROM ubuntu:20.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc libc6-dev qemu-user ca-certificates qemu-system-arm curl \ + xz-utils patch + +RUN mkdir /toolchain + +RUN curl --retry 5 -L https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2020.08-1.tar.bz2 | \ + tar xjf - -C /toolchain --strip-components=1 +RUN /toolchain/relocate-sdk.sh + +ENV PATH=$PATH:/rust/bin:/toolchain/bin \ + STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \ + CC_armv7_unknown_linux_uclibc=armv7-buildroot-linux-uclibc-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_LINKER=armv7-buildroot-linux-uclibc-gcc \ + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_RUNNER="qemu-arm -L /toolchain/arm-buildroot-linux-uclibcgnueabihf/sysroot/" diff --git a/ci/docker/mipsel-unknown-linux-uclibc/Dockerfile b/ci/docker/mipsel-unknown-linux-uclibc/Dockerfile new file mode 100644 index 0000000000..5abb49dbe6 --- /dev/null +++ b/ci/docker/mipsel-unknown-linux-uclibc/Dockerfile @@ -0,0 +1,22 @@ +FROM ubuntu:20.04 + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc libc6-dev qemu-user ca-certificates qemu-system-mipsel curl \ + xz-utils patch + +RUN mkdir /toolchain + +# binutils 2.33.1 +# gcc 9.3.0 +# gdb 8.3.1 +# linux-headers 4.9.234 +# uclibc 1.0.34 +RUN curl --retry 5 -L https://toolchains.bootlin.com/downloads/releases/toolchains/mips32el/tarballs/mips32el--uclibc--stable-2020.08-1.tar.bz2 | \ + tar xjf - -C /toolchain --strip-components=1 +RUN /toolchain/relocate-sdk.sh + +ENV PATH=$PATH:/rust/bin:/toolchain/bin \ + STAGING_DIR=/toolchain/mipsel-buildroot-linux-uclibc/sysroot \ + CC_mipsel_unknown_linux_uclibc=mipsel-buildroot-linux-uclibc-gcc \ + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_UCLIBC_LINKER=mipsel-buildroot-linux-uclibc-gcc \ + CARGO_TARGET_MIPSEL_UNKNOWN_LINUX_UCLIBC_RUNNER="qemu-mipsel -L /toolchain/mipsel-buildroot-linux-uclibc/sysroot/" diff --git a/libc-test/build.rs b/libc-test/build.rs index f568affc7d..719249a90a 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -428,10 +428,13 @@ fn test_openbsd(target: &str) { "sys/file.h", "sys/ioctl.h", "sys/mman.h", + "sys/param.h", "sys/resource.h", "sys/shm.h", "sys/socket.h", "sys/time.h", + "sys/uio.h", + "sys/ktrace.h", "sys/un.h", "sys/wait.h", "unistd.h", @@ -539,6 +542,9 @@ fn test_windows(target: &str) { let gnu = target.contains("gnu"); let mut cfg = ctest_cfg(); + if target.contains("msvc") { + cfg.flag("/wd4324"); + } cfg.define("_WIN32_WINNT", Some("0x8000")); headers! { cfg: @@ -603,6 +609,13 @@ fn test_windows(target: &str) { _ => false, }); + cfg.skip_struct(move |ty| { + if ty.starts_with("__c_anonymous_") { + return true; + } + return false; + }); + cfg.skip_const(move |name| { match name { // FIXME: API error: @@ -616,6 +629,10 @@ fn test_windows(target: &str) { } }); + cfg.skip_field(move |s, field| match s { + "CONTEXT" if field == "Fp" => true, + _ => false, + }); // FIXME: All functions point to the wrong addresses? cfg.skip_fn_ptrcheck(|_| true); @@ -969,6 +986,7 @@ fn test_netbsd(target: &str) { "sys/file.h", "sys/ioctl.h", "sys/ioctl_compat.h", + "sys/ktrace.h", "sys/mman.h", "sys/mount.h", "sys/ptrace.h", @@ -1185,6 +1203,7 @@ fn test_dragonflybsd(target: &str) { "sys/file.h", "sys/ioctl.h", "sys/ipc.h", + "sys/ktrace.h", "sys/mman.h", "sys/mount.h", "sys/ptrace.h", @@ -1815,9 +1834,11 @@ fn test_freebsd(target: &str) { "sys/types.h", "sys/ucontext.h", "sys/uio.h", + "sys/ktrace.h", "sys/un.h", "sys/user.h", "sys/utsname.h", + "sys/uuid.h", "sys/wait.h", "libprocstat.h", "syslog.h", @@ -2846,6 +2867,34 @@ fn test_linux(target: &str) { | "SW_CNT" if mips || ppc64 || riscv64 || sparc64 => true, + // kernel constants not available in uclibc 1.0.34 + | "ADDR_COMPAT_LAYOUT" + | "ADDR_LIMIT_3GB" + | "ADDR_NO_RANDOMIZE" + | "CLONE_NEWCGROUP" + | "EXTPROC" + | "FAN_MARK_FILESYSTEM" + | "FAN_MARK_INODE" + | "IPPROTO_BEETPH" + | "IPPROTO_MPLS" + | "IPV6_HDRINCL" + | "IPV6_MULTICAST_ALL" + | "IPV6_PMTUDISC_INTERFACE" + | "IPV6_PMTUDISC_OMIT" + | "IPV6_ROUTER_ALERT_ISOLATE" + | "O_TMPFILE" + | "PACKET_MR_UNICAST" + | "PTRACE_EVENT_STOP" + | "PTRACE_O_EXITKILL" + | "PTRACE_O_SUSPEND_SECCOMP" + | "PTRACE_PEEKSIGINFO" + | "READ_IMPLIES_EXEC" + | "RUSAGE_THREAD" + | "SHM_EXEC" + | "UDP_GRO" + | "UDP_SEGMENT" + if uclibc => true, + _ => false, } }); @@ -2923,6 +2972,9 @@ fn test_linux(target: &str) { "reallocarray" if musl => true, + // Not defined in uclibc as of 1.0.34 + "gettid" if uclibc => true, + _ => false, } }); diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 903f3f981e..f30ffa8247 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1355,6 +1355,7 @@ pthread_condattr_getclock pthread_condattr_getpshared pthread_condattr_setclock pthread_condattr_setpshared +pthread_get_name_np pthread_getcpuclockid pthread_kill pthread_main_np @@ -1462,6 +1463,7 @@ uselocale utimensat utmpx utmpxname +utrace uuid uuid_t vm_size_t diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 99aa6dd80a..57f2bc3ff2 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1365,6 +1365,7 @@ _SC_XOPEN_STREAMS _SC_XOPEN_UNIX _SC_XOPEN_VERSION _SC_XOPEN_XCU_VERSION +_UUID_NODE_LEN __c_anonymous_cr_pid __error __xuname @@ -1490,6 +1491,8 @@ getutxuser glob glob_t globfree +hexdump +humanize_number iconv iconv_close iconv_open @@ -1639,6 +1642,7 @@ pthread_condattr_getclock pthread_condattr_getpshared pthread_condattr_setclock pthread_condattr_setpshared +pthread_get_name_np pthread_getaffinity_np pthread_getcpuclockid pthread_getthreadid_np @@ -1748,14 +1752,22 @@ sysctl sysctlbyname sysctlnametomib telldir +timer_create +timer_delete +timer_getoverrun +timer_gettime +timer_settime +timer_t timex truncate ttyname_r +uuidgen unmount useconds_t uselocale utimensat utmpx +utrace vm_size_t wait4 waitid diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 83a82521d7..9eac72d3c5 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -15,6 +15,11 @@ ADJ_TICK ADJ_TIMECONST AFFS_SUPER_MAGIC AFS_SUPER_MAGIC +AF_MPLS +AF_XDP +AIO_ALLDONE +AIO_CANCELED +AIO_NOTCANCELED AT_STATX_DONT_SYNC AT_STATX_FORCE_SYNC AT_STATX_SYNC_AS_STAT @@ -54,6 +59,8 @@ EMPTY EXT2_SUPER_MAGIC EXT3_SUPER_MAGIC EXT4_SUPER_MAGIC +Elf32_Chdr +Elf64_Chdr F2FS_SUPER_MAGIC FDPIC_FUNCPTRS FUTEXFS_SUPER_MAGIC @@ -111,6 +118,11 @@ LC_PAPER LC_PAPER_MASK LC_TELEPHONE LC_TELEPHONE_MASK +LIO_NOP +LIO_NOWAIT +LIO_READ +LIO_WAIT +LIO_WRITE LM_ID_BASE LM_ID_NEWLM LOGIN_PROCESS @@ -316,6 +328,9 @@ OLD_TIME OPENPROM_SUPER_MAGIC OVERLAYFS_SUPER_MAGIC O_FSYNC +PF_IB +PF_MPLS +PF_XDP PROC_SUPER_MAGIC PTHREAD_MUTEX_ADAPTIVE_NP QNX4_SUPER_MAGIC @@ -524,6 +539,14 @@ __priority_which_t __rlimit_resource_t __timeval adjtimex +aio_cancel +aio_error +aio_fsync +aio_read +aio_return +aio_suspend +aio_write +aiocb backtrace clock_adjtime copy_file_range @@ -532,7 +555,10 @@ dlmopen endutxent explicit_bzero fgetspent_r +futimes +getauxval getgrent_r +getloadavg getpt getpwent_r getpwnam_r @@ -541,11 +567,12 @@ getutxent getutxid getutxline glob +glob_t glob64 glob64_t -glob_t globfree globfree64 +lio_listio mallinfo mallinfo2 malloc_info @@ -557,7 +584,13 @@ nl_pktinfo ntp_adjtime ntp_gettime ntptimeval +open_wmemstream preadv2 +preadv64 +prlimit +prlimit64 +process_vm_readv +process_vm_writev pthread_attr_getaffinity_np pthread_attr_setaffinity_np pthread_getname_np @@ -567,6 +600,7 @@ pthread_rwlockattr_setkind_np pthread_setname_np pututxline pwritev2 +pwritev64 qsort_r reallocarray semid_ds diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index bb69070b1f..737eb1f11d 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -1,8 +1,42 @@ # TODO: musl. +AF_IB +AF_MPLS +AF_XDP +AIO_ALLDONE +AIO_CANCELED +AIO_NOTCANCELED +Elf32_Chdr +Elf64_Chdr +LIO_NOP +LIO_NOWAIT +LIO_READ +LIO_WAIT +LIO_WRITE +PF_IB +PF_MPLS +PF_XDP adjtimex +aio_cancel +aio_error +aio_fsync +aio_read +aio_return +aio_suspend +aio_write +aiocb clock_adjtime explicit_bzero +futimes +getauxval +getloadavg +lio_listio ntptimeval +open_wmemstream +preadv64 +prlimit +prlimit64 +process_vm_readv +process_vm_writev +pwritev64 reallocarray timex - diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 5698a6f451..780181a509 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -35,7 +35,6 @@ AF_CAIF AF_CAN AF_DECnet AF_ECONET -AF_IB AF_IEEE802154 AF_IPX AF_IRDA @@ -44,7 +43,6 @@ AF_IUCV AF_KEY AF_LLC AF_LOCAL -AF_MPLS AF_NETBEUI AF_NETLINK AF_NETROM @@ -62,10 +60,6 @@ AF_TIPC AF_VSOCK AF_WANPIPE AF_X25 -AF_XDP -AIO_ALLDONE -AIO_CANCELED -AIO_NOTCANCELED AI_ADDRCONFIG AI_ALL AI_CANONNAME @@ -513,7 +507,6 @@ EXTA EXTB EXTPROC Elf32_Addr -Elf32_Chdr Elf32_Ehdr Elf32_Half Elf32_Off @@ -523,7 +516,6 @@ Elf32_Shdr Elf32_Sym Elf32_Word Elf64_Addr -Elf64_Chdr Elf64_Ehdr Elf64_Half Elf64_Off @@ -1050,11 +1042,6 @@ LINUX_REBOOT_MAGIC2 LINUX_REBOOT_MAGIC2A LINUX_REBOOT_MAGIC2B LINUX_REBOOT_MAGIC2C -LIO_NOP -LIO_NOWAIT -LIO_READ -LIO_WAIT -LIO_WRITE LOG_AUTHPRIV LOG_CRON LOG_FTP @@ -1483,7 +1470,6 @@ PF_CAIF PF_CAN PF_DECnet PF_ECONET -PF_IB PF_IEEE802154 PF_IPX PF_IRDA @@ -1492,7 +1478,6 @@ PF_IUCV PF_KEY PF_LLC PF_LOCAL -PF_MPLS PF_NETBEUI PF_NETLINK PF_NETROM @@ -1510,7 +1495,6 @@ PF_TIPC PF_VSOCK PF_WANPIPE PF_X25 -PF_XDP PIPE_BUF PM_STR POLLRDBAND @@ -2643,14 +2627,6 @@ accept4 acct addmntent af_alg_iv -aio_cancel -aio_error -aio_fsync -aio_read -aio_return -aio_suspend -aio_write -aiocb arpd_request arphdr arpreq @@ -2741,9 +2717,7 @@ fstatvfs64 ftello64 ftok ftruncate64 -futimes genlmsghdr -getauxval getdomainname getdtablesize getgrent @@ -2755,7 +2729,6 @@ getgrouplist gethostid getifaddrs getline -getloadavg getmntent getnameinfo getpriority @@ -2805,7 +2778,6 @@ key_t killpg labs lgetxattr -lio_listio listxattr llistxattr lockf @@ -2866,7 +2838,6 @@ nlmsghdr off64_t open64 open_memstream -open_wmemstream openat openat64 openpty @@ -2907,11 +2878,6 @@ ppoll prctl pread64 preadv -preadv64 -prlimit -prlimit64 -process_vm_readv -process_vm_writev pthread_attr_getguardsize pthread_attr_getstack pthread_cancel @@ -2941,7 +2907,6 @@ ptrace ptsname_r pwrite64 pwritev -pwritev64 qsort quotactl rand diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 4d1e7cf0d9..4f072f1c04 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1146,6 +1146,7 @@ fchdir fchflags fdatasync fdopendir +flags_to_string fmemopen forkpty freeifaddrs @@ -1208,6 +1209,7 @@ in6_pktinfo in_pktinfo initgroups ipc_perm +itimerspec kevent key_t killpg @@ -1269,6 +1271,7 @@ openat openpty pause pipe2 +pollts popen posix_madvise preadv @@ -1284,6 +1287,7 @@ pthread_cancel pthread_condattr_setclock pthread_getattr_np pthread_getaffinity_np +pthread_getname_np pthread_kill pthread_mutex_timedlock pthread_spin_destroy @@ -1367,6 +1371,7 @@ srand stack_t strcasecmp strcasestr +string_to_flags strncasecmp strndup strpct @@ -1377,6 +1382,12 @@ syscall sysctl sysctlbyname telldir +timer_create +timer_delete +timer_getoverrun +timer_gettime +timer_settime +timer_t timex truncate ttyname_r @@ -1390,6 +1401,7 @@ utmp utmpx utmpxname utpname +utrace vm_size_t wait4 waitid diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 228c617fa8..c2073563af 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -1031,6 +1031,7 @@ pthread_attr_getguardsize pthread_attr_getstack pthread_cancel pthread_condattr_setclock +pthread_get_name_np pthread_kill pthread_main_np pthread_mutex_timedlock @@ -1119,5 +1120,6 @@ useconds_t uselocale utimensat utmp +utrace wait4 xucred diff --git a/libc-test/semver/windows-msvc-x86_64.txt b/libc-test/semver/windows-msvc-x86_64.txt new file mode 100644 index 0000000000..eb09b4fbf0 --- /dev/null +++ b/libc-test/semver/windows-msvc-x86_64.txt @@ -0,0 +1 @@ +CONTEXT diff --git a/libc-test/semver/windows-msvc.txt b/libc-test/semver/windows-msvc.txt index 42dc8bede1..5b5296be3e 100644 --- a/libc-test/semver/windows-msvc.txt +++ b/libc-test/semver/windows-msvc.txt @@ -1,3 +1,4 @@ EOTHER +memccpy stricmp strnicmp diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index 259e3766ff..ade72529e2 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -178,6 +178,7 @@ creat dev_t dup dup2 +errno_t execl execle execlp @@ -239,6 +240,7 @@ isupper isxdigit labs listen +localtime_s lseek lseek64 malloc diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index c3e49a12df..4b99038784 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -1335,7 +1335,7 @@ f! { () } - pub fn CPU_ISSET(cpu: usize, cpuset: &mut cpu_set_t) -> bool { + pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { let (idx, offset) = ((cpu >> 6) & 3, cpu & 63); 0 != cpuset.ary[idx] & (1 << offset) } @@ -1390,6 +1390,7 @@ extern "C" { pub fn sched_getaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *mut cpu_set_t) -> ::c_int; pub fn sched_setaffinity(pid: ::pid_t, cpusetsize: ::size_t, mask: *const cpu_set_t) -> ::c_int; + pub fn sched_getcpu() -> ::c_int; pub fn setproctitle(fmt: *const ::c_char, ...); pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index a324cbd546..cc22a01536 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -5,6 +5,7 @@ pub type lwpid_t = i32; pub type blksize_t = i32; pub type clockid_t = ::c_int; pub type sem_t = _sem; +pub type timer_t = *mut __c_anonymous__timer; pub type fsblkcnt_t = u64; pub type fsfilcnt_t = u64; @@ -24,6 +25,8 @@ pub type pthread_spinlock_t = *mut __c_anonymous_pthread_spinlock; pub type pthread_barrierattr_t = *mut __c_anonymous_pthread_barrierattr; pub type pthread_barrier_t = *mut __c_anonymous_pthread_barrier; +pub type uuid_t = ::uuid; + s! { pub struct aiocb { pub aio_fildes: ::c_int, @@ -152,6 +155,15 @@ s! { c_spare: [u32; 1], } + pub struct uuid { + pub time_low: u32, + pub time_mid: u16, + pub time_hi_and_version: u16, + pub clock_seq_hi_and_reserved: u8, + pub clock_seq_low: u8, + pub node: [u8; _UUID_NODE_LEN], + } + pub struct __c_anonymous_pthread_spinlock { s_clock: umutex, } @@ -238,6 +250,15 @@ s! { envv: *mut ::c_void, core: ::uintptr_t, } + + pub struct itimerspec { + pub it_interval: ::timespec, + pub it_value: ::timespec, + } + + pub struct __c_anonymous__timer { + _priv: [::c_int; 3], + } } s_no_extra_traits! { @@ -1383,6 +1404,8 @@ pub const _PC_ACL_NFS4: ::c_int = 64; pub const _SC_CPUSET_SIZE: ::c_int = 122; +pub const _UUID_NODE_LEN: usize = 6; + // Flags which can be passed to pdfork(2) pub const PD_DAEMON: ::c_int = 0x00000001; pub const PD_CLOEXEC: ::c_int = 0x00000002; @@ -1528,7 +1551,7 @@ f! { () } - pub fn CPU_ISSET(cpu: usize, cpuset: &mut cpuset_t) -> bool { + pub fn CPU_ISSET(cpu: usize, cpuset: &cpuset_t) -> bool { let bitset_bits = ::mem::size_of::<::c_long>(); let (idx, offset) = (cpu / bitset_bits, cpu % bitset_bits); 0 != cpuset.__bits[idx] & (1 << offset) @@ -1766,6 +1789,8 @@ extern "C" { newfd: ::c_int, ) -> ::c_int; + pub fn uuidgen(store: *mut uuid, count: ::c_int) -> ::c_int; + pub fn pthread_getthreadid_np() -> ::c_int; pub fn pthread_getaffinity_np( td: ::pthread_t, @@ -1911,6 +1936,16 @@ extern "C" { pub fn kld_load(name: *const ::c_char) -> ::c_int; pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::c_int) -> *mut kinfo_vmentry; + + pub fn hexdump(ptr: *const ::c_void, length: ::c_int, hdr: *const ::c_char, flags: ::c_int); + pub fn humanize_number( + buf: *mut ::c_char, + len: ::size_t, + number: i64, + suffix: *const ::c_char, + scale: ::c_int, + flags: ::c_int, + ) -> ::c_int; } #[link(name = "procstat")] @@ -1938,6 +1973,20 @@ extern "C" { pub fn procstat_close(procstat: *mut procstat); } +#[link(name = "rt")] +extern "C" { + pub fn timer_create(clock_id: clockid_t, evp: *mut sigevent, timerid: *mut timer_t) -> ::c_int; + pub fn timer_delete(timerid: timer_t) -> ::c_int; + pub fn timer_getoverrun(timerid: timer_t) -> ::c_int; + pub fn timer_gettime(timerid: timer_t, value: *mut itimerspec) -> ::c_int; + pub fn timer_settime( + timerid: timer_t, + flags: ::c_int, + value: *const itimerspec, + ovalue: *mut itimerspec, + ) -> ::c_int; +} + cfg_if! { if #[cfg(freebsd13)] { mod freebsd13; diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 05648c9a9b..da38f1abb0 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1565,8 +1565,10 @@ extern "C" { ) -> ::c_int; pub fn pthread_barrier_destroy(barrier: *mut pthread_barrier_t) -> ::c_int; pub fn pthread_barrier_wait(barrier: *mut pthread_barrier_t) -> ::c_int; + pub fn pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t); pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_char, data: ::c_int) -> ::c_int; + pub fn utrace(addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn pututxline(ut: *const utmpx) -> *mut utmpx; pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index cf383798f6..2fa9d853d4 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -13,6 +13,7 @@ pub type shmatt_t = ::c_uint; pub type cpuid_t = u64; pub type cpuset_t = _cpuset; pub type pthread_spin_t = ::c_uchar; +pub type timer_t = ::c_int; // elf.h @@ -120,6 +121,11 @@ s! { pub mq_curmsgs: ::c_long, } + pub struct itimerspec { + pub it_interval: ::timespec, + pub it_value: ::timespec, + } + pub struct sigset_t { __bits: [u32; 4], } @@ -2147,6 +2153,8 @@ extern "C" { ) -> ::c_int; pub fn mq_unlink(name: *const ::c_char) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: *mut ::c_void, data: ::c_int) -> ::c_int; + pub fn utrace(label: *const ::c_char, addr: *mut ::c_void, len: ::size_t) -> ::c_int; + pub fn pthread_getname_np(t: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; pub fn pthread_setname_np( t: ::pthread_t, name: *const ::c_char, @@ -2255,6 +2263,21 @@ extern "C" { ) -> ::size_t; pub fn iconv_close(cd: iconv_t) -> ::c_int; + pub fn timer_create( + clockid: ::clockid_t, + sevp: *mut ::sigevent, + timerid: *mut ::timer_t, + ) -> ::c_int; + pub fn timer_delete(timerid: ::timer_t) -> ::c_int; + pub fn timer_getoverrun(timerid: ::timer_t) -> ::c_int; + pub fn timer_gettime(timerid: ::timer_t, curr_value: *mut ::itimerspec) -> ::c_int; + pub fn timer_settime( + timerid: ::timer_t, + flags: ::c_int, + new_value: *const ::itimerspec, + old_value: *mut ::itimerspec, + ) -> ::c_int; + // Added in `NetBSD` 7.0 pub fn explicit_memset(b: *mut ::c_void, c: ::c_int, len: ::size_t); pub fn consttime_memequal(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int; @@ -2276,6 +2299,14 @@ extern "C" { policy: ::c_int, param: *const ::sched_param, ) -> ::c_int; + + #[link_name = "__pollts50"] + pub fn pollts( + fds: *mut ::pollfd, + nfds: ::nfds_t, + ts: *const ::timespec, + sigmask: *const ::sigset_t, + ) -> ::c_int; } #[link(name = "util")] @@ -2388,6 +2419,13 @@ extern "C" { tpe: ::c_int, ); + pub fn string_to_flags( + string_p: *mut *mut ::c_char, + setp: *mut ::c_ulong, + clrp: *mut ::c_ulong, + ) -> ::c_int; + pub fn flags_to_string(flags: ::c_ulong, def: *const ::c_char) -> ::c_int; + pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::size_t) -> *mut kinfo_vmentry; } diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 4812db6f5c..535d7b1665 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1546,6 +1546,7 @@ extern "C" { stacksize: *mut ::size_t, ) -> ::c_int; pub fn pthread_main_np() -> ::c_int; + pub fn pthread_get_name_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t); pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); pub fn pthread_stackseg_np(thread: ::pthread_t, sinfo: *mut ::stack_t) -> ::c_int; @@ -1561,6 +1562,7 @@ extern "C" { pub fn setresgid(rgid: ::gid_t, egid: ::gid_t, sgid: ::gid_t) -> ::c_int; pub fn setresuid(ruid: ::uid_t, euid: ::uid_t, suid: ::uid_t) -> ::c_int; pub fn ptrace(request: ::c_int, pid: ::pid_t, addr: caddr_t, data: ::c_int) -> ::c_int; + pub fn utrace(label: *const ::c_char, addr: *const ::c_void, len: ::size_t) -> ::c_int; pub fn memmem( haystack: *const ::c_void, haystacklen: ::size_t, diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index d55973a77e..bb2a777d77 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -141,19 +141,6 @@ s! { pub keepcost: ::size_t, } - pub struct nlmsghdr { - pub nlmsg_len: u32, - pub nlmsg_type: u16, - pub nlmsg_flags: u16, - pub nlmsg_seq: u32, - pub nlmsg_pid: u32, - } - - pub struct nlmsgerr { - pub error: ::c_int, - pub msg: nlmsghdr, - } - pub struct nl_pktinfo { pub group: u32, } @@ -174,11 +161,6 @@ s! { pub nm_gid: u32, } - pub struct nlattr { - pub nla_len: u16, - pub nla_type: u16, - } - pub struct rtentry { pub rt_pad1: ::c_ulong, pub rt_dst: ::sockaddr, @@ -1210,13 +1192,6 @@ extern "C" { statxbuf: *mut statx, ) -> ::c_int; pub fn getrandom(buf: *mut ::c_void, buflen: ::size_t, flags: ::c_uint) -> ::ssize_t; - - pub fn memmem( - haystack: *const ::c_void, - haystacklen: ::size_t, - needle: *const ::c_void, - needlelen: ::size_t, - ) -> *mut ::c_void; pub fn getauxval(type_: ::c_ulong) -> ::c_ulong; pub fn adjtimex(buf: *mut timex) -> ::c_int; @@ -1305,16 +1280,6 @@ extern "C" { ) -> ::c_int; pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int; - pub fn pthread_getaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t, - ) -> ::c_int; - pub fn pthread_setaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t, - ) -> ::c_int; pub fn pthread_rwlockattr_getkind_np( attr: *const ::pthread_rwlockattr_t, val: *mut ::c_int, @@ -1323,7 +1288,6 @@ extern "C" { attr: *mut ::pthread_rwlockattr_t, val: ::c_int, ) -> ::c_int; - pub fn sched_getcpu() -> ::c_int; pub fn mallinfo() -> ::mallinfo; pub fn mallinfo2() -> ::mallinfo2; pub fn malloc_info(options: ::c_int, stream: *mut ::FILE) -> ::c_int; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 20cb9ae6e2..e10a310a2e 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -563,6 +563,24 @@ s! { pub instruction_pointer: ::__u64, pub args: [::__u64; 6], } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } + + pub struct nlmsgerr { + pub error: ::c_int, + pub msg: nlmsghdr, + } + + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } } s_no_extra_traits! { @@ -3438,6 +3456,16 @@ extern "C" { len: *mut ::socklen_t, flg: ::c_int, ) -> ::c_int; + pub fn pthread_getaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *mut ::cpu_set_t, + ) -> ::c_int; + pub fn pthread_setaffinity_np( + thread: ::pthread_t, + cpusetsize: ::size_t, + cpuset: *const ::cpu_set_t, + ) -> ::c_int; pub fn pthread_setschedprio(native: ::pthread_t, priority: ::c_int) -> ::c_int; pub fn reboot(how_to: ::c_int) -> ::c_int; pub fn setfsgid(gid: ::gid_t) -> ::c_int; @@ -3850,6 +3878,13 @@ extern "C" { pub fn gethostid() -> ::c_long; pub fn pthread_getcpuclockid(thread: ::pthread_t, clk_id: *mut ::clockid_t) -> ::c_int; + pub fn memmem( + haystack: *const ::c_void, + haystacklen: ::size_t, + needle: *const ::c_void, + needlelen: ::size_t, + ) -> *mut ::c_void; + pub fn sched_getcpu() -> ::c_int; } cfg_if! { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 6b2dd898fe..df596e9683 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -133,24 +133,6 @@ s! { __dummy4: [::c_char; 16], } - pub struct nlmsghdr { - pub nlmsg_len: u32, - pub nlmsg_type: u16, - pub nlmsg_flags: u16, - pub nlmsg_seq: u32, - pub nlmsg_pid: u32, - } - - pub struct nlmsgerr { - pub error: ::c_int, - pub msg: nlmsghdr, - } - - pub struct nlattr { - pub nla_len: u16, - pub nla_type: u16, - } - pub struct sigaction { pub sa_sigaction: ::sighandler_t, pub sa_mask: ::sigset_t, @@ -757,23 +739,6 @@ extern "C" { pub fn ptrace(request: ::c_int, ...) -> ::c_long; pub fn getpriority(which: ::c_int, who: ::id_t) -> ::c_int; pub fn setpriority(which: ::c_int, who: ::id_t, prio: ::c_int) -> ::c_int; - pub fn pthread_getaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *mut ::cpu_set_t, - ) -> ::c_int; - pub fn pthread_setaffinity_np( - thread: ::pthread_t, - cpusetsize: ::size_t, - cpuset: *const ::cpu_set_t, - ) -> ::c_int; - pub fn sched_getcpu() -> ::c_int; - pub fn memmem( - haystack: *const ::c_void, - haystacklen: ::size_t, - needle: *const ::c_void, - needlelen: ::size_t, - ) -> *mut ::c_void; // Musl targets need the `mask` argument of `fanotify_mark` be specified // `::c_ulonglong` instead of `u64` or there will be a type mismatch between // `long long unsigned int` and the expected `uint64_t`. diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index dc6518c0da..ccc005d48b 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -61,8 +61,8 @@ s! { pub st_mtime_nsec: ::c_long, pub st_ctime: ::time_t, pub st_ctime_nsec: ::c_long, - pub __uclibc_unused4: ::c_ulong, - pub __uclibc_unused5: ::c_ulong, + pub __unused4: ::c_ulong, + pub __unused5: ::c_ulong, } pub struct stat64 @@ -205,41 +205,41 @@ s! { pub __pad1: ::c_ushort, pub __seq: ::c_ushort, pub __pad2: ::c_ushort, - pub __uclibc_unused1: ::c_ulong, - pub __uclibc_unused2: ::c_ulong, + pub __unused1: ::c_ulong, + pub __unused2: ::c_ulong, } pub struct msqid_ds { pub msg_perm: ::ipc_perm, pub msg_stime: ::time_t, - pub __uclibc_unused1: ::c_ulong, + pub __unused1: ::c_ulong, pub msg_rtime: ::time_t, - pub __uclibc_unused2: ::c_ulong, + pub __unused2: ::c_ulong, pub msg_ctime: ::time_t, - pub __uclibc_unused3: ::c_ulong, + pub __unused3: ::c_ulong, pub __msg_cbytes: ::c_ulong, pub msg_qnum: ::msgqnum_t, pub msg_qbytes: ::msglen_t, pub msg_lspid: ::pid_t, pub msg_lrpid: ::pid_t, - pub __uclibc_unused4: ::c_ulong, - pub __uclibc_unused5: ::c_ulong, + pub __unused4: ::c_ulong, + pub __unused5: ::c_ulong, } pub struct shmid_ds { pub shm_perm: ::ipc_perm, pub shm_segsz: ::size_t, pub shm_atime: ::time_t, - pub __uclibc_unused1: ::c_ulong, + pub __unused1: ::c_ulong, pub shm_dtime: ::time_t, - pub __uclibc_unused2: ::c_ulong, + pub __unused2: ::c_ulong, pub shm_ctime: ::time_t, - pub __uclibc_unused3: ::c_ulong, + pub __unused3: ::c_ulong, pub shm_cpid: ::pid_t, pub shm_lpid: ::pid_t, pub shm_nattch: ::shmatt_t, - pub __uclibc_unused4: ::c_ulong, - pub __uclibc_unused5: ::c_ulong, + pub __unused4: ::c_ulong, + pub __unused5: ::c_ulong, } } @@ -469,6 +469,7 @@ pub const PENDIN: ::tcflag_t = 0x4000; pub const POLLWRBAND: ::c_short = 0x200; pub const POLLWRNORM: ::c_short = 0x100; pub const PTHREAD_STACK_MIN: ::size_t = 16384; +pub const RTLD_GLOBAL: ::c_int = 0x00100; // These are typed unsigned to match sigaction pub const SA_NOCLDSTOP: ::c_ulong = 0x1; @@ -516,6 +517,8 @@ pub const TABDLY: ::c_int = 0x1800; pub const TCSADRAIN: ::c_int = 0x1; pub const TCSAFLUSH: ::c_int = 0x2; pub const TCSANOW: ::c_int = 0; +pub const TIOCGWINSZ: ::c_int = 0x5413; +pub const TIOCSWINSZ: ::c_int = 0x5414; pub const TOSTOP: ::tcflag_t = 0x100; pub const VDISCARD: usize = 0xd; pub const VEOF: usize = 0x4; @@ -886,6 +889,9 @@ pub const SYS_pwritev2: ::c_long = 393; pub const SYS_pkey_mprotect: ::c_long = 394; pub const SYS_pkey_alloc: ::c_long = 395; pub const SYS_pkey_free: ::c_long = 396; +pub const SYS_statx: ::c_int = 397; +pub const SYS_pidfd_open: ::c_long = 434; +pub const SYS_clone3: ::c_long = 435; extern "C" { pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int; diff --git a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs index 8edde11aad..c0fe0ab5f5 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mips32/mod.rs @@ -625,6 +625,7 @@ pub const SYS_pwritev2: ::c_long = 4000 + 362; pub const SYS_pkey_mprotect: ::c_long = 4000 + 363; pub const SYS_pkey_alloc: ::c_long = 4000 + 364; pub const SYS_pkey_free: ::c_long = 4000 + 365; +pub const SYS_clone3: ::c_long = 4000 + 435; #[link(name = "util")] extern "C" { diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index 28fa9a22a3..a724c3e08c 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -32,22 +32,13 @@ pub const EPOLL_CLOEXEC: ::c_int = 0x80000; pub const EFD_CLOEXEC: ::c_int = 0x80000; -pub const BUFSIZ: ::c_uint = 4096; pub const TMP_MAX: ::c_uint = 238328; -pub const FOPEN_MAX: ::c_uint = 16; -pub const POSIX_MADV_DONTNEED: ::c_int = 4; pub const _SC_2_C_VERSION: ::c_int = 96; pub const O_ACCMODE: ::c_int = 3; pub const O_DIRECT: ::c_int = 0x8000; pub const O_DIRECTORY: ::c_int = 0x10000; pub const O_NOFOLLOW: ::c_int = 0x20000; -pub const NI_MAXHOST: ::socklen_t = 1025; -pub const RLIMIT_NOFILE: ::c_int = 5; -pub const RLIMIT_AS: ::c_int = 6; -pub const RLIMIT_RSS: ::c_int = 7; -pub const RLIMIT_NPROC: ::c_int = 8; -pub const RLIMIT_MEMLOCK: ::c_int = 9; pub const RLIMIT_NLIMITS: ::c_int = 15; pub const RLIM_NLIMITS: ::c_int = RLIMIT_NLIMITS; @@ -87,7 +78,6 @@ pub const EXFULL: ::c_int = 52; pub const ENOANO: ::c_int = 53; pub const EBADRQC: ::c_int = 54; pub const EBADSLT: ::c_int = 55; -pub const EDEADLOCK: ::c_int = 56; pub const EMULTIHOP: ::c_int = 74; pub const EOVERFLOW: ::c_int = 79; pub const ENOTUNIQ: ::c_int = 80; @@ -189,7 +179,6 @@ pub const SIGTSTP: ::c_int = 24; pub const SIGURG: ::c_int = 21; pub const SIGIO: ::c_int = 22; pub const SIGSYS: ::c_int = 12; -pub const SIGPOLL: ::c_int = 22; pub const SIGPWR: ::c_int = 19; pub const SIG_SETMASK: ::c_int = 3; pub const SIG_BLOCK: ::c_int = 0x1; @@ -216,47 +205,15 @@ pub const CPU_SETSIZE: ::c_int = 0x400; pub const EFD_NONBLOCK: ::c_int = 0x80; pub const F_GETLK: ::c_int = 14; -pub const F_GETOWN: ::c_int = 23; -pub const F_SETOWN: ::c_int = 24; pub const F_SETLK: ::c_int = 6; pub const F_SETLKW: ::c_int = 7; pub const SFD_NONBLOCK: ::c_int = 0x80; -pub const TCGETS: ::c_ulong = 0x540d; -pub const TCSETS: ::c_ulong = 0x540e; -pub const TCSETSW: ::c_ulong = 0x540f; -pub const TCSETSF: ::c_ulong = 0x5410; -pub const TCGETA: ::c_ulong = 0x5401; -pub const TCSETA: ::c_ulong = 0x5402; -pub const TCSETAW: ::c_ulong = 0x5403; -pub const TCSETAF: ::c_ulong = 0x5404; -pub const TCSBRK: ::c_ulong = 0x5405; -pub const TCXONC: ::c_ulong = 0x5406; -pub const TCFLSH: ::c_ulong = 0x5407; -pub const TIOCGSOFTCAR: ::c_ulong = 0x5481; -pub const TIOCSSOFTCAR: ::c_ulong = 0x5482; -pub const TIOCINQ: ::c_ulong = 0x467f; -pub const TIOCLINUX: ::c_ulong = 0x5483; -pub const TIOCGSERIAL: ::c_ulong = 0x5484; -pub const TIOCEXCL: ::c_ulong = 0x740d; -pub const TIOCNXCL: ::c_ulong = 0x740e; -pub const TIOCSCTTY: ::c_ulong = 0x5480; -pub const TIOCGPGRP: ::c_ulong = 0x40047477; -pub const TIOCSPGRP: ::c_ulong = 0x80047476; -pub const TIOCOUTQ: ::c_ulong = 0x7472; -pub const TIOCSTI: ::c_ulong = 0x5472; pub const TIOCGWINSZ: ::c_ulong = 0x40087468; pub const TIOCSWINSZ: ::c_ulong = 0x80087467; -pub const TIOCMGET: ::c_ulong = 0x741d; -pub const TIOCMBIS: ::c_ulong = 0x741b; -pub const TIOCMBIC: ::c_ulong = 0x741c; -pub const TIOCMSET: ::c_ulong = 0x741a; -pub const FIONREAD: ::c_ulong = 0x467f; -pub const TIOCCONS: ::c_ulong = 0x80047478; pub const RTLD_GLOBAL: ::c_int = 0x4; -pub const RTLD_NOLOAD: ::c_int = 0x8; pub const SIGSTKSZ: ::size_t = 8192; pub const CBAUD: ::tcflag_t = 0o0010017; @@ -316,8 +273,6 @@ pub const B4800: ::speed_t = 0o000014; pub const B9600: ::speed_t = 0o000015; pub const B19200: ::speed_t = 0o000016; pub const B38400: ::speed_t = 0o000017; -pub const EXTA: ::speed_t = B19200; -pub const EXTB: ::speed_t = B38400; pub const B57600: ::speed_t = 0o010001; pub const B115200: ::speed_t = 0o010002; pub const B230400: ::speed_t = 0o010003; diff --git a/src/unix/linux_like/linux/uclibc/mod.rs b/src/unix/linux_like/linux/uclibc/mod.rs index 396e33d560..113303a49f 100644 --- a/src/unix/linux_like/linux/uclibc/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mod.rs @@ -2,6 +2,8 @@ pub type shmatt_t = ::c_ulong; pub type msgqnum_t = ::c_ulong; pub type msglen_t = ::c_ulong; pub type regoff_t = ::c_int; +pub type __rlimit_resource_t = ::c_uint; +pub type __priority_which_t = ::c_uint; s! { pub struct statvfs { // Different than GNU! @@ -34,6 +36,32 @@ s! { __re_nsub: ::size_t, __bitfield: u8, } + + pub struct rtentry { + pub rt_pad1: ::c_ulong, + pub rt_dst: ::sockaddr, + pub rt_gateway: ::sockaddr, + pub rt_genmask: ::sockaddr, + pub rt_flags: ::c_ushort, + pub rt_pad2: ::c_short, + pub rt_pad3: ::c_ulong, + pub rt_tos: ::c_uchar, + pub rt_class: ::c_uchar, + #[cfg(target_pointer_width = "64")] + pub rt_pad4: [::c_short; 3usize], + #[cfg(not(target_pointer_width = "64"))] + pub rt_pad4: ::c_short, + pub rt_metric: ::c_short, + pub rt_dev: *mut ::c_char, + pub rt_mtu: ::c_ulong, + pub rt_window: ::c_ulong, + pub rt_irtt: ::c_ushort, + } + + pub struct __exit_status { + pub e_termination: ::c_short, + pub e_exit: ::c_short, + } } pub const MCL_CURRENT: ::c_int = 0x0001; @@ -223,6 +251,108 @@ pub const PRIO_USER: ::c_int = 2; pub const ST_RELATIME: ::c_ulong = 4096; +pub const AF_NFC: ::c_int = PF_NFC; +pub const BUFSIZ: ::c_int = 4096; +pub const EDEADLOCK: ::c_int = EDEADLK; +pub const EXTA: ::c_uint = B19200; +pub const EXTB: ::c_uint = B38400; +pub const EXTPROC: ::c_int = 0200000; +pub const FAN_MARK_FILESYSTEM: ::c_int = 0x00000100; +pub const FAN_MARK_INODE: ::c_int = 0x00000000; +pub const FAN_MARK_MOUNT: ::c_int = 0x10; +pub const FIONREAD: ::c_int = 0x541B; +pub const FOPEN_MAX: ::c_int = 16; +pub const F_GETOWN: ::c_int = 9; +pub const F_OFD_GETLK: ::c_int = 36; +pub const F_OFD_SETLK: ::c_int = 37; +pub const F_OFD_SETLKW: ::c_int = 38; +pub const F_RDLCK: ::c_int = 0; +pub const F_SETOWN: ::c_int = 8; +pub const F_UNLCK: ::c_int = 2; +pub const F_WRLCK: ::c_int = 1; +pub const IPV6_MULTICAST_ALL: ::c_int = 29; +pub const IPV6_ROUTER_ALERT_ISOLATE: ::c_int = 30; +pub const MAP_HUGE_SHIFT: ::c_int = 26; +pub const MAP_HUGE_MASK: ::c_int = 0x3f; +pub const MAP_HUGE_64KB: ::c_int = 16 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512KB: ::c_int = 19 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1MB: ::c_int = 20 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2MB: ::c_int = 21 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_8MB: ::c_int = 23 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16MB: ::c_int = 24 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_32MB: ::c_int = 25 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_256MB: ::c_int = 28 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_512MB: ::c_int = 29 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_1GB: ::c_int = 30 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_2GB: ::c_int = 31 << MAP_HUGE_SHIFT; +pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT; +pub const MINSIGSTKSZ: ::c_int = 2048; +pub const MSG_COPY: ::c_int = 040000; +pub const NI_MAXHOST: ::socklen_t = 1025; +pub const O_TMPFILE: ::c_int = 020000000 | O_DIRECTORY; +pub const PACKET_MR_UNICAST: ::c_int = 3; +pub const PF_NFC: ::c_int = 39; +pub const PF_VSOCK: ::c_int = 40; +pub const POSIX_MADV_DONTNEED: ::c_int = 4; +pub const PTRACE_EVENT_STOP: ::c_int = 128; +pub const PTRACE_PEEKSIGINFO: ::c_int = 0x4209; +pub const RLIMIT_AS: ::c_int = 9; +pub const RLIMIT_MEMLOCK: ::c_int = 8; +pub const RLIMIT_NLIMITS: ::c_int = 15; +pub const RLIMIT_NOFILE: ::c_int = 7; +pub const RLIMIT_NPROC: ::c_int = 6; +pub const RLIMIT_RSS: ::c_int = 5; +pub const RLIMIT_RTTIME: ::c_int = 15; +pub const RTLD_NOLOAD: ::c_int = 0x00004; +pub const RUSAGE_THREAD: ::c_int = 1; +pub const SHM_EXEC: ::c_int = 0100000; +pub const SIGPOLL: ::c_int = SIGIO; +pub const SOCK_DCCP: ::c_int = 6; +pub const SOCK_PACKET: ::c_int = 10; +pub const TCFLSH: ::c_int = 0x540B; +pub const TCGETA: ::c_int = 0x5405; +pub const TCGETS: ::c_int = 0x5401; +pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; +pub const TCSBRK: ::c_int = 0x5409; +pub const TCSETA: ::c_int = 0x5406; +pub const TCSETAF: ::c_int = 0x5408; +pub const TCSETAW: ::c_int = 0x5407; +pub const TCSETS: ::c_int = 0x5402; +pub const TCSETSF: ::c_int = 0x5404; +pub const TCSETSW: ::c_int = 0x5403; +pub const TCXONC: ::c_int = 0x540A; +pub const TIOCCONS: ::c_int = 0x541D; +pub const TIOCEXCL: ::c_int = 0x540C; +pub const TIOCGPGRP: ::c_int = 0x540F; +pub const TIOCGSERIAL: ::c_int = 0x541E; +pub const TIOCGSOFTCAR: ::c_int = 0x5419; +pub const TIOCINQ: ::c_int = FIONREAD; +pub const TIOCLINUX: ::c_int = 0x541C; +pub const TIOCMBIC: ::c_int = 0x5417; +pub const TIOCMGET: ::c_int = 0x5415; +pub const TIOCMBIS: ::c_int = 0x5416; +pub const TIOCMSET: ::c_int = 0x5418; +pub const TIOCM_CAR: ::c_int = 0x040; +pub const TIOCM_CD: ::c_int = TIOCM_CAR; +pub const TIOCM_CTS: ::c_int = 0x020; +pub const TIOCM_DSR: ::c_int = 0x100; +pub const TIOCM_DTR: ::c_int = 0x002; +pub const TIOCM_LE: ::c_int = 0x001; +pub const TIOCM_RI: ::c_int = TIOCM_RNG; +pub const TIOCM_RNG: ::c_int = 0x080; +pub const TIOCM_RTS: ::c_int = 0x004; +pub const TIOCM_SR: ::c_int = 0x010; +pub const TIOCM_ST: ::c_int = 0x008; +pub const TIOCNXCL: ::c_int = 0x540D; +pub const TIOCOUTQ: ::c_int = 0x5411; +pub const TIOCSCTTY: ::c_int = 0x540E; +pub const TIOCSPGRP: ::c_int = 0x5410; +pub const TIOCSSOFTCAR: ::c_int = 0x541A; +pub const TIOCSTI: ::c_int = 0x5412; +pub const UDP_GRO: ::c_int = 104; +pub const UDP_SEGMENT: ::c_int = 103; +pub const YESEXPR: ::c_int = ((5) << 8) | (0); + extern "C" { pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int; @@ -289,6 +419,19 @@ extern "C" { ) -> ::ssize_t; pub fn sethostid(hostid: ::c_long) -> ::c_int; + pub fn fanotify_mark( + fd: ::c_int, + flags: ::c_uint, + mask: u64, + dirfd: ::c_int, + path: *const ::c_char, + ) -> ::c_int; + pub fn getrlimit64(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit64) -> ::c_int; + pub fn setrlimit64(resource: ::__rlimit_resource_t, rlim: *const ::rlimit64) -> ::c_int; + pub fn getrlimit(resource: ::__rlimit_resource_t, rlim: *mut ::rlimit) -> ::c_int; + pub fn setrlimit(resource: ::__rlimit_resource_t, rlim: *const ::rlimit) -> ::c_int; + pub fn getpriority(which: ::__priority_which_t, who: ::id_t) -> ::c_int; + pub fn setpriority(which: ::__priority_which_t, who: ::id_t, prio: ::c_int) -> ::c_int; } cfg_if! { diff --git a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs index 16ec0ef966..c7cbafa16e 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/l4re.rs @@ -46,3 +46,8 @@ pub struct pthread_attr_t { // L4Re requires a min stack size of 64k; that isn't defined in uClibc, but // somewhere in the core libraries. uClibc wants 16k, but that's not enough. pub const PTHREAD_STACK_MIN: usize = 65536; + +// Misc other constants required for building. +pub const SIGIO: ::c_int = 29; +pub const B19200: ::speed_t = 0o000016; +pub const B38400: ::speed_t = 0o000017; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index a8b0332065..5940424721 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -877,6 +877,8 @@ pub const IPPROTO_MH: ::c_int = 135; pub const IPPROTO_UDPLITE: ::c_int = 136; /// raw IP packet pub const IPPROTO_RAW: ::c_int = 255; +pub const IPPROTO_BEETPH: ::c_int = 94; +pub const IPPROTO_MPLS: ::c_int = 137; pub const MCAST_EXCLUDE: ::c_int = 0; pub const MCAST_INCLUDE: ::c_int = 1; @@ -913,6 +915,7 @@ pub const IPV6_JOIN_ANYCAST: ::c_int = 27; pub const IPV6_LEAVE_ANYCAST: ::c_int = 28; pub const IPV6_IPSEC_POLICY: ::c_int = 34; pub const IPV6_XFRM_POLICY: ::c_int = 35; +pub const IPV6_HDRINCL: ::c_int = 36; pub const IPV6_RECVPKTINFO: ::c_int = 49; pub const IPV6_PKTINFO: ::c_int = 50; pub const IPV6_RECVHOPLIMIT: ::c_int = 51; @@ -948,6 +951,8 @@ pub const IPV6_PMTUDISC_DONT: ::c_int = 0; pub const IPV6_PMTUDISC_WANT: ::c_int = 1; pub const IPV6_PMTUDISC_DO: ::c_int = 2; pub const IPV6_PMTUDISC_PROBE: ::c_int = 3; +pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4; +pub const IPV6_PMTUDISC_OMIT: ::c_int = 5; pub const TCP_NODELAY: ::c_int = 1; pub const TCP_MAXSEG: ::c_int = 2; @@ -1117,6 +1122,7 @@ pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000; pub const CLONE_DETACHED: ::c_int = 0x400000; pub const CLONE_UNTRACED: ::c_int = 0x800000; pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000; +pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; pub const CLONE_NEWUTS: ::c_int = 0x04000000; pub const CLONE_NEWIPC: ::c_int = 0x08000000; pub const CLONE_NEWUSER: ::c_int = 0x10000000; @@ -1132,11 +1138,15 @@ pub const WCONTINUED: ::c_int = 0x00000008; pub const WNOWAIT: ::c_int = 0x01000000; // Options for personality(2). +pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000; pub const MMAP_PAGE_ZERO: ::c_int = 0x0100000; +pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000; +pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000; pub const ADDR_LIMIT_32BIT: ::c_int = 0x0800000; pub const SHORT_INODE: ::c_int = 0x1000000; pub const WHOLE_SECONDS: ::c_int = 0x2000000; pub const STICKY_TIMEOUTS: ::c_int = 0x4000000; +pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000; // Options set using PTRACE_SETOPTIONS. pub const PTRACE_O_TRACESYSGOOD: ::c_int = 0x00000001; @@ -1147,6 +1157,8 @@ pub const PTRACE_O_TRACEEXEC: ::c_int = 0x00000010; pub const PTRACE_O_TRACEVFORKDONE: ::c_int = 0x00000020; pub const PTRACE_O_TRACEEXIT: ::c_int = 0x00000040; pub const PTRACE_O_TRACESECCOMP: ::c_int = 0x00000080; +pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; +pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; // Wait extended result codes for the above trace options. pub const PTRACE_EVENT_FORK: ::c_int = 1; @@ -1346,18 +1358,6 @@ pub const ARPHRD_NONE: u16 = 0xFFFE; cfg_if! { if #[cfg(not(target_env = "uclibc"))] { - pub const IPPROTO_BEETPH: ::c_int = 94; - pub const IPPROTO_MPLS: ::c_int = 137; - pub const IPV6_HDRINCL: ::c_int = 36; - pub const IPV6_PMTUDISC_INTERFACE: ::c_int = 4; - pub const IPV6_PMTUDISC_OMIT: ::c_int = 5; - pub const CLONE_NEWCGROUP: ::c_int = 0x02000000; - pub const ADDR_NO_RANDOMIZE: ::c_int = 0x0040000; - pub const ADDR_COMPAT_LAYOUT: ::c_int = 0x0200000; - pub const READ_IMPLIES_EXEC: ::c_int = 0x0400000; - pub const ADDR_LIMIT_3GB: ::c_int = 0x8000000; - pub const PTRACE_O_EXITKILL: ::c_int = 0x00100000; - pub const PTRACE_O_SUSPEND_SECCOMP: ::c_int = 0x00200000; pub const PTRACE_O_MASK: ::c_int = 0x003000ff; } } diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 8ee388ce6a..67147ea4a3 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2415,6 +2415,8 @@ extern "C" { lock: *mut pthread_mutex_t, abstime: *const ::timespec, ) -> ::c_int; + pub fn pthread_getname_np(tid: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int; + pub fn pthread_setname_np(tid: ::pthread_t, name: *const ::c_char) -> ::c_int; pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t, options: ::c_int) -> ::c_int; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 71af46a272..8ecff3ca7e 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -27,6 +27,8 @@ pub type wchar_t = u16; pub type clock_t = i32; +pub type errno_t = ::c_int; + cfg_if! { if #[cfg(all(target_arch = "x86", target_env = "gnu"))] { pub type time_t = i32; @@ -372,6 +374,8 @@ extern "C" { #[link_name = "_gmtime64_s"] pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> ::c_int; + #[link_name = "_localtime64_s"] + pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> ::errno_t; #[link_name = "_time64"] pub fn time(destTime: *mut time_t) -> time_t; #[link_name = "_chmod"] diff --git a/src/windows/msvc.rs b/src/windows/msvc/mod.rs index b4c98a8496..8cdb5bb176 100644 --- a/src/windows/msvc.rs +++ b/src/windows/msvc/mod.rs @@ -10,4 +10,20 @@ extern "C" { pub fn stricmp(s1: *const ::c_char, s2: *const ::c_char) -> ::c_int; #[link_name = "_strnicmp"] pub fn strnicmp(s1: *const ::c_char, s2: *const ::c_char, n: ::size_t) -> ::c_int; + #[link_name = "_memccpy"] + pub fn memccpy( + dest: *mut ::c_void, + src: *const ::c_void, + c: ::c_int, + count: ::size_t, + ) -> *mut ::c_void; +} + +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // Unknown target_arch + } } diff --git a/src/windows/msvc/x86_64.rs b/src/windows/msvc/x86_64.rs new file mode 100644 index 0000000000..249e590165 --- /dev/null +++ b/src/windows/msvc/x86_64.rs @@ -0,0 +1,140 @@ +pub type XMM_SAVE_AREA32 = XSAVE_FORMAT; + +s_no_extra_traits! { + #[repr(align(16))] + pub union __c_anonymous_CONTEXT_FP { + pub FltSave: ::XMM_SAVE_AREA32, + pub Xmm: __c_anonymous_CONTEXT_XMM, + } +} + +cfg_if! { + if #[cfg(feature = "extra_traits")] { + impl PartialEq for __c_anonymous_CONTEXT_FP { + fn eq(&self, other: &__c_anonymous_CONTEXT_FP) -> bool { + unsafe { + self.FltSave == other.FltSave || + self.Xmm == other.Xmm + } + } + } + impl Eq for __c_anonymous_CONTEXT_FP {} + impl ::fmt::Debug for __c_anonymous_CONTEXT_FP { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + unsafe { + f.debug_struct("__c_anonymous_CONTEXT_FP") + .field("FltSave", &self.FltSave) + .finish() + } + } + } + impl ::hash::Hash for __c_anonymous_CONTEXT_FP { + fn hash<H: ::hash::Hasher>(&self, state: &mut H) { + unsafe { + self.FltSave.hash(state); + self.Xmm.hash(state); + } + } + } + } +} + +s! { + #[repr(align(16))] + pub struct M128A { + pub Low: ::c_ulonglong, + pub High: ::c_longlong, + } + + #[repr(align(16))] + pub struct XSAVE_FORMAT { + pub ControlWord: ::c_ushort, + pub StatusWord: ::c_ushort, + pub TagWord: ::c_uchar, + _Reserved1: ::c_uchar, + pub ErrorOpcode: ::c_ushort, + pub ErrorOffset: ::c_ulong, + pub ErrorSelector: ::c_ushort, + _Reserved2: ::c_ushort, + pub DataOffset: ::c_ulong, + pub DataSelector: ::c_ushort, + _Reserved3: ::c_ushort, + pub MxCsr: ::c_ulong, + pub MxCsr_Mask: ::c_ulong, + pub FloatRegisters: [M128A; 8], + pub XmmRegisters: [M128A; 16], + _Reserved4: [::c_uchar; 96], + } + + #[repr(align(16))] + pub struct __c_anonymous_CONTEXT_XMM { + pub Header: [M128A; 2], + pub Legacy: [M128A; 8], + pub Xmm0: M128A, + pub Xmm1: M128A, + pub Xmm2: M128A, + pub Xmm3: M128A, + pub Xmm4: M128A, + pub Xmm5: M128A, + pub Xmm6: M128A, + pub Xmm7: M128A, + pub Xmm8: M128A, + pub Xmm9: M128A, + pub Xmm10: M128A, + pub Xmm11: M128A, + pub Xmm12: M128A, + pub Xmm13: M128A, + pub Xmm14: M128A, + pub Xmm15: M128A, + } + + #[repr(align(16))] + pub struct CONTEXT { + pub P1Home: u64, + pub P2Home: u64, + pub P3Home: u64, + pub P4Home: u64, + pub P5Home: u64, + pub P6Home: u64, + pub ContextFlags: ::c_ulong, + pub MxCsr: ::c_ulong, + pub SegCs: ::c_ushort, + pub SegDs: ::c_ushort, + pub SegEs: ::c_ushort, + pub SegFs: ::c_ushort, + pub SegGs: ::c_ushort, + pub SegSs: ::c_ushort, + pub EFlags: ::c_ulong, + pub Dr0: u64, + pub Dr1: u64, + pub Dr2: u64, + pub Dr3: u64, + pub Dr6: u64, + pub Dr7: u64, + pub Rax: u64, + pub Rcx: u64, + pub Rdx: u64, + pub Rbx: u64, + pub Rsp: u64, + pub Rbp: u64, + pub Rsi: u64, + pub Rdi: u64, + pub R8: u64, + pub R9: u64, + pub R10: u64, + pub R11: u64, + pub R12: u64, + pub R13: u64, + pub R14: u64, + pub R15: u64, + pub Rip: u64, + pub Fp: __c_anonymous_CONTEXT_FP, + pub VectorRegister: [M128A; 26], + pub VectorControl: u64, + pub DebugControl: u64, + pub LastBranchToRip: u64, + pub LastBranchFromRip: u64, + pub LastExceptionToRip: u64, + pub LastExceptionFromRip: u64, + } +} |