4 dnl Using code from emacs, based on suggestions from Paul Eggert
5 dnl and Ulrich Drepper.
7 dnl Find out how to determine the number of pending output bytes on a stream.
8 dnl glibc (2.1.93 and newer) and Solaris provide __fpending. On other systems,
9 dnl we have to grub around in the FILE struct.
11 AC_DEFUN(jm_FUNC_FPENDING,
13 AC_CHECK_HEADERS(stdio_ext.h)
14 AC_REPLACE_FUNCS([__fpending])
17 # include <stdio_ext.h>
20 AC_CHECK_DECLS([__fpending], , , $fp_headers)
21 if test $ac_cv_func___fpending = no; then
23 [how to determine the number of pending output bytes on a stream],
24 ac_cv_sys_pending_output_n_bytes,
30 'fp->_IO_write_ptr - fp->_IO_write_base' \
32 '# traditional Unix' \
33 'fp->_ptr - fp->_base' \
36 'fp->_p - fp->_bf._base' \
39 'fp->__ptr - fp->__base' \
42 'fp->__bufp - fp->__buffer' \
44 '# old glibc iostream?' \
45 'fp->_pptr - fp->_pbase' \
48 '(*fp)->_ptr - (*fp)->_base' \
50 '# e.g., DGUX R4.11; the info is not available' \
54 # Skip each embedded comment.
55 case "$ac_expr" in '#'*) continue;; esac
57 DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
61 [FILE *fp = stdin; (void) ($ac_expr);],
65 test "$fp_done" = yes && break
68 ac_cv_sys_pending_output_n_bytes=$ac_expr
71 AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
72 $ac_cv_sys_pending_output_n_bytes,
73 [the number of pending output bytes on stream `fp'])