diff --git a/.cirrus.yml b/.cirrus.yml index ff11c9cccb528..4c09801e7bedc 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -16,7 +16,7 @@ task: image: freebsd-15-0-release-amd64-ufs - name: nightly freebsd-14 x86_64 freebsd_instance: - image: freebsd-14-3-release-amd64-ufs + image: freebsd-14-4-release-amd64-ufs - name: nightly freebsd-15 x86_64 freebsd_instance: image: freebsd-15-0-release-amd64-ufs diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 17af6d3c62119..7203340862eb9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -36,7 +36,7 @@ jobs: name: Clippy on ${{ matrix.os }} strategy: matrix: - os: [ubuntu-24.04, macos-15, windows-2025] + os: [ubuntu-24.04, macos-26, windows-2025] runs-on: ${{ matrix.os }} timeout-minutes: 10 steps: @@ -109,7 +109,7 @@ jobs: matrix: include: - target: aarch64-apple-darwin - os: macos-15 + os: macos-26 - target: aarch64-pc-windows-msvc os: windows-11-arm - target: aarch64-unknown-linux-gnu @@ -209,7 +209,7 @@ jobs: - target: wasm32-wasip1 - target: wasm32-wasip2 - target: x86_64-apple-darwin - os: macos-15-intel + os: macos-26-intel - target: x86_64-linux-android # FIXME: Exec format error (os error 8) # - target: x86_64-unknown-linux-gnux32 @@ -273,7 +273,7 @@ jobs: steps: - uses: actions/checkout@v6 - name: test on Solaris - uses: vmactions/solaris-vm@v1.3.1 + uses: vmactions/solaris-vm@v1.3.2 if: contains(matrix.target, 'solaris') with: release: "11.4-gcc" diff --git a/ci/verify-build.py b/ci/verify-build.py index ce3410398eb34..d704002ccb449 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -287,14 +287,16 @@ def do_semver_checks(cfg: Cfg, target: Target) -> bool: "--features=std,extra_traits", "--release-type=patch", ], - check=True, + check=False, ) # Don't return here so we still get the same rustdoc-json-base tests even while # running on the host. if cfg.baseline_crate_dir is None: - eprint("Non-host target: --baseline-crate-dir must be specified to \ - run semver-checks") + eprint( + "Non-host target: --baseline-crate-dir must be specified to \ + run semver-checks" + ) sys.exit(1) # Since semver-checks doesn't work with `--target`, we build the json ourself and diff --git a/libc-test/build.rs b/libc-test/build.rs index 985ed0e3bd042..1153f56e1f5ff 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -342,6 +342,9 @@ fn test_apple(target: &str) { // FIXME(macos): The size is changed in recent macOSes. "malloc_introspection_t" if x86_64 => true, + + // FIXME(macos): The size is changed in macOS 26. + "vm_statistics64" => true, _ => false, } }); @@ -358,6 +361,21 @@ fn test_apple(target: &str) { // https://github.com/apple-oss-distributions/xnu/commit/e6231be02a03711ca404e5121a151b24afbff733 "TIOCREMOTE" => true, + // FIXME(macos): bumped up on macOS 26 + // https://github.com/apple-oss-distributions/xnu/commit/f6217f891ac0bb64f3d375211650a4c1ff8ca1ea + "ELAST" => true, + + // FIXME(macos): bumped up on macOS 26, it's sizeof `vm_statistics64_data_t` + "HOST_VM_INFO64_COUNT" => true, + + _ => false, + } + }); + + cfg.skip_alias(move |ty| { + match ty.ident() { + // FIXME(macos): The size is changed in macOS 26. + "vm_statistics64_data_t" => true, _ => false, } }); @@ -2875,6 +2893,9 @@ fn test_freebsd(target: &str) { // Added in FreeBSD 15 "AT_HWCAP3" | "AT_HWCAP4" if Some(15) > freebsd_ver => true, + // Added in FreeBSD 15 + "DTYPE_INOTIFY" | "DTYPE_JAILDESC" if Some(15) > freebsd_ver => true, + _ => false, } }); @@ -3997,8 +4018,9 @@ fn test_linux(target: &str) { "linux/can.h", "linux/can/bcm.h", "linux/can/error.h", - "linux/can/raw.h", "linux/can/j1939.h", + "linux/can/netlink.h", + "linux/can/raw.h", "linux/cn_proc.h", "linux/connector.h", "linux/dccp.h", @@ -4295,6 +4317,10 @@ fn test_linux(target: &str) { // FIXME(musl): New fields in newer versions "utmpx" if !old_musl => true, + // FIXME(linux): Requires >= 6.16 kernel headers. + // On 64 bits the size did not change, skip only for 32 bits. + "ptrace_syscall_info" if pointer_width == 32 => true, + _ => false, } }); @@ -4662,6 +4688,7 @@ fn test_linux(target: &str) { }); let c_enums = [ + "can_state", "membarrier_cmd", "pid_type", "proc_cn_event", @@ -4862,7 +4889,9 @@ fn test_linux(target: &str) { true } // the `u` field is in fact an anonymous union - ("ptrace_syscall_info", "u" | "pad") if gnu => true, + ("ptrace_syscall_info", "u") if gnu => true, + // FIXME(linux): `flags` requires >= 6.16 kernel headers + ("ptrace_syscall_info", "flags") if gnu => true, // the vregs field is a `__uint128_t` C's type. ("user_fpsimd_struct", "vregs") => true, // Linux >= 5.11 tweaked the `svm_zero` field of the `sockaddr_vm` struct. diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index a6acde40a9ba2..e48c6d8258566 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3449,6 +3449,7 @@ epoll_create1 epoll_ctl epoll_event epoll_wait +ethhdr eventfd eventfd_read eventfd_write diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 6d41c8c6cabd9..0b158da70a17a 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -500,6 +500,7 @@ IPV6_RECVPKTINFO IPV6_RECVTCLASS IPV6_TCLASS IP_HDRINCL +IP_MINTTL IP_RECVDSTADDR IP_RECVIF IP_RECVTTL diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index ba905e04a7fa7..79a81624074c9 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -669,6 +669,7 @@ IP_BINDANY IP_BINDMULTI IP_DONTFRAG IP_HDRINCL +IP_MINTTL IP_ORIGDSTADDR IP_RECVDSTADDR IP_RECVIF @@ -2434,4 +2435,5 @@ vmtotal wait4 waitid xallocx +xfile xucred diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 9b5a384b0d3f6..d8cf94d3512ce 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -597,6 +597,7 @@ dlvsym eaccess endutxent epoll_pwait2 +ethhdr euidaccess execveat explicit_bzero diff --git a/libc-test/semver/linux-riscv64gc.txt b/libc-test/semver/linux-riscv64gc.txt index 01609e899a709..3f0f93a13ac13 100644 --- a/libc-test/semver/linux-riscv64gc.txt +++ b/libc-test/semver/linux-riscv64gc.txt @@ -80,3 +80,4 @@ TIOCSRS485 flock64 fsblkcnt64_t fsfilcnt64_t +max_align_t diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index bd421d8d68c21..8e7a748ada4d3 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -234,6 +234,17 @@ CANXL_SEC CANXL_XLF CAN_BCM CAN_BUS_OFF_THRESHOLD +CAN_CTRLMODE_3_SAMPLES +CAN_CTRLMODE_BERR_REPORTING +CAN_CTRLMODE_CC_LEN8_DLC +CAN_CTRLMODE_FD +CAN_CTRLMODE_FD_NON_ISO +CAN_CTRLMODE_LISTENONLY +CAN_CTRLMODE_LOOPBACK +CAN_CTRLMODE_ONE_SHOT +CAN_CTRLMODE_PRESUME_ACK +CAN_CTRLMODE_TDC_AUTO +CAN_CTRLMODE_TDC_MANUAL CAN_EFF_FLAG CAN_EFF_ID_BITS CAN_EFF_MASK @@ -321,6 +332,13 @@ CAN_RAW_XL_FRAMES CAN_RTR_FLAG CAN_SFF_ID_BITS CAN_SFF_MASK +CAN_STATE_BUS_OFF +CAN_STATE_ERROR_ACTIVE +CAN_STATE_ERROR_PASSIVE +CAN_STATE_ERROR_WARNING +CAN_STATE_SLEEPING +CAN_STATE_STOPPED +CAN_TERMINATION_DISABLED CAN_TP16 CAN_TP20 CBAUD @@ -1055,6 +1073,36 @@ IFLA_AF_SPEC IFLA_ALLMULTI IFLA_ALT_IFNAME IFLA_BROADCAST +IFLA_CAN_BERR_COUNTER +IFLA_CAN_BITRATE_CONST +IFLA_CAN_BITRATE_MAX +IFLA_CAN_BITTIMING +IFLA_CAN_BITTIMING_CONST +IFLA_CAN_CLOCK +IFLA_CAN_CTRLMODE +IFLA_CAN_CTRLMODE_EXT +IFLA_CAN_CTRLMODE_SUPPORTED +IFLA_CAN_CTRLMODE_UNSPEC +IFLA_CAN_DATA_BITRATE_CONST +IFLA_CAN_DATA_BITTIMING +IFLA_CAN_DATA_BITTIMING_CONST +IFLA_CAN_RESTART +IFLA_CAN_RESTART_MS +IFLA_CAN_STATE +IFLA_CAN_TDC +IFLA_CAN_TDC_TDCF +IFLA_CAN_TDC_TDCF_MAX +IFLA_CAN_TDC_TDCF_MIN +IFLA_CAN_TDC_TDCO +IFLA_CAN_TDC_TDCO_MAX +IFLA_CAN_TDC_TDCO_MIN +IFLA_CAN_TDC_TDCV +IFLA_CAN_TDC_TDCV_MAX +IFLA_CAN_TDC_TDCV_MIN +IFLA_CAN_TDC_UNSPEC +IFLA_CAN_TERMINATION +IFLA_CAN_TERMINATION_CONST +IFLA_CAN_UNSPEC IFLA_CARRIER IFLA_CARRIER_CHANGES IFLA_CARRIER_DOWN_COUNT @@ -3959,9 +4007,16 @@ bcm_timeval blkcnt64_t brk bsearch +can_berr_counter +can_bittiming +can_bittiming_const +can_clock +can_ctrlmode +can_device_stats can_err_mask_t can_filter can_frame +can_state canfd_frame canid_t canxl_frame @@ -4093,6 +4148,7 @@ if_freenameindex if_nameindex ifaddrs ifconf +ifinfomsg ifreq in6_ifreq in6_pktinfo diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index 7b99a8c29cc3c..182d4e2b5a7b2 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -119,7 +119,9 @@ CLD_KILLED CLD_STOPPED CLD_TRAPPED CLOCK_PROCESS_CPUTIME_ID +CLOCK_PROF CLOCK_THREAD_CPUTIME_ID +CLOCK_VIRTUAL CMSG_DATA CMSG_FIRSTHDR CMSG_LEN diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 2b71394c4b845..083e25648045d 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -97,6 +97,7 @@ EUNATCH EUSERS EXFULL FIONREAD +F_DUPFD_CLOEXEC IMAXBEL IPPROTO_ICMP IPPROTO_IDP @@ -109,6 +110,8 @@ IPPROTO_TCP IPPROTO_UDP IPV6_ADD_MEMBERSHIP IPV6_DROP_MEMBERSHIP +IPV6_JOIN_GROUP +IPV6_LEAVE_GROUP IP_RECVTOS IP_TOS IUCLC @@ -162,6 +165,7 @@ RLIMIT_STACK RLIM_INFINITY RLIM_SAVED_CUR RLIM_SAVED_MAX +RTLD_NOLOAD RUSAGE_BOTH RUSAGE_CHILDREN RUSAGE_SELF @@ -187,7 +191,10 @@ SO_REUSEPORT SO_SNDBUFFORCE TCFLSH TCGETS +TCP_KEEPCNT TCP_KEEPIDLE +TCP_KEEPINTVL +TCP_MAXSEG TCSETS TIOCGPGRP TIOCSCTTY diff --git a/libc-test/semver/wasi.txt b/libc-test/semver/wasi.txt index 0a9e966ff56fa..5e7ab4b5192c8 100644 --- a/libc-test/semver/wasi.txt +++ b/libc-test/semver/wasi.txt @@ -1,5 +1,148 @@ FD_ISSET FD_SET FD_ZERO +_SC_2_CHAR_TERM +_SC_2_C_BIND +_SC_2_C_DEV +_SC_2_FORT_DEV +_SC_2_FORT_RUN +_SC_2_LOCALEDEF +_SC_2_PBS +_SC_2_PBS_ACCOUNTING +_SC_2_PBS_CHECKPOINT +_SC_2_PBS_LOCATE +_SC_2_PBS_MESSAGE +_SC_2_PBS_TRACK +_SC_2_SW_DEV +_SC_2_UPE +_SC_2_VERSION +_SC_ADVISORY_INFO +_SC_AIO_LISTIO_MAX +_SC_AIO_MAX +_SC_AIO_PRIO_DELTA_MAX +_SC_ARG_MAX +_SC_ASYNCHRONOUS_IO +_SC_ATEXIT_MAX +_SC_AVPHYS_PAGES +_SC_BARRIERS +_SC_BC_BASE_MAX +_SC_BC_DIM_MAX +_SC_BC_SCALE_MAX +_SC_BC_STRING_MAX +_SC_CHILD_MAX +_SC_CLK_TCK +_SC_CLOCK_SELECTION +_SC_COLL_WEIGHTS_MAX +_SC_CPUTIME +_SC_DELAYTIMER_MAX +_SC_EXPR_NEST_MAX +_SC_FSYNC +_SC_GETGR_R_SIZE_MAX +_SC_GETPW_R_SIZE_MAX +_SC_HOST_NAME_MAX +_SC_IOV_MAX +_SC_IPV6 +_SC_JOB_CONTROL +_SC_LINE_MAX +_SC_LOGIN_NAME_MAX +_SC_MAPPED_FILES +_SC_MEMLOCK +_SC_MEMLOCK_RANGE +_SC_MEMORY_PROTECTION +_SC_MESSAGE_PASSING +_SC_MINSIGSTKSZ +_SC_MONOTONIC_CLOCK +_SC_MQ_OPEN_MAX +_SC_MQ_PRIO_MAX +_SC_NGROUPS_MAX +_SC_NPROCESSORS_CONF +_SC_NPROCESSORS_ONLN +_SC_NZERO +_SC_OPEN_MAX +_SC_PAGESIZE +_SC_PAGE_SIZE +_SC_PASS_MAX +_SC_PHYS_PAGES +_SC_PRIORITIZED_IO +_SC_PRIORITY_SCHEDULING +_SC_RAW_SOCKETS +_SC_READER_WRITER_LOCKS +_SC_REALTIME_SIGNALS +_SC_REGEXP +_SC_RE_DUP_MAX +_SC_RTSIG_MAX +_SC_SAVED_IDS +_SC_SEMAPHORES +_SC_SEM_NSEMS_MAX +_SC_SEM_VALUE_MAX +_SC_SHARED_MEMORY_OBJECTS +_SC_SHELL +_SC_SIGQUEUE_MAX +_SC_SIGSTKSZ +_SC_SPAWN +_SC_SPIN_LOCKS +_SC_SPORADIC_SERVER +_SC_SS_REPL_MAX +_SC_STREAMS +_SC_STREAM_MAX +_SC_SYMLOOP_MAX +_SC_SYNCHRONIZED_IO +_SC_THREADS +_SC_THREAD_ATTR_STACKADDR +_SC_THREAD_ATTR_STACKSIZE +_SC_THREAD_CPUTIME +_SC_THREAD_DESTRUCTOR_ITERATIONS +_SC_THREAD_KEYS_MAX +_SC_THREAD_PRIORITY_SCHEDULING +_SC_THREAD_PRIO_INHERIT +_SC_THREAD_PRIO_PROTECT +_SC_THREAD_PROCESS_SHARED +_SC_THREAD_ROBUST_PRIO_INHERIT +_SC_THREAD_ROBUST_PRIO_PROTECT +_SC_THREAD_SAFE_FUNCTIONS +_SC_THREAD_SPORADIC_SERVER +_SC_THREAD_STACK_MIN +_SC_THREAD_THREADS_MAX +_SC_TIMEOUTS +_SC_TIMERS +_SC_TIMER_MAX +_SC_TRACE +_SC_TRACE_EVENT_FILTER +_SC_TRACE_EVENT_NAME_MAX +_SC_TRACE_INHERIT +_SC_TRACE_LOG +_SC_TRACE_NAME_MAX +_SC_TRACE_SYS_MAX +_SC_TRACE_USER_EVENT_MAX +_SC_TTY_NAME_MAX +_SC_TYPED_MEMORY_OBJECTS +_SC_TZNAME_MAX +_SC_UIO_MAXIOV +_SC_V6_ILP32_OFF32 +_SC_V6_ILP32_OFFBIG +_SC_V6_LP64_OFF64 +_SC_V6_LPBIG_OFFBIG +_SC_V7_ILP32_OFF32 +_SC_V7_ILP32_OFFBIG +_SC_V7_LP64_OFF64 +_SC_V7_LPBIG_OFFBIG +_SC_VERSION +_SC_XBS5_ILP32_OFF32 +_SC_XBS5_ILP32_OFFBIG +_SC_XBS5_LP64_OFF64 +_SC_XBS5_LPBIG_OFFBIG +_SC_XOPEN_CRYPT +_SC_XOPEN_ENH_I18N +_SC_XOPEN_LEGACY +_SC_XOPEN_REALTIME +_SC_XOPEN_REALTIME_THREADS +_SC_XOPEN_SHM +_SC_XOPEN_STREAMS +_SC_XOPEN_UNIX +_SC_XOPEN_VERSION +_SC_XOPEN_XCU_VERSION +_SC_XOPEN_XPG2 +_SC_XOPEN_XPG3 +_SC_XOPEN_XPG4 fd_set select diff --git a/libc-test/tests/primitive_types.rs b/libc-test/tests/primitive_types.rs deleted file mode 100644 index c125a92a58110..0000000000000 --- a/libc-test/tests/primitive_types.rs +++ /dev/null @@ -1,15 +0,0 @@ -use std::any::TypeId; - -macro_rules! ok { - ($($t:ident)*) => {$( - assert!(TypeId::of::() == TypeId::of::(), - "{} is wrong", stringify!($t)); - )*} -} - -#[test] -fn same() { - use std::ffi; - ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong - c_longlong c_ulonglong c_float c_double); -} diff --git a/libc-test/tests/style.rs b/libc-test/tests/style.rs index dcbe43bb59651..3cc70586d15e8 100644 --- a/libc-test/tests/style.rs +++ b/libc-test/tests/style.rs @@ -23,7 +23,9 @@ use style_lib::{ const SKIP_PREFIXES: &[&str] = &[ // Don't run the style checker on the reorganized portion of the crate while we figure // out what style we want. - "new/", "types.rs", + "new/", + "primitives.rs", + "types.rs", ]; #[test] diff --git a/src/lib.rs b/src/lib.rs index 76c668dca8d6b..a00de4e2e0638 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,7 @@ // Attributes needed when building as part of the standard library #![cfg_attr(feature = "rustc-dep-of-std", feature(link_cfg, no_core))] #![cfg_attr(feature = "rustc-dep-of-std", allow(internal_features))] +// Some targets don't need `link_cfg` and emit a warning. #![cfg_attr(feature = "rustc-dep-of-std", allow(unused_features))] // DIFF(1.0): The thread local references that raise this lint were removed in 1.0 #![cfg_attr(feature = "rustc-dep-of-std", allow(static_mut_refs))] diff --git a/src/new/apple/xnu/mach/arm/_structs.rs b/src/new/apple/xnu/mach/arm/_structs.rs index c0ebce437aedd..6160e773fd33b 100644 --- a/src/new/apple/xnu/mach/arm/_structs.rs +++ b/src/new/apple/xnu/mach/arm/_structs.rs @@ -24,7 +24,7 @@ s! { #[cfg(target_arch = "aarch64")] pub struct __darwin_arm_neon_state64 { - pub __v: [crate::__uint128_t; 32], + pub __v: [u128; 32], pub __fpsr: u32, pub __fpcr: u32, } diff --git a/src/new/freebsd/mod.rs b/src/new/freebsd/mod.rs index 87c2e487560be..eedf235d1e235 100644 --- a/src/new/freebsd/mod.rs +++ b/src/new/freebsd/mod.rs @@ -3,4 +3,5 @@ //! * Headers: //! * Symbol map: +pub(crate) mod sys; pub(crate) mod unistd; diff --git a/src/new/freebsd/sys/file.rs b/src/new/freebsd/sys/file.rs new file mode 100644 index 0000000000000..3072c1de7d763 --- /dev/null +++ b/src/new/freebsd/sys/file.rs @@ -0,0 +1,46 @@ +//! Header: `sys/file.h` +//! +//! https://github.com/freebsd/freebsd-src/blob/main/sys/sys/file.h + +use crate::prelude::*; + +pub const DTYPE_NONE: c_int = 0; +pub const DTYPE_VNODE: c_int = 1; +pub const DTYPE_SOCKET: c_int = 2; +pub const DTYPE_PIPE: c_int = 3; +pub const DTYPE_FIFO: c_int = 4; +pub const DTYPE_KQUEUE: c_int = 5; +pub const DTYPE_CRYPTO: c_int = 6; +pub const DTYPE_MQUEUE: c_int = 7; +pub const DTYPE_SHM: c_int = 8; +pub const DTYPE_SEM: c_int = 9; +pub const DTYPE_PTS: c_int = 10; +pub const DTYPE_DEV: c_int = 11; +pub const DTYPE_PROCDESC: c_int = 12; +pub const DTYPE_EVENTFD: c_int = 13; +pub const DTYPE_TIMERFD: c_int = 14; +pub const DTYPE_INOTIFY: c_int = 15; +pub const DTYPE_JAILDESC: c_int = 16; + +s! { + #[cfg(not(any(freebsd10, freebsd11)))] + pub struct xfile { + pub xf_size: crate::ksize_t, + pub xf_pid: crate::pid_t, + pub xf_uid: crate::uid_t, + pub xf_fd: c_int, + _xf_int_pad1: Padding, + pub xf_file: crate::kvaddr_t, + pub xf_type: c_short, + _xf_short_pad1: Padding, + pub xf_count: c_int, + pub xf_msgcount: c_int, + _xf_int_pad2: Padding, + pub xf_offset: crate::off_t, + pub xf_data: crate::kvaddr_t, + pub xf_vnode: crate::kvaddr_t, + pub xf_flag: c_uint, + _xf_int_pad3: Padding, + _xf_int64_pad: Padding<[i64; 6]>, + } +} diff --git a/src/new/freebsd/sys/mod.rs b/src/new/freebsd/sys/mod.rs new file mode 100644 index 0000000000000..210e674072c59 --- /dev/null +++ b/src/new/freebsd/sys/mod.rs @@ -0,0 +1,5 @@ +//! Directory: `sys/` +//! +//! https://github.com/freebsd/freebsd-src/tree/main/sys/sys' + +pub(crate) mod file; diff --git a/src/new/linux_uapi/linux/can.rs b/src/new/linux_uapi/linux/can.rs index 54148976e6254..c4ae2da584345 100644 --- a/src/new/linux_uapi/linux/can.rs +++ b/src/new/linux_uapi/linux/can.rs @@ -3,6 +3,7 @@ pub(crate) mod bcm; pub(crate) mod error; pub(crate) mod j1939; +pub(crate) mod netlink; pub(crate) mod raw; use crate::prelude::*; diff --git a/src/new/linux_uapi/linux/can/netlink.rs b/src/new/linux_uapi/linux/can/netlink.rs new file mode 100644 index 0000000000000..2892941090cb9 --- /dev/null +++ b/src/new/linux_uapi/linux/can/netlink.rs @@ -0,0 +1,125 @@ +//! Header: `linux/can/netlink.h` + +use crate::prelude::*; + +s! { + pub struct can_bittiming { + pub bitrate: u32, + pub sample_point: u32, + pub tq: u32, + pub prop_seg: u32, + pub phase_seg1: u32, + pub phase_seg2: u32, + pub sjw: u32, + pub brp: u32, + } + + pub struct can_bittiming_const { + pub name: [c_char; 16], + pub tseg1_min: u32, + pub tseg1_max: u32, + pub tseg2_min: u32, + pub tseg2_max: u32, + pub sjw_max: u32, + pub brp_min: u32, + pub brp_max: u32, + pub brp_inc: u32, + } + + pub struct can_clock { + pub freq: u32, + } + + pub struct can_berr_counter { + pub txerr: u16, + pub rxerr: u16, + } + + pub struct can_ctrlmode { + pub mask: u32, + pub flags: u32, + } + + pub struct can_device_stats { + pub bus_error: u32, + pub error_warning: u32, + pub error_passive: u32, + pub bus_off: u32, + pub arbitration_lost: u32, + pub restarts: u32, + } +} + +c_enum! { + #[repr(c_uint)] + pub enum can_state { + pub CAN_STATE_ERROR_ACTIVE = 0, + pub CAN_STATE_ERROR_WARNING, + pub CAN_STATE_ERROR_PASSIVE, + pub CAN_STATE_BUS_OFF, + pub CAN_STATE_STOPPED, + pub CAN_STATE_SLEEPING, + } +} + +pub const CAN_CTRLMODE_LOOPBACK: u32 = 0x01; +pub const CAN_CTRLMODE_LISTENONLY: u32 = 0x02; +pub const CAN_CTRLMODE_3_SAMPLES: u32 = 0x04; +pub const CAN_CTRLMODE_ONE_SHOT: u32 = 0x08; +pub const CAN_CTRLMODE_BERR_REPORTING: u32 = 0x10; +pub const CAN_CTRLMODE_FD: u32 = 0x20; +pub const CAN_CTRLMODE_PRESUME_ACK: u32 = 0x40; +pub const CAN_CTRLMODE_FD_NON_ISO: u32 = 0x80; +pub const CAN_CTRLMODE_CC_LEN8_DLC: u32 = 0x100; +pub const CAN_CTRLMODE_TDC_AUTO: u32 = 0x200; +pub const CAN_CTRLMODE_TDC_MANUAL: u32 = 0x400; + +c_enum! { + #[repr(c_int)] + pub enum #anon { + pub IFLA_CAN_UNSPEC = 0, + pub IFLA_CAN_BITTIMING, + pub IFLA_CAN_BITTIMING_CONST, + pub IFLA_CAN_CLOCK, + pub IFLA_CAN_STATE, + pub IFLA_CAN_CTRLMODE, + pub IFLA_CAN_RESTART_MS, + pub IFLA_CAN_RESTART, + pub IFLA_CAN_BERR_COUNTER, + pub IFLA_CAN_DATA_BITTIMING, + pub IFLA_CAN_DATA_BITTIMING_CONST, + pub IFLA_CAN_TERMINATION, + pub IFLA_CAN_TERMINATION_CONST, + pub IFLA_CAN_BITRATE_CONST, + pub IFLA_CAN_DATA_BITRATE_CONST, + pub IFLA_CAN_BITRATE_MAX, + pub IFLA_CAN_TDC, + pub IFLA_CAN_CTRLMODE_EXT, + } +} + +c_enum! { + #[repr(c_int)] + pub enum #anon { + pub IFLA_CAN_TDC_UNSPEC = 0, + pub IFLA_CAN_TDC_TDCV_MIN, + pub IFLA_CAN_TDC_TDCV_MAX, + pub IFLA_CAN_TDC_TDCO_MIN, + pub IFLA_CAN_TDC_TDCO_MAX, + pub IFLA_CAN_TDC_TDCF_MIN, + pub IFLA_CAN_TDC_TDCF_MAX, + pub IFLA_CAN_TDC_TDCV, + pub IFLA_CAN_TDC_TDCO, + pub IFLA_CAN_TDC_TDCF, + } +} + +c_enum! { + #[repr(c_int)] + pub enum #anon { + pub IFLA_CAN_CTRLMODE_UNSPEC = 0, + pub IFLA_CAN_CTRLMODE_SUPPORTED, + } +} + +pub const CAN_TERMINATION_DISABLED: u16 = 0; diff --git a/src/new/mod.rs b/src/new/mod.rs index c0c6891242ad4..1c5d6a6e17c25 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -179,6 +179,7 @@ cfg_if! { pub use linux::can::bcm::*; pub use linux::can::error::*; pub use linux::can::j1939::*; + pub use linux::can::netlink::*; pub use linux::can::raw::*; pub use linux::can::*; pub use linux::keyctl::*; @@ -210,6 +211,8 @@ cfg_if! { } else if #[cfg(target_os = "nto")] { pub use net::bpf::*; pub use net::if_::*; + } else if #[cfg(target_os = "freebsd")] { + pub use sys::file::*; } } diff --git a/src/new/netbsd/sys/time.rs b/src/new/netbsd/sys/time.rs index 5f2d39d347e69..b776b2a7db911 100644 --- a/src/new/netbsd/sys/time.rs +++ b/src/new/netbsd/sys/time.rs @@ -9,5 +9,7 @@ s! { } } +pub const CLOCK_VIRTUAL: crate::clockid_t = 1; +pub const CLOCK_PROF: crate::clockid_t = 2; pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 0x20000000; pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 0x40000000; diff --git a/src/primitives.rs b/src/primitives.rs index 80a10af4c8546..228dbc2c55467 100644 --- a/src/primitives.rs +++ b/src/primitives.rs @@ -6,63 +6,22 @@ //! //! The fixed-width integer aliases are deprecated: use the Rust types instead. -pub type c_schar = i8; -pub type c_uchar = u8; -pub type c_short = i16; -pub type c_ushort = u16; - -pub type c_longlong = i64; -pub type c_ulonglong = u64; - -pub type c_float = f32; -pub type c_double = f64; - -cfg_if! { - if #[cfg(all( - not(windows), - not(target_vendor = "apple"), - not(target_os = "vita"), - any( - target_arch = "aarch64", - target_arch = "arm", - target_arch = "csky", - target_arch = "hexagon", - target_arch = "msp430", - target_arch = "powerpc", - target_arch = "powerpc64", - target_arch = "riscv32", - target_arch = "riscv64", - target_arch = "s390x", - target_arch = "xtensa", - ) - ))] { - pub type c_char = u8; - } else { - // On every other target, c_char is signed. - pub type c_char = i8; - } -} - -cfg_if! { - if #[cfg(any(target_arch = "avr", target_arch = "msp430"))] { - pub type c_int = i16; - pub type c_uint = u16; - } else { - pub type c_int = i32; - pub type c_uint = u32; - } -} - -cfg_if! { - if #[cfg(all(target_pointer_width = "64", not(windows)))] { - pub type c_long = i64; - pub type c_ulong = u64; - } else { - // The minimal size of `long` in the C standard is 32 bits - pub type c_long = i32; - pub type c_ulong = u32; - } -} +// FIXME(1.0): Deprecate these aliases in a few releases, remove in 1.0. +pub use core::ffi::{ + c_char, + c_double, + c_float, + c_int, + c_long, + c_longlong, + c_schar, + c_short, + c_uchar, + c_uint, + c_ulong, + c_ulonglong, + c_ushort, +}; #[deprecated(since = "0.2.55", note = "Use i8 instead.")] pub type int8_t = i8; @@ -84,12 +43,16 @@ pub type uint64_t = u64; cfg_if! { if #[cfg(all(target_arch = "aarch64", not(target_os = "windows")))] { /// C `__int128` (a GCC extension that's part of many ABIs) + #[deprecated(since = "0.2.184", note = "Use i128 instead.")] pub type __int128 = i128; /// C `unsigned __int128` (a GCC extension that's part of many ABIs) + #[deprecated(since = "0.2.184", note = "Use u128 instead.")] pub type __uint128 = u128; /// C __int128_t (alternate name for [__int128][]) + #[deprecated(since = "0.2.184", note = "Use i128 instead.")] pub type __int128_t = i128; /// C __uint128_t (alternate name for [__uint128][]) + #[deprecated(since = "0.2.184", note = "Use u128 instead.")] pub type __uint128_t = u128; } } diff --git a/src/types.rs b/src/types.rs index c2873ddbf4f1b..1b41d6d0b6338 100644 --- a/src/types.rs +++ b/src/types.rs @@ -11,7 +11,7 @@ use crate::prelude::*; // This is restricted to `Copy` types since that's a loose indicator that zeros is actually // a valid bitpattern. There is no technical reason this is required, though, so it could be // lifted in the future if it becomes a problem. -#[allow(unused)] +#[allow(dead_code)] #[repr(transparent)] #[derive(Clone, Copy)] pub(crate) struct Padding(MaybeUninit); @@ -23,14 +23,10 @@ impl Default for Padding { } impl Padding { - /// Const constructor for uninitialized padding in const contexts. - // FIXME: Change this into zeroed() and use MaybeUninit::zeroed() - // when we depend on rustc 1.75.0. - #[allow(unused)] - pub(crate) const fn uninit() -> Self { - // We can still safely use uninit here, since padding is something - // that is not meant to be read or written anyways. - Self(MaybeUninit::uninit()) + /// Create a `Padding` initialized with the given value. + #[allow(dead_code)] + pub(crate) const fn new(val: T) -> Self { + Self(MaybeUninit::new(val)) } } diff --git a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs index 2d7a2b66621cf..984854261d764 100644 --- a/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64/mod.rs @@ -119,12 +119,12 @@ s! { pub mc_xfpustate: register_t, pub mc_xfpustate_len: register_t, // freebsd < 15 - #[cfg(any(freebsd11, freebsd12, freebsd13, freebsd14))] + #[cfg(any(freebsd11, freebsd12, freebsd13))] pub mc_spare: [c_long; 4], // freebsd >= 15 - #[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))] + #[cfg(not(any(freebsd11, freebsd12, freebsd13)))] pub mc_tlsbase: register_t, - #[cfg(not(any(freebsd11, freebsd12, freebsd13, freebsd14)))] + #[cfg(not(any(freebsd11, freebsd12, freebsd13)))] pub mc_spare: [c_long; 3], } } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 0ec0eecd6ede9..38fe66a11b8ea 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -935,6 +935,7 @@ pub const IP_ADD_MEMBERSHIP: c_int = 12; pub const IP_DROP_MEMBERSHIP: c_int = 13; pub const IP_RECVIF: c_int = 20; pub const IP_RECVTTL: c_int = 65; +pub const IP_MINTTL: c_int = 66; pub const IPV6_RECVHOPLIMIT: c_int = 37; pub const IPV6_JOIN_GROUP: c_int = 12; pub const IPV6_LEAVE_GROUP: c_int = 13; diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 27e77c28b4f24..f3d027ce34323 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1328,9 +1328,9 @@ cfg_if! { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ptm_magic: 0x33330003, ptm_errorcheck: 0, - ptm_pad1: Padding::uninit(), - ptm_unused: Padding::uninit(), - ptm_pad2: Padding::uninit(), + ptm_pad1: Padding::new([0; 3]), + ptm_unused: Padding::new(0), + ptm_pad2: Padding::new([0; 3]), ptm_waiters: 0 as *mut _, ptm_owner: 0, ptm_recursed: 0, @@ -1340,7 +1340,7 @@ cfg_if! { pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { ptm_magic: 0x33330003, ptm_errorcheck: 0, - ptm_unused: Padding::uninit(), + ptm_unused: Padding::new(0), ptm_waiters: 0 as *mut _, ptm_owner: 0, ptm_recursed: 0, diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index e190e18f4cd63..0c093a4c17726 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -1038,6 +1038,7 @@ pub const TIOCM_RTS: c_int = 0x004; pub const TIOCM_CTS: c_int = 0x020; pub const TIOCM_CAR: c_int = 0x040; pub const TIOCM_RNG: c_int = 0x080; +pub const TIOCM_DSR: c_int = 0x100; pub const TIOCM_CD: c_int = TIOCM_CAR; pub const TIOCM_RI: c_int = TIOCM_RNG; pub const TCOOFF: c_int = 0; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 87caa545c183a..cbb6464ed84b0 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1091,13 +1091,13 @@ pub const PTHREAD_STACK_MIN: size_t = 8192; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { flags: 0, lock: 0, - unused: Padding::uninit(), + unused: Padding::new(0), owner: -1, owner_count: 0, }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { flags: 0, - unused: Padding::uninit(), + unused: Padding::new(0), mutex: 0 as *mut _, waiter_count: 0, lock: 0, diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 7080de567a314..74b77d96f007e 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -3331,8 +3331,8 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { __shpid: 0, __type: PTHREAD_MUTEX_TIMED as c_int, __flags: 0, - __reserved1: Padding::uninit(), - __reserved2: Padding::uninit(), + __reserved1: Padding::new(0), + __reserved2: Padding::new(0), }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { __lock: __PTHREAD_SPIN_LOCK_INITIALIZER, diff --git a/src/unix/linux_like/android/b32/mod.rs b/src/unix/linux_like/android/b32/mod.rs index 7927a2390ccf2..d0c2349b98c62 100644 --- a/src/unix/linux_like/android/b32/mod.rs +++ b/src/unix/linux_like/android/b32/mod.rs @@ -209,7 +209,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { pendingReaders: 0, pendingWriters: 0, attr: 0, - __reserved: Padding::uninit(), + __reserved: Padding::new([0; 12]), }; pub const PTHREAD_STACK_MIN: size_t = 4096 * 2; pub const CPU_SETSIZE: size_t = 32; diff --git a/src/unix/linux_like/android/b64/aarch64/mod.rs b/src/unix/linux_like/android/b64/aarch64/mod.rs index 7c7a08fdf334f..3cc6fc837693e 100644 --- a/src/unix/linux_like/android/b64/aarch64/mod.rs +++ b/src/unix/linux_like/android/b64/aarch64/mod.rs @@ -78,7 +78,7 @@ s! { } pub struct user_fpsimd_struct { - pub vregs: [crate::__uint128_t; 32], + pub vregs: [u128; 32], pub fpsr: u32, pub fpcr: u32, } diff --git a/src/unix/linux_like/android/b64/mod.rs b/src/unix/linux_like/android/b64/mod.rs index 9fc1819379e56..84c35a57f674a 100644 --- a/src/unix/linux_like/android/b64/mod.rs +++ b/src/unix/linux_like/android/b64/mod.rs @@ -155,11 +155,11 @@ pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0, - __reserved: Padding::uninit(), + __reserved: Padding::new([0; 36]), }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { value: 0, - __reserved: Padding::uninit(), + __reserved: Padding::new([0; 44]), }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { numLocks: 0, @@ -167,7 +167,7 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { pendingReaders: 0, pendingWriters: 0, attr: 0, - __reserved: Padding::uninit(), + __reserved: Padding::new([0; 36]), }; pub const PTHREAD_STACK_MIN: size_t = 4096 * 4; pub const CPU_SETSIZE: size_t = 1024; diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index 1c186351dfc58..31d1dba3ecf1b 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -46,6 +46,7 @@ pub type __u16 = c_ushort; pub type __s16 = c_short; pub type __u32 = c_uint; pub type __s32 = c_int; +pub type __be16 = __u16; // linux/elf.h @@ -625,6 +626,15 @@ s_no_extra_traits! { pub ifc_ifcu: __c_anonymous_ifc_ifcu, } + // linux/if_ether.h + + #[repr(C, packed)] + pub struct ethhdr { + pub h_dest: [c_uchar; crate::ETH_ALEN as usize], + pub h_source: [c_uchar; crate::ETH_ALEN as usize], + pub h_proto: crate::__be16, + } + // Internal, for casts to access union fields struct sifields_sigchld { si_pid: crate::pid_t, diff --git a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs index d896257046df4..b8c55dc33c89f 100644 --- a/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs @@ -223,7 +223,7 @@ s! { } pub struct user_fpsimd_struct { - pub vregs: [crate::__uint128_t; 32], + pub vregs: [u128; 32], pub fpsr: c_uint, pub fpcr: c_uint, } diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs index 3438a510d3bf9..cbb1502ebcc01 100644 --- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs +++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs @@ -286,6 +286,11 @@ s_no_extra_traits! { pub __fcsr: c_uint, pub __glibc_reserved: [c_uint; 3], } + + #[repr(align(16))] + pub struct max_align_t { + priv_: [f32; 8], + } } pub const POSIX_FADV_DONTNEED: c_int = 4; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index f9805b0b021f7..65e94a19a517b 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -7,6 +7,7 @@ pub type __rlimit_resource_t = c_uint; pub type Lmid_t = c_long; pub type regoff_t = c_int; pub type __kernel_rwf_t = c_int; +pub type __be16 = crate::__u16; cfg_if! { if #[cfg(doc)] { @@ -201,11 +202,13 @@ s! { pub nr: crate::__u64, pub args: [crate::__u64; 6], pub ret_data: crate::__u32, + reserved2: Padding, } pub struct ptrace_syscall_info { pub op: crate::__u8, - pub pad: [crate::__u8; 3], + reserved: Padding, + pub flags: crate::__u16, pub arch: crate::__u32, pub instruction_pointer: crate::__u64, pub stack_pointer: crate::__u64, @@ -404,6 +407,15 @@ impl siginfo_t { } s_no_extra_traits! { + // linux/if_ether.h + + #[repr(C, packed)] + pub struct ethhdr { + pub h_dest: [c_uchar; crate::ETH_ALEN as usize], + pub h_source: [c_uchar; crate::ETH_ALEN as usize], + pub h_proto: crate::__be16, + } + // Internal, for casts to access union fields struct sifields_sigchld { si_pid: crate::pid_t, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index dacd357bbb36f..0d3e830b77e47 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1254,6 +1254,16 @@ s! { pub handle_type: c_int, pub f_handle: [c_uchar; 0], } + + // include/uapi/linux/rtnetlink.h + pub struct ifinfomsg { + pub ifi_family: c_uchar, + __ifi_pad: Padding, + pub ifi_type: c_ushort, + pub ifi_index: c_int, + pub ifi_flags: c_uint, + pub ifi_change: c_uint, + } } cfg_if! { diff --git a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs index e28310be3ee32..82df29bf43a1f 100644 --- a/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/aarch64/mod.rs @@ -102,7 +102,7 @@ s! { } pub struct user_fpsimd_struct { - pub vregs: [crate::__uint128_t; 32], + pub vregs: [u128; 32], pub fpsr: u32, pub fpcr: u32, } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 5f23744d276cf..6bde0295ba95a 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -234,7 +234,11 @@ pub const SIG_IGN: sighandler_t = 1 as sighandler_t; pub const SIG_ERR: sighandler_t = !0 as sighandler_t; cfg_if! { - if #[cfg(all(not(target_os = "nto"), not(target_os = "aix")))] { + if #[cfg(all( + not(target_os = "nto"), + not(target_os = "aix"), + not(target_os = "espidf") + ))] { pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; pub const DT_CHR: u8 = 2; diff --git a/src/unix/newlib/espidf/mod.rs b/src/unix/newlib/espidf/mod.rs index d3b01b883566b..b791bbe265368 100644 --- a/src/unix/newlib/espidf/mod.rs +++ b/src/unix/newlib/espidf/mod.rs @@ -99,6 +99,17 @@ pub const NSIG: size_t = 32; pub const SOMAXCONN: c_int = 128; +pub const DT_UNKNOWN: u8 = 0; +pub const DT_REG: u8 = 1; +pub const DT_DIR: u8 = 2; +// Not used by esp-idf, but still defined in headers. +pub const DT_CHR: u8 = 4; +pub const DT_BLK: u8 = 6; +pub const DT_FIFO: u8 = 8; +pub const DT_LNK: u8 = 10; +pub const DT_SOCK: u8 = 12; +pub const DT_WHT: u8 = 14; + extern "C" { pub fn pthread_create( native: *mut crate::pthread_t, diff --git a/src/unix/nuttx/mod.rs b/src/unix/nuttx/mod.rs index e3ad7bafd153c..150dc43557d29 100644 --- a/src/unix/nuttx/mod.rs +++ b/src/unix/nuttx/mod.rs @@ -512,6 +512,7 @@ pub const FIONBIO: i32 = 0x30a; pub const _SC_PAGESIZE: i32 = 0x36; pub const _SC_THREAD_STACK_MIN: i32 = 0x58; pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; +pub const _SC_HOST_NAME_MAX: i32 = 0x26; // signal.h pub const SIGHUP: c_int = 1; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 635d73027be3c..51766620c6705 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -353,6 +353,7 @@ pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); // dlfcn.h pub const RTLD_LAZY: c_int = 0x0001; pub const RTLD_NOW: c_int = 0x0002; +pub const RTLD_NOLOAD: c_int = 0x0004; pub const RTLD_GLOBAL: c_int = 0x0100; pub const RTLD_LOCAL: c_int = 0x0000; @@ -502,9 +503,7 @@ pub const F_GETFD: c_int = 1; pub const F_SETFD: c_int = 2; pub const F_GETFL: c_int = 3; pub const F_SETFL: c_int = 4; -// FIXME(redox): relibc { -pub const F_DUPFD_CLOEXEC: c_int = crate::F_DUPFD; -// } +pub const F_DUPFD_CLOEXEC: c_int = 1030; pub const FD_CLOEXEC: c_int = 0x0100_0000; pub const O_RDONLY: c_int = 0x0001_0000; pub const O_WRONLY: c_int = 0x0002_0000; @@ -530,13 +529,13 @@ pub const O_NOFOLLOW: c_int = -0x8000_0000; pub const O_NOCTTY: c_int = 0x00000200; // locale.h -pub const LC_ALL: c_int = 0; -pub const LC_COLLATE: c_int = 1; -pub const LC_CTYPE: c_int = 2; -pub const LC_MESSAGES: c_int = 3; -pub const LC_MONETARY: c_int = 4; -pub const LC_NUMERIC: c_int = 5; -pub const LC_TIME: c_int = 6; +pub const LC_COLLATE: c_int = 0; +pub const LC_CTYPE: c_int = 1; +pub const LC_MESSAGES: c_int = 2; +pub const LC_MONETARY: c_int = 3; +pub const LC_NUMERIC: c_int = 4; +pub const LC_TIME: c_int = 5; +pub const LC_ALL: c_int = 6; // netdb.h pub const AI_PASSIVE: c_int = 0x0001; @@ -574,7 +573,9 @@ pub const IPV6_MULTICAST_IF: c_int = 17; pub const IPV6_MULTICAST_HOPS: c_int = 18; pub const IPV6_MULTICAST_LOOP: c_int = 19; pub const IPV6_ADD_MEMBERSHIP: c_int = 20; +pub const IPV6_JOIN_GROUP: c_int = 20; pub const IPV6_DROP_MEMBERSHIP: c_int = 21; +pub const IPV6_LEAVE_GROUP: c_int = 21; pub const IPV6_V6ONLY: c_int = 26; pub const IP_MULTICAST_IF: c_int = 32; pub const IP_MULTICAST_TTL: c_int = 33; @@ -582,7 +583,7 @@ pub const IP_MULTICAST_LOOP: c_int = 34; pub const IP_ADD_MEMBERSHIP: c_int = 35; pub const IP_DROP_MEMBERSHIP: c_int = 36; pub const IP_TOS: c_int = 1; -pub const IP_RECVTOS: c_int = 2; +pub const IP_RECVTOS: c_int = 13; pub const IPPROTO_IGMP: c_int = 2; pub const IPPROTO_PUP: c_int = 12; pub const IPPROTO_IDP: c_int = 22; @@ -592,9 +593,10 @@ pub const IPPROTO_MAX: c_int = 255; // netinet/tcp.h pub const TCP_NODELAY: c_int = 1; -// FIXME(redox): relibc { -pub const TCP_KEEPIDLE: c_int = 1; -// } +pub const TCP_MAXSEG: c_int = 2; +pub const TCP_KEEPIDLE: c_int = 4; +pub const TCP_KEEPINTVL: c_int = 5; +pub const TCP_KEEPCNT: c_int = 6; // poll.h pub const POLLIN: c_short = 0x001; @@ -665,14 +667,14 @@ pub const SIGPWR: c_int = 30; pub const SIGSYS: c_int = 31; pub const NSIG: c_int = 32; -pub const SA_NOCLDWAIT: c_ulong = 0x0000_0002; -pub const SA_RESTORER: c_ulong = 0x0000_0004; // FIXME(redox): remove after relibc removes it -pub const SA_SIGINFO: c_ulong = 0x0200_0000; -pub const SA_ONSTACK: c_ulong = 0x0400_0000; -pub const SA_RESTART: c_ulong = 0x0800_0000; -pub const SA_NODEFER: c_ulong = 0x1000_0000; -pub const SA_RESETHAND: c_ulong = 0x2000_0000; -pub const SA_NOCLDSTOP: c_ulong = 0x4000_0000; +pub const SA_NOCLDWAIT: c_int = 0x0000_0002; +pub const SA_RESTORER: c_int = 0x0000_0004; // FIXME(redox): remove after relibc removes it +pub const SA_SIGINFO: c_int = 0x0200_0000; +pub const SA_ONSTACK: c_int = 0x0400_0000; +pub const SA_RESTART: c_int = 0x0800_0000; +pub const SA_NODEFER: c_int = 0x1000_0000; +pub const SA_RESETHAND: c_int = 0x2000_0000; +pub const SA_NOCLDSTOP: c_int = 0x4000_0000; // sys/file.h pub const LOCK_SH: c_int = 1; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 9e91dcd5b3a50..bc4d536896473 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -474,6 +474,14 @@ s! { pub mq_curmsgs: c_long, } + pub struct flock { + pub l_type: c_short, + pub l_whence: c_short, + pub l_start: c_longlong, + pub l_len: c_longlong, + pub l_pid: c_long, + } + pub struct winsize { pub ws_row: c_ushort, pub ws_col: c_ushort, @@ -1193,6 +1201,9 @@ pub const F_GETLK: c_int = 7; pub const F_SETLK: c_int = 8; pub const F_SETLKW: c_int = 9; pub const F_DUPFD_CLOEXEC: c_int = 14; +pub const F_RDLCK: c_int = 1; +pub const F_WRLCK: c_int = 2; +pub const F_UNLCK: c_int = 3; pub const LOG_EMERG: c_int = 0; pub const LOG_ALERT: c_int = 1; diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index cd4f508459155..e580df52ad224 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -400,10 +400,149 @@ pub const ENOTCAPABLE: c_int = 76; pub const EOPNOTSUPP: c_int = ENOTSUP; pub const EWOULDBLOCK: c_int = EAGAIN; +pub const _SC_ARG_MAX: c_int = 0; +pub const _SC_CHILD_MAX: c_int = 1; +pub const _SC_CLK_TCK: c_int = 2; +pub const _SC_NGROUPS_MAX: c_int = 3; +pub const _SC_OPEN_MAX: c_int = 4; +pub const _SC_STREAM_MAX: c_int = 5; +pub const _SC_TZNAME_MAX: c_int = 6; +pub const _SC_JOB_CONTROL: c_int = 7; +pub const _SC_SAVED_IDS: c_int = 8; +pub const _SC_REALTIME_SIGNALS: c_int = 9; +pub const _SC_PRIORITY_SCHEDULING: c_int = 10; +pub const _SC_TIMERS: c_int = 11; +pub const _SC_ASYNCHRONOUS_IO: c_int = 12; +pub const _SC_PRIORITIZED_IO: c_int = 13; +pub const _SC_SYNCHRONIZED_IO: c_int = 14; +pub const _SC_FSYNC: c_int = 15; +pub const _SC_MAPPED_FILES: c_int = 16; +pub const _SC_MEMLOCK: c_int = 17; +pub const _SC_MEMLOCK_RANGE: c_int = 18; +pub const _SC_MEMORY_PROTECTION: c_int = 19; +pub const _SC_MESSAGE_PASSING: c_int = 20; +pub const _SC_SEMAPHORES: c_int = 21; +pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22; +pub const _SC_AIO_LISTIO_MAX: c_int = 23; +pub const _SC_AIO_MAX: c_int = 24; +pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25; +pub const _SC_DELAYTIMER_MAX: c_int = 26; +pub const _SC_MQ_OPEN_MAX: c_int = 27; +pub const _SC_MQ_PRIO_MAX: c_int = 28; +pub const _SC_VERSION: c_int = 29; pub const _SC_PAGESIZE: c_int = 30; pub const _SC_PAGE_SIZE: c_int = _SC_PAGESIZE; +pub const _SC_RTSIG_MAX: c_int = 31; +pub const _SC_SEM_NSEMS_MAX: c_int = 32; +pub const _SC_SEM_VALUE_MAX: c_int = 33; +pub const _SC_SIGQUEUE_MAX: c_int = 34; +pub const _SC_TIMER_MAX: c_int = 35; +pub const _SC_BC_BASE_MAX: c_int = 36; +pub const _SC_BC_DIM_MAX: c_int = 37; +pub const _SC_BC_SCALE_MAX: c_int = 38; +pub const _SC_BC_STRING_MAX: c_int = 39; +pub const _SC_COLL_WEIGHTS_MAX: c_int = 40; +pub const _SC_EXPR_NEST_MAX: c_int = 42; +pub const _SC_LINE_MAX: c_int = 43; +pub const _SC_RE_DUP_MAX: c_int = 44; +pub const _SC_2_VERSION: c_int = 46; +pub const _SC_2_C_BIND: c_int = 47; +pub const _SC_2_C_DEV: c_int = 48; +pub const _SC_2_FORT_DEV: c_int = 49; +pub const _SC_2_FORT_RUN: c_int = 50; +pub const _SC_2_SW_DEV: c_int = 51; +pub const _SC_2_LOCALEDEF: c_int = 52; +pub const _SC_UIO_MAXIOV: c_int = 60; pub const _SC_IOV_MAX: c_int = 60; +pub const _SC_THREADS: c_int = 67; +pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68; +pub const _SC_GETGR_R_SIZE_MAX: c_int = 69; +pub const _SC_GETPW_R_SIZE_MAX: c_int = 70; +pub const _SC_LOGIN_NAME_MAX: c_int = 71; +pub const _SC_TTY_NAME_MAX: c_int = 72; +pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73; +pub const _SC_THREAD_KEYS_MAX: c_int = 74; +pub const _SC_THREAD_STACK_MIN: c_int = 75; +pub const _SC_THREAD_THREADS_MAX: c_int = 76; +pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77; +pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78; +pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79; +pub const _SC_THREAD_PRIO_INHERIT: c_int = 80; +pub const _SC_THREAD_PRIO_PROTECT: c_int = 81; +pub const _SC_THREAD_PROCESS_SHARED: c_int = 82; +pub const _SC_NPROCESSORS_CONF: c_int = 83; +pub const _SC_NPROCESSORS_ONLN: c_int = 84; +pub const _SC_PHYS_PAGES: c_int = 85; +pub const _SC_AVPHYS_PAGES: c_int = 86; +pub const _SC_ATEXIT_MAX: c_int = 87; +pub const _SC_PASS_MAX: c_int = 88; +pub const _SC_XOPEN_VERSION: c_int = 89; +pub const _SC_XOPEN_XCU_VERSION: c_int = 90; +pub const _SC_XOPEN_UNIX: c_int = 91; +pub const _SC_XOPEN_CRYPT: c_int = 92; +pub const _SC_XOPEN_ENH_I18N: c_int = 93; +pub const _SC_XOPEN_SHM: c_int = 94; +pub const _SC_2_CHAR_TERM: c_int = 95; +pub const _SC_2_UPE: c_int = 97; +pub const _SC_XOPEN_XPG2: c_int = 98; +pub const _SC_XOPEN_XPG3: c_int = 99; +pub const _SC_XOPEN_XPG4: c_int = 100; +pub const _SC_NZERO: c_int = 109; +pub const _SC_XBS5_ILP32_OFF32: c_int = 125; +pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126; +pub const _SC_XBS5_LP64_OFF64: c_int = 127; +pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128; +pub const _SC_XOPEN_LEGACY: c_int = 129; +pub const _SC_XOPEN_REALTIME: c_int = 130; +pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131; +pub const _SC_ADVISORY_INFO: c_int = 132; +pub const _SC_BARRIERS: c_int = 133; +pub const _SC_CLOCK_SELECTION: c_int = 137; +pub const _SC_CPUTIME: c_int = 138; +pub const _SC_THREAD_CPUTIME: c_int = 139; +pub const _SC_MONOTONIC_CLOCK: c_int = 149; +pub const _SC_READER_WRITER_LOCKS: c_int = 153; +pub const _SC_SPIN_LOCKS: c_int = 154; +pub const _SC_REGEXP: c_int = 155; +pub const _SC_SHELL: c_int = 157; +pub const _SC_SPAWN: c_int = 159; +pub const _SC_SPORADIC_SERVER: c_int = 160; +pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161; +pub const _SC_TIMEOUTS: c_int = 164; +pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165; +pub const _SC_2_PBS: c_int = 168; +pub const _SC_2_PBS_ACCOUNTING: c_int = 169; +pub const _SC_2_PBS_LOCATE: c_int = 170; +pub const _SC_2_PBS_MESSAGE: c_int = 171; +pub const _SC_2_PBS_TRACK: c_int = 172; pub const _SC_SYMLOOP_MAX: c_int = 173; +pub const _SC_STREAMS: c_int = 174; +pub const _SC_2_PBS_CHECKPOINT: c_int = 175; +pub const _SC_V6_ILP32_OFF32: c_int = 176; +pub const _SC_V6_ILP32_OFFBIG: c_int = 177; +pub const _SC_V6_LP64_OFF64: c_int = 178; +pub const _SC_V6_LPBIG_OFFBIG: c_int = 179; +pub const _SC_HOST_NAME_MAX: c_int = 180; +pub const _SC_TRACE: c_int = 181; +pub const _SC_TRACE_EVENT_FILTER: c_int = 182; +pub const _SC_TRACE_INHERIT: c_int = 183; +pub const _SC_TRACE_LOG: c_int = 184; +pub const _SC_IPV6: c_int = 235; +pub const _SC_RAW_SOCKETS: c_int = 236; +pub const _SC_V7_ILP32_OFF32: c_int = 237; +pub const _SC_V7_ILP32_OFFBIG: c_int = 238; +pub const _SC_V7_LP64_OFF64: c_int = 239; +pub const _SC_V7_LPBIG_OFFBIG: c_int = 240; +pub const _SC_SS_REPL_MAX: c_int = 241; +pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242; +pub const _SC_TRACE_NAME_MAX: c_int = 243; +pub const _SC_TRACE_SYS_MAX: c_int = 244; +pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245; +pub const _SC_XOPEN_STREAMS: c_int = 246; +pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; +pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; +pub const _SC_MINSIGSTKSZ: c_int = 249; +pub const _SC_SIGSTKSZ: c_int = 250; // FIXME(msrv): `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 #[allow(unused_unsafe)]