Re: [klibc] [patch] import socket defines

2008-01-11 Thread H. Peter Anvin

Mike Frysinger wrote:
all this stuff is ABI constants, and the only reason glibc 
doesn't use them is that glibc prefers to use enums over #defines.


a proper libc defines things in their headers according to the POSIX specs 
rather than relying on others to do it for them.  if you want to argue about 
linux-specific ABI pieces being exported, then you probably have a valid 
point, but socket.h is hardly that.


Have you looked at it?!!?  It's full of ABI constants, and that's what I 
care about.  POSIX doesn't define, say, AF_UNIX; that's an ABI specific.


so if the only consumer is klibc and you're against adding these things to it, 
special case it for __KLIBC__.


No, let's split the header so that there are *no* libc knowledge in the 
kernel.  For the kernel to have knowledge about the specifics of any 
particular libc (klibc, glibc, or any other) is stupid, and that's the 
whole reason we're in this spot to begin with.


Again, I don't particularly care about what they're named, but the whole 
point is


#include linux/foo.h

if you want the subset and

#include linux/bar.h

if you want the whole set.

No libc specifics, and no feature test macros, which I think we can both 
agree are uglier than hell.


I thought the naming worked out nicer with linux/sockaddr.h, but I 
*don't really care*.


-hpa
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-11 Thread Mike Frysinger
On Friday 11 January 2008, H. Peter Anvin wrote:
 Mike Frysinger wrote:
  all this stuff is ABI constants, and the only reason glibc
  doesn't use them is that glibc prefers to use enums over #defines.
 
  a proper libc defines things in their headers according to the POSIX
  specs rather than relying on others to do it for them.  if you want to
  argue about linux-specific ABI pieces being exported, then you probably
  have a valid point, but socket.h is hardly that.

 Have you looked at it?!!?  It's full of ABI constants, and that's what I
 care about.  POSIX doesn't define, say, AF_UNIX; that's an ABI specific.

i guess it depends on how you define define :P.  no, POSIX does not state 
the specific numerical value (ABI) for the define (API), but POSIX does 
require sys/socket.h provide the macro AF_UNIX.

  so if the only consumer is klibc and you're against adding these things
  to it, special case it for __KLIBC__.

 No, let's split the header so that there are *no* libc knowledge in the
 kernel.  For the kernel to have knowledge about the specifics of any
 particular libc (klibc, glibc, or any other) is stupid, and that's the
 whole reason we're in this spot to begin with.

we're in this spot at the moment to appease klibc only.  is there any other 
libc out there that is not providing its own complete sys/socket.h but 
instead relying on linux/socket.h ?  glibc/uClibc rely on linux/socket.h only 
for the kernel's definition of sockaddr.

 Again, I don't particularly care about what they're named, but the whole
 point is

   #include linux/foo.h

 if you want the subset and

   #include linux/bar.h

 if you want the whole set.

i looked more at glibc/uClibc and my primary/original concern (and what i 
thought what David was raising and you confirming) was that building of glibc 
was broken and glibc headers would need updates.  that does not seem to be 
the case.  the breakage here is for packages that include both sys/socket.h 
(directly/indirectly) and linux/socket.h (directly/indirectly).

due to the way the network headers depend on each other, this case is trivial 
to induce.  but i dont think linux/socket.h is any more special than the 
current retarded conflicts we have between the network headers from the libc 
(which are required by POSIX and beyond) and the kernel headers.

 No libc specifics, and no feature test macros, which I think we can both
 agree are uglier than hell.

i think in general, all of the network related headers under linux/ are 
fubared for userspace.

 I thought the naming worked out nicer with linux/sockaddr.h

placing the sockaddr definitions into linux/sockaddr.h makes sense.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [klibc] [patch] import socket defines

2008-01-11 Thread Mike Frysinger
On Friday 11 January 2008, Mike Frysinger wrote:
 On Friday 11 January 2008, H. Peter Anvin wrote:
  Again, I don't particularly care about what they're named, but the whole
  point is
 
  #include linux/foo.h
 
  if you want the subset and
 
  #include linux/bar.h
 
  if you want the whole set.

 i looked more at glibc/uClibc and my primary/original concern (and what i
 thought what David was raising and you confirming) was that building of
 glibc was broken and glibc headers would need updates.  that does not seem
 to be the case.  the breakage here is for packages that include both
 sys/socket.h (directly/indirectly) and linux/socket.h
 (directly/indirectly).

 due to the way the network headers depend on each other, this case is
 trivial to induce.  but i dont think linux/socket.h is any more special
 than the current retarded conflicts we have between the network headers
 from the libc (which are required by POSIX and beyond) and the kernel
 headers.

  No libc specifics, and no feature test macros, which I think we can both
  agree are uglier than hell.

 i think in general, all of the network related headers under linux/ are
 fubared for userspace.

  I thought the naming worked out nicer with linux/sockaddr.h

 placing the sockaddr definitions into linux/sockaddr.h makes sense.

so there's no confusion, since the building of the libc itself and using pure 
libc headers are generally unaffected, and all of the network linux headers 
are already screwed for userspace usage, i'm not against the proposed change 
from Peter.  it doesnt really make the situation any better/worse.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [klibc] [patch] import socket defines

2008-01-10 Thread David Miller
From: H. Peter Anvin [EMAIL PROTECTED]
Date: Wed, 02 Jan 2008 10:09:56 -0800

 Seems the most logical thing to do would be to break out the small 
 portion that everyone wants into linux/sockaddr.h or somesuch, and 
 then remove those ifdefs entirely.
 
 Proposed patch (still being tested) attached...

I think this would clearly break existing glibc builds.

I agree with fixing the ifdef checks, but not like this.
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-10 Thread Mike Frysinger
On Friday 11 January 2008, David Miller wrote:
 From: H. Peter Anvin [EMAIL PROTECTED]
  Seems the most logical thing to do would be to break out the small
  portion that everyone wants into linux/sockaddr.h or somesuch, and
  then remove those ifdefs entirely.
 
  Proposed patch (still being tested) attached...

 I think this would clearly break existing glibc builds.

 I agree with fixing the ifdef checks, but not like this.

how ?  the large crap in linux/socket.h never made it into glibc builds, and 
the few things at the top which were relocated to linux/sockaddr.h are still 
pulled in via linux/socket.h.  for glibc, the resulting '#include 
linux/socket.h' should be unchanged.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [klibc] [patch] import socket defines

2008-01-10 Thread H. Peter Anvin

Mike Frysinger wrote:

On Friday 11 January 2008, David Miller wrote:

From: H. Peter Anvin [EMAIL PROTECTED]

Seems the most logical thing to do would be to break out the small
portion that everyone wants into linux/sockaddr.h or somesuch, and
then remove those ifdefs entirely.

Proposed patch (still being tested) attached...

I think this would clearly break existing glibc builds.

I agree with fixing the ifdef checks, but not like this.


how ?  the large crap in linux/socket.h never made it into glibc builds, and 
the few things at the top which were relocated to linux/sockaddr.h are still 
pulled in via linux/socket.h.  for glibc, the resulting '#include 
linux/socket.h' should be unchanged.


The problem is that there isn't any way to do this without breaking 
*something*, since the fundamental problem is that userspace doesn't ask 
for what it wants, so the kernel is expected to figure it out.


We can either change the way glibc includes the kernel headers, or the 
way everything else does.  The latter should really include the kernel, 
although there is the hack of


/* linux/socket.h */

/* sockaddr stuff */

#ifdef __KERNEL__
# include linux/socket2.h
#endif

The reason I went the direction I did was that it looked like the end 
result was cleaner.


