OSDN Git Service

Last portion of libc_hidden_proto removal.
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / clock_getres.c
1 /*
2  * clock_getres() for uClibc
3  *
4  * Copyright (C) 2005 by Peter Kjellerstedt <pkj@axis.com>
5  * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
6  *
7  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
8  */
9
10 #include <sys/syscall.h>
11 #include <time.h>
12 #include <unistd.h>
13
14 #ifdef __NR_clock_getres
15 _syscall2(int, clock_getres, clockid_t, clock_id, struct timespec*, res)
16 #else
17 /* libc_hidden_proto(sysconf) */
18
19 int clock_getres(clockid_t clock_id, struct timespec* res)
20 {
21         int retval = -1;
22
23         switch (clock_id) {
24                 case CLOCK_REALTIME:
25                         if (res) {
26                                 long clk_tck;
27
28                                 if ((clk_tck = sysconf(_SC_CLK_TCK)) < 0)
29                                         clk_tck = 100;
30                                 res->tv_sec = 0;
31                                 res->tv_nsec = 1000000000 / clk_tck;
32                         }
33                         retval = 0;
34                         break;
35
36                 default:
37                         errno = EINVAL;
38                         break;
39         }
40
41         return retval;
42 }
43 #endif
44 libc_hidden_def(clock_getres)