dnl CF_STDIO_UNLOCKED version: 7 updated: 2023/12/13 18:02:34
dnl -----------------
dnl The four functions getc_unlocked(), getchar_unlocked(), putc_unlocked(),
dnl putchar_unlocked() are in POSIX.1-2001.
dnl
dnl Test for one or more of the "unlocked" stdio getc/putc functions, and (if
dnl the system requires it to declare the prototype) define _REENTRANT
dnl
dnl $1 = one or more stdio functions to check for existence and prototype.
AC_DEFUN([CF_STDIO_UNLOCKED],
[
cf_stdio_unlocked=no
AC_CHECK_FUNCS(ifelse([$1],,[getc_unlocked putc_unlocked],[$1]),
	[cf_stdio_unlocked="$ac_func"])
if test "$cf_stdio_unlocked" != no ; then
	case "$CPPFLAGS" in
	(*-D_REENTRANT*)
		;;
	(*)
	AC_CACHE_CHECK(if we should define _REENTRANT,cf_cv_stdio_unlocked,[
	AC_TRY_COMPILE([#include <stdio.h>],[
		extern void *$cf_stdio_unlocked(void *);
		void *dummy = $cf_stdio_unlocked(0); (void)dummy],
			[cf_cv_stdio_unlocked=yes],
			[cf_cv_stdio_unlocked=no])])
		if test "$cf_cv_stdio_unlocked" = yes ; then
			AC_DEFINE(_REENTRANT,1,[Define to 1 if we should define _REENTRANT])
		fi
		;;
	esac
fi
])
