[PATCH 2/2] Added support for compiling against Android bionic

Tito farmatito at tiscali.it
Tue May 31 06:07:34 UTC 2011



On Tuesday 31 May 2011 01:48:05 Rich Felker wrote:
> On Mon, May 30, 2011 at 02:05:13PM -0700, Dan Fandrich wrote:
> > It's not easy compiling something against bionic using the
> > Android compiler outside the Android build system, but it can
> > at least now happen.
> > 
> > Signed-off-by: Dan Fandrich <dan at coneharvesters.com>
> > ---
> > Conditionally compiling xmalloc_ttyname() is a bit ugly, but necessary
> > since bionic doesn't have ttyname_r.
> 
> 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)...

from bionic libc

char* ttyname(int fd)
{
    fprintf(stderr, "FIX ME! implement ttyname() %s:%d\n", __FILE__, __LINE__);
    return NULL;
}

int ttyname_r(int fd, char *buf, size_t buflen)
{
    fprintf(stderr, "FIX ME! implement ttyname_r() %s:%d\n", __FILE__, __LINE__);
    return -ERANGE;
}

> >  /* 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:
> 
> #include <limits.h>
> #ifndef PAGE_SIZE
> #include <sys/user.h>
> #endif
> 
> > --- 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.
> 
> Rich
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
> 



More information about the busybox mailing list