XenevaOS
Loading...
Searching...
No Matches
export.h
Go to the documentation of this file.
1#ifndef __LINUX_EXPORT_H__
2#define __LINUX_EXPORT_H__
3
4/*
5 * DCL <linux/export.h> -- EXPORT_SYMBOL family. DCL compiles ports straight
6 * into the kernel image rather than into modules, so exporting is a no-op
7 * here; a port built as a .ko resolves symbols through
8 * KernelAA64/kernel_exports.c instead. No-ops keep both worlds' source
9 * compiling unchanged.
10 */
11
12#define EXPORT_SYMBOL(sym)
13#define EXPORT_SYMBOL_GPL(sym)
14#define EXPORT_SYMBOL_NS(sym, ns)
15#define EXPORT_SYMBOL_NS_GPL(sym, ns)
16
17/*
18 * EXPORT_SYMBOL_IF_KUNIT(sym) -- "export this only in a KUnit build", so the
19 * symbol exists for tests and not for a shippable image. mainline guards the
20 * two spellings on CONFIG_KUNIT: EXPORT_SYMBOL(sym) when it is set, the empty
21 * macro otherwise. Both arms are this macro here, and not as a simplification
22 * -- CONFIG_KUNIT has no referent, and EXPORT_SYMBOL is already the empty
23 * macro, so the guard would be choosing between two spellings of nothing.
24 *
25 * Four consumers, all drm: drm_color_mgmt.c:499/:515 export the maximum-
26 * luminance property tests, vkms_composer.c and vkms_formats.c do the same
27 * for their CTM and format helpers, vkms_config.c for the config accessors.
28 * All four sit in the tree's *first* configuration-tunable code, which is
29 * worth noting: the call sites are the point, and they are the first thing
30 * here written against a test harness that does not exist yet.
31 *
32 * It is a macro at all rather than nothing, because an undefined
33 * EXPORT_SYMBOL_IF_KUNIT(name) at file scope reads as a function *declaration*
34 * -- "type specifier missing, defaults to int" plus "a parameter list without
35 * types is only allowed in a function definition", one error at the site of
36 * the export and none of them naming the macro.
37 */
38#define EXPORT_SYMBOL_IF_KUNIT(sym)
39
40/*
41 * VISIBLE_IF_KUNIT(sym) -- the *declaration* half of the same pair, and the
42 * reason it is here at all is vkms_composer.c:67, :78, :86 and :132.
43 *
44 * Unlike every other macro in this header, that one prefixes a function *definition*
45 * -- `VISIBLE_IF_KUNIT u16 lerp_u16(u16 a, u16 b, s64 t)` -- so an undefined
46 * spelling does not decay into a harmless no-op the way an EXPORT_* line
47 * would: it leaves a bare identifier where the return type belongs, and clang
48 * reports "unknown type name 'VISIBLE_IF_KUNIT'" at each of the four, plus
49 * "expected ';' after top level declarator" on the closing brace of each.
50 *
51 * Empty, and the emptiness is the honest answer rather than a shortcut. In
52 * mainline the attribute carries the visibility that makes an exported symbol
53 * survive a non-KUnit link; DCL drops the export (EXPORT_SYMBOL_IF_KUNIT
54 * above), so there is nothing left to keep visible.
55 *
56 * Object-like, not function-like: the four sites write it with no argument
57 * list at all -- `VISIBLE_IF_KUNIT u16 lerp_u16(u16 a, u16 b, s64 t)` -- so a
58 * parameterised definition would never fire, since a function-like macro only
59 * expands when the next token is `(`. A parameter here would be a definition
60 * that never runs.
61 */
62#define VISIBLE_IF_KUNIT
63
64#endif /* __LINUX_EXPORT_H__ */