diff options
| author | Z8MAN8 <[email protected]> | 2024-08-11 12:12:39 +0800 |
|---|---|---|
| committer | Rbb666 <[email protected]> | 2024-08-11 14:37:36 +0800 |
| commit | 24b0a8174fd4ba1fbbc2510023e3fbc02ecf8de6 (patch) | |
| tree | 2d4860914a60134cf1cd1c16e218b7f74ff80514 /components/libc/compilers/common | |
| parent | f543160ead455096d0f5756ffd8876914dd4abdb (diff) | |
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 <[email protected]>
Reviewed-by: Chen Wang <[email protected]>
Diffstat (limited to 'components/libc/compilers/common')
| -rw-r--r-- | components/libc/compilers/common/ctime.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c index b523c827f9..480fe02a54 100644 --- a/components/libc/compilers/common/ctime.c +++ b/components/libc/compilers/common/ctime.c @@ -602,9 +602,11 @@ int clock_getres(clockid_t clockid, struct timespec *res) switch (clockid) { +#ifdef RT_USING_RTC case CLOCK_REALTIME: // use RTC case CLOCK_REALTIME_COARSE: return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMERES, res); +#endif /* RT_USING_RTC */ case CLOCK_MONOTONIC: // use cputimer case CLOCK_MONOTONIC_COARSE: @@ -633,9 +635,11 @@ int clock_gettime(clockid_t clockid, struct timespec *tp) switch (clockid) { +#ifdef RT_USING_RTC case CLOCK_REALTIME: // use RTC case CLOCK_REALTIME_COARSE: return _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMESPEC, tp); +#endif /* RT_USING_RTC */ case CLOCK_MONOTONIC: // use boottime case CLOCK_MONOTONIC_COARSE: @@ -675,10 +679,12 @@ int clock_nanosleep(clockid_t clockid, int flags, const struct timespec *rqtp, s switch (clockid) { +#ifdef RT_USING_RTC case CLOCK_REALTIME: // use RTC if (flags & TIMER_ABSTIME) err = _control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMESPEC, &ts); break; +#endif /* RT_USING_RTC */ case CLOCK_MONOTONIC: // use boottime case CLOCK_PROCESS_CPUTIME_ID: @@ -727,8 +733,10 @@ int clock_settime(clockid_t clockid, const struct timespec *tp) switch (clockid) { +#ifdef RT_USING_RTC case CLOCK_REALTIME: return _control_rtc(RT_DEVICE_CTRL_RTC_SET_TIMESPEC, (void *)tp); +#endif /* RT_USING_RTC */ case CLOCK_REALTIME_COARSE: case CLOCK_MONOTONIC: |
