Providing dprintf

Rob Landley rob at landley.net
Tue Oct 25 02:14:27 UTC 2005


On Monday 24 October 2005 19:43, Shaun Jackman wrote:
> busybox provides vdprintf in vdprintf.c if __GLIBC__ < 2.  I'd like to
> modify vdprintf.c to provide both vdprintf and dprintf if necessary.
> Since both these functions are GNU glibc extensions and not defined by
> any standard (as far as I know), this addition would improve the
> portability of busybox.
>
> Without the use of autoconf though, I can't write a check for dprintf
> and provide it if the system does not. So, how do you suggest I go
> about conditionally providing dprintf?

Um.  Tough one.

We've pondered adding autoconf stuff before, but have generally shied away 
from the complexity without a _really_good_reason_.

Could do it as a config option, but it's the kind of horrible config option 
that people really shouldn't be confronted with in menuconfig.

> Cheers,
> Shaun
>
> note: As per usual, the purpose of this is to port busybox to newlib,
> which doesn't currently (1.13.0) provide dprintf or vdprintf, although
> there is a patch in CVS to add dprintf to newlib. I'd like to support
> the released version as well. Unfortunately, newlib doesn't provide a
> nice integer version symbol such as __GLIBC__. It provides
> _NEWLIB_VERSION, but it's a string (currently defined to "1.13.0").

Perhaps the makefile run sed against the thing and...  No.  Go down that path 
and we're reimplementing autoconf (badly) ourselves.

It would be really nice if you could submit a patch to the newlib CVS to fix 
the version thingy so there's something that C code can sanely test against.  
Then we could always do "#if defined(_NEWLIB_VERSION) 
&& !defined(newversionthingy)" and use that as a way of saying "you're using 
a newlib that's too old to tell _what_ version it is, so obviously it's older 
than 1.14, so it hasn't got dprintf."  As long as the ugliness is isolated in 
some kind of platform.h file so nobody else ever has to care (we're going to 
need one of those eventually, might as well start now), I'm all for it.

Or we could even say that busybox supports newlib but only version X and 
newer.  (Not exactly optimal, but really easy to do...)

Opinions?

Rob



More information about the busybox mailing list