00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __SYSINTERF_TIME_H__
00036 #define __SYSINTERF_TIME_H__
00037
00038
00039
00040
00041
00042 struct timeval {
00043 long tv_sec;
00044 long tv_usec;
00045 };
00046
00047
00048
00049
00050 struct timespec {
00051 time_t tv_sec;
00052 long tv_nsec;
00053 };
00054
00055 #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
00056 (ts)->tv_sec = (tv)->tv_sec; \
00057 (ts)->tv_nsec = (tv)->tv_usec * 1000; \
00058 }
00059 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
00060 (tv)->tv_sec = (ts)->tv_sec; \
00061 (tv)->tv_usec = (ts)->tv_nsec / 1000; \
00062 }
00063
00064
00065
00066
00067
00068 struct timezone {
00069 int tz_minuteswest;
00070 int tz_dsttime;
00071 };
00072
00073
00074 #define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
00075 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
00076 #define timercmp(tvp, uvp, cmp) \
00077 (((tvp)->tv_sec == (uvp)->tv_sec) ? \
00078 ((tvp)->tv_usec cmp (uvp)->tv_usec) : \
00079 ((tvp)->tv_sec cmp (uvp)->tv_sec))
00080 #define timeradd(tvp, uvp, vvp) \
00081 do { \
00082 (vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec; \
00083 (vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec; \
00084 if ((vvp)->tv_usec >= 1000000) { \
00085 (vvp)->tv_sec++; \
00086 (vvp)->tv_usec -= 1000000; \
00087 } \
00088 } while ( 0)
00089 #define timersub(tvp, uvp, vvp) \
00090 do { \
00091 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
00092 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
00093 if ((vvp)->tv_usec < 0) { \
00094 (vvp)->tv_sec--; \
00095 (vvp)->tv_usec += 1000000; \
00096 } \
00097 } while ( 0)
00098
00099
00100 #define timespecclear(tsp) (tsp)->tv_sec = (tsp)->tv_nsec = 0
00101 #define timespecisset(tsp) ((tsp)->tv_sec || (tsp)->tv_nsec)
00102 #define timespeccmp(tsp, usp, cmp) \
00103 (((tsp)->tv_sec == (usp)->tv_sec) ? \
00104 ((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
00105 ((tsp)->tv_sec cmp (usp)->tv_sec))
00106 #define timespecadd(tsp, usp, vsp) \
00107 do { \
00108 (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec; \
00109 (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec; \
00110 if ((vsp)->tv_nsec >= 1000000000L) { \
00111 (vsp)->tv_sec++; \
00112 (vsp)->tv_nsec -= 1000000000L; \
00113 } \
00114 } while ( 0)
00115 #define timespecsub(tsp, usp, vsp) \
00116 do { \
00117 (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec; \
00118 (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec; \
00119 if ((vsp)->tv_nsec < 0) { \
00120 (vsp)->tv_sec--; \
00121 (vsp)->tv_nsec += 1000000000L; \
00122 } \
00123 } while ( 0)
00124
00125
00126
00127
00128
00129 #define ITIMER_REAL 0
00130 #define ITIMER_VIRTUAL 1
00131 #define ITIMER_PROF 2
00132
00133 struct itimerval {
00134 struct timeval it_interval;
00135 struct timeval it_value;
00136 };
00137
00138
00139
00140
00141 struct clockinfo {
00142 int hz;
00143 int tick;
00144 int tickadj;
00145 int stathz;
00146 int profhz;
00147 };
00148
00149 #define CLOCK_REALTIME 0
00150 #define CLOCK_VIRTUAL 1
00151 #define CLOCK_PROF 2
00152 #define CLOCK_MONOTONIC 3
00153
00154 #define TIMER_RELTIME 0x0
00155 #define TIMER_ABSTIME 0x1
00156
00157 #endif
00158