Commit 6646cd45 authored by Mark Dickinson's avatar Mark Dickinson

Issue #10325: Fix two issues in the fallback definitions of PY_LLONG_MAX and

PY_ULLONG_MAX in pyport.h.  Thanks Hallvard B Furuseth for the patch.
parent ec0d3558
...@@ -62,15 +62,20 @@ Used in: PY_LONG_LONG ...@@ -62,15 +62,20 @@ Used in: PY_LONG_LONG
#define PY_LLONG_MAX LLONG_MAX #define PY_LLONG_MAX LLONG_MAX
#define PY_ULLONG_MAX ULLONG_MAX #define PY_ULLONG_MAX ULLONG_MAX
#elif defined(__LONG_LONG_MAX__) #elif defined(__LONG_LONG_MAX__)
/* Otherwise, if GCC has a builtin define, use that. */ /* Otherwise, if GCC has a builtin define, use that. (Definition of
* PY_LLONG_MIN assumes two's complement with no trap representation.) */
#define PY_LLONG_MAX __LONG_LONG_MAX__ #define PY_LLONG_MAX __LONG_LONG_MAX__
#define PY_LLONG_MIN (-PY_LLONG_MAX-1) #define PY_LLONG_MIN (-PY_LLONG_MAX - 1)
#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) #define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
#else #elif defined(SIZEOF_LONG_LONG)
/* Otherwise, rely on two's complement. */ /* Otherwise compute from SIZEOF_LONG_LONG, assuming two's complement, no
#define PY_ULLONG_MAX (~0ULL) padding bits, and no trap representation. Note: PY_ULLONG_MAX was
#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) previously #defined as (~0ULL) here; but that'll give the wrong value in a
#define PY_LLONG_MIN (-PY_LLONG_MAX-1) preprocessor expression on systems where long long != intmax_t. */
#define PY_LLONG_MAX \
(1 + 2 * ((Py_LL(1) << (CHAR_BIT * SIZEOF_LONG_LONG - 2)) - 1))
#define PY_LLONG_MIN (-PY_LLONG_MAX - 1)
#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1)
#endif /* LLONG_MAX */ #endif /* LLONG_MAX */
#endif #endif
#endif /* HAVE_LONG_LONG */ #endif /* HAVE_LONG_LONG */
......
...@@ -45,6 +45,12 @@ Tests ...@@ -45,6 +45,12 @@ Tests
- Issue #8886: Use context managers throughout test_zipfile. Patch by - Issue #8886: Use context managers throughout test_zipfile. Patch by
Eric Carstensen. Eric Carstensen.
Build
-----
- Issue #10325: Fix two issues in the fallback definitions for PY_ULLONG_MAX and
PY_LLONG_MAX that made them unsuitable for use in preprocessor conditionals.
What's New in Python 3.2 Alpha 4? What's New in Python 3.2 Alpha 4?
================================= =================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment