*** empty log message ***
[gnulib.git] / m4 / fpending.m4
1 #serial 1
2
3 dnl From Jim Meyering
4 dnl Using code from emacs, based on suggestions from Paul Eggert
5 dnl and Ulrich Drepper.
6
7 AC_DEFUN(jm_FUNC_FPENDING,
8 [
9   AC_CHECK_HEADERS(stdio_ext.h)
10   AC_REPLACE_FUNCS([__fpending])
11   if test $ac_cv_func___fpending = no; then
12     AC_CACHE_CHECK(
13               [how to determine the number of pending output bytes on a stream],
14                    ac_cv_sys_pending_output_n_bytes,
15       [
16         fp_save_DEFS=$DEFS
17         for ac_expr in                                          \
18                                                                 \
19             '# glibc2'                                          \
20             'fp->_IO_write_ptr - fp->_IO_write_x_base'          \
21                                                                 \
22             '# traditional Unix'                                \
23             'fp->_ptr - fp->_base'                              \
24                                                                 \
25             '# BSD'                                             \
26             'fp->_p - fp->_bf._base'                            \
27                                                                 \
28             '# SCO, Unixware'                                   \
29             'fp->__ptr - fp->__base'                            \
30                                                                 \
31             '# old glibc?'                                      \
32             'fp->__bufp - fp->__buffer'                         \
33                                                                 \
34             '# old glibc iostream?'                             \
35             'fp->_pptr - fp->_pbase'                            \
36                                                                 \
37             '# VMS'                                             \
38             '(*fp)->_ptr - (*fp)->_base'                        \
39                                                                 \
40             '# e.g., DGUX R4.11; the info is not available'     \
41             1                                                   \
42             ; do
43
44           # Skip each embedded comment.
45           case "$ac_expr" in '#'*) continue;; esac
46
47           DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
48           AC_TRY_COMPILE(
49             [#include <stdio.h>
50             ],
51             [FILE *fp = stdin; (void) ($ac_expr);],
52             fp_done=yes
53           )
54           DEFS=$fp_save_DEFS
55           test "$fp_done" = yes && break
56         done
57
58         ac_cv_sys_pending_output_n_bytes=$ac_expr
59       ]
60     )
61     AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
62       $ac_cv_sys_pending_output_n_bytes,
63       [the number of pending output bytes on stream `fp'])
64   fi
65 ])