├── .gitignore ├── ctest-test ├── src │ ├── t1.cpp │ ├── t2.cpp │ ├── t2.c │ ├── lib.rs │ ├── bin │ │ ├── t1.rs │ │ └── t2.rs │ ├── t2.h │ └── t2.rs └── Cargo.toml ├── src ├── new │ ├── sgx │ │ ├── mod.rs │ │ └── unistd.rs │ ├── common │ │ ├── bsd.rs │ │ ├── netbsd_like.rs │ │ ├── solarish.rs │ │ ├── freebsd_like.rs │ │ ├── linux_like │ │ │ ├── mod.rs │ │ │ └── pthread.rs │ │ ├── posix │ │ │ ├── unistd.rs │ │ │ └── mod.rs │ │ └── mod.rs │ ├── xous │ │ └── mod.rs │ ├── bionic_libc │ │ ├── sys │ │ │ ├── mod.rs │ │ │ └── socket.rs │ │ ├── unistd.rs │ │ ├── mod.rs │ │ └── pthread.rs │ ├── hurd │ │ └── mod.rs │ ├── rtems │ │ └── mod.rs │ ├── trusty │ │ └── mod.rs │ ├── espidf │ │ └── mod.rs │ ├── horizon │ │ └── mod.rs │ ├── solid │ │ └── mod.rs │ ├── vita │ │ └── mod.rs │ ├── wasi │ │ └── mod.rs │ ├── redox │ │ └── mod.rs │ ├── nuttx │ │ ├── mod.rs │ │ └── unistd.rs │ ├── fuchsia │ │ ├── mod.rs │ │ └── unistd.rs │ ├── haiku │ │ ├── mod.rs │ │ └── unistd.rs │ ├── illumos │ │ ├── mod.rs │ │ └── unistd.rs │ ├── newlib │ │ └── mod.rs │ ├── nto │ │ ├── mod.rs │ │ └── unistd.rs │ ├── vxworks │ │ ├── mod.rs │ │ └── unistd.rs │ ├── linux_uapi │ │ ├── mod.rs │ │ └── linux │ │ │ ├── mod.rs │ │ │ └── can │ │ │ ├── raw.rs │ │ │ ├── bcm.rs │ │ │ └── j1939.rs │ ├── l4re │ │ └── mod.rs │ ├── teeos │ │ └── mod.rs │ ├── hermit_abi │ │ └── mod.rs │ ├── musl │ │ ├── arch │ │ │ ├── mips │ │ │ │ ├── bits │ │ │ │ │ └── socket.rs │ │ │ │ └── mod.rs │ │ │ ├── mips64 │ │ │ │ ├── bits │ │ │ │ │ └── socket.rs │ │ │ │ └── mod.rs │ │ │ ├── generic │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ ├── unistd.rs │ │ ├── mod.rs │ │ ├── sched.rs │ │ ├── pthread.rs │ │ └── sys │ │ │ └── socket.rs │ ├── openbsd │ │ ├── sys │ │ │ ├── mod.rs │ │ │ └── ipc.rs │ │ ├── unistd.rs │ │ └── mod.rs │ ├── relibc │ │ ├── mod.rs │ │ └── unistd.rs │ ├── cygwin │ │ ├── mod.rs │ │ └── unistd.rs │ ├── aix │ │ ├── unistd.rs │ │ └── mod.rs │ ├── solaris │ │ ├── mod.rs │ │ └── unistd.rs │ ├── dragonfly │ │ ├── unistd.rs │ │ └── mod.rs │ ├── freebsd │ │ ├── unistd.rs │ │ └── mod.rs │ ├── netbsd │ │ ├── unistd.rs │ │ ├── sys │ │ │ ├── mod.rs │ │ │ ├── types.rs │ │ │ ├── time.rs │ │ │ ├── ipc.rs │ │ │ └── statvfs.rs │ │ ├── mod.rs │ │ └── utmp_.rs │ ├── uclibc │ │ ├── unistd.rs │ │ ├── mod.rs │ │ └── pthread.rs │ ├── apple │ │ ├── libc │ │ │ ├── signal.rs │ │ │ └── unistd.rs │ │ ├── xnu │ │ │ ├── sys │ │ │ │ ├── signal.rs │ │ │ │ ├── mod.rs │ │ │ │ └── _types │ │ │ │ │ └── _ucontext.rs │ │ │ ├── machine │ │ │ │ └── _mcontext.rs │ │ │ ├── arm │ │ │ │ └── _mcontext.rs │ │ │ ├── i386 │ │ │ │ └── _mcontext.rs │ │ │ ├── mach │ │ │ │ ├── machine │ │ │ │ │ └── _structs.rs │ │ │ │ ├── mod.rs │ │ │ │ └── arm │ │ │ │ │ └── _structs.rs │ │ │ └── mod.rs │ │ ├── libpthread │ │ │ ├── pthread_ │ │ │ │ ├── sched.rs │ │ │ │ ├── stack_np.rs │ │ │ │ ├── pthread_impl.rs │ │ │ │ ├── pthread_spis.rs │ │ │ │ ├── spawn.rs │ │ │ │ ├── qos.rs │ │ │ │ └── introspection.rs │ │ │ ├── sys │ │ │ │ ├── qos.rs │ │ │ │ └── mod.rs │ │ │ └── mod.rs │ │ └── mod.rs │ ├── emscripten │ │ ├── unistd.rs │ │ ├── mod.rs │ │ ├── pthread.rs │ │ └── sched.rs │ ├── glibc │ │ ├── sysdeps │ │ │ ├── unix │ │ │ │ ├── mod.rs │ │ │ │ └── linux │ │ │ │ │ ├── mod.rs │ │ │ │ │ └── net │ │ │ │ │ └── route.rs │ │ │ └── nptl │ │ │ │ ├── mod.rs │ │ │ │ └── pthread.rs │ │ ├── posix │ │ │ └── unistd.rs │ │ └── mod.rs │ └── ucrt │ │ └── mod.rs ├── solid │ ├── aarch64.rs │ └── arm.rs ├── vxworks │ ├── arm.rs │ ├── x86.rs │ ├── aarch64.rs │ ├── powerpc.rs │ ├── powerpc64.rs │ ├── riscv32.rs │ ├── riscv64.rs │ └── x86_64.rs ├── unix │ ├── bsd │ │ ├── netbsdlike │ │ │ ├── openbsd │ │ │ │ ├── mips64.rs │ │ │ │ ├── sparc64.rs │ │ │ │ ├── x86.rs │ │ │ │ ├── arm.rs │ │ │ │ ├── powerpc.rs │ │ │ │ ├── powerpc64.rs │ │ │ │ ├── aarch64.rs │ │ │ │ ├── riscv64.rs │ │ │ │ └── x86_64.rs │ │ │ └── netbsd │ │ │ │ ├── x86.rs │ │ │ │ ├── sparc64.rs │ │ │ │ ├── powerpc.rs │ │ │ │ ├── mips.rs │ │ │ │ └── x86_64.rs │ │ ├── apple │ │ │ └── b64 │ │ │ │ └── aarch64 │ │ │ │ └── mod.rs │ │ └── freebsdlike │ │ │ └── freebsd │ │ │ ├── freebsd12 │ │ │ └── x86_64.rs │ │ │ ├── freebsd13 │ │ │ └── x86_64.rs │ │ │ ├── freebsd14 │ │ │ └── x86_64.rs │ │ │ ├── freebsd15 │ │ │ └── x86_64.rs │ │ │ ├── arm.rs │ │ │ ├── powerpc.rs │ │ │ ├── powerpc64.rs │ │ │ ├── freebsd11 │ │ │ ├── b64.rs │ │ │ └── b32.rs │ │ │ ├── aarch64.rs │ │ │ ├── riscv64.rs │ │ │ └── x86.rs │ ├── newlib │ │ ├── powerpc │ │ │ └── mod.rs │ │ ├── generic.rs │ │ ├── aarch64 │ │ │ └── mod.rs │ │ └── arm │ │ │ └── mod.rs │ ├── haiku │ │ ├── b32.rs │ │ ├── b64.rs │ │ └── x86_64.rs │ ├── linux_like │ │ └── linux │ │ │ ├── arch │ │ │ └── mod.rs │ │ │ └── musl │ │ │ └── b32 │ │ │ └── mod.rs │ ├── nto │ │ └── aarch64.rs │ └── solarish │ │ └── x86.rs ├── sgx.rs ├── switch.rs ├── xous.rs ├── windows │ ├── msvc │ │ └── mod.rs │ └── gnu │ │ └── mod.rs └── fuchsia │ └── riscv64.rs ├── libc-test ├── semver │ ├── netbsd-powerpc.txt │ ├── wasi.txt │ ├── windows-msvc.txt │ ├── netbsd-mips.txt │ ├── ios.txt │ ├── macos-aarch64.txt │ ├── windows-gnu.txt │ ├── linux-gnu-riscv64gc.txt │ ├── macos-i686.txt │ ├── macos.txt │ ├── emscripten.txt │ ├── macos-x86_64.txt │ ├── android-i686.txt │ ├── TODO-unix.txt │ ├── linux-gnu-s390x.txt │ ├── freebsd-x86_64.txt │ ├── fuchsia-x86_64.txt │ ├── netbsd-x86_64.txt │ ├── android-aarch64.txt │ ├── linux-powerpc-gnu.txt │ ├── linux-gnu-loongarch64.txt │ ├── linux-gnu-powerpc64.txt │ ├── trusty.txt │ ├── illumos.txt │ ├── espidf.txt │ ├── README.md │ ├── linux-gnu-x86_64.txt │ ├── netbsd-aarch64.txt │ ├── android-x86_64.txt │ ├── wasi-p2.txt │ ├── linux-musl.txt │ ├── android-riscv64.txt │ ├── linux-riscv64gc.txt │ ├── linux-aarch64.txt │ ├── solarish.txt │ ├── TODO-linux.txt │ ├── linux-s390x.txt │ └── linux-mips.txt ├── src │ ├── sigrt.c │ ├── errqueue.c │ ├── makedev.c │ └── cmsg.c ├── tests │ ├── ctest.rs │ ├── semver.rs │ ├── linux_elf.rs │ ├── linux_ipv6.rs │ ├── linux_fcntl.rs │ ├── linux_if_arp.rs │ ├── linux_termios.rs │ ├── linux_strerror_r.rs │ ├── primitive_types.rs │ ├── linux_kernel_version.rs │ ├── errqueue.rs │ ├── sigrt.rs │ └── style.rs └── Cargo.toml ├── ctest ├── tests │ └── input │ │ ├── hierarchy │ │ ├── bar │ │ │ └── mod.rs │ │ ├── lib.rs │ │ └── foo.rs │ │ ├── invalid_syntax.rs │ │ ├── macro.rs │ │ ├── macro.h │ │ ├── hierarchy.h │ │ ├── simple.out.c │ │ ├── simple.h │ │ └── simple.rs ├── askama.toml ├── src │ ├── ast │ │ ├── type_alias.rs │ │ ├── constant.rs │ │ ├── field.rs │ │ ├── parameter.rs │ │ ├── union.rs │ │ ├── structure.rs │ │ ├── static_variable.rs │ │ ├── function.rs │ │ └── mod.rs │ └── macro_expansion.rs ├── Cargo.toml └── LICENSE-MIT ├── .github ├── dependabot.yaml ├── ISSUE_TEMPLATE │ ├── api_request.md │ └── bug_report.md ├── workflows │ └── release.yaml └── PULL_REQUEST_TEMPLATE.md ├── ci ├── emscripten-entry.sh ├── docker │ ├── wasm32-unknown-emscripten │ │ ├── node-wrapper.sh │ │ └── Dockerfile │ ├── x86_64-unknown-linux-gnux32 │ │ └── Dockerfile │ ├── x86_64-unknown-linux-gnu │ │ └── Dockerfile │ ├── x86_64-unknown-redox │ │ └── Dockerfile │ ├── i686-unknown-linux-gnu │ │ └── Dockerfile │ ├── aarch64-unknown-linux-gnu │ │ └── Dockerfile │ ├── x86_64-unknown-linux-musl │ │ └── Dockerfile │ ├── powerpc64-unknown-linux-gnu │ │ └── Dockerfile │ ├── powerpc64le-unknown-linux-gnu │ │ └── Dockerfile │ ├── sparc64-unknown-linux-gnu │ │ └── Dockerfile │ ├── riscv64gc-unknown-linux-gnu │ │ └── Dockerfile │ ├── s390x-unknown-linux-gnu │ │ └── Dockerfile │ ├── loongarch64-unknown-linux-gnu │ │ └── Dockerfile │ ├── wasm32-wasip2 │ │ └── Dockerfile │ ├── arm-unknown-linux-gnueabihf │ │ └── Dockerfile │ ├── powerpc-unknown-linux-gnu │ │ └── Dockerfile │ ├── s390x-unknown-linux-musl │ │ └── Dockerfile │ ├── wasm32-wasip1 │ │ └── Dockerfile │ ├── asmjs-unknown-emscripten │ │ └── Dockerfile │ ├── aarch64-unknown-linux-musl │ │ └── Dockerfile │ ├── i686-unknown-linux-musl │ │ └── Dockerfile │ ├── powerpc64le-unknown-linux-musl │ │ └── Dockerfile │ ├── loongarch64-unknown-linux-musl │ │ └── Dockerfile │ ├── x86_64-linux-android │ │ └── Dockerfile │ ├── arm-unknown-linux-musleabihf │ │ └── Dockerfile │ ├── armv7-unknown-linux-uclibceabihf │ │ └── Dockerfile │ ├── i686-linux-android │ │ └── Dockerfile │ ├── arm-linux-androideabi │ │ └── Dockerfile │ └── aarch64-linux-android │ │ └── Dockerfile ├── android-install-ndk.sh ├── test-runner-linux ├── linux-s390x.sh ├── emscripten.sh ├── wasi.sh ├── prep-semver-baseline.sh ├── android-sysimage.sh ├── runtest-android.rs ├── install-rust.sh └── run.sh ├── tests └── const_fn.rs ├── .editorconfig ├── .git-blame-ignore-revs ├── .rustfmt.toml ├── LICENSE-MIT └── .cirrus.yml /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | *~ 3 | -------------------------------------------------------------------------------- /ctest-test/src/t1.cpp: -------------------------------------------------------------------------------- 1 | t1.c -------------------------------------------------------------------------------- /ctest-test/src/t2.cpp: -------------------------------------------------------------------------------- 1 | t2.c -------------------------------------------------------------------------------- /ctest-test/src/t2.c: -------------------------------------------------------------------------------- 1 | 2 | void T2a() {} 3 | -------------------------------------------------------------------------------- /src/new/sgx/mod.rs: -------------------------------------------------------------------------------- 1 | //! Fortanix SGX. 2 | -------------------------------------------------------------------------------- /src/solid/aarch64.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = u32; 2 | -------------------------------------------------------------------------------- /src/solid/arm.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = u32; 2 | -------------------------------------------------------------------------------- /src/vxworks/arm.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = u32; 2 | -------------------------------------------------------------------------------- /src/vxworks/x86.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = i32; 2 | -------------------------------------------------------------------------------- /src/vxworks/aarch64.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = u32; 2 | -------------------------------------------------------------------------------- /src/vxworks/powerpc.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = u32; 2 | -------------------------------------------------------------------------------- /src/vxworks/powerpc64.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = u32; 2 | -------------------------------------------------------------------------------- /src/vxworks/riscv32.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = i32; 2 | -------------------------------------------------------------------------------- /src/vxworks/riscv64.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = i32; 2 | -------------------------------------------------------------------------------- /src/vxworks/x86_64.rs: -------------------------------------------------------------------------------- 1 | pub type wchar_t = i32; 2 | -------------------------------------------------------------------------------- /src/new/common/bsd.rs: -------------------------------------------------------------------------------- 1 | //! Interfaces common across the BSD family. 2 | -------------------------------------------------------------------------------- /libc-test/semver/netbsd-powerpc.txt: -------------------------------------------------------------------------------- 1 | PT_GETREGS 2 | PT_SETREGS 3 | PT_STEP 4 | -------------------------------------------------------------------------------- /libc-test/semver/wasi.txt: -------------------------------------------------------------------------------- 1 | FD_ISSET 2 | FD_SET 3 | FD_ZERO 4 | fd_set 5 | select 6 | -------------------------------------------------------------------------------- /libc-test/semver/windows-msvc.txt: -------------------------------------------------------------------------------- 1 | EOTHER 2 | memccpy 3 | stricmp 4 | strnicmp 5 | -------------------------------------------------------------------------------- /src/new/xous/mod.rs: -------------------------------------------------------------------------------- 1 | //! Xous libc. 2 | // FIXME(xous): link to headers needed. 3 | -------------------------------------------------------------------------------- /src/new/bionic_libc/sys/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `sys/` 2 | 3 | pub(crate) mod socket; 4 | -------------------------------------------------------------------------------- /src/new/hurd/mod.rs: -------------------------------------------------------------------------------- 1 | //! GNU Hurd libc. 2 | // FIXME(hurd): link to headers needed. 3 | -------------------------------------------------------------------------------- /src/new/rtems/mod.rs: -------------------------------------------------------------------------------- 1 | //! RTEMS libc. 2 | // FIXME(rtems): link to headers needed. 3 | -------------------------------------------------------------------------------- /src/new/trusty/mod.rs: -------------------------------------------------------------------------------- 1 | //! Trusty libc. 2 | // FIXME(trusty): link to headers needed. 3 | -------------------------------------------------------------------------------- /src/new/espidf/mod.rs: -------------------------------------------------------------------------------- 1 | //! Expressif libc. 2 | // FIXME(espidf): link to headers needed. 3 | -------------------------------------------------------------------------------- /libc-test/semver/netbsd-mips.txt: -------------------------------------------------------------------------------- 1 | PT_GETFPREGS 2 | PT_GETREGS 3 | PT_SETFPREGS 4 | PT_SETREGS 5 | -------------------------------------------------------------------------------- /ctest/tests/input/hierarchy/bar/mod.rs: -------------------------------------------------------------------------------- 1 | #[allow(non_camel_case_types)] 2 | pub type in6_addr = u32; 3 | -------------------------------------------------------------------------------- /src/new/horizon/mod.rs: -------------------------------------------------------------------------------- 1 | //! Switch libc. 2 | // FIXME(horizon): link to headers or manpages needed. 3 | -------------------------------------------------------------------------------- /src/new/solid/mod.rs: -------------------------------------------------------------------------------- 1 | //! Kyoto Microcomputer SOLID. 2 | // FIXME(solid): link to headers needed. 3 | -------------------------------------------------------------------------------- /ctest/askama.toml: -------------------------------------------------------------------------------- 1 | [[escaper]] 2 | path = "askama::filters::Text" 3 | extensions = ["rs", "c", "cpp"] 4 | -------------------------------------------------------------------------------- /src/new/vita/mod.rs: -------------------------------------------------------------------------------- 1 | //! VITASDK system library. 2 | // FIXME(vita): link to headers or manpages needed. 3 | -------------------------------------------------------------------------------- /src/new/wasi/mod.rs: -------------------------------------------------------------------------------- 1 | //! WASI libc. 2 | //! 3 | //! * Headers: 4 | -------------------------------------------------------------------------------- /src/new/redox/mod.rs: -------------------------------------------------------------------------------- 1 | //! Redox libc. 2 | //! 3 | //! * Headers: 4 | -------------------------------------------------------------------------------- /src/new/nuttx/mod.rs: -------------------------------------------------------------------------------- 1 | //! RTEMS libc. 2 | // FIXME(nuttx): link to headers needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /libc-test/semver/ios.txt: -------------------------------------------------------------------------------- 1 | __darwin_arm_exception_state64 2 | __darwin_arm_neon_state64 3 | __darwin_arm_thread_state64 4 | -------------------------------------------------------------------------------- /src/new/fuchsia/mod.rs: -------------------------------------------------------------------------------- 1 | //! Fuschia libc. 2 | // FIXME(fuchsia): link to headers needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /src/new/haiku/mod.rs: -------------------------------------------------------------------------------- 1 | //! Haiku OS libc. 2 | // FIXME(haiku): link to headers needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /src/new/illumos/mod.rs: -------------------------------------------------------------------------------- 1 | //! Illumos libc. 2 | // FIXME(illumos): link to headers needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /src/new/newlib/mod.rs: -------------------------------------------------------------------------------- 1 | //! Newlib libc. 2 | // FIXME(newlib): link to headers needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /src/new/nto/mod.rs: -------------------------------------------------------------------------------- 1 | //! QNX Neutrino libc. 2 | // FIXME(nto): link to manpages needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /src/new/vxworks/mod.rs: -------------------------------------------------------------------------------- 1 | //! VxWorks libc. 2 | // FIXME(vxworks): link to headers needed. 3 | 4 | pub(crate) mod unistd; 5 | -------------------------------------------------------------------------------- /src/new/common/netbsd_like.rs: -------------------------------------------------------------------------------- 1 | //! Interfaces common in NetBSD-derived operating systems. This includes NetBSD and OpenBSD. 2 | -------------------------------------------------------------------------------- /src/new/common/solarish.rs: -------------------------------------------------------------------------------- 1 | //! Interfaces common in solaris-derived operating systems. This includes Solaris and Illumos. 2 | -------------------------------------------------------------------------------- /src/new/linux_uapi/mod.rs: -------------------------------------------------------------------------------- 1 | //! This directory maps to `include/uapi` in the Linux source tree. 2 | 3 | pub(crate) mod linux; 4 | -------------------------------------------------------------------------------- /libc-test/semver/macos-aarch64.txt: -------------------------------------------------------------------------------- 1 | __darwin_arm_exception_state64 2 | __darwin_arm_neon_state64 3 | __darwin_arm_thread_state64 4 | -------------------------------------------------------------------------------- /src/new/l4re/mod.rs: -------------------------------------------------------------------------------- 1 | //! L4re. 2 | //! 3 | //! * Headers: 4 | -------------------------------------------------------------------------------- /src/new/teeos/mod.rs: -------------------------------------------------------------------------------- 1 | //! Per the target docs, TEEOS uses part of musl as its libc. 2 | // FIXME(teeos): link to headers needed. 3 | -------------------------------------------------------------------------------- /src/new/common/freebsd_like.rs: -------------------------------------------------------------------------------- 1 | //! Interfaces common in FreeBSD-derived operating systems. This includes FreeBSD and DragonFlyBSD. 2 | -------------------------------------------------------------------------------- /src/new/hermit_abi/mod.rs: -------------------------------------------------------------------------------- 1 | //! Hermit kernel libc. 2 | //! 3 | //! * Headers: 4 | -------------------------------------------------------------------------------- /ctest-test/src/lib.rs: -------------------------------------------------------------------------------- 1 | // src/** is mostly dummy files 2 | #![allow(clippy::style, clippy::correctness)] 3 | 4 | pub mod t1; 5 | pub mod t2; 6 | -------------------------------------------------------------------------------- /libc-test/semver/windows-gnu.txt: -------------------------------------------------------------------------------- 1 | STDERR_FILENO 2 | STDIN_FILENO 3 | STDOUT_FILENO 4 | max_align_t 5 | strcasecmp 6 | strncasecmp 7 | wmemchr 8 | -------------------------------------------------------------------------------- /src/new/musl/arch/mips/bits/socket.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub const SOCK_STREAM: c_int = 2; 4 | pub const SOCK_DGRAM: c_int = 1; 5 | -------------------------------------------------------------------------------- /src/new/musl/arch/mips64/bits/socket.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub const SOCK_STREAM: c_int = 2; 4 | pub const SOCK_DGRAM: c_int = 1; 5 | -------------------------------------------------------------------------------- /src/new/openbsd/sys/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `sys/` 2 | //! 3 | //! https://github.com/openbsd/src/tree/trunk/sys/sys 4 | 5 | pub(crate) mod ipc; 6 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/mips64.rs: -------------------------------------------------------------------------------- 1 | #[doc(hidden)] 2 | pub const _ALIGNBYTES: usize = 7; 3 | 4 | pub const _MAX_PAGE_SHIFT: u32 = 14; 5 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/sparc64.rs: -------------------------------------------------------------------------------- 1 | #[doc(hidden)] 2 | pub const _ALIGNBYTES: usize = 0xf; 3 | 4 | pub const _MAX_PAGE_SHIFT: u32 = 13; 5 | -------------------------------------------------------------------------------- /src/new/relibc/mod.rs: -------------------------------------------------------------------------------- 1 | //! Redox OS libc. 2 | //! 3 | //! * Headers: 4 | 5 | pub(crate) mod unistd; 6 | -------------------------------------------------------------------------------- /ctest/tests/input/invalid_syntax.rs: -------------------------------------------------------------------------------- 1 | struct Foo { 2 | a: int, 3 | b: u8; 4 | } 5 | 6 | unin Bar { 7 | x: u8, 8 | y: u8 9 | } 10 | -------------------------------------------------------------------------------- /ctest-test/src/bin/t1.rs: -------------------------------------------------------------------------------- 1 | #![cfg(not(test))] 2 | #![deny(warnings)] 3 | 4 | use ctest_test::t1::*; 5 | 6 | include!(concat!(env!("OUT_DIR"), "/t1gen.rs")); 7 | -------------------------------------------------------------------------------- /ctest-test/src/bin/t2.rs: -------------------------------------------------------------------------------- 1 | #![cfg(not(test))] 2 | #![deny(warnings)] 3 | 4 | use ctest_test::t2::*; 5 | 6 | include!(concat!(env!("OUT_DIR"), "/t2gen.rs")); 7 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "weekly" 7 | -------------------------------------------------------------------------------- /libc-test/semver/linux-gnu-riscv64gc.txt: -------------------------------------------------------------------------------- 1 | PTRACE_GETFPREGS 2 | PTRACE_GETFPXREGS 3 | PTRACE_GETREGS 4 | PTRACE_SETFPREGS 5 | PTRACE_SETFPXREGS 6 | PTRACE_SETREGS 7 | -------------------------------------------------------------------------------- /libc-test/src/sigrt.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int sigrtmax() { 4 | return SIGRTMAX; 5 | } 6 | 7 | int sigrtmin() { 8 | return SIGRTMIN; 9 | } 10 | -------------------------------------------------------------------------------- /libc-test/tests/ctest.rs: -------------------------------------------------------------------------------- 1 | #![allow(deprecated)] 2 | 3 | #[allow(unused_imports)] 4 | use libc::*; 5 | 6 | include!(concat!(env!("OUT_DIR"), "/ctest_output.rs")); 7 | -------------------------------------------------------------------------------- /src/new/cygwin/mod.rs: -------------------------------------------------------------------------------- 1 | //! Cygwin libc. 2 | //! 3 | //! * Headers: 4 | 5 | pub(crate) mod unistd; 6 | -------------------------------------------------------------------------------- /ci/emscripten-entry.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux 4 | 5 | # shellcheck disable=SC1091 6 | source /emsdk-portable/emsdk_env.sh &> /dev/null 7 | 8 | exec "$@" 9 | -------------------------------------------------------------------------------- /libc-test/semver/macos-i686.txt: -------------------------------------------------------------------------------- 1 | __darwin_mmst_reg 2 | __darwin_x86_exception_state64 3 | __darwin_x86_float_state64 4 | __darwin_x86_thread_state64 5 | __darwin_xmm_reg 6 | -------------------------------------------------------------------------------- /libc-test/semver/macos.txt: -------------------------------------------------------------------------------- 1 | CLOCK_MONOTONIC_RAW 2 | CLOCK_MONOTONIC_RAW_APPROX 3 | CLOCK_UPTIME_RAW 4 | CLOCK_UPTIME_RAW_APPROX 5 | clock_settime 6 | memmem 7 | task_set_info 8 | -------------------------------------------------------------------------------- /src/new/aix/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/musl/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/nto/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/sgx/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/solaris/mod.rs: -------------------------------------------------------------------------------- 1 | //! Solaris libc. 2 | //! 3 | //! * Manual pages: (under "Reference Manuals") 4 | 5 | pub(crate) mod unistd; 6 | -------------------------------------------------------------------------------- /tests/const_fn.rs: -------------------------------------------------------------------------------- 1 | #[cfg(target_os = "linux")] 2 | const _FOO: libc::c_uint = unsafe { libc::CMSG_SPACE(1) }; 3 | //^ if CMSG_SPACE is not const, this will fail to compile 4 | -------------------------------------------------------------------------------- /libc-test/semver/emscripten.txt: -------------------------------------------------------------------------------- 1 | AT_EACCESS 2 | getentropy 3 | getgrgid 4 | getgrgid_r 5 | getgrnam 6 | getgrnam_r 7 | getpwnam_r 8 | getpwuid_r 9 | posix_fallocate64 10 | -------------------------------------------------------------------------------- /src/new/cygwin/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/dragonfly/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/freebsd/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/fuchsia/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/haiku/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/illumos/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/netbsd/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/nuttx/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/openbsd/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/relibc/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/solaris/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/uclibc/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/vxworks/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/x86.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 4 | 5 | pub const _MAX_PAGE_SHIFT: u32 = 12; 6 | -------------------------------------------------------------------------------- /ctest/tests/input/hierarchy/lib.rs: -------------------------------------------------------------------------------- 1 | // Ensure that our crate is able to handle definitions spread across many files 2 | 3 | mod bar; 4 | mod foo; 5 | 6 | use bar::*; 7 | use foo::*; 8 | -------------------------------------------------------------------------------- /src/new/apple/libc/signal.rs: -------------------------------------------------------------------------------- 1 | //! Header: `signal.h` 2 | //! 3 | //! 4 | 5 | pub use crate::sys::signal::*; 6 | -------------------------------------------------------------------------------- /src/new/apple/libc/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/bionic_libc/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/new/emscripten/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::posix::unistd::{ 4 | STDERR_FILENO, 5 | STDIN_FILENO, 6 | STDOUT_FILENO, 7 | }; 8 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/netbsd/x86.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type __cpu_simple_lock_nv_t = c_uchar; 4 | 5 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 6 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/arm.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 4 | 5 | pub const _MAX_PAGE_SHIFT: u32 = 12; 6 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/powerpc.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 4 | 5 | pub const _MAX_PAGE_SHIFT: u32 = 12; 6 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/powerpc64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 4 | 5 | pub const _MAX_PAGE_SHIFT: u32 = 12; 6 | -------------------------------------------------------------------------------- /src/new/linux_uapi/linux/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `linux/` 2 | //! 3 | //! 4 | 5 | pub(crate) mod can; 6 | pub(crate) mod keyctl; 7 | -------------------------------------------------------------------------------- /libc-test/semver/macos-x86_64.txt: -------------------------------------------------------------------------------- 1 | __darwin_mmst_reg 2 | __darwin_x86_exception_state64 3 | __darwin_x86_float_state64 4 | __darwin_x86_thread_state64 5 | __darwin_xmm_reg 6 | malloc_introspection_t 7 | -------------------------------------------------------------------------------- /src/new/musl/arch/mips/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `arch/mips/` 2 | //! 3 | //! 4 | 5 | pub(crate) mod bits { 6 | pub(crate) mod socket; 7 | } 8 | -------------------------------------------------------------------------------- /src/new/uclibc/mod.rs: -------------------------------------------------------------------------------- 1 | //! uClibc. 2 | //! 3 | //! * About: 4 | //! * Headers: (mirror) 5 | 6 | pub(crate) mod pthread; 7 | pub(crate) mod unistd; 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*.sh] 2 | # See https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd#examples 3 | indent_style = space 4 | indent_size = 4 5 | 6 | switch_case_indent = true 7 | space_redirects = true 8 | -------------------------------------------------------------------------------- /libc-test/semver/android-i686.txt: -------------------------------------------------------------------------------- 1 | AT_SYSINFO 2 | AT_SYSINFO_EHDR 3 | AT_VECTOR_SIZE_ARCH 4 | SYS_memfd_secret 5 | __c_anonymous_uc_sigmask 6 | __c_anonymous_uc_sigmask_with_padding 7 | time64_t 8 | timegm64 9 | -------------------------------------------------------------------------------- /src/new/glibc/sysdeps/unix/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `sysdeps/unix/` 2 | //! 3 | //! 4 | 5 | #[cfg(target_os = "linux")] 6 | pub(crate) mod linux; 7 | -------------------------------------------------------------------------------- /src/new/musl/arch/generic/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `arch/generic/` 2 | //! 3 | //! 4 | 5 | pub(crate) mod bits { 6 | // Currently unused 7 | } 8 | -------------------------------------------------------------------------------- /src/new/musl/arch/mips64/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `arch/mips64/` 2 | //! 3 | //! 4 | 5 | pub(crate) mod bits { 6 | pub(crate) mod socket; 7 | } 8 | -------------------------------------------------------------------------------- /src/new/openbsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! OpenBSD libc. 2 | //! 3 | //! * Headers: 4 | //! * Manual pages: 5 | 6 | pub(crate) mod sys; 7 | pub(crate) mod unistd; 8 | -------------------------------------------------------------------------------- /src/new/aix/mod.rs: -------------------------------------------------------------------------------- 1 | //! IBM AIX libc. 2 | //! 3 | //! * Headers are not public 4 | //! * Manual pages: (under "Technical reference" for that version) 5 | 6 | pub(crate) mod unistd; 7 | -------------------------------------------------------------------------------- /ci/docker/wasm32-unknown-emscripten/node-wrapper.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eux 4 | 5 | me="$1" 6 | shift 7 | dir=$(dirname "$me") 8 | file=$(basename "$me") 9 | 10 | cd "$dir" 11 | exec node "$file" "$@" 12 | -------------------------------------------------------------------------------- /src/new/dragonfly/mod.rs: -------------------------------------------------------------------------------- 1 | //! DragonFly BSD libc. 2 | //! 3 | //! * Headers: 4 | //! * Manual pages: 5 | 6 | pub(crate) mod unistd; 7 | -------------------------------------------------------------------------------- /src/new/glibc/sysdeps/nptl/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `sysdeps/nptl/`o 2 | //! 3 | //! Native POSIX threading library. 4 | //! 5 | //! 6 | 7 | pub(crate) mod pthread; 8 | -------------------------------------------------------------------------------- /src/new/emscripten/mod.rs: -------------------------------------------------------------------------------- 1 | //! Emscripten libc. 2 | //! 3 | //! * Headers: 4 | 5 | pub(crate) mod pthread; 6 | pub(crate) mod sched; 7 | pub(crate) mod unistd; 8 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/netbsd/sparc64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type __cpu_simple_lock_nv_t = c_uchar; 4 | 5 | // should be pub(crate), but that requires Rust 1.18.0 6 | #[doc(hidden)] 7 | pub const _ALIGNBYTES: usize = 0xf; 8 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # Format macro bodies 2 | a0c7f8017b964a2de8bc3aabebdabd4a8f2c0905 3 | 4 | # Automated changes related to the 2021 edition upgrade 5 | 20f6aa4c8135ba5e2c079ff21b20f0a1be87e1c4 6 | f8a018a8e3efaf8cc4fbad84974255b0fa899fc2 7 | -------------------------------------------------------------------------------- /ci/docker/x86_64-unknown-linux-gnux32/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc-multilib \ 6 | libc6-dev 7 | 8 | ENV PATH=$PATH:/rust/bin 9 | -------------------------------------------------------------------------------- /src/new/apple/xnu/sys/signal.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/signal.h` 2 | //! 3 | //! 4 | 5 | pub use crate::machine::_mcontext::*; 6 | pub use crate::sys::_types::_ucontext::*; 7 | -------------------------------------------------------------------------------- /.rustfmt.toml: -------------------------------------------------------------------------------- 1 | edition = "2021" 2 | error_on_line_overflow = true 3 | group_imports = "StdExternalCrate" 4 | imports_granularity = "Module" 5 | # This crate gets large lists of reexports. Use vertical to reduce conflicts. 6 | imports_layout = "Vertical" 7 | -------------------------------------------------------------------------------- /src/new/netbsd/sys/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `sys/` 2 | //! 3 | //! https://github.com/NetBSD/src/tree/trunk/sys/sys 4 | 5 | pub(crate) mod ipc; 6 | pub(crate) mod statvfs; 7 | pub(crate) mod time; 8 | pub(crate) mod timex; 9 | pub(crate) mod types; 10 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/sched.rs: -------------------------------------------------------------------------------- 1 | pub use crate::new::pthread_::pthread_impl::*; 2 | use crate::prelude::*; 3 | 4 | s! { 5 | pub struct sched_param { 6 | pub sched_priority: c_int, 7 | __opaque: [c_char; 4], 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /libc-test/semver/TODO-unix.txt: -------------------------------------------------------------------------------- 1 | # These symbols are no-op or missing on these targets: 2 | # * wasm32-unknown-emscripten 3 | getpwuid_r 4 | pthread_atfork 5 | pthread_sigmask 6 | # * Solaris is missing flock(2) 7 | LOCK_EX 8 | LOCK_NB 9 | LOCK_SH 10 | LOCK_UN 11 | -------------------------------------------------------------------------------- /src/new/glibc/posix/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | //! 3 | //! 4 | 5 | pub use crate::new::common::posix::unistd::{ 6 | STDERR_FILENO, 7 | STDIN_FILENO, 8 | STDOUT_FILENO, 9 | }; 10 | -------------------------------------------------------------------------------- /ctest/tests/input/hierarchy/foo.rs: -------------------------------------------------------------------------------- 1 | use crate::bar::in6_addr; 2 | use std::os::raw::c_void; 3 | 4 | pub const ON: bool = true; 5 | 6 | unsafe extern "C" { 7 | pub fn malloc(size: usize) -> *mut c_void; 8 | 9 | pub static in6addr_any: in6_addr; 10 | } 11 | -------------------------------------------------------------------------------- /libc-test/semver/linux-gnu-s390x.txt: -------------------------------------------------------------------------------- 1 | PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 2 | PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP 3 | PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 4 | getcontext 5 | makecontext 6 | mcontext_t 7 | setcontext 8 | swapcontext 9 | sysctl 10 | ucontext_t 11 | -------------------------------------------------------------------------------- /src/new/freebsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! FreeBSD libc. 2 | //! 3 | //! * Headers: 4 | //! * Symbol map: 5 | 6 | pub(crate) mod unistd; 7 | -------------------------------------------------------------------------------- /ctest/tests/input/macro.rs: -------------------------------------------------------------------------------- 1 | macro_rules! vector { 2 | ($name:ident, $ty:ty) => { 3 | #[repr(C)] 4 | struct $name { 5 | pub x: $ty, 6 | pub y: $ty, 7 | } 8 | }; 9 | } 10 | 11 | vector!(VecU8, u8); 12 | vector!(VecU16, u16); 13 | -------------------------------------------------------------------------------- /src/new/bionic_libc/mod.rs: -------------------------------------------------------------------------------- 1 | //! This directory maps to `bionic/libc/include` in the Android source. 2 | //! 3 | //! 4 | 5 | pub(crate) mod pthread; 6 | pub(crate) mod sys; 7 | pub(crate) mod unistd; 8 | -------------------------------------------------------------------------------- /src/new/musl/arch/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `arch/` 2 | //! 3 | //! 4 | 5 | pub(crate) mod generic; 6 | 7 | #[cfg(target_arch = "mips")] 8 | pub(crate) mod mips; 9 | #[cfg(target_arch = "mips64")] 10 | pub(crate) mod mips64; 11 | -------------------------------------------------------------------------------- /ci/docker/x86_64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | libc6-dev 7 | 8 | RUN apt search linux-headers 9 | RUN ls /usr/src 10 | 11 | ENV PATH=$PATH:/rust/bin 12 | -------------------------------------------------------------------------------- /libc-test/tests/semver.rs: -------------------------------------------------------------------------------- 1 | #![allow(unused_imports)] 2 | #![allow(deprecated)] 3 | 4 | // Generated in `build.rs`. 5 | include!(concat!(env!("OUT_DIR"), "/semver.rs")); 6 | 7 | fn main() { 8 | // The test is about the imports created in `semver.rs`. 9 | println!("PASSED 1 tests"); 10 | } 11 | -------------------------------------------------------------------------------- /src/new/common/linux_like/mod.rs: -------------------------------------------------------------------------------- 1 | //! API that primarily comes from Linux but is also used other platforms (e.g. Android). 2 | 3 | #[cfg(any( 4 | target_os = "android", 5 | target_os = "emscripten", 6 | target_os = "l4re", 7 | target_os = "linux" 8 | ))] 9 | pub(crate) mod pthread; 10 | -------------------------------------------------------------------------------- /src/new/common/posix/unistd.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | pub const STDIN_FILENO: c_int = 0; 8 | pub const STDOUT_FILENO: c_int = 1; 9 | pub const STDERR_FILENO: c_int = 2; 10 | -------------------------------------------------------------------------------- /libc-test/tests/linux_elf.rs: -------------------------------------------------------------------------------- 1 | #![allow(bad_style, improper_ctypes, unused, deprecated)] 2 | 3 | use libc::*; 4 | 5 | #[cfg(target_os = "linux")] 6 | include!(concat!(env!("OUT_DIR"), "/linux_elf.rs")); 7 | 8 | #[cfg(not(target_os = "linux"))] 9 | fn main() { 10 | println!("PASSED 0 tests"); 11 | } 12 | -------------------------------------------------------------------------------- /libc-test/tests/linux_ipv6.rs: -------------------------------------------------------------------------------- 1 | #![allow(bad_style, improper_ctypes, unused, deprecated)] 2 | 3 | use libc::*; 4 | 5 | #[cfg(target_os = "linux")] 6 | include!(concat!(env!("OUT_DIR"), "/linux_ipv6.rs")); 7 | 8 | #[cfg(not(target_os = "linux"))] 9 | fn main() { 10 | println!("PASSED 0 tests"); 11 | } 12 | -------------------------------------------------------------------------------- /src/new/ucrt/mod.rs: -------------------------------------------------------------------------------- 1 | //! Windows Universal C Runtime. 2 | //! 3 | //! * Manual pages: 4 | //! * UCRT information: 5 | -------------------------------------------------------------------------------- /libc-test/semver/freebsd-x86_64.txt: -------------------------------------------------------------------------------- 1 | Elf64_Auxinfo 2 | KINFO_FILE_SIZE 3 | MAP_32BIT 4 | _MC_FPFMT_NODEV 5 | _MC_FPFMT_XMM 6 | _MC_FPOWNED_FPU 7 | _MC_FPOWNED_NONE 8 | _MC_FPOWNED_PCB 9 | _MC_HASBASES 10 | _MC_HASFPXSTATE 11 | _MC_HASSEGS 12 | fpreg 13 | fpreg32 14 | max_align_t 15 | reg 16 | reg32 17 | xmmreg 18 | -------------------------------------------------------------------------------- /ctest/tests/input/macro.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef SUPPRESS_ERROR 4 | #error Expected SUPPRESS_ERROR to be defined (testing per-file defines) 5 | #endif 6 | 7 | struct VecU8 8 | { 9 | uint8_t x; 10 | uint8_t y; 11 | }; 12 | 13 | struct VecU16 14 | { 15 | uint16_t x; 16 | uint16_t y; 17 | }; 18 | -------------------------------------------------------------------------------- /libc-test/semver/fuchsia-x86_64.txt: -------------------------------------------------------------------------------- 1 | CS 2 | DS 3 | EFLAGS 4 | ES 5 | FS 6 | FS_BASE 7 | GS 8 | GS_BASE 9 | MAP_32BIT 10 | ORIG_RAX 11 | R10 12 | R11 13 | R12 14 | R13 15 | R14 16 | R15 17 | R8 18 | R9 19 | RAX 20 | RBP 21 | RBX 22 | RCX 23 | RDI 24 | RDX 25 | RIP 26 | RSI 27 | RSP 28 | SS 29 | mcontext_t 30 | ucontext_t 31 | -------------------------------------------------------------------------------- /ci/android-install-ndk.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -eux 4 | 5 | ndk=android-ndk-r27 6 | wget --tries=20 -q "https://dl.google.com/android/repository/${ndk}-linux.zip" 7 | unzip -q "${ndk}-linux.zip" 8 | 9 | mv "./${ndk}/toolchains/llvm/prebuilt/linux-x86_64" /android 10 | 11 | rm -rf "./${ndk}-linux.zip" "./${ndk}" 12 | -------------------------------------------------------------------------------- /ctest/tests/input/hierarchy.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #ifdef SUPPRESS_ERROR 5 | #error Expected SUPPRESS_ERROR to not be defined (testing per-file defines) 6 | #endif 7 | 8 | typedef unsigned int in6_addr; 9 | 10 | #define ON true 11 | 12 | extern void *malloc(size_t size); 13 | extern in6_addr in6addr_any; 14 | -------------------------------------------------------------------------------- /src/new/glibc/sysdeps/unix/linux/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source directory: `sysdeps/unix/sysv/linux` (the `sysv` is flattened). 2 | //! 3 | //! 4 | 5 | /// Directory: `net/` 6 | /// 7 | /// Source directory: `sysdeps/unix/sysv/linux/net` 8 | pub(crate) mod net { 9 | pub(crate) mod route; 10 | } 11 | -------------------------------------------------------------------------------- /libc-test/tests/linux_fcntl.rs: -------------------------------------------------------------------------------- 1 | #![allow(bad_style, improper_ctypes, unused, deprecated)] 2 | 3 | use libc::*; 4 | 5 | #[cfg(any(target_os = "linux", target_os = "android"))] 6 | include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs")); 7 | 8 | #[cfg(not(any(target_os = "linux", target_os = "android")))] 9 | fn main() { 10 | println!("PASSED 0 tests"); 11 | } 12 | -------------------------------------------------------------------------------- /libc-test/tests/linux_if_arp.rs: -------------------------------------------------------------------------------- 1 | #![allow(bad_style, improper_ctypes, unused, deprecated)] 2 | 3 | use libc::*; 4 | 5 | #[cfg(any(target_os = "linux", target_os = "android"))] 6 | include!(concat!(env!("OUT_DIR"), "/linux_if_arp.rs")); 7 | 8 | #[cfg(not(any(target_os = "linux", target_os = "android")))] 9 | fn main() { 10 | println!("PASSED 0 tests"); 11 | } 12 | -------------------------------------------------------------------------------- /libc-test/tests/linux_termios.rs: -------------------------------------------------------------------------------- 1 | #![allow(bad_style, improper_ctypes, unused, deprecated)] 2 | 3 | use libc::*; 4 | 5 | #[cfg(any(target_os = "linux", target_os = "android"))] 6 | include!(concat!(env!("OUT_DIR"), "/linux_termios.rs")); 7 | 8 | #[cfg(not(any(target_os = "linux", target_os = "android")))] 9 | fn main() { 10 | println!("PASSED 0 tests"); 11 | } 12 | -------------------------------------------------------------------------------- /src/unix/bsd/apple/b64/aarch64/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type boolean_t = c_int; 4 | 5 | s! { 6 | pub struct malloc_zone_t { 7 | __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support 8 | } 9 | } 10 | 11 | s_no_extra_traits! { 12 | pub struct max_align_t { 13 | priv_: f64, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /libc-test/tests/linux_strerror_r.rs: -------------------------------------------------------------------------------- 1 | #![allow(bad_style, improper_ctypes, unused, deprecated)] 2 | 3 | use libc::*; 4 | 5 | #[cfg(any(target_os = "linux", target_os = "android"))] 6 | include!(concat!(env!("OUT_DIR"), "/linux_strerror_r.rs")); 7 | 8 | #[cfg(not(any(target_os = "linux", target_os = "android")))] 9 | fn main() { 10 | println!("PASSED 0 tests"); 11 | } 12 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/freebsd12/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; 4 | pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; 5 | pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; 6 | pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; 7 | pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; 8 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/freebsd13/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; 4 | pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; 5 | pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; 6 | pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; 7 | pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; 8 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/netbsd/powerpc.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use crate::PT_FIRSTMACH; 3 | 4 | pub type __cpu_simple_lock_nv_t = c_int; 5 | 6 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 7 | 8 | pub const PT_STEP: c_int = PT_FIRSTMACH + 0; 9 | pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; 10 | pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; 11 | -------------------------------------------------------------------------------- /libc-test/src/errqueue.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // SO_EE_OFFENDER is defined as a macro in linux/errqueue.h. This file wraps 5 | // that macro in a function so we can test the reimplementation in this package 6 | // is equivalent. 7 | 8 | struct sockaddr *so_ee_offender(struct sock_extended_err *ee) { 9 | return SO_EE_OFFENDER(ee); 10 | } 11 | -------------------------------------------------------------------------------- /src/sgx.rs: -------------------------------------------------------------------------------- 1 | //! SGX C types definition 2 | 3 | use crate::prelude::*; 4 | 5 | pub type intmax_t = i64; 6 | pub type uintmax_t = u64; 7 | 8 | pub type size_t = usize; 9 | pub type ptrdiff_t = isize; 10 | pub type intptr_t = isize; 11 | pub type uintptr_t = usize; 12 | pub type ssize_t = isize; 13 | 14 | pub const INT_MIN: c_int = -2147483648; 15 | pub const INT_MAX: c_int = 2147483647; 16 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/stack_np.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread/stack_np.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | extern "C" { 8 | pub fn pthread_stack_frame_decode_np( 9 | frame_addr: uintptr_t, 10 | return_addr: *mut uintptr_t, 11 | ) -> uintptr_t; 12 | } 13 | -------------------------------------------------------------------------------- /src/new/apple/xnu/machine/_mcontext.rs: -------------------------------------------------------------------------------- 1 | //! Header: `machine/_mcontext.h` 2 | 3 | cfg_if! { 4 | if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { 5 | pub use crate::i386::_mcontext::*; 6 | } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { 7 | pub use crate::arm::_mcontext::*; 8 | } else { 9 | // Unsupported arch 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/new/netbsd/sys/types.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/types.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | pub type dev_t = u64; 8 | 9 | pub type lwpid_t = i32; 10 | 11 | pub type mqd_t = c_int; 12 | pub type cpuid_t = c_ulong; 13 | 14 | pub type clock_t = c_uint; 15 | pub type timer_t = c_int; 16 | pub type suseconds_t = c_int; 17 | -------------------------------------------------------------------------------- /src/new/netbsd/mod.rs: -------------------------------------------------------------------------------- 1 | //! NetBSD libc. 2 | //! 3 | //! * Headers: 4 | //! * Sys headers: 5 | //! * Manual pages: 6 | 7 | pub(crate) mod net { 8 | pub(crate) mod if_; 9 | } 10 | 11 | pub(crate) mod sys; 12 | pub(crate) mod unistd; 13 | pub(crate) mod utmp_; 14 | pub(crate) mod utmpx_; 15 | -------------------------------------------------------------------------------- /src/switch.rs: -------------------------------------------------------------------------------- 1 | //! Switch C type definitions 2 | 3 | pub type intmax_t = i64; 4 | pub type uintmax_t = u64; 5 | 6 | pub type size_t = usize; 7 | pub type ptrdiff_t = isize; 8 | pub type intptr_t = isize; 9 | pub type uintptr_t = usize; 10 | pub type ssize_t = isize; 11 | 12 | pub type off_t = i64; 13 | pub type wchar_t = u32; 14 | 15 | pub const INT_MIN: c_int = -2147483648; 16 | pub const INT_MAX: c_int = 2147483647; 17 | -------------------------------------------------------------------------------- /ctest/src/ast/type_alias.rs: -------------------------------------------------------------------------------- 1 | use crate::BoxStr; 2 | 3 | /// Represents a type alias defined in Rust. 4 | #[derive(Debug, Clone)] 5 | pub struct Type { 6 | pub(crate) public: bool, 7 | pub(crate) ident: BoxStr, 8 | pub(crate) ty: syn::Type, 9 | } 10 | 11 | impl Type { 12 | /// Return the identifier of the type alias as a string. 13 | pub fn ident(&self) -> &str { 14 | &self.ident 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/new/netbsd/sys/time.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/time.h` 2 | //! 3 | //! 4 | 5 | s! { 6 | pub struct itimerspec { 7 | pub it_interval: crate::timespec, 8 | pub it_value: crate::timespec, 9 | } 10 | } 11 | 12 | pub const CLOCK_THREAD_CPUTIME_ID: crate::clockid_t = 0x20000000; 13 | pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 0x40000000; 14 | -------------------------------------------------------------------------------- /src/unix/newlib/powerpc/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = c_ulong; 4 | pub type wchar_t = c_int; 5 | 6 | pub use crate::unix::newlib::generic::{ 7 | dirent, 8 | sigset_t, 9 | stat, 10 | }; 11 | 12 | // the newlib shipped with devkitPPC does not support the following components: 13 | // - sockaddr 14 | // - AF_INET6 15 | // - FIONBIO 16 | // - POLL* 17 | // - SOL_SOCKET 18 | // - MSG_* 19 | -------------------------------------------------------------------------------- /ctest/src/ast/constant.rs: -------------------------------------------------------------------------------- 1 | use crate::BoxStr; 2 | 3 | /// Represents a constant variable defined in Rust. 4 | #[derive(Debug, Clone)] 5 | pub struct Const { 6 | pub(crate) public: bool, 7 | pub(crate) ident: BoxStr, 8 | pub(crate) ty: syn::Type, 9 | } 10 | 11 | impl Const { 12 | /// Return the identifier of the constant as a string. 13 | pub fn ident(&self) -> &str { 14 | &self.ident 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ci/docker/x86_64-unknown-redox/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM redoxos/redoxer 2 | 3 | RUN mv /root/.redoxer /.redoxer 4 | 5 | ENV PATH=$PATH:/.redoxer/toolchain/bin:/rust/bin \ 6 | AR_x86_64_unknown_redox="x86_64-unknown-redox-ar" \ 7 | CC_x86_64_unknown_redox="x86_64-unknown-redox-gcc" \ 8 | CARGO_TARGET_X86_64_UNKNOWN_REDOX_LINKER="x86_64-unknown-redox-gcc" \ 9 | CARGO_TARGET_X86_64_UNKNOWN_REDOX_RUNNER="redoxer exec --folder ." 10 | -------------------------------------------------------------------------------- /ctest/src/ast/field.rs: -------------------------------------------------------------------------------- 1 | use crate::BoxStr; 2 | 3 | /// Represents a field in a struct or union defined in Rust. 4 | #[derive(Debug, Clone)] 5 | pub struct Field { 6 | pub(crate) public: bool, 7 | pub(crate) ident: BoxStr, 8 | pub(crate) ty: syn::Type, 9 | } 10 | 11 | impl Field { 12 | /// Return the identifier of the field as a string. 13 | pub fn ident(&self) -> &str { 14 | &self.ident 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/netbsd/mips.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use crate::PT_FIRSTMACH; 3 | 4 | pub type __cpu_simple_lock_nv_t = c_int; 5 | 6 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 7 | 8 | pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; 9 | pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; 10 | pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3; 11 | pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4; 12 | -------------------------------------------------------------------------------- /ctest/src/ast/parameter.rs: -------------------------------------------------------------------------------- 1 | use crate::BoxStr; 2 | 3 | /// Represents a parameter in a function signature defined in Rust. 4 | #[derive(Debug, Clone)] 5 | pub struct Parameter { 6 | pub(crate) ident: BoxStr, 7 | #[expect(unused)] 8 | pub(crate) ty: syn::Type, 9 | } 10 | 11 | impl Parameter { 12 | /// Return the identifier of the parameter as a string. 13 | pub fn ident(&self) -> &str { 14 | &self.ident 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /libc-test/semver/netbsd-x86_64.txt: -------------------------------------------------------------------------------- 1 | Aux64Info 2 | PT_GETFPREGS 3 | PT_GETREGS 4 | PT_SETFPREGS 5 | PT_SETREGS 6 | PT_STEP 7 | _REG_DS 8 | _REG_ERR 9 | _REG_ES 10 | _REG_FS 11 | _REG_GS 12 | _REG_R10 13 | _REG_R11 14 | _REG_R12 15 | _REG_R13 16 | _REG_R14 17 | _REG_R15 18 | _REG_R8 19 | _REG_R9 20 | _REG_RAX 21 | _REG_RBP 22 | _REG_RBX 23 | _REG_RCX 24 | _REG_RDI 25 | _REG_RFLAGS 26 | _REG_RIP 27 | _REG_RSI 28 | _REG_RSP 29 | _REG_SS 30 | _REG_TRAPNO 31 | -------------------------------------------------------------------------------- /src/xous.rs: -------------------------------------------------------------------------------- 1 | //! Xous C type definitions 2 | 3 | use crate::prelude::*; 4 | 5 | pub type intmax_t = i64; 6 | pub type uintmax_t = u64; 7 | 8 | pub type size_t = usize; 9 | pub type ptrdiff_t = isize; 10 | pub type intptr_t = isize; 11 | pub type uintptr_t = usize; 12 | pub type ssize_t = isize; 13 | 14 | pub type off_t = i64; 15 | pub type wchar_t = u32; 16 | 17 | pub const INT_MIN: c_int = -2147483648; 18 | pub const INT_MAX: c_int = 2147483647; 19 | -------------------------------------------------------------------------------- /ci/docker/i686-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:23.10 2 | 3 | # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time 4 | RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ 5 | /etc/apt/sources.list && \ 6 | apt-get update && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | gcc-multilib \ 9 | libc6-dev 10 | 11 | ENV PATH=$PATH:/rust/bin 12 | -------------------------------------------------------------------------------- /ctest/src/ast/union.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | BoxStr, 3 | Field, 4 | }; 5 | 6 | /// Represents a union defined in Rust. 7 | #[derive(Debug, Clone)] 8 | pub struct Union { 9 | pub(crate) public: bool, 10 | pub(crate) ident: BoxStr, 11 | pub(crate) fields: Vec, 12 | } 13 | 14 | impl Union { 15 | /// Return the identifier of the union as a string. 16 | pub fn ident(&self) -> &str { 17 | &self.ident 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libc-test/tests/primitive_types.rs: -------------------------------------------------------------------------------- 1 | use std::any::TypeId; 2 | 3 | macro_rules! ok { 4 | ($($t:ident)*) => {$( 5 | assert!(TypeId::of::() == TypeId::of::(), 6 | "{} is wrong", stringify!($t)); 7 | )*} 8 | } 9 | 10 | #[test] 11 | fn same() { 12 | use std::ffi; 13 | ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong 14 | c_longlong c_ulonglong c_float c_double); 15 | } 16 | -------------------------------------------------------------------------------- /ctest/src/ast/structure.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | BoxStr, 3 | Field, 4 | }; 5 | 6 | /// Represents a struct defined in Rust. 7 | #[derive(Debug, Clone)] 8 | pub struct Struct { 9 | pub(crate) public: bool, 10 | pub(crate) ident: BoxStr, 11 | pub(crate) fields: Vec, 12 | } 13 | 14 | impl Struct { 15 | /// Return the identifier of the struct as a string. 16 | pub fn ident(&self) -> &str { 17 | &self.ident 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /libc-test/semver/android-aarch64.txt: -------------------------------------------------------------------------------- 1 | AT_SYSINFO_EHDR 2 | AT_VECTOR_SIZE_ARCH 3 | HWCAP2_DCPODP 4 | HWCAP2_FLAGM2 5 | HWCAP2_FRINT 6 | HWCAP2_SVE2 7 | HWCAP2_SVEAES 8 | HWCAP2_SVEBITPERM 9 | HWCAP2_SVEPMULL 10 | HWCAP2_SVESHA3 11 | HWCAP2_SVESM4 12 | PROT_BTI 13 | PROT_MTE 14 | SYS_arch_specific_syscall 15 | SYS_fcntl 16 | SYS_lseek 17 | SYS_memfd_secret 18 | SYS_mmap 19 | SYS_syscalls 20 | __system_property_wait 21 | user_fpsimd_struct 22 | user_regs_struct 23 | -------------------------------------------------------------------------------- /src/new/netbsd/sys/ipc.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/ipc.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | s! { 8 | pub struct ipc_perm { 9 | pub uid: crate::uid_t, 10 | pub gid: crate::gid_t, 11 | pub cuid: crate::uid_t, 12 | pub cgid: crate::gid_t, 13 | pub mode: crate::mode_t, 14 | pub _seq: c_ushort, 15 | pub _key: crate::key_t, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/new/openbsd/sys/ipc.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/ipc.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | s! { 8 | pub struct ipc_perm { 9 | pub cuid: crate::uid_t, 10 | pub cgid: crate::gid_t, 11 | pub uid: crate::uid_t, 12 | pub gid: crate::gid_t, 13 | pub mode: crate::mode_t, 14 | pub seq: c_ushort, 15 | pub key: crate::key_t, 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ci/docker/aarch64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | gcc-aarch64-linux-gnu \ 7 | libc6-dev \ 8 | libc6-dev-arm64-cross \ 9 | qemu-user 10 | 11 | ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ 12 | CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \ 13 | PATH=$PATH:/rust/bin 14 | -------------------------------------------------------------------------------- /src/new/apple/xnu/arm/_mcontext.rs: -------------------------------------------------------------------------------- 1 | //! Header: `arm/_mcontext.h` 2 | //! 3 | //! 4 | 5 | pub use crate::mach::machine::_structs::*; 6 | 7 | s! { 8 | pub struct __darwin_mcontext64 { 9 | pub __es: __darwin_arm_exception_state64, 10 | pub __ss: __darwin_arm_thread_state64, 11 | pub __ns: __darwin_arm_neon_state64, 12 | } 13 | } 14 | 15 | pub type mcontext_t = *mut __darwin_mcontext64; 16 | -------------------------------------------------------------------------------- /ci/docker/x86_64-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | curl \ 6 | gcc \ 7 | git \ 8 | libc6-dev \ 9 | make \ 10 | patch \ 11 | rsync \ 12 | xz-utils 13 | 14 | ARG MUSL_VERSION 15 | COPY install-musl.sh / 16 | RUN /install-musl.sh x86_64 "$MUSL_VERSION" 17 | 18 | ENV PATH=$PATH:/musl-x86_64/bin:/rust/bin \ 19 | EXTRA_RUSTFLAGS="-L /musl-x86_64/lib" 20 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/pthread_impl.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | // FIXME(apple): these should all be `pub(crate)` 4 | pub const _PTHREAD_MUTEX_SIG_init: c_long = 0x32AAABA7; 5 | 6 | pub const _PTHREAD_COND_SIG_init: c_long = 0x3CB0B1BB; 7 | pub(crate) const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA; 8 | pub const _PTHREAD_RWLOCK_SIG_init: c_long = 0x2DA8B3B4; 9 | 10 | pub const SCHED_OTHER: c_int = 1; 11 | pub const SCHED_FIFO: c_int = 4; 12 | pub const SCHED_RR: c_int = 2; 13 | -------------------------------------------------------------------------------- /src/new/apple/xnu/i386/_mcontext.rs: -------------------------------------------------------------------------------- 1 | //! Header: `i386/_mcontext.h` 2 | //! 3 | //! 4 | 5 | pub use crate::mach::machine::_structs::*; 6 | 7 | s! { 8 | pub struct __darwin_mcontext64 { 9 | pub __es: __darwin_x86_exception_state64, 10 | pub __ss: __darwin_x86_thread_state64, 11 | pub __fs: __darwin_x86_float_state64, 12 | } 13 | } 14 | 15 | pub type mcontext_t = *mut __darwin_mcontext64; 16 | -------------------------------------------------------------------------------- /src/new/emscripten/pthread.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread.h` 2 | 3 | pub use crate::new::common::linux_like::pthread::pthread_getattr_np; 4 | pub use crate::new::common::posix::pthread::{ 5 | pthread_attr_getstack, 6 | pthread_attr_setstack, 7 | pthread_condattr_getclock, 8 | pthread_condattr_setclock, 9 | pthread_condattr_setpshared, 10 | pthread_create, 11 | pthread_mutexattr_setpshared, 12 | pthread_rwlockattr_getpshared, 13 | pthread_rwlockattr_setpshared, 14 | }; 15 | -------------------------------------------------------------------------------- /src/new/common/posix/mod.rs: -------------------------------------------------------------------------------- 1 | //! POSIX APIs that are used by a number of platforms 2 | //! 3 | //! These can be found at: . 4 | 5 | // FIXME(pthread): eventually all platforms should use this module 6 | #[cfg(any( 7 | target_os = "android", 8 | target_os = "emscripten", 9 | target_os = "l4re", 10 | target_os = "linux", 11 | target_vendor = "apple", 12 | ))] 13 | pub(crate) mod pthread; 14 | pub(crate) mod unistd; 15 | -------------------------------------------------------------------------------- /ctest/tests/input/simple.out.c: -------------------------------------------------------------------------------- 1 | /* This file was autogenerated by ctest; do not modify directly */ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static char const* __test_const_A_val = A; 10 | 11 | // Define a function that returns a pointer to the value of the constant to test. 12 | // This will later be called on the Rust side via FFI. 13 | char const** __test_const_A(void) { 14 | return &__test_const_A_val; 15 | } 16 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/pthread_spis.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread/pthread_spis.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | extern "C" { 8 | pub fn pthread_create_from_mach_thread( 9 | thread: *mut crate::pthread_t, 10 | attr: *const crate::pthread_attr_t, 11 | f: extern "C" fn(*mut c_void) -> *mut c_void, 12 | value: *mut c_void, 13 | ) -> c_int; 14 | } 15 | -------------------------------------------------------------------------------- /src/new/apple/xnu/sys/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `sys/` 2 | //! 3 | //! 4 | 5 | pub(crate) mod signal; 6 | 7 | /// Directory: `sys/_types` 8 | /// 9 | /// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/sys/_types 10 | pub(crate) mod _types { 11 | pub(crate) mod _ucontext; 12 | } 13 | 14 | // Bit of a hack since the directories get merged and we can't have >1 sys module. 15 | pub(crate) use crate::new::apple::libpthread::sys::*; 16 | -------------------------------------------------------------------------------- /libc-test/semver/linux-powerpc-gnu.txt: -------------------------------------------------------------------------------- 1 | KEYCTL_CAPABILITIES 2 | KEYCTL_CAPS0_BIG_KEY 3 | KEYCTL_CAPS0_CAPABILITIES 4 | KEYCTL_CAPS0_DIFFIE_HELLMAN 5 | KEYCTL_CAPS0_INVALIDATE 6 | KEYCTL_CAPS0_MOVE 7 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 8 | KEYCTL_CAPS0_PUBLIC_KEY 9 | KEYCTL_CAPS0_RESTRICT_KEYRING 10 | KEYCTL_CAPS1_NS_KEYRING_NAME 11 | KEYCTL_CAPS1_NS_KEY_TAG 12 | KEYCTL_MOVE 13 | PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 14 | PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP 15 | PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 16 | sysctl 17 | -------------------------------------------------------------------------------- /src/new/apple/xnu/sys/_types/_ucontext.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/_types/_ucontext.h` 2 | 3 | pub use crate::machine::_mcontext::*; 4 | use crate::prelude::*; 5 | 6 | s! { 7 | pub struct __darwin_ucontext { 8 | pub uc_onstack: c_int, 9 | pub uc_sigmask: crate::sigset_t, 10 | pub uc_stack: crate::stack_t, 11 | pub uc_link: *mut ucontext_t, 12 | pub uc_mcsize: usize, 13 | pub uc_mcontext: mcontext_t, 14 | } 15 | } 16 | 17 | pub type ucontext_t = __darwin_ucontext; 18 | -------------------------------------------------------------------------------- /src/new/apple/xnu/mach/machine/_structs.rs: -------------------------------------------------------------------------------- 1 | //! Header: `mach/machine/_structs.h` 2 | //! 3 | //! 4 | 5 | cfg_if! { 6 | if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { 7 | pub use crate::mach::i386::_structs::*; 8 | } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] { 9 | pub use crate::mach::arm::_structs::*; 10 | } else { 11 | // Unsupported arch 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/sys/qos.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/qos.h` 2 | //! 3 | //! 4 | 5 | c_enum! { 6 | #[repr(u32)] 7 | pub enum qos_class_t { 8 | pub QOS_CLASS_USER_INTERACTIVE = 0x21, 9 | pub QOS_CLASS_USER_INITIATED = 0x19, 10 | pub QOS_CLASS_DEFAULT = 0x15, 11 | pub QOS_CLASS_UTILITY = 0x11, 12 | pub QOS_CLASS_BACKGROUND = 0x09, 13 | pub QOS_CLASS_UNSPECIFIED = 0x00, 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/sys/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `sys/` 2 | //! 3 | //! 4 | 5 | /// Directory: `sys/_pthread/` 6 | /// 7 | /// 8 | pub(crate) mod _pthread { 9 | // We don't have the `_pthread_attr_t` and similar modules to match `_pthread_attr_t.h`, 10 | // everything is defined in `_pthread_types`. 11 | pub(crate) mod _pthread_types; 12 | } 13 | 14 | pub(crate) mod qos; 15 | -------------------------------------------------------------------------------- /libc-test/semver/linux-gnu-loongarch64.txt: -------------------------------------------------------------------------------- 1 | KEYCTL_CAPABILITIES 2 | KEYCTL_CAPS0_BIG_KEY 3 | KEYCTL_CAPS0_CAPABILITIES 4 | KEYCTL_CAPS0_DIFFIE_HELLMAN 5 | KEYCTL_CAPS0_INVALIDATE 6 | KEYCTL_CAPS0_MOVE 7 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 8 | KEYCTL_CAPS0_PUBLIC_KEY 9 | KEYCTL_CAPS0_RESTRICT_KEYRING 10 | KEYCTL_CAPS1_NS_KEYRING_NAME 11 | KEYCTL_CAPS1_NS_KEY_TAG 12 | KEYCTL_MOVE 13 | PTRACE_GETFPREGS 14 | PTRACE_GETFPXREGS 15 | PTRACE_GETREGS 16 | PTRACE_SETFPREGS 17 | PTRACE_SETFPXREGS 18 | PTRACE_SETREGS 19 | PTRACE_SYSEMU 20 | PTRACE_SYSEMU_SINGLESTEP 21 | -------------------------------------------------------------------------------- /ci/docker/powerpc64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | gcc-powerpc64-linux-gnu \ 7 | libc6-dev \ 8 | libc6-dev-ppc64-cross \ 9 | qemu-system-ppc \ 10 | qemu-user 11 | 12 | ENV CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_LINKER=powerpc64-linux-gnu-gcc \ 13 | CARGO_TARGET_POWERPC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64 -L /usr/powerpc64-linux-gnu" \ 14 | CC=powerpc64-linux-gnu-gcc \ 15 | PATH=$PATH:/rust/bin 16 | -------------------------------------------------------------------------------- /ctest-test/src/t2.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef int32_t T2Foo; 4 | typedef int8_t T2Bar; 5 | 6 | typedef T2Foo T2TypedefFoo; 7 | typedef unsigned T2TypedefInt; 8 | 9 | struct T2Baz { 10 | int8_t _a; 11 | int64_t a; 12 | uint32_t b; 13 | }; 14 | 15 | typedef struct { 16 | uint32_t a; 17 | int64_t b; 18 | } T2Union; 19 | 20 | static void T2a(void) {} 21 | 22 | #define T2C 4 23 | #define T2S "a" 24 | 25 | enum enum_repr_too_small { 26 | ENUM_REPR_TOO_SMALL_A 27 | }; 28 | 29 | enum enum_wrong_signedness { 30 | ENUM_WRONG_SIGNEDNESS_A 31 | }; -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/spawn.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread/spawn.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | extern "C" { 8 | pub fn posix_spawnattr_set_qos_class_np( 9 | attr: *mut crate::posix_spawnattr_t, 10 | qos_class: crate::qos_class_t, 11 | ) -> c_int; 12 | pub fn posix_spawnattr_get_qos_class_np( 13 | attr: *const crate::posix_spawnattr_t, 14 | qos_class: *mut crate::qos_class_t, 15 | ) -> c_int; 16 | } 17 | -------------------------------------------------------------------------------- /src/new/apple/xnu/mach/mod.rs: -------------------------------------------------------------------------------- 1 | //! Directory: `mach/` 2 | //! 3 | //! 4 | 5 | /// Directory: `mach/arm` 6 | #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] 7 | pub(crate) mod arm { 8 | pub(crate) mod _structs; 9 | } 10 | 11 | /// Directory: `mach/i386` 12 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 13 | pub(crate) mod i386 { 14 | pub(crate) mod _structs; 15 | } 16 | 17 | /// Directory: `mach/machine` 18 | pub(crate) mod machine { 19 | pub(crate) mod _structs; 20 | } 21 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/aarch64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type ucontext_t = sigcontext; 4 | 5 | s! { 6 | pub struct sigcontext { 7 | __sc_unused: Padding, 8 | pub sc_mask: c_int, 9 | pub sc_sp: c_ulong, 10 | pub sc_lr: c_ulong, 11 | pub sc_elr: c_ulong, 12 | pub sc_spsr: c_ulong, 13 | pub sc_x: [c_ulong; 30], 14 | pub sc_cookie: c_long, 15 | } 16 | } 17 | 18 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 19 | 20 | pub const _MAX_PAGE_SHIFT: u32 = 12; 21 | -------------------------------------------------------------------------------- /ci/docker/powerpc64le-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | gcc-powerpc64le-linux-gnu \ 7 | libc6-dev \ 8 | libc6-dev-ppc64el-cross \ 9 | qemu-system-ppc \ 10 | qemu-user 11 | 12 | ENV CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_LINKER=powerpc64le-linux-gnu-gcc \ 13 | CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc64le -L /usr/powerpc64le-linux-gnu" \ 14 | CC=powerpc64le-linux-gnu-gcc \ 15 | PATH=$PATH:/rust/bin 16 | -------------------------------------------------------------------------------- /ci/docker/sparc64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | gcc-sparc64-linux-gnu \ 7 | libc6-dev \ 8 | libc6-dev-sparc64-cross \ 9 | qemu-system-sparc64 \ 10 | qemu-user 11 | 12 | ENV CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_LINKER=sparc64-linux-gnu-gcc \ 13 | CARGO_TARGET_SPARC64_UNKNOWN_LINUX_GNU_RUNNER="qemu-sparc64 -L /usr/sparc64-linux-gnu" \ 14 | CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc \ 15 | PATH=$PATH:/rust/bin 16 | -------------------------------------------------------------------------------- /src/windows/msvc/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | // POSIX Supplement (from errno.h) 4 | // This particular error code is only currently available in msvc toolchain 5 | pub const EOTHER: c_int = 131; 6 | 7 | extern "C" { 8 | #[link_name = "_stricmp"] 9 | pub fn stricmp(s1: *const c_char, s2: *const c_char) -> c_int; 10 | #[link_name = "_strnicmp"] 11 | pub fn strnicmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; 12 | #[link_name = "_memccpy"] 13 | pub fn memccpy(dest: *mut c_void, src: *const c_void, c: c_int, count: size_t) -> *mut c_void; 14 | } 15 | -------------------------------------------------------------------------------- /src/unix/haiku/b32.rs: -------------------------------------------------------------------------------- 1 | pub type time_t = i32; 2 | 3 | pub type Elf_Addr = crate::Elf32_Addr; 4 | pub type Elf_Half = crate::Elf32_Half; 5 | pub type Elf_Phdr = crate::Elf32_Phdr; 6 | 7 | s! { 8 | pub struct Elf32_Phdr { 9 | pub p_type: crate::Elf32_Word, 10 | pub p_offset: crate::Elf32_Off, 11 | pub p_vaddr: crate::Elf32_Addr, 12 | pub p_paddr: crate::Elf32_Addr, 13 | pub p_filesz: crate::Elf32_Word, 14 | pub p_memsz: crate::Elf32_Word, 15 | pub p_flags: crate::Elf32_Word, 16 | pub p_align: crate::Elf32_Word, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/unix/haiku/b64.rs: -------------------------------------------------------------------------------- 1 | pub type time_t = i64; 2 | 3 | pub type Elf_Addr = crate::Elf64_Addr; 4 | pub type Elf_Half = crate::Elf64_Half; 5 | pub type Elf_Phdr = crate::Elf64_Phdr; 6 | 7 | s! { 8 | pub struct Elf64_Phdr { 9 | pub p_type: crate::Elf64_Word, 10 | pub p_flags: crate::Elf64_Word, 11 | pub p_offset: crate::Elf64_Off, 12 | pub p_vaddr: crate::Elf64_Addr, 13 | pub p_paddr: crate::Elf64_Addr, 14 | pub p_filesz: crate::Elf64_Xword, 15 | pub p_memsz: crate::Elf64_Xword, 16 | pub p_align: crate::Elf64_Xword, 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ci/test-runner-linux: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eux 4 | 5 | arch="$1" 6 | prog="$2" 7 | 8 | cd /qemu/init 9 | echo "#!/bin/sh\n/prog --color=never" > run_prog.sh 10 | chmod +x run_prog.sh 11 | cp -f $2 prog 12 | find . | cpio --create --format='newc' --quiet | gzip > ../initrd.gz 13 | cd .. 14 | 15 | timeout 30s qemu-system-$arch \ 16 | -m 1024 \ 17 | -nographic \ 18 | -kernel kernel \ 19 | -initrd initrd.gz \ 20 | -append init=/run_prog.sh > output || true 21 | 22 | # remove kernel messages 23 | tr -d '\r' < output | grep -Ev '^\[' 24 | 25 | grep -E "(PASSED)|(test result: ok)" output > /dev/null 26 | -------------------------------------------------------------------------------- /src/new/linux_uapi/linux/can/raw.rs: -------------------------------------------------------------------------------- 1 | //! Header: `linux/can/raw.h` 2 | 3 | pub use crate::linux::can::*; 4 | 5 | pub const SOL_CAN_RAW: c_int = SOL_CAN_BASE + CAN_RAW; 6 | pub const CAN_RAW_FILTER_MAX: c_int = 512; 7 | 8 | // FIXME(cleanup): use `c_enum!`, which needs to be adapted to allow omitting a type. 9 | pub const CAN_RAW_FILTER: c_int = 1; 10 | pub const CAN_RAW_ERR_FILTER: c_int = 2; 11 | pub const CAN_RAW_LOOPBACK: c_int = 3; 12 | pub const CAN_RAW_RECV_OWN_MSGS: c_int = 4; 13 | pub const CAN_RAW_FD_FRAMES: c_int = 5; 14 | pub const CAN_RAW_JOIN_FILTERS: c_int = 6; 15 | pub const CAN_RAW_XL_FRAMES: c_int = 7; 16 | -------------------------------------------------------------------------------- /libc-test/semver/linux-gnu-powerpc64.txt: -------------------------------------------------------------------------------- 1 | KEYCTL_CAPABILITIES 2 | KEYCTL_CAPS0_BIG_KEY 3 | KEYCTL_CAPS0_CAPABILITIES 4 | KEYCTL_CAPS0_DIFFIE_HELLMAN 5 | KEYCTL_CAPS0_INVALIDATE 6 | KEYCTL_CAPS0_MOVE 7 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 8 | KEYCTL_CAPS0_PUBLIC_KEY 9 | KEYCTL_CAPS0_RESTRICT_KEYRING 10 | KEYCTL_CAPS1_NS_KEYRING_NAME 11 | KEYCTL_CAPS1_NS_KEY_TAG 12 | KEYCTL_MOVE 13 | __NFPREG 14 | __NGREG 15 | __NVRREG 16 | clone_args 17 | fpregset_t 18 | getcontext 19 | gregset_t 20 | makecontext 21 | max_align_t 22 | mcontext_t 23 | pt_regs 24 | setcontext 25 | swapcontext 26 | sysctl 27 | ucontext_t 28 | vrregset_t 29 | vscr_t 30 | -------------------------------------------------------------------------------- /libc-test/tests/linux_kernel_version.rs: -------------------------------------------------------------------------------- 1 | //! Compare libc's KERNEL_VERSION macro against a specific kernel version. 2 | 3 | #[cfg(target_os = "linux")] 4 | mod t { 5 | use libc; 6 | 7 | #[test] 8 | fn test_kernel_version() { 9 | assert_eq!(libc::KERNEL_VERSION(6, 0, 0), 393216); 10 | // Check that the patch level saturates 11 | assert_eq!(libc::KERNEL_VERSION(6, 0, 255), 393471); 12 | assert_eq!(libc::KERNEL_VERSION(6, 0, 256), 393471); 13 | assert_eq!(libc::KERNEL_VERSION(6, 0, 300), 393471); 14 | assert_eq!(libc::KERNEL_VERSION(6, 0, u32::MAX), 393471); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ctest/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ctest" 3 | version = "0.5.0-beta.2" 4 | edition = "2024" 5 | description = "Automated testing of FFI bindings in Rust." 6 | rust-version = "1.88" 7 | license = "MIT OR Apache-2.0" 8 | repository = "https://github.com/rust-lang/libc" 9 | publish = true 10 | 11 | [dependencies] 12 | askama = "0.14.0" 13 | cc = "1.2.43" 14 | proc-macro2 = { version = "1.0.103", features = ["span-locations"] } 15 | quote = "1.0.41" 16 | syn = { version = "2.0.108", features = ["full", "visit", "extra-traits"] } 17 | thiserror = "2.0.17" 18 | 19 | [dev-dependencies] 20 | pretty_assertions = "1.4.1" 21 | tempfile = "3.23.0" 22 | -------------------------------------------------------------------------------- /ci/docker/riscv64gc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | gcc-riscv64-linux-gnu \ 7 | libc6-dev \ 8 | libc6-dev-riscv64-cross \ 9 | qemu-system-riscv64 \ 10 | qemu-user 11 | 12 | ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc \ 13 | CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_RUNNER="qemu-riscv64 -L /usr/riscv64-linux-gnu" \ 14 | CC_riscv64gc_unknown_linux_gnu=riscv64-linux-gnu-gcc \ 15 | CFLAGS_riscv64gc_unknown_linux_gnu="-mabi=lp64d -fPIC" \ 16 | PATH=$PATH:/rust/bin 17 | -------------------------------------------------------------------------------- /ci/docker/s390x-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | cpio \ 6 | curl \ 7 | gcc \ 8 | gcc-s390x-linux-gnu \ 9 | libc6-dev \ 10 | libc6-dev-s390x-cross \ 11 | qemu-system-s390x 12 | 13 | COPY linux-s390x.sh / 14 | RUN /linux-s390x.sh 15 | 16 | COPY test-runner-linux / 17 | 18 | ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ 19 | CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-linux s390x" \ 20 | CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \ 21 | PATH=$PATH:/rust/bin 22 | -------------------------------------------------------------------------------- /ctest/tests/input/simple.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | typedef uint8_t Byte; 4 | 5 | typedef unsigned long gregset_t[32]; 6 | 7 | Byte byte = 0x42; 8 | 9 | typedef volatile char volatile_char; 10 | 11 | enum Color 12 | { 13 | RED, 14 | BLUE, 15 | GREEN 16 | }; 17 | 18 | struct Person 19 | { 20 | const char *name; 21 | uint8_t age; 22 | void (*job)(uint8_t, const char *); 23 | enum Color favorite_color; 24 | }; 25 | 26 | union Word 27 | { 28 | uint16_t word; 29 | Byte byte[2]; 30 | }; 31 | 32 | #define A "abc" 33 | #define C_B "bac" 34 | 35 | extern void *calloc(size_t num, size_t size); 36 | extern Byte byte; 37 | -------------------------------------------------------------------------------- /ci/linux-s390x.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -eux 4 | 5 | mkdir -m 777 /qemu 6 | cd /qemu 7 | 8 | curl --retry 5 -LO https://github.com/qemu/qemu/raw/HEAD/pc-bios/s390-ccw.img 9 | curl --retry 5 -LO https://ftp.debian.org/debian/dists/testing/main/installer-s390x/20250803/images/generic/kernel.debian 10 | curl --retry 5 -LO https://ftp.debian.org/debian/dists/testing/main/installer-s390x/20250803/images/generic/initrd.debian 11 | 12 | mv kernel.debian kernel 13 | mv initrd.debian initrd.gz 14 | 15 | mkdir init 16 | cd init 17 | gunzip -c ../initrd.gz | cpio -id 18 | rm ../initrd.gz 19 | cp /usr/s390x-linux-gnu/lib/libgcc_s.so.1 usr/lib/ 20 | chmod a+w . 21 | -------------------------------------------------------------------------------- /ci/docker/loongarch64-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | gcc-14-loongarch64-linux-gnu \ 7 | libc6-dev \ 8 | libc6-dev-loong64-cross \ 9 | qemu-user 10 | 11 | ENV CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_LINKER=loongarch64-linux-gnu-gcc-14 \ 12 | CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-loongarch64 -L /usr/loongarch64-linux-gnu" \ 13 | CC_loongarch64_unknown_linux_gnu=loongarch64-linux-gnu-gcc-14 \ 14 | CFLAGS_loongarch64_unknown_linux_gnu="-mabi=lp64d -fPIC" \ 15 | PATH=$PATH:/rust/bin 16 | -------------------------------------------------------------------------------- /src/new/apple/mod.rs: -------------------------------------------------------------------------------- 1 | //! Apple interfaces. 2 | //! 3 | //! The Xcode SDK includes interfaces that are split across a couple of different libraries. Most 4 | //! of these are available at . 5 | 6 | /// Entrypoint for Apple headers, usually found as part of the Xcode SDK. 7 | /// 8 | /// 9 | mod libc { 10 | pub(crate) mod signal; 11 | pub(crate) mod unistd; 12 | } 13 | 14 | mod libpthread; 15 | mod xnu; 16 | 17 | pub(crate) use libc::*; 18 | pub(crate) use libpthread::pthread_; 19 | pub(crate) use pthread_::pthread; 20 | pub(crate) use xnu::*; 21 | -------------------------------------------------------------------------------- /src/unix/linux_like/linux/arch/mod.rs: -------------------------------------------------------------------------------- 1 | cfg_if! { 2 | if #[cfg(any( 3 | target_arch = "mips", 4 | target_arch = "mips32r6", 5 | target_arch = "mips64", 6 | target_arch = "mips64r6" 7 | ))] { 8 | mod mips; 9 | pub use self::mips::*; 10 | } else if #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] { 11 | mod powerpc; 12 | pub use self::powerpc::*; 13 | } else if #[cfg(any(target_arch = "sparc", target_arch = "sparc64"))] { 14 | mod sparc; 15 | pub use self::sparc::*; 16 | } else { 17 | mod generic; 18 | pub use self::generic::*; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ci/emscripten.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux 4 | 5 | # Note: keep in sync with: 6 | # https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-unknown-emscripten.md#requirements 7 | emsdk_version=3.1.68 8 | 9 | git clone https://github.com/emscripten-core/emsdk.git /emsdk-portable 10 | cd /emsdk-portable 11 | ./emsdk install "$emsdk_version" 12 | ./emsdk activate "$emsdk_version" 13 | 14 | # Compile and cache libc 15 | # shellcheck disable=SC1091 16 | source ./emsdk_env.sh 17 | echo "int main() {return 0;}" > a.c 18 | HOME=/emsdk-portable/ emcc a.c 19 | rm -f a.* 20 | 21 | # Make emsdk usable by any user 22 | chmod a+rxw -R /emsdk-portable 23 | -------------------------------------------------------------------------------- /libc-test/tests/errqueue.rs: -------------------------------------------------------------------------------- 1 | //! Compare libc's SO_EE_OFFENDER function against the actual C macro 2 | 3 | #[cfg(any(target_os = "linux", target_os = "android"))] 4 | mod t { 5 | use libc::{ 6 | self, 7 | sock_extended_err, 8 | sockaddr, 9 | }; 10 | 11 | extern "C" { 12 | pub fn so_ee_offender(ee: *const sock_extended_err) -> *mut sockaddr; 13 | } 14 | 15 | #[test] 16 | fn test_cmsg_data() { 17 | for l in 0..128 { 18 | let ee = l as *const sock_extended_err; 19 | unsafe { 20 | assert_eq!(libc::SO_EE_OFFENDER(ee), so_ee_offender(ee)); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ci/docker/wasm32-wasip2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | COPY wasi.sh / 4 | RUN /wasi.sh 5 | 6 | # Note that most of these are copied from `wasm32-wasip1/Dockerfile` 7 | # 8 | # FIXME: the `-Clink-arg` to export `cabi_realloc` is a bug in the target 9 | # itself, this should be fixed upstream. 10 | ENV CARGO_TARGET_WASM32_WASIP2_RUNNER=wasmtime \ 11 | CARGO_TARGET_WASM32_WASIP2_LINKER=/opt/wasi-sdk/bin/clang \ 12 | EXTRA_RUSTFLAGS="-Clink-self-contained=n -lwasi-emulated-process-clocks -Clink-arg=-Wl,--export,cabi_realloc" \ 13 | CC_wasm32_wasip2=/opt/wasi-sdk/bin/clang \ 14 | CFLAGS_wasm32_wasip2=-D_WASI_EMULATED_PROCESS_CLOCKS \ 15 | PATH=$PATH:/rust/bin:/wasmtime 16 | -------------------------------------------------------------------------------- /libc-test/semver/trusty.txt: -------------------------------------------------------------------------------- 1 | AT_PAGESZ 2 | CLOCK_REALTIME 3 | MAP_FAILED 4 | PROT_READ 5 | PROT_WRITE 6 | STDERR_FILENO 7 | STDOUT_FILENO 8 | c_char 9 | c_int 10 | c_int16_t 11 | c_int32_t 12 | c_int64_t 13 | c_int8_t 14 | c_long 15 | c_longlong 16 | c_schar 17 | c_short 18 | c_uchar 19 | c_uint 20 | c_uint16_t 21 | c_uint32_t 22 | c_uint64_t 23 | c_uint8_t 24 | c_ulong 25 | c_ulonglong 26 | c_ushort 27 | c_void 28 | calloc 29 | clock_gettime 30 | clockid_t 31 | close 32 | free 33 | getauxval 34 | iovec 35 | malloc 36 | memalign 37 | mmap 38 | munmap 39 | nanosleep 40 | off_t 41 | posix_memalign 42 | realloc 43 | size_t 44 | ssize_t 45 | strlen 46 | time_t 47 | timespec 48 | write 49 | writev 50 | -------------------------------------------------------------------------------- /libc-test/semver/illumos.txt: -------------------------------------------------------------------------------- 1 | FD_CLOFORK 2 | F_DUP2FD_CLOEXEC 3 | F_DUP2FD_CLOFORK 4 | F_DUP3FD 5 | F_DUPFD_CLOFORK 6 | MSG_CMSG_CLOEXEC 7 | MSG_CMSG_CLOFORK 8 | O_CLOFORK 9 | O_RSYNC 10 | POLLRDHUP 11 | POSIX_FADV_DONTNEED 12 | POSIX_FADV_NOREUSE 13 | POSIX_FADV_NORMAL 14 | POSIX_FADV_RANDOM 15 | POSIX_FADV_SEQUENTIAL 16 | POSIX_FADV_WILLNEED 17 | POSIX_SPAWN_SETSID 18 | TFD_CLOEXEC 19 | TFD_NONBLOCK 20 | TFD_TIMER_ABSTIME 21 | TFD_TIMER_CANCEL_ON_SET 22 | posix_fadvise 23 | posix_fallocate 24 | posix_spawn_file_actions_addfchdir_np 25 | pthread_attr_get_np 26 | pthread_attr_getstackaddr 27 | pthread_attr_setstack 28 | ptsname_r 29 | syncfs 30 | timerfd_create 31 | timerfd_gettime 32 | timerfd_settime 33 | -------------------------------------------------------------------------------- /libc-test/src/makedev.c: -------------------------------------------------------------------------------- 1 | #include 2 | #if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(__CYGWIN__) 3 | #include 4 | #endif 5 | 6 | // Since makedev, major, minor are macros instead of functions, they aren't 7 | // available to FFI. libc must reimplement them, which is error-prone. This 8 | // file provides FFI access to the actual macros so they can be tested against 9 | // the Rust reimplementation. 10 | 11 | dev_t makedev_ffi(unsigned major, unsigned minor) { 12 | return makedev(major, minor); 13 | } 14 | 15 | unsigned int major_ffi(dev_t dev) { 16 | return major(dev); 17 | } 18 | 19 | unsigned int minor_ffi(dev_t dev) { 20 | return minor(dev); 21 | } 22 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source from libpthread 2 | 3 | /// Directory: `pthread/` 4 | /// 5 | /// Note that this module has a trailing underscore to avoid conflicting with its child `pthread` 6 | /// module. 7 | /// 8 | /// 9 | pub(crate) mod pthread_ { 10 | pub(crate) mod introspection; 11 | pub(crate) mod pthread; 12 | pub(crate) mod pthread_impl; 13 | pub(crate) mod pthread_spis; 14 | pub(crate) mod qos; 15 | pub(crate) mod sched; 16 | pub(crate) mod spawn; 17 | pub(crate) mod stack_np; 18 | } 19 | 20 | pub(crate) mod sys; 21 | -------------------------------------------------------------------------------- /libc-test/semver/espidf.txt: -------------------------------------------------------------------------------- 1 | AF_INET6 2 | AF_UNIX 3 | FIONBIO 4 | MSG_CTRUNC 5 | MSG_DONTROUTE 6 | MSG_DONTWAIT 7 | MSG_EOR 8 | MSG_MORE 9 | MSG_NOSIGNAL 10 | MSG_OOB 11 | MSG_PEEK 12 | MSG_TRUNC 13 | MSG_WAITALL 14 | NSIG 15 | POLLERR 16 | POLLHUP 17 | POLLIN 18 | POLLOUT 19 | POLLPRI 20 | POLLRDBAND 21 | POLLRDNORM 22 | POLLWRBAND 23 | POLLWRNORM 24 | PTHREAD_STACK_MIN 25 | SIGABRT 26 | SIGFPE 27 | SIGHUP 28 | SIGILL 29 | SIGINT 30 | SIGQUIT 31 | SIGSEGV 32 | SIGTERM 33 | SOL_SOCKET 34 | cmsghdr 35 | dirent 36 | eventfd 37 | gethostname 38 | getrandom 39 | msghdr 40 | pthread_create 41 | recvmsg 42 | sendmsg 43 | sigset_t 44 | sockaddr 45 | sockaddr_in 46 | sockaddr_in6 47 | sockaddr_storage 48 | sockaddr_un 49 | stat 50 | -------------------------------------------------------------------------------- /ci/docker/arm-unknown-linux-gnueabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:23.10 2 | 3 | # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time 4 | RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ 5 | /etc/apt/sources.list && \ 6 | apt-get update && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | gcc \ 9 | gcc-arm-linux-gnueabihf \ 10 | libc6-dev \ 11 | libc6-dev-armhf-cross \ 12 | qemu-user 13 | 14 | ENV CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc \ 15 | CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_RUNNER="qemu-arm -L /usr/arm-linux-gnueabihf" \ 16 | PATH=$PATH:/rust/bin 17 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/riscv64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type ucontext_t = sigcontext; 4 | 5 | s! { 6 | pub struct sigcontext { 7 | __sc_unused: Padding, 8 | pub sc_mask: c_int, 9 | pub sc_ra: c_long, 10 | pub sc_sp: c_long, 11 | pub sc_gp: c_long, 12 | pub sc_tp: c_long, 13 | pub sc_t: [c_long; 7], 14 | pub sc_s: [c_long; 12], 15 | pub sc_a: [c_long; 8], 16 | pub sc_sepc: c_long, 17 | pub sc_f: [c_long; 32], 18 | pub sc_fcsr: c_long, 19 | pub sc_cookie: c_long, 20 | } 21 | } 22 | 23 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 24 | 25 | pub const _MAX_PAGE_SHIFT: u32 = 12; 26 | -------------------------------------------------------------------------------- /libc-test/semver/README.md: -------------------------------------------------------------------------------- 1 | # Supported API by libc 2 | 3 | These files are read by [`build.rs`](../build.rs) and turned into tests to 4 | ensure that APIs aren't removed between libc releases. 5 | 6 | ## File order 7 | 8 | Files are including in the following order: 9 | 10 | * Family, e.g. `unix.txt`. NOTE: Windows is skipped here and includes as OS name 11 | below. 12 | * Vendor, e.g. `apple.txt`. This allows us to have a single file with system 13 | calls shared between multiple OSs, e.g. `ios.txt`, `macos.txt` share the same 14 | kernel. 15 | * OS, e.g `linux.txt`, `macos.txt`, `windows.txt`. 16 | * Architecture specific system calls, e.g. `linux-x86_64.txt` or 17 | `linux-aarch64.txt`. 18 | * Target environment, e.g. `windows-mscv.txt` or `windows-gnu.txt`. 19 | -------------------------------------------------------------------------------- /ci/docker/powerpc-unknown-linux-gnu/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:23.10 2 | 3 | # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time 4 | RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ 5 | /etc/apt/sources.list && \ 6 | apt-get update && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | gcc \ 9 | gcc-powerpc-linux-gnu \ 10 | libc6-dev \ 11 | libc6-dev-powerpc-cross \ 12 | qemu-system-ppc \ 13 | qemu-user 14 | 15 | ENV CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_LINKER=powerpc-linux-gnu-gcc \ 16 | CARGO_TARGET_POWERPC_UNKNOWN_LINUX_GNU_RUNNER="qemu-ppc -L /usr/powerpc-linux-gnu" \ 17 | CC=powerpc-linux-gnu-gcc \ 18 | PATH=$PATH:/rust/bin 19 | -------------------------------------------------------------------------------- /ci/docker/s390x-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | curl \ 5 | ca-certificates \ 6 | gcc \ 7 | gcc-s390x-linux-gnu \ 8 | qemu-user \ 9 | xz-utils \ 10 | patch \ 11 | rsync 12 | 13 | ARG MUSL_VERSION 14 | COPY install-musl.sh / 15 | RUN /install-musl.sh s390x "$MUSL_VERSION" 16 | 17 | # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? 18 | ENV CC_s390x_unknown_linux_gnu=musl-gcc \ 19 | CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \ 20 | CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /musl-s390x" \ 21 | EXTRA_RUSTFLAGS="-Clink-args=-lgcc -L /musl-s390x/lib" \ 22 | PATH=$PATH:/musl-s390x/bin:/rust/bin 23 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; 4 | pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; 5 | pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; 6 | pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; 7 | pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; 8 | pub const PROC_LA_CTL: c_int = crate::PROC_PROCCTL_MD_MIN + 2; 9 | pub const PROC_LA_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 3; 10 | pub const PROC_LA_CTL_LA48_ON_EXEC: c_int = 1; 11 | pub const PROC_LA_CTL_LA57_ON_EXEC: c_int = 2; 12 | pub const PROC_LA_CTL_DEFAULT_ON_EXEC: c_int = 3; 13 | pub const PROC_LA_STATUS_LA48: c_int = 0x01000000; 14 | pub const PROC_LA_STATUS_LA57: c_int = 0x02000000; 15 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/freebsd15/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub const PROC_KPTI_CTL: c_int = crate::PROC_PROCCTL_MD_MIN; 4 | pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: c_int = 1; 5 | pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: c_int = 2; 6 | pub const PROC_KPTI_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 1; 7 | pub const PROC_KPTI_STATUS_ACTIVE: c_int = 0x80000000; 8 | pub const PROC_LA_CTL: c_int = crate::PROC_PROCCTL_MD_MIN + 2; 9 | pub const PROC_LA_STATUS: c_int = crate::PROC_PROCCTL_MD_MIN + 3; 10 | pub const PROC_LA_CTL_LA48_ON_EXEC: c_int = 1; 11 | pub const PROC_LA_CTL_LA57_ON_EXEC: c_int = 2; 12 | pub const PROC_LA_CTL_DEFAULT_ON_EXEC: c_int = 3; 13 | pub const PROC_LA_STATUS_LA48: c_int = 0x01000000; 14 | pub const PROC_LA_STATUS_LA57: c_int = 0x02000000; 15 | -------------------------------------------------------------------------------- /ci/docker/wasm32-wasip1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | COPY wasi.sh / 4 | RUN /wasi.sh 5 | 6 | # Note that `-D_WASI_EMULATED_PROCESS_CLOCKS` is used to enable access to 7 | # clock-related defines even though they're emulated. Also note that the usage 8 | # of `-Ctarget-feature=-crt-static` here forces usage of the external wasi-libc 9 | # installed via `wasi-sdk` instead of the version that comes with the standard 10 | # library. 11 | ENV CARGO_TARGET_WASM32_WASIP1_RUNNER=wasmtime \ 12 | CARGO_TARGET_WASM32_WASIP1_LINKER=/opt/wasi-sdk/bin/clang \ 13 | EXTRA_RUSTFLAGS="-Clink-self-contained=n -lwasi-emulated-process-clocks" \ 14 | CC_wasm32_wasip1=/opt/wasi-sdk/bin/clang \ 15 | CFLAGS_wasm32_wasip1=-D_WASI_EMULATED_PROCESS_CLOCKS \ 16 | PATH=$PATH:/rust/bin:/wasmtime 17 | -------------------------------------------------------------------------------- /libc-test/tests/sigrt.rs: -------------------------------------------------------------------------------- 1 | //! Compare libc's SIGRTMAX and SIGRTMIN functions against the actual C macros 2 | 3 | #[cfg(any( 4 | target_os = "linux", 5 | target_os = "l4re", 6 | target_os = "android", 7 | target_os = "emscripten", 8 | target_os = "solaris", 9 | target_os = "illumos", 10 | ))] 11 | mod t { 12 | use libc; 13 | 14 | extern "C" { 15 | pub fn sigrtmax() -> libc::c_int; 16 | pub fn sigrtmin() -> libc::c_int; 17 | } 18 | 19 | #[test] 20 | fn test_sigrtmax() { 21 | unsafe { 22 | assert_eq!(libc::SIGRTMAX(), sigrtmax()); 23 | } 24 | } 25 | 26 | #[test] 27 | fn test_sigrtmin() { 28 | unsafe { 29 | assert_eq!(libc::SIGRTMIN(), sigrtmin()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/api_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: API request 3 | about: Send a API request for the libc crate. 4 | labels: C-API-request 5 | --- 6 | 7 | 21 | -------------------------------------------------------------------------------- /ctest-test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ctest-test" 3 | version = "0.1.0" 4 | authors = ["Alex Crichton "] 5 | publish = false 6 | edition = "2021" 7 | 8 | [build-dependencies] 9 | ctest = { path = "../ctest" } 10 | cc = "1.2" 11 | 12 | [dev-dependencies] 13 | ctest = { path = "../ctest" } 14 | 15 | [dependencies] 16 | libc = { path = ".." } 17 | 18 | [[bin]] 19 | name = "t1" 20 | test = false 21 | 22 | [[bin]] 23 | name = "t2" 24 | test = false 25 | 26 | # FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]` 27 | # once MSRV is above 1.64 and replaced with `[lints] workspace=true` 28 | 29 | [lints.rust] 30 | # FIXME(cleanup): make ident usage consistent in each file 31 | unused_qualifications = "allow" 32 | 33 | [lints.clippy] 34 | -------------------------------------------------------------------------------- /ci/docker/asmjs-unknown-emscripten/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | # This is a workaround to avoid the interaction with tzdata. 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | ENV TZ=America/New_York 6 | 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ 8 | bzip2 \ 9 | ca-certificates \ 10 | curl \ 11 | gcc \ 12 | git \ 13 | libc6-dev \ 14 | libxml2 \ 15 | python3 \ 16 | tzdata \ 17 | xz-utils 18 | 19 | COPY emscripten.sh / 20 | RUN /emscripten.sh 21 | 22 | ENV PATH=$PATH:/rust/bin \ 23 | CARGO_TARGET_ASMJS_UNKNOWN_EMSCRIPTEN_RUNNER=node 24 | 25 | # `-g4` is used by default which causes a linking error. 26 | # Using `-g3` not to generate a source map. 27 | ENV EMCC_CFLAGS=-g3 28 | 29 | COPY emscripten-entry.sh / 30 | ENTRYPOINT ["/emscripten-entry.sh"] 31 | -------------------------------------------------------------------------------- /ci/wasi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux 4 | 5 | apt-get update 6 | apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | curl \ 9 | clang \ 10 | xz-utils 11 | 12 | # Wasmtime is used to execute tests and wasi-sdk is used to compile tests. 13 | # Download appropriate versions here and configure various flags below. 14 | wasmtime=38.0.2 15 | wasi_sdk=29 16 | 17 | curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v$wasmtime/wasmtime-v$wasmtime-x86_64-linux.tar.xz | 18 | tar xJf - 19 | mv wasmtime-v$wasmtime-x86_64-linux wasmtime 20 | 21 | # The pre-built `*.deb` files for wasi-sdk install to `/opt/wasi-sdk` 22 | curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$wasi_sdk/wasi-sdk-$wasi_sdk.0-x86_64-linux.deb 23 | dpkg -i ./wasi-sdk-*.deb 24 | -------------------------------------------------------------------------------- /libc-test/semver/linux-gnu-x86_64.txt: -------------------------------------------------------------------------------- 1 | FICLONE 2 | FICLONERANGE 3 | KEYCTL_CAPABILITIES 4 | KEYCTL_CAPS0_BIG_KEY 5 | KEYCTL_CAPS0_CAPABILITIES 6 | KEYCTL_CAPS0_DIFFIE_HELLMAN 7 | KEYCTL_CAPS0_INVALIDATE 8 | KEYCTL_CAPS0_MOVE 9 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 10 | KEYCTL_CAPS0_PUBLIC_KEY 11 | KEYCTL_CAPS0_RESTRICT_KEYRING 12 | KEYCTL_CAPS1_NS_KEYRING_NAME 13 | KEYCTL_CAPS1_NS_KEY_TAG 14 | KEYCTL_MOVE 15 | NFT_MSG_DELOBJ 16 | NFT_MSG_GETOBJ 17 | NFT_MSG_GETOBJ_RESET 18 | NFT_MSG_NEWOBJ 19 | PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 20 | PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP 21 | PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 22 | PTRACE_GET_RSEQ_CONFIGURATION 23 | PTRACE_SYSEMU 24 | PTRACE_SYSEMU_SINGLESTEP 25 | _libc_fpstate 26 | flock64 27 | getcontext 28 | makecontext 29 | ptrace_rseq_configuration 30 | setcontext 31 | swapcontext 32 | termios2 33 | -------------------------------------------------------------------------------- /ci/docker/aarch64-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | curl \ 6 | gcc \ 7 | gcc-aarch64-linux-gnu \ 8 | git \ 9 | libc6-dev \ 10 | make \ 11 | patch \ 12 | qemu-user \ 13 | rsync \ 14 | xz-utils 15 | 16 | ARG MUSL_VERSION 17 | COPY install-musl.sh / 18 | RUN /install-musl.sh aarch64 "$MUSL_VERSION" 19 | 20 | # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? 21 | ENV PATH=$PATH:/musl-aarch64/bin:/rust/bin \ 22 | CC_aarch64_unknown_linux_musl=musl-gcc \ 23 | CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \ 24 | CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-aarch64 -L /musl-aarch64" \ 25 | EXTRA_RUSTFLAGS="-Clink-args=-lgcc -L /musl-aarch64/lib" 26 | -------------------------------------------------------------------------------- /libc-test/src/cmsg.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Since the cmsg(3) macros are macros instead of functions, they aren't 5 | // available to FFI. libc must reimplement them, which is error-prone. This 6 | // file provides FFI access to the actual macros so they can be tested against 7 | // the Rust reimplementations. 8 | 9 | struct cmsghdr *cmsg_firsthdr(struct msghdr *msgh) { 10 | return CMSG_FIRSTHDR(msgh); 11 | } 12 | 13 | struct cmsghdr *cmsg_nxthdr(struct msghdr *msgh, struct cmsghdr *cmsg) { 14 | return CMSG_NXTHDR(msgh, cmsg); 15 | } 16 | 17 | size_t cmsg_space(size_t length) { 18 | return CMSG_SPACE(length); 19 | } 20 | 21 | size_t cmsg_len(size_t length) { 22 | return CMSG_LEN(length); 23 | } 24 | 25 | unsigned char *cmsg_data(struct cmsghdr *cmsg) { 26 | return CMSG_DATA(cmsg); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /ci/docker/i686-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:23.10 2 | 3 | # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time 4 | RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ 5 | /etc/apt/sources.list && \ 6 | dpkg --add-architecture i386 && \ 7 | apt-get update && apt-get install -y --no-install-recommends \ 8 | ca-certificates \ 9 | curl \ 10 | gcc-multilib \ 11 | git \ 12 | libc6-dev \ 13 | libc6-i386 \ 14 | make \ 15 | patch \ 16 | rsync \ 17 | xz-utils 18 | 19 | ARG MUSL_VERSION 20 | COPY install-musl.sh / 21 | RUN /install-musl.sh i686 "$MUSL_VERSION" 22 | 23 | ENV PATH=$PATH:/musl-i686/bin:/rust/bin \ 24 | CC_i686_unknown_linux_musl=musl-gcc \ 25 | EXTRA_RUSTFLAGS="-L /musl-i686/lib" 26 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/arm.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = u32; 4 | pub type wchar_t = u32; 5 | pub type time_t = i64; 6 | pub type suseconds_t = i32; 7 | pub type register_t = i32; 8 | pub type __greg_t = c_uint; 9 | pub type __gregset_t = [crate::__greg_t; 17]; 10 | 11 | s! { 12 | pub struct mcontext_t { 13 | pub __gregs: crate::__gregset_t, 14 | pub mc_vfp_size: usize, 15 | pub mc_vfp_ptr: *mut c_void, 16 | pub mc_spare: [c_uint; 33], 17 | } 18 | } 19 | 20 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 21 | 22 | pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; 23 | pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; 24 | 25 | pub const MAP_32BIT: c_int = 0x00080000; 26 | pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4 27 | pub const TIOCTIMESTAMP: c_ulong = 0x40107459; 28 | -------------------------------------------------------------------------------- /src/unix/nto/aarch64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type wchar_t = u32; 4 | pub type time_t = i64; 5 | 6 | s! { 7 | pub struct aarch64_qreg_t { 8 | pub qlo: u64, 9 | pub qhi: u64, 10 | } 11 | 12 | pub struct aarch64_fpu_registers { 13 | pub reg: [crate::aarch64_qreg_t; 32], 14 | pub fpsr: u32, 15 | pub fpcr: u32, 16 | } 17 | 18 | pub struct aarch64_cpu_registers { 19 | pub gpr: [u64; 32], 20 | pub elr: u64, 21 | pub pstate: u64, 22 | } 23 | 24 | #[repr(align(16))] 25 | pub struct mcontext_t { 26 | pub cpu: crate::aarch64_cpu_registers, 27 | pub fpu: crate::aarch64_fpu_registers, 28 | } 29 | 30 | pub struct stack_t { 31 | pub ss_sp: *mut c_void, 32 | pub ss_size: size_t, 33 | pub ss_flags: c_int, 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ci/docker/powerpc64le-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | curl \ 6 | gcc \ 7 | gcc-powerpc64le-linux-gnu \ 8 | git \ 9 | libc6-dev \ 10 | make \ 11 | patch \ 12 | qemu-user \ 13 | rsync \ 14 | xz-utils 15 | 16 | ARG MUSL_VERSION 17 | COPY install-musl.sh / 18 | RUN /install-musl.sh powerpc64le "$MUSL_VERSION" 19 | 20 | # FIXME: shouldn't need the `-lgcc` here, shouldn't that be in std? 21 | ENV PATH=$PATH:/musl-powerpc64/bin:/rust/bin \ 22 | CC_powerpc64le_unknown_linux_musl=musl-gcc \ 23 | CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \ 24 | CARGO_TARGET_POWERPC64LE_UNKNOWN_LINUX_MUSL_RUNNER="qemu-ppc64le -L /musl-powerpc64" \ 25 | EXTRA_RUSTFLAGS="-Clink-args=-lgcc -L /musl-powerpc64/lib" 26 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/qos.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread/qos.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | pub use crate::sys::qos::*; 7 | 8 | extern "C" { 9 | pub fn pthread_attr_set_qos_class_np( 10 | attr: *mut crate::pthread_attr_t, 11 | class: qos_class_t, 12 | priority: c_int, 13 | ) -> c_int; 14 | pub fn pthread_attr_get_qos_class_np( 15 | attr: *mut crate::pthread_attr_t, 16 | class: *mut qos_class_t, 17 | priority: *mut c_int, 18 | ) -> c_int; 19 | pub fn pthread_set_qos_class_self_np(class: qos_class_t, priority: c_int) -> c_int; 20 | pub fn pthread_get_qos_class_np( 21 | thread: crate::pthread_t, 22 | class: *mut qos_class_t, 23 | priority: *mut c_int, 24 | ) -> c_int; 25 | } 26 | -------------------------------------------------------------------------------- /ci/docker/loongarch64-unknown-linux-musl/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | curl \ 6 | gcc \ 7 | gcc-14-loongarch64-linux-gnu \ 8 | git \ 9 | libc6-dev \ 10 | make \ 11 | patch \ 12 | qemu-user \ 13 | rsync \ 14 | xz-utils 15 | 16 | ARG MUSL_VERSION 17 | COPY install-musl.sh / 18 | RUN /install-musl.sh loongarch64 "$MUSL_VERSION" 19 | 20 | ENV CC_loongarch64_unknown_linux_musl=musl-gcc \ 21 | CFLAGS_loongarch64_unknown_linux_musl="-mabi=lp64d -fPIC" \ 22 | CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_LINKER=musl-gcc \ 23 | CARGO_TARGET_LOONGARCH64_UNKNOWN_LINUX_MUSL_RUNNER="qemu-loongarch64" \ 24 | EXTRA_RUSTFLAGS="-Ctarget-feature=+crt-static" \ 25 | QEMU_LD_PREFIX=/musl-loongarch64 \ 26 | PATH=$PATH:/musl-loongarch64/bin:/rust/bin 27 | -------------------------------------------------------------------------------- /ctest/src/ast/static_variable.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | Abi, 3 | BoxStr, 4 | }; 5 | 6 | /// Represents a static variable in Rust. 7 | /// 8 | /// This structure is only used for parsing statics in extern blocks, 9 | /// as a result it does not have a field for storing the expression. 10 | #[derive(Debug, Clone)] 11 | pub struct Static { 12 | pub(crate) public: bool, 13 | #[expect(unused)] 14 | pub(crate) abi: Abi, 15 | pub(crate) ident: BoxStr, 16 | pub(crate) link_name: Option, 17 | pub(crate) ty: syn::Type, 18 | } 19 | 20 | impl Static { 21 | /// Return the identifier of the static variable as a string. 22 | pub fn ident(&self) -> &str { 23 | &self.ident 24 | } 25 | 26 | /// Return the name of the function to be linked C side with. 27 | pub fn link_name(&self) -> Option<&str> { 28 | self.link_name.as_deref() 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /libc-test/semver/netbsd-aarch64.txt: -------------------------------------------------------------------------------- 1 | PT_GETFPREGS 2 | PT_GETREGS 3 | PT_SETFPREGS 4 | PT_SETREGS 5 | _REG_CPSR 6 | _REG_ELR 7 | _REG_FP 8 | _REG_LR 9 | _REG_PC 10 | _REG_R0 11 | _REG_R1 12 | _REG_R10 13 | _REG_R11 14 | _REG_R12 15 | _REG_R13 16 | _REG_R14 17 | _REG_R15 18 | _REG_R2 19 | _REG_R3 20 | _REG_R4 21 | _REG_R5 22 | _REG_R6 23 | _REG_R7 24 | _REG_R8 25 | _REG_R9 26 | _REG_RV 27 | _REG_SP 28 | _REG_SPSR 29 | _REG_TIPDR 30 | _REG_X0 31 | _REG_X1 32 | _REG_X10 33 | _REG_X11 34 | _REG_X12 35 | _REG_X13 36 | _REG_X14 37 | _REG_X15 38 | _REG_X16 39 | _REG_X17 40 | _REG_X18 41 | _REG_X19 42 | _REG_X2 43 | _REG_X20 44 | _REG_X21 45 | _REG_X22 46 | _REG_X23 47 | _REG_X24 48 | _REG_X25 49 | _REG_X26 50 | _REG_X27 51 | _REG_X28 52 | _REG_X29 53 | _REG_X3 54 | _REG_X30 55 | _REG_X31 56 | _REG_X4 57 | _REG_X5 58 | _REG_X6 59 | _REG_X7 60 | _REG_X8 61 | _REG_X9 62 | __fregset 63 | mcontext_t 64 | ucontext_t 65 | -------------------------------------------------------------------------------- /ctest/tests/input/simple.rs: -------------------------------------------------------------------------------- 1 | use std::ffi::{c_char, c_int, c_ulong, c_void}; 2 | 3 | pub type Byte = u8; 4 | 5 | pub type volatile_char = c_char; 6 | 7 | // This should be automatically skipped for roundtripping. 8 | pub type gregset_t = [c_ulong; 32]; 9 | 10 | pub type Color = c_int; 11 | pub const RED: Color = 0; 12 | pub const BLUE: Color = RED + 1; 13 | pub const GREEN: Color = BLUE + 1; 14 | 15 | #[repr(C)] 16 | pub struct Person { 17 | pub name: *const c_char, 18 | pub age: u8, 19 | pub job: extern "C" fn(u8, *const c_char), 20 | pub favorite_color: Color, 21 | } 22 | 23 | #[repr(C)] 24 | pub union Word { 25 | pub word: u16, 26 | pub byte: [Byte; 2], 27 | } 28 | 29 | const A: *const c_char = c"abc".as_ptr(); 30 | const B: *const c_char = c"bac".as_ptr(); 31 | 32 | unsafe extern "C" { 33 | pub fn calloc(num: usize, size: usize) -> *mut c_void; 34 | 35 | pub static byte: Byte; 36 | } 37 | -------------------------------------------------------------------------------- /src/new/apple/xnu/mod.rs: -------------------------------------------------------------------------------- 1 | //! Source from XNU 2 | //! 3 | //! We omit nesting for the `bsd` module since most items of interest are in there. 4 | 5 | /// Directory: `arm/` 6 | /// 7 | /// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/arm 8 | #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] 9 | pub(crate) mod arm { 10 | pub(crate) mod _mcontext; 11 | } 12 | 13 | /// Directory: `i386/` 14 | /// 15 | /// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/i386 16 | #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] 17 | pub(crate) mod i386 { 18 | pub(crate) mod _mcontext; 19 | } 20 | 21 | pub(crate) mod mach; 22 | 23 | /// Directory: `machine/` 24 | /// 25 | /// https://github.com/apple-oss-distributions/xnu/tree/main/bsd/machine 26 | pub(crate) mod machine { 27 | pub(crate) mod _mcontext; 28 | } 29 | 30 | pub(crate) mod sys; 31 | -------------------------------------------------------------------------------- /src/new/netbsd/utmp_.rs: -------------------------------------------------------------------------------- 1 | //! Header: `utmp.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | pub const UT_NAMESIZE: usize = 8; 8 | pub const UT_LINESIZE: usize = 8; 9 | pub const UT_HOSTSIZE: usize = 16; 10 | 11 | s! { 12 | pub struct lastlog { 13 | pub ll_time: crate::time_t, 14 | pub ll_line: [c_char; UT_LINESIZE], 15 | pub ll_host: [c_char; UT_HOSTSIZE], 16 | } 17 | 18 | pub struct utmp { 19 | pub ut_line: [c_char; UT_LINESIZE], 20 | pub ut_name: [c_char; UT_NAMESIZE], 21 | pub ut_host: [c_char; UT_HOSTSIZE], 22 | pub ut_time: crate::time_t, 23 | } 24 | } 25 | 26 | #[link(name = "util")] 27 | extern "C" { 28 | pub fn utmpname(file: *const c_char) -> c_int; 29 | pub fn setutent(); 30 | #[link_name = "__getutent50"] 31 | pub fn getutent() -> *mut utmp; 32 | pub fn endutent(); 33 | } 34 | -------------------------------------------------------------------------------- /ctest/src/ast/function.rs: -------------------------------------------------------------------------------- 1 | use crate::{ 2 | Abi, 3 | BoxStr, 4 | Parameter, 5 | }; 6 | 7 | /// Represents a function signature defined in Rust. 8 | /// 9 | /// This structure is only used for parsing functions in extern blocks. 10 | #[derive(Debug, Clone)] 11 | pub struct Fn { 12 | pub(crate) public: bool, 13 | #[expect(unused)] 14 | pub(crate) abi: Abi, 15 | pub(crate) ident: BoxStr, 16 | pub(crate) link_name: Option, 17 | #[expect(unused)] 18 | pub(crate) parameters: Vec, 19 | #[expect(unused)] 20 | pub(crate) return_type: Option, 21 | } 22 | 23 | impl Fn { 24 | /// Return the identifier of the function as a string. 25 | pub fn ident(&self) -> &str { 26 | &self.ident 27 | } 28 | 29 | /// Return the name of the function to be linked C side with. 30 | pub fn link_name(&self) -> Option<&str> { 31 | self.link_name.as_deref() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ci/docker/x86_64-linux-android/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN apt-get update && apt-get install -y --no-install-recommends \ 4 | ca-certificates \ 5 | gcc \ 6 | libc-dev \ 7 | python3 \ 8 | unzip \ 9 | wget 10 | 11 | WORKDIR /android/ 12 | ENV ANDROID_ARCH=x86_64 13 | COPY android-install-ndk.sh /android/ 14 | RUN /android/android-install-ndk.sh 15 | 16 | # We do not run x86_64-linux-android tests on an android emulator. 17 | # See ci/android-sysimage.sh for information about how tests are run. 18 | COPY android-sysimage.sh /android/ 19 | RUN /android/android-sysimage.sh x86_64 x86_64-24_r07.zip 20 | 21 | ENV PATH=$PATH:/rust/bin:/android/linux-x86_64/bin \ 22 | CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android28-clang \ 23 | CC_x86_64_linux_android=x86_64-linux-android28-clang \ 24 | CXX_x86_64_linux_android=x86_64-linux-android28-clang++ \ 25 | AR_x86_64_linux_android=llvm-ar \ 26 | HOME=/tmp 27 | -------------------------------------------------------------------------------- /ci/docker/wasm32-unknown-emscripten/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | # This is a workaround to avoid the interaction with tzdata. 4 | ENV DEBIAN_FRONTEND=noninteractive 5 | ENV TZ=America/New_York 6 | 7 | RUN apt-get update && apt-get install -y --no-install-recommends \ 8 | bzip2 \ 9 | ca-certificates \ 10 | cmake \ 11 | curl \ 12 | file \ 13 | g++ \ 14 | gcc \ 15 | gdb \ 16 | git \ 17 | libc6-dev \ 18 | libxml2 \ 19 | make \ 20 | python3 \ 21 | tzdata \ 22 | sudo \ 23 | xz-utils 24 | 25 | RUN ln -s /usr/bin/python3 /usr/bin/python & \ 26 | ln -s /usr/bin/pip3 /usr/bin/pip 27 | COPY emscripten.sh / 28 | RUN /emscripten.sh 29 | 30 | ENV PATH=$PATH:/rust/bin \ 31 | CARGO_TARGET_WASM32_UNKNOWN_EMSCRIPTEN_RUNNER=node-wrapper.sh 32 | 33 | COPY emscripten-entry.sh / 34 | COPY docker/wasm32-unknown-emscripten/node-wrapper.sh /usr/local/bin/node-wrapper.sh 35 | ENTRYPOINT ["/emscripten-entry.sh"] 36 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/powerpc.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = u32; 4 | pub type wchar_t = i32; 5 | pub type time_t = i64; 6 | pub type suseconds_t = i32; 7 | pub type register_t = i32; 8 | 9 | s! { 10 | #[repr(align(16))] 11 | pub struct mcontext_t { 12 | pub mc_vers: c_int, 13 | pub mc_flags: c_int, 14 | pub mc_onstack: c_int, 15 | pub mc_len: c_int, 16 | pub mc_avec: [u64; 64], 17 | pub mc_av: [u32; 2], 18 | pub mc_frame: [crate::register_t; 42], 19 | pub mc_fpreg: [u64; 33], 20 | pub mc_vsxfpreg: [u64; 32], 21 | } 22 | } 23 | 24 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 25 | 26 | pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; 27 | pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; 28 | pub const MAP_32BIT: c_int = 0x00080000; 29 | pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 30 | pub const TIOCTIMESTAMP: c_ulong = 0x40107459; 31 | -------------------------------------------------------------------------------- /src/new/common/linux_like/pthread.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | extern "C" { 4 | #[cfg(any(target_os = "linux", target_os = "l4re"))] 5 | pub fn pthread_getaffinity_np( 6 | thread: crate::pthread_t, 7 | cpusetsize: size_t, 8 | cpuset: *mut crate::cpu_set_t, 9 | ) -> c_int; 10 | 11 | pub fn pthread_getattr_np(native: crate::pthread_t, attr: *mut crate::pthread_attr_t) -> c_int; 12 | 13 | #[cfg(target_os = "linux")] 14 | pub fn pthread_getname_np(thread: crate::pthread_t, name: *mut c_char, len: size_t) -> c_int; 15 | 16 | #[cfg(any(target_os = "linux", target_os = "l4re"))] 17 | pub fn pthread_setaffinity_np( 18 | thread: crate::pthread_t, 19 | cpusetsize: size_t, 20 | cpuset: *const crate::cpu_set_t, 21 | ) -> c_int; 22 | 23 | #[cfg(any(target_os = "android", target_os = "linux"))] 24 | pub fn pthread_setname_np(thread: crate::pthread_t, name: *const c_char) -> c_int; 25 | } 26 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/powerpc64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = u32; 4 | pub type wchar_t = i32; 5 | pub type time_t = i64; 6 | pub type suseconds_t = i64; 7 | pub type register_t = i64; 8 | 9 | s! { 10 | #[repr(align(16))] 11 | pub struct mcontext_t { 12 | pub mc_vers: c_int, 13 | pub mc_flags: c_int, 14 | pub mc_onstack: c_int, 15 | pub mc_len: c_int, 16 | pub mc_avec: [u64; 64], 17 | pub mc_av: [u32; 2], 18 | pub mc_frame: [crate::register_t; 42], 19 | pub mc_fpreg: [u64; 33], 20 | pub mc_vsxfpreg: [u64; 32], 21 | } 22 | } 23 | 24 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 25 | 26 | pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; 27 | pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; 28 | 29 | pub const MAP_32BIT: c_int = 0x00080000; 30 | pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 31 | pub const TIOCTIMESTAMP: c_ulong = 0x40107459; 32 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | # release-plz for the stable 0.2 branch 2 | 3 | name: Release-plz 4 | 5 | permissions: 6 | pull-requests: write 7 | contents: write 8 | 9 | on: 10 | push: 11 | branches: 12 | - main 13 | 14 | jobs: 15 | release-plz: 16 | name: Release-plz 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout repository 20 | uses: actions/checkout@v6 21 | with: 22 | fetch-depth: 0 23 | - name: Install Rust (rustup) 24 | run: rustup update stable --no-self-update && rustup default stable 25 | - name: Run release-plz 26 | uses: MarcoIeni/release-plz-action@v0.5 27 | env: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} 30 | with: 31 | # FIXME(release): release-pr is broken since we have two release tracks for 32 | # `libc` :( 33 | command: release 34 | -------------------------------------------------------------------------------- /libc-test/semver/android-x86_64.txt: -------------------------------------------------------------------------------- 1 | AT_SYSINFO_EHDR 2 | AT_VECTOR_SIZE_ARCH 3 | EFLAGS 4 | FS_BASE 5 | GS_BASE 6 | ORIG_RAX 7 | R10 8 | R11 9 | R12 10 | R13 11 | R14 12 | R15 13 | R8 14 | R9 15 | RAX 16 | RBP 17 | RBX 18 | RCX 19 | RDI 20 | RDX 21 | REG_CR2 22 | REG_CSGSFS 23 | REG_OLDMASK 24 | REG_R10 25 | REG_R11 26 | REG_R12 27 | REG_R13 28 | REG_R14 29 | REG_R15 30 | REG_R8 31 | REG_R9 32 | REG_RAX 33 | REG_RBP 34 | REG_RBX 35 | REG_RCX 36 | REG_RDI 37 | REG_RDX 38 | REG_RIP 39 | REG_RSI 40 | REG_RSP 41 | RIP 42 | RSI 43 | RSP 44 | SYS_accept 45 | SYS_arch_prctl 46 | SYS_epoll_ctl_old 47 | SYS_epoll_wait_old 48 | SYS_kexec_file_load 49 | SYS_memfd_secret 50 | SYS_msgctl 51 | SYS_msgget 52 | SYS_msgrcv 53 | SYS_msgsnd 54 | SYS_newfstatat 55 | SYS_security 56 | SYS_semctl 57 | SYS_semget 58 | SYS_semop 59 | SYS_semtimedop 60 | SYS_shmat 61 | SYS_shmctl 62 | SYS_shmdt 63 | SYS_shmget 64 | SYS_tuxcall 65 | SYS_vserver 66 | __c_anonymous_uc_sigmask 67 | _libc_fpxreg 68 | _libc_xmmreg 69 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/freebsd11/b64.rs: -------------------------------------------------------------------------------- 1 | use crate::off_t; 2 | use crate::prelude::*; 3 | 4 | s! { 5 | pub struct stat { 6 | pub st_dev: crate::dev_t, 7 | pub st_ino: crate::ino_t, 8 | pub st_mode: crate::mode_t, 9 | pub st_nlink: crate::nlink_t, 10 | pub st_uid: crate::uid_t, 11 | pub st_gid: crate::gid_t, 12 | pub st_rdev: crate::dev_t, 13 | pub st_atime: crate::time_t, 14 | pub st_atime_nsec: c_long, 15 | pub st_mtime: crate::time_t, 16 | pub st_mtime_nsec: c_long, 17 | pub st_ctime: crate::time_t, 18 | pub st_ctime_nsec: c_long, 19 | pub st_size: off_t, 20 | pub st_blocks: crate::blkcnt_t, 21 | pub st_blksize: crate::blksize_t, 22 | pub st_flags: crate::fflags_t, 23 | pub st_gen: u32, 24 | pub st_lspare: i32, 25 | pub st_birthtime: crate::time_t, 26 | pub st_birthtime_nsec: c_long, 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/unix/solarish/x86.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type Elf32_Addr = c_ulong; 4 | pub type Elf32_Half = c_ushort; 5 | pub type Elf32_Off = c_ulong; 6 | pub type Elf32_Sword = c_long; 7 | pub type Elf32_Word = c_ulong; 8 | pub type Elf32_Lword = c_ulonglong; 9 | pub type Elf32_Phdr = __c_anonymous_Elf32_Phdr; 10 | 11 | s! { 12 | pub struct __c_anonymous_Elf32_Phdr { 13 | pub p_type: Elf32_Word, 14 | pub p_offset: Elf32_Off, 15 | pub p_vaddr: Elf32_Addr, 16 | pub p_paddr: Elf32_Addr, 17 | pub p_filesz: Elf32_Word, 18 | pub p_memsz: Elf32_Word, 19 | pub p_flags: Elf32_Word, 20 | pub p_align: Elf32_Word, 21 | } 22 | 23 | pub struct dl_phdr_info { 24 | pub dlpi_addr: Elf32_Addr, 25 | pub dlpi_name: *const c_char, 26 | pub dlpi_phdr: *const Elf32_Phdr, 27 | pub dlpi_phnum: Elf32_Half, 28 | pub dlpi_adds: c_ulonglong, 29 | pub dlpi_subs: c_ulonglong, 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ci/docker/arm-unknown-linux-musleabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:23.10 2 | 3 | # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time 4 | RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ 5 | /etc/apt/sources.list && \ 6 | apt-get update && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | curl \ 9 | gcc \ 10 | gcc-arm-linux-gnueabihf \ 11 | git \ 12 | libc6-dev \ 13 | make \ 14 | patch \ 15 | qemu-user \ 16 | rsync \ 17 | xz-utils 18 | 19 | ARG MUSL_VERSION 20 | COPY install-musl.sh / 21 | RUN /install-musl.sh arm "$MUSL_VERSION" 22 | 23 | ENV PATH=$PATH:/musl-arm/bin:/rust/bin \ 24 | CC_arm_unknown_linux_musleabihf=musl-gcc \ 25 | CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_LINKER=musl-gcc \ 26 | CARGO_TARGET_ARM_UNKNOWN_LINUX_MUSLEABIHF_RUNNER="qemu-arm -L /musl-arm" \ 27 | EXTRA_RUSTFLAGS="-L /musl-arm/lib" 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a bug report for the libc crate. 4 | labels: C-bug 5 | --- 6 | 7 | 24 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/freebsd11/b32.rs: -------------------------------------------------------------------------------- 1 | use crate::off_t; 2 | use crate::prelude::*; 3 | 4 | s! { 5 | pub struct stat { 6 | pub st_dev: crate::dev_t, 7 | pub st_ino: crate::ino_t, 8 | pub st_mode: crate::mode_t, 9 | pub st_nlink: crate::nlink_t, 10 | pub st_uid: crate::uid_t, 11 | pub st_gid: crate::gid_t, 12 | pub st_rdev: crate::dev_t, 13 | pub st_atime: crate::time_t, 14 | pub st_atime_nsec: c_long, 15 | pub st_mtime: crate::time_t, 16 | pub st_mtime_nsec: c_long, 17 | pub st_ctime: crate::time_t, 18 | pub st_ctime_nsec: c_long, 19 | pub st_size: off_t, 20 | pub st_blocks: crate::blkcnt_t, 21 | pub st_blksize: crate::blksize_t, 22 | pub st_flags: crate::fflags_t, 23 | pub st_gen: u32, 24 | pub st_lspare: i32, 25 | pub st_birthtime: crate::time_t, 26 | pub st_birthtime_nsec: c_long, 27 | __unused: Padding<[u8; 8]>, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/new/glibc/sysdeps/unix/linux/net/route.rs: -------------------------------------------------------------------------------- 1 | //! Header: `net/route.h` 2 | //! 3 | //! Source header: `sysdeps/unix/sysv/linux/net/route.h` 4 | //! 5 | 6 | use crate::prelude::*; 7 | 8 | s! { 9 | pub struct rtentry { 10 | pub rt_pad1: c_ulong, 11 | pub rt_dst: crate::sockaddr, 12 | pub rt_gateway: crate::sockaddr, 13 | pub rt_genmask: crate::sockaddr, 14 | pub rt_flags: c_ushort, 15 | pub rt_pad2: c_short, 16 | pub rt_pad3: c_ulong, 17 | pub rt_tos: c_uchar, 18 | pub rt_class: c_uchar, 19 | // FIXME(1.0): private padding fields 20 | #[cfg(target_pointer_width = "64")] 21 | pub rt_pad4: [c_short; 3usize], 22 | #[cfg(not(target_pointer_width = "64"))] 23 | pub rt_pad4: c_short, 24 | pub rt_metric: c_short, 25 | pub rt_dev: *mut c_char, 26 | pub rt_mtu: c_ulong, 27 | pub rt_window: c_ulong, 28 | pub rt_irtt: c_ushort, 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/new/apple/xnu/mach/arm/_structs.rs: -------------------------------------------------------------------------------- 1 | //! Header: `arm/_structs.h` 2 | //! 3 | //! 4 | 5 | #[cfg(target_arch = "arm")] 6 | use crate::prelude::*; 7 | 8 | s! { 9 | pub struct __darwin_arm_exception_state64 { 10 | pub __far: u64, 11 | pub __esr: u32, 12 | pub __exception: u32, 13 | } 14 | 15 | pub struct __darwin_arm_thread_state64 { 16 | pub __x: [u64; 29], 17 | pub __fp: u64, 18 | pub __lr: u64, 19 | pub __sp: u64, 20 | pub __pc: u64, 21 | pub __cpsr: u32, 22 | pub __pad: u32, 23 | } 24 | 25 | #[cfg(target_arch = "aarch64")] 26 | pub struct __darwin_arm_neon_state64 { 27 | pub __v: [crate::__uint128_t; 32], 28 | pub __fpsr: u32, 29 | pub __fpcr: u32, 30 | } 31 | 32 | #[cfg(target_arch = "arm")] 33 | #[repr(align(16))] 34 | pub struct __darwin_arm_neon_state64 { 35 | opaque: [c_char; (32 * 16) + (2 * size_of::())], 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/new/musl/mod.rs: -------------------------------------------------------------------------------- 1 | //! Musl libc. 2 | //! 3 | //! * Headers: (official) 4 | //! * Headers: (mirror) 5 | 6 | // The musl build system includes `arch/$(ARCH)` (preferred if it exists) and `arch/generic` (used 7 | // as the fallback). We can't exactly mirror this with glob exports, so instead we selectively 8 | // reexport in a new module. 9 | mod arch; 10 | 11 | pub(crate) mod bits { 12 | cfg_if! { 13 | if #[cfg(target_arch = "mips")] { 14 | pub(crate) use super::arch::mips::bits::socket; 15 | } else if #[cfg(target_arch = "mips64")] { 16 | pub(crate) use super::arch::mips64::bits::socket; 17 | } else { 18 | // Reexports from generic will live here once we need them. 19 | } 20 | } 21 | } 22 | 23 | pub(crate) mod pthread; 24 | 25 | /// Directory: `sys/` 26 | /// 27 | /// 28 | pub(crate) mod sys { 29 | pub(crate) mod socket; 30 | } 31 | 32 | pub(crate) mod sched; 33 | pub(crate) mod unistd; 34 | -------------------------------------------------------------------------------- /src/new/glibc/mod.rs: -------------------------------------------------------------------------------- 1 | //! GNU libc. 2 | //! 3 | //! * Headers: (official) 4 | //! * Headers: (mirror) 5 | //! 6 | //! This module structure is modeled after glibc's source tree. Its build system selects headers 7 | //! from different locations based on the platform, which we mimic here with reexports. 8 | 9 | /// Source directory: `posix/` 10 | /// 11 | /// 12 | mod posix { 13 | pub(crate) mod unistd; 14 | } 15 | 16 | /// Source directory: `sysdeps/` 17 | /// 18 | /// 19 | mod sysdeps { 20 | // FIXME(pthread): eventually all platforms should use this module 21 | #[cfg(target_os = "linux")] 22 | pub(crate) mod nptl; 23 | pub(crate) mod unix; 24 | } 25 | 26 | pub(crate) use posix::*; 27 | // FIXME(pthread): eventually all platforms should use this module 28 | #[cfg(target_os = "linux")] 29 | pub(crate) use sysdeps::nptl::*; 30 | #[cfg(target_os = "linux")] 31 | pub(crate) use sysdeps::unix::linux::*; 32 | -------------------------------------------------------------------------------- /ctest-test/src/t2.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | 3 | use std::ffi::{ 4 | c_char, 5 | c_int, 6 | }; 7 | 8 | pub type T2Foo = u32; 9 | pub type T2Bar = u32; 10 | 11 | pub type T2TypedefFoo = T2Foo; 12 | pub type T2TypedefInt = c_int; 13 | 14 | macro_rules! i { 15 | ($i:item) => { 16 | $i 17 | }; 18 | } 19 | 20 | #[repr(C)] 21 | #[derive(Debug)] 22 | pub struct T2Baz { 23 | pub a: i64, 24 | pub b: u32, 25 | } 26 | 27 | #[repr(C)] 28 | pub union T2Union { 29 | pub a: u32, 30 | pub b: i64, 31 | } 32 | 33 | pub const T2C: i32 = 5; 34 | 35 | i! { 36 | pub const T2S: *const c_char = b"b\0".as_ptr().cast(); 37 | } 38 | 39 | extern "C" { 40 | pub fn T2a(); 41 | } 42 | 43 | #[cfg(target_env = "msvc")] 44 | pub type enum_repr_too_small = i16; 45 | #[cfg(not(target_env = "msvc"))] 46 | pub type enum_repr_too_small = u16; 47 | pub const ENUM_REPR_TOO_SMALL_A: enum_repr_too_small = 0; 48 | 49 | #[cfg(target_env = "msvc")] 50 | pub type enum_wrong_signedness = u32; 51 | #[cfg(not(target_env = "msvc"))] 52 | pub type enum_wrong_signedness = i32; 53 | pub const ENUM_WRONG_SIGNEDNESS_A: enum_wrong_signedness = 0; 54 | -------------------------------------------------------------------------------- /src/windows/gnu/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | cfg_if! { 4 | if #[cfg(target_pointer_width = "64")] { 5 | s_no_extra_traits! { 6 | #[repr(align(16))] 7 | pub struct max_align_t { 8 | priv_: [f64; 4], 9 | } 10 | } 11 | } else if #[cfg(target_pointer_width = "32")] { 12 | s_no_extra_traits! { 13 | #[repr(align(16))] 14 | pub struct max_align_t { 15 | priv_: [i64; 6], 16 | } 17 | } 18 | } 19 | } 20 | 21 | // stdio file descriptor numbers 22 | pub const STDIN_FILENO: c_int = 0; 23 | pub const STDOUT_FILENO: c_int = 1; 24 | pub const STDERR_FILENO: c_int = 2; 25 | 26 | extern "C" { 27 | pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; 28 | pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; 29 | 30 | // NOTE: For MSVC target, `wmemchr` is only a inline function in `` 31 | // header file. We cannot find a way to link to that symbol from Rust. 32 | pub fn wmemchr(cx: *const crate::wchar_t, c: crate::wchar_t, n: size_t) -> *mut crate::wchar_t; 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2020 The Rust Project Developers 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /ctest/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014-2020 Alex Crichton, Gonzalo Brito Gadeschi, Yuki Okushi 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. 26 | -------------------------------------------------------------------------------- /libc-test/semver/wasi-p2.txt: -------------------------------------------------------------------------------- 1 | AF_INET 2 | AF_INET6 3 | AF_UNSPEC 4 | EAI_SYSTEM 5 | IPPROTO_IP 6 | IPPROTO_IPV6 7 | IPPROTO_TCP 8 | IPPROTO_UDP 9 | IPV6_ADD_MEMBERSHIP 10 | IPV6_DROP_MEMBERSHIP 11 | IPV6_JOIN_GROUP 12 | IPV6_LEAVE_GROUP 13 | IPV6_MULTICAST_LOOP 14 | IPV6_UNICAST_HOPS 15 | IPV6_V6ONLY 16 | IP_ADD_MEMBERSHIP 17 | IP_DROP_MEMBERSHIP 18 | IP_MULTICAST_LOOP 19 | IP_MULTICAST_TTL 20 | IP_TTL 21 | MSG_NOSIGNAL 22 | MSG_PEEK 23 | SHUT_RD 24 | SHUT_RDWR 25 | SHUT_WR 26 | SOCK_DGRAM 27 | SOCK_NONBLOCK 28 | SOCK_STREAM 29 | SOL_SOCKET 30 | SO_ACCEPTCONN 31 | SO_BROADCAST 32 | SO_DOMAIN 33 | SO_ERROR 34 | SO_KEEPALIVE 35 | SO_LINGER 36 | SO_PROTOCOL 37 | SO_RCVBUF 38 | SO_RCVTIMEO 39 | SO_REUSEADDR 40 | SO_SNDBUF 41 | SO_SNDTIMEO 42 | SO_TYPE 43 | TCP_KEEPCNT 44 | TCP_KEEPIDLE 45 | TCP_KEEPINTVL 46 | TCP_NODELAY 47 | accept 48 | accept4 49 | addrinfo 50 | bind 51 | connect 52 | freeaddrinfo 53 | gai_strerror 54 | getaddrinfo 55 | getpeername 56 | getsockname 57 | getsockopt 58 | in6_addr 59 | in_addr 60 | in_addr_t 61 | in_port_t 62 | ip_mreq 63 | ipv6_mreq 64 | linger 65 | listen 66 | recvfrom 67 | sa_family_t 68 | sendto 69 | setsockopt 70 | sockaddr 71 | sockaddr_in 72 | sockaddr_in6 73 | sockaddr_storage 74 | socket 75 | socklen_t 76 | -------------------------------------------------------------------------------- /src/new/apple/libpthread/pthread_/introspection.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread/introspection.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | pub use crate::pthread_::pthread::*; 7 | 8 | c_enum! { 9 | #[repr(c_uint)] 10 | pub enum #anon { 11 | pub PTHREAD_INTROSPECTION_THREAD_CREATE = 1, 12 | pub PTHREAD_INTROSPECTION_THREAD_START, 13 | pub PTHREAD_INTROSPECTION_THREAD_TERMINATE, 14 | pub PTHREAD_INTROSPECTION_THREAD_DESTROY, 15 | } 16 | } 17 | 18 | pub type pthread_introspection_hook_t = 19 | extern "C" fn(event: c_uint, thread: pthread_t, addr: *mut c_void, size: size_t); 20 | 21 | extern "C" { 22 | // Available from Big Sur 23 | pub fn pthread_introspection_hook_install( 24 | hook: pthread_introspection_hook_t, 25 | ) -> pthread_introspection_hook_t; 26 | pub fn pthread_introspection_setspecific_np( 27 | thread: pthread_t, 28 | key: pthread_key_t, 29 | value: *const c_void, 30 | ) -> c_int; 31 | 32 | pub fn pthread_introspection_getspecific_np( 33 | thread: pthread_t, 34 | key: pthread_key_t, 35 | ) -> *mut c_void; 36 | } 37 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/aarch64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = i32; 4 | pub type wchar_t = u32; 5 | pub type time_t = i64; 6 | pub type suseconds_t = i64; 7 | pub type register_t = i64; 8 | 9 | s! { 10 | pub struct gpregs { 11 | pub gp_x: [crate::register_t; 30], 12 | pub gp_lr: crate::register_t, 13 | pub gp_sp: crate::register_t, 14 | pub gp_elr: crate::register_t, 15 | pub gp_spsr: u32, 16 | pub gp_pad: c_int, 17 | } 18 | 19 | pub struct fpregs { 20 | pub fp_q: u128, 21 | pub fp_sr: u32, 22 | pub fp_cr: u32, 23 | pub fp_flags: c_int, 24 | pub fp_pad: c_int, 25 | } 26 | 27 | pub struct mcontext_t { 28 | pub mc_gpregs: gpregs, 29 | pub mc_fpregs: fpregs, 30 | pub mc_flags: c_int, 31 | pub mc_pad: c_int, 32 | pub mc_spare: [u64; 8], 33 | } 34 | } 35 | 36 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 37 | 38 | pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; 39 | pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; 40 | pub const MAP_32BIT: c_int = 0x00080000; 41 | pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4 42 | pub const TIOCTIMESTAMP: c_ulong = 0x40107459; 43 | -------------------------------------------------------------------------------- /ctest/src/ast/mod.rs: -------------------------------------------------------------------------------- 1 | mod constant; 2 | mod field; 3 | mod function; 4 | mod parameter; 5 | mod static_variable; 6 | mod structure; 7 | mod type_alias; 8 | mod union; 9 | 10 | use std::fmt; 11 | 12 | pub use constant::Const; 13 | pub use field::Field; 14 | pub use function::Fn; 15 | pub use parameter::Parameter; 16 | pub use static_variable::Static; 17 | pub use structure::Struct; 18 | pub use type_alias::Type; 19 | pub use union::Union; 20 | 21 | /// The ABI as defined by the extern block. 22 | #[derive(Debug, Clone, PartialEq, Eq)] 23 | pub enum Abi { 24 | /// The C ABI. 25 | C, 26 | /// The Rust ABI. 27 | Rust, 28 | /// Any other ABI. 29 | Other(String), 30 | } 31 | 32 | impl From<&str> for Abi { 33 | fn from(value: &str) -> Self { 34 | match value.to_lowercase().as_str() { 35 | "c" => Abi::C, 36 | "rust" => Abi::Rust, 37 | s => Abi::Other(s.to_string()), 38 | } 39 | } 40 | } 41 | 42 | impl fmt::Display for Abi { 43 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 44 | match self { 45 | Abi::C => write!(f, "C"), 46 | Abi::Rust => write!(f, "Rust"), 47 | Abi::Other(s) => write!(f, "{s}"), 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ci/prep-semver-baseline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Download a baseline crate to run semver checks against 3 | 4 | set -euxo pipefail 5 | 6 | # Retrieve the index for libc 7 | index=$(curl -L https://index.crates.io/li/bc/libc) 8 | 9 | # Regex for versions matching what we want to check against. Note we check only 10 | # a suffix since in the merge queue `base_ref` is set to something like 11 | # `refs/heads/main` rather than only the branch name. 12 | if [[ "${TARGET_REF:-}" = *"libc-0.2" ]]; then 13 | pat="^0.2" 14 | elif [[ "${TARGET_REF:-}" = *"main" ]]; then 15 | pat="^1.0" 16 | else 17 | echo "TARGET_REF must be set and end with either 'libc-0.2' or 'main'" 18 | exit 1 19 | fi 20 | 21 | # Find the most recent version matching a pattern. 22 | version=$( 23 | echo "$index" | 24 | jq -er --slurp --arg pat "$pat" ' 25 | map(select(.vers | test($pat))) 26 | | last 27 | | debug("version:", .) 28 | | .vers 29 | ' 30 | ) 31 | 32 | libc_cache="${XDG_CACHE_DIR:-$HOME/.cache}/libc-ci/" 33 | mkdir -p "$libc_cache" 34 | 35 | curl -L "https://static.crates.io/crates/libc/libc-$version.crate" | tar xzf - -C "$libc_cache" 36 | crate_dir="$libc_cache/libc-$version" 37 | 38 | echo "BASELINE_CRATE_DIR=$crate_dir" >> "$GITHUB_ENV" 39 | -------------------------------------------------------------------------------- /ci/docker/armv7-unknown-linux-uclibceabihf/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:23.10 2 | 3 | # FIXME(time): we are using an EOL release because 24.04 changes to 64-bit time 4 | RUN sed -i -E 's/(archive|security)\.ubuntu\.com/old-releases.ubuntu.com/g' \ 5 | /etc/apt/sources.list && \ 6 | apt-get update && apt-get install -y --no-install-recommends \ 7 | ca-certificates \ 8 | curl \ 9 | file \ 10 | gcc \ 11 | libc6-dev \ 12 | patch \ 13 | qemu-system-arm \ 14 | qemu-user \ 15 | xz-utils 16 | 17 | RUN mkdir /toolchain 18 | 19 | RUN curl --retry 5 -L https://toolchains.bootlin.com/downloads/releases/toolchains/armv7-eabihf/tarballs/armv7-eabihf--uclibc--bleeding-edge-2021.11-1.tar.bz2 | \ 20 | tar xjf - -C /toolchain --strip-components=1 21 | RUN /toolchain/relocate-sdk.sh 22 | 23 | ENV PATH=$PATH:/rust/bin:/toolchain/bin \ 24 | STAGING_DIR=/toolchain/armv7-buildroot-linux-uclibceabihf/sysroot \ 25 | CC_armv7_unknown_linux_uclibceabihf=arm-buildroot-linux-uclibcgnueabihf-gcc \ 26 | CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_LINKER=arm-buildroot-linux-uclibcgnueabihf-gcc \ 27 | CARGO_TARGET_ARMV7_UNKNOWN_LINUX_UCLIBCEABIHF_RUNNER="qemu-arm -L /toolchain/arm-buildroot-linux-uclibcgnueabihf/sysroot/" 28 | -------------------------------------------------------------------------------- /src/unix/newlib/generic.rs: -------------------------------------------------------------------------------- 1 | //! Common types used by most newlib platforms 2 | 3 | #[allow(unused_imports)] // needed for platforms that don't use the prelude here 4 | use crate::prelude::*; 5 | 6 | s! { 7 | #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] 8 | pub struct sigset_t { 9 | __val: u32, 10 | } 11 | 12 | #[cfg(all(not(target_os = "vita"), not(target_os = "horizon")))] 13 | pub struct stat { 14 | pub st_dev: crate::dev_t, 15 | pub st_ino: crate::ino_t, 16 | pub st_mode: crate::mode_t, 17 | pub st_nlink: crate::nlink_t, 18 | pub st_uid: crate::uid_t, 19 | pub st_gid: crate::gid_t, 20 | pub st_rdev: crate::dev_t, 21 | pub st_size: crate::off_t, 22 | pub st_atime: crate::time_t, 23 | pub st_spare1: c_long, 24 | pub st_mtime: crate::time_t, 25 | pub st_spare2: c_long, 26 | pub st_ctime: crate::time_t, 27 | pub st_spare3: c_long, 28 | pub st_blksize: crate::blksize_t, 29 | pub st_blocks: crate::blkcnt_t, 30 | pub st_spare4: [c_long; 2usize], 31 | } 32 | 33 | #[cfg(not(target_os = "vita"))] 34 | pub struct dirent { 35 | pub d_ino: crate::ino_t, 36 | pub d_type: c_uchar, 37 | pub d_name: [c_char; 256usize], 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/new/bionic_libc/pthread.rs: -------------------------------------------------------------------------------- 1 | //! Header: `unistd.h` 2 | 3 | pub use crate::new::common::linux_like::pthread::{ 4 | pthread_getattr_np, 5 | pthread_setname_np, 6 | }; 7 | pub use crate::new::common::posix::pthread::{ 8 | pthread_atfork, 9 | pthread_attr_getguardsize, 10 | pthread_attr_getinheritsched, 11 | pthread_attr_getstack, 12 | pthread_attr_setguardsize, 13 | pthread_attr_setinheritsched, 14 | pthread_attr_setstack, 15 | pthread_barrier_destroy, 16 | pthread_barrier_init, 17 | pthread_barrier_wait, 18 | pthread_barrierattr_destroy, 19 | pthread_barrierattr_getpshared, 20 | pthread_barrierattr_init, 21 | pthread_barrierattr_setpshared, 22 | pthread_condattr_getclock, 23 | pthread_condattr_getpshared, 24 | pthread_condattr_setclock, 25 | pthread_condattr_setpshared, 26 | pthread_create, 27 | pthread_getcpuclockid, 28 | pthread_getschedparam, 29 | pthread_kill, 30 | pthread_mutex_timedlock, 31 | pthread_mutexattr_getpshared, 32 | pthread_mutexattr_setpshared, 33 | pthread_rwlockattr_getpshared, 34 | pthread_rwlockattr_setpshared, 35 | pthread_setschedparam, 36 | pthread_sigmask, 37 | pthread_spin_destroy, 38 | pthread_spin_init, 39 | pthread_spin_lock, 40 | pthread_spin_trylock, 41 | pthread_spin_unlock, 42 | }; 43 | -------------------------------------------------------------------------------- /.cirrus.yml: -------------------------------------------------------------------------------- 1 | task: 2 | only_if: $CIRRUS_BRANCH == 'main' || $CIRRUS_BASE_BRANCH == 'libc-0.2' || $CIRRUS_BASE_BRANCH == 'main' 3 | env: 4 | HOME: /tmp # cargo cache needs it 5 | TARGET: x86_64-unknown-freebsd 6 | matrix: 7 | # FIXME(#4740): FreeBSD 13 tests are extremely flaky and fail most of the time 8 | # - name: nightly freebsd-13 x86_64 9 | # freebsd_instance: 10 | # image_family: freebsd-13-4 11 | - name: nightly freebsd-15 i686 12 | # Test i686 FreeBSD in 32-bit emulation on a 64-bit host. 13 | env: 14 | TARGET: i686-unknown-freebsd 15 | freebsd_instance: 16 | image: freebsd-15-0-release-amd64-ufs 17 | - name: nightly freebsd-14 x86_64 18 | freebsd_instance: 19 | image: freebsd-14-3-release-amd64-ufs 20 | - name: nightly freebsd-15 x86_64 21 | freebsd_instance: 22 | image: freebsd-15-0-release-amd64-ufs 23 | setup_script: 24 | - pkg install -y libnghttp2 curl 25 | - curl https://sh.rustup.rs -sSf --output rustup.sh 26 | - sh rustup.sh -y --default-toolchain nightly --profile=minimal 27 | - . $HOME/.cargo/env 28 | - if [ "$TARGET" = "i686-unknown-freebsd" ]; then rustup target add i686-unknown-freebsd; fi 29 | test_script: 30 | - . $HOME/.cargo/env 31 | - LIBC_CI=1 sh ci/run.sh $TARGET 32 | - sh ci/run.sh $TARGET 33 | -------------------------------------------------------------------------------- /src/new/bionic_libc/sys/socket.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/socket.h` 2 | 3 | use crate::prelude::*; 4 | 5 | s! { 6 | pub struct msghdr { 7 | pub msg_name: *mut c_void, 8 | pub msg_namelen: crate::socklen_t, 9 | pub msg_iov: *mut crate::iovec, 10 | pub msg_iovlen: size_t, 11 | pub msg_control: *mut c_void, 12 | pub msg_controllen: size_t, 13 | pub msg_flags: c_int, 14 | } 15 | 16 | pub struct cmsghdr { 17 | pub cmsg_len: size_t, 18 | pub cmsg_level: c_int, 19 | pub cmsg_type: c_int, 20 | } 21 | 22 | pub struct ucred { 23 | pub pid: crate::pid_t, 24 | pub uid: crate::uid_t, 25 | pub gid: crate::gid_t, 26 | } 27 | } 28 | 29 | extern "C" { 30 | pub fn recvmmsg( 31 | sockfd: c_int, 32 | msgvec: *mut crate::mmsghdr, 33 | vlen: c_uint, 34 | flags: c_int, 35 | timeout: *const crate::timespec, 36 | ) -> c_int; 37 | pub fn sendmmsg( 38 | sockfd: c_int, 39 | msgvec: *const crate::mmsghdr, 40 | vlen: c_uint, 41 | flags: c_int, 42 | ) -> c_int; 43 | pub fn recvfrom( 44 | socket: c_int, 45 | buf: *mut c_void, 46 | len: size_t, 47 | flags: c_int, 48 | addr: *mut crate::sockaddr, 49 | addrlen: *mut crate::socklen_t, 50 | ) -> ssize_t; 51 | } 52 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/riscv64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = i32; 4 | pub type wchar_t = c_int; 5 | pub type time_t = i64; 6 | pub type suseconds_t = c_long; 7 | pub type register_t = i64; 8 | 9 | s! { 10 | pub struct gpregs { 11 | pub gp_ra: crate::register_t, 12 | pub gp_sp: crate::register_t, 13 | pub gp_gp: crate::register_t, 14 | pub gp_tp: crate::register_t, 15 | pub gp_t: [crate::register_t; 7], 16 | pub gp_s: [crate::register_t; 12], 17 | pub gp_a: [crate::register_t; 8], 18 | pub gp_sepc: crate::register_t, 19 | pub gp_sstatus: crate::register_t, 20 | } 21 | 22 | pub struct fpregs { 23 | pub fp_x: [[u64; 2]; 32], 24 | pub fp_fcsr: u64, 25 | pub fp_flags: c_int, 26 | pub pad: c_int, 27 | } 28 | 29 | pub struct mcontext_t { 30 | pub mc_gpregs: gpregs, 31 | pub mc_fpregs: fpregs, 32 | pub mc_flags: c_int, 33 | pub mc_pad: c_int, 34 | pub mc_spare: [u64; 8], 35 | } 36 | } 37 | 38 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 39 | 40 | pub const BIOCSRTIMEOUT: c_ulong = 0x8010426d; 41 | pub const BIOCGRTIMEOUT: c_ulong = 0x4010426e; 42 | pub const MAP_32BIT: c_int = 0x00080000; 43 | pub const MINSIGSTKSZ: size_t = 4096; // 1024 * 4 44 | pub const TIOCTIMESTAMP: c_ulong = 0x40107459; 45 | -------------------------------------------------------------------------------- /ci/android-sysimage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -eux 4 | 5 | URL=https://dl.google.com/android/repository/sys-img/android 6 | 7 | main() { 8 | local arch="${1}" 9 | local name="${2}" 10 | local dest=/system 11 | local td 12 | td="$(mktemp -d)" 13 | 14 | apt-get install --no-install-recommends e2tools 15 | 16 | pushd "${td}" 17 | wget -q --tries=5 "${URL}/${name}" 18 | unzip -q "${name}" 19 | 20 | local system 21 | system="$(find . -name system.img)" 22 | mkdir -p ${dest}/{bin,lib,lib64} 23 | 24 | # Extract android linker and libraries to /system 25 | # This allows android executables to be run directly (or with qemu) 26 | if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then 27 | e2cp -p "${system}:/bin/linker64" "${dest}/bin/" 28 | e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/" 29 | e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/" 30 | e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/" 31 | else 32 | e2cp -p "${system}:/bin/linker" "${dest}/bin/" 33 | e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/" 34 | e2cp -p "${system}:/lib/libc.so" "${dest}/lib/" 35 | e2cp -p "${system}:/lib/libm.so" "${dest}/lib/" 36 | fi 37 | 38 | # clean up 39 | apt-get purge --auto-remove -y e2tools 40 | 41 | popd 42 | 43 | rm -rf "${td}" 44 | } 45 | 46 | main "${@}" 47 | -------------------------------------------------------------------------------- /src/unix/linux_like/linux/musl/b32/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type nlink_t = u32; 4 | pub type blksize_t = c_long; 5 | pub type __u64 = c_ulonglong; 6 | pub type __s64 = c_longlong; 7 | pub type regoff_t = c_int; 8 | 9 | s! { 10 | pub struct pthread_attr_t { 11 | __size: [u32; 9], 12 | } 13 | 14 | pub struct sigset_t { 15 | __val: [c_ulong; 32], 16 | } 17 | 18 | pub struct sem_t { 19 | __val: [c_int; 4], 20 | } 21 | } 22 | 23 | pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; 24 | pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; 25 | pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20; 26 | 27 | cfg_if! { 28 | if #[cfg(any(target_arch = "x86"))] { 29 | mod x86; 30 | pub use self::x86::*; 31 | } else if #[cfg(any(target_arch = "mips"))] { 32 | mod mips; 33 | pub use self::mips::*; 34 | } else if #[cfg(any(target_arch = "arm"))] { 35 | mod arm; 36 | pub use self::arm::*; 37 | } else if #[cfg(any(target_arch = "powerpc"))] { 38 | mod powerpc; 39 | pub use self::powerpc::*; 40 | } else if #[cfg(any(target_arch = "hexagon"))] { 41 | mod hexagon; 42 | pub use self::hexagon::*; 43 | } else if #[cfg(any(target_arch = "riscv32"))] { 44 | mod riscv32; 45 | pub use self::riscv32::*; 46 | } else { 47 | // Unknown target_arch 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/new/common/mod.rs: -------------------------------------------------------------------------------- 1 | //! Interfaces that are common across multiple platforms 2 | //! 3 | //! We make these available everywhere but each platform must opt in to reexporting. 4 | //! 5 | //! There shouldn't be any repeated definitions or complex configuration in this module. On 6 | //! platforms that don't use common APIs it is fine to use `#[cfg(not(...))]`, but if a platform 7 | //! needs a custom definition then it should be defined in the platform-specific module. 8 | //! 9 | //! The goal is that platforms need to opt in to the definitions here, so that worst case we have 10 | //! an unused warning on untested platforms (rather than exposing incorrect API). 11 | 12 | #[cfg(any( 13 | target_vendor = "apple", 14 | target_os = "dragonfly", 15 | target_os = "freebsd", 16 | target_os = "netbsd", 17 | target_os = "openbsd", 18 | ))] 19 | pub(crate) mod bsd; 20 | 21 | #[cfg(any( 22 | target_os = "android", 23 | target_os = "emscripten", 24 | target_os = "l4re", 25 | target_os = "linux", 26 | ))] 27 | pub(crate) mod linux_like; 28 | 29 | #[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] 30 | pub(crate) mod freebsd_like; 31 | 32 | #[cfg(any(target_os = "netbsd", target_os = "openbsd"))] 33 | pub(crate) mod netbsd_like; 34 | 35 | #[cfg(any(target_os = "illumos", target_os = "solaris"))] 36 | pub(crate) mod solarish; 37 | 38 | #[cfg(target_family = "unix")] 39 | pub(crate) mod posix; 40 | -------------------------------------------------------------------------------- /libc-test/semver/linux-musl.txt: -------------------------------------------------------------------------------- 1 | ACCOUNTING 2 | AF_IB 3 | AF_MPLS 4 | AF_XDP 5 | AIO_ALLDONE 6 | AIO_CANCELED 7 | AIO_NOTCANCELED 8 | BOOT_TIME 9 | DEAD_PROCESS 10 | EMPTY 11 | Elf32_Chdr 12 | Elf64_Chdr 13 | INIT_PROCESS 14 | LIO_NOP 15 | LIO_NOWAIT 16 | LIO_READ 17 | LIO_WAIT 18 | LIO_WRITE 19 | LOGIN_PROCESS 20 | MPOL_BIND 21 | MPOL_DEFAULT 22 | MPOL_INTERLEAVE 23 | MPOL_LOCAL 24 | MPOL_PREFERRED 25 | NEW_TIME 26 | OLD_TIME 27 | PF_IB 28 | PF_MPLS 29 | PF_XDP 30 | PR_SET_VMA 31 | PR_SET_VMA_ANON_NAME 32 | RUN_LVL 33 | RWF_APPEND 34 | RWF_ATOMIC 35 | RWF_DONTCACHE 36 | RWF_DSYNC 37 | RWF_HIPRI 38 | RWF_NOAPPEND 39 | RWF_NOWAIT 40 | RWF_SYNC 41 | SUN_LEN 42 | USER_PROCESS 43 | UT_HOSTSIZE 44 | UT_LINESIZE 45 | UT_NAMESIZE 46 | _CS_V6_ENV 47 | _CS_V7_ENV 48 | adjtimex 49 | aio_cancel 50 | aio_error 51 | aio_fsync 52 | aio_read 53 | aio_return 54 | aio_suspend 55 | aio_write 56 | aiocb 57 | asctime_r 58 | basename 59 | clock_adjtime 60 | copy_file_range 61 | ctermid 62 | dirname 63 | eaccess 64 | endutxent 65 | euidaccess 66 | explicit_bzero 67 | futimes 68 | getauxval 69 | getloadavg 70 | getutxent 71 | getutxid 72 | getutxline 73 | lio_listio 74 | ntptimeval 75 | open_wmemstream 76 | posix_spawn_file_actions_addchdir_np 77 | posix_spawn_file_actions_addfchdir_np 78 | preadv2 79 | preadv64 80 | prlimit 81 | prlimit64 82 | process_vm_readv 83 | process_vm_writev 84 | pututxline 85 | pwritev2 86 | pwritev64 87 | reallocarray 88 | setutxent 89 | tcp_info 90 | timex 91 | utmpxname 92 | -------------------------------------------------------------------------------- /src/new/linux_uapi/linux/can/bcm.rs: -------------------------------------------------------------------------------- 1 | //! Header: `linux/can/bcm.h` 2 | 3 | pub use crate::linux::can::*; 4 | 5 | s! { 6 | pub struct bcm_timeval { 7 | pub tv_sec: c_long, 8 | pub tv_usec: c_long, 9 | } 10 | 11 | pub struct bcm_msg_head { 12 | pub opcode: u32, 13 | pub flags: u32, 14 | pub count: u32, 15 | pub ival1: bcm_timeval, 16 | pub ival2: bcm_timeval, 17 | pub can_id: canid_t, 18 | pub nframes: u32, 19 | pub frames: [can_frame; 0], 20 | } 21 | } 22 | 23 | c_enum! { 24 | #[repr(u32)] 25 | pub enum #anon { 26 | pub TX_SETUP = 1, 27 | pub TX_DELETE, 28 | pub TX_READ, 29 | pub TX_SEND, 30 | pub RX_SETUP, 31 | pub RX_DELETE, 32 | pub RX_READ, 33 | pub TX_STATUS, 34 | pub TX_EXPIRED, 35 | pub RX_STATUS, 36 | pub RX_TIMEOUT, 37 | pub RX_CHANGED, 38 | } 39 | } 40 | 41 | pub const SETTIMER: u32 = 0x0001; 42 | pub const STARTTIMER: u32 = 0x0002; 43 | pub const TX_COUNTEVT: u32 = 0x0004; 44 | pub const TX_ANNOUNCE: u32 = 0x0008; 45 | pub const TX_CP_CAN_ID: u32 = 0x0010; 46 | pub const RX_FILTER_ID: u32 = 0x0020; 47 | pub const RX_CHECK_DLC: u32 = 0x0040; 48 | pub const RX_NO_AUTOTIMER: u32 = 0x0080; 49 | pub const RX_ANNOUNCE_RESUME: u32 = 0x0100; 50 | pub const TX_RESET_MULTI_IDX: u32 = 0x0200; 51 | pub const RX_RTR_FRAME: u32 = 0x0400; 52 | pub const CAN_FD_FRAME: u32 = 0x0800; 53 | -------------------------------------------------------------------------------- /src/new/netbsd/sys/statvfs.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/statvfs.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | const _VFS_NAMELEN: usize = 32; 8 | const _VFS_MNAMELEN: usize = 1024; 9 | 10 | s! { 11 | pub struct statvfs { 12 | pub f_flag: c_ulong, 13 | pub f_bsize: c_ulong, 14 | pub f_frsize: c_ulong, 15 | pub f_iosize: c_ulong, 16 | 17 | pub f_blocks: crate::fsblkcnt_t, 18 | pub f_bfree: crate::fsblkcnt_t, 19 | pub f_bavail: crate::fsblkcnt_t, 20 | pub f_bresvd: crate::fsblkcnt_t, 21 | 22 | pub f_files: crate::fsfilcnt_t, 23 | pub f_ffree: crate::fsfilcnt_t, 24 | pub f_favail: crate::fsfilcnt_t, 25 | pub f_fresvd: crate::fsfilcnt_t, 26 | 27 | pub f_syncreads: u64, 28 | pub f_syncwrites: u64, 29 | 30 | pub f_asyncreads: u64, 31 | pub f_asyncwrites: u64, 32 | 33 | pub f_fsidx: crate::fsid_t, 34 | pub f_fsid: c_ulong, 35 | pub f_namemax: c_ulong, 36 | pub f_owner: crate::uid_t, 37 | 38 | // This type is updated in a future version 39 | f_spare: [u32; 4], 40 | 41 | pub f_fstypename: [c_char; _VFS_NAMELEN], 42 | pub f_mntonname: [c_char; _VFS_MNAMELEN], 43 | pub f_mntfromname: [c_char; _VFS_MNAMELEN], 44 | // Added in NetBSD10 45 | // pub f_mntfromlabel: [c_char; _VFS_MNAMELEN], 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/fuchsia/riscv64.rs: -------------------------------------------------------------------------------- 1 | use crate::off_t; 2 | use crate::prelude::*; 3 | 4 | // From psABI Calling Convention for RV64 5 | pub type __u64 = c_ulonglong; 6 | pub type wchar_t = i32; 7 | 8 | pub type nlink_t = c_ulong; 9 | pub type blksize_t = c_long; 10 | 11 | pub type stat64 = stat; 12 | s! { 13 | pub struct stat { 14 | pub st_dev: crate::dev_t, 15 | pub st_ino: crate::ino_t, 16 | pub st_nlink: crate::nlink_t, 17 | pub st_mode: crate::mode_t, 18 | pub st_uid: crate::uid_t, 19 | pub st_gid: crate::gid_t, 20 | __pad0: Padding, 21 | pub st_rdev: crate::dev_t, 22 | pub st_size: off_t, 23 | pub st_blksize: crate::blksize_t, 24 | pub st_blocks: crate::blkcnt_t, 25 | pub st_atime: crate::time_t, 26 | pub st_atime_nsec: c_long, 27 | pub st_mtime: crate::time_t, 28 | pub st_mtime_nsec: c_long, 29 | pub st_ctime: crate::time_t, 30 | pub st_ctime_nsec: c_long, 31 | __unused: Padding<[c_long; 3]>, 32 | } 33 | 34 | // Not actually used, IPC calls just return ENOSYS 35 | pub struct ipc_perm { 36 | pub __ipc_perm_key: crate::key_t, 37 | pub uid: crate::uid_t, 38 | pub gid: crate::gid_t, 39 | pub cuid: crate::uid_t, 40 | pub cgid: crate::gid_t, 41 | pub mode: crate::mode_t, 42 | pub __seq: c_ushort, 43 | __unused1: Padding, 44 | __unused2: Padding, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ci/docker/i686-linux-android/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN dpkg --add-architecture i386 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | ca-certificates \ 6 | expect \ 7 | gcc \ 8 | libc6-dev \ 9 | libpulse0 \ 10 | libstdc++6:i386 \ 11 | openjdk-8-jre \ 12 | python3 \ 13 | unzip \ 14 | wget \ 15 | file 16 | 17 | WORKDIR /android/ 18 | COPY android* /android/ 19 | 20 | ENV ANDROID_ARCH=i686 21 | ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools 22 | 23 | RUN /android/android-install-ndk.sh 24 | RUN /android/android-install-sdk.sh $ANDROID_ARCH 25 | RUN mv /root/.android /tmp 26 | RUN chmod 777 -R /tmp/.android 27 | RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* 28 | 29 | ENV PATH=$PATH:/rust/bin \ 30 | CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android28-clang \ 31 | CARGO_TARGET_I686_LINUX_ANDROID_RUNNER=/tmp/runtest \ 32 | CC_i686_linux_android=i686-linux-android28-clang \ 33 | AR_i686_linux_android=llvm-ar \ 34 | HOME=/tmp 35 | 36 | ADD runtest-android.rs /tmp/runtest.rs 37 | ENTRYPOINT [ \ 38 | "bash", \ 39 | "-c", \ 40 | # set SHELL so android can detect a 64bits system, see 41 | # http://stackoverflow.com/a/41789144 42 | "SHELL=/bin/dash /android/sdk/emulator/emulator @i686 -no-window -no-accel & \ 43 | rustc /tmp/runtest.rs -o /tmp/runtest && \ 44 | exec \"$@\"", \ 45 | "--" \ 46 | ] 47 | -------------------------------------------------------------------------------- /src/new/musl/sched.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | cfg_if! { 4 | if #[cfg(musl_v1_2_3)] { 5 | s! { 6 | struct __c_anon_sched_param__reserved2 { 7 | __reserved1: crate::time_t, 8 | __reserved2: c_long, 9 | } 10 | 11 | pub struct sched_param { 12 | pub sched_priority: c_int, 13 | 14 | __reserved1: Padding, 15 | #[cfg(musl32_time64)] 16 | __reserved2: Padding<[c_long; 4]>, 17 | #[cfg(not(musl32_time64))] 18 | __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, 19 | __reserved3: Padding, 20 | } 21 | } 22 | } else { 23 | s! { 24 | pub struct sched_param { 25 | pub sched_priority: c_int, 26 | 27 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 28 | pub sched_ss_low_priority: c_int, 29 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 30 | pub sched_ss_repl_period: crate::timespec, 31 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 32 | pub sched_ss_init_budget: crate::timespec, 33 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 34 | pub sched_ss_max_repl: c_int, 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ci/docker/arm-linux-androideabi/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN dpkg --add-architecture i386 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | ca-certificates \ 6 | expect \ 7 | file \ 8 | gcc \ 9 | libc6-dev \ 10 | libpulse0 \ 11 | libstdc++6:i386 \ 12 | openjdk-8-jre \ 13 | python3 \ 14 | unzip \ 15 | wget 16 | 17 | WORKDIR /android/ 18 | COPY android* /android/ 19 | 20 | ENV ANDROID_ARCH=arm 21 | ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools 22 | 23 | RUN /android/android-install-ndk.sh 24 | RUN /android/android-install-sdk.sh $ANDROID_ARCH 25 | RUN mv /root/.android /tmp 26 | RUN chmod 777 -R /tmp/.android 27 | RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* 28 | 29 | ENV PATH=$PATH:/rust/bin \ 30 | CARGO_TARGET_ARM_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi28-clang \ 31 | CARGO_TARGET_ARM_LINUX_ANDROIDEABI_RUNNER=/tmp/runtest \ 32 | CC_arm_linux_androideabi=armv7a-linux-androideabi28-clang \ 33 | AR_arm_linux_androideabi=llvm-ar \ 34 | HOME=/tmp 35 | 36 | ADD runtest-android.rs /tmp/runtest.rs 37 | ENTRYPOINT [ \ 38 | "bash", \ 39 | "-c", \ 40 | # set SHELL so android can detect a 64bits system, see 41 | # http://stackoverflow.com/a/41789144 42 | "SHELL=/bin/dash /android/sdk/emulator/emulator @arm -no-window & \ 43 | rustc /tmp/runtest.rs -o /tmp/runtest && \ 44 | exec \"$@\"", \ 45 | "--" \ 46 | ] 47 | -------------------------------------------------------------------------------- /src/new/emscripten/sched.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | cfg_if! { 4 | if #[cfg(musl_v1_2_3)] { 5 | s! { 6 | struct __c_anon_sched_param__reserved2 { 7 | __reserved1: crate::time_t, 8 | __reserved2: c_long, 9 | } 10 | 11 | pub struct sched_param { 12 | pub sched_priority: c_int, 13 | 14 | __reserved1: Padding, 15 | #[cfg(musl32_time64)] 16 | __reserved2: Padding<[c_long; 4]>, 17 | #[cfg(not(musl32_time64))] 18 | __reserved2: Padding<[__c_anon_sched_param__reserved2; 2]>, 19 | __reserved3: Padding, 20 | } 21 | } 22 | } else { 23 | s! { 24 | pub struct sched_param { 25 | pub sched_priority: c_int, 26 | 27 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 28 | pub sched_ss_low_priority: c_int, 29 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 30 | pub sched_ss_repl_period: crate::timespec, 31 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 32 | pub sched_ss_init_budget: crate::timespec, 33 | #[deprecated(since = "0.2.173", note = "This field has been removed upstream")] 34 | pub sched_ss_max_repl: c_int, 35 | } 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ci/docker/aarch64-linux-android/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:25.04 2 | 3 | RUN dpkg --add-architecture i386 4 | RUN apt-get update && apt-get install -y --no-install-recommends \ 5 | ca-certificates \ 6 | expect \ 7 | file \ 8 | gcc \ 9 | libc6-dev \ 10 | libpulse0 \ 11 | libstdc++6:i386 \ 12 | openjdk-8-jre \ 13 | python3 \ 14 | unzip \ 15 | wget 16 | 17 | WORKDIR /android/ 18 | COPY android* /android/ 19 | 20 | ENV ANDROID_ARCH=aarch64 21 | ENV PATH=$PATH:/android/linux-x86_64/bin:/android/sdk/cmdline-tools/tools:/android/sdk/platform-tools 22 | 23 | RUN /android/android-install-ndk.sh 24 | RUN /android/android-install-sdk.sh $ANDROID_ARCH 25 | RUN mv /root/.android /tmp 26 | RUN chmod 777 -R /tmp/.android 27 | RUN chmod 755 /android/sdk/cmdline-tools/tools/* /android/sdk/emulator/qemu/linux-x86_64/* 28 | 29 | ENV PATH=$PATH:/rust/bin \ 30 | CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android28-clang \ 31 | CARGO_TARGET_AARCH64_LINUX_ANDROID_RUNNER=/tmp/runtest \ 32 | CC_aarch64_linux_android=aarch64-linux-android28-clang \ 33 | AR_aarch64_linux_android=llvm-ar \ 34 | HOME=/tmp 35 | 36 | ADD runtest-android.rs /tmp/runtest.rs 37 | ENTRYPOINT [ \ 38 | "bash", \ 39 | "-c", \ 40 | # set SHELL so android can detect a 64bits system, see 41 | # http://stackoverflow.com/a/41789144 42 | "SHELL=/bin/dash /android/sdk/emulator/emulator @aarch64 -no-window & \ 43 | rustc /tmp/runtest.rs -o /tmp/runtest && \ 44 | exec \"$@\"", \ 45 | "--" \ 46 | ] 47 | -------------------------------------------------------------------------------- /ctest/src/macro_expansion.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::fs::canonicalize; 3 | use std::path::Path; 4 | use std::process::Command; 5 | 6 | use crate::{ 7 | EDITION, 8 | Result, 9 | }; 10 | 11 | /// Use rustc to expand all macros and pretty print the crate into a single file. 12 | pub fn expand>( 13 | crate_path: P, 14 | cfg: &[(String, Option)], 15 | target: String, 16 | ) -> Result { 17 | let rustc = env::var("RUSTC").unwrap_or_else(|_| String::from("rustc")); 18 | 19 | let mut cmd = Command::new(rustc); 20 | cmd.env("RUSTC_BOOTSTRAP", "1") 21 | .arg("-Zunpretty=expanded") 22 | .arg("--edition") 23 | .arg(EDITION) // By default, -Zunpretty=expanded uses 2015 edition. 24 | .arg(canonicalize(crate_path)?); 25 | 26 | if !target.is_empty() { 27 | cmd.arg("--target").arg(target); 28 | } 29 | 30 | // `libc` uses non standard cfg flags as well, which have to be manually expanded. 31 | for (k, v) in cfg { 32 | match v { 33 | None => cmd.arg("--cfg").arg(k), 34 | Some(val) => cmd.arg("--cfg").arg(format!("{k}=\"{val}\"")), 35 | }; 36 | } 37 | 38 | let output = cmd.output()?; 39 | 40 | if !output.status.success() { 41 | let stderr = std::str::from_utf8(&output.stderr)?; 42 | return Err(format!("macro expansion failed with {}: {}", output.status, stderr).into()); 43 | } 44 | 45 | let expanded = std::str::from_utf8(&output.stdout)?.to_string(); 46 | 47 | Ok(expanded) 48 | } 49 | -------------------------------------------------------------------------------- /src/unix/newlib/aarch64/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = c_long; 4 | pub type wchar_t = u32; 5 | 6 | s! { 7 | pub struct sockaddr { 8 | pub sa_len: u8, 9 | pub sa_family: crate::sa_family_t, 10 | pub sa_data: [c_char; 14], 11 | } 12 | 13 | pub struct sockaddr_in6 { 14 | pub sin6_len: u8, 15 | pub sin6_family: crate::sa_family_t, 16 | pub sin6_port: crate::in_port_t, 17 | pub sin6_flowinfo: u32, 18 | pub sin6_addr: crate::in6_addr, 19 | pub sin6_scope_id: u32, 20 | } 21 | 22 | pub struct sockaddr_in { 23 | pub sin_len: u8, 24 | pub sin_family: crate::sa_family_t, 25 | pub sin_port: crate::in_port_t, 26 | pub sin_addr: crate::in_addr, 27 | pub sin_zero: [c_char; 8], 28 | } 29 | } 30 | 31 | pub const AF_INET6: c_int = 23; 32 | 33 | pub const FIONBIO: c_ulong = 1; 34 | 35 | pub const POLLIN: c_short = 0x1; 36 | pub const POLLPRI: c_short = 0x2; 37 | pub const POLLOUT: c_short = 0x4; 38 | pub const POLLERR: c_short = 0x8; 39 | pub const POLLHUP: c_short = 0x10; 40 | pub const POLLNVAL: c_short = 0x20; 41 | 42 | pub const SOL_SOCKET: c_int = 65535; 43 | 44 | pub const MSG_OOB: c_int = 1; 45 | pub const MSG_PEEK: c_int = 2; 46 | pub const MSG_DONTWAIT: c_int = 4; 47 | pub const MSG_DONTROUTE: c_int = 0; 48 | pub const MSG_WAITALL: c_int = 0; 49 | pub const MSG_MORE: c_int = 0; 50 | pub const MSG_NOSIGNAL: c_int = 0; 51 | 52 | pub use crate::unix::newlib::generic::{ 53 | dirent, 54 | sigset_t, 55 | stat, 56 | }; 57 | -------------------------------------------------------------------------------- /libc-test/semver/android-riscv64.txt: -------------------------------------------------------------------------------- 1 | AT_SYSINFO_EHDR 2 | AT_VECTOR_SIZE_ARCH 3 | HWCAP2_AFP 4 | HWCAP2_BF16 5 | HWCAP2_BTI 6 | HWCAP2_DCPODP 7 | HWCAP2_DGH 8 | HWCAP2_EBF16 9 | HWCAP2_ECV 10 | HWCAP2_FLAGM2 11 | HWCAP2_FRINT 12 | HWCAP2_I8MM 13 | HWCAP2_MTE 14 | HWCAP2_MTE3 15 | HWCAP2_RNG 16 | HWCAP2_RPRES 17 | HWCAP2_SME 18 | HWCAP2_SME_B16F32 19 | HWCAP2_SME_F16F32 20 | HWCAP2_SME_F32F32 21 | HWCAP2_SME_F64F64 22 | HWCAP2_SME_FA64 23 | HWCAP2_SME_I16I64 24 | HWCAP2_SME_I8I32 25 | HWCAP2_SVE2 26 | HWCAP2_SVEAES 27 | HWCAP2_SVEBF16 28 | HWCAP2_SVEBITPERM 29 | HWCAP2_SVEF32MM 30 | HWCAP2_SVEF64MM 31 | HWCAP2_SVEI8MM 32 | HWCAP2_SVEPMULL 33 | HWCAP2_SVESHA3 34 | HWCAP2_SVESM4 35 | HWCAP2_SVE_EBF16 36 | HWCAP2_WFXT 37 | HWCAP_AES 38 | HWCAP_ASIMD 39 | HWCAP_ASIMDDP 40 | HWCAP_ASIMDFHM 41 | HWCAP_ASIMDHP 42 | HWCAP_ASIMDRDM 43 | HWCAP_ATOMICS 44 | HWCAP_CPUID 45 | HWCAP_CRC32 46 | HWCAP_DCPOP 47 | HWCAP_DIT 48 | HWCAP_EVTSTRM 49 | HWCAP_FCMA 50 | HWCAP_FLAGM 51 | HWCAP_FP 52 | HWCAP_FPHP 53 | HWCAP_ILRCPC 54 | HWCAP_JSCVT 55 | HWCAP_LRCPC 56 | HWCAP_PACA 57 | HWCAP_PACG 58 | HWCAP_PMULL 59 | HWCAP_SB 60 | HWCAP_SHA1 61 | HWCAP_SHA2 62 | HWCAP_SHA3 63 | HWCAP_SHA512 64 | HWCAP_SM3 65 | HWCAP_SM4 66 | HWCAP_SSBS 67 | HWCAP_SVE 68 | HWCAP_USCAT 69 | PROT_BTI 70 | PROT_MTE 71 | SYS_accept 72 | SYS_arch_specific_syscall 73 | SYS_fcntl 74 | SYS_getrlimit 75 | SYS_memfd_secret 76 | SYS_migrate_pages 77 | SYS_msgctl 78 | SYS_msgget 79 | SYS_msgrcv 80 | SYS_msgsnd 81 | SYS_semctl 82 | SYS_semget 83 | SYS_semop 84 | SYS_semtimedop 85 | SYS_shmat 86 | SYS_shmctl 87 | SYS_shmdt 88 | SYS_shmget 89 | SYS_sync_file_range 90 | SYS_syscalls 91 | -------------------------------------------------------------------------------- /src/unix/newlib/arm/mod.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = c_long; 4 | pub type wchar_t = u32; 5 | 6 | s! { 7 | pub struct sockaddr { 8 | pub sa_family: crate::sa_family_t, 9 | pub sa_data: [c_char; 14], 10 | } 11 | 12 | pub struct sockaddr_in6 { 13 | pub sin6_family: crate::sa_family_t, 14 | pub sin6_port: crate::in_port_t, 15 | pub sin6_flowinfo: u32, 16 | pub sin6_addr: crate::in6_addr, 17 | pub sin6_scope_id: u32, 18 | } 19 | 20 | pub struct sockaddr_in { 21 | pub sin_family: crate::sa_family_t, 22 | pub sin_port: crate::in_port_t, 23 | pub sin_addr: crate::in_addr, 24 | pub sin_zero: [u8; 8], 25 | } 26 | 27 | pub struct sockaddr_storage { 28 | pub ss_family: crate::sa_family_t, 29 | pub __ss_padding: [u8; 26], 30 | } 31 | } 32 | 33 | pub const AF_INET6: c_int = 23; 34 | 35 | pub const FIONBIO: c_ulong = 1; 36 | 37 | pub const POLLIN: c_short = 0x1; 38 | pub const POLLPRI: c_short = 0x2; 39 | pub const POLLHUP: c_short = 0x4; 40 | pub const POLLERR: c_short = 0x8; 41 | pub const POLLOUT: c_short = 0x10; 42 | pub const POLLNVAL: c_short = 0x20; 43 | 44 | pub const SOL_SOCKET: c_int = 65535; 45 | 46 | pub const MSG_OOB: c_int = 1; 47 | pub const MSG_PEEK: c_int = 2; 48 | pub const MSG_DONTWAIT: c_int = 4; 49 | pub const MSG_DONTROUTE: c_int = 0; 50 | pub const MSG_WAITALL: c_int = 0; 51 | pub const MSG_MORE: c_int = 0; 52 | pub const MSG_NOSIGNAL: c_int = 0; 53 | 54 | pub use crate::unix::newlib::generic::{ 55 | dirent, 56 | sigset_t, 57 | stat, 58 | }; 59 | -------------------------------------------------------------------------------- /libc-test/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "libc-test" 3 | version = "0.1.0" 4 | description = "A test crate for the libc crate." 5 | publish = false 6 | authors = ["The Rust Project Developers"] 7 | edition = "2021" 8 | license = "MIT OR Apache-2.0" 9 | repository = "https://github.com/rust-lang/libc" 10 | 11 | [dependencies] 12 | cfg-if = "1.0.4" 13 | libc = { path = "..", version = "1.0.0-alpha.1", default-features = false } 14 | 15 | [dev-dependencies] 16 | syn = { version = "2.0.108", features = ["full", "visit"] } 17 | proc-macro2 = { version = "1.0.103", features = ["span-locations"] } 18 | glob = "0.3.3" 19 | annotate-snippets = { version = "0.11.5", features = ["testing-colors"] } 20 | 21 | [build-dependencies] 22 | cc = "1.2.43" 23 | ctest = { path = "../ctest" } 24 | regex = "1.12.2" 25 | 26 | [features] 27 | default = ["std"] 28 | std = ["libc/std"] 29 | extra_traits = ["libc/extra_traits"] 30 | 31 | [[test]] 32 | name = "ctest" 33 | harness = false 34 | 35 | [[test]] 36 | name = "linux_fcntl" 37 | harness = false 38 | 39 | [[test]] 40 | name = "linux_if_arp" 41 | harness = false 42 | 43 | [[test]] 44 | name = "linux_ipv6" 45 | harness = false 46 | 47 | [[test]] 48 | name = "linux_elf" 49 | harness = false 50 | 51 | [[test]] 52 | name = "linux_strerror_r" 53 | harness = false 54 | 55 | [[test]] 56 | name = "linux_termios" 57 | harness = false 58 | 59 | [[test]] 60 | name = "semver" 61 | harness = false 62 | 63 | # FIXME(msrv): These should be moved to the root Cargo.toml as `[workspace.lints.*]` 64 | # once MSRV is above 1.64 and replaced with `[lints] workspace=true` 65 | 66 | [lints.rust] 67 | 68 | [lints.clippy] 69 | -------------------------------------------------------------------------------- /src/unix/haiku/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | s! { 4 | pub struct fpu_state { 5 | pub control: c_ushort, 6 | pub status: c_ushort, 7 | pub tag: c_ushort, 8 | pub opcode: c_ushort, 9 | pub rip: c_ulong, 10 | pub rdp: c_ulong, 11 | pub mxcsr: c_uint, 12 | pub mscsr_mask: c_uint, 13 | pub _fpreg: [[c_uchar; 8]; 16], 14 | pub _xmm: [[c_uchar; 16]; 16], 15 | pub _reserved_416_511: [c_uchar; 96], 16 | } 17 | 18 | pub struct xstate_hdr { 19 | pub bv: c_ulong, 20 | pub xcomp_bv: c_ulong, 21 | pub _reserved: [c_uchar; 48], 22 | } 23 | 24 | pub struct savefpu { 25 | pub fp_fxsave: fpu_state, 26 | pub fp_xstate: xstate_hdr, 27 | pub _fp_ymm: [[c_uchar; 16]; 16], 28 | } 29 | 30 | pub struct mcontext_t { 31 | pub rax: c_ulong, 32 | pub rbx: c_ulong, 33 | pub rcx: c_ulong, 34 | pub rdx: c_ulong, 35 | pub rdi: c_ulong, 36 | pub rsi: c_ulong, 37 | pub rbp: c_ulong, 38 | pub r8: c_ulong, 39 | pub r9: c_ulong, 40 | pub r10: c_ulong, 41 | pub r11: c_ulong, 42 | pub r12: c_ulong, 43 | pub r13: c_ulong, 44 | pub r14: c_ulong, 45 | pub r15: c_ulong, 46 | pub rsp: c_ulong, 47 | pub rip: c_ulong, 48 | pub rflags: c_ulong, 49 | pub fpu: savefpu, 50 | } 51 | 52 | pub struct ucontext_t { 53 | pub uc_link: *mut ucontext_t, 54 | pub uc_sigmask: crate::sigset_t, 55 | pub uc_stack: crate::stack_t, 56 | pub uc_mcontext: mcontext_t, 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /libc-test/semver/linux-riscv64gc.txt: -------------------------------------------------------------------------------- 1 | B2500000 2 | B3000000 3 | B3500000 4 | B4000000 5 | CIBAUD 6 | COMPAT_HWCAP_ISA_A 7 | COMPAT_HWCAP_ISA_C 8 | COMPAT_HWCAP_ISA_D 9 | COMPAT_HWCAP_ISA_F 10 | COMPAT_HWCAP_ISA_I 11 | COMPAT_HWCAP_ISA_M 12 | COMPAT_HWCAP_ISA_V 13 | Elf32_Rela 14 | Elf64_Rela 15 | KEYCTL_CAPABILITIES 16 | KEYCTL_CAPS0_BIG_KEY 17 | KEYCTL_CAPS0_CAPABILITIES 18 | KEYCTL_CAPS0_DIFFIE_HELLMAN 19 | KEYCTL_CAPS0_INVALIDATE 20 | KEYCTL_CAPS0_MOVE 21 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 22 | KEYCTL_CAPS0_PUBLIC_KEY 23 | KEYCTL_CAPS0_RESTRICT_KEYRING 24 | KEYCTL_CAPS1_NS_KEYRING_NAME 25 | KEYCTL_CAPS1_NS_KEY_TAG 26 | KEYCTL_MOVE 27 | MADV_SOFT_OFFLINE 28 | MAP_SYNC 29 | NFT_MSG_DELOBJ 30 | NFT_MSG_GETOBJ 31 | NFT_MSG_GETOBJ_RESET 32 | NFT_MSG_NEWOBJ 33 | SCM_TIMESTAMPNS 34 | SCM_WIFI_STATUS 35 | SIGSTKFLT 36 | SO_ATTACH_BPF 37 | SO_ATTACH_FILTER 38 | SO_BPF_EXTENSIONS 39 | SO_BSDCOMPAT 40 | SO_DETACH_BPF 41 | SO_DETACH_FILTER 42 | SO_GET_FILTER 43 | SO_INCOMING_CPU 44 | SO_LOCK_FILTER 45 | SO_MAX_PACING_RATE 46 | SO_NOFCS 47 | SO_NO_CHECK 48 | SO_PEERNAME 49 | SO_PRIORITY 50 | SO_PROTOCOL 51 | SO_SECURITY_AUTHENTICATION 52 | SO_SECURITY_ENCRYPTION_NETWORK 53 | SO_SECURITY_ENCRYPTION_TRANSPORT 54 | SO_SELECT_ERR_QUEUE 55 | SO_WIFI_STATUS 56 | SYS_accept 57 | SYS_fadvise64 58 | SYS_fstat 59 | SYS_msgctl 60 | SYS_msgget 61 | SYS_msgrcv 62 | SYS_msgsnd 63 | SYS_newfstatat 64 | SYS_pkey_alloc 65 | SYS_pkey_free 66 | SYS_pkey_mprotect 67 | SYS_semctl 68 | SYS_semget 69 | SYS_semop 70 | SYS_semtimedop 71 | SYS_sendfile 72 | SYS_setrlimit 73 | SYS_shmat 74 | SYS_shmctl 75 | SYS_shmdt 76 | SYS_shmget 77 | SYS_sync_file_range 78 | TIOCGRS485 79 | TIOCSRS485 80 | flock64 81 | fsblkcnt64_t 82 | fsfilcnt64_t 83 | -------------------------------------------------------------------------------- /src/unix/bsd/freebsdlike/freebsd/x86.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | 3 | pub type clock_t = c_ulong; 4 | pub type wchar_t = i32; 5 | pub type time_t = i32; 6 | pub type suseconds_t = i32; 7 | pub type register_t = i32; 8 | 9 | s! { 10 | #[repr(align(16))] 11 | pub struct mcontext_t { 12 | pub mc_onstack: register_t, 13 | pub mc_gs: register_t, 14 | pub mc_fs: register_t, 15 | pub mc_es: register_t, 16 | pub mc_ds: register_t, 17 | pub mc_edi: register_t, 18 | pub mc_esi: register_t, 19 | pub mc_ebp: register_t, 20 | pub mc_isp: register_t, 21 | pub mc_ebx: register_t, 22 | pub mc_edx: register_t, 23 | pub mc_ecx: register_t, 24 | pub mc_eax: register_t, 25 | pub mc_trapno: register_t, 26 | pub mc_err: register_t, 27 | pub mc_eip: register_t, 28 | pub mc_cs: register_t, 29 | pub mc_eflags: register_t, 30 | pub mc_esp: register_t, 31 | pub mc_ss: register_t, 32 | pub mc_len: c_int, 33 | pub mc_fpformat: c_int, 34 | pub mc_ownedfp: c_int, 35 | pub mc_flags: register_t, 36 | pub mc_fpstate: [c_int; 128], 37 | pub mc_fsbase: register_t, 38 | pub mc_gsbase: register_t, 39 | pub mc_xfpustate: register_t, 40 | pub mc_xfpustate_len: register_t, 41 | pub mc_spare2: [c_int; 4], 42 | } 43 | } 44 | 45 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 46 | 47 | pub const MINSIGSTKSZ: size_t = 2048; // 512 * 4 48 | 49 | pub const BIOCSRTIMEOUT: c_ulong = 0x8008426d; 50 | pub const BIOCGRTIMEOUT: c_ulong = 0x4008426e; 51 | pub const KINFO_FILE_SIZE: c_int = 1392; 52 | pub const TIOCTIMESTAMP: c_ulong = 0x40087459; 53 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | # Description 10 | 11 | 12 | 13 | # Sources 14 | 15 | 29 | 30 | # Checklist 31 | 32 | 34 | 35 | - [ ] Relevant tests in `libc-test/semver` have been updated 36 | - [ ] No placeholder or unstable values like `*LAST` or `*MAX` are 37 | included (see [#3131](https://github.com/rust-lang/libc/issues/3131)) 38 | - [ ] Tested locally (`cd libc-test && cargo test --target mytarget`); 39 | especially relevant for platforms that may not be checked in CI 40 | 41 | 46 | -------------------------------------------------------------------------------- /ci/runtest-android.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | use std::path::{ 3 | Path, 4 | PathBuf, 5 | }; 6 | use std::process::Command; 7 | 8 | fn main() { 9 | let args = env::args_os() 10 | .skip(1) 11 | .filter(|arg| arg != "--quiet" && arg != "--skip" && arg != "check_style") 12 | .collect::>(); 13 | assert_eq!(args.len(), 1); 14 | let test = PathBuf::from(&args[0]); 15 | let dst = Path::new("/data/local/tmp").join(test.file_name().unwrap()); 16 | 17 | let status = Command::new("adb") 18 | .arg("wait-for-device") 19 | .status() 20 | .expect("failed to run: adb wait-for-device"); 21 | assert!(status.success()); 22 | 23 | let status = Command::new("adb") 24 | .arg("push") 25 | .arg(&test) 26 | .arg(&dst) 27 | .status() 28 | .expect("failed to run: adb push"); 29 | assert!(status.success()); 30 | 31 | let output = Command::new("adb") 32 | .arg("shell") 33 | .arg("RUST_BACKTRACE=1") 34 | .arg(&dst) 35 | .output() 36 | .expect("failed to run: adb shell"); 37 | assert!(status.success()); 38 | 39 | let stdout = String::from_utf8_lossy(&output.stdout); 40 | let stderr = String::from_utf8_lossy(&output.stderr); 41 | 42 | println!( 43 | "status: {}\nstdout ---\n{stdout}\nstderr ---\n{stderr}", 44 | output.status, 45 | ); 46 | 47 | if !stderr.lines().any(|l| { 48 | (l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok") 49 | }) && !stdout.lines().any(|l| { 50 | (l.starts_with("PASSED ") && l.contains(" tests")) || l.starts_with("test result: ok") 51 | }) { 52 | panic!("failed to find successful test run"); 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /libc-test/semver/linux-aarch64.txt: -------------------------------------------------------------------------------- 1 | B2500000 2 | B3000000 3 | B3500000 4 | B4000000 5 | BPF_A 6 | BPF_ABS 7 | BPF_ADD 8 | BPF_ALU 9 | BPF_B 10 | BPF_CLASS 11 | BPF_DIV 12 | BPF_H 13 | BPF_IMM 14 | BPF_IND 15 | BPF_JA 16 | BPF_JEQ 17 | BPF_JGE 18 | BPF_JGT 19 | BPF_JMP 20 | BPF_JUMP 21 | BPF_K 22 | BPF_LD 23 | BPF_LDX 24 | BPF_LEN 25 | BPF_LL_OFF 26 | BPF_MEM 27 | BPF_MISC 28 | BPF_MISCOP 29 | BPF_MOD 30 | BPF_MODE 31 | BPF_MSH 32 | BPF_NEG 33 | BPF_NET_OFF 34 | BPF_OP 35 | BPF_RET 36 | BPF_RVAL 37 | BPF_SIZE 38 | BPF_SRC 39 | BPF_ST 40 | BPF_STMT 41 | BPF_STX 42 | BPF_SUB 43 | BPF_TAX 44 | BPF_TXA 45 | BPF_W 46 | BPF_X 47 | BPF_XOR 48 | CIBAUD 49 | Elf32_Rela 50 | Elf64_Rela 51 | FICLONE 52 | FICLONERANGE 53 | MADV_SOFT_OFFLINE 54 | MAP_SYNC 55 | SIGSTKFLT 56 | SIGUNUSED 57 | SKF_AD_ALU_XOR_X 58 | SKF_AD_CPU 59 | SKF_AD_HATYPE 60 | SKF_AD_MARK 61 | SKF_AD_MAX 62 | SKF_AD_NLATTR 63 | SKF_AD_NLATTR_NEST 64 | SKF_AD_OFF 65 | SKF_AD_PAY_OFFSET 66 | SKF_AD_PKTTYPE 67 | SKF_AD_PROTOCOL 68 | SKF_AD_QUEUE 69 | SKF_AD_RANDOM 70 | SKF_AD_RXHASH 71 | SKF_AD_VLAN_TAG 72 | SKF_AD_VLAN_TAG_PRESENT 73 | SKF_AD_VLAN_TPID 74 | SKF_LL_OFF 75 | SKF_NET_OFF 76 | SO_PRIORITY 77 | SO_PROTOCOL 78 | SYS_accept 79 | SYS_fstat 80 | SYS_msgctl 81 | SYS_msgget 82 | SYS_msgrcv 83 | SYS_msgsnd 84 | SYS_newfstatat 85 | SYS_pkey_alloc 86 | SYS_pkey_free 87 | SYS_pkey_mprotect 88 | SYS_renameat 89 | SYS_semctl 90 | SYS_semget 91 | SYS_semop 92 | SYS_semtimedop 93 | SYS_setrlimit 94 | SYS_shmat 95 | SYS_shmctl 96 | SYS_shmdt 97 | SYS_shmget 98 | SYS_sync_file_range 99 | TIOCCBRK 100 | TIOCGRS485 101 | TIOCSBRK 102 | TIOCSRS485 103 | flock64 104 | max_align_t 105 | mcontext_t 106 | ucontext_t 107 | user_fpsimd_struct 108 | user_regs_struct 109 | -------------------------------------------------------------------------------- /libc-test/tests/style.rs: -------------------------------------------------------------------------------- 1 | //! Simple script to verify the coding style of this library. 2 | //! 3 | //! ## How to run 4 | //! 5 | //! The first argument to this script is the directory to run on, so running 6 | //! this script should be as simple as: 7 | //! 8 | //! ```notrust 9 | //! cargo test --test style 10 | //! ``` 11 | 12 | pub mod style_lib; 13 | 14 | use std::env; 15 | use std::path::Path; 16 | 17 | use style_lib::{ 18 | Result, 19 | StyleChecker, 20 | }; 21 | 22 | /// Relative to `src/`. 23 | const SKIP_PREFIXES: &[&str] = &[ 24 | // Don't run the style checker on the reorganized portion of the crate while we figure 25 | // out what style we want. 26 | "new/", "types.rs", 27 | ]; 28 | 29 | #[test] 30 | fn check_style() { 31 | let src_root = Path::new(env!("CARGO_MANIFEST_DIR")).join("../src"); 32 | walk(&src_root).unwrap(); 33 | eprintln!("good style!"); 34 | } 35 | 36 | fn walk(src_root: &Path) -> Result<()> { 37 | let mut style_checker = StyleChecker::new(); 38 | 39 | for entry in glob::glob(&format!( 40 | "{}/**/*.rs", 41 | src_root.to_str().expect("dir should be valid UTF-8") 42 | ))? { 43 | let entry = entry?; 44 | let relpath = entry.strip_prefix(src_root).expect("known path"); 45 | if SKIP_PREFIXES.iter().any(|pfx| relpath.starts_with(pfx)) { 46 | continue; 47 | } 48 | 49 | let name = entry 50 | .file_name() 51 | .expect("file name should not end in ..") 52 | .to_str() 53 | .expect("file name should be valid UTF-8"); 54 | if let "lib.rs" | "macros.rs" = &name[..] { 55 | continue; 56 | } 57 | 58 | let path = entry.as_path(); 59 | style_checker.check_file(path)?; 60 | style_checker.reset_state(); 61 | } 62 | 63 | style_checker.finalize() 64 | } 65 | -------------------------------------------------------------------------------- /libc-test/semver/solarish.txt: -------------------------------------------------------------------------------- 1 | AIO_ALLDONE 2 | AIO_CANCELED 3 | AIO_NOTCANCELED 4 | IPV6_BOUND_IF 5 | IPV6_DONTFRAG 6 | IPV6_PKTINFO 7 | IPV6_RECVTCLASS 8 | IPV6_TCLASS 9 | IP_BOUND_IF 10 | IP_DONTFRAG 11 | IP_PKTINFO 12 | IP_TOS 13 | IP_TTL 14 | LIO_NOP 15 | LIO_NOWAIT 16 | LIO_READ 17 | LIO_WAIT 18 | LIO_WRITE 19 | PIPE_BUF 20 | POSIX_SPAWN_NOEXECERR_NP 21 | POSIX_SPAWN_NOSIGCHLD_NP 22 | POSIX_SPAWN_RESETIDS 23 | POSIX_SPAWN_SETPGROUP 24 | POSIX_SPAWN_SETSCHEDPARAM 25 | POSIX_SPAWN_SETSCHEDULER 26 | POSIX_SPAWN_SETSIGDEF 27 | POSIX_SPAWN_SETSIGIGN_NP 28 | POSIX_SPAWN_SETSIGMASK 29 | POSIX_SPAWN_WAITPID_NP 30 | SIGEV_PORT 31 | SIGRTMAX 32 | SIGRTMIN 33 | _POSIX_VDISABLE 34 | _ST_FSTYPSZ 35 | aio_cancel 36 | aio_error 37 | aio_fsync 38 | aio_read 39 | aio_result_t 40 | aio_return 41 | aio_suspend 42 | aio_waitn 43 | aio_write 44 | aiocb 45 | arc4random 46 | arc4random_buf 47 | arc4random_uniform 48 | bind 49 | in6_pktinfo 50 | in_pktinfo 51 | lio_listio 52 | posix_spawn 53 | posix_spawn_file_actions_addchdir 54 | posix_spawn_file_actions_addchdir_np 55 | posix_spawn_file_actions_addclose 56 | posix_spawn_file_actions_addclosefrom_np 57 | posix_spawn_file_actions_adddup2 58 | posix_spawn_file_actions_addfchdir 59 | posix_spawn_file_actions_addopen 60 | posix_spawn_file_actions_destroy 61 | posix_spawn_file_actions_init 62 | posix_spawnattr_destroy 63 | posix_spawnattr_getflags 64 | posix_spawnattr_getpgroup 65 | posix_spawnattr_getschedparam 66 | posix_spawnattr_getschedpolicy 67 | posix_spawnattr_getsigdefault 68 | posix_spawnattr_getsigignore_np 69 | posix_spawnattr_getsigmask 70 | posix_spawnattr_init 71 | posix_spawnattr_setflags 72 | posix_spawnattr_setpgroup 73 | posix_spawnattr_setschedparam 74 | posix_spawnattr_setschedpolicy 75 | posix_spawnattr_setsigdefault 76 | posix_spawnattr_setsigignore_np 77 | posix_spawnattr_setsigmask 78 | posix_spawnp 79 | recvmsg 80 | sendmsg 81 | sigqueue 82 | strftime 83 | strftime_l 84 | -------------------------------------------------------------------------------- /libc-test/semver/TODO-linux.txt: -------------------------------------------------------------------------------- 1 | # The following symbols are not available in some combinations of 2 | # musl/gnu/android and/or architecture. 3 | KEYCTL_CAPABILITIES 4 | KEYCTL_CAPS0_BIG_KEY 5 | KEYCTL_CAPS0_CAPABILITIES 6 | KEYCTL_CAPS0_DIFFIE_HELLMAN 7 | KEYCTL_CAPS0_INVALIDATE 8 | KEYCTL_CAPS0_MOVE 9 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 10 | KEYCTL_CAPS0_PUBLIC_KEY 11 | KEYCTL_CAPS0_RESTRICT_KEYRING 12 | KEYCTL_CAPS1_NS_KEYRING_NAME 13 | KEYCTL_CAPS1_NS_KEY_TAG 14 | KEYCTL_MOVE 15 | NFT_MSG_DELOBJ 16 | NFT_MSG_GETOBJ 17 | NFT_MSG_GETOBJ_RESET 18 | NFT_MSG_NEWOBJ 19 | PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 20 | PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP 21 | PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP 22 | SCM_TIMESTAMPING_OPT_STATS 23 | SCM_TIMESTAMPING_PKTINFO 24 | SCM_TIMESTAMPNS 25 | SCM_TXTIME 26 | SCM_WIFI_STATUS 27 | SO_ATTACH_BPF 28 | SO_ATTACH_FILTER 29 | SO_ATTACH_REUSEPORT_CBPF 30 | SO_ATTACH_REUSEPORT_EBPF 31 | SO_BINDTOIFINDEX 32 | SO_BPF_EXTENSIONS 33 | SO_BSDCOMPAT 34 | SO_CNX_ADVICE 35 | SO_COOKIE 36 | SO_DETACH_BPF 37 | SO_DETACH_FILTER 38 | SO_DETACH_REUSEPORT_BPF 39 | SO_GET_FILTER 40 | SO_INCOMING_CPU 41 | SO_INCOMING_NAPI_ID 42 | SO_LOCK_FILTER 43 | SO_MAX_PACING_RATE 44 | SO_MEMINFO 45 | SO_NOFCS 46 | SO_NO_CHECK 47 | SO_PEERGROUPS 48 | SO_PEERNAME 49 | SO_RCVTIMEO_NEW 50 | SO_SECURITY_AUTHENTICATION 51 | SO_SECURITY_ENCRYPTION_NETWORK 52 | SO_SECURITY_ENCRYPTION_TRANSPORT 53 | SO_SELECT_ERR_QUEUE 54 | SO_SNDTIMEO_NEW 55 | SO_STYLE 56 | SO_TIMESTAMPING_NEW 57 | SO_TIMESTAMPNS_NEW 58 | SO_TIMESTAMP_NEW 59 | SO_TXTIME 60 | SO_WIFI_STATUS 61 | SO_ZEROCOPY 62 | SYS__llseek 63 | SYS__newselect 64 | SYS__sysctl 65 | SYS_create_module 66 | SYS_fadvise64 67 | SYS_fstatat64 68 | SYS_get_kernel_syms 69 | SYS_get_thread_area 70 | SYS_getrlimit 71 | SYS_migrate_pages 72 | SYS_mmap 73 | SYS_nfsservctl 74 | SYS_pread64 75 | SYS_pwrite64 76 | SYS_query_module 77 | SYS_set_thread_area 78 | SYS_uselib 79 | fsblkcnt64_t 80 | fsfilcnt64_t 81 | getrandom 82 | sysctl 83 | termios2 84 | -------------------------------------------------------------------------------- /src/new/glibc/sysdeps/nptl/pthread.rs: -------------------------------------------------------------------------------- 1 | //! Source header: `sysdeps/nptl/pthread.h` 2 | //! 3 | //! 4 | 5 | pub use crate::new::common::linux_like::pthread::{ 6 | pthread_getaffinity_np, 7 | pthread_getattr_np, 8 | pthread_getname_np, 9 | pthread_setaffinity_np, 10 | pthread_setname_np, 11 | }; 12 | pub use crate::new::common::posix::pthread::{ 13 | pthread_atfork, 14 | pthread_attr_getguardsize, 15 | pthread_attr_getinheritsched, 16 | pthread_attr_getschedparam, 17 | pthread_attr_getschedpolicy, 18 | pthread_attr_getstack, 19 | pthread_attr_setguardsize, 20 | pthread_attr_setinheritsched, 21 | pthread_attr_setschedparam, 22 | pthread_attr_setschedpolicy, 23 | pthread_attr_setstack, 24 | pthread_barrier_destroy, 25 | pthread_barrier_init, 26 | pthread_barrier_wait, 27 | pthread_barrierattr_destroy, 28 | pthread_barrierattr_getpshared, 29 | pthread_barrierattr_init, 30 | pthread_barrierattr_setpshared, 31 | pthread_cancel, 32 | pthread_condattr_getclock, 33 | pthread_condattr_getpshared, 34 | pthread_condattr_setclock, 35 | pthread_condattr_setpshared, 36 | pthread_create, 37 | pthread_getcpuclockid, 38 | pthread_getschedparam, 39 | pthread_kill, 40 | pthread_mutex_consistent, 41 | pthread_mutex_timedlock, 42 | pthread_mutexattr_getprotocol, 43 | pthread_mutexattr_getpshared, 44 | pthread_mutexattr_getrobust, 45 | pthread_mutexattr_setprotocol, 46 | pthread_mutexattr_setpshared, 47 | pthread_mutexattr_setrobust, 48 | pthread_once, 49 | pthread_rwlockattr_getpshared, 50 | pthread_rwlockattr_setpshared, 51 | pthread_setschedparam, 52 | pthread_setschedprio, 53 | pthread_sigmask, 54 | pthread_spin_destroy, 55 | pthread_spin_init, 56 | pthread_spin_lock, 57 | pthread_spin_trylock, 58 | pthread_spin_unlock, 59 | }; 60 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/netbsd/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use crate::PT_FIRSTMACH; 3 | 4 | pub type c___greg_t = u64; 5 | pub type __cpu_simple_lock_nv_t = c_uchar; 6 | 7 | // FIXME(alignment): Type is `__aligned(8)` 8 | type __fpregset_t = [c_char; 512]; 9 | 10 | s! { 11 | pub struct mcontext_t { 12 | pub __gregs: [c___greg_t; 26], 13 | pub _mc_tlsbase: c___greg_t, 14 | pub __fpregs: __fpregset_t, 15 | } 16 | 17 | pub struct ucontext_t { 18 | pub uc_flags: c_uint, 19 | pub uc_link: *mut crate::ucontext_t, 20 | pub uc_sigmask: crate::sigset_t, 21 | pub uc_stack: crate::stack_t, 22 | pub uc_mcontext: crate::mcontext_t, 23 | } 24 | } 25 | 26 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 27 | 28 | pub const PT_STEP: c_int = PT_FIRSTMACH + 0; 29 | pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; 30 | pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; 31 | pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3; 32 | pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4; 33 | 34 | pub const _REG_RDI: c_int = 0; 35 | pub const _REG_RSI: c_int = 1; 36 | pub const _REG_RDX: c_int = 2; 37 | pub const _REG_RCX: c_int = 3; 38 | pub const _REG_R8: c_int = 4; 39 | pub const _REG_R9: c_int = 5; 40 | pub const _REG_R10: c_int = 6; 41 | pub const _REG_R11: c_int = 7; 42 | pub const _REG_R12: c_int = 8; 43 | pub const _REG_R13: c_int = 9; 44 | pub const _REG_R14: c_int = 10; 45 | pub const _REG_R15: c_int = 11; 46 | pub const _REG_RBP: c_int = 12; 47 | pub const _REG_RBX: c_int = 13; 48 | pub const _REG_RAX: c_int = 14; 49 | pub const _REG_GS: c_int = 15; 50 | pub const _REG_FS: c_int = 16; 51 | pub const _REG_ES: c_int = 17; 52 | pub const _REG_DS: c_int = 18; 53 | pub const _REG_TRAPNO: c_int = 19; 54 | pub const _REG_ERR: c_int = 20; 55 | pub const _REG_RIP: c_int = 21; 56 | pub const _REG_CS: c_int = 22; 57 | pub const _REG_RFLAGS: c_int = 23; 58 | pub const _REG_RSP: c_int = 24; 59 | pub const _REG_SS: c_int = 25; 60 | -------------------------------------------------------------------------------- /src/new/musl/pthread.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread.h` 2 | //! 3 | //! 4 | 5 | pub use crate::new::common::linux_like::pthread::{ 6 | pthread_getaffinity_np, 7 | pthread_getattr_np, 8 | pthread_getname_np, 9 | pthread_setaffinity_np, 10 | pthread_setname_np, 11 | }; 12 | pub use crate::new::common::posix::pthread::{ 13 | pthread_atfork, 14 | pthread_attr_getguardsize, 15 | pthread_attr_getinheritsched, 16 | pthread_attr_getschedparam, 17 | pthread_attr_getschedpolicy, 18 | pthread_attr_getstack, 19 | pthread_attr_setguardsize, 20 | pthread_attr_setinheritsched, 21 | pthread_attr_setschedparam, 22 | pthread_attr_setschedpolicy, 23 | pthread_attr_setstack, 24 | pthread_barrier_destroy, 25 | pthread_barrier_init, 26 | pthread_barrier_wait, 27 | pthread_barrierattr_destroy, 28 | pthread_barrierattr_getpshared, 29 | pthread_barrierattr_init, 30 | pthread_barrierattr_setpshared, 31 | pthread_condattr_getclock, 32 | pthread_condattr_getpshared, 33 | pthread_condattr_setclock, 34 | pthread_condattr_setpshared, 35 | pthread_create, 36 | pthread_getcpuclockid, 37 | pthread_getschedparam, 38 | pthread_kill, 39 | pthread_mutex_timedlock, 40 | pthread_mutexattr_getprotocol, 41 | pthread_mutexattr_getpshared, 42 | pthread_mutexattr_setprotocol, 43 | pthread_mutexattr_setpshared, 44 | pthread_once, 45 | pthread_rwlockattr_getpshared, 46 | pthread_rwlockattr_setpshared, 47 | pthread_setschedparam, 48 | pthread_setschedprio, 49 | pthread_sigmask, 50 | pthread_spin_destroy, 51 | pthread_spin_init, 52 | pthread_spin_lock, 53 | pthread_spin_trylock, 54 | pthread_spin_unlock, 55 | }; 56 | #[cfg(not(target_env = "ohos"))] 57 | pub use crate::new::common::posix::pthread::{ 58 | pthread_cancel, 59 | pthread_mutex_consistent, 60 | pthread_mutexattr_getrobust, 61 | pthread_mutexattr_setrobust, 62 | }; 63 | -------------------------------------------------------------------------------- /ci/install-rust.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | # This is intended to be used in CI only. 3 | 4 | set -eux 5 | 6 | echo "Setup toolchain" 7 | 8 | toolchain="${TOOLCHAIN:-nightly}" 9 | os="${OS:-}" 10 | 11 | case "$(uname -s)" in 12 | Linux*) os=linux ;; 13 | Darwin*) os=macos ;; 14 | MINGW*) os=windows ;; 15 | *) 16 | echo "Unknown system $(uname -s)" 17 | exit 1 18 | ;; 19 | esac 20 | 21 | if [ "$os" = "windows" ] && [ -n "${TARGET:-}" ]; then 22 | toolchain="$toolchain-$TARGET" 23 | rustup set profile minimal 24 | fi 25 | 26 | rustup set profile minimal 27 | rustup update --force "$toolchain" --no-self-update 28 | rustup default "$toolchain" 29 | 30 | if [ -n "${TARGET:-}" ]; then 31 | echo "Install target" 32 | rustup target add "$TARGET" 33 | fi 34 | 35 | if [ -n "${INSTALL_RUST_SRC:-}" ]; then 36 | echo "Install rust-src" 37 | rustup component add rust-src 38 | fi 39 | 40 | if [ "$os" = "windows" ]; then 41 | if [ "${ARCH_BITS:-}" = "i686" ]; then 42 | echo "Install MinGW32" 43 | choco install mingw --x86 --force 44 | fi 45 | 46 | echo "Find GCC libraries" 47 | gcc -print-search-dirs 48 | /usr/bin/find "C:\ProgramData\Chocolatey" -name "crt2*" 49 | /usr/bin/find "C:\ProgramData\Chocolatey" -name "dllcrt2*" 50 | /usr/bin/find "C:\ProgramData\Chocolatey" -name "libmsvcrt*" 51 | 52 | if [ -n "${ARCH_BITS:-}" ]; then 53 | echo "Fix MinGW" 54 | for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a; do 55 | cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw$ARCH_BITS/$ARCH-w64-mingw32/lib/$i" "$(rustc --print sysroot)/lib/rustlib/$TARGET/lib" 56 | done 57 | fi 58 | fi 59 | 60 | echo "Query rust and cargo versions" 61 | rustc -Vv 62 | cargo -V 63 | rustup -Vv 64 | rustup show 65 | 66 | echo "Generate lockfile" 67 | N=5 68 | n=0 69 | until [ $n -ge $N ]; do 70 | if cargo generate-lockfile; then 71 | break 72 | fi 73 | 74 | n=$((n + 1)) 75 | sleep 1 76 | done 77 | -------------------------------------------------------------------------------- /src/unix/bsd/netbsdlike/openbsd/x86_64.rs: -------------------------------------------------------------------------------- 1 | use crate::prelude::*; 2 | use crate::PT_FIRSTMACH; 3 | 4 | pub type ucontext_t = sigcontext; 5 | 6 | s! { 7 | pub struct sigcontext { 8 | pub sc_rdi: c_long, 9 | pub sc_rsi: c_long, 10 | pub sc_rdx: c_long, 11 | pub sc_rcx: c_long, 12 | pub sc_r8: c_long, 13 | pub sc_r9: c_long, 14 | pub sc_r10: c_long, 15 | pub sc_r11: c_long, 16 | pub sc_r12: c_long, 17 | pub sc_r13: c_long, 18 | pub sc_r14: c_long, 19 | pub sc_r15: c_long, 20 | pub sc_rbp: c_long, 21 | pub sc_rbx: c_long, 22 | pub sc_rax: c_long, 23 | pub sc_gs: c_long, 24 | pub sc_fs: c_long, 25 | pub sc_es: c_long, 26 | pub sc_ds: c_long, 27 | pub sc_trapno: c_long, 28 | pub sc_err: c_long, 29 | pub sc_rip: c_long, 30 | pub sc_cs: c_long, 31 | pub sc_rflags: c_long, 32 | pub sc_rsp: c_long, 33 | pub sc_ss: c_long, 34 | pub sc_fpstate: *mut fxsave64, 35 | __sc_unused: Padding, 36 | pub sc_mask: c_int, 37 | pub sc_cookie: c_long, 38 | } 39 | 40 | #[repr(packed)] 41 | pub struct fxsave64 { 42 | pub fx_fcw: u16, 43 | pub fx_fsw: u16, 44 | pub fx_ftw: u8, 45 | __fx_unused1: Padding, 46 | pub fx_fop: u16, 47 | pub fx_rip: u64, 48 | pub fx_rdp: u64, 49 | pub fx_mxcsr: u32, 50 | pub fx_mxcsr_mask: u32, 51 | pub fx_st: [[u64; 2]; 8], 52 | pub fx_xmm: [[u64; 2]; 16], 53 | __fx_unused3: Padding<[u8; 96]>, 54 | } 55 | } 56 | 57 | pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; 58 | 59 | pub const _MAX_PAGE_SHIFT: u32 = 12; 60 | 61 | pub const PT_STEP: c_int = PT_FIRSTMACH + 0; 62 | pub const PT_GETREGS: c_int = PT_FIRSTMACH + 1; 63 | pub const PT_SETREGS: c_int = PT_FIRSTMACH + 2; 64 | pub const PT_GETFPREGS: c_int = PT_FIRSTMACH + 3; 65 | pub const PT_SETFPREGS: c_int = PT_FIRSTMACH + 4; 66 | -------------------------------------------------------------------------------- /libc-test/semver/linux-s390x.txt: -------------------------------------------------------------------------------- 1 | B2500000 2 | B3000000 3 | B3500000 4 | B4000000 5 | CIBAUD 6 | KEYCTL_CAPABILITIES 7 | KEYCTL_CAPS0_BIG_KEY 8 | KEYCTL_CAPS0_CAPABILITIES 9 | KEYCTL_CAPS0_DIFFIE_HELLMAN 10 | KEYCTL_CAPS0_INVALIDATE 11 | KEYCTL_CAPS0_MOVE 12 | KEYCTL_CAPS0_PERSISTENT_KEYRINGS 13 | KEYCTL_CAPS0_PUBLIC_KEY 14 | KEYCTL_CAPS0_RESTRICT_KEYRING 15 | KEYCTL_CAPS1_NS_KEYRING_NAME 16 | KEYCTL_CAPS1_NS_KEY_TAG 17 | KEYCTL_MOVE 18 | MADV_SOFT_OFFLINE 19 | MAP_SYNC 20 | NFT_MSG_DELOBJ 21 | NFT_MSG_GETOBJ 22 | NFT_MSG_GETOBJ_RESET 23 | NFT_MSG_NEWOBJ 24 | SIGSTKFLT 25 | SIGUNUSED 26 | SO_BSDCOMPAT 27 | SO_PRIORITY 28 | SO_PROTOCOL 29 | SYS__sysctl 30 | SYS_access 31 | SYS_afs_syscall 32 | SYS_alarm 33 | SYS_bdflush 34 | SYS_chmod 35 | SYS_chown 36 | SYS_creat 37 | SYS_create_module 38 | SYS_dup2 39 | SYS_epoll_create 40 | SYS_epoll_wait 41 | SYS_eventfd 42 | SYS_fadvise64 43 | SYS_fork 44 | SYS_fstat 45 | SYS_fstatfs64 46 | SYS_futimesat 47 | SYS_get_kernel_syms 48 | SYS_getdents 49 | SYS_getpgrp 50 | SYS_getpmsg 51 | SYS_idle 52 | SYS_inotify_init 53 | SYS_ipc 54 | SYS_lchown 55 | SYS_link 56 | SYS_lstat 57 | SYS_mkdir 58 | SYS_mknod 59 | SYS_mseal 60 | SYS_newfstatat 61 | SYS_nice 62 | SYS_open 63 | SYS_pause 64 | SYS_pipe 65 | SYS_poll 66 | SYS_putpmsg 67 | SYS_query_module 68 | SYS_readdir 69 | SYS_readlink 70 | SYS_rename 71 | SYS_renameat 72 | SYS_rmdir 73 | SYS_s390_pci_mmio_read 74 | SYS_s390_pci_mmio_write 75 | SYS_s390_runtime_instr 76 | SYS_select 77 | SYS_sendfile 78 | SYS_setrlimit 79 | SYS_sigaction 80 | SYS_signal 81 | SYS_signalfd 82 | SYS_sigpending 83 | SYS_sigprocmask 84 | SYS_sigreturn 85 | SYS_sigsuspend 86 | SYS_socketcall 87 | SYS_stat 88 | SYS_statfs64 89 | SYS_symlink 90 | SYS_sync_file_range 91 | SYS_sysfs 92 | SYS_timerfd 93 | SYS_umount 94 | SYS_unlink 95 | SYS_uselib 96 | SYS_ustat 97 | SYS_utime 98 | SYS_utimes 99 | SYS_vfork 100 | TIOCCBRK 101 | TIOCSBRK 102 | __psw_t 103 | flock64 104 | fpreg_t 105 | fpregset_t 106 | greg_t 107 | termios2 108 | -------------------------------------------------------------------------------- /ci/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # Builds and runs tests for a particular target passed as an argument to this 4 | # script. 5 | 6 | set -eux 7 | 8 | target="$1" 9 | 10 | export RUST_BACKTRACE="${RUST_BACKTRACE:-1}" 11 | # Add target-specific rustflags set in dockerfiles 12 | export RUSTFLAGS="${EXTRA_RUSTFLAGS:-} ${RUSTFLAGS:-}" 13 | 14 | echo "RUSTFLAGS: '$RUSTFLAGS'" 15 | 16 | # For logging 17 | uname -a 18 | 19 | cmd="cargo test --target $target ${LIBC_CI_ZBUILD_STD+"-Zbuild-std"}" 20 | test_flags="--skip check_style" 21 | 22 | # Run tests in the `libc` crate 23 | case "$target" in 24 | # Only run `libc-test` 25 | # FIXME(android): unit tests fail to start on Android 26 | *android*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; 27 | *s390x*) cmd="$cmd --manifest-path libc-test/Cargo.toml" ;; 28 | # For all other platforms, test everything in the workspace 29 | *) cmd="$cmd --workspace" ;; 30 | esac 31 | 32 | case "$target" in 33 | # crash in std::env::tmp_dir (no filesystem on wasm). 34 | *wasm*) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next" ;; 35 | # Loongarch was fixed, but there are new instances of 36 | # https://github.com/bytecodealliance/rustix/issues/1496 37 | powerpc64le*musl) cmd="$cmd --exclude ctest --exclude ctest-test --exclude ctest-next" ;; 38 | esac 39 | 40 | env="$(rustc --print cfg --target "$target" | sed -n 's/target_env="\(.*\)"/\1/p')" 41 | bits="$(rustc --print cfg --target "$target" | sed -n 's/target_pointer_width="\(.*\)"/\1/p')" 42 | 43 | # shellcheck disable=SC2086 44 | $cmd --no-default-features -- $test_flags 45 | # shellcheck disable=SC2086 46 | $cmd -- $test_flags 47 | # shellcheck disable=SC2086 48 | $cmd --features extra_traits -- $test_flags 49 | 50 | # On relevant platforms, also test with our optional settings 51 | 52 | if [ "$env" = "gnu" ] && [ "$bits" = "32" ]; then 53 | # shellcheck disable=SC2086 54 | RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS=64 $cmd -- $test_flags 55 | # shellcheck disable=SC2086 56 | RUST_LIBC_UNSTABLE_GNU_TIME_BITS=64 $cmd -- $test_flags 57 | fi 58 | -------------------------------------------------------------------------------- /libc-test/semver/linux-mips.txt: -------------------------------------------------------------------------------- 1 | B2500000 2 | B3000000 3 | B3500000 4 | B4000000 5 | CIBAUD 6 | PTRACE_GETFPREGS 7 | PTRACE_GETFPXREGS 8 | PTRACE_GETREGS 9 | PTRACE_SETFPREGS 10 | PTRACE_SETFPXREGS 11 | PTRACE_SETREGS 12 | SIGEMT 13 | SO_PRIORITY 14 | SO_PROTOCOL 15 | SYS__sysctl 16 | SYS_accept 17 | SYS_access 18 | SYS_afs_syscall 19 | SYS_alarm 20 | SYS_bdflush 21 | SYS_break 22 | SYS_cachectl 23 | SYS_cacheflush 24 | SYS_chmod 25 | SYS_chown 26 | SYS_creat 27 | SYS_create_module 28 | SYS_dup2 29 | SYS_epoll_create 30 | SYS_epoll_wait 31 | SYS_eventfd 32 | SYS_fcntl64 33 | SYS_fork 34 | SYS_fstat 35 | SYS_fstat64 36 | SYS_fstatfs64 37 | SYS_ftime 38 | SYS_ftruncate64 39 | SYS_futimesat 40 | SYS_get_kernel_syms 41 | SYS_getdents 42 | SYS_getpgrp 43 | SYS_getpmsg 44 | SYS_gtty 45 | SYS_idle 46 | SYS_inotify_init 47 | SYS_ioperm 48 | SYS_iopl 49 | SYS_ipc 50 | SYS_lchown 51 | SYS_link 52 | SYS_lock 53 | SYS_lstat 54 | SYS_lstat64 55 | SYS_mkdir 56 | SYS_mknod 57 | SYS_mmap2 58 | SYS_modify_ldt 59 | SYS_mpx 60 | SYS_nice 61 | SYS_open 62 | SYS_pause 63 | SYS_pipe 64 | SYS_pkey_alloc 65 | SYS_pkey_free 66 | SYS_pkey_mprotect 67 | SYS_poll 68 | SYS_prof 69 | SYS_profil 70 | SYS_putpmsg 71 | SYS_query_module 72 | SYS_readdir 73 | SYS_readlink 74 | SYS_recv 75 | SYS_rename 76 | SYS_renameat 77 | SYS_rmdir 78 | SYS_send 79 | SYS_sendfile 80 | SYS_sendfile64 81 | SYS_set_thread_area 82 | SYS_setrlimit 83 | SYS_sgetmask 84 | SYS_sigaction 85 | SYS_signal 86 | SYS_signalfd 87 | SYS_sigpending 88 | SYS_sigprocmask 89 | SYS_sigreturn 90 | SYS_sigsuspend 91 | SYS_socketcall 92 | SYS_ssetmask 93 | SYS_stat 94 | SYS_stat64 95 | SYS_statfs64 96 | SYS_stime 97 | SYS_stty 98 | SYS_symlink 99 | SYS_sync_file_range 100 | SYS_syscall 101 | SYS_sysfs 102 | SYS_sysmips 103 | SYS_time 104 | SYS_timerfd 105 | SYS_truncate64 106 | SYS_ulimit 107 | SYS_umount 108 | SYS_unlink 109 | SYS_uselib 110 | SYS_ustat 111 | SYS_utime 112 | SYS_utimes 113 | SYS_vm86 114 | SYS_vserver 115 | SYS_waitpid 116 | TIOCCBRK 117 | TIOCSBRK 118 | max_align_t 119 | -------------------------------------------------------------------------------- /src/new/linux_uapi/linux/can/j1939.rs: -------------------------------------------------------------------------------- 1 | //! `linux/can/j1939.h` 2 | 3 | pub use crate::linux::can::*; 4 | 5 | pub const J1939_MAX_UNICAST_ADDR: c_uchar = 0xfd; 6 | pub const J1939_IDLE_ADDR: c_uchar = 0xfe; 7 | pub const J1939_NO_ADDR: c_uchar = 0xff; 8 | pub const J1939_NO_NAME: c_ulong = 0; 9 | pub const J1939_PGN_REQUEST: c_uint = 0x0ea00; 10 | pub const J1939_PGN_ADDRESS_CLAIMED: c_uint = 0x0ee00; 11 | pub const J1939_PGN_ADDRESS_COMMANDED: c_uint = 0x0fed8; 12 | pub const J1939_PGN_PDU1_MAX: c_uint = 0x3ff00; 13 | pub const J1939_PGN_MAX: c_uint = 0x3ffff; 14 | pub const J1939_NO_PGN: c_uint = 0x40000; 15 | 16 | pub type pgn_t = u32; 17 | pub type priority_t = u8; 18 | pub type name_t = u64; 19 | 20 | pub const SOL_CAN_J1939: c_int = SOL_CAN_BASE + CAN_J1939; 21 | 22 | // FIXME(cleanup): these could use c_enum if it can accept anonymous enums. 23 | 24 | pub const SO_J1939_FILTER: c_int = 1; 25 | pub const SO_J1939_PROMISC: c_int = 2; 26 | pub const SO_J1939_SEND_PRIO: c_int = 3; 27 | pub const SO_J1939_ERRQUEUE: c_int = 4; 28 | 29 | pub const SCM_J1939_DEST_ADDR: c_int = 1; 30 | pub const SCM_J1939_DEST_NAME: c_int = 2; 31 | pub const SCM_J1939_PRIO: c_int = 3; 32 | pub const SCM_J1939_ERRQUEUE: c_int = 4; 33 | 34 | pub const J1939_NLA_PAD: c_int = 0; 35 | pub const J1939_NLA_BYTES_ACKED: c_int = 1; 36 | pub const J1939_NLA_TOTAL_SIZE: c_int = 2; 37 | pub const J1939_NLA_PGN: c_int = 3; 38 | pub const J1939_NLA_SRC_NAME: c_int = 4; 39 | pub const J1939_NLA_DEST_NAME: c_int = 5; 40 | pub const J1939_NLA_SRC_ADDR: c_int = 6; 41 | pub const J1939_NLA_DEST_ADDR: c_int = 7; 42 | 43 | pub const J1939_EE_INFO_NONE: c_int = 0; 44 | pub const J1939_EE_INFO_TX_ABORT: c_int = 1; 45 | pub const J1939_EE_INFO_RX_RTS: c_int = 2; 46 | pub const J1939_EE_INFO_RX_DPO: c_int = 3; 47 | pub const J1939_EE_INFO_RX_ABORT: c_int = 4; 48 | 49 | s! { 50 | pub struct j1939_filter { 51 | pub name: name_t, 52 | pub name_mask: name_t, 53 | pub pgn: pgn_t, 54 | pub pgn_mask: pgn_t, 55 | pub addr: u8, 56 | pub addr_mask: u8, 57 | } 58 | } 59 | 60 | pub const J1939_FILTER_MAX: c_int = 512; 61 | -------------------------------------------------------------------------------- /src/new/musl/sys/socket.rs: -------------------------------------------------------------------------------- 1 | //! Header: `sys/socket.h` 2 | //! 3 | //! 4 | 5 | use crate::prelude::*; 6 | 7 | s! { 8 | pub struct msghdr { 9 | pub msg_name: *mut c_void, 10 | pub msg_namelen: crate::socklen_t, 11 | pub msg_iov: *mut crate::iovec, 12 | #[cfg(all(target_pointer_width = "64", target_endian = "big"))] 13 | __pad1: Padding, 14 | pub msg_iovlen: c_int, 15 | #[cfg(all(target_pointer_width = "64", target_endian = "little"))] 16 | __pad1: Padding, 17 | pub msg_control: *mut c_void, 18 | #[cfg(all(target_pointer_width = "64", target_endian = "big"))] 19 | __pad2: Padding, 20 | pub msg_controllen: crate::socklen_t, 21 | #[cfg(all(target_pointer_width = "64", target_endian = "little"))] 22 | __pad2: Padding, 23 | pub msg_flags: c_int, 24 | } 25 | 26 | pub struct cmsghdr { 27 | #[cfg(all(target_pointer_width = "64", target_endian = "big"))] 28 | pub __pad1: c_int, 29 | pub cmsg_len: crate::socklen_t, 30 | #[cfg(all(target_pointer_width = "64", target_endian = "little"))] 31 | pub __pad1: c_int, 32 | pub cmsg_level: c_int, 33 | pub cmsg_type: c_int, 34 | } 35 | } 36 | 37 | extern "C" { 38 | pub fn sendmmsg( 39 | sockfd: c_int, 40 | msgvec: *mut crate::mmsghdr, 41 | vlen: c_uint, 42 | flags: c_uint, 43 | ) -> c_int; 44 | #[cfg_attr(musl32_time64, link_name = "__recvmmsg_time64")] 45 | pub fn recvmmsg( 46 | sockfd: c_int, 47 | msgvec: *mut crate::mmsghdr, 48 | vlen: c_uint, 49 | flags: c_uint, 50 | timeout: *mut crate::timespec, 51 | ) -> c_int; 52 | } 53 | 54 | cfg_if! { 55 | if #[cfg(any(target_arch = "mips", target_arch = "mips64"))] { 56 | pub use crate::bits::socket::{ 57 | SOCK_DGRAM, 58 | SOCK_STREAM, 59 | }; 60 | } else { 61 | pub const SOCK_STREAM: c_int = 1; 62 | pub const SOCK_DGRAM: c_int = 2; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/new/uclibc/pthread.rs: -------------------------------------------------------------------------------- 1 | //! Header: `pthread.h` 2 | //! 3 | //! Note that The l4re port of uclibc doesn't yet support all `pthread_*` API that is 4 | //! available upstream. 5 | 6 | pub use crate::new::common::linux_like::pthread::{ 7 | pthread_getaffinity_np, 8 | pthread_getattr_np, 9 | pthread_setaffinity_np, 10 | }; 11 | #[cfg(not(target_os = "l4re"))] 12 | pub use crate::new::common::linux_like::pthread::{ 13 | pthread_getname_np, 14 | pthread_setname_np, 15 | }; 16 | #[cfg(not(target_os = "l4re"))] 17 | pub use crate::new::common::posix::pthread::{ 18 | pthread_atfork, 19 | pthread_barrierattr_getpshared, 20 | pthread_condattr_getclock, 21 | pthread_condattr_setclock, 22 | pthread_getcpuclockid, 23 | pthread_mutex_consistent, 24 | pthread_mutexattr_getprotocol, 25 | pthread_mutexattr_getrobust, 26 | pthread_mutexattr_setprotocol, 27 | pthread_mutexattr_setrobust, 28 | pthread_setschedprio, 29 | }; 30 | pub use crate::new::common::posix::pthread::{ 31 | pthread_attr_getguardsize, 32 | pthread_attr_getinheritsched, 33 | pthread_attr_getschedparam, 34 | pthread_attr_getschedpolicy, 35 | pthread_attr_getstack, 36 | pthread_attr_setguardsize, 37 | pthread_attr_setinheritsched, 38 | pthread_attr_setschedparam, 39 | pthread_attr_setschedpolicy, 40 | pthread_attr_setstack, 41 | pthread_barrier_destroy, 42 | pthread_barrier_init, 43 | pthread_barrier_wait, 44 | pthread_barrierattr_destroy, 45 | pthread_barrierattr_init, 46 | pthread_barrierattr_setpshared, 47 | pthread_cancel, 48 | pthread_condattr_getpshared, 49 | pthread_condattr_setpshared, 50 | pthread_create, 51 | pthread_getschedparam, 52 | pthread_kill, 53 | pthread_mutex_timedlock, 54 | pthread_mutexattr_getpshared, 55 | pthread_mutexattr_setpshared, 56 | pthread_once, 57 | pthread_rwlockattr_getpshared, 58 | pthread_rwlockattr_setpshared, 59 | pthread_setschedparam, 60 | pthread_sigmask, 61 | pthread_spin_destroy, 62 | pthread_spin_init, 63 | pthread_spin_lock, 64 | pthread_spin_trylock, 65 | pthread_spin_unlock, 66 | }; 67 | --------------------------------------------------------------------------------