From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3442 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.comp.lib.gnulib.bugs,gmane.linux.lib.musl.general Subject: Re: gnulib cross-compiling issue with musl Date: Tue, 18 Jun 2013 13:09:10 -0700 Message-ID: <51C0BE66.5000402@cs.ucla.edu> References: <20130618170305.GA30936@brightrain.aerifal.cx> <51C09BD9.8000503@cs.ucla.edu> <20130618180755.GV29800@brightrain.aerifal.cx> <51C0A7D2.4020605@cs.ucla.edu> <20130618184224.GW29800@brightrain.aerifal.cx> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1371586166 15546 80.91.229.3 (18 Jun 2013 20:09:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 18 Jun 2013 20:09:26 +0000 (UTC) Cc: musl@lists.openwall.com, bug-gnulib@gnu.org, Eric Blake To: Rich Felker Original-X-From: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane.org@gnu.org Tue Jun 18 22:09:27 2013 Return-path: Envelope-to: gnu-bug-gnulib@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Up2DP-0000s0-Id for gnu-bug-gnulib@m.gmane.org; Tue, 18 Jun 2013 22:09:19 +0200 Original-Received: from localhost ([::1]:39056 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Up2DP-0001eR-4t for gnu-bug-gnulib@m.gmane.org; Tue, 18 Jun 2013 16:09:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48853) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Up2DK-0001eD-46 for bug-gnulib@gnu.org; Tue, 18 Jun 2013 16:09:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Up2DI-0004tk-BS for bug-gnulib@gnu.org; Tue, 18 Jun 2013 16:09:14 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:51118) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Up2DI-0004tg-3Q for bug-gnulib@gnu.org; Tue, 18 Jun 2013 16:09:12 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 4ADBBA60001; Tue, 18 Jun 2013 13:09:11 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6s9euYyN4ty0; Tue, 18 Jun 2013 13:09:10 -0700 (PDT) Original-Received: from penguin.cs.ucla.edu (Penguin.CS.UCLA.EDU [131.179.64.200]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 76D6F39E8105; Tue, 18 Jun 2013 13:09:10 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 In-Reply-To: <20130618184224.GW29800@brightrain.aerifal.cx> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 131.179.128.62 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane.org@gnu.org Original-Sender: bug-gnulib-bounces+gnu-bug-gnulib=m.gmane.org@gnu.org Xref: news.gmane.org gmane.comp.lib.gnulib.bugs:32949 gmane.linux.lib.musl.general:3442 Archived-At: On 06/18/13 11:42, Rich Felker wrote: > if > you think it matters, you could add #elif defined _POSIX_VERSION > containing the if(0) Yes, that should work, though it needs to check a couple ore things as well. I pushed the following: does it work for you? 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 . * 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. diff --git a/lib/fseeko.c b/lib/fseeko.c index a625803..ec5a6aa 100644 --- a/lib/fseeko.c +++ b/lib/fseeko.c @@ -19,7 +19,7 @@ /* Specification. */ #include -/* Get off_t and lseek. */ +/* Get off_t, lseek, _POSIX_VERSION. */ #include #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 2cc2e12..b306b6d 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 6df5173..c16b314 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 e0f2dfb..ca9da28 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 ])