1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _LINUX_EXPORT_H
3 #define _LINUX_EXPORT_H
5 #include <linux/compiler.h>
6 #include <linux/linkage.h>
7 #include <linux/stringify.h>
10 * This comment block is used by fixdep. Please do not remove.
12 * When CONFIG_MODVERSIONS is changed from n to y, all source files having
13 * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
14 * side effect of the *.o build rule.
18 #define __EXPORT_SYMBOL_REF(sym) \
22 #define __EXPORT_SYMBOL_REF(sym) \
27 #define ___EXPORT_SYMBOL(sym, license, ns) \
28 .section ".export_symbol","a" ASM_NL \
29 __export_symbol_##sym: ASM_NL \
30 .asciz license ASM_NL \
32 __EXPORT_SYMBOL_REF(sym) ASM_NL \
35 #if defined(__DISABLE_EXPORTS)
38 * Allow symbol exports to be disabled completely so that C code may
39 * be reused in other execution contexts such as the UEFI stub or the
42 #define __EXPORT_SYMBOL(sym, license, ns)
44 #elif defined(__GENKSYMS__)
46 #define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
48 #elif defined(__ASSEMBLY__)
50 #define __EXPORT_SYMBOL(sym, license, ns) \
51 ___EXPORT_SYMBOL(sym, license, ns)
55 #define __EXPORT_SYMBOL(sym, license, ns) \
56 extern typeof(sym) sym; \
58 asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
62 #ifdef DEFAULT_SYMBOL_NAMESPACE
63 #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)
65 #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
68 #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
69 #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
70 #define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", ns)
71 #define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", ns)
73 #endif /* _LINUX_EXPORT_H */