[Hamlib-commits] Hamlib -- Ham radio control libraries branch master updated. 54fc0e10f63767dd7e637
Library to control radio transceivers and receivers
Brought to you by:
n0nb
|
From: Michael B. <mdb...@us...> - 2021-01-25 18:26:16
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Hamlib -- Ham radio control libraries".
The branch, master has been updated
via 54fc0e10f63767dd7e63728cd1715559de761c99 (commit)
from e38c69602bdfadf0203ac6788f2e8787a3397c87 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 54fc0e10f63767dd7e63728cd1715559de761c99
Author: Michael Black W9MDB <mdb...@ya...>
Date: Mon Jan 25 12:23:05 2021 -0600
Add clock change to misc.c to allow building hamlib on some mac platforms
diff --git a/src/misc.c b/src/misc.c
index a0b31cf8..2aa1ad56 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -57,6 +57,46 @@
#include "misc.h"
#include "serial.h"
#include "network.h"
+#ifdef __APPLE__
+
+#if !HAVE_CLOCK_GETTIME
+
+# include <mach/mach_time.h>
+# ifndef __clockid_t_defined
+ typedef int clockid_t;
+ #define __clockid_t_defined 1
+# endif /* __clockid_t_defined */
+
+# define CLOCK_REALTIME 0
+# define CLOCK_MONOTONIC 6
+
+int clock_gettime(clockid_t clock_id, struct timespec* tp)
+{
+ if (clock_id == CLOCK_REALTIME) {
+ struct timeval t;
+ if (gettimeofday(&t, NULL) != 0)
+ return -1;
+ tp->tv_sec = t.tv_sec;
+ tp->tv_nsec = t.tv_usec * 1000;
+ }
+ else if (clock_id == CLOCK_MONOTONIC) {
+ static mach_timebase_info_data_t info = { 0, 0 };
+ if (info.denom == 0)
+ mach_timebase_info(&info);
+ uint64_t t = mach_absolute_time() * info.numer / info.denom;
+ tp->tv_sec = t / 1000000000;
+ tp->tv_nsec = t % 1000000000;
+ }
+ else {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return 0;
+}
+#endif // !HAVE_CLOCK_GETTIME
+
+#endif // __APPLE__
/**
-----------------------------------------------------------------------
Summary of changes:
src/misc.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
hooks/post-receive
--
Hamlib -- Ham radio control libraries
|