File tree Expand file tree Collapse file tree 5 files changed +11
-16
lines changed Expand file tree Collapse file tree 5 files changed +11
-16
lines changed Original file line number Diff line number Diff line change 1616# define _SGI_MP_SOURCE
1717#endif
1818
19- // stdlib.h, stdio.h, errno.h and string .h headers are not used by Python
19+ // stdlib.h, stdio.h, and errno .h headers are not used by Python
2020// headers, but kept for backward compatibility. They are excluded from the
2121// limited C API of Python 3.11.
2222#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
2323# include <stdlib.h>
2424# include <stdio.h> // FILE*
2525# include <errno.h> // errno
26- # include <string.h> // memcpy()
2726#endif
2827#ifndef MS_WINDOWS
2928# include <unistd.h>
3433
3534#include <assert.h> // assert()
3635#include <wchar.h> // wchar_t
36+ #include <string.h> // memcpy()
3737
3838#include "pyport.h"
3939#include "pymacro.h"
Original file line number Diff line number Diff line change @@ -131,14 +131,14 @@ check by comparing the reference count field to the immortality reference count.
131131#define PyObject_HEAD_INIT (type ) \
132132 { \
133133 _PyObject_EXTRA_INIT \
134- { _Py_IMMORTAL_REFCNT }, \
134+ _Py_IMMORTAL_REFCNT, \
135135 (type) \
136136 },
137137#else
138138#define PyObject_HEAD_INIT (type ) \
139139 { \
140140 _PyObject_EXTRA_INIT \
141- { 1 }, \
141+ 1, \
142142 (type) \
143143 },
144144#endif /* Py_BUILD_CORE */
@@ -165,12 +165,7 @@ check by comparing the reference count field to the immortality reference count.
165165 */
166166struct _object {
167167 _PyObject_HEAD_EXTRA
168- union {
169- Py_ssize_t ob_refcnt ;
170- #if SIZEOF_VOID_P > 4
171- PY_UINT32_T ob_refcnt_split [2 ];
172- #endif
173- };
168+ Py_ssize_t ob_refcnt ;
174169 PyTypeObject * ob_type ;
175170};
176171
@@ -624,12 +619,12 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
624619 // directly PyObject.ob_refcnt.
625620#if SIZEOF_VOID_P > 4
626621 // Portable saturated add, branching on the carry flag and set low bits
627- PY_UINT32_T cur_refcnt = op -> ob_refcnt_split [ PY_BIG_ENDIAN ] ;
622+ PY_UINT32_T cur_refcnt = _Py_CAST ( PY_UINT32_T , op -> ob_refcnt ) ;
628623 PY_UINT32_T new_refcnt = cur_refcnt + 1 ;
629624 if (new_refcnt == 0 ) {
630625 return ;
631626 }
632- op -> ob_refcnt_split [ PY_BIG_ENDIAN ] = new_refcnt ;
627+ memcpy ( & op -> ob_refcnt , & new_refcnt , sizeof ( new_refcnt )) ;
633628#else
634629 // Explicitly check immortality against the immortal value
635630 if (_Py_IsImmortal (op )) {
Original file line number Diff line number Diff line change @@ -1876,7 +1876,7 @@ PyTypeObject _PyNone_Type = {
18761876
18771877PyObject _Py_NoneStruct = {
18781878 _PyObject_EXTRA_INIT
1879- { _Py_IMMORTAL_REFCNT } ,
1879+ _Py_IMMORTAL_REFCNT ,
18801880 & _PyNone_Type
18811881};
18821882
@@ -1979,7 +1979,7 @@ PyTypeObject _PyNotImplemented_Type = {
19791979
19801980PyObject _Py_NotImplementedStruct = {
19811981 _PyObject_EXTRA_INIT
1982- { _Py_IMMORTAL_REFCNT } ,
1982+ _Py_IMMORTAL_REFCNT ,
19831983 & _PyNotImplemented_Type
19841984};
19851985
Original file line number Diff line number Diff line change @@ -2544,6 +2544,6 @@ static PyTypeObject _PySetDummy_Type = {
25442544
25452545static PyObject _dummy_struct = {
25462546 _PyObject_EXTRA_INIT
2547- { _Py_IMMORTAL_REFCNT } ,
2547+ _Py_IMMORTAL_REFCNT ,
25482548 & _PySetDummy_Type
25492549};
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ PyTypeObject PyEllipsis_Type = {
9999
100100PyObject _Py_EllipsisObject = {
101101 _PyObject_EXTRA_INIT
102- { _Py_IMMORTAL_REFCNT } ,
102+ _Py_IMMORTAL_REFCNT ,
103103 & PyEllipsis_Type
104104};
105105
You can’t perform that action at this time.
0 commit comments