*** 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_FEPLACE_FUNCS([__fpending])
11   if test $ac_cv_func___fpending = no; then
12     AC_REPLACE_FUNCS(__fpending)
13     AC_CACHE_CHECK(
14               [how to determine the number of pending output bytes on a stream],
15                    ac_cv_sys_pending_output_n_bytes,
16       [
17         fp_save_DEFS=$DEFS
18         for ac_expr in                                          \
19                                                                 \
20           '# glibc2'                                            \
21           'fp->_IO_write_ptr - fp->_IO_write_base'              \
22                                                                 \
23           '# traditional Unix'                                  \
24           'fp->_ptr - fp->_base'                                \
25                                                                 \
26           '# BSD'                                               \
27           'fp->_p - fp->_bf._base'                              \
28                                                                 \
29           '# SCO, Unixware'                                     \
30           'fp->__ptr - fp->__base'                              \
31                                                                 \
32           '# old glibc?'                                        \
33           'fp->__bufp - fp->__buffer'                           \
34                                                                 \
35           '# old glibc iostream?'                               \
36           'fp->_pptr - fp->_pbase'                              \
37                                                                 \
38           '# VMS'                                               \
39           '(*fp)->_ptr - (*fp)->_base'                          \
40                                                                 \
41           '# e.g., DGUX R4.11; the info is not available'       \
42           1                                                     \
43           ; do
44             # Skip each embedded comment.
45             case "$ac_expr" in '#'*) continue;; esac
46 '
47
48             DEFS="$DEFS -DPENDING_OUTPUT_N_BYTES=$ac_expr"
49             AC_TRY_COMPILE(
50               [#include <stdio.h>
51               ],
52               [long unsigned int n = $ac_expr;],
53               fp_done=yes
54             )
55             DEFS=$fp_save_DEFS
56             test "$fp_done" = yes && break
57         done
58         AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES, $ac_expr,
59           [the number of pending output bytes on stream `fp'])
60       ])
61   fi
62
63
64
65
66   if test $fu_cv_sys_struct_timespec = yes; then
67     AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMESPEC, 1,
68                        [Define if struct timespec is declared in <time.h>. ])
69   fi
70 ])