MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / clock_getres

Function clock_getres

components/libc/compilers/common/ctime.c:595–625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

593#if defined(RT_USING_POSIX_CLOCK) && defined(RT_USING_KTIME)
594
595int clock_getres(clockid_t clockid, struct timespec *res)
596{
597 if (res == RT_NULL)
598 {
599 rt_set_errno(EFAULT);
600 return -1;
601 }
602
603 switch (clockid)
604 {
605 case CLOCK_REALTIME: // use RTC
606 case CLOCK_REALTIME_COARSE:
607#ifdef RT_USING_RTC
608 return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMERES, res);
609#endif /* RT_USING_RTC */
610
611 case CLOCK_MONOTONIC: // use cputimer
612 case CLOCK_MONOTONIC_COARSE:
613 case CLOCK_MONOTONIC_RAW:
614 case CLOCK_BOOTTIME:
615 case CLOCK_PROCESS_CPUTIME_ID:
616 case CLOCK_THREAD_CPUTIME_ID:
617 res->tv_sec = 0;
618 res->tv_nsec = (rt_ktime_cputimer_getres() / RT_KTIME_RESMUL);
619 return 0;
620
621 default:
622 rt_set_errno(EINVAL);
623 return -1;
624 }
625}
626RTM_EXPORT(clock_getres);
627
628int clock_gettime(clockid_t clockid, struct timespec *tp)

Callers 1

sys_clock_getresFunction · 0.85

Calls 3

rt_set_errnoFunction · 0.85
_control_rtcFunction · 0.85
rt_ktime_cputimer_getresFunction · 0.50

Tested by

no test coverage detected