File: ompi_time.h

package info (click to toggle)
openmpi 1.6.5-9.1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 91,628 kB
  • ctags: 44,305
  • sloc: ansic: 408,966; cpp: 44,454; sh: 27,828; makefile: 10,486; asm: 3,882; python: 1,239; lex: 805; perl: 549; csh: 253; fortran: 232; f90: 126; tcl: 12
file content (184 lines) | stat: -rw-r--r-- 5,365 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
 *Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
 *                        University Research and Technology
 *                        Corporation.  All rights reserved.
 *Copyright (c) 2004-2005 The University of Tennessee and The University
 *                        of Tennessee Research Foundation.  All rights
 *                        reserved.
 *Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 
 *                        University of Stuttgart.  All rights reserved.
 *Copyright (c) 2004-2005 The Regents of the University of California.
 *                        All rights reserved.
 *$COPYRIGHT$
 *
 *Additional copyrights may follow
 *
 *$HEADER$
 */

#ifndef OMPI_TIME_H
#define OMPI_TIME_H

#include "opal_config.h"

#ifndef OMPI_WIN_COMPAT_H
#error This file is supposed to be included only from win_compat.h
#endif  /* OMPI_WIN_COMPAT_H */

#define DST_NONE    0   /* not on dst */
#define DST_USA     1   /* USA style dst */
#define DST_AUST    2   /* Australian style dst */
#define DST_WET     3   /* Western European dst */
#define DST_MET     4   /* Middle European dst */
#define DST_EET     5   /* Eastern European dst */
#define DST_CAN     6   /* Canada */

#define TIMEVAL_TO_TIMESPEC(tv, ts) \
(ts)->tv_sec = (tv)->tv_sec;    \
(ts)->tv_nsec = (tv)->tv_usec * 1000;

#define TIMESPEC_TO_TIMEVAL(tv, ts) \
(tv)->tv_sec = (ts)->tv_sec;  \
(tv)->tv_usec = (ts)->tv_nsec / 1000;


/* some more utility functions */
/* Operations on timevals. */
#ifndef timerclear
#define timerclear(tvp)     (tvp)->tv_sec = (tvp)->tv_usec = 0
#endif

#ifndef timerisset
#define timerisset(tvp)     ((tvp)->tv_sec || (tvp)->tv_usec)
#endif

#ifndef timercmp
#define timercmp(tvp, uvp, cmp)                     \
    (((tvp)->tv_sec == (uvp)->tv_sec) ?             \
    ((tvp)->tv_usec cmp (uvp)->tv_usec) :           \
    ((tvp)->tv_sec cmp (uvp)->tv_sec))
#endif

#ifndef timeradd
#define timeradd(tvp, uvp, vvp)                     \
    do {                                \
    (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;      \
    (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;   \
    if ((vvp)->tv_usec >= 1000000) {            \
        (vvp)->tv_sec++;                \
        (vvp)->tv_usec -= 1000000;          \
        }                           \
    } while (0)
#endif
    
#ifndef timersub
#define timersub(tvp, uvp, vvp)                     \
    do {                                \
    (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;      \
    (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;   \
    if ((vvp)->tv_usec < 0) {               \
    (vvp)->tv_sec--;                \
    (vvp)->tv_usec += 1000000;          \
    }                           \
    } while (0)
#endif

/* Operations on timespecs. */

#ifndef timespecclear
#define timespecclear(tsp)      (tsp)->tv_sec = (tsp)->tv_nsec = 0
#endif

#ifndef timespecisset
#define timespecisset(tsp)      ((tsp)->tv_sec || (tsp)->tv_nsec)
#endif

#ifndef timespeccmp
#define timespeccmp(tsp, usp, cmp)                  \
    (((tsp)->tv_sec == (usp)->tv_sec) ?             \
    ((tsp)->tv_nsec cmp (usp)->tv_nsec) :           \
    ((tsp)->tv_sec cmp (usp)->tv_sec))
#endif

#ifndef timespecadd
#define timespecadd(tsp, usp, vsp)                  \
    do {                                \
    (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;      \
    (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;   \
    if ((vsp)->tv_nsec >= 1000000000L) {            \
    (vsp)->tv_sec++;                \
    (vsp)->tv_nsec -= 1000000000L;          \
    }                           \
    } while (0)
#endif

#ifndef timespecsub
#define timespecsub(tsp, usp, vsp)                  \
    do {                                \
    (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;      \
    (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;   \
    if ((vsp)->tv_nsec < 0) {               \
    (vsp)->tv_sec--;                \
    (vsp)->tv_nsec += 1000000000L;          \
    }                           \
    } while (0)
#endif

/*
 * Names of the interval timers, and structure
  * defining a timer setting.
   */
#define ITIMER_REAL 0
#define ITIMER_VIRTUAL  1
#define ITIMER_PROF 2

struct itimerval {
  struct  timeval it_interval;    /* timer interval */
  struct  timeval it_value;   /* current value */
};

/*
 * Getkerninfo clock information structure
 */
struct clockinfo {
   int hz;     /* clock frequency */
   int tick;       /* micro-seconds per hz tick */
   int tickadj;    /* clock skew rate for adjtime() */
   int stathz;     /* statistics clock frequency */
   int profhz;     /* profiling clock frequency */
};

#define CLOCK_REALTIME  0
#define CLOCK_VIRTUAL   1
#define CLOCK_PROF  2

#define TIMER_RELTIME   0x0 /* relative timer */
#define TIMER_ABSTIME   0x1 /* absolute timer */

#ifndef OMPI_TIMESPEC
#define OMPI_TIMESPEC
struct timespec
{
  long tv_sec;
  long tv_nsec;
};
#endif


/*
NOTE: The use of timezone is obsolete even in linux and my gettimeofday
function is not going to support it either. So, please be aware of the 
fact that if you expect to pass anything here, then you are DEAD :-D */
struct timezone
{
  int tz_minuteswest;
  int tz_dsttime;
};

BEGIN_C_DECLS

OPAL_DECLSPEC int gettimeofday (struct timeval *tv, struct timezone *tz);

END_C_DECLS

#endif				/* OMPI_TIME_H */