Add RT_USING_RTC conditional compilation protection in ctimer.c

Analysis: RT_USING_RTC preprocessing is used in 47cd52d ("修复不
使能 RT_USING_DEVICE 时编译报错") to control the reference of
rtdevice.h, as well as the implementation and call of _control_rtc,
but there are some omissions.

Solution: Add RT_USING_RTC preprocessing control to missing
_control_rtc

Signed-off-by: Shicheng Chu <1468559561@qq.com>
Reviewed-by: Chen Wang <unicorn_wang@outlook.com>
This commit is contained in:
Z8MAN8 2024-08-11 12:12:39 +08:00 committed by Rbb666
parent f543160ead
commit 24b0a8174f
1 changed files with 8 additions and 0 deletions

View File

@ -602,9 +602,11 @@ int clock_getres(clockid_t clockid, struct timespec *res)
switch (clockid) switch (clockid)
{ {
#ifdef RT_USING_RTC
case CLOCK_REALTIME: // use RTC case CLOCK_REALTIME: // use RTC
case CLOCK_REALTIME_COARSE: case CLOCK_REALTIME_COARSE:
return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMERES, res); return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMERES, res);
#endif /* RT_USING_RTC */
case CLOCK_MONOTONIC: // use cputimer case CLOCK_MONOTONIC: // use cputimer
case CLOCK_MONOTONIC_COARSE: case CLOCK_MONOTONIC_COARSE:
@ -633,9 +635,11 @@ int clock_gettime(clockid_t clockid, struct timespec *tp)
switch (clockid) switch (clockid)
{ {
#ifdef RT_USING_RTC
case CLOCK_REALTIME: // use RTC case CLOCK_REALTIME: // use RTC
case CLOCK_REALTIME_COARSE: case CLOCK_REALTIME_COARSE:
return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMESPEC, tp); return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMESPEC, tp);
#endif /* RT_USING_RTC */
case CLOCK_MONOTONIC: // use boottime case CLOCK_MONOTONIC: // use boottime
case CLOCK_MONOTONIC_COARSE: case CLOCK_MONOTONIC_COARSE:
@ -675,10 +679,12 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s
switch (clockid) switch (clockid)
{ {
#ifdef RT_USING_RTC
case CLOCK_REALTIME: // use RTC case CLOCK_REALTIME: // use RTC
if (flags & TIMER_ABSTIME) if (flags & TIMER_ABSTIME)
err = _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMESPEC, &ts); err = _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMESPEC, &ts);
break; break;
#endif /* RT_USING_RTC */
case CLOCK_MONOTONIC: // use boottime case CLOCK_MONOTONIC: // use boottime
case CLOCK_PROCESS_CPUTIME_ID: case CLOCK_PROCESS_CPUTIME_ID:
@ -727,8 +733,10 @@ int clock_settime(clockid_t clockid, const struct timespec *tp)
switch (clockid) switch (clockid)
{ {
#ifdef RT_USING_RTC
case CLOCK_REALTIME: case CLOCK_REALTIME:
return _control_rtc(RT_DEVICE_CTRL_RTC_SET_TIMESPEC, (void *)tp); return _control_rtc(RT_DEVICE_CTRL_RTC_SET_TIMESPEC, (void *)tp);
#endif /* RT_USING_RTC */
case CLOCK_REALTIME_COARSE: case CLOCK_REALTIME_COARSE:
case CLOCK_MONOTONIC: case CLOCK_MONOTONIC: