2006-12-16 18:42:15

by Mike Frysinger

[permalink] [raw]
Subject: [patch] scrub non-__GLIBC__ checks in linux/socket.h and linux/stat.h

On 11/30/06, Robert P. J. Day <[email protected]> wrote:
> but there are a few other
> cases which still contain compound preprocessor directives such as:
>
> #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
>
> having never worked with unifdef before, i guess i was being overly
> optimistic in thinking that it, if i "unifdef"ed __KERNEL__, it might
> at least simplify the expression. oh, well ... live and learn.

userspace should be worrying about userspace, so having the socket.h
and stat.h pollute the namespace in the non-glibc case is wrong and
pretty much prevents any other libc from utilizing these headers
sanely unless they set up the __GLIBC__ define themselves (which
sucks)
-mike


Attachments:
(No filename) (722.00 B)
linux-scrub-GLIBC-ifdefs.patch (729.00 B)
Download all attachments

2006-12-16 18:57:28

by Erik Andersen

[permalink] [raw]
Subject: Re: [patch] scrub non-__GLIBC__ checks in linux/socket.h and linux/stat.h

On Sat Dec 16, 2006 at 01:42:11PM -0500, Mike Frysinger wrote:
> On 11/30/06, Robert P. J. Day <[email protected]> wrote:
> >but there are a few other
> >cases which still contain compound preprocessor directives such as:
> >
> > #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
> >
> >having never worked with unifdef before, i guess i was being overly
> >optimistic in thinking that it, if i "unifdef"ed __KERNEL__, it might
> >at least simplify the expression. oh, well ... live and learn.
>
> userspace should be worrying about userspace, so having the socket.h
> and stat.h pollute the namespace in the non-glibc case is wrong and
> pretty much prevents any other libc from utilizing these headers
> sanely unless they set up the __GLIBC__ define themselves (which
> sucks)
> -mike

Ack from me. I'd love to see this applied so uClibc could
stop have to define __GLIBC__

-Erik

--
Erik B. Andersen http://codepoet-consulting.com/
--This message was written using 73% post-consumer electrons--

2007-01-25 06:30:46

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [patch] scrub non-__GLIBC__ checks in linux/socket.h and linux/stat.h

Erik Andersen wrote:
> On Sat Dec 16, 2006 at 01:42:11PM -0500, Mike Frysinger wrote:
>> On 11/30/06, Robert P. J. Day <[email protected]> wrote:
>>> but there are a few other
>>> cases which still contain compound preprocessor directives such as:
>>>
>>> #if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2)
>>>
>>> having never worked with unifdef before, i guess i was being overly
>>> optimistic in thinking that it, if i "unifdef"ed __KERNEL__, it might
>>> at least simplify the expression. oh, well ... live and learn.
>> userspace should be worrying about userspace, so having the socket.h
>> and stat.h pollute the namespace in the non-glibc case is wrong and
>> pretty much prevents any other libc from utilizing these headers
>> sanely unless they set up the __GLIBC__ define themselves (which
>> sucks)
>> -mike
>
> Ack from me. I'd love to see this applied so uClibc could
> stop have to define __GLIBC__
>

klibc uses these definitions, but the right thing to do is to have libc
ask for it:

#if defined(__KERNEL__) || defined(__EXPORT_LINUX_SOCKET_H)

/* ... */

#endif

That way, klibc can just

#define __EXPORT_LINUX_SOCKET_H
#include <linux/socket.h>

-hpa