Fix mingw32 DLL linkage of hl_sleep

This commit is contained in:
Michael Black 2020-01-10 15:58:16 -06:00
parent 5ae03f0eed
commit b7e8f01701
8 changed files with 48 additions and 3 deletions

View File

@ -2439,7 +2439,6 @@ extern HAMLIB_EXPORT(const char *) rig_copyright HAMLIB_PARAMS(());
HAMLIB_EXPORT(void) rig_no_restore_ai();
#include <unistd.h>
#include <pthread.h> // so configure can pick up nanosleep on Win32
extern HAMLIB_EXPORT(int) hl_usleep(useconds_t msec);
__END_DECLS

View File

@ -1,4 +1,5 @@
#ifdef HAVE_CONFIG_H
#include "hamlib/rig.h"
#include <config.h>
#endif

View File

@ -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 <pthread.h>
#endif
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

4
scripts/build-w32.sh Normal file → Executable file
View File

@ -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}`

View File

@ -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

View File

@ -48,6 +48,7 @@
* \example ../tests/testrig.c
*/
#include "hamlib/rig.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

View File

@ -39,6 +39,8 @@
#include <errno.h>
#include <time.h>
#include <pthread.h>
#include "config.h"
#include "sleep.h"
#ifdef __cplusplus
extern "C" {

35
src/sleep.h Normal file
View File

@ -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 <hamlib/rig.h>
#include "iofunc.h"
__BEGIN_DECLS
/* Hamlib internal use, see rig.c */
int hl_usleep(useconds_t usec);
__END_DECLS
#endif /* _HL_SLEEP_H */