~ubuntu-branches/ubuntu/intrepid/parted/intrepid

« back to all changes in this revision

Viewing changes to gnulib/m4/fflush.m4

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2008-06-24 14:31:05 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080624143105-rd7yw67a9qnvh51i
Tags: 1.8.8.git.2008.03.24-7ubuntu1
* Resynchronise with Debian (LP: #237568). Remaining changes:
  - swap-uuid.dpatch: Create UUIDs on new swap partitions.
  - gptsync.dpatch: On Intel Mac systems, write a synced MBR rather than a
    protective MBR.
  - Add -fno-stack-protector on sparc.
  - sparc-new-label.dpatch: Fix sparc disk label generation. This is
    required for LDOM and parallel installations with Solaris 10.
  - loop-partitions.dpatch: Loop devices can only have one partition, so
    don't generate device names such as "/dev/loop0p1".
  - unpartitioned-disks.dpatch: Don't try to call BLKPG ioctls on
    unpartitionable disks (only implemented for loop devices at the
    moment), as they will always fail.
  - When building with gcc-4.3, add -Wno-array-bounds to CFLAGS.
  - Cell partition tables are misdetected as pc98, so disable pc98 support
    on powerpc.
  - array-bounds.dpatch: Backport patch from git to allow building with
    gcc-4.3.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# fflush.m4 serial 4
 
2
 
 
3
# Copyright (C) 2007 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 Eric Blake
 
9
 
 
10
dnl Find out how to obey POSIX semantics of fflush(stdin) discarding
 
11
dnl unread input on seekable streams, rather than C99 undefined semantics.
 
12
 
 
13
AC_DEFUN([gl_FUNC_FFLUSH],
 
14
[
 
15
  AC_CACHE_CHECK([whether fflush works on input streams],
 
16
    [gl_cv_func_fflush_stdin],
 
17
    [echo hello world > conftest.txt
 
18
     AC_RUN_IFELSE([AC_LANG_PROGRAM(
 
19
       [[
 
20
#include <stdio.h>
 
21
#include <unistd.h>
 
22
       ]], [[FILE *f = fopen ("conftest.txt", "r");
 
23
         char buffer[10];
 
24
         int fd = fileno (f);
 
25
         if (!f || 0 > fd || fread (buffer, 1, 5, f) != 5)
 
26
           return 2;
 
27
         /* For deterministic results, ensure f read a bigger buffer.  */
 
28
         if (lseek (fd, 0, SEEK_CUR) == 5)
 
29
           return 3;
 
30
         /* POSIX requires fflush-fseek to set file offset of fd.  */
 
31
         if (fflush (f) != 0 || fseek (f, 0, SEEK_CUR) != 0)
 
32
           return 4;
 
33
         return !(lseek (fd, 0, SEEK_CUR) == 5);
 
34
       ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no],
 
35
     [dnl Pessimistically assume fflush is broken.  This is wrong for
 
36
      dnl at least glibc and cygwin; but lib/fflush.c takes this into account.
 
37
      gl_cv_func_fflush_stdin=no])
 
38
     rm conftest.txt
 
39
    ])
 
40
  if test $gl_cv_func_fflush_stdin = no; then
 
41
    gl_REPLACE_FFLUSH
 
42
  fi
 
43
])
 
44
 
 
45
AC_DEFUN([gl_REPLACE_FFLUSH],
 
46
[
 
47
  AC_LIBOBJ([fflush])
 
48
  AC_LIBOBJ([fseeko])
 
49
  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
 
50
  REPLACE_FFLUSH=1
 
51
  REPLACE_FSEEKO=1
 
52
])