Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux.git] / include / linux / export.h
blob2633df4d31e622a4be7dfa5a183db39fa09051ee
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>
9 /*
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.
17 #ifdef CONFIG_64BIT
18 #define __EXPORT_SYMBOL_REF(sym) \
19 .balign 8 ASM_NL \
20 .quad sym
21 #else
22 #define __EXPORT_SYMBOL_REF(sym) \
23 .balign 4 ASM_NL \
24 .long sym
25 #endif
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 \
31 .asciz ns ASM_NL \
32 __EXPORT_SYMBOL_REF(sym) ASM_NL \
33 .previous
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
40 * decompressor.
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)
53 #else
55 #define __EXPORT_SYMBOL(sym, license, ns) \
56 extern typeof(sym) sym; \
57 __ADDRESSABLE(sym) \
58 asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
60 #endif
62 #ifdef DEFAULT_SYMBOL_NAMESPACE
63 #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, DEFAULT_SYMBOL_NAMESPACE)
64 #else
65 #define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
66 #endif
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 */