[uClibc] sanitizing headers

Rogelio M.Serrano Jr. rogelio at smsglobal.net
Wed Nov 5 09:42:09 UTC 2003


I see. We need a header file dependency mapping tool then. This is 
interesting.
I have some ideas. I will see what i can do this weekend. Thanks! I 
surely want to help
cleaning up the headers.

On 2003-11-05 17:15:53 +0800 Erik Andersen <andersen at codepoet.org> 
wrote:

> On Wed Nov 05, 2003 at 04:09:07PM +0800, Rogelio M.Serrano Jr. wrote:
>> how do we go about sanitizing the headers? remove everything between 
>> ifdef 
>> KERNEL .. endif macros?
> 
> Not at all.
> 
> In fact, the include/linux/ stuff will probably remain as-is,
> just a copy taken from some random kernel tree.  But it will also
> be entirely unused except for naughty applications that include
> kernel headers.
> 
> Let me give you a few examples of what does need to be done.
> 
> When you compile an application using, say, limits.h (which most
> everything ends up including in some way or other), if you
> carefully check you will see the following chain of header files
> are loaded.
> 
> 	include/limits.h
> 	include/bits/posix1_lim.h
> 	include/bits/local_lim.h
> 	linux/limits.h
> 
> So even for something as simple as
> 	#include <limits.h>
> 
> the uClibc header files pull in kernel headers.  That is a bad
> thing.  In this case, include/bits/local_lim.h should be fixed to
> included the include/linux/limits.h since they are completely
> generic.
> 
> Similarly, include/netinet/if_ether.h, which includes
> linux/if_ether.h, can be fixed by merely copying the relevant
> bits from the Linux kernel header.
> Others require some scrubbing.  Take netinet/if_fddi.h for
> example.  It includes linux/if_fddi.h, which contains structures
> defined in terms of kernel specific types, i.e. __u8, __u16,
> __u32, etc.  All that stuff should be copied info
> netinet/if_fddi.h and then #include <stdint.h> should be added,
> and all the kernel types converted into C99 types, i.e.
> 	s/__u8/uint8_t/g
> 	s/__u16/uint16_t/g
> 	s/__u32/uint32_t/g
> etc.
> 
> To search for the most obvious offending uClibc header files
> just do a 'make clean; grep -lr include.*linux'
> 
> The hardest part is adapting the arch specific ABI stuff we
> obtain from include/asm/.  Everything under include/asm/ is a
> kernel header file, which often end up pulling in all sorts of
> additional kernel headers.  And worse, these files are not even
> very consistent between architectures.  Fixing these will have to
> be done on a per arch basis.  :-(
> 
> The idea is to add a uClibc/libc/sysdeps/linux/<arch>/asm/
> directory for each uClibc supported architecture.  That directory
> will then need to be populated using headers from the appropriate
> Linux kernel include/asm-<arch>/ directory.  I am not yet certain
> how much of the include/asm/ content is important, and how much
> is unnecessary....
> 
> -Erik
> 
> --
> Erik B. Andersen             http://codepoet-consulting.com/
> --This message was written using 73% post-consumer electrons--
> 




More information about the uClibc mailing list