~stefanlsd/+junk/test

« back to all changes in this revision

Viewing changes to gnulib/m4/fpending.m4

  • Committer: stefan
  • Date: 2008-09-05 20:22:13 UTC
  • Revision ID: stefan@lsd-20080905202213-tkhx46qm7rx4ynip
Initial Commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#serial 10
 
2
 
 
3
# Copyright (C) 2000, 2001, 2004, 2005, 2006 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.
 
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)
 
19
  AC_REPLACE_FUNCS([__fpending])
 
20
  fp_headers='
 
21
#     include <stdio.h>
 
22
#     if HAVE_STDIO_EXT_H
 
23
#      include <stdio_ext.h>
 
24
#     endif
 
25
'
 
26
  AC_CHECK_DECLS([__fpending], , , $fp_headers)
 
27
  if test $ac_cv_func___fpending = no; then
 
28
    AC_CACHE_CHECK(
 
29
              [how to determine the number of pending output bytes on a stream],
 
30
                   ac_cv_sys_pending_output_n_bytes,
 
31
      [
 
32
        for ac_expr in                                          \
 
33
                                                                \
 
34
            '# glibc2'                                          \
 
35
            'fp->_IO_write_ptr - fp->_IO_write_base'            \
 
36
                                                                \
 
37
            '# traditional Unix'                                \
 
38
            'fp->_ptr - fp->_base'                              \
 
39
                                                                \
 
40
            '# BSD'                                             \
 
41
            'fp->_p - fp->_bf._base'                            \
 
42
                                                                \
 
43
            '# SCO, Unixware'                                   \
 
44
            '(fp->__ptr ? fp->__ptr - fp->__base : 0)'          \
 
45
                                                                \
 
46
            '# old glibc?'                                      \
 
47
            'fp->__bufp - fp->__buffer'                         \
 
48
                                                                \
 
49
            '# old glibc iostream?'                             \
 
50
            'fp->_pptr - fp->_pbase'                            \
 
51
                                                                \
 
52
            '# VMS'                                             \
 
53
            '(*fp)->_ptr - (*fp)->_base'                        \
 
54
                                                                \
 
55
            '# e.g., DGUX R4.11; the info is not available'     \
 
56
            1                                                   \
 
57
            ; do
 
58
 
 
59
          # Skip each embedded comment.
 
60
          case "$ac_expr" in '#'*) continue;; esac
 
61
 
 
62
          AC_TRY_COMPILE(
 
63
            [#include <stdio.h>
 
64
            ],
 
65
            [FILE *fp = stdin; (void) ($ac_expr);],
 
66
            fp_done=yes
 
67
          )
 
68
          test "$fp_done" = yes && break
 
69
        done
 
70
 
 
71
        ac_cv_sys_pending_output_n_bytes=$ac_expr
 
72
      ]
 
73
    )
 
74
    AC_DEFINE_UNQUOTED(PENDING_OUTPUT_N_BYTES,
 
75
      $ac_cv_sys_pending_output_n_bytes,
 
76
      [the number of pending output bytes on stream `fp'])
 
77
  fi
 
78
])