diff options
Diffstat (limited to 'librt/clock_gettime.c')
| -rw-r--r-- | librt/clock_gettime.c | 34 | 
1 files changed, 32 insertions, 2 deletions
| diff --git a/librt/clock_gettime.c b/librt/clock_gettime.c index e65d39d44..dd1f0c514 100644 --- a/librt/clock_gettime.c +++ b/librt/clock_gettime.c @@ -22,10 +22,30 @@  #include <sys/time.h>  #include "kernel-posix-cpu-timers.h" +#ifdef __VDSO_SUPPORT__ +#include "ldso.h" +#endif + +#if defined(__UCLIBC_USE_TIME64__) +#include "internal/time64_helpers.h" +#endif +#if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64) +#define SYSCALL_GETTIME           \ +  {                               \ +  struct __ts64_struct __ts64;    \ +  retval = INLINE_SYSCALL (clock_gettime64, 2, clock_id, &__ts64); \ +  if (tp) {                       \ +    tp->tv_sec = __ts64.tv_sec;   \ +    tp->tv_nsec = __ts64.tv_nsec; \ +  }                               \ +  break;                          \ +  } +#else  #define SYSCALL_GETTIME \    retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \    break +#endif  /* The REALTIME and MONOTONIC clock are definitely supported in the kernel.  */  #define SYSDEP_GETTIME							      \ @@ -52,9 +72,8 @@ realtime_gettime (struct timespec *tp)    return retval;  } -/* Get current value of CLOCK and store it in TP.  */  int -clock_gettime (clockid_t clock_id, struct timespec *tp) +__libc_clock_gettime (clockid_t clock_id, struct timespec *tp)  {    int retval = -1;  #ifndef HANDLED_REALTIME @@ -85,3 +104,14 @@ clock_gettime (clockid_t clock_id, struct timespec *tp)    return retval;  } + +/* Get current value of CLOCK and store it in TP.  */ +int +clock_gettime (clockid_t clock_id, struct timespec *tp) +{ +#if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_CLOCK_GETTIME) +  return ARCH_VDSO_CLOCK_GETTIME(clock_id, tp); +#else +  return __libc_clock_gettime(clock_id, tp); +#endif +} | 
