From d57731f74bdaaf6bb5ce190b5ccebadad218ed2b Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Thu, 5 Oct 2000 01:42:25 +0000 Subject: [PATCH] Move LONG_BIT from intobject.c to pyport.h. #error if it's already been #define'd to an unreasonable value (several recent gcc systems have misdefined it, causing bogus overflows in integer multiplication). Nuke CHAR_BIT entirely. --- Include/pyport.h | 13 +++++++++++++ Objects/intobject.c | 8 -------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Include/pyport.h b/Include/pyport.h index 4914886df15..f35d8e66152 100644 --- a/Include/pyport.h +++ b/Include/pyport.h @@ -374,6 +374,19 @@ typedef struct fd_set { #define LONG_MIN (-LONG_MAX-1) #endif +#ifndef LONG_BIT +#define LONG_BIT (8 * SIZEOF_LONG) +#endif + +#if LONG_BIT != 8 * SIZEOF_LONG +/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent + * 32-bit platforms using gcc. We try to catch that here at compile-time + * rather than waiting for integer multiplication to trigger bogus + * overflows. + */ +#error "LONG_BIT definition appears wrong for platform (bad gcc config?)." +#endif + #ifdef __NeXT__ #ifdef __sparc__ /* diff --git a/Objects/intobject.c b/Objects/intobject.c index 8477a023817..b88a05de197 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -4,14 +4,6 @@ #include "Python.h" #include -#ifndef CHAR_BIT -#define CHAR_BIT 8 -#endif - -#ifndef LONG_BIT -#define LONG_BIT (CHAR_BIT * sizeof(long)) -#endif - long PyInt_GetMax(void) {