Date: Tue, 18 Jul 2000 06:50:02 -0700 (PDT) From: Sheldon Hearn <sheldonh@uunet.co.za> To: freebsd-bugs@FreeBSD.org Subject: Re: misc/19971: bug in /usr/include/sys/socket.h Message-ID: <200007181350.GAA45571@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/19971; it has been noted by GNATS. From: Sheldon Hearn <sheldonh@uunet.co.za> To: freebsd-gnats-submit@FreeBSD.org Cc: Subject: Re: misc/19971: bug in /usr/include/sys/socket.h Date: Tue, 18 Jul 2000 15:43:07 +0200 Right, I did some digging, which turned out to be useless. So I asked bruce Evans about the situation. This was his reply. Ciao, Sheldon. ------- Forwarded Message Date: Tue, 18 Jul 2000 23:37:32 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Sheldon Hearn <sheldonh@uunet.co.za> Subject: Re: The CMSG_*() and ALIGN() macros In-Reply-To: <48154.963919398@axl.ops.uunet.co.za> Message-ID: <Pine.BSF.4.21.0007182324480.1464-100000@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 18 Jul 2000, Sheldon Hearn wrote: > Could you either point me at the right archive or explain why > we shouldn't mandate the inclusion of <sys/param.h> instead of > <sys/types.h> in the socket(2) manpage and others which include > <sys/socket.h>? Because <sys/socket.h> implements socket stuff, not all the goop in <sys/param.h>. > Is the final word that folks who want CMSG_*() should just know for > themselves to do the right thing? Would a new manual page for the > macros help? That is too much to ask, since we changed the interface. Here is my last saved mail from shin about this. I was essentially happy with these patches, but don't seem to have replied. I thought that shin was going to commit them, but he disappeared almost immediately after writing this. Bruce From bde Mon Apr 3 21:55:23 2000 Return-Path: <shin@nd.net.fujitsu.co.jp> Received: from fgwmail5.fujitsu.co.jp (fgwmail5.fujitsu.co.jp [192.51.44.35]) by mailman.zeta.org.au (8.8.7/8.8.7) with ESMTP id CAA15739 for <bde@zeta.org.au>; Mon, 3 Apr 2000 02:09:11 +1000 Received: from m5.gw.fujitsu.co.jp by fgwmail5.fujitsu.co.jp (8.9.3/3.7W-MX0002-Fujitsu Gateway) id BAA16840 for <bde@zeta.org.au>; Mon, 3 Apr 2000 01:09:09 +0900 (JST) (envelope-from shin@nd.net.fujitsu.co.jp) Received: from incapgw.fujitsu.co.jp by m5.gw.fujitsu.co.jp (8.9.3/3.7W-0003-Fujitsu Domain Master) id BAA27587; Mon, 3 Apr 2000 01:09:08 +0900 (JST) Received: from localhost ([192.168.245.154]) by incapgw.fujitsu.co.jp (8.9.3/3.7W-0002) id BAA11137; Mon, 3 Apr 2000 01:09:05 +0900 (JST) To: bde@zeta.org.au Subject: Re: 'machine/param.h' required for 'sys/socket.h' In-Reply-To: <Pine.BSF.4.21.0004021744400.1236-100000@alphplex.bde.org> References: <20000402074908D.shin@nd.net.fujitsu.co.jp> <Pine.BSF.4.21.0004021744400.1236-100000@alphplex.bde.org> X-Mailer: Mew version 1.94 on Emacs 20.4 / Mule 4.0 (HANANOEN) X-Prom-Mew: Prom-Mew 1.93.4 (procmail reader for Mew) Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Mon_Apr__3_01:09:57_2000_809)--" Content-Transfer-Encoding: 7bit Message-Id: <20000403011000P.shin@nd.net.fujitsu.co.jp> Date: Mon, 03 Apr 2000 01:10:00 +0900 From: Yoshinobu Inoue <shin@nd.net.fujitsu.co.jp> X-Dispatcher: imput version 990905(IM130) Content-Length: 7447 Lines: 246 Status: RO X-Status: X-Keywords: X-UID: 19734 - ----Next_Part(Mon_Apr__3_01:09:57_2000_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit > > Index: alpha/include/param.h > > =================================================================== > > RCS file: /home/ncvs/src/sys/alpha/include/param.h,v > > retrieving revision 1.17 > > diff -u -r1.17 param.h > > Similarly. Diffing the alpha version with the i386 versions shows many > gratuitous differences and bugs (broken dbtob() on alpha...). It's > interesting that the alpha version doesn't have > "#ifndef _MACHINE_PARAM_H_ ...". Yes, so maybe there is no multiple inclusion for <sys/param.h> and <sys/pipe.h>. I once tried to merge some differences between param.h for i386 and alpha, but quit it because I thought it might create new namespace pollution for the copied side. (Or is it permissible?) Also I didn't touched dbtob() macro, because I don't know what is correct fix for alpha. I attach the updated patches. Please let me know if you think other changes(like ones I withhold above) should also be fixed in this time. Yoshinobu Inoue - ----Next_Part(Mon_Apr__3_01:09:57_2000_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="namespace.diff2" Index: sys/socket.h =================================================================== RCS file: /home/ncvs/src/sys/sys/socket.h,v retrieving revision 1.39 diff -u -r1.39 socket.h - --- sys/socket.h 2000/03/11 19:51:04 1.39 +++ sys/socket.h 2000/04/02 15:09:58 @@ -37,6 +37,14 @@ #ifndef _SYS_SOCKET_H_ #define _SYS_SOCKET_H_ +#ifdef _NO_NAMESPACE_POLLUTION +#include <machine/param.h> +#else +#define _NO_NAMESPACE_POLLUTION +#include <machine/param.h> +#undef _NO_NAMESPACE_POLLUTION +#endif + /* * Definitions related to sockets: types, address families, options. */ @@ -352,20 +360,20 @@ /* given pointer to struct cmsghdr, return pointer to data */ #define CMSG_DATA(cmsg) ((u_char *)(cmsg) + \ - - ALIGN(sizeof(struct cmsghdr))) + _ALIGN(sizeof(struct cmsghdr))) /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ #define CMSG_NXTHDR(mhdr, cmsg) \ - - (((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len) + \ - - ALIGN(sizeof(struct cmsghdr)) > \ + (((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len) + \ + _ALIGN(sizeof(struct cmsghdr)) > \ (caddr_t)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ (struct cmsghdr *)NULL : \ - - (struct cmsghdr *)((caddr_t)(cmsg) + ALIGN((cmsg)->cmsg_len))) + (struct cmsghdr *)((caddr_t)(cmsg) + _ALIGN((cmsg)->cmsg_len))) #define CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control) - -#define CMSG_SPACE(l) (ALIGN(sizeof(struct cmsghdr)) + ALIGN(l)) - -#define CMSG_LEN(l) (ALIGN(sizeof(struct cmsghdr)) + (l)) +#define CMSG_SPACE(l) (_ALIGN(sizeof(struct cmsghdr)) + _ALIGN(l)) +#define CMSG_LEN(l) (_ALIGN(sizeof(struct cmsghdr)) + (l)) /* "Socket"-level control message types: */ #define SCM_RIGHTS 0x01 /* access rights (array of int) */ Index: i386/include/param.h =================================================================== RCS file: /home/ncvs/src/sys/i386/include/param.h,v retrieving revision 1.55 diff -u -r1.55 param.h - --- i386/include/param.h 2000/03/29 05:39:04 1.55 +++ i386/include/param.h 2000/04/02 15:09:58 @@ -37,21 +37,37 @@ * $FreeBSD: src/sys/i386/include/param.h,v 1.55 2000/03/29 05:39:04 jlemon Exp $ */ - -#ifndef _MACHINE_PARAM_H_ - -#define _MACHINE_PARAM_H_ - - /* * Machine dependent constants for Intel 386. */ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value + * for all data types (int, long, ...). The result is unsigned int + * and must be cast to any desired pointer type. + */ +#ifndef _ALIGNBYTES +#define _ALIGNBYTES (sizeof(int) - 1) +#endif +#ifndef _ALIGN +#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) +#endif + #ifndef _MACHINE #define _MACHINE i386 #endif - -#ifndef MACHINE - -#define MACHINE "i386" - -#endif #ifndef _MACHINE_ARCH #define _MACHINE_ARCH i386 #endif + +#ifndef _NO_NAMESPACE_POLLUTION + +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +#ifndef MACHINE +#define MACHINE "i386" +#endif #ifndef MACHINE_ARCH #define MACHINE_ARCH "i386" #endif @@ -70,13 +86,8 @@ #define NCPUS 1 #endif - -/* - - * Round p (pointer or byte index) up to a correctly-aligned value - - * for all data types (int, long, ...). The result is unsigned int - - * and must be cast to any desired pointer type. - - */ - -#define ALIGNBYTES (sizeof(int) - 1) - -#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES) +#define ALIGNBYTES _ALIGNBYTES +#define ALIGN(p) _ALIGN(p) #define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */ #define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */ @@ -158,3 +169,4 @@ #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) #endif /* !_MACHINE_PARAM_H_ */ +#endif /* !_NO_NAMESPACE_POLLUTION */ Index: alpha/include/param.h =================================================================== RCS file: /home/ncvs/src/sys/alpha/include/param.h,v retrieving revision 1.17 diff -u -r1.17 param.h - --- alpha/include/param.h 2000/02/29 08:48:10 1.17 +++ alpha/include/param.h 2000/04/02 15:09:58 @@ -46,15 +46,43 @@ /* * Machine dependent constants for the Alpha. */ + +/* + * Round p (pointer or byte index) up to a correctly-aligned value for all + * data types (int, long, ...). The result is u_long and must be cast to + * any desired pointer type. + * + * ALIGNED_POINTER is a boolean macro that checks whether an address + * is valid to fetch data elements of type t from on this architecture. + * This does not reflect the optimal alignment, just the possibility + * (within reasonable limits). + * + */ +#ifndef _ALIGNBYTES +#define _ALIGNBYTES 7 +#endif +#ifndef _ALIGN +#define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) +#endif +#ifndef _ALIGNED_POINTER +#define _ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) +#endif + #ifndef _MACHINE #define _MACHINE alpha #endif - -#ifndef MACHINE - -#define MACHINE "alpha" - -#endif #ifndef _MACHINE_ARCH #define _MACHINE_ARCH alpha #endif + +#ifndef _NO_NAMESPACE_POLLUTION + +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +#ifndef MACHINE +#define MACHINE "alpha" +#endif #ifndef MACHINE_ARCH #define MACHINE_ARCH "alpha" #endif @@ -72,20 +100,9 @@ #define NCPUS 1 - -/* - - * Round p (pointer or byte index) up to a correctly-aligned value for all - - * data types (int, long, ...). The result is u_long and must be cast to - - * any desired pointer type. - - * - - * ALIGNED_POINTER is a boolean macro that checks whether an address - - * is valid to fetch data elements of type t from on this architecture. - - * This does not reflect the optimal alignment, just the possibility - - * (within reasonable limits). - - * - - */ - -#define ALIGNBYTES 7 - -#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES) - -#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) +#define ALIGNBYTES _ALIGNBYTES +#define ALIGN(p) _ALIGN(p) +#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t) #define PAGE_SIZE (1 << ALPHA_PGSHIFT) /* bytes/page */ #define PAGE_SHIFT ALPHA_PGSHIFT @@ -161,3 +178,6 @@ #define alpha_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) + +#endif /* !_MACHINE_PARAM_H_ */ +#endif /* !_NO_NAMESPACE_POLLUTION */ - ----Next_Part(Mon_Apr__3_01:09:57_2000_809)---- ------- End of Forwarded Message To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007181350.GAA45571>