OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [uClibc/] [libc/] [misc/] [time/] [clock_gettime.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1325 phoenix
/*  Copyright (C) 2003     Justus Pendleton     <uc@ryoohki.net>
2
 *
3
 *  This library is free software; you can redistribute it and/or
4
 *  modify it under the terms of the GNU Library General Public
5
 *  License as published by the Free Software Foundation; either
6
 *  version 2 of the License, or (at your option) any later version.
7
 *
8
 *  This library is distributed in the hope that it will be useful,
9
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11
 *  Library General Public License for more details.
12
 *
13
 *  You should have received a copy of the GNU Library General Public
14
 *  License along with this library; if not, write to the Free
15
 *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
17
 
18
#define _GNU_SOURCE
19
#include <time.h>
20
#include <errno.h>
21
#include <sys/time.h>
22
 
23
int clock_gettime (clockid_t clock, struct timespec* ts)
24
{
25
        struct timeval tv;
26
        int retval = -1;
27
        switch (clock) {
28
                case CLOCK_REALTIME:
29
                        retval = gettimeofday (&tv, NULL);
30
                        if (retval == 0) {
31
                                TIMEVAL_TO_TIMESPEC (&tv, ts);
32
                        }
33
                        break;
34
                default:
35
                        errno = EINVAL;
36
                        break;
37
        }
38
        return retval;
39
}
40
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.