mailing list of musl libc
 help / color / mirror / code / Atom feed
* Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs?
@ 2012-06-14  5:55 Isaac Dunham
  2012-06-15  2:14 ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Isaac Dunham @ 2012-06-14  5:55 UTC (permalink / raw)
  To: musl

Here's the latest re: getting gnulib to use something portable...

Begin forwarded message:

Date: Tue, 12 Jun 2012 13:30:45 +0200 
Subject: Re: Why require SLOW_BUT_NO_HACKS for stubs?


Il 12/06/2012 03:22, Isaac Dunham ha scritto:
>> > Performance, surely.  But if there's
>> > consensus that performance does not matter that
>> > much with musl, perhaps we should default to the
>> > slow version with musl.
> The test as it stands is "error out on unsupported platforms unless
> user specifies to use slow method".
> My proposal is "On unsupported platforms, use the slow method instead
> of erroring out."

I agree, downgrading to a #warning and removing SLOW_BUT_NO_HACKS
should be enough. That would be something like this, but it would fail
the tests.  What to do?

Paolo
------------ 8< ----------------

From e2aa7434ad06a0ec4e2c47b57564313d16561c14 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Tue, 12 Jun 2012 13:26:57 +0200
Subject: [PATCH 1/1] freadahead, freadptr, freadseek: Never fail
compilation

2012-06-12  Paolo Bonzini  <bonzini@gnu.org>

        * lib/freadahead.c [!SLOW_BUT_NO_HACKS]: Use the slow
          alternative, downgrading the #error to a #warning.
        * lib/freadptr.c [!SLOW_BUT_NO_HACKS]: Likewise.
        * lib/freadseek.c [!SLOW_BUT_NO_HACKS]: Likewise.
        * modules/freadahead: Depend on freading.
---
 lib/freadahead.c   |    9 +++++----
 lib/freadptr.c     |    5 ++---
 lib/freadseek.c    |    4 ++--
 modules/freadahead |    1 +
 4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/lib/freadahead.c b/lib/freadahead.c
index 2ba8b34..473911f 100644
--- a/lib/freadahead.c
+++ b/lib/freadahead.c
@@ -21,6 +21,7 @@
 
 #include <stdlib.h>
 #include "stdio-impl.h"
+#include "freading.h"
 
 size_t
 freadahead (FILE *fp)
@@ -84,10 +85,10 @@ freadahead (FILE *fp)
   if (fp->state == 4 /* WR */ || fp->rp >= fp->wp)
     return 0;
   return fp->wp - fp->rp;
-#elif defined SLOW_BUT_NO_HACKS     /* users can define this */
-  abort ();
-  return 0;
 #else
- #error "Please port gnulib freadahead.c to your platform! Look at the
definition of fflush, fread, ungetc on your system, then report this to
bug-gnulib."
+  /* This implementation is correct on any ANSI C platform.  It is just
+     awfully slow.  */
+  return freading(fp) && !feof(fp);
+ #warning "Please port gnulib freadahead.c to your platform! Look at
the definition of fflush, fread, ungetc on your system, then report
this to bug-gnulib." #endif }
diff --git a/lib/freadptr.c b/lib/freadptr.c
index 27c2285..325d91d 100644
--- a/lib/freadptr.c
+++ b/lib/freadptr.c
@@ -108,11 +108,10 @@ freadptr (FILE *fp, size_t *sizep)
     return NULL;
   *sizep = fp->wp - fp->rp;
   return fp->rp;
-#elif defined SLOW_BUT_NO_HACKS     /* users can define this */
+#else
   /* This implementation is correct on any ANSI C platform.  It is just
      awfully slow.  */
   return NULL;
-#else
- #error "Please port gnulib freadptr.c to your platform! Look at the
definition of fflush, fread, getc, getc_unlocked on your system, then
report this to bug-gnulib."
+ #warning "Please port gnulib freadptr.c to your platform! Look at the
definition of fflush, fread, getc, getc_unlocked on your system, then
report this to bug-gnulib." #endif }
diff --git a/lib/freadseek.c b/lib/freadseek.c
index 4145173..67de1c0 100644
--- a/lib/freadseek.c
+++ b/lib/freadseek.c
@@ -60,9 +60,9 @@ freadptrinc (FILE *fp, size_t increment)
   fp->__bufp += increment;
 #elif defined EPLAN9                /* Plan9 */
   fp->rp += increment;
