From 815db24852f30f9eb74531dae32a0fc571c5e446 Mon Sep 17 00:00:00 2001 From: Michael Black W9MDB Date: Sat, 13 Jun 2020 17:40:47 -0500 Subject: [PATCH] Fix MSVC compile by removing unistd.h and defining our own rig_useconds_t https://github.com/Hamlib/Hamlib/issues/301 --- dummy/flrig.h | 2 +- include/hamlib/rig.h | 4 ++-- src/misc.h | 2 +- src/sleep.c | 6 ++++-- src/sleep.h | 2 +- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/dummy/flrig.h b/dummy/flrig.h index 1134d7aba..00e841d8a 100644 --- a/dummy/flrig.h +++ b/dummy/flrig.h @@ -28,7 +28,7 @@ #include #endif -#define BACKEND_VER "20200510" +#define BACKEND_VER "20200613" #define EOM "\r" #define TRUE 1 diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 239c9deec..53e0f2948 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2743,8 +2743,8 @@ extern HAMLIB_EXPORT(int) rig_set_vfo_opt(RIG *rig, int status); // cppcheck-suppress * -#include -extern HAMLIB_EXPORT(int) hl_usleep(useconds_t msec); +typedef unsigned long rig_useconds_t; +extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t msec); //! @endcond diff --git a/src/misc.h b/src/misc.h index f92d5fcc8..382b949d8 100644 --- a/src/misc.h +++ b/src/misc.h @@ -100,7 +100,7 @@ extern HAMLIB_EXPORT(void) rig_force_cache_timeout(struct timeval *tv); extern HAMLIB_EXPORT(setting_t) rig_idx2setting(int i); -extern HAMLIB_EXPORT(int) hl_usleep(useconds_t usec); +extern HAMLIB_EXPORT(int) hl_usleep(rig_useconds_t usec); extern HAMLIB_EXPORT(double) elapsed_ms(struct timespec *start, int start_flag); diff --git a/src/sleep.c b/src/sleep.c index 709f884db..d8624ed4c 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -50,7 +50,7 @@ extern "C" { // In order to stop the usleep warnings in cppcheck we provide our own interface // So this will use system usleep or our usleep depending on availability of nanosleep // This version of usleep can handle > 1000000 usec values -int hl_usleep(useconds_t usec) +int hl_usleep(rig_useconds_t usec) { int retval = 0; @@ -85,12 +85,13 @@ unsigned int sleep(unsigned int secs) } +#if 0 /** * \brief microsecond sleep * \param usec is microseconds to sleep * This does not have the same 1000000 limit as POSIX usleep */ -int usleep(useconds_t usec) +int usleep(rig_useconds_t usec) { int retval; unsigned long sec = usec / 1000000ul; @@ -106,6 +107,7 @@ int usleep(useconds_t usec) return 0; } +#endif #endif // HAVE_NANOSLEEP #ifdef __cplusplus diff --git a/src/sleep.h b/src/sleep.h index 5f2c11d0d..89f9be2e3 100644 --- a/src/sleep.h +++ b/src/sleep.h @@ -28,7 +28,7 @@ __BEGIN_DECLS /* Hamlib internal use, see rig.c */ -int hl_usleep(useconds_t usec); +int hl_usleep(rig_useconds_t usec); __END_DECLS