1 /* clock_gettime -- Get current time from a POSIX clockid_t. Linux version.
2 Copyright (C) 2003, 2004 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
23 #include "kernel-posix-cpu-timers.h"
26 #define SYSCALL_GETTIME \
27 retval = INLINE_SYSCALL (clock_gettime, 2, clock_id, tp); \
30 /* The REALTIME and MONOTONIC clock are definitely supported in the kernel. */
31 #define SYSDEP_GETTIME \
32 SYSDEP_GETTIME_CPUTIME \
33 case CLOCK_REALTIME: \
34 case CLOCK_MONOTONIC: \
37 /* We handled the REALTIME clock here. */
38 #define HANDLED_REALTIME 1
39 #define HANDLED_CPUTIME 1
41 #define SYSDEP_GETTIME_CPU SYSCALL_GETTIME
42 #define SYSDEP_GETTIME_CPUTIME /* Default catches them too. */
45 realtime_gettime (struct timespec
*tp
)
48 int retval
= gettimeofday (&tv
, NULL
);
50 /* Convert into `timespec'. */
51 TIMEVAL_TO_TIMESPEC (&tv
, tp
);
55 /* Get current value of CLOCK and store it in TP. */
57 clock_gettime (clockid_t clock_id
, struct timespec
*tp
)
60 #ifndef HANDLED_REALTIME
70 #ifndef HANDLED_REALTIME
72 retval
= gettimeofday (&tv
, NULL
);
74 TIMEVAL_TO_TIMESPEC (&tv
, tp
);
79 #ifdef SYSDEP_GETTIME_CPU