bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

poll on MSVC


From: Bruno Haible
Subject: poll on MSVC
Date: Tue, 4 Oct 2011 03:35:11 +0200
User-agent: KMail/1.13.6 (Linux/2.6.37.6-0.5-desktop; KDE/4.6.0; x86_64; ; )

On 2011-09-22 I wrote:
> On MSVC 9, test-select does not link, because for the functions
>   DispatchMessageA
>   TranslateMessage
>   PeekMessageA
>   MsgWaitForMultipleObjects
> linking with -luser32 is necessary. On mingw, this linker option is apparently
> included by default.

The same holds for 'poll' on MSVC 9. This fixes it.


2011-10-03  Bruno Haible  <address@hidden>

        poll: Avoid link errors on MSVC.
        * m4/poll.m4 (gl_FUNC_POLL): Determine LIB_POLL.
        * modules/poll (Depends-on): Add sockets.
        (Link): New section.
        * NEWS: Mention the change.
        * modules/poll-tests (Makefile.am): Link test-poll against $(LIB_POLL).
        * modules/poll-h-c++-tests (Makefile.am): Link test-poll-h-c++ against
        $(LIB_POLL) instead of $(LIBSOCKET).

--- NEWS.orig   Tue Oct  4 03:28:39 2011
+++ NEWS        Tue Oct  4 03:04:24 2011
@@ -12,6 +12,9 @@
 
 Date        Modules         Changes
 
+2011-10-03  poll            The link requirements of this module are changed
+                            from empty to $(LIB_POLL).
+
 2011-09-25  sys_stat        This module no longer provides the fstat()
                             function. If you need this function, you now need
                             to request the 'fstat' module.
--- m4/poll.m4.orig     Tue Oct  4 03:28:39 2011
+++ m4/poll.m4  Tue Oct  4 03:26:23 2011
@@ -1,4 +1,4 @@
-# poll.m4 serial 14
+# poll.m4 serial 15
 dnl Copyright (c) 2003, 2005-2007, 2009-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,6 +7,7 @@
 AC_DEFUN([gl_FUNC_POLL],
 [
   AC_REQUIRE([gl_POLL_H])
+  AC_REQUIRE([gl_SOCKETS])
   if test "$ac_cv_header_poll_h" = no; then
     ac_cv_func_poll=no
     gl_cv_func_poll=no
@@ -68,6 +69,31 @@
     AC_DEFINE([HAVE_POLL], [1],
       [Define to 1 if you have the 'poll' function and it works.])
   fi
+
+  dnl Determine the needed libraries.
+  LIB_POLL="$LIBSOCKET"
+  if test $HAVE_POLL = 0 || test $REPLACE_POLL = 1; then
+    case "$host_os" in
+      mingw*)
+        dnl On the MSVC platform, the function MsgWaitForMultipleObjects
+        dnl (used in lib/poll.c) requires linking with -luser32. On mingw,
+        dnl it is implicit.
+        AC_LINK_IFELSE(
+          [AC_LANG_SOURCE([[
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+int
+main ()
+{
+  MsgWaitForMultipleObjects (0, NULL, 0, 0, 0);
+  return 0;
+}]])],
+          [],
+          [LIB_POLL="$LIB_POLL -luser32"])
+        ;;
+    esac
+  fi
+  AC_SUBST([LIB_POLL])
 ])
 
 # Prerequisites of lib/poll.c.
--- modules/poll.orig   Tue Oct  4 03:28:39 2011
+++ modules/poll        Tue Oct  4 03:27:26 2011
@@ -9,6 +9,7 @@
 poll-h
 alloca          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 select          [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
+sockets         [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 sys_select      [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 sys_time        [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
 errno           [test $HAVE_POLL = 0 || test $REPLACE_POLL = 1]
@@ -27,6 +28,9 @@
 Include:
 <poll.h>
 
+Link:
+$(LIB_POLL)
+
 License:
 LGPLv2+
 
--- modules/poll-h-c++-tests.orig       Tue Oct  4 03:28:39 2011
+++ modules/poll-h-c++-tests    Tue Oct  4 03:24:43 2011
@@ -15,5 +15,5 @@
 TESTS += test-poll-h-c++
 check_PROGRAMS += test-poll-h-c++
 test_poll_h_c___SOURCES = test-poll-h-c++.cc
-test_poll_h_c___LDADD = $(LDADD) @LIBSOCKET@
+test_poll_h_c___LDADD = $(LDADD) $(LIB_POLL)
 endif
--- modules/poll-tests.orig     Tue Oct  4 03:28:39 2011
+++ modules/poll-tests  Tue Oct  4 03:08:21 2011
@@ -28,4 +28,4 @@
 Makefile.am:
 TESTS += test-poll
 check_PROGRAMS += test-poll
-test_poll_LDADD = $(LDADD) @LIBSOCKET@ $(INET_PTON_LIB)
+test_poll_LDADD = $(LDADD) $(LIB_POLL) @LIBSOCKET@ $(INET_PTON_LIB)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]