summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-06-13 03:42:19 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-06-13 03:42:19 (GMT)
commit2a71a47c95701c71bc28314fe005e23fe32ddafb (patch)
tree45c5e3c9346b806e3a7d212a5dc7b13ced226a54
parentde15cdf9953884594b07a2c546eeedea8b290d68 (diff)
downloadcpython-2a71a47c95701c71bc28314fe005e23fe32ddafb.zip
cpython-2a71a47c95701c71bc28314fe005e23fe32ddafb.tar.gz
cpython-2a71a47c95701c71bc28314fe005e23fe32ddafb.tar.bz2
Provide PY_LLONG_MAX on all systems having long long.
Will backport to 2.5.
-rw-r--r--Include/pyport.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/Include/pyport.h b/Include/pyport.h
index 1b274fd..0020d7c 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -62,14 +62,20 @@ Used in: PY_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(__s390__)
-/* Apparently, S390 Linux has long long, but no LLONG_MAX */
-#define PY_LLONG_MAX 9223372036854775807LL
+#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)
-#define PY_ULLONG_MAX 18446744073709551615ULL
#endif /* LLONG_MAX */
#endif
#endif /* HAVE_LONG_LONG */