1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Non-trivial C macros cannot be used in Rust. Similarly, inlined C functions 4 * cannot be called either. This file explicitly creates functions ("helpers") 5 * that wrap those so that they can be called from Rust. 6 * 7 * Sorted alphabetically. 8 */ 9 10 #include <linux/compiler_types.h> 11 12 #ifdef __BINDGEN__ 13 // Omit `inline` for bindgen as it ignores inline functions. 14 #define __rust_helper 15 #else 16 // The helper functions are all inline functions. 17 // 18 // We use `__always_inline` here to bypass LLVM inlining checks, in case the 19 // helpers are inlined directly into Rust CGUs. 20 // 21 // The LLVM inlining checks are false positives: 22 // * LLVM doesn't want to inline functions compiled with 23 // `-fno-delete-null-pointer-checks` with code compiled without. 24 // The C CGUs all have this enabled and Rust CGUs don't. Inlining is okay 25 // since this is one of the hardening features that does not change the ABI, 26 // and we shouldn't have null pointer dereferences in these helpers. 27 // * LLVM doesn't want to inline functions with different list of builtins. C 28 // side has `-fno-builtin-wcslen`; `wcslen` is not a Rust builtin, so they 29 // should be compatible, but LLVM does not perform inlining due to attributes 30 // mismatch. 31 // * clang and Rust doesn't have the exact target string. Clang generates 32 // `+cmov,+cx8,+fxsr` but Rust doesn't enable them (in fact, Rust will 33 // complain if `-Ctarget-feature=+cmov,+cx8,+fxsr` is used). x86-64 always 34 // enable these features, so they are in fact the same target string, but 35 // LLVM doesn't understand this and so inlining is inhibited. This can be 36 // bypassed with `--ignore-tti-inline-compatible`, but this is a hidden 37 // option. 38 #define __rust_helper __always_inline 39 #endif 40 41 #include "atomic.c" 42 #include "atomic_ext.c" 43 #include "auxiliary.c" 44 #include "barrier.c" 45 #include "binder.c" 46 #include "bitmap.c" 47 #include "bitops.c" 48 #include "blk.c" 49 #include "bug.c" 50 #include "build_assert.c" 51 #include "build_bug.c" 52 #include "clk.c" 53 #include "completion.c" 54 #include "cpu.c" 55 #include "cpufreq.c" 56 #include "cpumask.c" 57 #include "cred.c" 58 #include "device.c" 59 #include "dma.c" 60 #include "drm.c" 61 #include "err.c" 62 #include "irq.c" 63 #include "fs.c" 64 #include "io.c" 65 #include "jump_label.c" 66 #include "kunit.c" 67 #include "maple_tree.c" 68 #include "mm.c" 69 #include "mutex.c" 70 #include "of.c" 71 #include "page.c" 72 #include "pci.c" 73 #include "pid_namespace.c" 74 #include "platform.c" 75 #include "poll.c" 76 #include "processor.c" 77 #include "property.c" 78 #include "pwm.c" 79 #include "rbtree.c" 80 #include "rcu.c" 81 #include "refcount.c" 82 #include "regulator.c" 83 #include "scatterlist.c" 84 #include "security.c" 85 #include "signal.c" 86 #include "slab.c" 87 #include "spinlock.c" 88 #include "sync.c" 89 #include "task.c" 90 #include "time.c" 91 #include "uaccess.c" 92 #include "usb.c" 93 #include "vmalloc.c" 94 #include "wait.c" 95 #include "workqueue.c" 96 #include "xarray.c" 97