summaryrefslogtreecommitdiffstats
path: root/sys/i386/include/param.h
diff options
context:
space:
mode:
authorasmodai <asmodai@FreeBSD.org>2000-11-08 16:59:25 +0000
committerasmodai <asmodai@FreeBSD.org>2000-11-08 16:59:25 +0000
commit97f7cec0968d034bffbf124dc2946ada93fb521a (patch)
treea319994be8baea17b969a2ad4b67bde13b83b362 /sys/i386/include/param.h
parentac72a4e40bac92e338bc519ef554897709c848c1 (diff)
downloadFreeBSD-src-97f7cec0968d034bffbf124dc2946ada93fb521a.zip
FreeBSD-src-97f7cec0968d034bffbf124dc2946ada93fb521a.tar.gz
Fix CMSG and ALIGN macro usage.
Previously we had to include <machine/param.h> or <sys/param.h> bogusly due to the fact that <sys/socket.h> CMSG macros needed the ALIGN macro, which was defined in param.h. However, including param.h was a disaster for namespace pollution. This solution, as contributed by shin a while ago, fixes it elegantly by wrapping the definitions around some namespace pollution preventer definitions. This patch was long overdue. This should allow any network programmer to use <sys/socket.h> as before. PR: 19971, 20530 Submitted by: Martin Kaeske <MartinKaeske@lausitz.net> Mark Andrews <Mark.Andrews@nominum.com> Patch submitted by: shin Reviewed by: bde
Diffstat (limited to 'sys/i386/include/param.h')
-rw-r--r--sys/i386/include/param.h38
1 files changed, 25 insertions, 13 deletions
diff --git a/sys/i386/include/param.h b/sys/i386/include/param.h
index 0d17297..dffc648 100644
--- a/sys/i386/include/param.h
+++ b/sys/i386/include/param.h
@@ -37,21 +37,37 @@
* $FreeBSD$
*/
-#ifndef _MACHINE_PARAM_H_
-#define _MACHINE_PARAM_H_
-
/*
* Machine dependent constants for Intel 386.
*/
+
+/*
+ * Round p (pointer or byte index) up to a correctly-aligned value
+ * for all data types (int, long, ...). The result is unsigned int
+ * and must be cast to any desired pointer type.
+ */
+#ifndef _ALIGNBYTES
+#define _ALIGNBYTES (sizeof(int) - 1)
+#endif
+#ifndef _ALIGN
+#define _ALIGN(p) (((unsigned)(p) + _ALIGNBYTES) & ~_ALIGNBYTES)
+#endif
+
#ifndef _MACHINE
#define _MACHINE i386
#endif
-#ifndef MACHINE
-#define MACHINE "i386"
-#endif
#ifndef _MACHINE_ARCH
#define _MACHINE_ARCH i386
#endif
+
+#ifndef _NO_NAMESPACE_POLLUTION
+
+#ifndef _MACHINE_PARAM_H_
+#define _MACHINE_PARAM_H_
+
+#ifndef MACHINE
+#define MACHINE "i386"
+#endif
#ifndef MACHINE_ARCH
#define MACHINE_ARCH "i386"
#endif
@@ -70,13 +86,8 @@
#define MAXCPU 1
#endif /* SMP */
-/*
- * Round p (pointer or byte index) up to a correctly-aligned value
- * for all data types (int, long, ...). The result is unsigned int
- * and must be cast to any desired pointer type.
- */
-#define ALIGNBYTES (sizeof(int) - 1)
-#define ALIGN(p) (((unsigned)(p) + ALIGNBYTES) & ~ALIGNBYTES)
+#define ALIGNBYTES _ALIGNBYTES
+#define ALIGN(p) _ALIGN(p)
#define PAGE_SHIFT 12 /* LOG2(PAGE_SIZE) */
#define PAGE_SIZE (1<<PAGE_SHIFT) /* bytes/page */
@@ -155,3 +166,4 @@
#define pgtok(x) ((x) * (PAGE_SIZE / 1024))
#endif /* !_MACHINE_PARAM_H_ */
+#endif /* !_NO_NAMESPACE_POLLUTION */
OpenPOWER on IntegriCloud