-hpa
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-10 Thread David Miller
From: Mike Frysinger [EMAIL PROTECTED]
Date: Fri, 11 Jan 2008 01:23:37 -0500

 On Friday 11 January 2008, David Miller wrote:
  From: H. Peter Anvin [EMAIL PROTECTED]
   Seems the most logical thing to do would be to break out the small
   portion that everyone wants into linux/sockaddr.h or somesuch, and
   then remove those ifdefs entirely.
  
   Proposed patch (still being tested) attached...
 
  I think this would clearly break existing glibc builds.
 
  I agree with fixing the ifdef checks, but not like this.
 
 how ?  the large crap in linux/socket.h never made it into glibc builds, and 
 the few things at the top which were relocated to linux/sockaddr.h are still 
 pulled in via linux/socket.h.  for glibc, the resulting '#include 
 linux/socket.h' should be unchanged.

Hmmm...

Doesn't glibc include linux/socket.h?  If so, before it wouldn't get
the sa_family_t et al. defines (because __GLIBC__ will be defined and
it will be = 2), but with your change it get those things.

Correct me if I'm wrong.

Thanks.
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-10 Thread H. Peter Anvin

David Miller wrote:


Hmmm...

Doesn't glibc include linux/socket.h?  If so, before it wouldn't get
the sa_family_t et al. defines (because __GLIBC__ will be defined and
it will be = 2), but with your change it get those things.

Correct me if I'm wrong.



At the moment, yes, it does.

-hpa

--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-10 Thread Mike Frysinger
On Friday 11 January 2008, David Miller wrote:
 From: Mike Frysinger [EMAIL PROTECTED]
 Date: Fri, 11 Jan 2008 01:23:37 -0500

  On Friday 11 January 2008, David Miller wrote:
   From: H. Peter Anvin [EMAIL PROTECTED]
  
Seems the most logical thing to do would be to break out the small
portion that everyone wants into linux/sockaddr.h or somesuch, and
then remove those ifdefs entirely.
   
Proposed patch (still being tested) attached...
  
   I think this would clearly break existing glibc builds.
  
   I agree with fixing the ifdef checks, but not like this.
 
  how ?  the large crap in linux/socket.h never made it into glibc builds,
  and the few things at the top which were relocated to linux/sockaddr.h
  are still pulled in via linux/socket.h.  for glibc, the resulting
  '#include linux/socket.h' should be unchanged.

 Hmmm...

 Doesn't glibc include linux/socket.h?  If so, before it wouldn't get
 the sa_family_t et al. defines (because __GLIBC__ will be defined and
 it will be = 2), but with your change it get those things.

oh, sorry, i see what you mean.  i was thinking in terms of crap removed (as 
that's what i'm after), not crap added (which is what Peter is after).  i 
hadnt noticed that.  i dont know if it'll break glibc (and really, any other 
sane libc).  if that is the case, then i think klibc here is the 2nd class 
citizen to everyone else.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [klibc] [patch] import socket defines

2008-01-10 Thread H. Peter Anvin

Mike Frysinger wrote:
oh, sorry, i see what you mean.  i was thinking in terms of crap removed (as 
that's what i'm after), not crap added (which is what Peter is after).  i 
hadnt noticed that.  i dont know if it'll break glibc (and really, any other 
sane libc).  if that is the case, then i think klibc here is the 2nd class 
citizen to everyone else.


I don't really understand why you insist on using such inflammatory 
language; all this stuff is ABI constants, and the only reason glibc 
doesn't use them is that glibc prefers to use enums over #defines.


Right now, glibc is special-cased.  glibc also tends to be very 
deliberate about its kernel header inclusions.  It wants a subset of the 
available defines, so it can include a subset header.


The reverse is definitely possible too -- all other users (kernel, 
newlib, dietlibc, uclibc, and klibc) can change and leave the current 
state for glibc.


We can special-case the kernel in the above case, but that would involve 
some additional ugliness.


-hpa
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-10 Thread H. Peter Anvin

H. Peter Anvin wrote:


Right now, glibc is special-cased.  glibc also tends to be very 
deliberate about its kernel header inclusions.  It wants a subset of the 
available defines, so it can include a subset header.


The reverse is definitely possible too -- all other users (kernel, 
newlib, dietlibc, uclibc, and klibc) can change and leave the current 
state for glibc.


We can special-case the kernel in the above case, but that would involve 
some additional ugliness.




Just to clarify: I don't have any strong opinions for any particular 
option -- I'm fine with either.  I'd just like to get rid of the 
ugliness of having #defines for any particular user spaces, and I'd 
prefer two include files over feature test macros.


-hpa
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [klibc] [patch] import socket defines

2008-01-10 Thread Mike Frysinger
On Friday 11 January 2008, H. Peter Anvin wrote:
 Mike Frysinger wrote:
  oh, sorry, i see what you mean.  i was thinking in terms of crap removed
  (as that's what i'm after), not crap added (which is what Peter is
  after).  i hadnt noticed that.  i dont know if it'll break glibc (and
  really, any other sane libc).  if that is the case, then i think klibc
  here is the 2nd class citizen to everyone else.

 I don't really understand why you insist on using such inflammatory
 language;

it's true.  it is much easier to adapt klibc on the fly than every one else.  
klibc is also of significant less importance in the larger open source 
landscape than glibc or other libc's.  this isnt really inflammatory so much 
as fact.

 all this stuff is ABI constants, and the only reason glibc 
 doesn't use them is that glibc prefers to use enums over #defines.

a proper libc defines things in their headers according to the POSIX specs 
rather than relying on others to do it for them.  if you want to argue about 
linux-specific ABI pieces being exported, then you probably have a valid 
point, but socket.h is hardly that.  imo klibc is being lazy.  you disagree.  
here we are.

 Right now, glibc is special-cased.  glibc also tends to be very
 deliberate about its kernel header inclusions.  It wants a subset of the
 available defines, so it can include a subset header.

 The reverse is definitely possible too -- all other users (kernel,
 newlib, dietlibc, uclibc, and klibc) can change and leave the current
 state for glibc.

that list is inaccurate.  newlib is generally not used under linux, but of the 
few headers it does use, socket.h is not one of them.

i dont use dietlibc myself as ive found it generally not suitable for much, 
but a quick look through their source code shows linux/socket.h not in use at 
all.

uClibc is the exact reason i started this thread in the first place.  we have 
__GLIBC__ define in place to account for broken code and it's because of 
things like linux/socket.h that we cannot yet remove it.

glibc has not used the typedefs/defines in question in ages, so they're not 
affected by the things not being available.

that leaves klibc.

 We can special-case the kernel in the above case, but that would involve
 some additional ugliness.

so if the only consumer is klibc and you're against adding these things to it, 
special case it for __KLIBC__.
-mike


signature.asc
Description: This is a digitally signed message part.


Re: [klibc] [patch] import socket defines

2008-01-02 Thread H. Peter Anvin

Mike Frysinger wrote:

On Tuesday 01 January 2008, H. Peter Anvin wrote:

Mike Frysinger wrote:

The kernel __GLIBC__ hacks were re-added so as to appease klibc people,
but the klibc people didnt actually fix the problem on their side.  This
patch imports the structures/defines that klibc seems to need.  Build
tested on x86_64 (i dont actually use klibc so no idea how to test it).

The whole point was to NOT need to replicate all these structures and
constants, which are part of the ABI, in klibc...


then figure out a way that doesnt make the kernel headers blow for everyone 
else out there.  change the __GLIBC__ crap to __KLIBC__ or something.


Seems the most logical thing to do would be to break out the small 
portion that everyone wants into linux/sockaddr.h or somesuch, and 
then remove those ifdefs entirely.


Proposed patch (still being tested) attached...

-hpa
From 727c56ac213bdaedb9247c442375a5979686acf5 Mon Sep 17 00:00:00 2001
From: H. Peter Anvin [EMAIL PROTECTED]
Date: Wed, 2 Jan 2008 10:08:16 -0800
Subject: [PATCH] linux/socket.h: break out glibc portions into linux/sockaddr.h

