mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Isaac Dunham <idunham@lavabit.com>
To: musl@lists.openwall.com
Subject: Fw: [buggnulib]Why require SLOW_BUT_NO_HACKS for stubs?
Date: Wed, 13 Jun 2012 22:55:37 -0700	[thread overview]
Message-ID: <20120613225537.21acfd38@newbook> (raw)

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




             reply	other threads:[~2012-06-14  5:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  5:55 Isaac Dunham [this message]
2012-06-15  2:14 ` Rich Felker
2012-06-15  3:54   ` Isaac Dunham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120613225537.21acfd38@newbook \
    --to=idunham@lavabit.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).