]> granicus.if.org Git - python/commitdiff
Move LONG_BIT from intobject.c to pyport.h. #error if it's already been
authorTim Peters <tim.peters@gmail.com>
Thu, 5 Oct 2000 01:42:25 +0000 (01:42 +0000)
committerTim Peters <tim.peters@gmail.com>
Thu, 5 Oct 2000 01:42:25 +0000 (01:42 +0000)
#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
Objects/intobject.c

index 4914886df15edb3421bad6608266d9cdbb028ea0..f35d8e661523ce71524e536f595ed5ed372e2d76 100644 (file)
@@ -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__
 /*
index 8477a02381792ce85b6e5515684bfc2297c89549..b88a05de19753ba76e5367ef7bb53f4634bc4938 100644 (file)
@@ -4,14 +4,6 @@
 #include "Python.h"
 #include <ctype.h>
 
-#ifndef CHAR_BIT
-#define CHAR_BIT 8
-#endif
-
-#ifndef LONG_BIT
-#define LONG_BIT (CHAR_BIT * sizeof(long))
-#endif
-
 long
 PyInt_GetMax(void)
 {