aboutsummaryrefslogtreecommitdiff
path: root/oslib-win32.c
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2010-10-26 10:39:23 +0200
committerBlue Swirl <blauwirbel@gmail.com>2010-10-30 08:02:38 +0000
commitdc786bc9103801fac5b90511b0761255b4eab622 (patch)
treebef5edd2a2c0b3f69d9b57cb129324f038c9c1ac /oslib-win32.c
parent949d31e665e9847b2a8f24a916abd96e79353535 (diff)
Move qemu_gettimeofday() to OS specific files
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'oslib-win32.c')
-rw-r--r--oslib-win32.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/oslib-win32.c b/oslib-win32.c
index 1ddd857942..e03c47294d 100644
--- a/oslib-win32.c
+++ b/oslib-win32.c
@@ -92,3 +92,30 @@ int inet_aton(const char *cp, struct in_addr *ia)
void qemu_set_cloexec(int fd)
{
}
+
+/* mingw32 needs ffs for compilations without optimization. */
+int ffs(int i)
+{
+ /* Use gcc's builtin ffs. */
+ return __builtin_ffs(i);
+}
+
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
+#define _W32_FT_OFFSET (116444736000000000ULL)
+
+int qemu_gettimeofday(qemu_timeval *tp)
+{
+ union {
+ unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
+ FILETIME ft;
+ } _now;
+
+ if(tp) {
+ GetSystemTimeAsFileTime (&_now.ft);
+ tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
+ tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
+ }
+ /* Always return 0 as per Open Group Base Specifications Issue 6.
+ Do not set errno on error. */
+ return 0;
+}