8000 convert more stuff to macros to try fix wasi · python/cpython@0242212 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0242212

Browse files
convert more stuff to macros to try fix wasi
1 parent 5053536 commit 0242212

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

Include/internal/pycore_stackref.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,32 +166,33 @@ PyStackRef_CLOSE(_PyStackRef tagged)
166166
Py_DECREF(PyStackRef_AsPyObjectBorrow(tagged));
167167
}
168168
#else
169-
#define PyStackRef_CLOSE(tagged) Py_DECREF(PyStackRef_AsPyObjectBorrow(tagged))
169+
# define PyStackRef_CLOSE(tagged) Py_DECREF(PyStackRef_AsPyObjectBorrow(tagged))
170170
#endif
171171

172-
static inline void
173-
PyStackRef_XCLOSE(_PyStackRef tagged)
174-
{
175-
if (!PyStackRef_IsNull(tagged)) {
176-
PyStackRef_CLOSE(tagged);
177-
}
178-
}
172+
#define PyStackRef_XCLOSE(stackref) \
173+
do { \
174+
_PyStackRef _tmp = (stackref); \
175+
if (!PyStackRef_IsNull(_tmp)) { \
176+
PyStackRef_CLOSE(_tmp); \
177+
} \
178+
} while (0);
179+
179180

181+
#ifdef Py_GIL_DISABLED
180182
static inline _PyStackRef
181183
PyStackRef_DUP(_PyStackRef tagged)
182184
{
183-
#ifdef Py_GIL_DISABLED
184185
if (PyStackRef_IsDeferred(tagged)) {
185186
assert(PyStackRef_IsNull(tagged) ||
186187
_Py_IsImmortal(PyStackRef_AsPyObjectBorrow(tagged)));
187188
return tagged;
188189
}
189190
Py_INCREF(PyStackRef_AsPyObjectBorrow(tagged));
190191
return tagged;
191-
#endif
192-
Py_INCREF(PyStackRef_AsPyObjectBorrow(tagged));
193-
return tagged;
194192
}
193+
#else
194+
# define PyStackRef_DUP(stackref) PyStackRef_FromPyObjectSteal(Py_NewRef(PyStackRef_AsPyObjectBorrow(stackref)))
195+
#endif
195196

196197
static inline _PyStackRef
197198
PyStackRef_XDUP(_PyStackRef tagged)

0 commit comments

Comments
 (0)
0