Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

api.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef _GPXE_API_H
  2. #define _GPXE_API_H
  3. /** @file
  4. *
  5. * gPXE internal APIs
  6. *
  7. * There are various formally-defined APIs internal to gPXE, with
  8. * several differing implementations specific to particular execution
  9. * environments (e.g. PC BIOS, EFI, LinuxBIOS).
  10. *
  11. */
  12. /** @defgroup Single-implementation APIs
  13. *
  14. * These are APIs for which only a single implementation may be
  15. * compiled in at any given time.
  16. *
  17. * @{
  18. */
  19. /**
  20. * Calculate function implementation name
  21. *
  22. * @v _prefix Subsystem prefix
  23. * @v _api_func API function
  24. * @ret _subsys_func Subsystem API function
  25. *
  26. * The subsystem prefix should be an empty string for the currently
  27. * selected subsystem, and should be a subsystem-unique string for all
  28. * other subsystems.
  29. */
  30. #define SINGLE_API_NAME( _prefix, _api_func ) _prefix ## _api_func
  31. /**
  32. * Calculate static inline function name
  33. *
  34. * @v _prefix Subsystem prefix
  35. * @v _api_func API function
  36. * @ret _subsys_func Subsystem API function
  37. */
  38. #define SINGLE_API_INLINE( _prefix, _api_func ) \
  39. SINGLE_API_NAME ( _prefix, _api_func )
  40. /**
  41. * Provide an API implementation
  42. *
  43. * @v _prefix Subsystem prefix
  44. * @v _api_func API function
  45. * @v _func Implementing function
  46. */
  47. #define PROVIDE_SINGLE_API( _prefix, _api_func, _func ) \
  48. /* Ensure that _api_func exists */ \
  49. typeof ( _api_func ) _api_func; \
  50. /* Ensure that _func exists */ \
  51. typeof ( _func ) _func; \
  52. /* Ensure that _func is type-compatible with _api_func */ \
  53. typeof ( _api_func ) _func; \
  54. /* Ensure that _subsys_func is non-static */ \
  55. extern typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func ); \
  56. /* Provide symbol alias from _subsys_func to _func */ \
  57. typeof ( _api_func ) SINGLE_API_NAME ( _prefix, _api_func ) \
  58. __attribute__ (( alias ( #_func ) ));
  59. /**
  60. * Provide a static inline API implementation
  61. *
  62. * @v _prefix Subsystem prefix
  63. * @v _api_func API function
  64. */
  65. #define PROVIDE_SINGLE_API_INLINE( _prefix, _api_func ) \
  66. /* Ensure that _api_func exists */ \
  67. typeof ( _api_func ) _api_func; \
  68. /* Ensure that _subsys_func exists and is static */ \
  69. static typeof ( SINGLE_API_INLINE ( _prefix, _api_func ) ) \
  70. SINGLE_API_INLINE ( _prefix, _api_func ); \
  71. /* Ensure that _subsys_func is type-compatible with _api_func */ \
  72. typeof ( _api_func ) SINGLE_API_INLINE ( _prefix, _api_func );
  73. /** @} */
  74. #endif /* _GPXE_API_H */