ref: 2cb57c6e7188a8438c58e1e3fc452b7ad06bee33
parent: 505751a54e61abbe98a2081930dfe09915626cf2
author: Tor Andersson <[email protected]>
date: Mon Dec 11 09:15:01 EST 2017
Fix issue #56: MacOS X not detected as a Unix for gettimeofday(). Add ifdef check for __APPLE__ since MacOS X doesn't define __unix__.
--- a/jsdate.c
+++ b/jsdate.c
@@ -4,7 +4,7 @@
#include <time.h>
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
#include <sys/time.h>
#elif defined(_WIN32)
#include <sys/timeb.h>
@@ -14,7 +14,7 @@
static double Now(void)
{
-#if defined(__unix__)
+#if defined(__unix__) || defined(__APPLE__)
struct timeval tv;
gettimeofday(&tv, NULL);
return floor(tv.tv_sec * 1000.0 + tv.tv_usec / 1000.0);