Messages in this thread Patches in this message | | | Date | Wed, 17 Dec 1997 23:57:13 +0100 | From | Pavel Machek <> | Subject | ARCH32BIT, ARCH64BIT defines |
| |
Hi!
Sometimes through the code (like in printk( "%08lx" );) knowing whether architecture is 32 or 64 bit would be nice. Yes, you can do it by if ((sizeof( long))==4) and hope that gcc optimizes it right, but this is more convient:
#ifdef ARCH32BIT #define X "8" #else #define X "16" #endif
...
printk( "%0" X "lx" );
When creating patch, I found out some strange things in 64 bit includes - like tests for 64 bit kernel, compiled by 32 bit compiler. I think that tests are unnecessary, since that can not happen. I put #error's there.
Is good think (tm), please apply. Pavel
--- clean/include/asm-alpha/types.h Tue Mar 26 15:47:39 1996 +++ linux/include/asm-alpha/types.h Wed Dec 17 20:49:41 1997 @@ -46,6 +46,7 @@ * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ +#define ARCH64BIT typedef signed char s8; typedef unsigned char u8; @@ -58,9 +59,12 @@ /* * There are 32-bit compilers for the alpha out there.. + * (hmm, but you are probably not going to compile kernel + * with them, are you?!) */ #if ((~0UL) == 0xffffffff) +#error Sorry, I thought this cannot happen - pavel@atrey.karlin.mff.cuni.cz typedef signed long long s64; typedef unsigned long long u64; --- clean/include/asm-i386/types.h Tue Mar 26 15:47:23 1996 +++ linux/include/asm-i386/types.h Wed Dec 17 20:47:43 1997 @@ -26,6 +26,7 @@ * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ +#define ARCH32BIT typedef signed char s8; typedef unsigned char u8; --- clean/include/asm-m68k/types.h Fri Apr 5 13:08:41 1996 +++ linux/include/asm-m68k/types.h Wed Dec 17 20:50:04 1997 @@ -34,6 +34,7 @@ * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ +#define ARCH32BIT typedef signed char s8; typedef unsigned char u8; --- clean/include/asm-mips/types.h Thu Jun 26 21:33:40 1997 +++ linux/include/asm-mips/types.h Wed Dec 17 20:51:08 1997 @@ -44,6 +44,7 @@ * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ +#define ARCH64BIT typedef __signed char s8; typedef unsigned char u8; @@ -57,6 +58,7 @@ #if ((~0UL) == 0xffffffff) #if defined(__GNUC__) && !defined(__STRICT_ANSI__) +#error 32bit compiler for kernel? typedef __signed__ long long s64; typedef unsigned long long u64; #endif --- clean/include/asm-ppc/types.h Mon May 27 11:00:59 1996 +++ linux/include/asm-ppc/types.h Wed Dec 17 20:51:21 1997 @@ -26,6 +26,7 @@ * These aren't exported outside the kernel to avoid name space clashes */ #ifdef __KERNEL__ +#define ARCH32BIT typedef signed char s8; typedef unsigned char u8; --- clean/include/asm-sparc/types.h Sat Nov 9 09:30:19 1996 +++ linux/include/asm-sparc/types.h Wed Dec 17 20:52:10 1997 @@ -26,10 +26,12 @@ typedef __signed__ int __s32; typedef unsigned int __u32; +/* Should not this be wrapped by #if GNUC? -- pavel@atrey.karlin.mff.cuni.cz */ typedef __signed__ long long __s64; typedef unsigned long long __u64; #ifdef __KERNEL__ +#define ARCH32BIT typedef __signed__ char s8; typedef unsigned char u8; --- clean/include/asm-sparc64/types.h Fri Dec 13 10:37:47 1996 +++ linux/include/asm-sparc64/types.h Wed Dec 17 20:52:32 1997 @@ -30,6 +30,7 @@ typedef unsigned long __u64; #ifdef __KERNEL__ +#define ARCH64BIT typedef __signed__ char s8; typedef unsigned char u8;
-- I'm really pavel@atrey.karlin.mff.cuni.cz. Pavel Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).
| |