From 43ce4f61352d6fcd5af4ed9ea22226052ed2f111 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Tue, 26 Dec 2017 14:09:30 +0100 Subject: [PATCH] Add checks for clock_gettime() support in Makefile --- include/timer.h | 2 +- src/Makefile | 6 ++++++ src/timer.c | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/timer.h b/include/timer.h index 7129303e8..63a23db30 100644 --- a/include/timer.h +++ b/include/timer.h @@ -6,7 +6,7 @@ #ifndef _TIMER_H #define _TIMER_H -#if defined(__APPLE__) +#if defined(__APPLE__) && defined(MISSING_CLOCK_GETTIME) #include #include #include diff --git a/src/Makefile b/src/Makefile index 5a2ff193c..ae491b6f5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -92,6 +92,7 @@ ifeq ($(UNAME),Darwin) CC := clang # the sed -i option of macOS requires a parameter for the backup file (we just use "") SED_IN_PLACE := -i "" +PROD_VERS := $(shell sw_vers -productVersion | cut -d. -f2) endif ifeq ($(UNAME),FreeBSD) @@ -215,6 +216,11 @@ endif # FreeBSD ifeq ($(UNAME),Darwin) export MACOSX_DEPLOYMENT_TARGET=10.9 CFLAGS_NATIVE := $(CFLAGS) + +ifeq ($(shell test $(PROD_VERS) -le 11; echo $$?), 0) +CFLAGS_NATIVE += -DMISSING_CLOCK_GETTIME +endif + LFLAGS_NATIVE := $(LFLAGS) LFLAGS_NATIVE += -framework OpenCL LFLAGS_NATIVE += -lpthread diff --git a/src/timer.c b/src/timer.c index ad1ccbf86..4cda1f092 100644 --- a/src/timer.c +++ b/src/timer.c @@ -33,7 +33,7 @@ inline double hc_timer_get (hc_timer_t a) inline void hc_timer_set (hc_timer_t* a) { - #if defined (__APPLE__) + #if defined(__APPLE__) && defined(MISSING_CLOCK_GETTIME) // taken from proxmark3/client/util_posix static uint64_t clock_start_time = 0; static mach_timebase_info_data_t timebase_info = {0, 0};