Go to the source code of this file.
Functions | |
void | util_time_get (struct util_time *t) |
void | util_time_add (const struct util_time *t1, int64_t usecs, struct util_time *t2) |
int64_t | util_time_diff (const struct util_time *t1, const struct util_time *t2) |
uint64_t | util_time_micros (void) |
static int | util_time_compare (const struct util_time *t1, const struct util_time *t2) |
Compare two time values. | |
boolean | util_time_timeout (const struct util_time *start, const struct util_time *end, const struct util_time *curr) |
Returns non-zero when the timeout expires. |
Definition in file u_time.c.
Definition at line 101 of file u_time.c.
References util_time::counter.
00104 { 00105 #if defined(PIPE_OS_LINUX) 00106 t2->tv.tv_sec = t1->tv.tv_sec + usecs / 1000000; 00107 t2->tv.tv_usec = t1->tv.tv_usec + usecs % 1000000; 00108 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) 00109 util_time_get_frequency(); 00110 t2->counter = t1->counter + (usecs * frequency + INT64_C(999999))/INT64_C(1000000); 00111 #elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) 00112 /* 1 tick = 100 nano seconds. */ 00113 t2->counter = t1->counter + usecs * 10; 00114 #else 00115 LARGE_INTEGER temp; 00116 LONGLONG freq; 00117 freq = temp.QuadPart; 00118 t2->counter = t1->counter + (usecs * freq)/1000000L; 00119 #endif 00120 }
Compare two time values.
Not publicly available because it does not take in account wrap-arounds. Use util_time_timeout instead.
Definition at line 166 of file u_time.c.
References util_time::counter.
00168 { 00169 #if defined(PIPE_OS_LINUX) 00170 if (t1->tv.tv_sec < t2->tv.tv_sec) 00171 return -1; 00172 else if(t1->tv.tv_sec > t2->tv.tv_sec) 00173 return 1; 00174 else if (t1->tv.tv_usec < t2->tv.tv_usec) 00175 return -1; 00176 else if(t1->tv.tv_usec > t2->tv.tv_usec) 00177 return 1; 00178 else 00179 return 0; 00180 #elif defined(PIPE_OS_WINDOWS) 00181 if (t1->counter < t2->counter) 00182 return -1; 00183 else if(t1->counter > t2->counter) 00184 return 1; 00185 else 00186 return 0; 00187 #endif 00188 }
Definition at line 124 of file u_time.c.
References util_time::counter.
00126 { 00127 #if defined(PIPE_OS_LINUX) 00128 return (t2->tv.tv_usec - t1->tv.tv_usec) + 00129 (t2->tv.tv_sec - t1->tv.tv_sec)*1000000; 00130 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) 00131 util_time_get_frequency(); 00132 return (t2->counter - t1->counter)*INT64_C(1000000)/frequency; 00133 #elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) 00134 return (t2->counter - t1->counter)/10; 00135 #endif 00136 }
void util_time_get | ( | struct util_time * | t | ) |
Definition at line 78 of file u_time.c.
References util_time::counter.
00079 { 00080 #if defined(PIPE_OS_LINUX) 00081 gettimeofday(&t->tv, NULL); 00082 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) 00083 LONGLONG temp; 00084 EngQueryPerformanceCounter(&temp); 00085 t->counter = temp; 00086 #elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) 00087 /* Updated every 10 miliseconds, measured in units of 100 nanoseconds. 00088 * http://msdn.microsoft.com/en-us/library/ms801642.aspx */ 00089 LARGE_INTEGER temp; 00090 KeQuerySystemTime(&temp); 00091 t->counter = temp.QuadPart; 00092 #elif defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) 00093 LARGE_INTEGER temp; 00094 QueryPerformanceCounter(&temp); 00095 t->counter = temp.QuadPart; 00096 #endif 00097 }
uint64_t util_time_micros | ( | void | ) |
Definition at line 141 of file u_time.c.
References util_time::counter, and util_time_get().
00142 { 00143 struct util_time t1; 00144 00145 util_time_get(&t1); 00146 00147 #if defined(PIPE_OS_LINUX) 00148 return t1.tv.tv_usec + t1.tv.tv_sec*1000000LL; 00149 #elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || defined(PIPE_SUBSYSTEM_WINDOWS_USER) || defined(PIPE_SUBSYSTEM_WINDOWS_CE) 00150 util_time_get_frequency(); 00151 return t1.counter*INT64_C(1000000)/frequency; 00152 #elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT) 00153 return t1.counter/10; 00154 #endif 00155 }
boolean util_time_timeout | ( | const struct util_time * | start, | |
const struct util_time * | end, | |||
const struct util_time * | curr | |||
) |
Returns non-zero when the timeout expires.
Definition at line 192 of file u_time.c.
References util_time_compare().
00195 { 00196 if(util_time_compare(start, end) <= 0) 00197 return !(util_time_compare(start, curr) <= 0 && util_time_compare(curr, end) < 0); 00198 else 00199 return !(util_time_compare(start, curr) <= 0 || util_time_compare(curr, end) < 0); 00200 }