Просмотр исходного кода

Merge pull request #89 from fremouw/master

clock_gettime missing on MacOS
bel2125 10 лет назад
Родитель
Сommit
55fe009f3f
1 измененных файлов с 17 добавлено и 0 удалено
  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>