e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
ab6f442011-04-25Martin Stjernholm || $Id$
e576bb2002-10-11Martin Nilsson */
1b10db2002-10-08Martin Nilsson 
026a351996-06-21Fredrik Hübinette (Hubbe) #ifndef TIME_STUFF_H #define TIME_STUFF_H
22549b2006-08-02Martin Stjernholm #include "global.h"
026a351996-06-21Fredrik Hübinette (Hubbe)  #if TIME_WITH_SYS_TIME # include <sys/time.h> # include <time.h> #else # if HAVE_SYS_TIME_H # include <sys/time.h> # else # if HAVE_TIME_H # include <time.h> # endif # endif #endif
ab926b2003-04-30Henrik Grubbström (Grubba) #ifdef HAVE_WINSOCK2_H # include <winsock2.h> #elif defined(HAVE_WINSOCK_H)
2043ba1998-02-10Fredrik Hübinette (Hubbe) # include <winsock.h>
bdfb861997-12-22Fredrik Hübinette (Hubbe) #endif
026a351996-06-21Fredrik Hübinette (Hubbe) #undef HAVE_SYS_TIME_H #undef HAVE_TIME_H #undef TIME_WITH_SYS_TIME #define my_timercmp(tvp, cmp, uvp) \
0cdad21996-07-01Fredrik Hübinette (Hubbe)  ( (tvp)->tv_sec == (uvp)->tv_sec ? \ (tvp)->tv_usec cmp (uvp)->tv_usec : \ (tvp)->tv_sec cmp (uvp)->tv_sec )
026a351996-06-21Fredrik Hübinette (Hubbe)  #define my_subtract_timeval(X, Y) \ do { \ struct timeval *_a=(X), *_b=(Y); \ _a->tv_sec -= _b->tv_sec; \
0cdad21996-07-01Fredrik Hübinette (Hubbe)  _a->tv_usec -= _b->tv_usec; \ if(_a->tv_usec < 0) { \ _a->tv_sec--; \ _a->tv_usec+=1000000; \
026a351996-06-21Fredrik Hübinette (Hubbe)  } \ } while(0) #define my_add_timeval(X, Y) \ do { \ struct timeval *_a=(X), *_b=(Y); \ _a->tv_sec += _b->tv_sec; \
0cdad21996-07-01Fredrik Hübinette (Hubbe)  _a->tv_usec += _b->tv_usec; \ if(_a->tv_usec >= 1000000) { \ _a->tv_sec++; \ _a->tv_usec-=1000000; \
026a351996-06-21Fredrik Hübinette (Hubbe)  } \ } while(0)
5e116c2006-06-20Martin Stjernholm /* Note: fdlib.c contains a function local_time_to_utc that converts a * time_t containing local time to a real one (i.e. UTC). It might be * generally useful but is so far slightly MS specific, which is why * it still resides in fdlib.c. (It just needs some more of the usual * HAVE_XYZ configure test hoopla.) */
dfa5b31996-12-05Fredrik Hübinette (Hubbe) #ifndef STRUCT_TIMEVAL_DECLARED #define STRUCT_TIMEVAL_DECLARED #endif
211d6b1996-12-05Fredrik Hübinette (Hubbe)  #ifndef HAVE_STRUCT_TIMEVAL
026a351996-06-21Fredrik Hübinette (Hubbe) struct timeval { long tv_sec; long tv_usec; }; #endif #endif