Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* clock_gettime -- Get the current time from a POSIX clockid_t. Unix version.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
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.
9
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.
14
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/>. */
18
19#include <errno.h>
20#include <stdint.h>
21#include <time.h>
22#include <sys/time.h>
23#include <libc-internal.h>
24#include <ldsodefs.h>
25
26
27static inline int
28realtime_gettime (struct timespec *tp)
29{
30 struct timeval tv;
31 int retval = __gettimeofday (&tv, NULL);
32 if (retval == 0)
33 /* Convert into `timespec'. */
34 TIMEVAL_TO_TIMESPEC (&tv, tp);
35 return retval;
36}
37
38
39/* Get current value of CLOCK and store it in TP. */
40int
41__clock_gettime (clockid_t clock_id, struct timespec *tp)
42{
43 int retval = -1;
44
45 switch (clock_id)
46 {
47 case CLOCK_REALTIME:
48 {
49 struct timeval tv;
50 retval = __gettimeofday (&tv, NULL);
51 if (retval == 0)
52 TIMEVAL_TO_TIMESPEC (&tv, tp);
53 }
54 break;
55
56 default:
57 __set_errno (EINVAL);
58 break;
59 }
60
61 return retval;
62}
63weak_alias (__clock_gettime, clock_gettime)
64libc_hidden_def (__clock_gettime)
65

Warning: That file was not part of the compilation database. It may have many parsing errors.