https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123406
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Hmm, so maybe like this:
AC_MSG_CHECKING([whether flockfile and putc_unlocked are defined in
<stdio.h>])
AC_TRY_COMPILE([
#include <stdio.h>
#if ! defined(__CYGWIN__) && __has_include(<newlib.h>)
#error No usable flockfile on non-cygwin newlib targets
#endif
],[
FILE* f = ::fopen("", "");
::flockfile(f);
::putc_unlocked(' ', f);
::funlockfile(f);
::fclose(f);
],[ac_stdio_locking=yes],[ac_stdio_locking=no])
AC_MSG_RESULT($ac_stdio_locking)