[OpenBIOS] 64bit paflof with lots of gnuisms
Parag Patel
parag at codegen.com
Mon Jun 3 12:48:53 CEST 2002
In message <20020603181539.GB19105 at suse.de>, Stefan Reinauer writes:
> typedef intptr_t type_n; // cell size
> typedef uintptr_t type_u; // cell size
>+#if defined(__alpha__) || defined(__x86_64__) || \
>+ defined(__ia64__) || defined(ppc64)
>+typedef intmax_t type_d __attribute__ ((mode (TI))); // 2 * cell size
>+typedef uintmax_t type_du __attribute__ ((mode (TI))); // 2 * cell size
>+#else
> typedef intmax_t type_d; // 2 * cell size
> typedef uintmax_t type_du; // 2 * cell size
>+#endif
> #else
Dunno about the Gnu-isms, 'cause we avoid 'em in SmartFirmware, but
as a general rule, you should change your defines to something like
this:
> typedef intptr_t type_n; // cell size
> typedef uintptr_t type_u; // cell size
>+#ifdef int64_type
>+typedef intmax_t type_d __attribute__ ((mode (TI))); // 2 * cell size
>+typedef uintmax_t type_du __attribute__ ((mode (TI))); // 2 * cell size
>+#else
> typedef intmax_t type_d; // 2 * cell size
> typedef uintmax_t type_du; // 2 * cell size
>+#endif
> #else
and have a machine-dependent section that sets int64_type (or whatever)
based on the CPU type or some-such. Make the macros reflect the
specific feature directly.
We use two different macros defined in a machdep.h header file, which is
customized for each platform and compiler. One macro determines the
presence/absence of 64-bit ints (say INT_64BIT) and another determines
if pointers will be 64-bits or not (PTR_64BIT). Only one place needs to
specify the settings of these macros, machdep.h, and every other common
source file is neatly disconnected from any machine dependancies.
As for the Gnu-isms, we wrap the necessary code in #ifdef __GNUC__, in
some cases creating a null macro to reduce the subsequent ifdef mess:
#ifndef __GNU_C__
#define __attribute__(arg) /* noop */
#endif
Obviously, there are other ways to deal with this as well.
Just for what it's worth.
-- Parag
-
To unsubscribe: send mail to majordomo at freiburg.linux.de
with 'unsubscribe openbios' in the body of the message
http://www.freiburg.linux.de/OpenBIOS/ - free your system..
More information about the openbios
mailing list