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

Function clock_settime

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

Source from the content-addressed store, hash-verified

718RTM_EXPORT(clock_nanosleep);
719
720int clock_settime(clockid_t clockid, const struct timespec *tp)
721{
722 if (tp == RT_NULL)
723 {
724 rt_set_errno(EFAULT);
725 return -1;
726 }
727
728 if (tp->tv_sec < 0 || tp->tv_nsec < 0 || tp->tv_nsec >= NANOSECOND_PER_SECOND)
729 {
730 rt_set_errno(EINVAL);
731 return -1;
732 }
733
734 switch (clockid)
735 {
736#ifdef RT_USING_RTC
737 case CLOCK_REALTIME:
738 return _control_rtc(RT_DEVICE_CTRL_RTC_SET_TIMESPEC, (void *)tp);
739#endif /* RT_USING_RTC */
740
741 case CLOCK_REALTIME_COARSE:
742 case CLOCK_MONOTONIC:
743 case CLOCK_MONOTONIC_COARSE:
744 case CLOCK_MONOTONIC_RAW:
745 case CLOCK_BOOTTIME:
746 case CLOCK_PROCESS_CPUTIME_ID:
747 case CLOCK_THREAD_CPUTIME_ID:
748 rt_set_errno(EPERM);
749 return -1;
750
751 default:
752 rt_set_errno(EINVAL);
753 return -1;
754 }
755}
756RTM_EXPORT(clock_settime);
757
758int rt_timespec_to_tick(const struct timespec *time)

Callers 1

sys_clock_settimeFunction · 0.85

Calls 2

rt_set_errnoFunction · 0.85
_control_rtcFunction · 0.85

Tested by

no test coverage detected