]> Savannah Git Hosting - gnulib.git/commitdiff
pthread_mutex_timedlock: Fix link errors on FreeBSD 5.2.1/i386.
authorBruno Haible <bruno@clisp.org>
Sun, 15 Oct 2023 19:57:26 +0000 (21:57 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 5 Nov 2023 19:17:47 +0000 (20:17 +0100)
* m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK): Test
not only whether pthread_mutex_timedlock is declared, but also whether
it is actually defined.

ChangeLog
m4/pthread_mutex_timedlock.m4

index 1888aea1cc624e17c8e5cb1eb0458ed96a77acdf..2b6e326d99f673637af244c2d1e0e198f2e2ae8b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2023-10-15  Bruno Haible  <bruno@clisp.org>
+
+       pthread_mutex_timedlock: Fix link errors on FreeBSD 5.2.1/i386.
+       * m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK): Test
+       not only whether pthread_mutex_timedlock is declared, but also whether
+       it is actually defined.
+
 2023-10-15  Bruno Haible  <bruno@clisp.org>
 
        threadlib: Fix link errors on FreeBSD 5.2.1/i386.
index 66867208051cd6be36dd173c7aaeb738c1143ee9..b8eb81bda9f7d516d811a98a5303d2c9d5a09310 100644 (file)
@@ -1,4 +1,4 @@
-# pthread_mutex_timedlock.m4 serial 2
+# pthread_mutex_timedlock.m4 serial 3
 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -8,6 +8,39 @@ AC_DEFUN([gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK],
 [
   AC_REQUIRE([gl_PTHREAD_H_DEFAULTS])
 
-  AC_CHECK_DECL([pthread_mutex_timedlock], , [HAVE_PTHREAD_MUTEX_TIMEDLOCK=0],
+  AC_CHECK_DECL([pthread_mutex_timedlock],
+    [dnl Test whether the gnulib module 'threadlib' is in use.
+     dnl Some packages like Emacs use --avoid=threadlib.
+     dnl Write the symbol in such a way that it does not cause 'aclocal' to pick
+     dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/.
+     m4_ifdef([gl_][THREADLIB], [
+       AC_REQUIRE([gl_][THREADLIB])
+       dnl Test whether the function actually exists.
+       dnl FreeBSD 5.2.1 declares it but does not define it.
+       AC_CACHE_CHECK([for pthread_mutex_timedlock],
+         [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD],
+         [gl_save_LIBS="$LIBS"
+          LIBS="$LIBS $LIBMULTITHREAD"
+          AC_LINK_IFELSE(
+            [AC_LANG_PROGRAM(
+               [[#include <pthread.h>
+                 #include <time.h>
+               ]],
+               [[pthread_mutex_t *lock;
+                 return pthread_mutex_timedlock (&lock, (struct timespec *) 0);
+               ]])
+            ],
+            [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=yes],
+            [gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD=no])
+          LIBS="$gl_save_LIBS"
+         ])
+       if test $gl_cv_func_pthread_mutex_timedlock_in_LIBMULTITHREAD != yes; then
+         HAVE_PTHREAD_MUTEX_TIMEDLOCK=0
+       fi
+     ], [
+       :
+     ])
+    ],
+    [HAVE_PTHREAD_MUTEX_TIMEDLOCK=0],
     [[#include <pthread.h>]])
 ])