]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
* tools/dbus-monitor.c: gettimeofday() is not available
authorRalf Habacker <ralf.habacker@freenet.de>
Sun, 31 Dec 2006 12:20:54 +0000 (12:20 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Sun, 31 Dec 2006 12:20:54 +0000 (12:20 +0000)
on windows so we have to provide our own. It's taken from
lgpl'd kdewin32 package. - Patches from Christian Ehrlicher

ChangeLog
tools/dbus-monitor.c

index fd93c9d6e0d182cd5d379531b3ddee9bf3f29769..5f93608ec724228ca0c57ca1d8b0b3c314a8a476 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-31  Ralf Habacker  <ralf.habacker@freenet.de>
+
+       * tools/dbus-monitor.c: gettimeofday() is not available 
+       on windows so we have to provide our own. It's taken from 
+       lgpl'd kdewin32 package. - Patches from Christian Ehrlicher
+
 2006-12-31  Ralf Habacker  <ralf.habacker@freenet.de>
 
        * dbus/dbus-sysdeps-unix.c: moved _dbus_atomic_inc/dec() 
index eb3da072daf905121898388ccd58f7bdbb81987f..9f7da5b26f378d0b62ad45fcdab4f1e947a43563 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#ifdef DBUS_WIN
+#include <winsock2.h>
+#undef interface
+#else
 #include <sys/time.h>
+#endif
+
 #include <time.h>
 
 #include <signal.h>
 
 #include "dbus-print-message.h"
 
+#ifdef DBUS_WIN
+
+/* gettimeofday is not defined on windows */
+#define DBUS_SECONDS_SINCE_1601 11644473600LL
+#define DBUS_USEC_IN_SEC        1000000LL
+
+static int
+gettimeofday (struct timeval *__p,
+             void *__t)
+{
+  union {
+      unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
+      FILETIME           ft;
+    } now;
+
+  GetSystemTimeAsFileTime (&now.ft);
+  __p->tv_usec = (long) ((now.ns100 / 10LL) % DBUS_USEC_IN_SEC);
+  __p->tv_sec  = (long)(((now.ns100 / 10LL) / DBUS_SECONDS_SINCE_1601) - DBUS_SECONDS_SINCE_1601);
+
+  return 0;
+}
+#endif
+
 static DBusHandlerResult
 monitor_filter_func (DBusConnection     *connection,
                     DBusMessage        *message,