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 * 68fcbf024SMiguel Ojeda * This requires the Rust's new/future `v0` mangling scheme because the default 78fcbf024SMiguel Ojeda * one ("legacy") uses invalid characters for C identifiers (thus we cannot use 88fcbf024SMiguel Ojeda * the `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 148fcbf024SMiguel Ojeda #include <linux/module.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" 198fcbf024SMiguel Ojeda #include "exports_alloc_generated.h" 208fcbf024SMiguel Ojeda #include "exports_bindings_generated.h" 218fcbf024SMiguel Ojeda #include "exports_kernel_generated.h" 22*ecaa6ddfSGary Guo 23*ecaa6ddfSGary Guo // For modules using `rust/build_error.rs`. 24*ecaa6ddfSGary Guo #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW 25*ecaa6ddfSGary Guo EXPORT_SYMBOL_RUST_GPL(rust_build_error); 26*ecaa6ddfSGary Guo #endif 27