[PATCH 2/2] Added support for compiling against Android bionic
Dan Fandrich
dan at coneharvesters.com
Tue May 31 06:14:35 UTC 2011
On Mon, May 30, 2011 at 07:48:05PM -0400, Rich Felker wrote:
> Plain ttyname could be used, I think. The only reason ttyname_r is
> used is to avoid enlarging bss for the nasty static buffer; it's not
> for reentrancy. This could also be done via HAVE_TTYNAME_R in
> platform.h rather than #ifndef ANDROID (see below)...
Ok, if reentrancy isn't an issue, I'll do that.
> > /* Try to pull in PAGE_SIZE */
> > #ifdef __linux__
> > -# include <sys/user.h>
> > +# ifdef ANDROID
> > +# include <sys/mman.h>
> > +# else
> > +# include <sys/user.h>
> > +# endif
>
> Why not get it from the correct place, limits.h? In case broken libs
> (glibc?) are missing it, you could do something like:
Is PAGE_SIZE mandated somewhere to be defined in limits.h? I tried
glibc, uclibc, libc5 and OpenWatcom (all on Linux) and none of them
defines it in limits.h.
> #include <limits.h>
> #ifndef PAGE_SIZE
> #include <sys/user.h>
> #endif
I changed it to basically follow this suggestion, and it's a bit harder to
follow now. But, it should stand up better with time.
> > --- a/libbb/obscure.c
> > +++ b/libbb/obscure.c
> > @@ -109,10 +109,12 @@ static const char *obscure_msg(const char *old_p, const char *new_p, const struc
> > if (string_checker(new_p, pw->pw_name)) {
> > return "similar to username";
> > }
> > +#ifndef ANDROID
> > /* no gecos as-is, as sub-string, reversed, capitalized, doubled */
> > if (pw->pw_gecos[0] && string_checker(new_p, pw->pw_gecos)) {
> > return "similar to gecos";
> > }
> > +#endif
>
> This is a really ugly legacy approach to "portability" and leads to
> spaghetti #ifdefs. Instead you should add HAVE_PW_GECOS or something
> and #undef it in platform.h for ANDROID. Basically, #ifdef SYSNAME or
> #ifndef SYSNAME should *never* appear outside of platform.h. Currently
> it does in many places, but this should be treated as a bug to be
> fixed, not a practice to be followed.
That ends up being more lines of code now, but it does make sense as
Busybox is now being ported to new platforms.
The conditional in networking/interface.c isn't as obvious. I tried removing
the UCLIBC clause altogether and it still compiled fine in uClibc 0.6.29,
so perhaps it dates from an earlier version and could just be removed now.
An updated patch is attached.
>>> Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-added-support-for-compiling-against-android-bionic.patch
Type: text/x-patch
Size: 4362 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20110530/e4b255b6/attachment.bin>
More information about the busybox
mailing list