1 
2    /**-------------------------------------------------------------------**
3     **                               CLooG                               **
4     **-------------------------------------------------------------------**
5     **                               util.c                              **
6     **-------------------------------------------------------------------**
7     **                   First version: January 8th 2014                 **
8     **-------------------------------------------------------------------**/
9 
10 
11 /******************************************************************************
12  *               CLooG : the Chunky Loop Generator (experimental)             *
13  ******************************************************************************
14  *                                                                            *
15  * Copyright (C) 2002-2005 Cedric Bastoul                                     *
16  *                                                                            *
17  * This library is free software; you can redistribute it and/or              *
18  * modify it under the terms of the GNU Lesser General Public                 *
19  * License as published by the Free Software Foundation; either               *
20  * version 2.1 of the License, or (at your option) any later version.         *
21  *                                                                            *
22  * This library is distributed in the hope that it will be useful,            *
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU          *
25  * Lesser General Public License for more details.                            *
26  *                                                                            *
27  * You should have received a copy of the GNU Lesser General Public           *
28  * License along with this library; if not, write to the Free Software        *
29  * Foundation, Inc., 51 Franklin Street, Fifth Floor,                         *
30  * Boston, MA  02110-1301  USA                                                *
31  *                                                                            *
32  * CLooG, the Chunky Loop Generator                                           *
33  * Written by Cedric Bastoul, Cedric.Bastoul@inria.fr                         *
34  *                                                                            *
35  ******************************************************************************/
36 
37 #include <unistd.h>
38 #include <sys/time.h>
39 #include <stdio.h>
40 #include "../include/cloog/cloog.h"
41 
42 /**
43  * cloog_util_rtclock function:
44  * this function returns the value, in seconds, of the real time clock of
45  * the operating system. The reference point between calls is consistent,
46  * making time comparison possible.
47  * \return The real time clock of the operating system in seconds.
48  */
cloog_util_rtclock()49 double cloog_util_rtclock() {
50   struct timezone Tzp;
51   struct timeval Tp;
52   int stat = gettimeofday(&Tp, &Tzp);
53   if (stat != 0)
54     cloog_msg(NULL, CLOOG_WARNING, "Error return from gettimeofday: %d", stat);
55   return (Tp.tv_sec + Tp.tv_usec*1.0e-6);
56 }
57