about summary refs log tree commit diff
path: root/library/core/src/ffi/mod.rs
AgeCommit message (Collapse)AuthorLines
2025-09-27Library: Remove remaining private `#[repr]` workaroundsLeón Orell Valerian Liehr-1/+1
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2025-05-21limit impls of `VaArgSafe` to just types that are actually safeFolkert de Vries-1/+1
8 and 16-bit integers are subject to upcasting in C, and hence are not reliably safe. users should perform their own casting and deal with the consequences
2025-05-12update version placeholdersPietro Albini-1/+1
2025-02-22Stabilise c_str_moduleltdk-1/+1
2025-02-09Mark extern blocks as unsafeMichael Goulet-1/+1
2025-02-03primitive type migration from mod.rs to primitives.rsricci009-168/+7
2025-01-28Update comments and sort target_arch in c_char_definitionTaiki Endo-7/+9
2025-01-20core: add `#![warn(unreachable_pub)]`Urgau-10/+10
2024-12-26docs: inline `core::ffi::c_str` types to `core::ffi`Michael Howell-2/+2
2024-12-10Add references to the specific ABI documentsAlex Richardson-7/+63
Expcept for L4RE and Xtensa these were obtained from #131319 I could not find an open link to the Xtensa documentation, but the signedness was confirmed by on of the Xtensa developers in https://github.com/llvm/llvm-project/pull/115967#issuecomment-2506292323 Co-authored-by: Taiki Endo <te316e89@gmail.com>
2024-12-10Remove l4re from the unsigned char operating system listAlex Richardson-2/+2
As noted in https://github.com/rust-lang/rust/pull/132975#issuecomment-2484645240, the default for userland apps is to follow the architecture defaults, the -funsigned-char flag only applies to kernel builds.
2024-12-10De-duplicate and improve definition of core::ffi::c_charAlex Richardson-53/+24
Instead of having a list of unsigned char targets for each OS, follow the logic Clang uses and instead set the value based on architecture with a special case for Darwin and Windows operating systems. This makes it easier to support new operating systems targeting Arm/AArch64 without having to modify this config statement for each new OS. The new list does not quite match Clang since I noticed a few bugs in the Clang implementation (https://github.com/llvm/llvm-project/issues/115957). Fixes: https://github.com/rust-lang/rust/issues/129945
2024-09-03Port std library to RTEMSJan Sommer-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-8/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-22Fix some `#[cfg_attr(not(doc), repr(..))]`Pavel Grigorenko-1/+1
Now that #90435 seems to have been resolved.
2024-07-04library: outline VaList into ffi::va_listJubilee Young-400/+14
and reexport
2024-06-24core: VaArgSafe is an unsafe traitJubilee Young-4/+5
`T: VaArgSafe` is relied on for soundness. Safe impls promise nothing. Therefore this must be an unsafe trait. Slightly pedantic, as only core can impl this, but we could choose to unseal the trait. That would allow soundly (but unsafely) implementing this for e.g. a `#[repr(C)] struct` that should be passable by varargs.
2024-05-20Fix c_char on AIXTaiki Endo-1/+2
Refs: https://github.com/rust-lang/rust/issues/122985
2024-04-28Fix va_list on watchOS and visionOSMads Marquart-16/+7
2024-04-14Move msvc libs to coreChris Denton-0/+10
2024-02-22Add std::ffi::c_str modulesltdk-2/+12
2024-01-29Remove `raw_os_nonzero` feature.Markus Reiter-50/+14
2023-10-28Remove asmjs from libraryJubilee Young-6/+0
2023-10-23Fix invalid stability attribute features in standard libraryDavid Tolnay-1/+1
2023-08-14add a csky-unknown-linux-gnuabiv2 targetDirreke-1/+2
2023-07-22Rollup merge of #112490 - Alexendoo:c-char-cfg-all, r=cuviperMatthias Krüger-5/+0
Remove `#[cfg(all())]` workarounds from `c_char` Casts to type aliases are now ignored by Clippy https://github.com/rust-lang/rust-clippy/pull/8596 Closes https://github.com/rust-lang/rust-clippy/issues/8093
2023-07-05Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd.Havard Eidnes-1/+6
2023-06-21Finish up preliminary tvos support in libstdThom Chiovoloni-7/+16
2023-06-16Remove `#[cfg(all())]` workarounds from `c_char`Alex Macleod-5/+0
2023-05-30Bump to latest beta compilerMark Rousskov-1/+1
2023-05-16Hide repr attribute from doc of types without guaranteed reprDavid Tolnay-7/+7
2023-05-03Rollup merge of #105452 - rcvalle:rust-cfi-3, r=bjorn3Manish Goregaokar-0/+1
Add cross-language LLVM CFI support to the Rust compiler This PR adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto). Thank you again, ``@bjorn3,`` ``@nikic,`` ``@samitolvanen,`` and the Rust community for all the help!
2023-05-03Add cross-language LLVM CFI support to the Rust compilerRamon de C Valle-0/+1
This commit adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).
2023-04-25Add definitions for riscv64gc-unknown-fuchsiaDan Johnson-1/+4
2023-04-12Make rust-intrinsic ABI unwindableGary Guo-0/+3
Stick `#[rustc_nounwind]` to all except `const_eval_select` to undo the change for all other intrinsics.
2023-02-28Add QNX Neutrino support to libstdFlorian Bartels-0/+1
Co-authored-by: gh-tr <troach@qnx.com>
2022-12-19Implement va_list and va_arg for s390x FFIUlrich Weigand-5/+50
Following the s390x ELF ABI and based on the clang implementation, provide appropriate definitions of va_list in library/core/src/ffi/mod.rs and va_arg handling in compiler/rustc_codegen_llvm/src/va_arg.rs. Fixes the following test cases on s390x: src/test/run-make-fulldeps/c-link-to-rust-va-list-fn src/test/ui/abi/variadic-ffi.rs Fixes https://github.com/rust-lang/rust/issues/84628.
2022-07-15Stabilize `core::ffi::CStr`, `alloc::ffi::CString`, and friendsJosh Triplett-1/+1
Stabilize the `core_c_str` and `alloc_c_string` feature gates. Change `std::ffi` to re-export these types rather than creating type aliases, since they now have matching stability.
2022-07-14Rollup merge of #98315 - joshtriplett:stabilize-core-ffi-c, r=Mark-SimulacrumDylan DPC-1/+1
Stabilize `core::ffi:c_*` and rexport in `std::ffi` This only stabilizes the base types, not the non-zero variants, since those have their own separate tracking issue and have not gone through FCP to stabilize.
2022-07-13Stabilize `core::ffi:c_*` and rexport in `std::ffi`Josh Triplett-1/+1
This only stabilizes the base types, not the non-zero variants, since those have their own separate tracking issue and have not gone through FCP to stabilize.
2022-06-25library: fix uefi va_list type definitionDan Robertson-9/+16
For uefi the va_list should always be the void pointer variant.
2022-06-13Horizon OS STD supportMeziu-1/+2
Co-authored-by: Ian Chamberlain <ian.h.chamberlain@gmail.com> Co-authored-by: Mark Drobnak <mark.drobnak@gmail.com>
2022-05-03Update library/core/src/ffi/mod.rsYonggang Luo-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-04-21library/core: Fixes implement of c_uint, c_long, c_ulongYonggang Luo-17/+46
Fixes: aa670166243 ("make memcmp return a value of c_int_width instead of i32") Introduce c_num_definition to getting the cfg_if logic easier to maintain Add newlines for easier code reading Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
2022-04-14library: Use type aliases to make `CStr(ing)` in libcore/liballoc unstableVadim Petrochenkov-1/+1
2022-04-14library: Move `CStr` to libcore, and `CString` to liballocVadim Petrochenkov-0/+5
2022-04-02make memcmp return a value of c_int_width instead of i32David Morrison-0/+3
2022-03-02merge the char signess list of archs with freebsd as it is the sameSébastien Marie-11/+1
2022-03-02update char signess for openbsdSébastien Marie-1/+10
adds more archs for openbsd: arm, mips64, powerpc, powerpc64, and riscv64.
2022-03-01Provide C FFI types via core::ffi, not just in stdJosh Triplett-0/+536
The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable.