sticky-check -> setgid-check
[coreutils.git] / m4 / fpending.m4
bloba6e4338dda292385bfe6af37763c04281a8291ff
1 #serial 1
3 dnl From Jim Meyering
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])
15   fp_headers='
16 #     if HAVE_STDIO_EXT_H
17 #      include <stdio_ext.h>
18 #     endif
20   AC_CHECK_DECLS([__fpending], , , $fp_headers)
21   if test $ac_cv_func___fpending = no; then
22     AC_CACHE_CHECK(
23               [how to determine the number of pending output bytes on a stream],
24                    ac_cv_sys_pending_output_n_bytes,
25       [
26         fp_save_DEFS=$DEFS
27         for ac_expr in                                          \
28                                                                 \
29             '# glibc2'                                          \
30             'fp->_IO_write_ptr - fp->_IO_write_base'            \
31                                                                 \
32             '# traditional Unix'                                \
33             'fp->_ptr - fp->_base'                              \
34                                                                 \
35             '# BSD'                                             \
36             'fp->_p - fp->_bf._base'                            \
37                                                                 \
38             '# SCO, Unixware'                                   \
39             'fp->__ptr - fp->__base'                            \
40                                                                 \
41             '# old glibc?'                                      \
42             'fp->__bufp - fp->__buffer'                         \
43                                                                 \
44             '# old glibc iostream?'                             \
45             'fp->_pptr - fp->_pbase'                            \
46                                                                 \
47             '# VMS'                                             \
48             '(*fp)->_ptr - (*fp)->_base'                        \
49                                                                 \
50             '# e.g., DGUX R4.11; the info is not available'     \
51             1                                                   \
52             ; do
54           # Skip each embedded comment.
55           case "$ac_expr" in '#'*) continue;; esac
57           DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
58           AC_TRY_COMPILE(
59             [#include <stdio.h>
60             ],
61             [FILE *fp = stdin; (void) ($ac_expr);],
62             fp_done=yes
63           )
64           DEFS=$fp_save_DEFS
65           test "$fp_done" = yes && break
66         done
68         ac_cv_sys_pending_output_n_bytes=$ac_expr
69       ]
70     )
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'])
74   fi