summaryrefslogtreecommitdiffstats
path: root/debian/grub-extras/disabled/gpxe/src/include/gpxe/api.h
blob: ff2ba595f58085aa89e41e3a49bf0343fef43d40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef _GPXE_API_H
#define _GPXE_API_H

/** @file
 *
 * gPXE internal APIs
 *
 * There are various formally-defined APIs internal to gPXE, with
 * several differing implementations specific to particular execution
 * environments (e.g. PC BIOS, EFI, LinuxBIOS).
 *
 */

FILE_LICENCE ( GPL2_OR_LATER );

/** @defgroup Single-implementation APIs
 *
 * These are APIs for which only a single implementation may be
 * compiled in at any given time.
 *
 * @{
 */

/**
 * Calculate function implementation name
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @ret _subsys_func	Subsystem API function
 *
 * The subsystem prefix should be an empty string for the currently
 * selected subsystem, and should be a subsystem-unique string for all
 * other subsystems.
 */
#define SINGLE_API_NAME( _prefix, _api_func ) _prefix ## _api_func

/**
 * Calculate static inline function name
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @ret _subsys_func	Subsystem API function
 */
#define SINGLE_API_INLINE( _prefix, _api_func )	\
	SINGLE_API_NAME ( _prefix, _api_func )

/**
 * Provide an API implementation
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 * @v _func		Implementing function
 */
#define PROVIDE_SINGLE_API( _prefix, _api_func, _func )			      \
	/* Ensure that _api_func exists */				      \
	typeof ( _api_func ) _api_func;					      \
	/* Ensure that _func exists */					      \
	typeof ( _func ) _func;						      \
	/* Ensure that _func is type-compatible with _api_func */	      \
	typeof ( _api_func ) _func;					      \
	/* Ensure that _subsys_func is non-static */			      \
	extern typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func );   \
	/* Provide symbol alias from _subsys_func to _func */		      \
	typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func )	      \
		__attribute__ (( alias ( #_func ) ));

/**
 * Provide a static inline API implementation
 *
 * @v _prefix		Subsystem prefix
 * @v _api_func		API function
 */
#define PROVIDE_SINGLE_API_INLINE( _prefix, _api_func )			      \
	/* Ensure that _api_func exists */				      \
	typeof ( _api_func ) _api_func;					      \
	/* Ensure that _subsys_func exists and is static */		      \
	static typeof ( SINGLE_API_INLINE ( _prefix, _api_func ) )	      \
		SINGLE_API_INLINE ( _prefix, _api_func );		      \
	/* Ensure that _subsys_func is type-compatible with _api_func */      \
	typeof ( _api_func ) SINGLE_API_INLINE ( _prefix, _api_func );

/** @} */

#endif /* _GPXE_API_H */