From 8c4cdceb200233a374f3b7696f77bc344bcf56ef Mon Sep 17 00:00:00 2001 From: guozhanxin Date: Wed, 13 Oct 2021 16:02:36 +0800 Subject: [PATCH] [fix] armclang cpp11 build error. --- components/cplusplus/cpp11/armclang/thread.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/components/cplusplus/cpp11/armclang/thread.cpp b/components/cplusplus/cpp11/armclang/thread.cpp index f7f0cb4077..46306eceb8 100644 --- a/components/cplusplus/cpp11/armclang/thread.cpp +++ b/components/cplusplus/cpp11/armclang/thread.cpp @@ -73,7 +73,19 @@ extern "C" void __ARM_TPL_thread_yield() extern "C" int __ARM_TPL_thread_nanosleep(const __ARM_TPL_timespec_t *__req, __ARM_TPL_timespec_t *__rem) { - return nanosleep(__req, rem); + rt_tick_t tick; + + tick = __req->tv_sec * RT_TICK_PER_SECOND + (__req->tv_nsec * RT_TICK_PER_SECOND)/ 1000000000; + rt_thread_delay(tick); + + if (__rem) + { + tick = rt_tick_get() - tick; + /* get the passed time */ + __rem->tv_sec = tick/RT_TICK_PER_SECOND; + __rem->tv_nsec = (tick%RT_TICK_PER_SECOND) * (1000000000/RT_TICK_PER_SECOND); + } + return 0; } extern "C" unsigned __ARM_TPL_thread_hw_concurrency()