diff options
| author | bernard <[email protected]> | 2017-10-15 22:41:59 +0800 |
|---|---|---|
| committer | bernard <[email protected]> | 2017-10-15 22:41:59 +0800 |
| commit | 5c7b16d00bdb536a694e6e31a2e0a1c33cb9dcb9 (patch) | |
| tree | 5da5e3404e1241b65e90089c4c370b40130df832 /components/libc/timer | |
| parent | b27c7e482648535760e012cd6f1afef1d800e2d2 (diff) | |
[libc] Update libc.
1. Add POSIX termios implementation;
2. Add POSIX signals implementation;
3. Add stdio for each libc.
Diffstat (limited to 'components/libc/timer')
| -rw-r--r-- | components/libc/timer/SConscript | 12 | ||||
| -rw-r--r-- | components/libc/timer/posix_sleep.c | 15 |
2 files changed, 27 insertions, 0 deletions
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 <stdlib.h> +#include <rtthread.h> + +#include <unistd.h> + +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; +} |
