From 5c7b16d00bdb536a694e6e31a2e0a1c33cb9dcb9 Mon Sep 17 00:00:00 2001 From: bernard Date: Sun, 15 Oct 2017 22:41:59 +0800 Subject: [libc] Update libc. 1. Add POSIX termios implementation; 2. Add POSIX signals implementation; 3. Add stdio for each libc. --- components/libc/timer/SConscript | 12 ++++++++++++ components/libc/timer/posix_sleep.c | 15 +++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 components/libc/timer/SConscript create mode 100644 components/libc/timer/posix_sleep.c (limited to 'components/libc/timer') diff --git a/components/libc/timer/SConscript b/components/libc/timer/SConscript new file mode 100644 index 0000000000..a01700aa8d --- /dev/null +++ b/components/libc/timer/SConscript @@ -0,0 +1,12 @@ +# RT-Thread building script for component + +from building import * + +cwd = GetCurrentDir() +src = Glob('*.c') + Glob('*.cpp') +CPPPATH = [cwd] + +group = DefineGroup('libc', src, + depend = ['RT_USING_LIBC', 'RT_USING_POSIX_TIMER'], CPPPATH = CPPPATH) + +Return('group') diff --git a/components/libc/timer/posix_sleep.c b/components/libc/timer/posix_sleep.c new file mode 100644 index 0000000000..b4b33722ac --- /dev/null +++ b/components/libc/timer/posix_sleep.c @@ -0,0 +1,15 @@ +#include +#include + +#include + +unsigned int sleep(unsigned int seconds) +{ + rt_tick_t delta_tick; + + delta_tick = rt_tick_get(); + rt_thread_delay(seconds * RT_TICK_PER_SECOND); + delta_tick = rt_tick_get() - delta_tick; + + return seconds - delta_tick/RT_TICK_PER_SECOND; +} -- cgit v1.3.1