2 * clock_gettime() for uClibc
4 * Copyright (C) 2003 by Justus Pendleton <uc@ryoohki.net>
5 * Copyright (C) 2005 by Peter Kjellerstedt <pkj@axis.com>
6 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
8 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
11 #include <sys/syscall.h>
14 #ifdef __VDSO_SUPPORT__
18 #if defined(__UCLIBC_USE_TIME64__) && defined(__NR_clock_gettime64)
19 #include "internal/time64_helpers.h"
21 int __libc_clock_gettime(clockid_t clock_id
, struct timespec
*tp
)
23 struct __ts64_struct __ts64
;
24 int __ret
= INLINE_SYSCALL(clock_gettime64
, 2, clock_id
, &__ts64
);
26 tp
->tv_sec
= __ts64
.tv_sec
;
27 tp
->tv_nsec
= __ts64
.tv_nsec
;
32 #elif defined(__NR_clock_gettime)
33 int __libc_clock_gettime(clockid_t clock_id
, struct timespec
*tp
)
35 return INLINE_SYSCALL(clock_gettime
, 2, clock_id
, tp
);
38 # include <sys/time.h>
40 int __libc_clock_gettime(clockid_t clock_id
, struct timespec
* tp
)
47 /* In Linux, gettimeofday fails only on bad parameter.
48 * We know that here parameter isn't bad.
50 gettimeofday(&tv
, NULL
);
51 TIMEVAL_TO_TIMESPEC(&tv
, tp
);
64 int clock_gettime(clockid_t clock_id
, struct timespec
*tp
)
66 #if defined(__VDSO_SUPPORT__) && defined(ARCH_VDSO_CLOCK_GETTIME)
67 return ARCH_VDSO_CLOCK_GETTIME(clock_id
, tp
);
69 return __libc_clock_gettime(clock_id
, tp
);