OSDN Git Service

f2fs: Revert rapid GC
[sagit-ice-cold/kernel_xiaomi_msm8998.git] / include / linux / export.h
1 #ifndef _LINUX_EXPORT_H
2 #define _LINUX_EXPORT_H
3
4 /*
5  * Export symbols from the kernel to modules.  Forked from module.h
6  * to reduce the amount of pointless cruft we feed to gcc when only
7  * exporting a simple symbol or two.
8  *
9  * Try not to add #includes here.  It slows compilation and makes kernel
10  * hackers place grumpy comments in header files.
11  */
12
13 /* Some toolchains use a `_' prefix for all user symbols. */
14 #ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
15 #define __VMLINUX_SYMBOL(x) _##x
16 #define __VMLINUX_SYMBOL_STR(x) "_" #x
17 #else
18 #define __VMLINUX_SYMBOL(x) x
19 #define __VMLINUX_SYMBOL_STR(x) #x
20 #endif
21
22 /* Indirect, so macros are expanded before pasting. */
23 #define VMLINUX_SYMBOL(x) __VMLINUX_SYMBOL(x)
24 #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x)
25
26 #ifndef __ASSEMBLY__
27 struct kernel_symbol
28 {
29         unsigned long value;
30         const char *name;
31 };
32
33 #ifdef MODULE
34 extern struct module __this_module;
35 #define THIS_MODULE (&__this_module)
36 #else
37 #define THIS_MODULE ((struct module *)0)
38 #endif
39
40 #ifdef CONFIG_MODULES
41
42 #ifndef __GENKSYMS__
43 #ifdef CONFIG_MODVERSIONS
44 /* Mark the CRC weak since genksyms apparently decides not to
45  * generate a checksums for some symbols */
46 #define __CRC_SYMBOL(sym, sec)                                          \
47         extern __visible void *__crc_##sym __attribute__((weak));       \
48         static const unsigned long __kcrctab_##sym                      \
49         __used                                                          \
50         __attribute__((section("___kcrctab" sec "+" #sym), used))       \
51         = (unsigned long) &__crc_##sym;
52 #else
53 #define __CRC_SYMBOL(sym, sec)
54 #endif
55
56 /* For every exported symbol, place a struct in the __ksymtab section */
57 #define __EXPORT_SYMBOL(sym, sec)                                       \
58         extern typeof(sym) sym;                                         \
59         __CRC_SYMBOL(sym, sec)                                          \
60         static const char __kstrtab_##sym[]                             \
61         __attribute__((section("__ksymtab_strings"), aligned(1)))       \
62         = VMLINUX_SYMBOL_STR(sym);                                      \
63         static const struct kernel_symbol __ksymtab_##sym               \
64         __used                                                          \
65         __attribute__((section("___ksymtab" sec "+" #sym), used))       \
66         = { (unsigned long)&sym, __kstrtab_##sym }
67
68 #define EXPORT_SYMBOL(sym)                                      \
69         __EXPORT_SYMBOL(sym, "")
70
71 #define EXPORT_SYMBOL_GPL(sym)                                  \
72         __EXPORT_SYMBOL(sym, "_gpl")
73
74 #define EXPORT_SYMBOL_GPL_FUTURE(sym)                           \
75         __EXPORT_SYMBOL(sym, "_gpl_future")
76
77 #ifdef CONFIG_UNUSED_SYMBOLS
78 #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
79 #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
80 #else
81 #define EXPORT_UNUSED_SYMBOL(sym)
82 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
83 #endif
84
85 #endif  /* __GENKSYMS__ */
86
87 #else /* !CONFIG_MODULES... */
88
89 #define EXPORT_SYMBOL(sym)
90 #define EXPORT_SYMBOL_GPL(sym)
91 #define EXPORT_SYMBOL_GPL_FUTURE(sym)
92 #define EXPORT_UNUSED_SYMBOL(sym)
93 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
94
95 #endif /* CONFIG_MODULES */
96 #endif /* !__ASSEMBLY__ */
97
98 #endif /* _LINUX_EXPORT_H */