diff options
-rw-r--r-- | libgloss/ChangeLog | 6 | ||||
-rw-r--r-- | libgloss/arm/libcfunc.c | 32 | ||||
-rw-r--r-- | libgloss/arm/syscalls.c | 11 |
3 files changed, 47 insertions, 2 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index d445ced78..0b49c1cd1 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,9 @@ +2005-11-30 Shaun Jackman <sjackman@gmail.com> + + * arm/libcfunc.c (clock, sleep, usleep): New functions. + * arm/syscalls.c (_clock): New function. + (_times): Call _clock. + 2005-11-17 Shaun Jackman <sjackman@gmail.com> * libgloss/arm/libcfunc.c (isatty): Call _isatty. GDB now supports diff --git a/libgloss/arm/libcfunc.c b/libgloss/arm/libcfunc.c index f28f527b2..ffad2e7e0 100644 --- a/libgloss/arm/libcfunc.c +++ b/libgloss/arm/libcfunc.c @@ -43,6 +43,13 @@ alarm (unsigned seconds) return 0; } +clock_t _clock(void); +clock_t __attribute__((weak)) +clock(void) +{ + return _clock(); +} + int _isatty(int fildes); int __attribute__((weak)) isatty(int fildes) @@ -51,8 +58,31 @@ isatty(int fildes) } int __attribute__((weak)) -pause (void) +pause(void) { errno = ENOSYS; return -1; } + +#include <sys/types.h> +#include <time.h> + +unsigned __attribute__((weak)) +sleep(unsigned seconds) +{ + clock_t t0 = _clock(); + clock_t dt = seconds * CLOCKS_PER_SEC; + + while (_clock() - t0 < dt); + return 0; +} + +int __attribute__((weak)) +usleep(useconds_t useconds) +{ + clock_t t0 = _clock(); + clock_t dt = useconds / (1000000/CLOCKS_PER_SEC); + + while (_clock() - t0 < dt); + return 0; +} diff --git a/libgloss/arm/syscalls.c b/libgloss/arm/syscalls.c index 2701bb87a..456b68129 100644 --- a/libgloss/arm/syscalls.c +++ b/libgloss/arm/syscalls.c @@ -31,6 +31,7 @@ int _getpid _PARAMS ((int)); int _kill _PARAMS ((int, int)); void _exit _PARAMS ((int)); int _close _PARAMS ((int)); +clock_t _clock _PARAMS ((void)); int _swiclose _PARAMS ((int)); int _open _PARAMS ((const char *, int, ...)); int _swiopen _PARAMS ((const char *, int)); @@ -597,7 +598,7 @@ _gettimeofday (struct timeval * tp, struct timezone * tzp) /* Return a clock that ticks at 100Hz. */ clock_t -_times (struct tms * tp) +_clock (void) { clock_t timeval; @@ -606,6 +607,14 @@ _times (struct tms * tp) #else asm ("swi %a1; mov %0, r0" : "=r" (timeval): "i" (SWI_Clock) : "r0"); #endif + return timeval; +} + +/* Return a clock that ticks at 100Hz. */ +clock_t +_times (struct tms * tp) +{ + clock_t timeval = _clock(); if (tp) { |