[pypy-svn] pypy default: Add constants: PY_LLONG_MAX &co

amauryfa commits-noreply at bitbucket.org
Fri Dec 17 19:00:15 CET 2010


Author: Amaury Forgeot d'Arc <amauryfa at gmail.com>
Branch: 
Changeset: r40099:00f508cb268c
Date: 2010-11-07 19:48 +0000
http://bitbucket.org/pypy/pypy/changeset/00f508cb268c/

Log:	Add constants: PY_LLONG_MAX &co

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,6 +5,29 @@
 #include <stdint.h>
 #endif
 
+/* typedefs for some C9X-defined synonyms for integral types. */
+#ifdef HAVE_LONG_LONG
+#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 */
+
 /* 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

diff --git a/pypy/module/cpyext/include/pyconfig.h b/pypy/module/cpyext/include/pyconfig.h
--- a/pypy/module/cpyext/include/pyconfig.h
+++ b/pypy/module/cpyext/include/pyconfig.h
@@ -10,7 +10,6 @@
 #define HAVE_LONG_LONG 1
 #define HAVE_STDARG_PROTOTYPES 1
 #define PY_FORMAT_LONG_LONG "ll"
-#define PY_LONG_LONG long long
 #define PY_FORMAT_SIZE_T "z"
 #define WITH_DOC_STRINGS
 #define HAVE_UNICODE



More information about the Pypy-commit mailing list