diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-09-08 03:40:33 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-09-08 03:40:33 +0000 |
commit | 211427d868f8aecd29999f2831103f73bfc92516 (patch) | |
tree | 5a25fcd1af5efcfaa5c78baf48489585ce16228e /sys/arch/sh/include | |
parent | 6f53e4ebb844e940e8bd7264ebb259719834ebe2 (diff) |
Provide namespace-safe alignment macros in <machine/_types.h>, with
compat names kept in <machine/param.h>. In <sys/socket.h>, pull
in <sys/_types.h> instead of the namespace polluting <machine/param.h>
and completely eliminate __CMSG_ALIGN, replaced by _ALIGN
ok deraadt@
Diffstat (limited to 'sys/arch/sh/include')
-rw-r--r-- | sys/arch/sh/include/_types.h | 16 | ||||
-rw-r--r-- | sys/arch/sh/include/param.h | 19 |
2 files changed, 19 insertions, 16 deletions
diff --git a/sys/arch/sh/include/_types.h b/sys/arch/sh/include/_types.h index 39ff7f66070..a690f51bcd8 100644 --- a/sys/arch/sh/include/_types.h +++ b/sys/arch/sh/include/_types.h @@ -1,4 +1,4 @@ -/* $OpenBSD: _types.h,v 1.8 2011/09/08 02:47:13 guenther Exp $ */ +/* $OpenBSD: _types.h,v 1.9 2011/09/08 03:40:32 guenther Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -41,6 +41,20 @@ typedef struct label_t { } label_t; #endif +/* + * _ALIGN(p) rounds p (pointer or byte index) up to a correctly-aligned + * value for all data types (int, long, ...). The result is an + * unsigned 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 (sizeof(int) - 1) +#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) +#define _ALIGNED_POINTER(p,t) ((((unsigned long)(p)) & (sizeof(t) - 1)) == 0) + /* 7.18.1.1 Exact-width integer types */ typedef __signed char __int8_t; typedef unsigned char __uint8_t; diff --git a/sys/arch/sh/include/param.h b/sys/arch/sh/include/param.h index 320d8b0e909..03f39929a21 100644 --- a/sys/arch/sh/include/param.h +++ b/sys/arch/sh/include/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.7 2011/04/07 15:45:18 miod Exp $ */ +/* $OpenBSD: param.h,v 1.8 2011/09/08 03:40:32 guenther Exp $ */ /* $NetBSD: param.h,v 1.15 2006/08/28 13:43:35 yamt Exp $ */ /*- @@ -66,20 +66,9 @@ #define NBPG PAGE_SIZE #define PGOFSET PAGE_MASK -/* - * 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 (sizeof(int) - 1) -#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) & ~ALIGNBYTES) -#define ALIGNED_POINTER(p, t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0) +#define ALIGNBYTES _ALIGNBYTES +#define ALIGN(p) _ALIGN(p) +#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t) #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ #define DEV_BSIZE (1 << DEV_BSHIFT) |