diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-06-18 13:07:00 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-06-18 13:07:28 -0700 |
commit | f4c1d340533fb8ee5acf94e0da194433b8db628a (patch) | |
tree | e2731e783cb02a4e1b5db22d34afef205df2f042 | |
parent | 86725346a1b116f3c2da26c124288f5f4495bf69 (diff) | |
download | gnulib-f4c1d340533fb8ee5acf94e0da194433b8db628a.tar.gz |
fflush, fseeko: port to musl cross-compiles
* lib/fseeko.c (fseeko): Assume that fflushing stdin works if
on some implementation that (1) is not known to be buggy,
(2) claims conformance to POSIX.1-2008 or later, and (3) is being
cross-compiled to so we can't easily check for lack of
conformance. This is for cross-compiling to musl.
Reported by Rich Felker in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-06/msg00043.html>.
* m4/fclose.m4 (gl_FUNC_FCLOSE):
* m4/fflush.m4 (gl_FUNC_FFLUSH):
* m4/fseeko.m4 (gl_FUNC_FSEEKO):
Adjust to above change.
* m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Set gl_cv_func_fflush_stdin
to 'cross', not to 'no', when cross-compiling. AC_DEFINE
FUNC_FFLUSH_STDIN to 1, 0, -1 if fflushing stdin is known to work,
known not to work, or unknown.
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | lib/fseeko.c | 10 | ||||
-rw-r--r-- | m4/fclose.m4 | 4 | ||||
-rw-r--r-- | m4/fflush.m4 | 15 | ||||
-rw-r--r-- | m4/fseeko.m4 | 4 |
5 files changed, 42 insertions, 10 deletions
@@ -1,3 +1,22 @@ +2013-06-18 Paul Eggert <eggert@cs.ucla.edu> + + fflush, fseeko: port to musl cross-compiles + * lib/fseeko.c (fseeko): Assume that fflushing stdin works if + on some implementation that (1) is not known to be buggy, + (2) claims conformance to POSIX.1-2008 or later, and (3) is being + cross-compiled to so we can't easily check for lack of + conformance. This is for cross-compiling to musl. + Reported by Rich Felker in + <http://lists.gnu.org/archive/html/bug-gnulib/2013-06/msg00043.html>. + * m4/fclose.m4 (gl_FUNC_FCLOSE): + * m4/fflush.m4 (gl_FUNC_FFLUSH): + * m4/fseeko.m4 (gl_FUNC_FSEEKO): + Adjust to above change. + * m4/fflush.m4 (gl_FUNC_FFLUSH_STDIN): Set gl_cv_func_fflush_stdin + to 'cross', not to 'no', when cross-compiling. AC_DEFINE + FUNC_FFLUSH_STDIN to 1, 0, -1 if fflushing stdin is known to work, + known not to work, or unknown. + 2013-06-15 Paul Eggert <eggert@cs.ucla.edu> msvc-inval: port to mingw-w64 diff --git a/lib/fseeko.c b/lib/fseeko.c index a625803b95..ec5a6aacdd 100644 --- a/lib/fseeko.c +++ b/lib/fseeko.c @@ -19,7 +19,7 @@ /* Specification. */ #include <stdio.h> -/* Get off_t and lseek. */ +/* Get off_t, lseek, _POSIX_VERSION. */ #include <unistd.h> #include "stdio-impl.h" @@ -99,8 +99,14 @@ fseeko (FILE *fp, off_t offset, int whence) #elif defined EPLAN9 /* Plan9 */ if (fp->rp == fp->buf && fp->wp == fp->buf) +#elif FUNC_FFLUSH_STDIN < 0 && 200809 <= _POSIX_VERSION + /* Cross-compiling to some other system advertising conformance to + POSIX.1-2008 or later. Assume fseeko and fflush work as advertised. + If this assumption is incorrect, please report the bug to + bug-gnulib. */ + if (0) #else - #error "Please port gnulib fseeko.c to your platform! Look at the code in fpurge.c, then report this to bug-gnulib." + #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib." #endif { /* We get here when an fflush() call immediately preceded this one (or diff --git a/m4/fclose.m4 b/m4/fclose.m4 index 2cc2e12936..b306b6d48a 100644 --- a/m4/fclose.m4 +++ b/m4/fclose.m4 @@ -1,4 +1,4 @@ -# fclose.m4 serial 5 +# fclose.m4 serial 6 dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -9,7 +9,7 @@ AC_DEFUN([gl_FUNC_FCLOSE], AC_REQUIRE([gl_STDIO_H_DEFAULTS]) gl_FUNC_FFLUSH_STDIN - if test $gl_cv_func_fflush_stdin = no; then + if test $gl_cv_func_fflush_stdin != yes; then REPLACE_FCLOSE=1 fi diff --git a/m4/fflush.m4 b/m4/fflush.m4 index 6df5173681..c16b314e3c 100644 --- a/m4/fflush.m4 +++ b/m4/fflush.m4 @@ -1,4 +1,4 @@ -# fflush.m4 serial 14 +# fflush.m4 serial 15 # Copyright (C) 2007-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation @@ -14,7 +14,7 @@ AC_DEFUN([gl_FUNC_FFLUSH], [ AC_REQUIRE([gl_STDIO_H_DEFAULTS]) gl_FUNC_FFLUSH_STDIN - if test $gl_cv_func_fflush_stdin = no; then + if test $gl_cv_func_fflush_stdin != yes; then REPLACE_FFLUSH=1 fi ]) @@ -72,10 +72,17 @@ AC_DEFUN([gl_FUNC_FFLUSH_STDIN], return 7; return 0; ]])], [gl_cv_func_fflush_stdin=yes], [gl_cv_func_fflush_stdin=no], - [dnl Pessimistically assume fflush is broken. - gl_cv_func_fflush_stdin=no]) + [gl_cv_func_fflush_stdin=cross]) rm conftest.txt ]) + case $gl_cv_func_fflush_stdin in + yes) gl_func_fflush_stdin=1 ;; + no) gl_func_fflush_stdin=0 ;; + *) gl_func_fflush_stdin='(-1)' ;; + esac + AC_DEFINE_UNQUOTED([FUNC_FFLUSH_STDIN], [$gl_func_fflush_stdin], + [Define to 1 if fflush is known to work on stdin as per POSIX.1-2008, + 0 if fflush is known to not work, -1 if unknown.]) ]) # Prerequisites of lib/fflush.c. diff --git a/m4/fseeko.m4 b/m4/fseeko.m4 index e0f2dfbe1f..ca9da2835d 100644 --- a/m4/fseeko.m4 +++ b/m4/fseeko.m4 @@ -1,4 +1,4 @@ -# fseeko.m4 serial 16 +# fseeko.m4 serial 17 dnl Copyright (C) 2007-2013 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -37,7 +37,7 @@ AC_DEFUN([gl_FUNC_FSEEKO], fi m4_ifdef([gl_FUNC_FFLUSH_STDIN], [ gl_FUNC_FFLUSH_STDIN - if test $gl_cv_func_fflush_stdin = no; then + if test $gl_cv_func_fflush_stdin != yes; then REPLACE_FSEEKO=1 fi ]) |