1 // SPDX-License-Identifier: GPL-2.0
3 //! Our own `compiler_builtins`.
5 //! Rust provides [`compiler_builtins`] as a port of LLVM's [`compiler-rt`].
6 //! Since we do not need the vast majority of them, we avoid the dependency
7 //! by providing this file.
9 //! At the moment, some builtins are required that should not be. For instance,
10 //! [`core`] has 128-bit integers functionality which we should not be compiling
11 //! in. We will work with upstream [`core`] to provide feature flags to disable
12 //! the parts we do not need. For the moment, we define them to [`panic!`] at
13 //! runtime for simplicity to catch mistakes, instead of performing surgery
16 //! In any case, all these symbols are weakened to ensure we do not override
17 //! those that may be provided by the rest of the kernel.
19 //! [`compiler_builtins`]: https://github.com/rust-lang/compiler-builtins
20 //! [`compiler-rt`]: https://compiler-rt.llvm.org/
22 #![feature(compiler_builtins)]
27 macro_rules! define_panicking_intrinsics(
28 ($reason: tt, { $($ident: ident, )* }) => {
31 #[export_name = concat!("__rust", stringify!($ident))]
32 pub extern "C" fn $ident() {
39 define_panicking_intrinsics!("`f32` should not be used", {
50 define_panicking_intrinsics!("`f64` should not be used", {
58 define_panicking_intrinsics!("`i128` should not be used", {
64 define_panicking_intrinsics!("`u128` should not be used", {
72 // NOTE: if you are adding a new intrinsic here, you should also add it to
73 // `redirect-intrinsics` in `rust/Makefile`.