summaryrefslogtreecommitdiff
path: root/components/libc
diff options
context:
space:
mode:
authorxqyjlj <[email protected]>2023-07-20 14:17:45 +0800
committerMan, Jianting (Meco) <[email protected]>2023-07-20 09:25:18 -0400
commit5f0328ee4195d523f66734f2e1d4fc87ed03a109 (patch)
tree8211cc007a357da5a4201de52df45f65342b5634 /components/libc
parent0b966bfca0bc369c0f8cc1fdd7ad7155ef4d0384 (diff)
✨ feat(ktime): add RT_USING_KTIME to kconfig build
Diffstat (limited to 'components/libc')
-rw-r--r--components/libc/compilers/common/ctime.c16
-rw-r--r--components/libc/posix/Kconfig3
2 files changed, 11 insertions, 8 deletions
diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c
index 4f3e424f68..bec2d24b4f 100644
--- a/components/libc/compilers/common/ctime.c
+++ b/components/libc/compilers/common/ctime.c
@@ -25,7 +25,6 @@
*/
#include "sys/time.h"
-#include <ktime.h>
#include <rthw.h>
#include <rtthread.h>
#include <sys/errno.h>
@@ -40,6 +39,9 @@
#if defined( RT_USING_RTC ) || defined( RT_USING_CPUTIME)
#include <rtdevice.h>
#endif
+#ifdef RT_USING_KTIME
+#include "ktime.h"
+#endif
#define DBG_TAG "time"
#define DBG_LVL DBG_INFO
@@ -459,7 +461,7 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
}
RTM_EXPORT(settimeofday);
-#ifdef RT_USING_POSIX_DELAY
+#if defined(RT_USING_POSIX_DELAY) && defined(RT_USING_KTIME)
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
{
struct timespec old_ts = {0};
@@ -501,9 +503,9 @@ int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
return 0;
}
RTM_EXPORT(nanosleep);
-#endif /* RT_USING_POSIX_DELAY */
+#endif /* RT_USING_POSIX_DELAY && RT_USING_KTIME */
-#ifdef RT_USING_POSIX_CLOCK
+#if defined(RT_USING_POSIX_CLOCK) && defined(RT_USING_KTIME)
int clock_getres(clockid_t clockid, struct timespec *res)
{
@@ -693,9 +695,9 @@ int rt_timespec_to_tick(const struct timespec *time)
}
RTM_EXPORT(rt_timespec_to_tick);
-#endif /* RT_USING_POSIX_CLOCK */
+#endif /* RT_USING_POSIX_CLOCK && RT_USING_KTIME */
-#ifdef RT_USING_POSIX_TIMER
+#if defined(RT_USING_POSIX_TIMER) && defined(RT_USING_KTIME)
#include <resource_id.h>
@@ -1111,7 +1113,7 @@ int timer_settime(timer_t timerid, int flags, const struct itimerspec *value,
return 0;
}
RTM_EXPORT(timer_settime);
-#endif /* RT_USING_POSIX_TIMER */
+#endif /* RT_USING_POSIX_TIMER && RT_USING_KTIME */
/* timezone */
diff --git a/components/libc/posix/Kconfig b/components/libc/posix/Kconfig
index 148014407a..f8c929b45c 100644
--- a/components/libc/posix/Kconfig
+++ b/components/libc/posix/Kconfig
@@ -47,6 +47,7 @@ if RT_USING_POSIX_FS
endif
config RT_USING_POSIX_DELAY
+ select RT_USING_KTIME
bool "Enable delay APIs, sleep()/usleep()/msleep() etc"
default n
@@ -56,7 +57,7 @@ config RT_USING_POSIX_CLOCK
default n
config RT_USING_POSIX_TIMER
- select RT_USING_TIMER_SOFT
+ select RT_USING_KTIME
select RT_USING_RESOURCE_ID
bool "Enable timer APIs, timer_create()/timer_gettime() etc"
default n