You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

time.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _IPXE_TIME_H
  2. #define _IPXE_TIME_H
  3. /** @file
  4. *
  5. * Time source
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <sys/time.h>
  10. #include <ipxe/api.h>
  11. #include <config/time.h>
  12. /**
  13. * Calculate static inline time API function name
  14. *
  15. * @v _prefix Subsystem prefix
  16. * @v _api_func API function
  17. * @ret _subsys_func Subsystem API function
  18. */
  19. #define TIME_INLINE( _subsys, _api_func ) \
  20. SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
  21. /**
  22. * Provide a time API implementation
  23. *
  24. * @v _prefix Subsystem prefix
  25. * @v _api_func API function
  26. * @v _func Implementing function
  27. */
  28. #define PROVIDE_TIME( _subsys, _api_func, _func ) \
  29. PROVIDE_SINGLE_API ( TIME_PREFIX_ ## _subsys, _api_func, _func )
  30. /**
  31. * Provide a static inline time API implementation
  32. *
  33. * @v _prefix Subsystem prefix
  34. * @v _api_func API function
  35. */
  36. #define PROVIDE_TIME_INLINE( _subsys, _api_func ) \
  37. PROVIDE_SINGLE_API_INLINE ( TIME_PREFIX_ ## _subsys, _api_func )
  38. /* Include all architecture-independent time API headers */
  39. #include <ipxe/null_time.h>
  40. #include <ipxe/efi/efi_time.h>
  41. #include <ipxe/linux/linux_time.h>
  42. /* Include all architecture-dependent time API headers */
  43. #include <bits/time.h>
  44. extern signed long time_offset;
  45. /**
  46. * Get current time in seconds (ignoring system clock offset)
  47. *
  48. * @ret time Time, in seconds
  49. */
  50. time_t time_now ( void );
  51. /**
  52. * Adjust system clock
  53. *
  54. * @v delta Clock adjustment, in seconds
  55. */
  56. static inline __attribute__ (( always_inline )) void
  57. time_adjust ( signed long delta ) {
  58. time_offset += delta;
  59. }
  60. #endif /* _IPXE_TIME_H */