| 718 | RTM_EXPORT(clock_nanosleep); |
| 719 | |
| 720 | int 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 | } |
| 756 | RTM_EXPORT(clock_settime); |
| 757 | |
| 758 | int rt_timespec_to_tick(const struct timespec *time) |
no test coverage detected