Make WvStreams compile with gcc 4.4.
[wvstreams.git] / win32 / utils.cc
blobd0ed911b965fd0523d504464d13344f7b1f9ca98
1 // utils.cpp : Defines the entry point for the DLL application.
2 //
4 #include "wvwin32-sanitize.h"
6 #define EPOCHFILETIME (116444736000000000LL)
8 int gettimeofday(struct timeval *tv, struct timezone *tz)
10 FILETIME ft;
11 LARGE_INTEGER li;
12 __int64 t;
13 static int tzflag;
15 if (tv)
17 GetSystemTimeAsFileTime(&ft);
18 li.LowPart = ft.dwLowDateTime;
19 li.HighPart = ft.dwHighDateTime;
20 t = li.QuadPart; /* In 100-nanosecond intervals */
21 t -= EPOCHFILETIME; /* Offset to the Epoch time */
22 t /= 10; /* In microseconds */
23 tv->tv_sec = (long)(t / 1000000);
24 tv->tv_usec = (long)(t % 1000000);
27 #if 0
28 if (tz)
30 if (!tzflag)
32 _tzset();
33 tzflag++;
35 tz->tz_minuteswest = _timezone / 60;
36 tz->tz_dsttime = _daylight;
38 #endif
39 return 0;
43 pid_t getpid()
45 return GetCurrentThreadId();
49 unsigned int sleep(unsigned int secs)
51 Sleep(secs*1000);
52 return 0;
56 // FIXME: this makes alarms silently fail. They should probably fail more
57 // nicely, or (better still) actually work...
58 unsigned int alarm(unsigned int t)
60 return 0;
64 // This is the same as what Python uses, apparently
65 int fsync(int fd)
67 return _commit(fd);