mirror of
https://github.com/johndoe6345789/typthon.git
synced 2026-04-24 13:45:05 +00:00
Rename Py_ to Ty_ throughout C API
Massive automated renaming of all Py_/PyObject/etc. prefixes to Ty_/TyObject/etc. This includes: - All public API types (TyObject, TyTypeObject, etc.) - All public API functions (Ty_Initialize, Ty_BuildValue, etc.) - All internal API (_Ty_ prefixes) - Reference counting macros (Ty_INCREF, Ty_DECREF, etc.) - Type flags (Ty_TPFLAGS_*) - Debug flags (Ty_DEBUG, Ty_TRACE_REFS, etc.) - All object type APIs (TyList_, TyDict_, TyUnicode_, etc.) This changes over 60,000 occurrences across 1000+ files. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
Stuff shared by all thread_*.h files is collected here. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "pycore_ceval.h" // _PyEval_MakePendingCalls()
|
||||
#include "pycore_pystate.h" // _PyInterpreterState_GET()
|
||||
#include "pycore_ceval.h" // _TyEval_MakePendingCalls()
|
||||
#include "pycore_pystate.h" // _TyInterpreterState_GET()
|
||||
#include "pycore_pythread.h" // _POSIX_THREADS
|
||||
#include "pycore_runtime.h" // _PyRuntime
|
||||
#include "pycore_structseq.h" // _PyStructSequence_FiniBuiltin()
|
||||
@@ -75,7 +75,7 @@ PyThread_init_thread(void)
|
||||
size_t
|
||||
PyThread_get_stacksize(void)
|
||||
{
|
||||
return _PyInterpreterState_GET()->threads.stacksize;
|
||||
return _TyInterpreterState_GET()->threads.stacksize;
|
||||
}
|
||||
|
||||
/* Only platforms defining a THREAD_SET_STACKSIZE() macro
|
||||
@@ -95,32 +95,32 @@ PyThread_set_stacksize(size_t size)
|
||||
|
||||
|
||||
int
|
||||
PyThread_ParseTimeoutArg(PyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
||||
PyThread_ParseTimeoutArg(TyObject *arg, int blocking, PY_TIMEOUT_T *timeout_p)
|
||||
{
|
||||
assert(_PyTime_FromSeconds(-1) == PyThread_UNSET_TIMEOUT);
|
||||
if (arg == NULL || arg == Py_None) {
|
||||
assert(_TyTime_FromSeconds(-1) == PyThread_UNSET_TIMEOUT);
|
||||
if (arg == NULL || arg == Ty_None) {
|
||||
*timeout_p = blocking ? PyThread_UNSET_TIMEOUT : 0;
|
||||
return 0;
|
||||
}
|
||||
if (!blocking) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
TyErr_SetString(TyExc_ValueError,
|
||||
"can't specify a timeout for a non-blocking call");
|
||||
return -1;
|
||||
}
|
||||
|
||||
PyTime_t timeout;
|
||||
if (_PyTime_FromSecondsObject(&timeout, arg, _PyTime_ROUND_TIMEOUT) < 0) {
|
||||
if (_TyTime_FromSecondsObject(&timeout, arg, _TyTime_ROUND_TIMEOUT) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (timeout < 0) {
|
||||
PyErr_SetString(PyExc_ValueError,
|
||||
TyErr_SetString(TyExc_ValueError,
|
||||
"timeout value must be a non-negative number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (_PyTime_AsMicroseconds(timeout,
|
||||
_PyTime_ROUND_TIMEOUT) > PY_TIMEOUT_MAX) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
if (_TyTime_AsMicroseconds(timeout,
|
||||
_TyTime_ROUND_TIMEOUT) > PY_TIMEOUT_MAX) {
|
||||
TyErr_SetString(TyExc_OverflowError,
|
||||
"timeout value is too large");
|
||||
return -1;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ PyLockStatus
|
||||
PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
||||
PY_TIMEOUT_T timeout)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
PyThreadState *tstate = _TyThreadState_GET();
|
||||
PyTime_t endtime = 0;
|
||||
if (timeout > 0) {
|
||||
endtime = _PyDeadline_Init(timeout);
|
||||
@@ -141,7 +141,7 @@ PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
||||
PyLockStatus r;
|
||||
do {
|
||||
PyTime_t microseconds;
|
||||
microseconds = _PyTime_AsMicroseconds(timeout, _PyTime_ROUND_CEILING);
|
||||
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);
|
||||
@@ -155,7 +155,7 @@ PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
||||
/* Run signal handlers if we were interrupted. Propagate
|
||||
* exceptions from signal handlers, such as KeyboardInterrupt, by
|
||||
* passing up PY_LOCK_INTR. */
|
||||
if (_PyEval_MakePendingCalls(tstate) < 0) {
|
||||
if (_TyEval_MakePendingCalls(tstate) < 0) {
|
||||
return PY_LOCK_INTR;
|
||||
}
|
||||
|
||||
@@ -182,10 +182,10 @@ PyThread_acquire_lock_timed_with_retries(PyThread_type_lock lock,
|
||||
Cross-platform components of TSS API implementation.
|
||||
*/
|
||||
|
||||
Py_tss_t *
|
||||
Ty_tss_t *
|
||||
PyThread_tss_alloc(void)
|
||||
{
|
||||
Py_tss_t *new_key = (Py_tss_t *)PyMem_RawMalloc(sizeof(Py_tss_t));
|
||||
Ty_tss_t *new_key = (Ty_tss_t *)TyMem_RawMalloc(sizeof(Ty_tss_t));
|
||||
if (new_key == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -194,16 +194,16 @@ PyThread_tss_alloc(void)
|
||||
}
|
||||
|
||||
void
|
||||
PyThread_tss_free(Py_tss_t *key)
|
||||
PyThread_tss_free(Ty_tss_t *key)
|
||||
{
|
||||
if (key != NULL) {
|
||||
PyThread_tss_delete(key);
|
||||
PyMem_RawFree((void *)key);
|
||||
TyMem_RawFree((void *)key);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
PyThread_tss_is_created(Py_tss_t *key)
|
||||
PyThread_tss_is_created(Ty_tss_t *key)
|
||||
{
|
||||
assert(key != NULL);
|
||||
return key->_is_initialized;
|
||||
@@ -229,12 +229,12 @@ static PyStructSequence_Desc threadinfo_desc = {
|
||||
3
|
||||
};
|
||||
|
||||
static PyTypeObject ThreadInfoType;
|
||||
static TyTypeObject ThreadInfoType;
|
||||
|
||||
PyObject*
|
||||
TyObject*
|
||||
PyThread_GetInfo(void)
|
||||
{
|
||||
PyObject *threadinfo, *value;
|
||||
TyObject *threadinfo, *value;
|
||||
int pos = 0;
|
||||
#if (defined(_POSIX_THREADS) && defined(HAVE_CONFSTR) \
|
||||
&& defined(_CS_GNU_LIBPTHREAD_VERSION))
|
||||
@@ -242,7 +242,7 @@ PyThread_GetInfo(void)
|
||||
int len;
|
||||
#endif
|
||||
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
PyInterpreterState *interp = _TyInterpreterState_GET();
|
||||
if (_PyStructSequence_InitBuiltin(interp, &ThreadInfoType, &threadinfo_desc) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -251,27 +251,27 @@ PyThread_GetInfo(void)
|
||||
if (threadinfo == NULL)
|
||||
return NULL;
|
||||
|
||||
value = PyUnicode_FromString(PYTHREAD_NAME);
|
||||
value = TyUnicode_FromString(PYTHREAD_NAME);
|
||||
if (value == NULL) {
|
||||
Py_DECREF(threadinfo);
|
||||
Ty_DECREF(threadinfo);
|
||||
return NULL;
|
||||
}
|
||||
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
|
||||
#ifdef HAVE_PTHREAD_STUBS
|
||||
value = Py_NewRef(Py_None);
|
||||
value = Ty_NewRef(Ty_None);
|
||||
#elif defined(_POSIX_THREADS)
|
||||
#ifdef USE_SEMAPHORES
|
||||
value = PyUnicode_FromString("semaphore");
|
||||
value = TyUnicode_FromString("semaphore");
|
||||
#else
|
||||
value = PyUnicode_FromString("mutex+cond");
|
||||
value = TyUnicode_FromString("mutex+cond");
|
||||
#endif
|
||||
if (value == NULL) {
|
||||
Py_DECREF(threadinfo);
|
||||
Ty_DECREF(threadinfo);
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
value = Py_NewRef(Py_None);
|
||||
value = Ty_NewRef(Ty_None);
|
||||
#endif
|
||||
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
|
||||
@@ -280,14 +280,14 @@ PyThread_GetInfo(void)
|
||||
value = NULL;
|
||||
len = confstr(_CS_GNU_LIBPTHREAD_VERSION, buffer, sizeof(buffer));
|
||||
if (1 < len && (size_t)len < sizeof(buffer)) {
|
||||
value = PyUnicode_DecodeFSDefaultAndSize(buffer, len-1);
|
||||
value = TyUnicode_DecodeFSDefaultAndSize(buffer, len-1);
|
||||
if (value == NULL)
|
||||
PyErr_Clear();
|
||||
TyErr_Clear();
|
||||
}
|
||||
if (value == NULL)
|
||||
#endif
|
||||
{
|
||||
value = Py_NewRef(Py_None);
|
||||
value = Ty_NewRef(Ty_None);
|
||||
}
|
||||
PyStructSequence_SET_ITEM(threadinfo, pos++, value);
|
||||
return threadinfo;
|
||||
|
||||
Reference in New Issue
Block a user