Merge branch 'master' into comment-cache
[emacs.git] / m4 / fpending.m4
blob3a5e934c251da0a7d189475250cc9e1f3f9df65f
1 # serial 22
3 # Copyright (C) 2000-2001, 2004-2017 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 (possibly opaque) 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