diff options
| author | Lim-LinYuanbo <[email protected]> | 2021-10-27 11:14:33 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-27 11:14:33 +0800 |
| commit | 078c3c5991e3024664fe7a51878874e02bf107dc (patch) | |
| tree | 1dde9d1e6b32c07d5c803088f3ce6455a520cd04 /components/cplusplus/cpp11/armclang/thread.cpp | |
| parent | 48ffde55a2562d99c627e4f7e24a6a111c5b80e7 (diff) | |
| parent | 31bf735d2159995358315036be1529523ac96d7d (diff) | |
Merge branch 'master' into master
Diffstat (limited to 'components/cplusplus/cpp11/armclang/thread.cpp')
| -rw-r--r-- | components/cplusplus/cpp11/armclang/thread.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
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() |
