Providing dprintf

Bernhard Fischer rep.nop at aon.at
Tue Oct 25 07:30:41 UTC 2005


On Mon, Oct 24, 2005 at 09:14:27PM -0500, Rob Landley wrote:
>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.

hm?
DEP_INCLUDES += include/automagic.h
nullify_automagic:
	-$(RM_F) include/automagic.h

include/automagic.h: nullify_automagic has_dprint has_whatever_additional_func

has_dprint:
	d=/tmp/$$busybox_dprintf.c ; ret=$(shell echo -e "#inc\ndprint(simple);" > $d && $(CC) -c $$d ; echo $?) ; if [ "x$ret" = "x0" ] ; then HAVE_DPRINT=1 ; fi
	[ $$HAVE_DPRINT -eq 1 ] && echo "#define HAVE_DPRINT 1" >> include/automagic.h || echo "#undef HAVE_DPRINT" >> include/automagic.h

and include it somewhere where the applets see the magic later on.
untested, but should allow us to get away without switching to autotools
just for dprint..

hth,
Bernhard

>
>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
>_______________________________________________
>busybox mailing list
>busybox at busybox.net
>http://busybox.net/cgi-bin/mailman/listinfo/busybox
>



More information about the busybox mailing list