Module Name: src Committed By: christos Date: Tue Jan 24 20:03:38 UTC 2012
Modified Files: src/sys/arch/alpha/include: param.h src/sys/arch/amd64/include: param.h src/sys/arch/arm/include: param.h src/sys/arch/hppa/include: param.h src/sys/arch/i386/include: param.h src/sys/arch/ia64/include: param.h src/sys/arch/m68k/include: param.h src/sys/arch/mips/include: mips_param.h src/sys/arch/powerpc/include: param.h src/sys/arch/sh3/include: param.h src/sys/arch/sparc/include: param.h src/sys/arch/sparc64/include: param.h src/sys/arch/vax/include: param.h src/sys/kern: init_main.c kern_exec.c src/sys/sys: param.h Log Message: Use and define ALIGN() ALIGN_POINTER() and STACK_ALIGN() consistently, and avoid definining them in 10 different places if not needed. To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/alpha/include/param.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amd64/include/param.h cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/include/param.h cvs rdiff -u -r1.16 -r1.17 src/sys/arch/hppa/include/param.h cvs rdiff -u -r1.73 -r1.74 src/sys/arch/i386/include/param.h cvs rdiff -u -r1.6 -r1.7 src/sys/arch/ia64/include/param.h cvs rdiff -u -r1.20 -r1.21 src/sys/arch/m68k/include/param.h cvs rdiff -u -r1.31 -r1.32 src/sys/arch/mips/include/mips_param.h cvs rdiff -u -r1.25 -r1.26 src/sys/arch/powerpc/include/param.h cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sh3/include/param.h cvs rdiff -u -r1.68 -r1.69 src/sys/arch/sparc/include/param.h cvs rdiff -u -r1.46 -r1.47 src/sys/arch/sparc64/include/param.h cvs rdiff -u -r1.59 -r1.60 src/sys/arch/vax/include/param.h cvs rdiff -u -r1.438 -r1.439 src/sys/kern/init_main.c cvs rdiff -u -r1.333 -r1.334 src/sys/kern/kern_exec.c cvs rdiff -u -r1.399 -r1.400 src/sys/sys/param.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/alpha/include/param.h diff -u src/sys/arch/alpha/include/param.h:1.39 src/sys/arch/alpha/include/param.h:1.40 --- src/sys/arch/alpha/include/param.h:1.39 Fri Jan 20 09:08:05 2012 +++ src/sys/arch/alpha/include/param.h Tue Jan 24 15:03:36 2012 @@ -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) */ Index: src/sys/arch/amd64/include/param.h diff -u src/sys/arch/amd64/include/param.h:1.15 src/sys/arch/amd64/include/param.h:1.16 --- src/sys/arch/amd64/include/param.h:1.15 Fri Jan 20 09:08:05 2012 +++ src/sys/arch/amd64/include/param.h Tue Jan 24 15:03:36 2012 @@ -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) Index: src/sys/arch/arm/include/param.h diff -u src/sys/arch/arm/include/param.h:1.14 src/sys/arch/arm/include/param.h:1.15 --- src/sys/arch/arm/include/param.h:1.14 Fri Jan 20 09:08:05 2012 +++ src/sys/arch/arm/include/param.h Tue Jan 24 15:03:36 2012 @@ -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) Index: src/sys/arch/hppa/include/param.h diff -u src/sys/arch/hppa/include/param.h:1.16 src/sys/arch/hppa/include/param.h:1.17 --- src/sys/arch/hppa/include/param.h:1.16 Fri Jan 20 09:08:05 2012 +++ src/sys/arch/hppa/include/param.h Tue Jan 24 15:03:36 2012 @@ -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 */ Index: src/sys/arch/i386/include/param.h diff -u src/sys/arch/i386/include/param.h:1.73 src/sys/arch/i386/include/param.h:1.74 --- src/sys/arch/i386/include/param.h:1.73 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/i386/include/param.h Tue Jan 24 15:03:37 2012 @@ -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) */ Index: src/sys/arch/ia64/include/param.h diff -u src/sys/arch/ia64/include/param.h:1.6 src/sys/arch/ia64/include/param.h:1.7 --- src/sys/arch/ia64/include/param.h:1.6 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/ia64/include/param.h Tue Jan 24 15:03:37 2012 @@ -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) Index: src/sys/arch/m68k/include/param.h diff -u src/sys/arch/m68k/include/param.h:1.20 src/sys/arch/m68k/include/param.h:1.21 --- src/sys/arch/m68k/include/param.h:1.20 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/m68k/include/param.h Tue Jan 24 15:03:37 2012 @@ -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 */ Index: src/sys/arch/mips/include/mips_param.h diff -u src/sys/arch/mips/include/mips_param.h:1.31 src/sys/arch/mips/include/mips_param.h:1.32 --- src/sys/arch/mips/include/mips_param.h:1.31 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/mips/include/mips_param.h Tue Jan 24 15:03:37 2012 @@ -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) */ Index: src/sys/arch/powerpc/include/param.h diff -u src/sys/arch/powerpc/include/param.h:1.25 src/sys/arch/powerpc/include/param.h:1.26 --- src/sys/arch/powerpc/include/param.h:1.25 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/powerpc/include/param.h Tue Jan 24 15:03:37 2012 @@ -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 Index: src/sys/arch/sh3/include/param.h diff -u src/sys/arch/sh3/include/param.h:1.21 src/sys/arch/sh3/include/param.h:1.22 --- src/sys/arch/sh3/include/param.h:1.21 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/sh3/include/param.h Tue Jan 24 15:03:37 2012 @@ -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 Index: src/sys/arch/sparc/include/param.h diff -u src/sys/arch/sparc/include/param.h:1.68 src/sys/arch/sparc/include/param.h:1.69 --- src/sys/arch/sparc/include/param.h:1.68 Fri Jan 20 09:08:06 2012 +++ src/sys/arch/sparc/include/param.h Tue Jan 24 15:03:37 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.68 2012/01/20 14:08:06 joerg Exp $ */ +/* $NetBSD: param.h,v 1.69 2012/01/24 20:03:37 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -57,21 +57,6 @@ #endif /* XXX */ #endif /* XXX */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value for - * the machine's strictest data type. 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 SUN4_PGSHIFT 13 /* for a sun4 machine */ #define SUN4CM_PGSHIFT 12 /* for a sun4c or sun4m machine */ Index: src/sys/arch/sparc64/include/param.h diff -u src/sys/arch/sparc64/include/param.h:1.46 src/sys/arch/sparc64/include/param.h:1.47 --- src/sys/arch/sparc64/include/param.h:1.46 Fri Jan 20 09:08:07 2012 +++ src/sys/arch/sparc64/include/param.h Tue Jan 24 15:03:38 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.46 2012/01/20 14:08:07 joerg Exp $ */ +/* $NetBSD: param.h,v 1.47 2012/01/24 20:03:38 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -87,23 +87,9 @@ #endif /* XXX */ #endif /* XXX */ -/* - * Round p (pointer or byte index) up to a correctly-aligned value for - * the machine's strictest data type. 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 ALIGNBYTES32 0x7 #define ALIGNBYTES64 0xf -#define ALIGNBYTES __ALIGNBYTES -#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES) #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) & ~ALIGNBYTES32) -#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) /* Index: src/sys/arch/vax/include/param.h diff -u src/sys/arch/vax/include/param.h:1.59 src/sys/arch/vax/include/param.h:1.60 --- src/sys/arch/vax/include/param.h:1.59 Fri Jan 20 09:08:07 2012 +++ src/sys/arch/vax/include/param.h Tue Jan 24 15:03:38 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.59 2012/01/20 14:08:07 joerg Exp $ */ +/* $NetBSD: param.h,v 1.60 2012/01/24 20:03:38 christos Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. * All rights reserved. @@ -46,22 +46,6 @@ #define MACHINE_ARCH "vax" #define MID_MACHINE MID_VAX -/* - * 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 PGSHIFT 12 /* LOG2(NBPG) */ #define NBPG (1 << PGSHIFT) /* (1 << PGSHIFT) bytes/page */ #define PGOFSET (NBPG - 1) /* byte offset into page */ Index: src/sys/kern/init_main.c diff -u src/sys/kern/init_main.c:1.438 src/sys/kern/init_main.c:1.439 --- src/sys/kern/init_main.c:1.438 Sun Dec 4 14:24:58 2011 +++ src/sys/kern/init_main.c Tue Jan 24 15:03:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.438 2011/12/04 19:24:58 jym Exp $ */ +/* $NetBSD: init_main.c,v 1.439 2012/01/24 20:03:36 christos Exp $ */ /*- * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. @@ -97,7 +97,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.438 2011/12/04 19:24:58 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.439 2012/01/24 20:03:36 christos Exp $"); #include "opt_ddb.h" #include "opt_ipsec.h" @@ -997,7 +997,7 @@ start_init(void *arg) /* * Move out the arg pointers. */ - ucp = (void *)STACK_ALIGN(ucp, ALIGNBYTES); + ucp = (void *)STACK_ALIGN(ucp, STACK_ALIGNBYTES); uap = (char **)STACK_ALLOC(ucp, sizeof(char *) * 3); SCARG(&args, path) = arg0; SCARG(&args, argp) = uap; Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.333 src/sys/kern/kern_exec.c:1.334 --- src/sys/kern/kern_exec.c:1.333 Sun Dec 4 10:12:07 2011 +++ src/sys/kern/kern_exec.c Tue Jan 24 15:03:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.333 2011/12/04 15:12:07 dholland Exp $ */ +/* $NetBSD: kern_exec.c,v 1.334 2012/01/24 20:03:36 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.333 2011/12/04 15:12:07 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.334 2012/01/24 20:03:36 christos Exp $"); #include "opt_exec.h" #include "opt_ktrace.h" @@ -792,11 +792,8 @@ execve1(struct lwp *l, const char *path, len += (cprng_fast32() % PAGE_SIZE); #endif /* PAX_ASLR */ -#ifdef STACKALIGN /* arm, etc. */ - len = STACKALIGN(len); /* make the stack "safely" aligned */ -#else - len = ALIGN(len); /* make the stack "safely" aligned */ -#endif + /* make the stack "safely" aligned */ + len = (size_t)STACK_ALIGN(len, STACK_ALIGNBYTES); if (len > pack.ep_ssize) { /* in effect, compare to initial limit */ DPRINTF(("%s: stack limit exceeded %zu\n", __func__, len)); Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.399 src/sys/sys/param.h:1.400 --- src/sys/sys/param.h:1.399 Fri Jan 13 11:25:16 2012 +++ src/sys/sys/param.h Tue Jan 24 15:03:36 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.399 2012/01/13 16:25:16 macallan Exp $ */ +/* $NetBSD: param.h,v 1.400 2012/01/24 20:03:36 christos Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -204,6 +204,11 @@ * allocated memory. */ #if defined(_KERNEL) || defined(__EXPOSE_STACK) + +#ifndef STACK_ALIGNBYTES +#define STACK_ALIGNBYTES __ALIGNBYTES +#endif + #ifdef __MACHINE_STACK_GROWS_UP #define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size)) #define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size)) @@ -219,9 +224,29 @@ #define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size)) #define STACK_MAX(p, _size) ((char *)(void *)(p)) #endif + #endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */ /* + * 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 +#ifndef ALIGN +#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) +#endif +#ifndef ALIGNED_POINTER +#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t) - 1)) == 0) +#endif + +/* * Historic priority levels. These are meaningless and remain only * for source compatibility. Do not use in new code. */