Merge tag 'soundwire-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul...
[linux-2.6-block.git] / include / linux / export.h
CommitLineData
bf49d9dd 1/* SPDX-License-Identifier: GPL-2.0-only */
f5016932
PG
2#ifndef _LINUX_EXPORT_H
3#define _LINUX_EXPORT_H
b67067f1 4
ddb5cdba
MY
5#include <linux/compiler.h>
6#include <linux/linkage.h>
d143b9db
GKH
7#include <linux/stringify.h>
8
f5016932
PG
9/*
10 * Export symbols from the kernel to modules. Forked from module.h
11 * to reduce the amount of pointless cruft we feed to gcc when only
12 * exporting a simple symbol or two.
13 *
b92021b0
RR
14 * Try not to add #includes here. It slows compilation and makes kernel
15 * hackers place grumpy comments in header files.
f5016932
PG
16 */
17
7b453719
MY
18/*
19 * This comment block is used by fixdep. Please do not remove.
20 *
21 * When CONFIG_MODVERSIONS is changed from n to y, all source files having
22 * EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
23 * side effect of the *.o build rule.
24 */
25
b92021b0 26#ifndef __ASSEMBLY__
f5016932
PG
27#ifdef MODULE
28extern struct module __this_module;
29#define THIS_MODULE (&__this_module)
30#else
31#define THIS_MODULE ((struct module *)0)
32#endif
ddb5cdba 33#endif /* __ASSEMBLY__ */
f5016932 34
ddb5cdba
MY
35#ifdef CONFIG_64BIT
36#define __EXPORT_SYMBOL_REF(sym) \
37 .balign 8 ASM_NL \
38 .quad sym
7290d580 39#else
ddb5cdba
MY
40#define __EXPORT_SYMBOL_REF(sym) \
41 .balign 4 ASM_NL \
42 .long sym
7290d580
AB
43#endif
44
5e9e95cc 45#define ___EXPORT_SYMBOL(sym, license, ns) \
ddb5cdba
MY
46 .section ".export_symbol","a" ASM_NL \
47 __export_symbol_##sym: ASM_NL \
48 .asciz license ASM_NL \
49 .asciz ns ASM_NL \
50 __EXPORT_SYMBOL_REF(sym) ASM_NL \
51 .previous
52
481461f5 53#if defined(__DISABLE_EXPORTS)
f922c4ab
AB
54
55/*
56 * Allow symbol exports to be disabled completely so that C code may
57 * be reused in other execution contexts such as the UEFI stub or the
58 * decompressor.
59 */
8ed7e33a 60#define __EXPORT_SYMBOL(sym, license, ns)
f922c4ab 61
5e9e95cc 62#elif defined(__GENKSYMS__)
bbda5ec6 63
8ed7e33a 64#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
c1a95fda 65
5e9e95cc 66#elif defined(__ASSEMBLY__)
ddb5cdba 67
5e9e95cc
MY
68#define __EXPORT_SYMBOL(sym, license, ns) \
69 ___EXPORT_SYMBOL(sym, license, ns)
8651ec01 70
f2355416 71#else
f2355416 72
5e9e95cc
MY
73#define __EXPORT_SYMBOL(sym, license, ns) \
74 extern typeof(sym) sym; \
75 __ADDRESSABLE(sym) \
76 asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
f5016932 77
481461f5 78#endif
f5016932 79
8e2adc6a 80#ifdef DEFAULT_SYMBOL_NAMESPACE
8ed7e33a 81#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE))
c3a6cf19 82#else
8ed7e33a 83#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
8e2adc6a
MM
84#endif
85
c3a6cf19 86#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
ddb5cdba 87#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
d143b9db 88#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", __stringify(ns))
ddb5cdba 89#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", __stringify(ns))
f5016932
PG
90
91#endif /* _LINUX_EXPORT_H */