Esempio n. 1
0
/**
 ******************************************************************************
 * @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);
}
Esempio n. 2
0
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);
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
PRIVATE void get_prof_time(struct timeval *tvp)
{
#if defined( ITIMER_PROF ) && ! defined( NO_ITIMER_PROF )
   struct rusage ru ;

   (void) getrusage( RUSAGE_SELF, &ru ) ;
   TV_ADD( *tvp, ru.ru_utime, ru.ru_stime ) ;
#endif
}