Browse Source

gettime fix for mac os.

Maarten Fremouw 10 years ago
parent
commit
9e18e20087
1 changed files with 17 additions and 0 deletions
  1. 17 0
      src/civetweb.c

+ 17 - 0
src/civetweb.c

@@ -82,6 +82,23 @@
 #include <fcntl.h>
 #endif /* !_WIN32_WCE */
 
+#ifdef __MACH__
+
+#define CLOCK_REALTIME 0
+#define CLOCK_MONOTONIC 0
+
+#include <sys/time.h>
+//clock_gettime is not implemented on OSX
+int clock_gettime(int clk_id, struct timespec* t) {
+    struct timeval now;
+    int rv = gettimeofday(&now, NULL);
+    if (rv) return rv;
+    t->tv_sec  = now.tv_sec;
+    t->tv_nsec = now.tv_usec * 1000;
+    return 0;
+}
+#endif
+
 #include <time.h>
 #include <stdlib.h>
 #include <stdarg.h>