Some userspaces (e.g. klibc) want to be able to use the full set of
ABI constants in linux/socket.h, others (e.g. glibc) do not, and
rather want just the bare minimum to build a kernel-valid
sockaddr... but apparently they want that much.  This is currently
keyed on the existence of __GLIBC__, which is clearly wrong.

This patch breaks out the bare minimum into linux/sockaddr.h for
the userspaces who want to do it themselves, and eliminates the
ifdefs completely.

Signed-off-by: H. Peter Anvin [EMAIL PROTECTED]
---
 include/linux/Kbuild |1 +
 include/linux/sockaddr.h |   19 +++
 include/linux/socket.h   |   21 ++---
 3 files changed, 22 insertions(+), 19 deletions(-)
 create mode 100644 include/linux/sockaddr.h

diff --git a/include/linux/Kbuild b/include/linux/Kbuild
index f30fa92..f8bbb31 100644
--- a/include/linux/Kbuild
+++ b/include/linux/Kbuild
@@ -139,6 +139,7 @@ header-y += rose.h
 header-y += serial_reg.h
 header-y += smbno.h
 header-y += snmp.h
+header-y += sockaddr.h
 header-y += sockios.h
 header-y += som.h
 header-y += sound.h
diff --git a/include/linux/sockaddr.h b/include/linux/sockaddr.h
new file mode 100644
index 000..f182083
--- /dev/null
+++ b/include/linux/sockaddr.h
@@ -0,0 +1,19 @@
+#ifndef _KERNEL_SOCKADDR_H
+#define _KERNEL_SOCKADDR_H
+
+/*
+ * Desired design of maximum size and alignment (see RFC2553)
+ */
+#define _K_SS_MAXSIZE	128	/* Implementation specific max size */
+#define _K_SS_ALIGNSIZE	(__alignof__ (struct sockaddr *))
+/* Implementation specific desired alignment */
+
+struct __kernel_sockaddr_storage {
+	unsigned short	ss_family;		/* address family */
+	/* Following field(s) are implementation specific */
+	char		__data[_K_SS_MAXSIZE - sizeof(unsigned short)];
+/* space to achieve desired size, */
+/* _SS_MAXSIZE value minus size of ss_family */
+} __attribute__ ((aligned(_K_SS_ALIGNSIZE)));	/* force desired alignment */
+
+#endif /* _KERNEL_SOCKADDR_H */
diff --git a/include/linux/socket.h b/include/linux/socket.h
index c22ef1c..9cd6edc 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -1,23 +1,7 @@
 #ifndef _LINUX_SOCKET_H
 #define _LINUX_SOCKET_H
 
-/*
- * Desired design of maximum size and alignment (see RFC2553)
- */
-#define _K_SS_MAXSIZE	128	/* Implementation specific max size */
-#define _K_SS_ALIGNSIZE	(__alignof__ (struct sockaddr *))
-/* Implementation specific desired alignment */
-
-struct __kernel_sockaddr_storage {
-	unsigned short	ss_family;		/* address family */
-	/* Following field(s) are implementation specific */
-	char		__data[_K_SS_MAXSIZE - sizeof(unsigned short)];
-/* space to achieve desired size, */
-/* _SS_MAXSIZE value minus size of ss_family */
-} __attribute__ ((aligned(_K_SS_ALIGNSIZE)));	/* force desired alignment */
-
-#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__  2)
-
+#include linux/sockaddr.h
 #include asm/socket.h			/* arch-dependent defines	*/
 #include linux/sockios.h		/* the SIOCxxx I/O controls	*/
 #include linux/uio.h			/* iovec support		*/
@@ -310,7 +294,6 @@ extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
 extern int move_addr_to_user(void *kaddr, int klen, void __user *uaddr, int __user *ulen);
 extern int move_addr_to_kernel(void __user *uaddr, int ulen, void *kaddr);
 extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
+#endif /* __KERNEL__ */
 
-#endif
-#endif /* not kernel and not glibc */
 #endif /* _LINUX_SOCKET_H */
-- 
1.5.3.6