Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120613225537.21acfd38@newbook>
Date: Wed, 13 Jun 2012 22:55:37 -0700
From: Isaac Dunham <idunham@...abit.com>
To: musl@...ts.openwall.com
Subject: Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs?

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@...hat.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@....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


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.