Commit | Line | Data |
---|---|---|
eaca0446 | 1 | # serial 20 |
7ccfb720 | 2 | |
9ff99d22 | 3 | # Copyright (C) 2000-2001, 2004-2013 Free Software Foundation, Inc. |
7ccfb720 PE |
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. | |
7 | ||
8 | dnl From Jim Meyering | |
9 | dnl Using code from emacs, based on suggestions from Paul Eggert | |
10 | dnl and Ulrich Drepper. | |
11 | ||
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. | |
15 | ||
16 | AC_DEFUN([gl_FUNC_FPENDING], | |
17 | [ | |
18 | AC_CHECK_HEADERS_ONCE([stdio_ext.h]) | |
eaca0446 PE |
19 | AC_CACHE_CHECK([for __fpending], [gl_cv_func___fpending], |
20 | [ | |
21 | AC_LINK_IFELSE( | |
22 | [AC_LANG_PROGRAM( | |
23 | [[#include <stdio.h> | |
24 | #if HAVE_STDIO_EXT_H | |
25 | # include <stdio_ext.h> | |
26 | #endif | |
27 | ]], | |
28 | [[return ! __fpending (stdin);]])], | |
29 | [gl_cv_func___fpending=yes], | |
30 | [gl_cv_func___fpending=no]) | |
31 | ]) | |
7ccfb720 PE |
32 | ]) |
33 | ||
34 | AC_DEFUN([gl_PREREQ_FPENDING], | |
35 | [ | |
36 | AC_CACHE_CHECK( | |
37 | [how to determine the number of pending output bytes on a stream], | |
38 | ac_cv_sys_pending_output_n_bytes, | |
39 | [ | |
40 | for ac_expr in \ | |
41 | \ | |
42 | '# glibc2' \ | |
43 | 'fp->_IO_write_ptr - fp->_IO_write_base' \ | |
44 | \ | |
45 | '# traditional Unix' \ | |
46 | 'fp->_ptr - fp->_base' \ | |
47 | \ | |
48 | '# BSD' \ | |
49 | 'fp->_p - fp->_bf._base' \ | |
50 | \ | |
51 | '# SCO, Unixware' \ | |
52 | '(fp->__ptr ? fp->__ptr - fp->__base : 0)' \ | |
53 | \ | |
54 | '# QNX' \ | |
55 | '(fp->_Mode & 0x2000 /*_MWRITE*/ ? fp->_Next - fp->_Buf : 0)' \ | |
56 | \ | |
57 | '# old glibc?' \ | |
58 | 'fp->__bufp - fp->__buffer' \ | |
59 | \ | |
60 | '# old glibc iostream?' \ | |
61 | 'fp->_pptr - fp->_pbase' \ | |
62 | \ | |
63 | '# emx+gcc' \ | |
64 | 'fp->_ptr - fp->_buffer' \ | |
65 | \ | |
66 | '# Minix' \ | |
67 | 'fp->_ptr - fp->_buf' \ | |
68 | \ | |
69 | '# Plan9' \ | |
70 | 'fp->wp - fp->buf' \ | |
71 | \ | |
72 | '# VMS' \ | |
73 | '(*fp)->_ptr - (*fp)->_base' \ | |
74 | \ | |
75 | '# e.g., DGUX R4.11; the info is not available' \ | |
76 | 1 \ | |
77 | ; do | |
78 | ||
79 | # Skip each embedded comment. | |
80 | case "$ac_expr" in '#'*) continue;; esac | |
81 | ||
82 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], | |
83 | [[FILE *fp = stdin; (void) ($ac_expr);]])], | |
84 | [fp_done=yes] | |
85 | ) | |
86 | test "$fp_done" = yes && break | |
87 | done | |
88 | ||
89 | ac_cv_sys_pending_output_n_bytes=$ac_expr | |
90 | ] | |
91 | ) | |
92 | AC_DEFINE_UNQUOTED([PENDING_OUTPUT_N_BYTES], | |
93 | $ac_cv_sys_pending_output_n_bytes, | |
94 | [the number of pending output bytes on stream 'fp']) | |
95 | ]) |