linux-zen-desktop/include/linux/export.h

92 lines
2.5 KiB
C
Raw Permalink Normal View History

2023-08-30 17:31:07 +02:00
/* SPDX-License-Identifier: GPL-2.0-only */
#ifndef _LINUX_EXPORT_H
#define _LINUX_EXPORT_H
2023-10-24 12:59:35 +02:00
#include <linux/compiler.h>
#include <linux/linkage.h>
2023-08-30 17:31:07 +02:00
#include <linux/stringify.h>
/*
* Export symbols from the kernel to modules. Forked from module.h
* to reduce the amount of pointless cruft we feed to gcc when only
* exporting a simple symbol or two.
*
* Try not to add #includes here. It slows compilation and makes kernel
* hackers place grumpy comments in header files.
*/
/*
* This comment block is used by fixdep. Please do not remove.
*
* When CONFIG_MODVERSIONS is changed from n to y, all source files having
* EXPORT_SYMBOL variants must be re-compiled because genksyms is run as a
* side effect of the *.o build rule.
*/
#ifndef __ASSEMBLY__
#ifdef MODULE
extern struct module __this_module;
#define THIS_MODULE (&__this_module)
#else
#define THIS_MODULE ((struct module *)0)
#endif
2023-10-24 12:59:35 +02:00
#endif /* __ASSEMBLY__ */
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
#ifdef CONFIG_64BIT
#define __EXPORT_SYMBOL_REF(sym) \
.balign 8 ASM_NL \
.quad sym
2023-08-30 17:31:07 +02:00
#else
2023-10-24 12:59:35 +02:00
#define __EXPORT_SYMBOL_REF(sym) \
.balign 4 ASM_NL \
.long sym
2023-08-30 17:31:07 +02:00
#endif
2023-10-24 12:59:35 +02:00
#define ___EXPORT_SYMBOL(sym, license, ns) \
.section ".export_symbol","a" ASM_NL \
__export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
.asciz ns ASM_NL \
__EXPORT_SYMBOL_REF(sym) ASM_NL \
.previous
2023-08-30 17:31:07 +02:00
#if !defined(CONFIG_MODULES) || defined(__DISABLE_EXPORTS)
/*
* Allow symbol exports to be disabled completely so that C code may
* be reused in other execution contexts such as the UEFI stub or the
* decompressor.
*/
2023-10-24 12:59:35 +02:00
#define __EXPORT_SYMBOL(sym, license, ns)
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
#elif defined(__GENKSYMS__)
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
#define __EXPORT_SYMBOL(sym, license, ns) __GENKSYMS_EXPORT_SYMBOL(sym)
2023-08-30 17:31:07 +02:00
2023-10-24 12:59:35 +02:00
#elif defined(__ASSEMBLY__)
#define __EXPORT_SYMBOL(sym, license, ns) \
___EXPORT_SYMBOL(sym, license, ns)
2023-08-30 17:31:07 +02:00
#else
2023-10-24 12:59:35 +02:00
#define __EXPORT_SYMBOL(sym, license, ns) \
extern typeof(sym) sym; \
__ADDRESSABLE(sym) \
asm(__stringify(___EXPORT_SYMBOL(sym, license, ns)))
2023-08-30 17:31:07 +02:00
#endif /* CONFIG_MODULES */
#ifdef DEFAULT_SYMBOL_NAMESPACE
2023-10-24 12:59:35 +02:00
#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, __stringify(DEFAULT_SYMBOL_NAMESPACE))
2023-08-30 17:31:07 +02:00
#else
2023-10-24 12:59:35 +02:00
#define _EXPORT_SYMBOL(sym, license) __EXPORT_SYMBOL(sym, license, "")
2023-08-30 17:31:07 +02:00
#endif
#define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
2023-10-24 12:59:35 +02:00
#define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL")
2023-08-30 17:31:07 +02:00
#define EXPORT_SYMBOL_NS(sym, ns) __EXPORT_SYMBOL(sym, "", __stringify(ns))
2023-10-24 12:59:35 +02:00
#define EXPORT_SYMBOL_NS_GPL(sym, ns) __EXPORT_SYMBOL(sym, "GPL", __stringify(ns))
2023-08-30 17:31:07 +02:00
#endif /* _LINUX_EXPORT_H */