bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdioext on musl


From: Bruno Haible
Subject: Re: stdioext on musl
Date: Mon, 18 Jun 2012 02:59:56 +0200
User-agent: KMail/4.7.4 (Linux/3.1.10-1.9-desktop; KDE/4.7.4; x86_64; ; )

Rich Felker wrote:
> > This is not hypothetical at all. The __freading, __fwriting functions
> > exist in various libcs (glibc, Solaris, uClibc, musl). But only in musl
> > the value is different in some particular case. Therefore I ask you to
> 
> Would you mind telling me how it's different and how that's a problem?
> I meant for these functions to follow the traditional stdio_ext.h API,
> and if they're not doing the right thing I'd rather fix them than have
> ugly workarounds going into gnulib.

Sure. You can reproduce the issues by applying the patch I sent to a
gnulib checkout, then do
  $ ./gnulib-tool --create-testdir --dir=/tmp/testdir-stdioext --with-tests 
--single-configure --avoid=havelib-tests fseterr freadable fwritable fbufmode 
freading fwriting freadptr freadseek freadahead fpurge fseeko ftello fpending 
fflush
then
  $ cd /tmp/testdir-stdioext
  $ ./configure CC=musl-gcc CPPFLAGS=-Wall
  $ make
  $ make check


1) If I attempt to write

bool
freading (FILE *fp)
{
  return __freading (fp);
}

instead of the current code

bool
freading (FILE *fp)
{
  return !__fwritable (fp) || __freading (fp);
}

then I get the test failure

test-freading.c:48: assertion failed
FAIL: test-freading


2) Independently of 1): If I attempt to write

bool
fwriting (FILE *fp)
{
  return __fwriting (fp);
}

instead of the current code

bool
fwriting (FILE *fp)
{
  return !__freadable (fp) || __fwriting (fp);
}

then I get the test failure

test-fwriting.c:41: assertion failed
FAIL: test-fwriting


> Is the issue that you want __fwriting to return 1 even if there's no
> data buffered as long as the last action on the file was a write? If
> so, I think I can easily fix that.

For 2), the issue is that for a stream opened in write-only mode,
immediately after the fopen() call, gnulib expects fwriting(fp) to be
true:

  fp = fopen (TESTFILE, "w");
  if (fp == NULL)
    goto skip;
  ASSERT (fwriting (fp));  // <== test-fwriting.c line 41


Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]