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,
29 'fp->_IO_write_ptr - fp->_IO_write_base' \
31 '# traditional Unix' \
32 'fp->_ptr - fp->_base' \
35 'fp->_p - fp->_bf._base' \
38 'fp->__ptr - fp->__base' \
41 'fp->__bufp - fp->__buffer' \
43 '# old glibc iostream?' \
44 'fp->_pptr - fp->_pbase' \
47 '(*fp)->_ptr - (*fp)->_base' \
49 '# e.g., DGUX R4.11; the info is not available' \
53 # Skip each embedded comment.
54 case "$ac_expr" in '#'*) continue;; esac
59 [FILE *fp = stdin; (void) ($ac_expr);],
62 test "$fp_done" = yes && break
65 ac_cv_sys_pending_output_n_bytes=$ac_expr
68 AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
69 $ac_cv_sys_pending_output_n_bytes,
70 [the number of pending output bytes on stream `fp'])