Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d57731f

Browse files
committed
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.
1 parent c85eb0b commit d57731f

2 files changed

Lines changed: 13 additions & 8 deletions

File tree

Include/pyport.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,19 @@ typedef struct fd_set {
374374
#define LONG_MIN (-LONG_MAX-1)
375375
#endif
376376

377+
#ifndef LONG_BIT
378+
#define LONG_BIT (8 * SIZEOF_LONG)
379+
#endif
380+
381+
#if LONG_BIT != 8 * SIZEOF_LONG
382+
/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
383+
* 32-bit platforms using gcc. We try to catch that here at compile-time
384+
* rather than waiting for integer multiplication to trigger bogus
385+
* overflows.
386+
*/
387+
#error "LONG_BIT definition appears wrong for platform (bad gcc config?)."
388+
#endif
389+
377390
#ifdef __NeXT__
378391
#ifdef __sparc__
379392
/*

Objects/intobject.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
#include "Python.h"
55
#include <ctype.h>
66

7-
#ifndef CHAR_BIT
8-
#define CHAR_BIT 8
9-
#endif
10-
11-
#ifndef LONG_BIT
12-
#define LONG_BIT (CHAR_BIT * sizeof(long))
13-
#endif
14-
157
long
168
PyInt_GetMax(void)
179
{

0 commit comments

Comments
 (0)