Provide custom-prompt-customize-unsaved-options.
[emacs.git] / m4 / fpending.m4
blobc2d01ef0713c23834ebe41c6ff34dd328c81a041
1 # serial 21
3 # Copyright (C) 2000-2001, 2004-2014 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.
8 dnl From Jim Meyering
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   fp_headers='
20     #include <stdio.h>
21     #if HAVE_STDIO_EXT_H
22     # include <stdio_ext.h>
23     #endif
24   '
25   AC_CACHE_CHECK([for __fpending], [gl_cv_func___fpending],
26     [
27       AC_LINK_IFELSE(
28         [AC_LANG_PROGRAM([$fp_headers],
29            [[return ! __fpending (stdin);]])],
30         [gl_cv_func___fpending=yes],
31         [gl_cv_func___fpending=no])
32     ])
33   if test $gl_cv_func___fpending = yes; then
34     AC_CHECK_DECLS([__fpending], [], [], [$fp_headers])
35   fi
38 AC_DEFUN([gl_PREREQ_FPENDING],
40   AC_CACHE_CHECK(
41               [how to determine the number of pending output bytes on a stream],
42                  ac_cv_sys_pending_output_n_bytes,
43     [
44       for ac_expr in                                                    \
45                                                                         \
46           '# glibc2'                                                    \
47           'fp->_IO_write_ptr - fp->_IO_write_base'                      \
48                                                                         \
49           '# traditional Unix'                                          \
50           'fp->_ptr - fp->_base'                                        \
51                                                                         \
52           '# BSD'                                                       \
53           'fp->_p - fp->_bf._base'                                      \
54                                                                         \
55           '# SCO, Unixware'                                             \
56           '(fp->__ptr ? fp->__ptr - fp->__base : 0)'                    \
57                                                                         \
58           '# QNX'                                                       \
59           '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \
60                                                                         \
61           '# old glibc?'                                                \
62           'fp->__bufp - fp->__buffer'                                   \
63                                                                         \
64           '# old glibc iostream?'                                       \
65           'fp->_pptr - fp->_pbase'                                      \
66                                                                         \
67           '# emx+gcc'                                                   \
68           'fp->_ptr - fp->_buffer'                                      \
69                                                                         \
70           '# Minix'                                                     \
71           'fp->_ptr - fp->_buf'                                         \
72                                                                         \
73           '# Plan9'                                                     \
74           'fp->wp - fp->buf'                                            \
75                                                                         \
76           '# VMS'                                                       \
77           '(*fp)->_ptr - (*fp)->_base'                                  \
78                                                                         \
79           '# e.g., DGUX R4.11; the info is not available'               \
80           1                                                             \
81           ; do
83         # Skip each embedded comment.
84         case "$ac_expr" in '#'*) continue;; esac
86         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]],
87           [[FILE *fp = stdin; (void) ($ac_expr);]])],
88           [fp_done=yes]
89         )
90         test "$fp_done" = yes && break
91       done
93       ac_cv_sys_pending_output_n_bytes=$ac_expr
94     ]
95   )
96   AC_DEFINE_UNQUOTED([PENDING_OUTPUT_N_BYTES],
97     $ac_cv_sys_pending_output_n_bytes,
98     [the number of pending output bytes on stream 'fp'])