From owner-freebsd-bugs Tue Jul 18 6:50:11 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 7662F37B544 for ; Tue, 18 Jul 2000 06:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id GAA45571; Tue, 18 Jul 2000 06:50:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Tue, 18 Jul 2000 06:50:02 -0700 (PDT) Message-Id: <200007181350.GAA45571@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Sheldon Hearn Subject: Re: misc/19971: bug in /usr/include/sys/socket.h Reply-To: Sheldon Hearn Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR misc/19971; it has been noted by GNATS. From: Sheldon Hearn 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 To: Sheldon Hearn Subject: Re: The CMSG_*() and ALIGN() macros In-Reply-To: <48154.963919398@axl.ops.uunet.co.za> Message-ID: 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 instead of > in the socket(2) manpage and others which include > ? Because implements socket stuff, not all the goop in . > 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: 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 ; 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 ; 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: References: <20000402074908D.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(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 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 and . 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 +#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/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<