Skip to content

Commit 512fe58

Browse files
committed
Actually make this a literal
1 parent e0156b0 commit 512fe58

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

Include/internal/pycore_gc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static inline void _PyObject_GC_SET_SHARED(PyObject *op) {
133133
*/
134134
#define _PyGC_NEXT_MASK_OLD_SPACE_1 1
135135

136-
#define _PyGC_PREV_SHIFT _PyObject_ALIGNMENT_SHIFT
136+
#define _PyGC_PREV_SHIFT 2
137137
#define _PyGC_PREV_MASK (((uintptr_t) -1) << _PyGC_PREV_SHIFT)
138138

139139
/* set for debugging information */

Include/internal/pycore_interp_structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ struct atexit_state {
159159
typedef struct {
160160
// Tagged pointer to next object in the list.
161161
// 0 means the object is not tracked
162-
_Py_ALIGNED_DEF(1 << _PyObject_ALIGNMENT_SHIFT, uintptr_t) _gc_next;
162+
_Py_ALIGNED_DEF(_PyObject_MIN_ALIGNMENT, uintptr_t) _gc_next;
163163

164164
// Tagged pointer to previous object in the list.
165165
// Lowest two bits are used for flags documented later.

Include/object.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ whose size is determined when the object is allocated.
103103

104104
/* PyObjects are given a minimum alignment so that the least significant bits
105105
* of an object pointer become available for other purposes.
106+
* This must be an integer literal with the value (1 << _PyGC_PREV_SHIFT)
106107
*/
107-
#define _PyObject_ALIGNMENT_SHIFT 2
108+
#define _PyObject_MIN_ALIGNMENT 4
108109

109110
/* Nothing is actually declared to be a PyObject, but every pointer to
110111
* a Python object can be cast to a PyObject*. This is inheritance built
@@ -141,7 +142,7 @@ struct _object {
141142
#else
142143
Py_ssize_t ob_refcnt;
143144
#endif
144-
_Py_ALIGNED_DEF(1 << _PyObject_ALIGNMENT_SHIFT, char) _aligner;
145+
_Py_ALIGNED_DEF(_PyObject_MIN_ALIGNMENT, char) _aligner;
145146
};
146147
#ifdef _MSC_VER
147148
__pragma(warning(pop))
@@ -159,7 +160,7 @@ struct _object {
159160
// ob_tid stores the thread id (or zero). It is also used by the GC and the
160161
// trashcan mechanism as a linked list pointer and by the GC to store the
161162
// computed "gc_refs" refcount.
162-
_Py_ALIGNED_DEF(1 << _PyObject_ALIGNMENT_SHIFT, uintptr_t) ob_tid;
163+
_Py_ALIGNED_DEF(_PyObject_MIN_ALIGNMENT, uintptr_t) ob_tid;
163164
uint16_t ob_flags;
164165
PyMutex ob_mutex; // per-object lock
165166
uint8_t ob_gc_bits; // gc-related state

0 commit comments

Comments
 (0)