File tree 5 files changed +11
-16
lines changed
5 files changed +11
-16
lines changed Original file line number Diff line number Diff line change 16
16
# define _SGI_MP_SOURCE
17
17
#endif
18
18
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
20
20
// headers, but kept for backward compatibility. They are excluded from the
21
21
// limited C API of Python 3.11.
22
22
#if !defined(Py_LIMITED_API ) || Py_LIMITED_API + 0 < 0x030b0000
23
23
# include <stdlib.h>
24
24
# include <stdio.h> // FILE*
25
25
# include <errno.h> // errno
26
- # include <string.h> // memcpy()
27
26
#endif
28
27
#ifndef MS_WINDOWS
29
28
# include <unistd.h>
34
33
35
34
#include <assert.h> // assert()
36
35
#include <wchar.h> // wchar_t
36
+ #include <string.h> // memcpy()
37
37
38
38
#include "pyport.h"
39
39
#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.
131
131
#define PyObject_HEAD_INIT (type ) \
132
132
{ \
133
133
_PyObject_EXTRA_INIT \
134
- { _Py_IMMORTAL_REFCNT }, \
134
+ _Py_IMMORTAL_REFCNT, \
135
135
(type) \
136
136
},
137
137
#else
138
138
#define PyObject_HEAD_INIT (type ) \
139
139
{ \
140
140
_PyObject_EXTRA_INIT \
141
- { 1 }, \
141
+ 1, \
142
142
(type) \
143
143
},
144
144
#endif /* Py_BUILD_CORE */
@@ -165,12 +165,7 @@ check by comparing the reference count field to the immortality reference count.
165
165
*/
166
166
struct _object {
167
167
_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 ;
174
169
PyTypeObject * ob_type ;
175
170
};
176
171
@@ -624,12 +619,12 @@ static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
624
619
// directly PyObject.ob_refcnt.
625
620
#if SIZEOF_VOID_P > 4
626
621
// 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 ) ;
628
623
PY_UINT32_T new_refcnt = cur_refcnt + 1 ;
629
624
if (new_refcnt == 0 ) {
630
625
return ;
631
626
}
632
- op -> ob_refcnt_split [ PY_BIG_ENDIAN ] = new_refcnt ;
627
+ memcpy ( & op -> ob_refcnt , & new_refcnt , sizeof ( new_refcnt )) ;
633
628
#else
634
629
// Explicitly check immortality against the immortal value
635
630
if (_Py_IsImmortal (op )) {
Original file line number Diff line number Diff line change @@ -1876,7 +1876,7 @@ PyTypeObject _PyNone_Type = {
1876
1876
1877
1877
PyObject _Py_NoneStruct = {
1878
1878
_PyObject_EXTRA_INIT
1879
- { _Py_IMMORTAL_REFCNT } ,
1879
+ _Py_IMMORTAL_REFCNT ,
1880
1880
& _PyNone_Type
1881
1881
};
1882
1882
@@ -1979,7 +1979,7 @@ PyTypeObject _PyNotImplemented_Type = {
1979
1979
1980
1980
PyObject _Py_NotImplementedStruct = {
1981
1981
_PyObject_EXTRA_INIT
1982
- { _Py_IMMORTAL_REFCNT } ,
1982
+ _Py_IMMORTAL_REFCNT ,
1983
1983
& _PyNotImplemented_Type
1984
1984
};
1985
1985
Original file line number Diff line number Diff line change @@ -2544,6 +2544,6 @@ static PyTypeObject _PySetDummy_Type = {
2544
2544
2545
2545
static PyObject _dummy_struct = {
2546
2546
_PyObject_EXTRA_INIT
2547
- { _Py_IMMORTAL_REFCNT } ,
2547
+ _Py_IMMORTAL_REFCNT ,
2548
2548
& _PySetDummy_Type
2549
2549
};
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ PyTypeObject PyEllipsis_Type = {
99
99
100
100
PyObject _Py_EllipsisObject = {
101
101
_PyObject_EXTRA_INIT
102
- { _Py_IMMORTAL_REFCNT } ,
102
+ _Py_IMMORTAL_REFCNT ,
103
103
& PyEllipsis_Type
104
104
};
105
105
You can’t perform that action at this time.
0 commit comments