AC_DEFUN([gl_FUNC_FPENDING],
[
AC_LIBSOURCES([__fpending.c, __fpending.h])
AC_CHECK_HEADERS(stdio_ext.h)
AC_REPLACE_FUNCS([__fpending])
fp_headers='
'
AC_CHECK_DECLS([__fpending], , , $fp_headers)
if test $ac_cv_func___fpending = no; then
AC_CACHE_CHECK(
[how to determine the number of pending output bytes on a stream],
ac_cv_sys_pending_output_n_bytes,
[
for ac_expr in \
\
' 'fp->_IO_write_ptr - fp->_IO_write_base' \
\
' 'fp->_ptr - fp->_base' \
\
' 'fp->_p - fp->_bf._base' \
\
' 'fp->__ptr - fp->__base' \
\
' 'fp->__bufp - fp->__buffer' \
\
' 'fp->_pptr - fp->_pbase' \
\
' '(*fp)->_ptr - (*fp)->_base' \
\
' 1 \
; do
case "$ac_expr" in '
AC_TRY_COMPILE(
[ ],
[FILE *fp = stdin; (void) ($ac_expr);],
fp_done=yes
)
test "$fp_done" = yes && break
done
ac_cv_sys_pending_output_n_bytes=$ac_expr
]
)
AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
$ac_cv_sys_pending_output_n_bytes,
[the number of pending output bytes on stream `fp'])
fi
])