Subject: Re: Proposal: CL* macros removal.
To: Anders Magnusson <ragge@ludd.luth.se>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 11/21/1999 17:06:19
On Sun, 21 Nov 1999 22:40:40 +0100 (MET)
Anders Magnusson <ragge@ludd.luth.se> wrote:
> Now you came up with something else: PAGE_SIZE as a variable instead of
> a constant create lots of unneccessary code, especially in complex
> expressions that otherwise could be optimized away by the compiler.
> What is the reason to have it as a variable instead of a constant?
> Can there ever be a benefit from this?
"Because that's the way Mach VM hid MI vs. MD page size"? :-)
Seriously, though, I think that what we should do is change the following
snippet of code in vm/vm_param.h from:
#if defined(_KERNEL)
/*
* All references to the size of a page should be done with PAGE_SIZE
* or PAGE_SHIFT. The fact they are variables is hidden here so that
* we can easily make them constant if we so desire.
*/
#define PAGE_SIZE uvmexp.pagesize /* size of page */
#define PAGE_MASK uvmexp.pagemask /* size of page - 1 */
#define PAGE_SHIFT uvmexp.pageshift /* bits to shift for pages */
#endif /* _KERNEL */
to:
#if defined(_KERNEL) && !defined(PAGE_SIZE)
/*
* All references to the size of a page should be done with PAGE_SIZE
* or PAGE_SHIFT. Machine dependent code may override these definitions,
* making them constants. Systems with page size detected at run-time
* should use these definitions instead.
*
* Note: these variables should always be initialized even if constants
* are used. This is for the benefit of user programs which want to
* read the `uvmexp' structure.
*/
#define PAGE_SIZE uvmexp.pagesize /* size of page */
#define PAGE_MASK uvmexp.pagemask /* size of page - 1 */
#define PAGE_SHIFT uvmexp.pageshift /* bits to shift for pages */
#endif /* _KERNEL && ! PAGE_SIZE */
#if !defined(PAGE_SIZE) || !defined(PAGE_MASK) || !defined(PAGE_SHIFT)
#error PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT must be defined
#endif
...then, <machine/vmparam.h> could do what it sees fit.
-- Jason R. Thorpe <thorpej@nas.nasa.gov>