summaryrefslogtreecommitdiff
path: root/sys/arch/amd64/include
diff options
context:
space:
mode:
authorPhilip Guenthe <guenther@cvs.openbsd.org>2011-09-08 03:40:33 +0000
committerPhilip Guenthe <guenther@cvs.openbsd.org>2011-09-08 03:40:33 +0000
commit211427d868f8aecd29999f2831103f73bfc92516 (patch)
tree5a25fcd1af5efcfaa5c78baf48489585ce16228e /sys/arch/amd64/include
parent6f53e4ebb844e940e8bd7264ebb259719834ebe2 (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/amd64/include')
-rw-r--r--sys/arch/amd64/include/_types.h16
-rw-r--r--sys/arch/amd64/include/param.h19
2 files changed, 19 insertions, 16 deletions
diff --git a/sys/arch/amd64/include/_types.h b/sys/arch/amd64/include/_types.h
index b0a0b51e129..ed5ce0d4990 100644
--- a/sys/arch/amd64/include/_types.h
+++ b/sys/arch/amd64/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
@@ -35,6 +35,20 @@
#ifndef _MACHINE__TYPES_H_
#define _MACHINE__TYPES_H_
+/*
+ * _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(long) - 1)
+#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) &~_ALIGNBYTES)
+#define _ALIGNED_POINTER(p,t) 1
+
#if defined(_KERNEL)
typedef struct label_t {
long val[8];
diff --git a/sys/arch/amd64/include/param.h b/sys/arch/amd64/include/param.h
index 89cfe97cde1..f7a1017d30a 100644
--- a/sys/arch/amd64/include/param.h
+++ b/sys/arch/amd64/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.17 2010/11/29 00:06:04 dlg Exp $ */
+/* $OpenBSD: param.h,v 1.18 2011/09/08 03:40:32 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -48,20 +48,9 @@
#define MACHINE_ARCH "amd64"
#define MID_MACHINE MID_AMD64
-/*
- * 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(long) - 1)
-#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ALIGNBYTES)
-#define ALIGNED_POINTER(p,t) 1
+#define ALIGNBYTES _ALIGNBYTES
+#define ALIGN(p) _ALIGN(p)
+#define ALIGNED_POINTER(p,t) _ALIGNED_POINTER(p,t)
#define PGSHIFT 12 /* LOG2(NBPG) */
#define NBPG (1 << PGSHIFT) /* bytes/page */