$NetBSD: patch-ac,v 1.15 2022/07/15 23:23:35 gutteridge Exp $

See patch-aa.

--- configure.orig	2022-06-09 01:06:54.000000000 +0000
+++ configure
@@ -22170,42 +22170,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
@@ -22227,12 +22201,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" ;;
@@ -25521,6 +25497,7 @@ echo " Loadable i18n module support:
 echo " Loadable xcursor library support:        "$XLIB_LOADABLE_XCURSOR
 echo " Threading support:                       "$xthreads
 echo " Use Threads safe API:                    "$mtsafeapi
+echo " Use thread safety constructor:           "$USE_THREAD_SAFETY_CONSTRUCTOR
 echo " Threads stubs in libX11:                 "$thrstubs
 echo " XCMS:                                    "$XCMS
 echo " Internationalization support:            "$XLOCALE
