Blame m4/fpending.m4

Packit 709fb3
# serial 22
Packit 709fb3
Packit 709fb3
# Copyright (C) 2000-2001, 2004-2017 Free Software Foundation, Inc.
Packit 709fb3
# This file is free software; the Free Software Foundation
Packit 709fb3
# gives unlimited permission to copy and/or distribute it,
Packit 709fb3
# with or without modifications, as long as this notice is preserved.
Packit 709fb3
Packit 709fb3
dnl From Jim Meyering
Packit 709fb3
dnl Using code from emacs, based on suggestions from Paul Eggert
Packit 709fb3
dnl and Ulrich Drepper.
Packit 709fb3
Packit 709fb3
dnl Find out how to determine the number of pending output bytes on a stream.
Packit 709fb3
dnl glibc (2.1.93 and newer) and Solaris provide __fpending.  On other systems,
Packit 709fb3
dnl we have to grub around in the (possibly opaque) FILE struct.
Packit 709fb3
Packit 709fb3
AC_DEFUN([gl_FUNC_FPENDING],
Packit 709fb3
[
Packit 709fb3
  AC_CHECK_HEADERS_ONCE([stdio_ext.h])
Packit 709fb3
  fp_headers='
Packit 709fb3
    #include <stdio.h>
Packit 709fb3
    #if HAVE_STDIO_EXT_H
Packit 709fb3
    # include <stdio_ext.h>
Packit 709fb3
    #endif
Packit 709fb3
  '
Packit 709fb3
  AC_CACHE_CHECK([for __fpending], [gl_cv_func___fpending],
Packit 709fb3
    [
Packit 709fb3
      AC_LINK_IFELSE(
Packit 709fb3
        [AC_LANG_PROGRAM([$fp_headers],
Packit 709fb3
           [[return ! __fpending (stdin);]])],
Packit 709fb3
        [gl_cv_func___fpending=yes],
Packit 709fb3
        [gl_cv_func___fpending=no])
Packit 709fb3
    ])
Packit 709fb3
  if test $gl_cv_func___fpending = yes; then
Packit 709fb3
    AC_CHECK_DECLS([__fpending], [], [], [$fp_headers])
Packit 709fb3
  fi
Packit 709fb3
])