*** 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_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             # Skip each embedded comment.
44             case "$ac_expr" in '#'*) continue;; esac
45 '
46
47             DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
48             AC_TRY_COMPILE(
49               [#include <stdio.h>
50               ],
51               [long unsigned int n = $ac_expr;],
52               fp_done=yes
53             )
54             DEFS=$fp_save_DEFS
55             test "$fp_done" = yes && break
56         done
57         AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES, $ac_expr,
58           [the number of pending output bytes on stream `fp'])
59       ])
60   fi
61
62
63
64
65   if test $fu_cv_sys_struct_timespec = yes; then
66     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
67                        [Define if struct timespec is declared in <time.h>. ])
68   fi
69 ])