From 54a6fbfd8c52dc8e0bb212ad9c7d0b55a6de40af Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 5 Apr 2010 23:46:02 +0200 Subject: [PATCH] Make the multithread modules work on Cygwin 1.7.2. --- ChangeLog | 7 +++++++ m4/threadlib.m4 | 41 ++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 583f0e305b..3e0e539ec8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-04-05 Bruno Haible + + Make the multithread modules work on Cygwin 1.7.2. + * m4/threadlib.m4 (gl_THREADLIB_BODY): Improve the test whether + imported symbols can be declared weak, so that it returns "no" on + Cygwin 1.7.2. + 2010-04-05 Bruno Haible Use the module 'strncat'. diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index bba460e4bc..05cc4ffab9 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -1,4 +1,4 @@ -# threadlib.m4 serial 4 (gettext-0.18) +# threadlib.m4 serial 5 (gettext-0.18) dnl Copyright (C) 2005-2010 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -107,11 +107,34 @@ AC_DEFUN([gl_THREADLIB_BODY], LTLIBMULTITHREAD= if test "$gl_use_threads" != no; then dnl Check whether the compiler and linker support weak declarations. - AC_MSG_CHECKING([whether imported symbols can be declared weak]) - gl_have_weak=no - AC_TRY_LINK([extern void xyzzy (); -#pragma weak xyzzy], [xyzzy();], [gl_have_weak=yes]) - AC_MSG_RESULT([$gl_have_weak]) + AC_CACHE_CHECK([whether imported symbols can be declared weak], + [gl_cv_have_weak], + [gl_cv_have_weak=no + dnl First, test whether the compiler accepts it syntactically. + AC_TRY_LINK([extern void xyzzy (); +#pragma weak xyzzy], [xyzzy();], [gl_cv_have_weak=maybe]) + if test $gl_cv_have_weak = maybe; then + dnl Second, test whether it actually works. On Cygwin 1.7.2, with + dnl gcc 4.3, symbols declared weak always evaluate to the address 0. + AC_TRY_RUN([ +#include +#pragma weak fputs +int main () +{ + return (fputs == NULL); +}], [gl_cv_have_weak=yes], [gl_cv_have_weak=no], + [dnl When cross-compiling, assume that only ELF platforms support + dnl weak symbols. + AC_EGREP_CPP([Extensible Linking Format], + [#ifdef __ELF__ + Extensible Linking Format + #endif + ], + [gl_cv_have_weak="guessing yes"], + [gl_cv_have_weak="guessing no"]) + ]) + fi + ]) if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then # On OSF/1, the compiler needs the flag -pthread or -D_REENTRANT so that # it groks . It's added above, in gl_THREADLIB_EARLY_BODY. @@ -165,7 +188,7 @@ AC_DEFUN([gl_THREADLIB_BODY], AC_DEFINE([USE_POSIX_THREADS], [1], [Define if the POSIX multithreading library can be used.]) if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if test $gl_have_weak = yes; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then AC_DEFINE([USE_POSIX_THREADS_WEAK], [1], [Define if references to the POSIX multithreading library should be made weak.]) LIBTHREAD= @@ -193,7 +216,7 @@ AC_DEFUN([gl_THREADLIB_BODY], LTLIBMULTITHREAD="$LTLIBTHREAD" AC_DEFINE([USE_SOLARIS_THREADS], [1], [Define if the old Solaris multithreading library can be used.]) - if test $gl_have_weak = yes; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then AC_DEFINE([USE_SOLARIS_THREADS_WEAK], [1], [Define if references to the old Solaris multithreading library should be made weak.]) LIBTHREAD= @@ -219,7 +242,7 @@ AC_DEFUN([gl_THREADLIB_BODY], AC_DEFINE([USE_PTH_THREADS], [1], [Define if the GNU Pth multithreading library can be used.]) if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if test $gl_have_weak = yes; then + if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then AC_DEFINE([USE_PTH_THREADS_WEAK], [1], [Define if references to the GNU Pth multithreading library should be made weak.]) LIBTHREAD= -- 2.30.2