Skip to content

Commit 4fe5510

Browse files
committed
require standard int types to be defined (python#17884)
1 parent 39093e9 commit 4fe5510

9 files changed

Lines changed: 15 additions & 401 deletions

File tree

Include/longintrepr.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ extern "C" {
4242
*/
4343

4444
#if PYLONG_BITS_IN_DIGIT == 30
45-
#if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \
46-
defined HAVE_INT64_T && defined HAVE_INT32_T)
47-
#error "30-bit long digits requested, but the necessary types are not available on this platform"
48-
#endif
4945
typedef PY_UINT32_T digit;
5046
typedef PY_INT32_T sdigit; /* signed variant of digit */
5147
typedef PY_UINT64_T twodigits;

Include/pyport.h

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55

66
/* Some versions of HP-UX & Solaris need inttypes.h for int32_t,
77
INT32_MAX, etc. */
8-
#ifdef HAVE_INTTYPES_H
98
#include <inttypes.h>
10-
#endif
11-
12-
#ifdef HAVE_STDINT_H
139
#include <stdint.h>
14-
#endif
1510

1611
/**************************************************************************
1712
Symbols and macros to supply platform-independent interfaces to basic
@@ -74,64 +69,19 @@ Used in: Py_uintptr_t
7469
#endif /* LLONG_MAX */
7570
#endif
7671

77-
/* a build with 30-bit digits for Python integers needs an exact-width
78-
* 32-bit unsigned integer type to store those digits. (We could just use
79-
* type 'unsigned long', but that would be wasteful on a system where longs
80-
* are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines
81-
* uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t.
82-
* However, it doesn't set HAVE_UINT32_T, so we do that here.
83-
*/
84-
#ifdef uint32_t
85-
#define HAVE_UINT32_T 1
86-
#endif
87-
88-
#ifdef HAVE_UINT32_T
89-
#ifndef PY_UINT32_T
9072
#define PY_UINT32_T uint32_t
91-
#endif
92-
#endif
93-
94-
/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the
95-
* integer implementation, when 30-bit digits are enabled.
96-
*/
97-
#ifdef uint64_t
98-
#define HAVE_UINT64_T 1
99-
#endif
100-
101-
#ifdef HAVE_UINT64_T
102-
#ifndef PY_UINT64_T
10373
#define PY_UINT64_T uint64_t
104-
#endif
105-
#endif
10674

10775
/* Signed variants of the above */
108-
#ifdef int32_t
109-
#define HAVE_INT32_T 1
110-
#endif
111-
112-
#ifdef HAVE_INT32_T
113-
#ifndef PY_INT32_T
11476
#define PY_INT32_T int32_t
115-
#endif
116-
#endif
117-
118-
#ifdef int64_t
119-
#define HAVE_INT64_T 1
120-
#endif
121-
122-
#ifdef HAVE_INT64_T
123-
#ifndef PY_INT64_T
12477
#define PY_INT64_T int64_t
125-
#endif
126-
#endif
12778

12879
/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all
12980
the necessary integer types are available, and we're on a 64-bit platform
13081
(as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */
13182

13283
#ifndef PYLONG_BITS_IN_DIGIT
133-
#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \
134-
defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8)
84+
#if SIZEOF_VOID_P >= 8
13585
#define PYLONG_BITS_IN_DIGIT 30
13686
#else
13787
#define PYLONG_BITS_IN_DIGIT 15

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 3.6.0 beta 1
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #17884: Python now requires systems with inttypes.h and stdint.h
14+
1315
- Issue #27961?: Require platforms to support ``long long``. Python hasn't
1416
compiled without ``long long`` for years, so this is basically a formality.
1517

Modules/_testcapimodule.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,14 @@ test_sizeof_c_types(PyObject *self)
9898
CHECK_SIGNNESS(Py_UCS1, 0);
9999
CHECK_SIGNNESS(Py_UCS2, 0);
100100
CHECK_SIGNNESS(Py_UCS4, 0);
101-
#ifdef HAVE_INT32_T
102101
CHECK_SIZEOF(PY_INT32_T, 4);
103102
CHECK_SIGNNESS(PY_INT32_T, 1);
104-
#endif
105-
#ifdef HAVE_UINT32_T
106103
CHECK_SIZEOF(PY_UINT32_T, 4);
107104
CHECK_SIGNNESS(PY_UINT32_T, 0);
108-
#endif
109-
#ifdef HAVE_INT64_T
110105
CHECK_SIZEOF(PY_INT64_T, 8);
111106
CHECK_SIGNNESS(PY_INT64_T, 1);
112-
#endif
113-
#ifdef HAVE_UINT64_T
114107
CHECK_SIZEOF(PY_UINT64_T, 8);
115108
CHECK_SIGNNESS(PY_UINT64_T, 0);
116-
#endif
117109

118110
/* pointer/size types */
119111
CHECK_SIZEOF(size_t, sizeof(void *));

PC/pyconfig.h

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -365,39 +365,10 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
365365

366366
/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the
367367
implementation of Python integers. */
368-
#ifndef PY_UINT32_T
369-
#if SIZEOF_INT == 4
370-
#define HAVE_UINT32_T 1
371-
#define PY_UINT32_T unsigned int
372-
#elif SIZEOF_LONG == 4
373-
#define HAVE_UINT32_T 1
374-
#define PY_UINT32_T unsigned long
375-
#endif
376-
#endif
377-
378-
#ifndef PY_UINT64_T
379-
#if SIZEOF_LONG_LONG == 8
380-
#define HAVE_UINT64_T 1
381-
#define PY_UINT64_T unsigned long long
382-
#endif
383-
#endif
384-
385-
#ifndef PY_INT32_T
386-
#if SIZEOF_INT == 4
387-
#define HAVE_INT32_T 1
388-
#define PY_INT32_T int
389-
#elif SIZEOF_LONG == 4
390-
#define HAVE_INT32_T 1
391-
#define PY_INT32_T long
392-
#endif
393-
#endif
394-
395-
#ifndef PY_INT64_T
396-
#if SIZEOF_LONG_LONG == 8
397-
#define HAVE_INT64_T 1
398-
#define PY_INT64_T long long
399-
#endif
400-
#endif
368+
#define PY_UINT32_T uint32_t
369+
#define PY_UINT64_T uint64_t
370+
#define PY_INT32_T int32_t
371+
#define PY_INT64_T int64_t
401372

402373
/* Fairly standard from here! */
403374

Python/dtoa.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,9 @@
151151
#endif
152152

153153

154-
#if defined(HAVE_UINT32_T) && defined(HAVE_INT32_T)
155-
typedef PY_UINT32_T ULong;
156-
typedef PY_INT32_T Long;
157-
#else
158-
#error "Failed to find an exact-width 32-bit integer type"
159-
#endif
160-
161-
#if defined(HAVE_UINT64_T)
162-
#define ULLong PY_UINT64_T
163-
#else
164-
#undef ULLong
165-
#endif
154+
typedef uint32_t ULong;
155+
typedef int32_t Long;
156+
typedef uint64_t ULLong;
166157

167158
#undef DEBUG
168159
#ifdef Py_DEBUG

0 commit comments

Comments
 (0)