Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN()...
details: https://anonhg.NetBSD.org/src/rev/027e1583a8b7
branches: trunk
changeset: 773007:027e1583a8b7
user: christos <christos%NetBSD.org@localhost>
date: Tue Jan 24 20:03:36 2012 +0000
description:
Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN() consistently,
and avoid definining them in 10 different places if not needed.
diffstat:
sys/arch/alpha/include/param.h | 17 +----------------
sys/arch/amd64/include/param.h | 15 +--------------
sys/arch/arm/include/param.h | 19 ++-----------------
sys/arch/hppa/include/param.h | 11 +----------
sys/arch/i386/include/param.h | 16 +---------------
sys/arch/ia64/include/param.h | 18 +-----------------
sys/arch/m68k/include/param.h | 17 +----------------
sys/arch/mips/include/mips_param.h | 19 +------------------
sys/arch/powerpc/include/param.h | 6 +-----
sys/arch/sh3/include/param.h | 17 +----------------
sys/arch/sparc/include/param.h | 17 +----------------
sys/arch/sparc64/include/param.h | 16 +---------------
sys/arch/vax/include/param.h | 18 +-----------------
sys/kern/init_main.c | 6 +++---
sys/kern/kern_exec.c | 11 ++++-------
sys/sys/param.h | 27 ++++++++++++++++++++++++++-
16 files changed, 47 insertions(+), 203 deletions(-)
diffs (truncated from 502 to 300 lines):
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/alpha/include/param.h
--- a/sys/arch/alpha/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/alpha/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.39 2012/01/20 14:08:05 joerg Exp $ */
+/* $NetBSD: param.h,v 1.40 2012/01/24 20:03:36 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -49,21 +49,6 @@
#include <machine/cpu.h>
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value for all
- * data types (int, long, ...). The result is u_long and must be cast to
- * any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
-
#define NBPG (1 << ALPHA_PGSHIFT) /* bytes/page */
#define PGOFSET (NBPG-1) /* byte off. into pg */
#define PGSHIFT ALPHA_PGSHIFT /* LOG2(NBPG) */
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/amd64/include/param.h
--- a/sys/arch/amd64/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/amd64/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.15 2012/01/20 14:08:05 joerg Exp $ */
+/* $NetBSD: param.h,v 1.16 2012/01/24 20:03:36 christos Exp $ */
#ifdef __x86_64__
@@ -12,19 +12,6 @@
#define MACHINE_ARCH "x86_64"
#define MID_MACHINE MID_X86_64
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value
- * for all data types (int, long, ...). The result is u_int and
- * must be cast to any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ALIGNBYTES)
#define ALIGNED_POINTER(p,t) 1
#define ALIGNBYTES32 (sizeof(int) - 1)
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/arm/include/param.h
--- a/sys/arch/arm/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/arm/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.14 2012/01/20 14:08:05 joerg Exp $ */
+/* $NetBSD: param.h,v 1.15 2012/01/24 20:03:36 christos Exp $ */
/*
* Copyright (c) 1994,1995 Mark Brinicombe.
@@ -79,23 +79,8 @@
#define MID_MACHINE MID_ARM6
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value
- * for all data types (int, long, ...). The result is u_int and
- * must be cast to any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
/* ARM-specific macro to align a stack pointer (downwards). */
-#define STACKALIGNBYTES (8 - 1)
-#define STACKALIGN(p) ((u_int)(p) &~ STACKALIGNBYTES)
+#define STACK_ALIGNBYTES (8 - 1)
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define DEV_BSIZE (1 << DEV_BSHIFT)
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/hppa/include/param.h
--- a/sys/arch/hppa/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/hppa/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.16 2012/01/20 14:08:05 joerg Exp $ */
+/* $NetBSD: param.h,v 1.17 2012/01/24 20:03:36 christos Exp $ */
/* $OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $ */
@@ -37,15 +37,6 @@
#define MACHINE_ARCH "hppa"
#define MID_MACHINE MID_HPPA
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value for all
- * data types (int, long, ...). The result is u_int and must be cast to
- * any desired pointer type.
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)
-
#define PGSHIFT 12 /* LOG2(NBPG) */
#define NBPG (1 << PGSHIFT) /* bytes/page */
#define PGOFSET (NBPG-1) /* byte offset into page */
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/i386/include/param.h
--- a/sys/arch/i386/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/i386/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.73 2012/01/20 14:08:06 joerg Exp $ */
+/* $NetBSD: param.h,v 1.74 2012/01/24 20:03:37 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -51,20 +51,6 @@
#define MACHINE_ARCH "i386"
#define MID_MACHINE MID_I386
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value
- * for all data types (int, long, ...). The result is u_int and
- * must be cast to any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_int)(u_long)(p) + ALIGNBYTES) &~ \
- ALIGNBYTES)
#define ALIGNED_POINTER(p,t) 1
#define PGSHIFT 12 /* LOG2(NBPG) */
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/ia64/include/param.h
--- a/sys/arch/ia64/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/ia64/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.6 2012/01/20 14:08:06 joerg Exp $ */
+/* $NetBSD: param.h,v 1.7 2012/01/24 20:03:37 christos Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -77,22 +77,6 @@
#endif
#define KSTACK_GUARD_PAGES 0 /* pages of kstack guard; 0 disables */
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value
- * for all data types (int, long, ...). The result is u_int and
- * must be cast to any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
-
#define ALIGNBYTES32 (sizeof(int) - 1)
#define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/m68k/include/param.h
--- a/sys/arch/m68k/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/m68k/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.20 2012/01/20 14:08:06 joerg Exp $ */
+/* $NetBSD: param.h,v 1.21 2012/01/24 20:03:37 christos Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -56,21 +56,6 @@
#define MACHINE "m68k"
#endif
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value for all
- * data types (int, long, ...). The result is u_int and must be cast to
- * any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
-
#define NBPG (1 << PGSHIFT) /* bytes/page */
#define PGOFSET (NBPG-1) /* byte offset into page */
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/mips/include/mips_param.h
--- a/sys/arch/mips/include/mips_param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/mips/include/mips_param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mips_param.h,v 1.31 2012/01/20 14:08:06 joerg Exp $ */
+/* $NetBSD: mips_param.h,v 1.32 2012/01/24 20:03:37 christos Exp $ */
#ifdef _KERNEL
#include <machine/cpu.h>
@@ -67,23 +67,6 @@
#define COHERENCY_UNIT 32 /* MIPS cachelines are usually 32 bytes */
#endif
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value for all
- * data types (int, long, ...). The result is u_int and must be cast to
- * any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGNBYTES32 ALIGNBYTES
-#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
-#define ALIGN32(p) (((uintptr_t)(p) + ALIGNBYTES32) & ~ALIGNBYTES32)
-#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t)-1)) == 0)
-
#ifdef ENABLE_MIPS_16KB_PAGE
#define NBPG 16384 /* bytes/page */
#define PGSHIFT 14 /* LOG2(NBPG) */
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/powerpc/include/param.h
--- a/sys/arch/powerpc/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/powerpc/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.25 2012/01/20 14:08:06 joerg Exp $ */
+/* $NetBSD: param.h,v 1.26 2012/01/24 20:03:37 christos Exp $ */
/*-
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -53,10 +53,6 @@
#define MACHINE_ARCH "powerpc"
#define MID_MACHINE MID_POWERPC
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0)
-
#ifdef PPC_IBM4XX
#define PGSHIFT 14 /* Use 16KB to reduce TLB thrashing */
#define UPAGES 1
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/sh3/include/param.h
--- a/sys/arch/sh3/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/sh3/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.21 2012/01/20 14:08:06 joerg Exp $ */
+/* $NetBSD: param.h,v 1.22 2012/01/24 20:03:37 christos Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -51,21 +51,6 @@
#define NBPG (1 << PGSHIFT)
#define PGOFSET (NBPG - 1)
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value
- * for all data types (int, long, ...). The result is u_int and
- * must be cast to any desired pointer type.
- *
- * ALIGNED_POINTER is a boolean macro that checks whether an address
- * is valid to fetch data elements of type t from on this architecture.
- * This does not reflect the optimal alignment, just the possibility
- * (within reasonable limits).
- *
- */
-#define ALIGNBYTES __ALIGNBYTES
-#define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES)
-#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0)
-
#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
#define DEV_BSIZE (1 << DEV_BSHIFT)
#define BLKDEV_IOSIZE 2048
diff -r 4b58813f9bd3 -r 027e1583a8b7 sys/arch/sparc/include/param.h
--- a/sys/arch/sparc/include/param.h Tue Jan 24 19:33:27 2012 +0000
+++ b/sys/arch/sparc/include/param.h Tue Jan 24 20:03:36 2012 +0000
@@ -1,4 +1,4 @@
Home |
Main Index |
Thread Index |
Old Index