[pypy-svn] r78836 - pypy/branch/fast-forward/pypy/module/cpyext/include

afa at codespeak.net afa at codespeak.net
Sun Nov 7 20:48:07 CET 2010


Author: afa
Date: Sun Nov  7 20:48:06 2010
New Revision: 78836

Modified:
   pypy/branch/fast-forward/pypy/module/cpyext/include/pyconfig.h
   pypy/branch/fast-forward/pypy/module/cpyext/include/pyport.h
Log:
Add constants: PY_LLONG_MAX &co


Modified: pypy/branch/fast-forward/pypy/module/cpyext/include/pyconfig.h
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/include/pyconfig.h	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/include/pyconfig.h	Sun Nov  7 20:48:06 2010
@@ -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

Modified: pypy/branch/fast-forward/pypy/module/cpyext/include/pyport.h
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/include/pyport.h	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/include/pyport.h	Sun Nov  7 20:48:06 2010
@@ -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



More information about the Pypy-commit mailing list