~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/export.h

Version: ~ [ linux-6.6-rc4 ] ~ [ linux-6.5.5 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.55 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.133 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.197 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.257 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.295 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.326 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  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 #if defined(__KERNEL__) && !defined(__GENKSYMS__)
 43 #ifdef CONFIG_MODVERSIONS
 44 /* Mark the CRC weak since genksyms apparently decides not to
 45  * generate a checksums for some symbols */
 46 #if defined(CONFIG_MODULE_REL_CRCS)
 47 #define __CRC_SYMBOL(sym, sec)                                          \
 48         asm("   .section \"___kcrctab" sec "+" #sym "\", \"a\"  \n"     \
 49             "   .weak   " VMLINUX_SYMBOL_STR(__crc_##sym) "     \n"     \
 50             "   .long   " VMLINUX_SYMBOL_STR(__crc_##sym) " - . \n"     \
 51             "   .previous                                       \n");
 52 #else
 53 #define __CRC_SYMBOL(sym, sec)                                          \
 54         asm("   .section \"___kcrctab" sec "+" #sym "\", \"a\"  \n"     \
 55             "   .weak   " VMLINUX_SYMBOL_STR(__crc_##sym) "     \n"     \
 56             "   .long   " VMLINUX_SYMBOL_STR(__crc_##sym) "     \n"     \
 57             "   .previous                                       \n");
 58 #endif
 59 #else
 60 #define __CRC_SYMBOL(sym, sec)
 61 #endif
 62 
 63 /* For every exported symbol, place a struct in the __ksymtab section */
 64 #define ___EXPORT_SYMBOL(sym, sec)                                      \
 65         extern typeof(sym) sym;                                         \
 66         __CRC_SYMBOL(sym, sec)                                          \
 67         static const char __kstrtab_##sym[]                             \
 68         __attribute__((section("__ksymtab_strings"), aligned(1)))       \
 69         = VMLINUX_SYMBOL_STR(sym);                                      \
 70         static const struct kernel_symbol __ksymtab_##sym               \
 71         __used                                                          \
 72         __attribute__((section("___ksymtab" sec "+" #sym), used))       \
 73         = { (unsigned long)&sym, __kstrtab_##sym }
 74 
 75 #if defined(__KSYM_DEPS__)
 76 
 77 /*
 78  * For fine grained build dependencies, we want to tell the build system
 79  * about each possible exported symbol even if they're not actually exported.
 80  * We use a string pattern that is unlikely to be valid code that the build
 81  * system filters out from the preprocessor output (see ksym_dep_filter
 82  * in scripts/Kbuild.include).
 83  */
 84 #define __EXPORT_SYMBOL(sym, sec)       === __KSYM_##sym ===
 85 
 86 #elif defined(CONFIG_TRIM_UNUSED_KSYMS)
 87 
 88 #include <generated/autoksyms.h>
 89 
 90 #define __EXPORT_SYMBOL(sym, sec)                               \
 91         __cond_export_sym(sym, sec, __is_defined(__KSYM_##sym))
 92 #define __cond_export_sym(sym, sec, conf)                       \
 93         ___cond_export_sym(sym, sec, conf)
 94 #define ___cond_export_sym(sym, sec, enabled)                   \
 95         __cond_export_sym_##enabled(sym, sec)
 96 #define __cond_export_sym_1(sym, sec) ___EXPORT_SYMBOL(sym, sec)
 97 #define __cond_export_sym_0(sym, sec) /* nothing */
 98 
 99 #else
100 #define __EXPORT_SYMBOL ___EXPORT_SYMBOL
101 #endif
102 
103 #define EXPORT_SYMBOL(sym)                                      \
104         __EXPORT_SYMBOL(sym, "")
105 
106 #define EXPORT_SYMBOL_GPL(sym)                                  \
107         __EXPORT_SYMBOL(sym, "_gpl")
108 
109 #define EXPORT_SYMBOL_GPL_FUTURE(sym)                           \
110         __EXPORT_SYMBOL(sym, "_gpl_future")
111 
112 #ifdef CONFIG_UNUSED_SYMBOLS
113 #define EXPORT_UNUSED_SYMBOL(sym) __EXPORT_SYMBOL(sym, "_unused")
114 #define EXPORT_UNUSED_SYMBOL_GPL(sym) __EXPORT_SYMBOL(sym, "_unused_gpl")
115 #else
116 #define EXPORT_UNUSED_SYMBOL(sym)
117 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
118 #endif
119 
120 #endif  /* __GENKSYMS__ */
121 
122 #else /* !CONFIG_MODULES... */
123 
124 #define EXPORT_SYMBOL(sym)
125 #define EXPORT_SYMBOL_GPL(sym)
126 #define EXPORT_SYMBOL_GPL_FUTURE(sym)
127 #define EXPORT_UNUSED_SYMBOL(sym)
128 #define EXPORT_UNUSED_SYMBOL_GPL(sym)
129 
130 #endif /* CONFIG_MODULES */
131 #endif /* !__ASSEMBLY__ */
132 
133 #endif /* _LINUX_EXPORT_H */
134 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp