Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
Cpython
Commits
d414f7ec
Unverified
Commit
d414f7ec
authored
May 2, 2022
by
Ganesh Kathiresan
Committed by
GitHub
May 2, 2022
Browse files
Options
Downloads
Patches
Plain Diff
gh-90822: Make `PY_SSIZE_T_MAX` and `PY_SSIZE_T_MIN` constant expression (GH-92071)
parent
4d10f703
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Include/pyport.h
+6
-5
6 additions, 5 deletions
Include/pyport.h
PC/pyconfig.h
+2
-0
2 additions, 0 deletions
PC/pyconfig.h
with
8 additions
and
5 deletions
Include/pyport.h
+
6
−
5
View file @
d414f7ec
...
@@ -114,17 +114,23 @@ typedef intptr_t Py_intptr_t;
...
@@ -114,17 +114,23 @@ typedef intptr_t Py_intptr_t;
/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
* sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
* sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
* unsigned integral type). See PEP 353 for details.
* unsigned integral type). See PEP 353 for details.
* PY_SSIZE_T_MAX is the largest positive value of type Py_ssize_t.
*/
*/
#ifdef HAVE_PY_SSIZE_T
#ifdef HAVE_PY_SSIZE_T
#elif HAVE_SSIZE_T
#elif HAVE_SSIZE_T
typedef
ssize_t
Py_ssize_t
;
typedef
ssize_t
Py_ssize_t
;
# define PY_SSIZE_T_MAX SSIZE_MAX
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
typedef
Py_intptr_t
Py_ssize_t
;
typedef
Py_intptr_t
Py_ssize_t
;
# define PY_SSIZE_T_MAX INTPTR_MAX
#else
#else
# error "Python needs a typedef for Py_ssize_t in pyport.h."
# error "Python needs a typedef for Py_ssize_t in pyport.h."
#endif
#endif
/* Smallest negative value of type Py_ssize_t. */
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
/* Py_hash_t is the same size as a pointer. */
/* Py_hash_t is the same size as a pointer. */
#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T
typedef
Py_ssize_t
Py_hash_t
;
typedef
Py_ssize_t
Py_hash_t
;
...
@@ -138,11 +144,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
...
@@ -138,11 +144,6 @@ typedef Py_ssize_t Py_ssize_clean_t;
/* Largest possible value of size_t. */
/* Largest possible value of size_t. */
#define PY_SIZE_MAX SIZE_MAX
#define PY_SIZE_MAX SIZE_MAX
/* Largest positive value of type Py_ssize_t. */
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
/* Smallest negative value of type Py_ssize_t. */
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
/* Macro kept for backward compatibility: use "z" in new code.
/* Macro kept for backward compatibility: use "z" in new code.
*
*
* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
...
...
This diff is collapsed.
Click to expand it.
PC/pyconfig.h
+
2
−
0
View file @
d414f7ec
...
@@ -162,8 +162,10 @@ WIN32 is still required for the locale module.
...
@@ -162,8 +162,10 @@ WIN32 is still required for the locale module.
/* Define like size_t, omitting the "unsigned" */
/* Define like size_t, omitting the "unsigned" */
#ifdef MS_WIN64
#ifdef MS_WIN64
typedef
__int64
Py_ssize_t
;
typedef
__int64
Py_ssize_t
;
# define PY_SSIZE_T_MAX LLONG_MAX
#else
#else
typedef
_W64
int
Py_ssize_t
;
typedef
_W64
int
Py_ssize_t
;
# define PY_SSIZE_T_MAX INT_MAX
#endif
#endif
#define HAVE_PY_SSIZE_T 1
#define HAVE_PY_SSIZE_T 1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment