Add a macro for shift of an integer (1 << shift == sizeof). Move the pointer

define to live alongside it.  For kicks assert at compile time that they are
correct.  Use these instead of magic numbers.
This commit is contained in:
jake 2002-02-27 00:21:04 +00:00
parent cc951d5968
commit aec950ed91
7 changed files with 13 additions and 7 deletions

View File

@ -29,7 +29,6 @@
#ifndef _MACHINE_FRAME_H_
#define _MACHINE_FRAME_H_
#define PTR_SHIFT 3
#define RW_SHIFT 7
#define SPOFF 2047

View File

@ -82,6 +82,9 @@
#define MAXCPU 1
#endif /* SMP */
#define INT_SHIFT 2
#define PTR_SHIFT 3
#define ALIGNBYTES _ALIGNBYTES
#define ALIGN(p) _ALIGN(p)

View File

@ -97,6 +97,9 @@ ASSYM(TSB_BUCKET_ADDRESS_BITS, TSB_BUCKET_ADDRESS_BITS);
ASSYM(TSB_BUCKET_SHIFT, TSB_BUCKET_SHIFT);
ASSYM(TSB_KERNEL_MASK, TSB_KERNEL_MASK);
ASSYM(INT_SHIFT, INT_SHIFT);
ASSYM(PTR_SHIFT, PTR_SHIFT);
ASSYM(PAGE_SHIFT, PAGE_SHIFT);
ASSYM(PAGE_MASK, PAGE_MASK);
@ -187,7 +190,6 @@ ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
ASSYM(P_VMSPACE, offsetof(struct proc, p_vmspace));
ASSYM(RW_SHIFT, RW_SHIFT);
ASSYM(PTR_SHIFT, PTR_SHIFT);
ASSYM(KE_FLAGS, offsetof(struct kse, ke_flags));

View File

@ -137,6 +137,9 @@ void sparc64_shutdown_final(void *dummy, int howto);
static void cpu_startup(void *);
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
CTASSERT((1 << INT_SHIFT) == sizeof(int));
CTASSERT((1 << PTR_SHIFT) == sizeof(char *));
CTASSERT(sizeof(struct pcpu) <= (PAGE_SIZE / 2));
static void

View File

@ -38,7 +38,6 @@
#include <machine/frame.h>
CTASSERT((1 << RW_SHIFT) == sizeof(struct rwindow));
CTASSERT((1 << PTR_SHIFT) == sizeof(char *));
int
rwindow_load(struct thread *td, struct trapframe *tf, int n)

View File

@ -136,7 +136,7 @@ ENTRY(cpu_switch)
* tsb.
*/
lduw [PCPU(CPUID)], %l3
sllx %l3, 2, %l3
sllx %l3, INT_SHIFT, %l3
add %l2, VM_PMAP + PM_CONTEXT, %l4
lduw [%l3 + %l4], %l5
brz,a,pn %l5, 3f
@ -164,7 +164,7 @@ ENTRY(cpu_switch)
* If the new process has nucleus context we are done.
*/
3: lduw [PCPU(CPUID)], %o3
sllx %o3, 2, %o3
sllx %o3, INT_SHIFT, %o3
add %o2, VM_PMAP + PM_CONTEXT, %o4
lduw [%o3 + %o4], %o5
brz,a,pn %o5, 4f

View File

@ -136,7 +136,7 @@ ENTRY(cpu_switch)
* tsb.
*/
lduw [PCPU(CPUID)], %l3
sllx %l3, 2, %l3
sllx %l3, INT_SHIFT, %l3
add %l2, VM_PMAP + PM_CONTEXT, %l4
lduw [%l3 + %l4], %l5
brz,a,pn %l5, 3f
@ -164,7 +164,7 @@ ENTRY(cpu_switch)
* If the new process has nucleus context we are done.
*/
3: lduw [PCPU(CPUID)], %o3
sllx %o3, 2, %o3
sllx %o3, INT_SHIFT, %o3
add %o2, VM_PMAP + PM_CONTEXT, %o4
lduw [%o3 + %o4], %o5
brz,a,pn %o5, 4f