[uClibc]proposal -- feedback requested

Manuel Novoa III mnovoa3 at bellsouth.net
Tue Jan 23 19:39:09 UTC 2001


Erik and other uClibc users,

I'd like to get some feedback on the following idea:

Right now there are certain "problem headers" in uClibc/linux that test for the
macro __GLIBC__ and it value, and modify their behavior based on that.
For 2.2.19pre7, find /usr/include/linux/ -name "*.h" | xargs grep __GLIBC__
gives:

/usr/include/linux/loop.h:#if __GLIBC__ >= 2 && !defined(dev_t)
/usr/include/linux/socket.h:#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
/usr/include/linux/socket.h:#if !defined(__KERNEL__) && (!defined(__GLIBC__) || (__GLIBC__ < 2))
/usr/include/linux/stat.h:#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
/usr/include/linux/coda.h:#if !defined(_UQUAD_T_) && (!defined(__GLIBC__) || __GLIBC__ < 2)
/usr/include/linux/byteorder/generic.h:#if defined(__KERNEL__) || (defined (__GLIBC__) && __GLIBC__ >= 2)
/usr/include/linux/byteorder/generic.h:#if defined(__KERNEL__) || (defined (__GLIBC__) && __GLIBC__ >= 2)

This has resulted in cases of duplicate macro definitions when compiling
packages (such as e2fsprogs).  The solution I'm considering is to create a
directories uClibc/include/_uClibc (name is just a placeholder -- I'm open to
better suggestions) and uClibc/include/_uClibc/linux and "wrap" the problem
kernel header files in the latter; for example:

uClibc/include/_uClibc/linux/stat.h

#ifndef __GLIBC__
/* Normal case -- not using glibc but want to emulate its behavior. */
#define __GLIBC__ 2
#include "../../linux/stat.h"
#undef __GLIBC__
#else
/* Should we warn instead, and just include the kernel header? */
#error __GLIBC__ is defined!
#endif

Then, all we have to do is insert uClibc/include/_uClibc as the first directory
in the include search order in CCFLAGS of Rules.mak and modify gcc-uClibc
slightly.

Does anyone have a better idea on how to get around this tie between the kernel
headers and glibc?

On a related topic, I'd like to generate a header file describing the
build-time configurate of uClibc that apps can check.  I was thinking of
uClibc/include/uClibc_config.h?  Again, I'm open to suggestions for a name.

Manuel










More information about the uClibc mailing list