From 83c8c61e32f4a9d42e2e4b324db99f3a58a498f3 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Mon, 3 Jul 2017 15:21:49 -0400 Subject: [PATCH] Clean up some compilation warnings, and allow FreeBSD 11.1 (and up) to use the clock_nanosleep() that is written/maintained for Linux. --- Makefile.am | 2 +- configure.ac | 4 ++++ driver-hashfast.c | 2 +- util.c | 7 +++++-- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index f9d21d4cbc..6a1cb81c27 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ ACLOCAL_AMFLAGS = -I m4 JANSSON_CPPFLAGS= -I$(top_builddir)/compat/jansson-2.9/src -I$(top_srcdir)/compat/jansson-2.9/src if WANT_USBUTILS -USBUTILS_CPPFLAGS = `pkg-config libusb-1.0 --libs --cflags` +USBUTILS_CPPFLAGS = `pkg-config libusb-1.0 --cflags` else USBUTILS_CPPFLAGS = endif diff --git a/configure.ac b/configure.ac index 51dc23c110..9468c1472c 100644 --- a/configure.ac +++ b/configure.ac @@ -126,6 +126,10 @@ if test "x$has_winpthread" != xtrue; then PTHREAD_LIBS=-lpthread fi +# Does the system have a POSIX clock_nanosleep (which can be given a +# CLOCK_MONOTONIC argument, can I check for that here too)? +AC_CHECK_FUNCS(clock_nanosleep) + # Drivers that are designed to be run on dedicated hardware should set standalone to yes # All drivers should prepend an x to the drivercount diff --git a/driver-hashfast.c b/driver-hashfast.c index d08beec2f5..d8b818f6f7 100644 --- a/driver-hashfast.c +++ b/driver-hashfast.c @@ -716,7 +716,7 @@ static void hfa_check_options(struct hashfast_info *info) if (!opt_hfa_options) return; - if (!info->op_name) + if (info->op_name[0] == '\0') return; maxlen = strlen(info->op_name); diff --git a/util.c b/util.c index 3e3cee319d..095c6e5eb6 100644 --- a/util.c +++ b/util.c @@ -40,6 +40,10 @@ #endif #include +#if (defined(__FreeBSD__) || defined(__OpenBSD__)) +# include +#endif + #include "miner.h" #include "elist.h" #include "compat.h" @@ -1444,8 +1448,7 @@ void cgtimer_sub(cgtimer_t *a, cgtimer_t *b, cgtimer_t *res) } #endif /* WIN32 */ -#if defined(CLOCK_MONOTONIC) && !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(WIN32) /* Essentially just linux */ -//#ifdef CLOCK_MONOTONIC /* Essentially just linux */ +#if defined(CLOCK_MONOTONIC) && HAVE_CLOCK_NANOSLEEP /* Mostly just linux */ void cgtimer_time(cgtimer_t *ts_start) { clock_gettime(CLOCK_MONOTONIC, ts_start);