projects/linux·blob master · refs

108 lines · 3.1 KiB

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#ifdef CONFIG_DMA_SHARED_BUFFER
61#include "dma-resv.c"
62#endif
63#include "drm.c"
64#include "drm_gpuvm.c"
65#include "err.c"
66#include "fs.c"
67#include "fwctl.c"
68#include "gpu.c"
69#include "interrupt.c"
70#include "io.c"
71#include "irq.c"
72#include "jump_label.c"
73#include "kunit.c"
74#include "list.c"
75#include "maple_tree.c"
76#include "mm.c"
77#include "mutex.c"
78#include "net/genetlink.c"
79#include "of.c"
80#include "page.c"
81#include "pci.c"
82#include "pid_namespace.c"
83#include "platform.c"
84#include "poll.c"
85#include "processor.c"
86#include "property.c"
87#include "pwm.c"
88#include "rbtree.c"
89#include "rcu.c"
90#include "refcount.c"
91#include "regulator.c"
92#include "scatterlist.c"
93#include "security.c"
94#include "serdev.c"
95#include "signal.c"
96#include "slab.c"
97#include "spinlock.c"
98#include "string.c"
99#include "srcu.c"
100#include "sync.c"
101#include "task.c"
102#include "time.c"
103#include "uaccess.c"
104#include "usb.c"
105#include "vmalloc.c"
106#include "wait.c"
107#include "workqueue.c"
108#include "xarray.c"