]> Savannah Git Hosting - gnulib.git/commitdiff
lock: Fix cross-compilation guesses.
authorBruno Haible <bruno@clisp.org>
Thu, 29 Aug 2019 22:06:52 +0000 (00:06 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 29 Aug 2019 22:06:52 +0000 (00:06 +0200)
* m4/pthread_rwlock_rdlock.m4 (gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER):
Require AC_CANONICAL_HOST. When cross-compiling, guess no on most
platforms.

ChangeLog
m4/pthread_rwlock_rdlock.m4

index 9119520717ee728e999f3bb871d6fd9714841b3a..2c6939b92519108c0359d58f2e689d0aaf997856 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2019-08-29  Bruno Haible  <bruno@clisp.org>
+
+       lock: Fix cross-compilation guesses.
+       * m4/pthread_rwlock_rdlock.m4 (gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER):
+       Require AC_CANONICAL_HOST. When cross-compiling, guess no on most
+       platforms.
+
 2019-08-28  Bruno Haible  <bruno@clisp.org>
 
        isfinite, isinf, isnan, signbit: Fix error in C++ mode on mingw.
index 3c1d64566128a3dd0905c4f9be3e69722f726e54..85e8dbae507704e047f90df44742bf0e87fd8181 100644 (file)
@@ -1,4 +1,4 @@
-# pthread_rwlock_rdlock.m4 serial 2
+# pthread_rwlock_rdlock.m4 serial 3
 dnl Copyright (C) 2017-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -29,11 +29,13 @@ dnl and SCHED_RR, see
 dnl http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_rwlock_rdlock.html
 dnl but this test verifies the guarantee regardless of TPS and regardless of
 dnl scheduling policy.
-dnl Glibc currently does not provide this guarantee, see
+dnl Glibc does not provide this guarantee (and never will on Linux), see
 dnl https://sourceware.org/bugzilla/show_bug.cgi?id=13701
+dnl https://bugzilla.redhat.com/show_bug.cgi?id=1410052
 AC_DEFUN([gl_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER],
 [
   AC_REQUIRE([gl_THREADLIB_EARLY])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
   AC_CACHE_CHECK([whether pthread_rwlock_rdlock prefers a writer to a reader],
     [gl_cv_pthread_rwlock_rdlock_prefer_writer],
     [save_LIBS="$LIBS"
@@ -153,7 +155,25 @@ main ()
 ]])],
        [gl_cv_pthread_rwlock_rdlock_prefer_writer=yes],
        [gl_cv_pthread_rwlock_rdlock_prefer_writer=no],
-       [gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"])
+       [case "$host_os" in
+                         # Guess no on glibc systems.
+          *-gnu* | gnu*) gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
+                         # Guess no on musl systems.
+          *-musl*)       gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
+                         # Guess no on bionic systems.
+          *-android*)    gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
+                         # Guess yes on native Windows with the mingw-w64 winpthreads library.
+                         # Guess no on native Windows with the gnulib windows-rwlock module.
+          mingw*)        if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
+                           gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing yes"
+                         else
+                           gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no"
+                         fi
+                         ;;
+                         # If we don't know, assume the worst.
+          *)             gl_cv_pthread_rwlock_rdlock_prefer_writer="guessing no" ;;
+         esac
+       ])
      LIBS="$save_LIBS"
     ])
   case "$gl_cv_pthread_rwlock_rdlock_prefer_writer" in