00001 /************************************************************************** 00002 * 00003 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. 00004 * All Rights Reserved. 00005 * 00006 * Permission is hereby granted, free of charge, to any person obtaining a 00007 * copy of this software and associated documentation files (the 00008 * "Software"), to deal in the Software without restriction, including 00009 * without limitation the rights to use, copy, modify, merge, publish, 00010 * distribute, sub license, and/or sell copies of the Software, and to 00011 * permit persons to whom the Software is furnished to do so, subject to 00012 * the following conditions: 00013 * 00014 * The above copyright notice and this permission notice (including the 00015 * next paragraph) shall be included in all copies or substantial portions 00016 * of the Software. 00017 * 00018 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00019 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00020 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 00021 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR 00022 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 00023 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 00024 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00025 * 00026 **************************************************************************/ 00027 00035 #ifndef U_TIME_H_ 00036 #define U_TIME_H_ 00037 00038 00039 #include "pipe/p_config.h" 00040 00041 #if defined(PIPE_OS_LINUX) 00042 #include <time.h> /* timeval */ 00043 #include <unistd.h> /* usleep */ 00044 #endif 00045 00046 #include "pipe/p_compiler.h" 00047 00048 00049 #ifdef __cplusplus 00050 extern "C" { 00051 #endif 00052 00053 00059 struct util_time 00060 { 00061 #if defined(PIPE_OS_LINUX) 00062 struct timeval tv; 00063 #else 00064 int64_t counter; 00065 #endif 00066 }; 00067 00068 00069 void 00070 util_time_get(struct util_time *t); 00071 00072 void 00073 util_time_add(const struct util_time *t1, 00074 int64_t usecs, 00075 struct util_time *t2); 00076 00077 uint64_t 00078 util_time_micros( void ); 00079 00080 int64_t 00081 util_time_diff(const struct util_time *t1, 00082 const struct util_time *t2); 00083 00087 boolean 00088 util_time_timeout(const struct util_time *start, 00089 const struct util_time *end, 00090 const struct util_time *curr); 00091 00092 #if defined(PIPE_OS_LINUX) 00093 #define util_time_sleep usleep 00094 #else 00095 void 00096 util_time_sleep(unsigned usecs); 00097 #endif 00098 00099 00100 #ifdef __cplusplus 00101 } 00102 #endif 00103 00104 #endif /* U_TIME_H_ */