Debian Codegraph @

3rdparty/dissection/src/Compiler/elapsed_time.hpp

raw
1 /*! \file elapsed_time.cpp
2 \brief time esurment functions
3 \author Atsushi Suzuki, Laboratoire Jacques-Louis Lions
4 \date Jun. 4th 2013
5 \date Jul. 12th 2015
6 \date Nov. 30th 2016
7 */
8
9 // This file is part of Dissection
10 //
11 // Dissection is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // Linking Dissection statically or dynamically with other modules is making
17 // a combined work based on Disssection. Thus, the terms and conditions of
18 // the GNU General Public License cover the whole combination.
19 //
20 // As a special exception, the copyright holders of Dissection give you
21 // permission to combine Dissection program with free software programs or
22 // libraries that are released under the GNU LGPL and with independent modules
23 // that communicate with Dissection solely through the Dissection-fortran
24 // interface. You may copy and distribute such a system following the terms of
25 // the GNU GPL for Dissection and the licenses of the other code concerned,
26 // provided that you include the source code of that other code when and as
27 // the GNU GPL requires distribution of source code and provided that you do
28 // not modify the Dissection-fortran interface.
29 //
30 // Note that people who make modified versions of Dissection are not obligated
31 // to grant this special exception for their modified versions; it is their
32 // choice whether to do so. The GNU General Public License gives permission to
33 // release a modified version without this exception; this exception also makes
34 // it possible to release a modified version which carries forward this
35 // exception. If you modify the Dissection-fortran interface, this exception
36 // does not apply to your modified version of Dissection, and you must remove
37 // this exception when you distribute your modified version.
38 //
39 // This exception is an additional permission under section 7 of the GNU
40 // General Public License, version 3 ("GPLv3")
41 //
42 // Dissection is distributed in the hope that it will be useful,
43 // but WITHOUT ANY WARRANTY; without even the implied warranty of
44 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45 // GNU General Public License for more details.
46 //
47 // You should have received a copy of the GNU General Public License
48 // along with Dissection. If not, see <http://www.gnu.org/licenses/>.
49 //
50
51 #ifndef _elapsed_time_
52
53 #ifdef CLOCK_GETTIME
54
55 # ifdef _MSC_VER // added by Yann Collette
56 # include <windows.h>
57
58 typedef struct timeval elapsed_t;
59
60 #define COPYTIME(a, b) ((a).tv_sec = (b).tv_sec);\
61 ((a).tv_usec = (b).tv_usec)
62
63 # else // ! _MSC_VER == Linux
64 #include <time.h>
65 typedef struct timespec elapsed_t;
66 #define COPYTIME(a, b) ((a).tv_sec = (b).tv_sec);\
67 ((a).tv_nsec = (b).tv_nsec)
68
69 #endif
70
71 #else /* #ifdef CLOCK_GETTIME */
72
73 # ifdef GETRUSAGE
74 # include <sys/time.h>
75 # include <sys/resource.h>
76 typedef struct rusage elapsed_t;
77
78 #define COPYTIME(a, b) ((a).ru_utime.tv_sec = (b).ru_utime.tv_sec); \
79 ((a).ru_utime.tv_usec = (b).ru_utime.tv_usec); \
80 ((a).ru_stime.tv_sec = (b).ru_stime.tv_sec); \
81 ((a).ru_stime.tv_usec = (b).ru_stime.tv_usec)
82
83 # else /* #ifdef GETTIMEOFDAY */
84
85 #ifdef CLOCK // for NEC SX-ACE
86 #include <time.h>
87 typedef clock_t elapsed_t;
88 #define COPYTIME(a, b) (a = b);
89
90 #else
91
92 #include <sys/time.h>
93 typedef struct timeval elapsed_t;
94
95 #define COPYTIME(a, b) ((a).tv_sec = (b).tv_sec); \
96 ((a).tv_usec = (b).tv_usec)
97
98 # endif /* #ifdef CLOCK */
99 # endif /* #ifdef GETRUSAGE */
100 #endif /* #ifdef CLOCK_GETTIME */
101
102 void get_realtime(elapsed_t *tm);
103 double convert_time(elapsed_t time0, elapsed_t time1);
104 int convert_sec(elapsed_t t);
105 int convert_microsec(elapsed_t t);
106
107 #define _elapsed_time_
108 #endif
109