$NetBSD: patch-ac,v 1.14 2021/06/06 21:05:08 wiz Exp $

See patch-aa.

--- configure.orig	2021-06-06 16:49:01.000000000 +0000
+++ configure
@@ -22009,42 +22009,16 @@ printf "%s\n" "#define XUSE_MTSAFE_API 1
 	;;
 esac
 
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_self in -lc" >&5
-printf %s "checking for pthread_self in -lc... " >&6; }
-if test ${ac_cv_lib_c_pthread_self+y}
+ac_fn_check_decl "$LINENO" "pthread_self" "ac_cv_have_decl_pthread_self" "#include <pthread.h>
+" "$ac_c_undeclared_builtin_options" "CFLAGS"
+if test "x$ac_cv_have_decl_pthread_self" = xyes
 then :
-  printf %s "(cached) " >&6
+  ac_have_decl=1
 else $as_nop
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lc  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-char pthread_self ();
-int
-main (void)
-{
-return pthread_self ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"
-then :
-  ac_cv_lib_c_pthread_self=yes
-else $as_nop
-  ac_cv_lib_c_pthread_self=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.beam \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
+  ac_have_decl=0
 fi
-{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_c_pthread_self" >&5
-printf "%s\n" "$ac_cv_lib_c_pthread_self" >&6; }
-if test "x$ac_cv_lib_c_pthread_self" = xyes
+printf "%s\n" "#define HAVE_DECL_PTHREAD_SELF $ac_have_decl" >>confdefs.h
+if test $ac_have_decl = 1
 then :
   thrstubs="no"
 else $as_nop
@@ -22066,12 +22040,12 @@ if test x$xthreads = xyes ; then
     linux*|gnu*|k*bsd*-gnu)
         XTHREADLIB=-lpthread ;;
     netbsd*)
-	XTHREAD_CFLAGS="-D_POSIX_THREAD_SAFE_FUNCTIONS"
-	XTHREADLIB="-lpthread" ;;
+	XTHREAD_CFLAGS="-D_REENTRANT"
+	XTHREADLIB="-pthread" ;;
     freebsd*)
         XTHREAD_CFLAGS="-D_THREAD_SAFE"
         XTHREADLIB="-pthread" ;;
-    dragonfly*|openbsd*)
+    dragonfly*|openbsd*|mirbsd*)
         XTHREADLIB="-pthread" ;;
     solaris*)
 	XTHREAD_CFLAGS="-D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS" ;;
