3 # Copyright (C) 2000-2001, 2004-2012 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
9 dnl Using code from emacs, based on suggestions from Paul Eggert
10 dnl and Ulrich Drepper.
12 dnl Find out how to determine the number of pending output bytes on a stream.
13 dnl glibc (2.1.93 and newer) and Solaris provide __fpending. On other systems,
14 dnl we have to grub around in the FILE struct.
16 AC_DEFUN([gl_FUNC_FPENDING],
18 AC_CHECK_HEADERS_ONCE([stdio_ext.h])
19 AC_CHECK_FUNCS_ONCE([__fpending])
23 # include <stdio_ext.h>
26 AC_CHECK_DECLS([__fpending], , , $fp_headers)
29 AC_DEFUN([gl_PREREQ_FPENDING],
32 [how to determine the number of pending output bytes on a stream],
33 ac_cv_sys_pending_output_n_bytes,
38 'fp->_IO_write_ptr - fp->_IO_write_base' \
40 '# traditional Unix' \
41 'fp->_ptr - fp->_base' \
44 'fp->_p - fp->_bf._base' \
47 '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \
50 '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
53 'fp->__bufp - fp->__buffer' \
55 '# old glibc iostream?' \
56 'fp->_pptr - fp->_pbase' \
59 'fp->_ptr - fp->_buffer' \
62 'fp->_ptr - fp->_buf' \
68 '(*fp)->_ptr - (*fp)->_base' \
70 '# e.g., DGUX R4.11; the info is not available' \
74 # Skip each embedded comment.
75 case "$ac_expr" in '#'*) continue;; esac
77 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
78 [[FILE *fp = stdin; (void) ($ac_expr);]])],
81 test "$fp_done" = yes && break
84 ac_cv_sys_pending_output_n_bytes=$ac_expr
87 AC_DEFINE_UNQUOTED([PENDING_OUTPUT_N_BYTES],
88 $ac_cv_sys_pending_output_n_bytes,
89 [the number of pending output bytes on stream 'fp'])