00001
00002
00003
00004
00005
00006
00007
00008 #ifndef TIME_STUFF_H
00009 #define TIME_STUFF_H
00010
00011 #ifndef CONFIGURE_TEST
00012 #include "machine.h"
00013 #endif
00014
00015 #if TIME_WITH_SYS_TIME
00016 # include <sys/time.h>
00017 # include <time.h>
00018 #else
00019 # if HAVE_SYS_TIME_H
00020 # include <sys/time.h>
00021 # else
00022 # if HAVE_TIME_H
00023 # include <time.h>
00024 # endif
00025 # endif
00026 #endif
00027
00028 #ifdef HAVE_WINSOCK2_H
00029 # include <winsock2.h>
00030 #elif defined(HAVE_WINSOCK_H)
00031 # include <winsock.h>
00032 #endif
00033
00034 #undef HAVE_SYS_TIME_H
00035 #undef HAVE_TIME_H
00036 #undef TIME_WITH_SYS_TIME
00037
00038 #define my_timercmp(tvp, cmp, uvp) \
00039 ( (tvp)->tv_sec == (uvp)->tv_sec ? \
00040 (tvp)->tv_usec cmp (uvp)->tv_usec : \
00041 (tvp)->tv_sec cmp (uvp)->tv_sec )
00042
00043 #define my_subtract_timeval(X, Y) \
00044 do { \
00045 struct timeval *_a=(X), *_b=(Y); \
00046 _a->tv_sec -= _b->tv_sec; \
00047 _a->tv_usec -= _b->tv_usec; \
00048 if(_a->tv_usec < 0) { \
00049 _a->tv_sec--; \
00050 _a->tv_usec+=1000000; \
00051 } \
00052 } while(0)
00053
00054 #define my_add_timeval(X, Y) \
00055 do { \
00056 struct timeval *_a=(X), *_b=(Y); \
00057 _a->tv_sec += _b->tv_sec; \
00058 _a->tv_usec += _b->tv_usec; \
00059 if(_a->tv_usec >= 1000000) { \
00060 _a->tv_sec++; \
00061 _a->tv_usec-=1000000; \
00062 } \
00063 } while(0)
00064
00065 #ifndef STRUCT_TIMEVAL_DECLARED
00066 #define STRUCT_TIMEVAL_DECLARED
00067 #endif
00068
00069 #ifndef HAVE_STRUCT_TIMEVAL
00070 struct timeval
00071 {
00072 long tv_sec;
00073 long tv_usec;
00074 };
00075 #endif
00076
00077
00078 #endif