1 #ifndef _LINUX_EXPORT_H
2 #define _LINUX_EXPORT_H
4 * Export symbols from the kernel to modules. Forked from module.h
5 * to reduce the amount of pointless cruft we feed to gcc when only
6 * exporting a simple symbol or two.
8 * If you feel the need to add #include <linux/foo.h> to this file
9 * then you are doing something wrong and should go away silently.
12 /* Some toolchains use a `_' prefix for all user symbols. */
13 #ifdef CONFIG_SYMBOL_PREFIX
14 #define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
16 #define MODULE_SYMBOL_PREFIX ""
26 extern struct module __this_module
;
27 #define THIS_MODULE (&__this_module)
29 #define THIS_MODULE ((struct module *)0)
35 #ifdef CONFIG_MODVERSIONS
36 /* Mark the CRC weak since genksyms apparently decides not to
37 * generate a checksums for some symbols */
38 #define __CRC_SYMBOL(sym, sec) \
39 extern void *__crc_##sym __attribute__((weak)); \
40 static const unsigned long __kcrctab_##sym \
42 __attribute__((section("___kcrctab" sec "+" #sym), unused)) \
43 = (unsigned long) &__crc_##sym;
45 #define __CRC_SYMBOL(sym, sec)
48 /* For every exported symbol, place a struct in the __ksymtab section */
49 #define __EXPORT_SYMBOL(sym, sec) \
50 extern typeof(sym) sym; \
51 __CRC_SYMBOL(sym, sec) \
52 static const char __kstrtab_##sym[] \
53 __attribute__((section("__ksymtab_strings"), aligned(1))) \
54 = MODULE_SYMBOL_PREFIX #sym; \
55 static const struct kernel_symbol __ksymtab_##sym \
57 __attribute__((section("___ksymtab" sec "+" #sym), unused)) \
58 = { (unsigned long)&sym, __kstrtab_##sym }
60 #define EXPORT_SYMBOL(sym) \
61 __EXPORT_SYMBOL(sym, "")
63 #define EXPORT_SYMBOL_GPL(sym) \
64 __EXPORT_SYMBOL(sym, "_gpl")
66 #define EXPORT_SYMBOL_GPL_FUTURE(sym) \
67 __EXPORT_SYMBOL(sym, "_gpl_future")
69 #ifdef CONFIG_UNUSED_SYMBOLS
70 #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
71 #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
73 #define EXPORT_UNUSED_SYMBOL(sym)
74 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
77 #endif /* __GENKSYMS__ */
79 #else /* !CONFIG_MODULES... */
81 #define EXPORT_SYMBOL(sym)
82 #define EXPORT_SYMBOL_GPL(sym)
83 #define EXPORT_SYMBOL_GPL_FUTURE(sym)
84 #define EXPORT_UNUSED_SYMBOL(sym)
85 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
87 #endif /* CONFIG_MODULES */
89 #endif /* _LINUX_EXPORT_H */