@@ -114,17 +114,23 @@ typedef intptr_t Py_intptr_t;
114114/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
115115 * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
116116 * unsigned integral type). See PEP 353 for details.
117+ * PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t.
117118 */
118119#ifdef HAVE_PY_SSIZE_T
119120
120121#elif HAVE_SSIZE_T
121122typedef ssize_t Py_ssize_t ;
123+ # define PY_SSIZE_T_MAX SSIZE_MAX
122124#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
123125typedef Py_intptr_t Py_ssize_t ;
126+ # define PY_SSIZE_T_MAX INTPTR_MAX
124127#else
125128# error "Python needs a typedef for Py_ssize_t in pyport.h."
126129#endif
127130
131+ /* Smallest negative value of type Py_ssize_t. */
132+ #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
133+
128134/* Py_hash_t is the same size as a pointer. */
129135#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
130136typedef Py_ssize_t Py_hash_t ;
@@ -138,11 +144,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
138144/* Largest possible value of size_t. */
139145#define PY_SIZE_MAX SIZE_MAX
140146
141- /* Largest positive value of type Py_ssize_t. */
142- #define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
143- /* Smallest negative value of type Py_ssize_t. */
144- #define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
145-
146147/* Macro kept for backward compatibility: use "z" in new code.
147148 *
148149 * PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
0 commit comments