From f2b7893a2b81c00e7a9998b376b846a34bab1205 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Wed, 27 Jan 2021 11:00:58 -0600 Subject: [PATCH] Another attempt to get clock_gettime compiling for all Mac flavors --- src/misc.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/misc.c b/src/misc.c index e5a0a6e76..eccb7ba15 100644 --- a/src/misc.c +++ b/src/misc.c @@ -60,22 +60,23 @@ #ifdef __APPLE__ -#include +#include -#if AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER +#if !defined(CLOCK_REALTIME) && !defined(CLOCK_MONOTONIC) +// +// MacOS < 10.12 does not have clock_gettime +// +// Contribution from github user "ra1nb0w" +// -#else - -# include -# ifndef __clockid_t_defined +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 6 typedef int clockid_t; -#define __clockid_t_defined 1 -# endif /* __clockid_t_defined */ -# define CLOCK_REALTIME 0 -# define CLOCK_MONOTONIC 1 +#include +#include -int clock_gettime(clockid_t clock_id, struct timespec *tp) +static int clock_gettime(clockid_t clock_id, struct timespec *tp) { if (clock_id == CLOCK_REALTIME) {