hal_time.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * time.c
  3. *
  4. * Copyright 2013-2022 Michael Zillgith
  5. *
  6. * This file is part of Platform Abstraction Layer (libpal)
  7. * for libiec61850, libmms, and lib60870.
  8. */
  9. #ifndef HAL_C_
  10. #define HAL_C_
  11. #include "hal_base.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /**
  16. * \file hal_time.h
  17. * \brief Abstraction layer for system time access
  18. */
  19. /*! \addtogroup hal
  20. *
  21. * @{
  22. */
  23. /**
  24. * @defgroup HAL_TIME Time related functions
  25. *
  26. * @{
  27. */
  28. typedef uint64_t nsSinceEpoch;
  29. typedef uint64_t msSinceEpoch;
  30. /**
  31. * Get the system time in milliseconds.
  32. *
  33. * The time value returned as 64-bit unsigned integer should represent the milliseconds
  34. * since the UNIX epoch (1970/01/01 00:00 UTC).
  35. *
  36. * \return the system time with millisecond resolution.
  37. */
  38. PAL_API msSinceEpoch
  39. Hal_getTimeInMs(void);
  40. /**
  41. * Get the system time in nanoseconds.
  42. *
  43. * The time value returned as 64-bit unsigned integer should represent the nanoseconds
  44. * since the UNIX epoch (1970/01/01 00:00 UTC).
  45. *
  46. * \return the system time with nanosecond resolution.
  47. */
  48. PAL_API nsSinceEpoch
  49. Hal_getTimeInNs(void);
  50. /**
  51. * Set the system time from ns time
  52. *
  53. * The time value returned as 64-bit unsigned integer should represent the nanoseconds
  54. * since the UNIX epoch (1970/01/01 00:00 UTC).
  55. *
  56. * \return true on success, otherwise false
  57. */
  58. PAL_API bool
  59. Hal_setTimeInNs(nsSinceEpoch nsTime);
  60. /*! @} */
  61. /*! @} */
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* HAL_C_ */