[pypy-commit] pypy py3.6: Partially resync pyport.h with CPython 3.6
rlamy
pypy.commits at gmail.com
Thu Jan 9 15:21:09 EST 2020
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.6
Changeset: r98503:1b19e41a3920
Date: 2020-01-09 20:16 +0000
http://bitbucket.org/pypy/pypy/changeset/1b19e41a3920/
Log: Partially resync pyport.h with CPython 3.6
diff --git a/pypy/module/cpyext/include/pyport.h b/pypy/module/cpyext/include/pyport.h
--- a/pypy/module/cpyext/include/pyport.h
+++ b/pypy/module/cpyext/include/pyport.h
@@ -5,115 +5,34 @@
#include <stdint.h>
#endif
-/* typedefs for some C9X-defined synonyms for integral types. */
-#ifdef HAVE_LONG_LONG
+/* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */
+#ifndef HAVE_LONG_LONG
+#define HAVE_LONG_LONG 1
+#endif
#ifndef PY_LONG_LONG
#define PY_LONG_LONG long long
-#if defined(LLONG_MAX)
/* If LLONG_MAX is defined in limits.h, use that. */
#define PY_LLONG_MIN LLONG_MIN
#define PY_LLONG_MAX LLONG_MAX
#define PY_ULLONG_MAX ULLONG_MAX
-#elif defined(__LONG_LONG_MAX__)
-/* Otherwise, if GCC has a builtin define, use that. */
-#define PY_LLONG_MAX __LONG_LONG_MAX__
-#define PY_LLONG_MIN (-PY_LLONG_MAX-1)
-#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL)
-#else
-/* Otherwise, rely on two's complement. */
-#define PY_ULLONG_MAX (~0ULL)
-#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1))
-#define PY_LLONG_MIN (-PY_LLONG_MAX-1)
-#endif /* LLONG_MAX */
-#endif
-#endif /* HAVE_LONG_LONG */
-
-/* a build with 30-bit digits for Python long integers needs an exact-width
- * 32-bit unsigned integer type to store those digits. (We could just use
- * type 'unsigned long', but that would be wasteful on a system where longs
- * are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines
- * uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t.
- * However, it doesn't set HAVE_UINT32_T, so we do that here.
- */
-#ifdef uint32_t
-#define HAVE_UINT32_T 1
#endif
-#ifdef HAVE_UINT32_T
-#ifndef PY_UINT32_T
#define PY_UINT32_T uint32_t
-#endif
-#endif
-
-/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the
- * long integer implementation, when 30-bit digits are enabled.
- */
-#ifdef uint64_t
-#define HAVE_UINT64_T 1
-#endif
-
-#ifdef HAVE_UINT64_T
-#ifndef PY_UINT64_T
#define PY_UINT64_T uint64_t
-#endif
-#endif
/* Signed variants of the above */
-#ifdef int32_t
-#define HAVE_INT32_T 1
-#endif
+#define PY_INT32_T int32_t
+#define PY_INT64_T int64_t
-#ifdef HAVE_INT32_T
-#ifndef PY_INT32_T
-#define PY_INT32_T int32_t
-#endif
-#endif
-
-#ifdef int64_t
-#define HAVE_INT64_T 1
-#endif
-
-#ifdef HAVE_INT64_T
-#ifndef PY_INT64_T
-#define PY_INT64_T int64_t
-#endif
-#endif
/* uintptr_t is the C9X name for an unsigned integral type such that a
* legitimate void* can be cast to uintptr_t and then back to void* again
* without loss of information. Similarly for intptr_t, wrt a signed
* integral type.
*/
-#ifdef HAVE_UINTPTR_T
typedef uintptr_t Py_uintptr_t;
typedef intptr_t Py_intptr_t;
-#elif SIZEOF_VOID_P <= SIZEOF_INT
-typedef unsigned int Py_uintptr_t;
-typedef int Py_intptr_t;
-
-#elif SIZEOF_VOID_P <= SIZEOF_LONG
-typedef unsigned long Py_uintptr_t;
-typedef long Py_intptr_t;
-
-#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG)
-typedef unsigned PY_LONG_LONG Py_uintptr_t;
-typedef PY_LONG_LONG Py_intptr_t;
-
-#else
-# error "Python needs a typedef for Py_uintptr_t in pyport.h."
-#endif /* HAVE_UINTPTR_T */
-
-/* Largest possible value of size_t.
- SIZE_MAX is part of C99, so it might be defined on some
- platforms. If it is not defined, (size_t)-1 is a portable
- definition for C89, due to the way signed->unsigned
- conversion is defined. */
-#ifdef SIZE_MAX
-#define PY_SIZE_MAX SIZE_MAX
-#else
-#define PY_SIZE_MAX ((size_t)-1)
-#endif
/* Py_hash_t is the same size as a pointer. */
#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
@@ -122,18 +41,16 @@
#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T
typedef size_t Py_uhash_t;
+/* Largest possible value of size_t. */
+#define PY_SIZE_MAX SIZE_MAX
+
+/* Largest positive value of type Py_ssize_t. */
+#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
+/* Smallest negative value of type Py_ssize_t. */
+#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
+
#include <stdarg.h>
-#ifdef __va_copy
-#define Py_VA_COPY __va_copy
-#else
-#ifdef VA_LIST_IS_ARRAY
-#define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list))
-#else
-#define Py_VA_COPY(x, y) (x) = (y)
-#endif
-#endif
-
/* CPython needs this for the c-extension datetime, which is pure python on PyPy
downstream packages assume it is here (Pandas for instance) */
#include <time.h>
@@ -183,8 +100,7 @@
* Hide GCC attributes from compilers that don't support them.
*/
#if (!defined(__GNUC__) || __GNUC__ < 2 || \
- (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \
- !defined(RISCOS)
+ (__GNUC__ == 2 && __GNUC_MINOR__ < 7) )
#define Py_GCC_ATTRIBUTE(x)
#else
#define Py_GCC_ATTRIBUTE(x) __attribute__(x)
@@ -206,10 +122,6 @@
#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED)
#endif
-/*
- * Older Microsoft compilers don't support the C99 long long literal suffixes,
- * so these will be defined in PC/pyconfig.h for those compilers.
- */
#ifndef Py_LL
#define Py_LL(x) x##LL
#endif
@@ -218,4 +130,7 @@
#define Py_ULL(x) Py_LL(x##U)
#endif
+#define Py_VA_COPY va_copy
+
+
#endif /* Py_PYPORT_H */
More information about the pypy-commit
mailing list