2004-10-14 00:21:07 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
*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.
|
2004-11-28 23:09:25 +03:00
|
|
|
*Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
*Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
*$COPYRIGHT$
|
|
|
|
*
|
|
|
|
*Additional copyrights may follow
|
|
|
|
*
|
2004-11-22 03:37:56 +03:00
|
|
|
*$HEADER$
|
|
|
|
*/
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
#ifndef OMPI_TIME_H
|
|
|
|
#define OMPI_TIME_H
|
2005-12-31 15:23:28 +03:00
|
|
|
|
2009-03-17 04:45:19 +03:00
|
|
|
#include "opal_config.h"
|
|
|
|
|
2005-12-31 15:23:28 +03:00
|
|
|
#ifndef OMPI_WIN_COMPAT_H
|
|
|
|
#error This file is supposed to be included only from win_compat.h
|
|
|
|
#endif /* OMPI_WIN_COMPAT_H */
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
#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;
|
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
|
2004-10-14 00:21:07 +04:00
|
|
|
(tv)->tv_sec = (ts)->tv_sec; \
|
|
|
|
(tv)->tv_usec = (ts)->tv_nsec / 1000;
|
|
|
|
|
|
|
|
|
|
|
|
/* some more utility functions */
|
|
|
|
/* Operations on timevals. */
|
2004-10-22 20:06:05 +04:00
|
|
|
#ifndef timerclear
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef timerisset
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef timercmp
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timercmp(tvp, uvp, cmp) \
|
2004-10-22 20:06:05 +04:00
|
|
|
(((tvp)->tv_sec == (uvp)->tv_sec) ? \
|
|
|
|
((tvp)->tv_usec cmp (uvp)->tv_usec) : \
|
|
|
|
((tvp)->tv_sec cmp (uvp)->tv_sec))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef timeradd
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timeradd(tvp, uvp, vvp) \
|
2004-10-22 20:06:05 +04:00
|
|
|
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
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timersub(tvp, uvp, vvp) \
|
2004-10-22 20:06:05 +04:00
|
|
|
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
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
/* Operations on timespecs. */
|
2004-10-22 20:06:05 +04:00
|
|
|
|
|
|
|
#ifndef timespecclear
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef timespecisset
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
|
2004-10-22 20:06:05 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef timespeccmp
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timespeccmp(tsp, usp, cmp) \
|
2004-10-22 20:06:05 +04:00
|
|
|
(((tsp)->tv_sec == (usp)->tv_sec) ? \
|
|
|
|
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
|
|
|
|
((tsp)->tv_sec cmp (usp)->tv_sec))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef timespecadd
|
2004-10-14 00:21:07 +04:00
|
|
|
#define timespecadd(tsp, usp, vsp) \
|
2004-10-22 20:06:05 +04:00
|
|
|
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
|
2004-10-14 00:21:07 +04:00
|
|
|
|
2004-10-22 20:06:05 +04:00
|
|
|
#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
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Names of the interval timers, and structure
|
|
|
|
* defining a timer setting.
|
|
|
|
*/
|
|
|
|
#define ITIMER_REAL 0
|
|
|
|
#define ITIMER_VIRTUAL 1
|
|
|
|
#define ITIMER_PROF 2
|
|
|
|
|
2006-01-26 14:55:00 +03:00
|
|
|
struct itimerval {
|
2004-10-14 00:21:07 +04:00
|
|
|
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 */
|
|
|
|
|
2011-04-29 18:42:07 +04:00
|
|
|
#ifndef OMPI_TIMESPEC
|
|
|
|
#define OMPI_TIMESPEC
|
2004-10-14 00:21:07 +04:00
|
|
|
struct timespec
|
|
|
|
{
|
|
|
|
long tv_sec;
|
|
|
|
long tv_nsec;
|
|
|
|
};
|
2011-04-29 18:42:07 +04:00
|
|
|
#endif
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
2009-08-20 15:42:18 +04:00
|
|
|
BEGIN_C_DECLS
|
2004-10-14 00:21:07 +04:00
|
|
|
|
2006-08-20 19:54:04 +04:00
|
|
|
OPAL_DECLSPEC int gettimeofday (struct timeval *tv, struct timezone *tz);
|
2004-10-14 00:21:07 +04:00
|
|
|
|
2009-08-20 15:42:18 +04:00
|
|
|
END_C_DECLS
|
2004-10-14 00:21:07 +04:00
|
|
|
|
|
|
|
#endif /* OMPI_TIME_H */
|