+2020-12-09 Bruno Haible <bruno@clisp.org>
+
+ threadlib: Fix test-fstrcmp failure on FreeBSD 11.
+ * m4/threadlib.m4 (gl_THREADLIB_BODY): When weak symbols are not present
+ on FreeBSD, define PTHREAD_IN_USE_DETECTION_HARD.
+ * lib/glthread/threadlib.c: Include <errno.h>.
+ (glthread_in_use): For FreeBSD, provide an alternative implementation
+ that uses pthread_key_create.
+
2020-12-09 Bruno Haible <bruno@clisp.org>
math C++ tests: Fix compilation error in with clang >= 7 on FreeBSD.
/* Use the POSIX threads library. */
+# include <errno.h>
# include <pthread.h>
# include <stdlib.h>
# if PTHREAD_IN_USE_DETECTION_HARD
+# if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
+
+/* Test using pthread_key_create. */
+
+int
+glthread_in_use (void)
+{
+ static int tested;
+ static int result; /* 1: linked with -lpthread, 0: only with libc */
+
+ if (!tested)
+ {
+ pthread_key_t key;
+ int err = pthread_key_create (&key, NULL);
+
+ if (err == ENOSYS)
+ result = 0;
+ else
+ {
+ result = 1;
+ if (err == 0)
+ pthread_key_delete (key);
+ }
+ tested = 1;
+ }
+ return result;
+}
+
+# else /* Solaris, HP-UX */
+
+/* Test using pthread_create. */
+
/* The function to be executed by a dummy thread. */
static void *
dummy_thread_func (void *arg)
return result;
}
+# endif
+
# endif
#endif
-# threadlib.m4 serial 28
+# threadlib.m4 serial 29
dnl Copyright (C) 2005-2020 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
AC_DEFINE([USE_POSIX_THREADS_WEAK], [1],
[Define if references to the POSIX multithreading library should be made weak.])
LIBTHREAD= LTLIBTHREAD=
+ else
+ case "$host_os" in
+ freebsd* | dragonfly*)
+ if test "x$LIBTHREAD" != "x$LIBMULTITHREAD"; then
+ dnl If weak symbols can't tell whether pthread_create(), pthread_key_create()
+ dnl etc. will succeed, we need a runtime test.
+ AC_DEFINE([PTHREAD_IN_USE_DETECTION_HARD], [1],
+ [Define if the pthread_in_use() detection is hard.])
+ fi
+ ;;
+ esac
fi
fi
fi