diff options
author | asmodai <asmodai@FreeBSD.org> | 2000-11-08 16:59:25 +0000 |
---|---|---|
committer | asmodai <asmodai@FreeBSD.org> | 2000-11-08 16:59:25 +0000 |
commit | 97f7cec0968d034bffbf124dc2946ada93fb521a (patch) | |
tree | a319994be8baea17b969a2ad4b67bde13b83b362 /sys/alpha/include | |
parent | ac72a4e40bac92e338bc519ef554897709c848c1 (diff) | |
download | FreeBSD-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/alpha/include')
-rw-r--r-- | sys/alpha/include/param.h | 54 |
1 files changed, 37 insertions, 17 deletions
diff --git a/sys/alpha/include/param.h b/sys/alpha/include/param.h index ae641f6..7c0f1af 100644 --- a/sys/alpha/include/param.h +++ b/sys/alpha/include/param.h @@ -46,15 +46,43 @@ /* * Machine dependent constants for the Alpha. */ + +/* + * 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 7 +#endif +#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 _MACHINE #define _MACHINE alpha #endif -#ifndef MACHINE -#define MACHINE "alpha" -#endif #ifndef _MACHINE_ARCH #define _MACHINE_ARCH alpha #endif + +#ifndef _NO_NAMESPACE_POLLUTION + +#ifndef _MACHINE_PARAM_H_ +#define _MACHINE_PARAM_H_ + +#ifndef MACHINE +#define MACHINE "alpha" +#endif #ifndef MACHINE_ARCH #define MACHINE_ARCH "alpha" #endif @@ -76,20 +104,9 @@ #define MAXCPU 1 #endif -/* - * 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 7 -#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 PAGE_SIZE (1 << ALPHA_PGSHIFT) /* bytes/page */ #define PAGE_SHIFT ALPHA_PGSHIFT @@ -157,3 +174,6 @@ #define alpha_ptob(x) ((unsigned long)(x) << PAGE_SHIFT) #define pgtok(x) ((x) * (PAGE_SIZE / 1024)) + +#endif /* !_MACHINE_PARAM_H_ */ +#endif /* !_NO_NAMESPACE_POLLUTION */ |