8 * There are various formally-defined APIs internal to iPXE, with
9 * several differing implementations specific to particular execution
10 * environments (e.g. PC BIOS, EFI, LinuxBIOS).
14 FILE_LICENCE ( GPL2_OR_LATER );
16 /** @defgroup Single-implementation APIs
18 * These are APIs for which only a single implementation may be
19 * compiled in at any given time.
25 * Calculate function implementation name
27 * @v _prefix Subsystem prefix
28 * @v _api_func API function
29 * @ret _subsys_func Subsystem API function
31 * The subsystem prefix should be an empty string for the currently
32 * selected subsystem, and should be a subsystem-unique string for all
35 #define SINGLE_API_NAME( _prefix, _api_func ) _prefix ## _api_func
38 * Calculate static inline function name
40 * @v _prefix Subsystem prefix
41 * @v _api_func API function
42 * @ret _subsys_func Subsystem API function
44 #define SINGLE_API_INLINE( _prefix, _api_func ) \
45 SINGLE_API_NAME ( _prefix, _api_func )
48 * Provide an API implementation
50 * @v _prefix Subsystem prefix
51 * @v _api_func API function
52 * @v _func Implementing function
54 #define PROVIDE_SINGLE_API( _prefix, _api_func, _func ) \
55 /* Ensure that _api_func exists */ \
56 typeof ( _api_func ) _api_func; \
57 /* Ensure that _func exists */ \
58 typeof ( _func ) _func; \
59 /* Ensure that _func is type-compatible with _api_func */ \
60 typeof ( _api_func ) _func; \
61 /* Ensure that _subsys_func is non-static */ \
62 extern typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func ); \
63 /* Provide symbol alias from _subsys_func to _func */ \
64 typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func ) \
65 __attribute__ (( alias ( #_func ) ));
68 * Provide a static inline API implementation
70 * @v _prefix Subsystem prefix
71 * @v _api_func API function
73 #define PROVIDE_SINGLE_API_INLINE( _prefix, _api_func ) \
74 /* Ensure that _api_func exists */ \
75 typeof ( _api_func ) _api_func; \
76 /* Ensure that _subsys_func exists and is static */ \
77 static typeof ( SINGLE_API_INLINE ( _prefix, _api_func ) ) \
78 SINGLE_API_INLINE ( _prefix, _api_func ); \
79 /* Ensure that _subsys_func is type-compatible with _api_func */ \
80 typeof ( _api_func ) SINGLE_API_INLINE ( _prefix, _api_func );
84 #endif /* _IPXE_API_H */