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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgomp/] [config/] [posix/] [time.c] - Blame information for rev 849

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 735 jeremybenn
/* Copyright (C) 2005, 2009 Free Software Foundation, Inc.
2
   Contributed by Richard Henderson <rth@redhat.com>.
3
 
4
   This file is part of the GNU OpenMP Library (libgomp).
5
 
6
   Libgomp is free software; you can redistribute it and/or modify it
7
   under the terms of the GNU General Public License as published by
8
   the Free Software Foundation; either version 3, or (at your option)
9
   any later version.
10
 
11
   Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
12
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
14
   more details.
15
 
16
   Under Section 7 of GPL version 3, you are granted additional
17
   permissions described in the GCC Runtime Library Exception, version
18
   3.1, as published by the Free Software Foundation.
19
 
20
   You should have received a copy of the GNU General Public License and
21
   a copy of the GCC Runtime Library Exception along with this program;
22
   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
   <http://www.gnu.org/licenses/>.  */
24
 
25
/* This file contains system specific timer routines.  It is expected that
26
   a system may well want to write special versions of each of these.
27
 
28
   The following implementation uses the most simple POSIX routines.
29
   If present, POSIX 4 clocks should be used instead.  */
30
 
31
#include "libgomp.h"
32
#include <unistd.h>
33
#if TIME_WITH_SYS_TIME
34
# include <sys/time.h>
35
# include <time.h>
36
#else
37
# if HAVE_SYS_TIME_H
38
#  include <sys/time.h>
39
# else
40
#  include <time.h>
41
# endif
42
#endif
43
 
44
 
45
double
46
omp_get_wtime (void)
47
{
48
#ifdef HAVE_CLOCK_GETTIME
49
  struct timespec ts;
50
# ifdef CLOCK_MONOTONIC
51
  if (clock_gettime (CLOCK_MONOTONIC, &ts) < 0)
52
# endif
53
    clock_gettime (CLOCK_REALTIME, &ts);
54
  return ts.tv_sec + ts.tv_nsec / 1e9;
55
#else
56
  struct timeval tv;
57
  gettimeofday (&tv, NULL);
58
  return tv.tv_sec + tv.tv_usec / 1e6;
59
#endif
60
}
61
 
62
double
63
omp_get_wtick (void)
64
{
65
#ifdef HAVE_CLOCK_GETTIME
66
  struct timespec ts;
67
# ifdef CLOCK_MONOTONIC
68
  if (clock_getres (CLOCK_MONOTONIC, &ts) < 0)
69
# endif
70
    clock_getres (CLOCK_REALTIME, &ts);
71
  return ts.tv_sec + ts.tv_nsec / 1e9;
72
#else
73
  return 1.0 / sysconf(_SC_CLK_TCK);
74
#endif
75
}
76
 
77
ialias (omp_get_wtime)
78
ialias (omp_get_wtick)

powered by: WebSVN 2.1.0

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