#include "pycore_pyarena.h" // PyArena
_Py_DECLARE_STR(empty, "")
-#if defined(Py_DEBUG) && defined(Py_GIL_DISABLED)
#define _parser_runtime_state_INIT \
{ \
- .mutex = {0}, \
.dummy_name = { \
.kind = Name_kind, \
.v.Name.id = &_Py_STR(empty), \
.end_col_offset = 0, \
}, \
}
-#else
-#define _parser_runtime_state_INIT \
- { \
- .dummy_name = { \
- .kind = Name_kind, \
- .v.Name.id = &_Py_STR(empty), \
- .v.Name.ctx = Load, \
- .lineno = 1, \
- .col_offset = 0, \
- .end_lineno = 1, \
- .end_col_offset = 0, \
- }, \
- }
-#endif
extern struct _mod* _PyParser_ASTFromString(
const char *str,
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_parser.h" // _PYPEGEN_NSTATISTICS
#include "pycore_pyerrors.h" // PyExc_IncompleteInputError
-#include "pycore_runtime.h" // _PyRuntime
+#include "pycore_runtime.h" // _PyRuntime
#include "pycore_unicodeobject.h" // _PyUnicode_InternImmortal
-#include "pycore_pyatomic_ft_wrappers.h"
#include <errcode.h>
#include "lexer/lexer.h"
void
_PyPegen_clear_memo_statistics(void)
{
- FT_MUTEX_LOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Lock(&_PyRuntime.parser.mutex);
for (int i = 0; i < NSTATISTICS; i++) {
memo_statistics[i] = 0;
}
- FT_MUTEX_UNLOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Unlock(&_PyRuntime.parser.mutex);
}
PyObject *
return NULL;
}
- FT_MUTEX_LOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Lock(&_PyRuntime.parser.mutex);
for (int i = 0; i < NSTATISTICS; i++) {
PyObject *value = PyLong_FromLong(memo_statistics[i]);
if (value == NULL) {
- FT_MUTEX_UNLOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Unlock(&_PyRuntime.parser.mutex);
Py_DECREF(ret);
return NULL;
}
// PyList_SetItem borrows a reference to value.
if (PyList_SetItem(ret, i, value) < 0) {
- FT_MUTEX_UNLOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Unlock(&_PyRuntime.parser.mutex);
Py_DECREF(ret);
return NULL;
}
}
- FT_MUTEX_UNLOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Unlock(&_PyRuntime.parser.mutex);
return ret;
}
#endif
if (count <= 0) {
count = 1;
}
- FT_MUTEX_LOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Lock(&_PyRuntime.parser.mutex);
memo_statistics[type] += count;
- FT_MUTEX_UNLOCK(&_PyRuntime.parser.mutex);
+ PyMutex_Unlock(&_PyRuntime.parser.mutex);
}
#endif
p->mark = m->mark;