diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/include/runtime/interface.h | 15 | ||||
-rw-r--r-- | src/runtime/rt_time.C | 9 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/include/runtime/interface.h b/src/include/runtime/interface.h index 69696cfc0..52717fbc3 100644 --- a/src/include/runtime/interface.h +++ b/src/include/runtime/interface.h @@ -40,7 +40,7 @@ #ifndef __HOSTBOOT_RUNTIME_INTERFACE_VERSION_ONLY #include <stdint.h> - +#include <time.h> /** @typedef hostInterfaces_t * @brief Interfaces provided by the underlying environment (ex. Sapphire). * @@ -142,6 +142,19 @@ typedef struct hostInterfaces */ void (*report_failure)( uint64_t i_status, uint64_t i_partId ); + /** + * @brief Reads the clock value from a POSIX clock. + * @param[in] i_clkId - The clock ID to read. + * @param[out] o_tp - The timespec struct to store the clock value in. + * + * @return 0 or -(errno). + * @retval 0 - SUCCESS. + * @retval -EINVAL - Invalid clock requested. + * @retval -EFAULT - NULL ptr given for timespec struct. + * + */ + int (*clock_gettime)(clockid_t i_clkId, timespec_t* o_tp); + // Reserve some space for future growth. void (*reserved[32])(void); diff --git a/src/runtime/rt_time.C b/src/runtime/rt_time.C index a5d00157e..e222a3718 100644 --- a/src/runtime/rt_time.C +++ b/src/runtime/rt_time.C @@ -33,3 +33,12 @@ void nanosleep(uint64_t sec, uint64_t nsec) } } +int clock_gettime(clockid_t i_clkId, timespec_t* o_tp) +{ + int l_rc = -1; + if (g_hostInterfaces && g_hostInterfaces->clock_gettime) + { + l_rc = g_hostInterfaces->clock_gettime(i_clkId, o_tp); + } + return l_rc; +} |