From 8c393fd1f0cc514a007104469b11eaeeefb829b6 Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Sun, 5 Jul 2009 17:45:48 +0000 Subject: [PATCH] Cleanup ALIGNED_POINTER: o add to platforms where it was missing (arm, i386, powerpc, sparc64, sun4v) o define as "1" on amd64 and i386 where there is no restriction o make the type returned consistent with ALIGN o remove _ALIGNED_POINTER o make associated comments consistent Reviewed by: bde, imp, marcel Approved by: re (kensmith) --- sys/amd64/include/param.h | 17 +++++++---------- sys/arm/include/param.h | 7 +++++++ sys/i386/include/param.h | 7 +++++++ sys/ia64/include/param.h | 20 +++----------------- sys/mips/include/param.h | 8 +++++++- sys/powerpc/include/param.h | 7 +++++++ sys/sparc64/include/param.h | 7 +++++++ sys/sun4v/include/param.h | 7 +++++++ 8 files changed, 52 insertions(+), 28 deletions(-) diff --git a/sys/amd64/include/param.h b/sys/amd64/include/param.h index 8ab4cffd19a..edcf427df3e 100644 --- a/sys/amd64/include/param.h +++ b/sys/amd64/include/param.h @@ -47,12 +47,6 @@ * 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). - * */ #ifndef _ALIGNBYTES #define _ALIGNBYTES (sizeof(long) - 1) @@ -60,9 +54,6 @@ #ifndef _ALIGN #define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) #endif -#ifndef _ALIGNED_POINTER -#define _ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) -#endif #ifndef _NO_NAMESPACE_POLLUTION @@ -87,7 +78,13 @@ #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) -#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t) +/* + * 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 ALIGNED_POINTER(p, t) 1 /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/arm/include/param.h b/sys/arm/include/param.h index 802390bc8f7..c6801487c46 100644 --- a/sys/arm/include/param.h +++ b/sys/arm/include/param.h @@ -80,6 +80,13 @@ #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) +/* + * 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 ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof(t)-1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h index a6108db09e4..2bcbaf478c9 100644 --- a/sys/i386/include/param.h +++ b/sys/i386/include/param.h @@ -73,6 +73,13 @@ #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) +/* + * 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 ALIGNED_POINTER(p, t) 1 /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/ia64/include/param.h b/sys/ia64/include/param.h index f59c40883b7..cb805a6b344 100644 --- a/sys/ia64/include/param.h +++ b/sys/ia64/include/param.h @@ -46,12 +46,6 @@ * 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). - * */ #ifndef _ALIGNBYTES #define _ALIGNBYTES 15 @@ -59,9 +53,6 @@ #ifndef _ALIGN #define _ALIGN(p) (((u_long)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) #endif -#ifndef _ALIGNED_POINTER -#define _ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) -#endif #ifndef _NO_NAMESPACE_POLLUTION @@ -84,20 +75,15 @@ #define MAXCPU 1 #endif +#define ALIGNBYTES _ALIGNBYTES +#define ALIGN(p) _ALIGN(p) /* - * 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) _ALIGN(p) -#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t) +#define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/mips/include/param.h b/sys/mips/include/param.h index ea599d11f5e..250de77ba7e 100644 --- a/sys/mips/include/param.h +++ b/sys/mips/include/param.h @@ -84,10 +84,16 @@ */ #define _ALIGNBYTES 7 #define _ALIGN(p) (((u_int)(p) + _ALIGNBYTES) &~ _ALIGNBYTES) -#define ALIGNED_POINTER(p, t) ((((u_int32_t)(p)) & (sizeof (t) - 1)) == 0) #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) +/* + * 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 ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/powerpc/include/param.h b/sys/powerpc/include/param.h index a9142c6df14..9728fe416c0 100644 --- a/sys/powerpc/include/param.h +++ b/sys/powerpc/include/param.h @@ -78,6 +78,13 @@ #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) +/* + * 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 ALIGNED_POINTER(p, t) ((((unsigned)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/sparc64/include/param.h b/sys/sparc64/include/param.h index f09a6cda503..ebd7f0d1128 100644 --- a/sys/sparc64/include/param.h +++ b/sys/sparc64/include/param.h @@ -70,6 +70,13 @@ #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) +/* + * 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 ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an diff --git a/sys/sun4v/include/param.h b/sys/sun4v/include/param.h index e42abf50c97..4b26748cb98 100644 --- a/sys/sun4v/include/param.h +++ b/sys/sun4v/include/param.h @@ -70,6 +70,13 @@ #define ALIGNBYTES _ALIGNBYTES #define ALIGN(p) _ALIGN(p) +/* + * 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 ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof (t) - 1)) == 0) /* * CACHE_LINE_SIZE is the compile-time maximum cache line size for an