diff --git a/include/hamlib/rig.h b/include/hamlib/rig.h index 6a251e26e..6513a3a23 100644 --- a/include/hamlib/rig.h +++ b/include/hamlib/rig.h @@ -2439,7 +2439,6 @@ extern HAMLIB_EXPORT(const char *) rig_copyright HAMLIB_PARAMS(()); HAMLIB_EXPORT(void) rig_no_restore_ai(); #include -#include // so configure can pick up nanosleep on Win32 extern HAMLIB_EXPORT(int) hl_usleep(useconds_t msec); __END_DECLS diff --git a/lib/termios.c b/lib/termios.c index 86ea26eab..1d24392b8 100644 --- a/lib/termios.c +++ b/lib/termios.c @@ -1,4 +1,5 @@ #ifdef HAVE_CONFIG_H +#include "hamlib/rig.h" #include #endif diff --git a/macros/gr_pwin32.m4 b/macros/gr_pwin32.m4 index 090972f78..0687200da 100644 --- a/macros/gr_pwin32.m4 +++ b/macros/gr_pwin32.m4 @@ -23,6 +23,8 @@ AC_DEFUN([GR_PWIN32], [ AC_REQUIRE([AC_HEADER_TIME]) +AC_SEARCH_LIBS([nanosleep], [pthread], [], [AC_MSG_ERROR([unable to find nanosleep])]) +AC_CHECK_HEADERS([pthread.h]) AC_CHECK_HEADERS([sys/types.h]) AC_CHECK_HEADERS([windows.h]) AC_CHECK_HEADERS([winioctl.h winbase.h], [], [], [ @@ -33,6 +35,9 @@ AC_CHECK_HEADERS([winioctl.h winbase.h], [], [], [ AC_CHECK_FUNCS([getopt getopt_long usleep sleep nanosleep gettimeofday]) AC_CHECK_TYPES([struct timezone, ssize_t],[],[],[ + #if HAVE_PTHREAD_H + #include + #endif #if HAVE_SYS_TYPES_H # include #endif diff --git a/scripts/build-w32.sh b/scripts/build-w32.sh old mode 100644 new mode 100755 index b1a32ebdc..a2072712d --- a/scripts/build-w32.sh +++ b/scripts/build-w32.sh @@ -15,7 +15,7 @@ BUILD_DIR=~/builds # Set this to LibUSB archive extracted in $BUILD_DIR -LIBUSB_VER=libusb-1.0.20 +LIBUSB_VER=libusb-1.0.22 # uncomment the correct HOST_ARCH= line for your minGW installation HOST_ARCH=i686-w64-mingw32 @@ -225,6 +225,6 @@ cp -a ${LIBUSB_1_0_BIN_PATH}/MinGW32/dll/libusb-1.0.dll ${ZIP_DIR}/bin/libusb-1. cp -a /usr/lib/gcc/i686-w64-mingw32/6.3-posix/libgcc_s_sjlj-1.dll ${ZIP_DIR}/bin/libgcc_s_sjlj-1.dll ## Need VC++ free toolkit installed (default Wine directory installation shown) -( cd ${ZIP_DIR}/lib/msvc/ && wine ~/.wine/drive_c/Program\ Files/Microsoft\ Visual\ C++\ Toolkit\ 2003/bin/link.exe /lib /machine:i386 /def:libhamlib-2.def ) +( cd ${ZIP_DIR}/lib/msvc/ && wine ~/.wine/drive_c/Program\ Files\ (x86)\/Microsoft\ Visual\ Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x86/bin/link.exe /lib /machine:i386 /def:libhamlib-2.def ) /usr/bin/zip -r ${HL_FILENAME}.zip `basename ${ZIP_DIR}` diff --git a/src/misc.h b/src/misc.h index 5774eeb7a..99ae92874 100644 --- a/src/misc.h +++ b/src/misc.h @@ -98,6 +98,8 @@ 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); + #ifdef PRId64 /** \brief printf(3) format to be used for long long (64bits) type */ # define PRIll PRId64 diff --git a/src/rig.c b/src/rig.c index 3d7ab0b9e..6a3b96d4c 100644 --- a/src/rig.c +++ b/src/rig.c @@ -48,6 +48,7 @@ * \example ../tests/testrig.c */ +#include "hamlib/rig.h" #ifdef HAVE_CONFIG_H # include "config.h" #endif diff --git a/src/sleep.c b/src/sleep.c index ef86592f2..eed6a193f 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -39,6 +39,8 @@ #include #include #include +#include "config.h" +#include "sleep.h" #ifdef __cplusplus extern "C" { diff --git a/src/sleep.h b/src/sleep.h new file mode 100644 index 000000000..5f2c11d0d --- /dev/null +++ b/src/sleep.h @@ -0,0 +1,35 @@ +/* + * Hamlib Interface - sleep header + * Copyright (c) 2020 by Michael Black W9MDB + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef _HL_SLEEP_H +#define _HL_SLEEP_H 1 + +#include +#include "iofunc.h" + +__BEGIN_DECLS + +/* Hamlib internal use, see rig.c */ +int hl_usleep(useconds_t usec); + +__END_DECLS + +#endif /* _HL_SLEEP_H */