Subject: Re: "const int" in conf/param.c?
To: None <tech-kern@netbsd.org>
From: Eduardo E. Horvath <eeh@one-o.com>
List: tech-kern
Date: 04/28/1999 10:13:27
On Wed, 28 Apr 1999, I. Souvatzis wrote:

> On Wed, Apr 28, 1999 at 02:53:37AM +0200, Olaf Seibert wrote:
> > On Tue, 27 Apr 1999, Simon Burge wrote:
> > 
> > > "Eduardo E. Horvath" wrote:
> > > 
> > > > sparc64 currently runs in either 32-bit or 64-bit mode, so the mbuf size
> > > > should vary depending on the kernel.  What we really need is some cpp
> > > > define that reports pointer size so we can check that rather than:
> > > > 
> > > > #if defined(alpha) || (defined(sparc64) && defined(__arch64__)) || \
> > > > 	(defined(mips) && ...) || (defined(powerpc) ....
> > > 
> > > It doesn't have to be that bad:
> > > 
> > > #define MSIZE	(128 * (sizeof(void *) / 4))
> > 
> > But you can never use MSIZE in an #if, since the preprocessor does not
> > know about sizeof().
> > 
> > (No, don't tell me about gcc extensions. I know. It's Not Standard.)
> > 
> 
> I repeat the question somebody else asked:
> 
> do we really need a CPP definition, or do we just need it so that the 
> _compiler_ can declare the mbuf header?

Yes, we really need a CPP definition.  Here's a bit of code from
nfs_subs.c:

void
nfs_init()
{

#if !defined(alpha) && defined(DIAGNOSTIC)
        /*
         * Check to see if major data structures haven't bloated.
         */
        if (sizeof (struct nfsnode) > NFS_NODEALLOC) {
                printf("struct nfsnode bloated (> %dbytes)\n",
NFS_NODEALLOC);
                printf("Try reducing NFS_SMALLFH\n");
        }
        if (sizeof (struct nfssvc_sock) > NFS_SVCALLOC) {
                printf("struct nfssvc_sock bloated (>
%dbytes)\n",NFS_SVCALLOC);
                printf("Try reducing NFS_UIDHASHSIZ\n");
        }
        if (sizeof (struct nfsuid) > NFS_UIDALLOC) {
                printf("struct nfsuid bloated (>
%dbytes)\n",NFS_UIDALLOC);
                printf("Try unionizing the nu_nickname and nu_flag
fields\n");
        }
#endif

In most parts of MI code `#if defined(alpha)' is synonymous with LP64.
Then there are the userland bits as well.

There are other places in MD code where differenct code needs to be
compiled depending on the memeory model, such as the different signal
trampolines.  And then there's the compat_netbsd32 code.

We could probably change some of the code to depend on sizeof(void*), but
I'm sure there are other places where we need to define different function
signatures depending on the size of a pointer.


=========================================================================
Eduardo Horvath				eeh@one-o.com
	"I need to find a pithy new quote." -- me