mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Fix more missed Py_ patterns - opcode, thread, exception
Fixed additional patterns: - _PyOpcode_* → _TyOpcode_* (all opcode metadata) - _PyUOpName → _TyUOpName - _PyFunction_* → _TyFunction_* - _PyListIterObject → _TyListIterObject - _Py_T_OBJECT → _Ty_T_OBJECT - Py_BEGIN_ALLOW_THREADS, Py_END_ALLOW_THREADS → Ty_* - PyDoc_STRVAR, PyDoc_STR → TyDoc_* - PyInterpreterState, PyThread_*, PyTime_t → Ty* - PyStructSequence_* → TyStructSequence_* - PyLockStatus → TyLockStatus - PyVarObject_HEAD_INIT → TyVarObject_HEAD_INIT - PyBaseExceptionObject → TyBaseExceptionObject - Fixed _PyExc_ → _TyExc_ in exception macros Build is progressing further. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
|
||||
// Define PY_TIMEOUT_MAX constant.
|
||||
#ifdef _POSIX_THREADS
|
||||
// PyThread_acquire_lock_timed() uses (us * 1000) to convert microseconds
|
||||
// TyThread_acquire_lock_timed() uses (us * 1000) to convert microseconds
|
||||
// to nanoseconds.
|
||||
# define PY_TIMEOUT_MAX_VALUE (LLONG_MAX / 1000)
|
||||
#elif defined (NT_THREADS)
|
||||
@@ -39,18 +39,18 @@
|
||||
const long long PY_TIMEOUT_MAX = PY_TIMEOUT_MAX_VALUE;
|
||||
|
||||
|
||||
static void PyThread__init_thread(void); /* Forward */
|
||||
static void TyThread__init_thread(void); /* Forward */
|
||||
|
||||
#define initialized _PyRuntime.threads.initialized
|
||||
|
||||
void
|
||||
PyThread_init_thread(void)
|
||||
TyThread_init_thread(void)
|
||||
{
|
||||
if (initialized) {
|
||||
return;
|
||||
}
|
||||
initialized = 1;
|
||||
PyThread__init_thread();
|
||||
TyThread__init_thread();
|
||||
}
|
||||
|
||||
#if defined(HAVE_PTHREAD_STUBS)
|
||||
@@ -73,7 +73,7 @@ PyThread_init_thread(void)
|
||||
|
||||
/* return the current thread stack size */
|
||||
size_t
|
||||
PyThread_get_stacksize(void)
|
||||
TyThread_get_stacksize(void)
|
||||
{
|
||||
return _TyInterpreterState_GET()->threads.stacksize;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ PyThread_get_stacksize(void)
|
||||
-1 if stack size value is invalid,
|
||||
-2 if setting stack size is not supported. */
|
||||
int
|
||||
PyThread_set_stacksize(size_t size)
|
||||
TyThread_set_stacksize(size_t size)
|
||||
{
|
||||
#if defined(THREAD_SET_STACKSIZE)
|
||||
return THREAD_SET_STACKSIZE(size);
|
||||
@@ -95,11 +95,11 @@ PyThread_set_stacksize(size_t size)
|
||||
|
||||
|
||||
int
|
||||
PyThread_ParseTimeoutArg(TyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
||||
TyThread_ParseTimeoutArg(TyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
||||
{
|
||||
assert(_TyTime_FromSeconds(-1) == PyThread_UNSET_TIMEOUT);
|
||||
assert(_TyTime_FromSeconds(-1) == TyThread_UNSET_TIMEOUT);
|
||||
if (arg == NULL || arg == Ty_None) {
|
||||
*timeout_p = blocking ? PyThread_UNSET_TIMEOUT : 0;
|
||||
*timeout_p = blocking ? TyThread_UNSET_TIMEOUT : 0;
|
||||
return 0;
|
||||
}
|
||||
if (!blocking) {
|
||||
@@ -108,7 +108,7 @@ PyThread_ParseTimeoutArg(TyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyTime_t timeout;
|
||||
TyTime_t timeout;
|
||||
if (_TyTime_FromSecondsObject(&timeout, arg, _TyTime_ROUND_TIMEOUT) < 0) {
|
||||
return -1;
|
||||
}
|
||||
@@ -128,27 +128,27 @@ PyThread_ParseTimeoutArg(TyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyLockStatus
|
||||
PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
||||
TyLockStatus
|
||||
TyThread_acquire_lock_timed_with_retries(TyThread_type_lock lock,
|
||||
PY_TIMEOUT_T timeout)
|
||||
{
|
||||
TyThreadState *tstate = _TyThreadState_GET();
|
||||
PyTime_t endtime = 0;
|
||||
TyTime_t endtime = 0;
|
||||
if (timeout > 0) {
|
||||
endtime = _PyDeadline_Init(timeout);
|
||||
}
|
||||
|
||||
PyLockStatus r;
|
||||
TyLockStatus r;
|
||||
do {
|
||||
PyTime_t microseconds;
|
||||
TyTime_t microseconds;
|
||||
microseconds = _TyTime_AsMicroseconds(timeout, _TyTime_ROUND_CEILING);
|
||||
|
||||
/* first a simple non-blocking try without releasing the GIL */
|
||||
r = PyThread_acquire_lock_timed(lock, 0, 0);
|
||||
r = TyThread_acquire_lock_timed(lock, 0, 0);
|
||||
if (r == PY_LOCK_FAILURE && microseconds != 0) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
r = PyThread_acquire_lock_timed(lock, microseconds, 1);
|
||||
Py_END_ALLOW_THREADS
|
||||
Ty_BEGIN_ALLOW_THREADS
|
||||
r = TyThread_acquire_lock_timed(lock, microseconds, 1);
|
||||
Ty_END_ALLOW_THREADS
|
||||
}
|
||||
|
||||
if (r == PY_LOCK_INTR) {
|
||||
@@ -183,7 +183,7 @@ PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
||||
*/
|
||||
|
||||
Ty_tss_t *
|
||||
PyThread_tss_alloc(void)
|
||||
TyThread_tss_alloc(void)
|
||||
{
|
||||
Ty_tss_t *new_key = (Ty_tss_t *)TyMem_RawMalloc(sizeof(Ty_tss_t));
|
||||
if (new_key == NULL) {
|
||||
@@ -194,35 +194,35 @@ PyThread_tss_alloc(void)
|
||||
}
|
||||
|
||||
void
|
||||
PyThread_tss_free(Ty_tss_t *key)
|
||||
TyThread_tss_free(Ty_tss_t *key)
|
||||
{
|
||||
if (key != NULL) {
|
||||
PyThread_tss_delete(key);
|
||||
TyThread_tss_delete(key);
|
||||
TyMem_RawFree((void *)key);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
PyThread_tss_is_created(Ty_tss_t *key)
|
||||
TyThread_tss_is_created(Ty_tss_t *key)
|
||||
{
|
||||
assert(key != NULL);
|
||||
return key->_is_initialized;
|
||||
}
|
||||
|
||||
|
||||
PyDoc_STRVAR(threadinfo__doc__,
|
||||
TyDoc_STRVAR(threadinfo__doc__,
|
||||
"sys.thread_info\n\
|
||||
\n\
|
||||
A named tuple holding information about the thread implementation.");
|
||||
|
||||
static PyStructSequence_Field threadinfo_fields[] = {
|
||||
static TyStructSequence_Field threadinfo_fields[] = {
|
||||
{"name", "name of the thread implementation"},
|
||||
{"lock", "name of the lock implementation"},
|
||||
{"version", "name and version of the thread library"},
|
||||
{0}
|
||||
};
|
||||
|
||||
static PyStructSequence_Desc threadinfo_desc = {
|
||||
static TyStructSequence_Desc threadinfo_desc = {
|
||||
"sys.thread_info", /* name */
|
||||
threadinfo__doc__, /* doc */
|
||||
threadinfo_fields, /* fields */
|
||||
@@ -232,7 +232,7 @@ static PyStructSequence_Desc threadinfo_desc = {
|
||||
static TyTypeObject ThreadInfoType;
|
||||
|
||||
TyObject*
|
||||
PyThread_GetInfo(void)
|
||||
TyThread_GetInfo(void)
|
||||
{
|
||||
TyObject *threadinfo, *value;
|
||||
int pos = 0;
|
||||
@@ -242,12 +242,12 @@ PyThread_GetInfo(void)
|
||||
int len;
|
||||
#endif
|
||||
|
||||
PyInterpreterState *interp = _TyInterpreterState_GET();
|
||||
TyInterpreterState *interp = _TyInterpreterState_GET();
|
||||
if (_PyStructSequence_InitBuiltin(interp, &ThreadInfoType, &threadinfo_desc) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
threadinfo = PyStructSequence_New(&ThreadInfoType);
|
||||
threadinfo = TyStructSequence_New(&ThreadInfoType);
|
||||
if (threadinfo == NULL)
|
||||
return NULL;
|
||||
|
||||
@@ -256,7 +256,7 @@ PyThread_GetInfo(void)
|
||||
Ty_DECREF(threadinfo);
|
||||
return NULL;
|
||||
}
|
||||
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
TyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
|
||||
#ifdef HAVE_PTHREAD_STUBS
|
||||
value = Ty_NewRef(Ty_None);
|
||||
@@ -273,7 +273,7 @@ PyThread_GetInfo(void)
|
||||
#else
|
||||
value = Ty_NewRef(Ty_None);
|
||||
#endif
|
||||
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
TyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
|
||||
#if (defined(_POSIX_THREADS) && defined(HAVE_CONFSTR) \
|
||||
&& defined(_CS_GNU_LIBPTHREAD_VERSION))
|
||||
@@ -289,13 +289,13 @@ PyThread_GetInfo(void)
|
||||
{
|
||||
value = Ty_NewRef(Ty_None);
|
||||
}
|
||||
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
TyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
return threadinfo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
_PyThread_FiniType(PyInterpreterState *interp)
|
||||
_PyThread_FiniType(TyInterpreterState *interp)
|
||||
{
|
||||
_PyStructSequence_FiniBuiltin(interp, &ThreadInfoType);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user