summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-09-26 05:46:01 (GMT)
committerFred Drake <fdrake@acm.org>2000-09-26 05:46:01 (GMT)
commitd5fadf75e4d18df61db41205ace0cda28d98eeaa (patch)
tree1b82c40e9bacf707cc8411fb9f0b6816c6f857d4 /Include
parent1b6185941ee5ccbfb7bb79ef2fcd55e279ade902 (diff)
downloadcpython-d5fadf75e4d18df61db41205ace0cda28d98eeaa.zip
cpython-d5fadf75e4d18df61db41205ace0cda28d98eeaa.tar.gz
cpython-d5fadf75e4d18df61db41205ace0cda28d98eeaa.tar.bz2
Rationalize use of limits.h, moving the inclusion to Python.h.
Add definitions of INT_MAX and LONG_MAX to pyport.h. Remove includes of limits.h and conditional definitions of INT_MAX and LONG_MAX elsewhere. This closes SourceForge patch #101659 and bug #115323.
Diffstat (limited to 'Include')
-rw-r--r--Include/Python.h4
-rw-r--r--Include/longobject.h7
-rw-r--r--Include/pyport.h32
3 files changed, 36 insertions, 7 deletions
diff --git a/Include/Python.h b/Include/Python.h
index 153ba07..3086552 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -23,6 +23,10 @@
#include "patchlevel.h"
#include "config.h"
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
/* config.h may or may not define DL_IMPORT */
#ifndef DL_IMPORT /* declarations for DLL import/export */
#define DL_IMPORT(RTYPE) RTYPE
diff --git a/Include/longobject.h b/Include/longobject.h
index f2dea93..7ebceec 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -24,14 +24,7 @@ extern DL_IMPORT(void *) PyLong_AsVoidPtr(PyObject *);
#ifdef HAVE_LONG_LONG
-#ifdef HAVE_LIMITS_H
-#include <limits.h>
-#endif
-
/* Hopefully this is portable... */
-#ifndef LONG_MAX
-#define LONG_MAX 2147483647L
-#endif
#ifndef ULONG_MAX
#define ULONG_MAX 4294967295U
#endif
diff --git a/Include/pyport.h b/Include/pyport.h
index 48cd45b..4914886 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -354,6 +354,38 @@ typedef struct fd_set {
#endif /* fd manipulation macros */
+/* limits.h constants that may be missing */
+
+#ifndef INT_MAX
+#define INT_MAX 2147483647
+#endif
+
+#ifndef LONG_MAX
+#if SIZEOF_LONG == 4
+#define LONG_MAX 0X7FFFFFFFL
+#elif SIZEOF_LONG == 8
+#define LONG_MAX 0X7FFFFFFFFFFFFFFFL
+#else
+#error "could not set LONG_MAX in pyport.h"
+#endif
+#endif
+
+#ifndef LONG_MIN
+#define LONG_MIN (-LONG_MAX-1)
+#endif
+
+#ifdef __NeXT__
+#ifdef __sparc__
+/*
+ * This works around a bug in the NS/Sparc 3.3 pre-release
+ * limits.h header file.
+ * 10-Feb-1995 bwarsaw@cnri.reston.va.us
+ */
+#undef LONG_MIN
+#define LONG_MIN (-LONG_MAX-1)
+#endif
+#endif
+
#ifdef __cplusplus
}
#endif