00001 /* 00002 * $Id: gi_time.h,v 1.1.2.2 2004/01/08 05:12:57 jasta Exp $ 00003 * 00004 * Copyright (C) 2003 giFT project (gift.sourceforge.net) 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation; either version 2, or (at your option) any 00009 * later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 */ 00016 00017 #ifndef __GI_TIME_H 00018 #define __GI_TIME_H 00019 00020 /*****************************************************************************/ 00021 00031 /*****************************************************************************/ 00032 00033 #ifdef TIME_WITH_SYS_TIME 00034 # include <time.h> 00035 # include <sys/time.h> 00036 #else /* !TIME_WITH_SYS_TIME */ 00037 # ifdef HAVE_SYS_TIME_H 00038 # include <sys/time.h> 00039 # else 00040 # include <time.h> 00041 # endif 00042 #endif /* TIME_WITH_SYS_TIME */ 00043 00044 /*****************************************************************************/ 00045 00046 EXTERN_C_BEGIN 00047 00048 /*****************************************************************************/ 00049 00054 typedef struct 00055 { 00062 bool active; 00063 00069 double elapsed; 00070 00077 struct timeval start; 00078 } GiStopWatch; 00079 00080 /*****************************************************************************/ 00081 00086 LIBGIFT_EXPORT 00087 void gi_stopwatch_init (GiStopWatch *watch); 00088 00093 LIBGIFT_EXPORT 00094 bool gi_stopwatch_start (GiStopWatch *watch); 00095 00099 LIBGIFT_EXPORT 00100 bool gi_stopwatch_stop (GiStopWatch *watch); 00101 00105 LIBGIFT_EXPORT 00106 void gi_stopwatch_reset (GiStopWatch *watch); 00107 00115 LIBGIFT_EXPORT 00116 double gi_stopwatch_elapsed (GiStopWatch *watch); 00117 00118 /*****************************************************************************/ 00119 00120 #ifndef HAVE_GETTIMEOFDAY 00121 00126 LIBGIFT_EXPORT 00127 int gettimeofday (struct timeval *tv, struct timezone *tz); 00128 #endif /* !HAVE_GETTIMEOFDAY */ 00129 00130 /*****************************************************************************/ 00131 00132 EXTERN_C_END 00133 00134 /*****************************************************************************/ 00135 00136 #endif /* __GI_TIME_H */
1.3.7