Re: sys/types.h in sys/socket.h
...and here's a diff for discussion that removes the sa_family_t and socklen_t typedefs from sys/types.h, transferring them to sys/socket.h and duping them in netinet/in.h, netinet6/in6.h, and sys/un.h as necessary. There are only two user-land fixes necessary for a build with this, in sasyncd and bind (the latter in the locally written privsep bits) This diff also includes some compliance fixes for netinet/in.h that I had been noodelling on, hiding behind __BSD_VISIBLE various things which are not permitted by the standard. The switching from socklen_t to __socklen_t in the pure kernel headers (sys/domain.h and sys/socketvar.h) is perhaps a bit dubious; suggestions are welcome. Perhaps sys/types.h should continue to declare sa_family_t and socklen_t under __BSD_VISIBLE... Philip Guenther Index: include/netdb.h === RCS file: /cvs/src/include/netdb.h,v retrieving revision 1.27 diff -u -p -r1.27 netdb.h --- include/netdb.h 2 Jun 2009 16:47:50 - 1.27 +++ include/netdb.h 21 Nov 2010 08:37:30 - @@ -89,6 +89,7 @@ #include sys/param.h #include sys/cdefs.h +#include sys/socket.h #define_PATH_HEQUIV/etc/hosts.equiv #define_PATH_HOSTS /etc/hosts Index: sys/sys/domain.h === RCS file: /cvs/src/sys/sys/domain.h,v retrieving revision 1.9 diff -u -p -r1.9 domain.h --- sys/sys/domain.h22 Feb 2009 07:47:22 - 1.9 +++ sys/sys/domain.h21 Nov 2010 08:25:46 - @@ -47,7 +47,7 @@ structdomain { char*dom_name; void(*dom_init)(void); /* initialize domain data structures */ /* externalize access rights */ - int (*dom_externalize)(struct mbuf *, socklen_t); + int (*dom_externalize)(struct mbuf *, __socklen_t); /* dispose of internalized rights */ void(*dom_dispose)(struct mbuf *); struct protosw *dom_protosw, *dom_protoswNPROTOSW; Index: sys/sys/socket.h === RCS file: /cvs/src/sys/sys/socket.h,v retrieving revision 1.70 diff -u -p -r1.70 socket.h --- sys/sys/socket.h5 Jul 2010 22:20:22 - 1.70 +++ sys/sys/socket.h21 Nov 2010 08:25:48 - @@ -35,10 +35,30 @@ #ifndef _SYS_SOCKET_H_ #define_SYS_SOCKET_H_ -/* - * needed for ALIGNBYTES - */ -#include machine/param.h +#include sys/cdefs.h +#include sys/_types.h +#include machine/param.h /* needed for ALIGN() */ + +#ifndef_SOCKLEN_T_DEFINED_ +#define_SOCKLEN_T_DEFINED_ +typedef__socklen_t socklen_t; /* length type for network syscalls */ +#endif + +#ifndef_SA_FAMILY_T_DEFINED_ +#define_SA_FAMILY_T_DEFINED_ +typedef__sa_family_t sa_family_t;/* sockaddr address family type */ +#endif + +#ifndef_SIZE_T_DEFINED_ +#define_SIZE_T_DEFINED_ +typedef__size_tsize_t; +#endif + +#ifndef_SSIZE_T_DEFINED_ +#define_SSIZE_T_DEFINED_ +typedef__ssize_t ssize_t; +#endif + /* * Definitions related to sockets: types, address families, options. Index: sys/sys/socketvar.h === RCS file: /cvs/src/sys/sys/socketvar.h,v retrieving revision 1.47 diff -u -p -r1.47 socketvar.h --- sys/sys/socketvar.h 24 Sep 2010 02:59:46 - 1.47 +++ sys/sys/socketvar.h 21 Nov 2010 08:25:49 - @@ -297,7 +297,7 @@ voidsoqinsque(struct socket *head, stru intsoqremque(struct socket *so, int q); intsoreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp, - socklen_t controllen); + __socklen_t controllen); intsoreserve(struct socket *so, u_long sndcc, u_long rcvcc); void sorflush(struct socket *so); intsosend(struct socket *so, struct mbuf *addr, struct uio *uio, Index: sys/sys/types.h === RCS file: /cvs/src/sys/sys/types.h,v retrieving revision 1.31 diff -u -p -r1.31 types.h --- sys/sys/types.h 16 Mar 2008 19:42:57 - 1.31 +++ sys/sys/types.h 21 Nov 2010 08:25:52 - @@ -159,8 +159,6 @@ typedef __fsfilcnt_tfsfilcnt_t; /* file */ typedef __in_addr_tin_addr_t; /* base type for internet address */ typedef __in_port_tin_port_t; /* IP port type */ -typedef __sa_family_t sa_family_t;/* sockaddr address family type */ -typedef __socklen_tsocklen_t; /* length type for network syscalls */ /* * The following types may be defined in multiple header files. Index: sys/sys/un.h === RCS file: /cvs/src/sys/sys/un.h,v retrieving revision 1.10 diff -u -p -r1.10
Re: sys/types.h in sys/socket.h
Is this enough to compile socket.h by itself? I think sockcred needs to be hidden inside bsd visible too, because you aren't providing uid_t that i can see. On Sun, Nov 21, 2010 at 3:45 AM, Philip Guenther guent...@gmail.com wrote: ...and here's a diff for discussion that removes the sa_family_t and socklen_t typedefs from sys/types.h, transferring them to sys/socket.h and duping them in netinet/in.h, netinet6/in6.h, and sys/un.h as necessary. There are only two user-land fixes necessary for a build with this, in sasyncd and bind (the latter in the locally written privsep bits) This diff also includes some compliance fixes for netinet/in.h that I had been noodelling on, hiding behind __BSD_VISIBLE various things which are not permitted by the standard. The switching from socklen_t to __socklen_t in the pure kernel headers (sys/domain.h and sys/socketvar.h) is perhaps a bit dubious; suggestions are welcome. Perhaps sys/types.h should continue to declare sa_family_t and socklen_t under __BSD_VISIBLE... Philip Guenther Index: include/netdb.h === RCS file: /cvs/src/include/netdb.h,v retrieving revision 1.27 diff -u -p -r1.27 netdb.h --- include/netdb.h 2 Jun 2009 16:47:50 - 1.27 +++ include/netdb.h 21 Nov 2010 08:37:30 - @@ -89,6 +89,7 @@ #include sys/param.h #include sys/cdefs.h +#include sys/socket.h #define_PATH_HEQUIV/etc/hosts.equiv #define_PATH_HOSTS /etc/hosts Index: sys/sys/domain.h === RCS file: /cvs/src/sys/sys/domain.h,v retrieving revision 1.9 diff -u -p -r1.9 domain.h --- sys/sys/domain.h22 Feb 2009 07:47:22 - 1.9 +++ sys/sys/domain.h21 Nov 2010 08:25:46 - @@ -47,7 +47,7 @@ structdomain { char*dom_name; void(*dom_init)(void); /* initialize domain data structures */ /* externalize access rights */ - int (*dom_externalize)(struct mbuf *, socklen_t); + int (*dom_externalize)(struct mbuf *, __socklen_t); /* dispose of internalized rights */ void(*dom_dispose)(struct mbuf *); struct protosw *dom_protosw, *dom_protoswNPROTOSW; Index: sys/sys/socket.h === RCS file: /cvs/src/sys/sys/socket.h,v retrieving revision 1.70 diff -u -p -r1.70 socket.h --- sys/sys/socket.h5 Jul 2010 22:20:22 - 1.70 +++ sys/sys/socket.h21 Nov 2010 08:25:48 - @@ -35,10 +35,30 @@ #ifndef _SYS_SOCKET_H_ #define_SYS_SOCKET_H_ -/* - * needed for ALIGNBYTES - */ -#include machine/param.h +#include sys/cdefs.h +#include sys/_types.h +#include machine/param.h /* needed for ALIGN() */ + +#ifndef_SOCKLEN_T_DEFINED_ +#define_SOCKLEN_T_DEFINED_ +typedef__socklen_t socklen_t; /* length type for network syscalls */ +#endif + +#ifndef_SA_FAMILY_T_DEFINED_ +#define_SA_FAMILY_T_DEFINED_ +typedef__sa_family_t sa_family_t;/* sockaddr address family type */ +#endif + +#ifndef_SIZE_T_DEFINED_ +#define_SIZE_T_DEFINED_ +typedef__size_tsize_t; +#endif + +#ifndef_SSIZE_T_DEFINED_ +#define_SSIZE_T_DEFINED_ +typedef__ssize_t ssize_t; +#endif + /* * Definitions related to sockets: types, address families, options. Index: sys/sys/socketvar.h === RCS file: /cvs/src/sys/sys/socketvar.h,v retrieving revision 1.47 diff -u -p -r1.47 socketvar.h --- sys/sys/socketvar.h 24 Sep 2010 02:59:46 - 1.47 +++ sys/sys/socketvar.h 21 Nov 2010 08:25:49 - @@ -297,7 +297,7 @@ voidsoqinsque(struct socket *head, stru intsoqremque(struct socket *so, int q); intsoreceive(struct socket *so, struct mbuf **paddr, struct uio *uio, struct mbuf **mp0, struct mbuf **controlp, int *flagsp, - socklen_t controllen); + __socklen_t controllen); intsoreserve(struct socket *so, u_long sndcc, u_long rcvcc); void sorflush(struct socket *so); intsosend(struct socket *so, struct mbuf *addr, struct uio *uio, Index: sys/sys/types.h === RCS file: /cvs/src/sys/sys/types.h,v retrieving revision 1.31 diff -u -p -r1.31 types.h --- sys/sys/types.h 16 Mar 2008 19:42:57 - 1.31 +++ sys/sys/types.h 21 Nov 2010 08:25:52 - @@ -159,8 +159,6 @@ typedef __fsfilcnt_tfsfilcnt_t; /* file */ typedef __in_addr_tin_addr_t; /* base type for internet address */ typedef __in_port_tin_port_t; /* IP port type */ -typedef __sa_family_t sa_family_t;/* sockaddr address family
Re: sys/types.h in sys/socket.h
On Sat, Nov 20, 2010 at 9:18 AM, Mark Kettenis mark.kette...@xs4all.nl wrote: openbsd is apparently among the last operating systems to require sys/types.h before sys/socket.h. posix doesn't require this and it runs contrary to current recommendations i think, so it's just one more weird thing to deal with when trying to get something to compile. i haven't really tested this, i'm just throwing it out there. Sorry, but blindly including sys/types.h isn't allowed by POSIX. Requiring everyone to include sys/types.h before socket.h isn't allowed by posix either. This way, at least the code compiles without changes. our socket.h header is broken. this makes it better.
Re: sys/types.h in sys/socket.h
On Sat, Nov 20, 2010 at 11:54 AM, Ted Unangst ted.unan...@gmail.com wrote: On Sat, Nov 20, 2010 at 9:18 AM, Mark Kettenis mark.kette...@xs4all.nl wrote: openbsd is apparently among the last operating systems to require sys/types.h before sys/socket.h. posix doesn't require this and it runs contrary to current recommendations i think, so it's just one more weird thing to deal with when trying to get something to compile. i haven't really tested this, i'm just throwing it out there. Sorry, but blindly including sys/types.h isn't allowed by POSIX. Requiring everyone to include sys/types.h before socket.h isn't allowed by posix either. This way, at least the code compiles without changes. our socket.h header is broken. this makes it better. By, the way, there's this comment in types.h: * XPG4.2 states that inclusion of netinet/in.h must pull these * in and that inclusion of sys/socket.h must pull in sa_family_t. * We put these here because there are other headers that require * these types and sys/socket.h and netinet/in.h will indirectly * include sys/types.h. So somebody already thinks socket.h includes types.h.
Re: sys/types.h in sys/socket.h
On Sat, Nov 20, 2010 at 9:10 AM, Ted Unangst ted.unan...@gmail.com wrote: On Sat, Nov 20, 2010 at 11:54 AM, Ted Unangst ted.unan...@gmail.com wrote: On Sat, Nov 20, 2010 at 9:18 AM, Mark Kettenis mark.kette...@xs4all.nl wrote: openbsd is apparently among the last operating systems to require sys/types.h before sys/socket.h. posix doesn't require this and it runs contrary to current recommendations i think, so it's just one more weird thing to deal with when trying to get something to compile. i haven't really tested this, i'm just throwing it out there. Sorry, but blindly including sys/types.h isn't allowed by POSIX. Requiring everyone to include sys/types.h before socket.h isn't allowed by posix either. This way, at least the code compiles without changes. our socket.h header is broken. this makes it better. IMO, this takes it from not enough, right past good, to too much... By, the way, there's this comment in types.h: * XPG4.2 states that inclusion of netinet/in.h must pull these * in and that inclusion of sys/socket.h must pull in sa_family_t. * We put these here because there are other headers that require * these types and sys/socket.h and netinet/in.h will indirectly * include sys/types.h. So somebody already thinks socket.h includes types.h. The next line of that comment is interesting: * XXX - now that we have protected versions these should move. Why not do what that suggests and move the sa_family_t and socklen_t types to socket.h? Copy the #ifndef...#endif blocks for ssize_t and size_t there at the same time, add includes of sys/cdefs.h and sys/_types.h and give compilation a whirl... Philip Guenther