-#elif defined SLOW_BUT_NO_HACKS     /* users can define this */
 #else
- #error "Please port gnulib freadseek.c to your platform! Look at the
definition of getc, getc_unlocked on your system, then report this to
bug-gnulib."
+  /* Doing nothing is fine on any ANSI C platform.  It is just awfully
slow.  */
+ #warning "Please port gnulib freadseek.c to your platform! Look at
the definition of getc, getc_unlocked on your system, then report this
to bug-gnulib." #endif }
 
diff --git a/modules/freadahead b/modules/freadahead
index 96ef2e8..4730695 100644
--- a/modules/freadahead
+++ b/modules/freadahead
@@ -8,6 +8,7 @@ lib/freadahead.c
 lib/stdio-impl.h
 
 Depends-on:
+freading
 
 configure.ac:
 
-- 
1.7.10.2




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs?
  2012-06-14  5:55 Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs? Isaac Dunham
@ 2012-06-15  2:14 ` Rich Felker
  2012-06-15  3:54   ` Isaac Dunham
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2012-06-15  2:14 UTC (permalink / raw)
  To: musl

On Wed, Jun 13, 2012 at 10:55:37PM -0700, Isaac Dunham wrote:
> Here's the latest re: getting gnulib to use something portable...

Thanks.

> > The test as it stands is "error out on unsupported platforms unless
> > user specifies to use slow method".
> > My proposal is "On unsupported platforms, use the slow method instead
> > of erroring out."
> 
> I agree, downgrading to a #warning and removing SLOW_BUT_NO_HACKS
> should be enough. That would be something like this, but it would fail
> the tests.  What to do?
> 
> Paolo

Do you know what he's talking about for failing the tests?

> diff --git a/lib/freadahead.c b/lib/freadahead.c
> index 2ba8b34..473911f 100644
> --- a/lib/freadahead.c
> +++ b/lib/freadahead.c
> @@ -21,6 +21,7 @@
>  
> [...]
> +  /* This implementation is correct on any ANSI C platform.  It is just
> +     awfully slow.  */
> +  return freading(fp) && !feof(fp);

This can definitely return 1 when no data is buffered, and when read
would block, on some platforms. I think that could break some
applications using the interface.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs?
  2012-06-15  2:14 ` Rich Felker
@ 2012-06-15  3:54   ` Isaac Dunham
  0 siblings, 0 replies; 3+ messages in thread
From: Isaac Dunham @ 2012-06-15  3:54 UTC (permalink / raw)
  To: musl

On Thu, 14 Jun 2012 22:14:44 -0400
Rich Felker <dalias@aerifal.cx> wrote:

> On Wed, Jun 13, 2012 at 10:55:37PM -0700, Isaac Dunham wrote:
> > Here's the latest re: getting gnulib to use something portable...  
> 
> Thanks.
> 
> > > The test as it stands is "error out on unsupported platforms
> > > unless user specifies to use slow method".
> > > My proposal is "On unsupported platforms, use the slow method
> > > instead of erroring out."  
> > 
> > I agree, downgrading to a #warning and removing SLOW_BUT_NO_HACKS
> > should be enough. That would be something like this, but it would
> > fail the tests.  What to do?

> Do you know what he's talking about for failing the tests?
Not a clue. 

> > diff --git a/lib/freadahead.c b/lib/freadahead.c
> > index 2ba8b34..473911f 100644
> > --- a/lib/freadahead.c
> > +++ b/lib/freadahead.c
> > @@ -21,6 +21,7 @@
> >  
> > [...]
> > +  /* This implementation is correct on any ANSI C platform.  It is
> > just
> > +     awfully slow.  */
> > +  return freading(fp) && !feof(fp);  
> 
> This can definitely return 1 when no data is buffered, and when read
> would block, on some platforms. I think that could break some
> applications using the interface.
I ought to mention that over there...

Thanks,
Isaac Dunham



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-06-15  3:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-14  5:55 Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs? Isaac Dunham
2012-06-15  2:14 ` Rich Felker
2012-06-15  3:54   ` Isaac Dunham

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).