00001 #include "libu_conf.h"
00002 #ifndef HAVE_GETTIMEOFDAY
00003 #include <u/carpal.h>
00004 #include <u/gettimeofday.h>
00005
00006 #ifdef OS_WIN
00007 #include <time.h>
00008 #include <sys/timeb.h>
00009 int gettimeofday(struct timeval *tv, struct timezone *tz)
00010 {
00011 struct _timeb tb;
00012
00013 dbg_return_if(tv == NULL, -1);
00014
00015
00016 _ftime(&tb);
00017
00018
00019 tv->tv_sec = tb.time;
00020 tv->tv_usec = 1000 * tb.millitm;
00021
00022 if(tz == NULL)
00023 return 0;
00024
00025
00026 tz->tz_minuteswest = tb.timezone;
00027 tz->tz_dsttime = tb.dstflag;
00028
00029 return 0;
00030 }
00031 #else
00032 #warning missing gettimeofday,tv.tv_usec will be always set to zero
00033 int gettimeofday(struct timeval *tv, struct timezone *tzp)
00034 {
00035 if(tzp)
00036 tzp->tz_minuteswest = tzp->tz_dsttime = 0;
00037
00038 tv->tv_sec = time(0);
00039 tv->tv_usec = 0;
00040
00041 return 0;
00042 }
00043 #endif
00044
00045 #else
00046 #include <sys/time.h>
00047 int gettimeofday(struct timeval *tp, struct timezone *tzp);
00048 #endif