From owner-freebsd-current Sat Apr 1 14:49:28 2000 Delivered-To: freebsd-current@freebsd.org Received: from fgwmail5.fujitsu.co.jp (fgwmail5.fujitsu.co.jp [192.51.44.35]) by hub.freebsd.org (Postfix) with ESMTP id 1B4EA37BC43 for ; Sat, 1 Apr 2000 14:49:16 -0800 (PST) (envelope-from shin@nd.net.fujitsu.co.jp) Received: from m4.gw.fujitsu.co.jp by fgwmail5.fujitsu.co.jp (8.9.3/3.7W-MX0002-Fujitsu Gateway) id HAA12811; Sun, 2 Apr 2000 07:48:15 +0900 (JST) (envelope-from shin@nd.net.fujitsu.co.jp) Received: from incapgw.fujitsu.co.jp by m4.gw.fujitsu.co.jp (8.9.3/3.7W-0003-Fujitsu Domain Master) id HAA00418; Sun, 2 Apr 2000 07:48:14 +0900 (JST) Received: from localhost ([192.168.245.183]) by incapgw.fujitsu.co.jp (8.9.3/3.7W-0002) id HAA15291; Sun, 2 Apr 2000 07:48:11 +0900 (JST) To: bde@zeta.org.au Cc: bmah@CA.Sandia.GOV, nnd@mail.nsk.ru, current@FreeBSD.ORG Subject: Re: 'machine/param.h' required for 'sys/socket.h' In-Reply-To: References: <20000329003050L.shin@nd.net.fujitsu.co.jp> 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(Sun_Apr__2_07:49:06_2000_809)--" Content-Transfer-Encoding: 7bit Message-Id: <20000402074908D.shin@nd.net.fujitsu.co.jp> Date: Sun, 02 Apr 2000 07:49:08 +0900 From: Yoshinobu Inoue X-Dispatcher: imput version 990905(IM130) Lines: 257 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG ----Next_Part(Sun_Apr__2_07:49:06_2000_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit > > I created the patches. > > It become a little bit more complicated than I expected, to > > avoid duplicated inclusion independently in each of namespace > > polluted part and non polluted part. > > Now I don't like this for a quick fix :-). It is more complicated than > a correct fix. > > I think it would be OK without any anti-redefinition ifdefs. Redefinition > is only a micro-pessimization since there are only #define's (no > typedefs, etc.) and won't occur often since should only > be included by , and . Reinclusion > can be optimized in the including file using e.g. #ifndef _ALIGN in > . I once tried more simpler patches, but then I had a build problem at sbin/ipfw/ipfw.c. It includes before , so is once included via but namespace non-polluted part only. Then it is re-included via , but nothing actually included due to anti-redefiition ifdefs. And build failed because the file needs namespace polluted definitions in . This seems to be difficult issue, and some considration in seems to be inevitable. This time I created less complicated patches, which define namespace non-polluted macros outside of anti-redefiition ifdefs for the file. But each such namespace non-polluted macros have each anti-redefinition ifdef itself. Yoshinobu Inoue ----Next_Part(Sun_Apr__2_07:49:06_2000_809)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="namespace.diff" 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/01 20:40:30 @@ -37,6 +37,14 @@ #ifndef _SYS_SOCKET_H_ #define _SYS_SOCKET_H_ +#ifdef _NO_NAMESPACE_POLLUTION +#include +#else +#define _NO_NAMESPACE_POLLUTION +#include +#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/01 20:40:31 @@ -37,8 +37,17 @@ * $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_ +/* + * 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 /* * Machine dependent constants for Intel 386. @@ -46,12 +55,21 @@ #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_ + +/* + * Machine dependent constants for Intel 386. + */ +#ifndef MACHINE +#define MACHINE "i386" +#endif #ifndef MACHINE_ARCH #define MACHINE_ARCH "i386" #endif @@ -70,13 +88,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<