root/opal/win32/opal_time.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  *Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                        University Research and Technology
   4  *                        Corporation.  All rights reserved.
   5  *Copyright (c) 2004-2014 The University of Tennessee and The University
   6  *                        of Tennessee Research Foundation.  All rights
   7  *                        reserved.
   8  *Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                        University of Stuttgart.  All rights reserved.
  10  *Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                        All rights reserved.
  12  *$COPYRIGHT$
  13  *
  14  *Additional copyrights may follow
  15  *
  16  *$HEADER$
  17  */
  18 
  19 #ifndef OPAL_TIME_H
  20 #define OPAL_TIME_H
  21 
  22 #include "opal_config.h"
  23 
  24 #ifndef OPAL_WIN_COMPAT_H
  25 #error This file is supposed to be included only from win_compat.h
  26 #endif  /* OPAL_WIN_COMPAT_H */
  27 
  28 #define DST_NONE    0   /* not on dst */
  29 #define DST_USA     1   /* USA style dst */
  30 #define DST_AUST    2   /* Australian style dst */
  31 #define DST_WET     3   /* Western European dst */
  32 #define DST_MET     4   /* Middle European dst */
  33 #define DST_EET     5   /* Eastern European dst */
  34 #define DST_CAN     6   /* Canada */
  35 
  36 #define TIMEVAL_TO_TIMESPEC(tv, ts) \
  37 (ts)->tv_sec = (tv)->tv_sec;    \
  38 (ts)->tv_nsec = (tv)->tv_usec * 1000;
  39 
  40 #define TIMESPEC_TO_TIMEVAL(tv, ts) \
  41 (tv)->tv_sec = (ts)->tv_sec;  \
  42 (tv)->tv_usec = (ts)->tv_nsec / 1000;
  43 
  44 
  45 /* some more utility functions */
  46 /* Operations on timevals. */
  47 #ifndef timerclear
  48 #define timerclear(tvp)     (tvp)->tv_sec = (tvp)->tv_usec = 0
  49 #endif
  50 
  51 #ifndef timerisset
  52 #define timerisset(tvp)     ((tvp)->tv_sec || (tvp)->tv_usec)
  53 #endif
  54 
  55 #ifndef timercmp
  56 #define timercmp(tvp, uvp, cmp)                     \
  57     (((tvp)->tv_sec == (uvp)->tv_sec) ?             \
  58     ((tvp)->tv_usec cmp (uvp)->tv_usec) :           \
  59     ((tvp)->tv_sec cmp (uvp)->tv_sec))
  60 #endif
  61 
  62 #ifndef timeradd
  63 #define timeradd(tvp, uvp, vvp)                     \
  64     do {                                \
  65     (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;      \
  66     (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;   \
  67     if ((vvp)->tv_usec >= 1000000) {            \
  68         (vvp)->tv_sec++;                \
  69         (vvp)->tv_usec -= 1000000;          \
  70         }                           \
  71     } while (0)
  72 #endif
  73 
  74 #ifndef timersub
  75 #define timersub(tvp, uvp, vvp)                     \
  76     do {                                \
  77     (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;      \
  78     (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;   \
  79     if ((vvp)->tv_usec < 0) {               \
  80     (vvp)->tv_sec--;                \
  81     (vvp)->tv_usec += 1000000;          \
  82     }                           \
  83     } while (0)
  84 #endif
  85 
  86 /* Operations on timespecs. */
  87 
  88 #ifndef timespecclear
  89 #define timespecclear(tsp)      (tsp)->tv_sec = (tsp)->tv_nsec = 0
  90 #endif
  91 
  92 #ifndef timespecisset
  93 #define timespecisset(tsp)      ((tsp)->tv_sec || (tsp)->tv_nsec)
  94 #endif
  95 
  96 #ifndef timespeccmp
  97 #define timespeccmp(tsp, usp, cmp)                  \
  98     (((tsp)->tv_sec == (usp)->tv_sec) ?             \
  99     ((tsp)->tv_nsec cmp (usp)->tv_nsec) :           \
 100     ((tsp)->tv_sec cmp (usp)->tv_sec))
 101 #endif
 102 
 103 #ifndef timespecadd
 104 #define timespecadd(tsp, usp, vsp)                  \
 105     do {                                \
 106     (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;      \
 107     (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;   \
 108     if ((vsp)->tv_nsec >= 1000000000L) {            \
 109     (vsp)->tv_sec++;                \
 110     (vsp)->tv_nsec -= 1000000000L;          \
 111     }                           \
 112     } while (0)
 113 #endif
 114 
 115 #ifndef timespecsub
 116 #define timespecsub(tsp, usp, vsp)                  \
 117     do {                                \
 118     (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;      \
 119     (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;   \
 120     if ((vsp)->tv_nsec < 0) {               \
 121     (vsp)->tv_sec--;                \
 122     (vsp)->tv_nsec += 1000000000L;          \
 123     }                           \
 124     } while (0)
 125 #endif
 126 
 127 /*
 128  * Names of the interval timers, and structure
 129   * defining a timer setting.
 130    */
 131 #define ITIMER_REAL 0
 132 #define ITIMER_VIRTUAL  1
 133 #define ITIMER_PROF 2
 134 
 135 struct itimerval {
 136   struct  timeval it_interval;    /* timer interval */
 137   struct  timeval it_value;   /* current value */
 138 };
 139 
 140 /*
 141  * Getkerninfo clock information structure
 142  */
 143 struct clockinfo {
 144    int hz;     /* clock frequency */
 145    int tick;       /* micro-seconds per hz tick */
 146    int tickadj;    /* clock skew rate for adjtime() */
 147    int stathz;     /* statistics clock frequency */
 148    int profhz;     /* profiling clock frequency */
 149 };
 150 
 151 #define CLOCK_REALTIME  0
 152 #define CLOCK_VIRTUAL   1
 153 #define CLOCK_PROF  2
 154 
 155 #define TIMER_RELTIME   0x0 /* relative timer */
 156 #define TIMER_ABSTIME   0x1 /* absolute timer */
 157 
 158 #ifndef OPAL_TIMESPEC
 159 #define OPAL_TIMESPEC
 160 struct timespec
 161 {
 162   long tv_sec;
 163   long tv_nsec;
 164 };
 165 #endif
 166 
 167 
 168 /*
 169 NOTE: The use of timezone is obsolete even in linux and my gettimeofday
 170 function is not going to support it either. So, please be aware of the
 171 fact that if you expect to pass anything here, then you are DEAD :-D */
 172 struct timezone
 173 {
 174   int tz_minuteswest;
 175   int tz_dsttime;
 176 };
 177 
 178 BEGIN_C_DECLS
 179 
 180 OPAL_DECLSPEC int gettimeofday (struct timeval *tv, struct timezone *tz);
 181 
 182 END_C_DECLS
 183 
 184 #endif  /* OPAL_TIME_H */

/* [<][>][^][v][top][bottom][index][help] */