Hi, On Fri, Dec 17, 2010 at 10:26:09AM +0100, Frédéric Bohé wrote: > I have usleep in unistd.h :
usleep was apparently added to mingw on 2008-05-04, and yes, even Debian experimental is older than that, i wished there was a better maintainer for it in Debian. > The key seems to be __NO_ISOCEXT here. Can you try to add "#ifdef > __NO_ISOCEXT" around your usleep definition. Looks like a wrong idea, please consider an alternative approach :) (two patches attached, please make me aware if that's inconvenient and you prefer patches being sent in separate letters) -- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:[email protected]
>From 49f3e05ab30f663642b4ba271bc4b31edb942945 Mon Sep 17 00:00:00 2001 From: Paul Fertser <[email protected]> Date: Mon, 20 Dec 2010 13:50:03 +0300 Subject: [PATCH 1/2] Add usleep() implementation for systems that lack it This is needed e.g. on Debian which ships a really ancient version of mingw runtime. --- common/wincompat.c | 17 +++++++++++++++++ configure.in | 1 + include/common.h | 4 ++++ 3 files changed, 22 insertions(+), 0 deletions(-) diff --git a/common/wincompat.c b/common/wincompat.c index 3873d2c..a9fbabc 100644 --- a/common/wincompat.c +++ b/common/wincompat.c @@ -26,6 +26,23 @@ extern int errno; const char * EventLogName = NULL; +#ifndef HAVE_USLEEP +/* Verbatim from + http://cygwin.com/cgi-bin/cvsweb.cgi/~checkout~/src/winsup/mingw/mingwex/usleep.c?rev=1.2&cvsroot=src */ +int __cdecl usleep(unsigned int useconds) +{ + if(useconds == 0) + return 0; + + if(useconds >= 1000000) + return EINVAL; + + Sleep((useconds + 999) / 1000); + + return 0; +} +#endif /* !HAVE_USLEEP */ + int sktconnect(int fh, struct sockaddr * name, int len) { int ret = connect(fh,name,len); diff --git a/configure.in b/configure.in index 528ffcd..6bc263e 100644 --- a/configure.in +++ b/configure.in @@ -89,6 +89,7 @@ AC_CHECK_FUNCS(flock lockf fcvt fcvtl) AC_CHECK_FUNCS(cfsetispeed tcsendbreak) AC_CHECK_FUNCS(seteuid setsid getpassphrase) AC_CHECK_FUNCS(on_exit strptime setlogmask) +AC_CHECK_FUNCS(usleep) AC_CHECK_DECLS(LOG_UPTO, [], [], [#include <syslog.h>]) dnl the following may add stuff to LIBOBJS (is this still needed?) diff --git a/include/common.h b/include/common.h index dbeec9a..2fde7a5 100644 --- a/include/common.h +++ b/include/common.h @@ -182,4 +182,8 @@ extern int optind; #endif /* WIN32*/ +#ifndef HAVE_USLEEP +int __cdecl usleep(unsigned int useconds); +#endif /* HAVE_USLEEP */ + #endif /* NUT_COMMON_H */ -- 1.5.6.5
>From 7aa7110bbc40e3a5e997dea1fe45a1801f70deac Mon Sep 17 00:00:00 2001 From: Paul Fertser <[email protected]> Date: Mon, 20 Dec 2010 13:54:43 +0300 Subject: [PATCH 2/2] Automatically find the appropriate windows-specific tools, drop dllwrap This enables configure to find the tools from mingw-binutils repository packages. Also gets rid of deprecated dllwrap and uses ld instead. --- configure.in | 7 +++---- scripts/Windows/Makefile.am | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/configure.in b/configure.in index 6bc263e..276071e 100644 --- a/configure.in +++ b/configure.in @@ -408,11 +408,10 @@ NUT_REPORT_FEATURE([build Powerman PDU client driver], [${nut_with_powerman}]) dnl ---------------------------------------------------------------------- dnl checks related to MS Windows support (MingW) -AC_PATH_PROGS([WINDMC], [windmc], [none]) -AC_PATH_PROGS([WINDRES], [windres], [none]) -AC_PATH_PROGS([DLLWRAP], [dllwrap], [none]) +AC_CHECK_TOOL(WINDMC, windmc, none) +AC_CHECK_TOOL(WINDRES, windres, none) -if test "x$WINDMC" != "xnone" -a "x$WINDRES" != "xnone" -a "x$DLLWRAP" != "xnone"; then +if test "x$WINDMC" != "xnone" -a "x$WINDRES" != "xnone"; then nut_have_mingw_resgen="yes" fi diff --git a/scripts/Windows/Makefile.am b/scripts/Windows/Makefile.am index 18d545e..b2d70f1 100644 --- a/scripts/Windows/Makefile.am +++ b/scripts/Windows/Makefile.am @@ -16,7 +16,7 @@ winevent.o: winevent.rc winevent.h $(WINDRES) winevent.rc winevent.o winevent.dll: winevent.o - $(DLLWRAP) --output-lib=libwinevent.a --dllname=winevent.dll --driver-name=gcc winevent.o + $(LINK) -shared -Wl,--out-implib,libwinevent.a winevent.o bin_PROGRAMS = nut halt @@ -31,7 +31,7 @@ CLEANFILES = winevent.rc winevent.o winevent.dll winevent.h else !HAVE_MINGW_RESGEN winevent.dll: - @echo "Not building MingW resources since the needed programs (windmc, windres, dllwrap) were not found." + @echo "Not building MingW resources since the needed programs (windmc, windres) were not found." endif !HAVE_MINGW_RESGEN -- 1.5.6.5
_______________________________________________ Nut-upsdev mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev
