xref: /linux/rust/exports.c (revision 54c5dc52143e5b335b698f4e8810efa1f00787bf)
18fcbf024SMiguel Ojeda // SPDX-License-Identifier: GPL-2.0
28fcbf024SMiguel Ojeda /*
38fcbf024SMiguel Ojeda  * A hack to export Rust symbols for loadable modules without having to redo
48fcbf024SMiguel Ojeda  * the entire `include/linux/export.h` logic in Rust.
58fcbf024SMiguel Ojeda  *
6*54c5dc52STamir Duberstein  * This requires Rust's new/future `v0` mangling scheme because the default one
7*54c5dc52STamir Duberstein  * ("legacy") uses invalid characters for C identifiers (thus we cannot use the
8*54c5dc52STamir Duberstein  * `EXPORT_SYMBOL_*` macros).
98fcbf024SMiguel Ojeda  *
108fcbf024SMiguel Ojeda  * All symbols are exported as GPL-only to guarantee no GPL-only feature is
118fcbf024SMiguel Ojeda  * accidentally exposed.
128fcbf024SMiguel Ojeda  */
138fcbf024SMiguel Ojeda 
14dc92ac9fSMasahiro Yamada #include <linux/export.h>
158fcbf024SMiguel Ojeda 
168fcbf024SMiguel Ojeda #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
178fcbf024SMiguel Ojeda 
188fcbf024SMiguel Ojeda #include "exports_core_generated.h"
19e26fa546SGary Guo #include "exports_helpers_generated.h"
208fcbf024SMiguel Ojeda #include "exports_bindings_generated.h"
218fcbf024SMiguel Ojeda #include "exports_kernel_generated.h"
22ecaa6ddfSGary Guo 
23ecaa6ddfSGary Guo // For modules using `rust/build_error.rs`.
24ecaa6ddfSGary Guo #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
25ecaa6ddfSGary Guo EXPORT_SYMBOL_RUST_GPL(rust_build_error);
26ecaa6ddfSGary Guo #endif
27