/** ****************************************************************************** * @brief get the current time of the clock. * @param[in] clock_id : clock ID (always CLOCK_REALTIME) * * @param[out] tp : where to store current time * @retval 0 (OK), or -1 (ERROR) if clock_id is invalid or tp is NULL. * * @details * This routine gets the current value tp for the clock. * @note ****************************************************************************** */ extern int clock_gettime(int clock_id, struct timespec * tp ) { uint32_t diffTicks; /* system clock tick count */ clockLibInit(); if (clock_id != CLOCK_REALTIME) { return (ERROR); } if (tp == NULL) { return (ERROR); } diffTicks = tickGet() - _clockRealtime.tickBase; TV_CONVERT_TO_SEC(*tp, diffTicks); TV_ADD(*tp, _clockRealtime.timeBase); return (OK); }
extern int32_t clock_gettime ( int32_t clock_id, /* clock ID (always CLOCK_REALTIME) */ struct timespec * tp /* where to store current time */ ) { uint32_t diffTicks; /* system clock tick count */ clockLibInit (); if (clock_id != CLOCK_REALTIME) { return (ERROR); } if (tp == NULL) { return (ERROR); } diffTicks = OSTimeGet() - _clockRealtime.tickBase; TV_CONVERT_TO_SEC(*tp, diffTicks); TV_ADD (*tp, _clockRealtime.timeBase); return (OK); }
int clock_gettime( clockid_t id, struct timespec *tp ) { int ret; u_int64_t diff; if (id != CLOCK_REALTIME) { errnoSet(EINVAL); ret = ERROR; } else { if (tp == NULL) { errnoSet(EINVAL); ret = ERROR; } else { diff = tick64Get() - _clockRealtime.tickBase; TV_CONVERT_TO_SEC(*tp, diff); TV_ADD(*tp, _clockRealtime.timeBase); ret = OK; } } return ret; }