Revision dc786bc9 oslib-win32.c
b/oslib-win32.c | ||
---|---|---|
92 | 92 |
void qemu_set_cloexec(int fd) |
93 | 93 |
{ |
94 | 94 |
} |
95 |
|
|
96 |
/* mingw32 needs ffs for compilations without optimization. */ |
|
97 |
int ffs(int i) |
|
98 |
{ |
|
99 |
/* Use gcc's builtin ffs. */ |
|
100 |
return __builtin_ffs(i); |
|
101 |
} |
|
102 |
|
|
103 |
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ |
|
104 |
#define _W32_FT_OFFSET (116444736000000000ULL) |
|
105 |
|
|
106 |
int qemu_gettimeofday(qemu_timeval *tp) |
|
107 |
{ |
|
108 |
union { |
|
109 |
unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ |
|
110 |
FILETIME ft; |
|
111 |
} _now; |
|
112 |
|
|
113 |
if(tp) { |
|
114 |
GetSystemTimeAsFileTime (&_now.ft); |
|
115 |
tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); |
|
116 |
tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); |
|
117 |
} |
|
118 |
/* Always return 0 as per Open Group Base Specifications Issue 6. |
|
119 |
Do not set errno on error. */ |
|
120 |
return 0; |
|
121 |
} |
Also available in: Unified diff