mailing list of musl libc
 help / color / mirror / code / Atom feed
* stdio "ext2" functions
@ 2012-06-18 23:03 Rich Felker
  0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2012-06-18 23:03 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 2020 bytes --]

Hi all,

Here's a proposed "ext2.c" (no relation to the filesystem) containing
the 4 functions to make gnulib work without having to poke at
internals. It's pretty close to the version Bruno sent, even though I
just wrote it off the top of my head, since there's pretty much only
one way to write these functions. My versions might be a few bytes
smaller.

I know a few ppl have been pretty opposed to adding these functions,
but here's my logic:

1. We already discussed and decided to add __freadahead.

2. Each of the remaining 3 functions should be possible to implement
on any stdio implementation that actually uses userspace buffers, and
in a worst-case, __freadptr (and __freadptrinc) could be dummied
(always return NULL and force the caller to use standard functions)
without breaking anything. Therefore, committing to provide these
functions permanently as part of musl does not lock us into the
current implementation or prevent making internal changes.

3. Unless somebody wants to wage a publicity war against the gnulib
folks, not-implementing these functions is not going to keep things
clean on the gnulib side. It's just going to result in gnulib adding
musl-specific hacks that will be fragile and cause musl users no end
of grief.

4. Adding 54 bytes of code with minimal maintenance cost, even if it's
ideologically ugly code, puts us on the high ground in terms of being
reasonable and compromising. I don't believe this puts us in a
position of being subject to more and more irrational demands from the
gnulib ppl. I think it puts us in the opposite position: we've already
proven our willingness to work with projects, even distasteful ones,
when it's in the best interest of users. If/when they go trying to
hard-code soon-to-be-outdated knowledge about musl into gnulib and
breaking things, users/history will will them as the ones who screwed
up.

Comments are welcome, but I'd like to avoid a bikeshed discussion of
whether or not to do this unless you have real viable alternatives.

Rich

[-- Attachment #2: ext2.c --]
[-- Type: text/plain, Size: 337 bytes --]

#include "stdio_impl.h"

size_t __freadahead(FILE *f)
{
	return f->rend - f->rpos;
}

const char *__freadptr(FILE *f, size_t *sizep)
{
	size_t size = f->rend - f->rpos;
	if (!size) return 0;
	*sizep = size;
	return f->rpos;
}

void __freadptrinc(FILE *f, size_t inc)
{
	f->rpos += inc;
}

void __fseterr(FILE *f)
{
	f->flags |= F_ERR;
}

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-06-18 23:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-18 23:03 stdio "ext2" functions Rich Felker

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).