WvStreams
|
00001 // utils.cpp : Defines the entry point for the DLL application. 00002 // 00003 00004 #include "wvwin32-sanitize.h" 00005 00006 #define EPOCHFILETIME (116444736000000000LL) 00007 00008 int gettimeofday(struct timeval *tv, struct timezone *tz) 00009 { 00010 FILETIME ft; 00011 LARGE_INTEGER li; 00012 __int64 t; 00013 static int tzflag; 00014 00015 if (tv) 00016 { 00017 GetSystemTimeAsFileTime(&ft); 00018 li.LowPart = ft.dwLowDateTime; 00019 li.HighPart = ft.dwHighDateTime; 00020 t = li.QuadPart; /* In 100-nanosecond intervals */ 00021 t -= EPOCHFILETIME; /* Offset to the Epoch time */ 00022 t /= 10; /* In microseconds */ 00023 tv->tv_sec = (long)(t / 1000000); 00024 tv->tv_usec = (long)(t % 1000000); 00025 } 00026 00027 #if 0 00028 if (tz) 00029 { 00030 if (!tzflag) 00031 { 00032 _tzset(); 00033 tzflag++; 00034 } 00035 tz->tz_minuteswest = _timezone / 60; 00036 tz->tz_dsttime = _daylight; 00037 } 00038 #endif 00039 return 0; 00040 } 00041 00042 00043 pid_t getpid() 00044 { 00045 return GetCurrentThreadId(); 00046 } 00047 00048 00049 unsigned int sleep(unsigned int secs) 00050 { 00051 Sleep(secs*1000); 00052 return 0; 00053 } 00054 00055 00056 // FIXME: this makes alarms silently fail. They should probably fail more 00057 // nicely, or (better still) actually work... 00058 unsigned int alarm(unsigned int t) 00059 { 00060 return 0; 00061 } 00062 00063 00064 // This is the same as what Python uses, apparently 00065 int fsync(int fd) 00066 { 00067 return _commit(fd); 00068 }