mirror of https://github.com/python/cpython
gh-111178: Fix function signatures in _threadmodule.c (#124964)
This commit is contained in:
parent
ac9648243d
commit
ddccd546a0
|
@ -599,8 +599,9 @@ PyThreadHandleObject_traverse(PyThreadHandleObject *self, visitproc visit,
|
|||
}
|
||||
|
||||
static void
|
||||
PyThreadHandleObject_dealloc(PyThreadHandleObject *self)
|
||||
PyThreadHandleObject_dealloc(PyObject *op)
|
||||
{
|
||||
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
|
||||
PyObject_GC_UnTrack(self);
|
||||
PyTypeObject *tp = Py_TYPE(self);
|
||||
ThreadHandle_decref(self->handle);
|
||||
|
@ -609,23 +610,26 @@ PyThreadHandleObject_dealloc(PyThreadHandleObject *self)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
PyThreadHandleObject_repr(PyThreadHandleObject *self)
|
||||
PyThreadHandleObject_repr(PyObject *op)
|
||||
{
|
||||
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
|
||||
PyThread_ident_t ident = ThreadHandle_ident(self->handle);
|
||||
return PyUnicode_FromFormat("<%s object: ident=%" PY_FORMAT_THREAD_IDENT_T ">",
|
||||
Py_TYPE(self)->tp_name, ident);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyThreadHandleObject_get_ident(PyThreadHandleObject *self,
|
||||
PyObject *Py_UNUSED(ignored))
|
||||
PyThreadHandleObject_get_ident(PyObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
|
||||
return PyLong_FromUnsignedLongLong(ThreadHandle_ident(self->handle));
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyThreadHandleObject_join(PyThreadHandleObject *self, PyObject *args)
|
||||
PyThreadHandleObject_join(PyObject *op, PyObject *args)
|
||||
{
|
||||
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
|
||||
|
||||
PyObject *timeout_obj = NULL;
|
||||
if (!PyArg_ParseTuple(args, "|O:join", &timeout_obj)) {
|
||||
return NULL;
|
||||
|
@ -646,9 +650,9 @@ PyThreadHandleObject_join(PyThreadHandleObject *self, PyObject *args)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
PyThreadHandleObject_is_done(PyThreadHandleObject *self,
|
||||
PyObject *Py_UNUSED(ignored))
|
||||
PyThreadHandleObject_is_done(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
|
||||
if (_PyEvent_IsSet(&self->handle->thread_is_exiting)) {
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
@ -658,9 +662,9 @@ PyThreadHandleObject_is_done(PyThreadHandleObject *self,
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
PyThreadHandleObject_set_done(PyThreadHandleObject *self,
|
||||
PyObject *Py_UNUSED(ignored))
|
||||
PyThreadHandleObject_set_done(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyThreadHandleObject *self = (PyThreadHandleObject*)op;
|
||||
if (ThreadHandle_set_done(self->handle) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -668,20 +672,20 @@ PyThreadHandleObject_set_done(PyThreadHandleObject *self,
|
|||
}
|
||||
|
||||
static PyGetSetDef ThreadHandle_getsetlist[] = {
|
||||
{"ident", (getter)PyThreadHandleObject_get_ident, NULL, NULL},
|
||||
{"ident", PyThreadHandleObject_get_ident, NULL, NULL},
|
||||
{0},
|
||||
};
|
||||
|
||||
static PyMethodDef ThreadHandle_methods[] = {
|
||||
{"join", (PyCFunction)PyThreadHandleObject_join, METH_VARARGS, NULL},
|
||||
{"_set_done", (PyCFunction)PyThreadHandleObject_set_done, METH_NOARGS, NULL},
|
||||
{"is_done", (PyCFunction)PyThreadHandleObject_is_done, METH_NOARGS, NULL},
|
||||
{"join", PyThreadHandleObject_join, METH_VARARGS, NULL},
|
||||
{"_set_done", PyThreadHandleObject_set_done, METH_NOARGS, NULL},
|
||||
{"is_done", PyThreadHandleObject_is_done, METH_NOARGS, NULL},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
static PyType_Slot ThreadHandle_Type_slots[] = {
|
||||
{Py_tp_dealloc, (destructor)PyThreadHandleObject_dealloc},
|
||||
{Py_tp_repr, (reprfunc)PyThreadHandleObject_repr},
|
||||
{Py_tp_dealloc, PyThreadHandleObject_dealloc},
|
||||
{Py_tp_repr, PyThreadHandleObject_repr},
|
||||
{Py_tp_getset, ThreadHandle_getsetlist},
|
||||
{Py_tp_traverse, PyThreadHandleObject_traverse},
|
||||
{Py_tp_methods, ThreadHandle_methods},
|
||||
|
@ -707,15 +711,16 @@ typedef struct {
|
|||
} lockobject;
|
||||
|
||||
static int
|
||||
lock_traverse(lockobject *self, visitproc visit, void *arg)
|
||||
lock_traverse(PyObject *self, visitproc visit, void *arg)
|
||||
{
|
||||
Py_VISIT(Py_TYPE(self));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
lock_dealloc(lockobject *self)
|
||||
lock_dealloc(PyObject *op)
|
||||
{
|
||||
lockobject *self = (lockobject*)op;
|
||||
PyObject_GC_UnTrack(self);
|
||||
if (self->in_weakreflist != NULL) {
|
||||
PyObject_ClearWeakRefs((PyObject *) self);
|
||||
|
@ -784,11 +789,14 @@ lock_acquire_parse_args(PyObject *args, PyObject *kwds,
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
lock_PyThread_acquire_lock(lockobject *self, PyObject *args, PyObject *kwds)
|
||||
lock_PyThread_acquire_lock(PyObject *op, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
lockobject *self = (lockobject*)op;
|
||||
|
||||
PyTime_t timeout;
|
||||
if (lock_acquire_parse_args(args, kwds, &timeout) < 0)
|
||||
if (lock_acquire_parse_args(args, kwds, &timeout) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PyLockStatus r = acquire_timed(self->lock_lock, timeout);
|
||||
if (r == PY_LOCK_INTR) {
|
||||
|
@ -824,8 +832,9 @@ PyDoc_STRVAR(enter_doc,
|
|||
Lock the lock.");
|
||||
|
||||
static PyObject *
|
||||
lock_PyThread_release_lock(lockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
lock_PyThread_release_lock(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
lockobject *self = (lockobject*)op;
|
||||
/* Sanity check: the lock must be locked */
|
||||
if (!self->locked) {
|
||||
PyErr_SetString(ThreadError, "release unlocked lock");
|
||||
|
@ -858,8 +867,9 @@ PyDoc_STRVAR(lock_exit_doc,
|
|||
Release the lock.");
|
||||
|
||||
static PyObject *
|
||||
lock_locked_lock(lockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
lock_locked_lock(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
lockobject *self = (lockobject*)op;
|
||||
return PyBool_FromLong((long)self->locked);
|
||||
}
|
||||
|
||||
|
@ -876,16 +886,18 @@ PyDoc_STRVAR(locked_lock_doc,
|
|||
An obsolete synonym of locked().");
|
||||
|
||||
static PyObject *
|
||||
lock_repr(lockobject *self)
|
||||
lock_repr(PyObject *op)
|
||||
{
|
||||
lockobject *self = (lockobject*)op;
|
||||
return PyUnicode_FromFormat("<%s %s object at %p>",
|
||||
self->locked ? "locked" : "unlocked", Py_TYPE(self)->tp_name, self);
|
||||
}
|
||||
|
||||
#ifdef HAVE_FORK
|
||||
static PyObject *
|
||||
lock__at_fork_reinit(lockobject *self, PyObject *Py_UNUSED(args))
|
||||
lock__at_fork_reinit(PyObject *op, PyObject *Py_UNUSED(args))
|
||||
{
|
||||
lockobject *self = (lockobject*)op;
|
||||
if (_PyThread_at_fork_reinit(&self->lock_lock) < 0) {
|
||||
PyErr_SetString(ThreadError, "failed to reinitialize lock at fork");
|
||||
return NULL;
|
||||
|
@ -924,20 +936,20 @@ static PyMethodDef lock_methods[] = {
|
|||
METH_VARARGS | METH_KEYWORDS, acquire_lock_doc},
|
||||
{"acquire", _PyCFunction_CAST(lock_PyThread_acquire_lock),
|
||||
METH_VARARGS | METH_KEYWORDS, acquire_doc},
|
||||
{"release_lock", (PyCFunction)lock_PyThread_release_lock,
|
||||
{"release_lock", lock_PyThread_release_lock,
|
||||
METH_NOARGS, release_lock_doc},
|
||||
{"release", (PyCFunction)lock_PyThread_release_lock,
|
||||
{"release", lock_PyThread_release_lock,
|
||||
METH_NOARGS, release_doc},
|
||||
{"locked_lock", (PyCFunction)lock_locked_lock,
|
||||
{"locked_lock", lock_locked_lock,
|
||||
METH_NOARGS, locked_lock_doc},
|
||||
{"locked", (PyCFunction)lock_locked_lock,
|
||||
{"locked", lock_locked_lock,
|
||||
METH_NOARGS, locked_doc},
|
||||
{"__enter__", _PyCFunction_CAST(lock_PyThread_acquire_lock),
|
||||
METH_VARARGS | METH_KEYWORDS, enter_doc},
|
||||
{"__exit__", (PyCFunction)lock_PyThread_release_lock,
|
||||
{"__exit__", lock_PyThread_release_lock,
|
||||
METH_VARARGS, lock_exit_doc},
|
||||
#ifdef HAVE_FORK
|
||||
{"_at_fork_reinit", (PyCFunction)lock__at_fork_reinit,
|
||||
{"_at_fork_reinit", lock__at_fork_reinit,
|
||||
METH_NOARGS, NULL},
|
||||
#endif
|
||||
{NULL, NULL} /* sentinel */
|
||||
|
@ -964,8 +976,8 @@ static PyMemberDef lock_type_members[] = {
|
|||
};
|
||||
|
||||
static PyType_Slot lock_type_slots[] = {
|
||||
{Py_tp_dealloc, (destructor)lock_dealloc},
|
||||
{Py_tp_repr, (reprfunc)lock_repr},
|
||||
{Py_tp_dealloc, lock_dealloc},
|
||||
{Py_tp_repr, lock_repr},
|
||||
{Py_tp_doc, (void *)lock_doc},
|
||||
{Py_tp_methods, lock_methods},
|
||||
{Py_tp_traverse, lock_traverse},
|
||||
|
@ -1001,8 +1013,9 @@ rlock_traverse(rlockobject *self, visitproc visit, void *arg)
|
|||
|
||||
|
||||
static void
|
||||
rlock_dealloc(rlockobject *self)
|
||||
rlock_dealloc(PyObject *op)
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyObject_GC_UnTrack(self);
|
||||
if (self->in_weakreflist != NULL)
|
||||
PyObject_ClearWeakRefs((PyObject *) self);
|
||||
|
@ -1029,8 +1042,9 @@ rlock_is_owned_by(rlockobject *self, PyThread_ident_t tid)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
rlock_acquire(rlockobject *self, PyObject *args, PyObject *kwds)
|
||||
rlock_acquire(PyObject *op, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyTime_t timeout;
|
||||
PyThread_ident_t tid;
|
||||
PyLockStatus r = PY_LOCK_ACQUIRED;
|
||||
|
@ -1086,8 +1100,9 @@ PyDoc_STRVAR(rlock_enter_doc,
|
|||
Lock the lock.");
|
||||
|
||||
static PyObject *
|
||||
rlock_release(rlockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
rlock_release(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyThread_ident_t tid = PyThread_get_thread_ident_ex();
|
||||
|
||||
if (!rlock_is_owned_by(self, tid)) {
|
||||
|
@ -1122,8 +1137,9 @@ PyDoc_STRVAR(rlock_exit_doc,
|
|||
Release the lock.");
|
||||
|
||||
static PyObject *
|
||||
rlock_acquire_restore(rlockobject *self, PyObject *args)
|
||||
rlock_acquire_restore(PyObject *op, PyObject *args)
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyThread_ident_t owner;
|
||||
unsigned long count;
|
||||
int r = 1;
|
||||
|
@ -1154,8 +1170,9 @@ PyDoc_STRVAR(rlock_acquire_restore_doc,
|
|||
For internal use by `threading.Condition`.");
|
||||
|
||||
static PyObject *
|
||||
rlock_release_save(rlockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
rlock_release_save(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyThread_ident_t owner;
|
||||
unsigned long count;
|
||||
|
||||
|
@ -1180,8 +1197,9 @@ PyDoc_STRVAR(rlock_release_save_doc,
|
|||
For internal use by `threading.Condition`.");
|
||||
|
||||
static PyObject *
|
||||
rlock_recursion_count(rlockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
rlock_recursion_count(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyThread_ident_t tid = PyThread_get_thread_ident_ex();
|
||||
PyThread_ident_t owner =
|
||||
_Py_atomic_load_ullong_relaxed(&self->rlock_owner);
|
||||
|
@ -1195,8 +1213,9 @@ PyDoc_STRVAR(rlock_recursion_count_doc,
|
|||
For internal use by reentrancy checks.");
|
||||
|
||||
static PyObject *
|
||||
rlock_is_owned(rlockobject *self, PyObject *Py_UNUSED(ignored))
|
||||
rlock_is_owned(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyThread_ident_t tid = PyThread_get_thread_ident_ex();
|
||||
|
||||
if (rlock_is_owned_by(self, tid)) {
|
||||
|
@ -1232,8 +1251,9 @@ rlock_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
rlock_repr(rlockobject *self)
|
||||
rlock_repr(PyObject *op)
|
||||
{
|
||||
rlockobject *self = (rlockobject*)op;
|
||||
PyThread_ident_t owner =
|
||||
_Py_atomic_load_ullong_relaxed(&self->rlock_owner);
|
||||
return PyUnicode_FromFormat(
|
||||
|
@ -1264,19 +1284,19 @@ rlock__at_fork_reinit(rlockobject *self, PyObject *Py_UNUSED(args))
|
|||
static PyMethodDef rlock_methods[] = {
|
||||
{"acquire", _PyCFunction_CAST(rlock_acquire),
|
||||
METH_VARARGS | METH_KEYWORDS, rlock_acquire_doc},
|
||||
{"release", (PyCFunction)rlock_release,
|
||||
{"release", rlock_release,
|
||||
METH_NOARGS, rlock_release_doc},
|
||||
{"_is_owned", (PyCFunction)rlock_is_owned,
|
||||
{"_is_owned", rlock_is_owned,
|
||||
METH_NOARGS, rlock_is_owned_doc},
|
||||
{"_acquire_restore", (PyCFunction)rlock_acquire_restore,
|
||||
{"_acquire_restore", rlock_acquire_restore,
|
||||
METH_VARARGS, rlock_acquire_restore_doc},
|
||||
{"_release_save", (PyCFunction)rlock_release_save,
|
||||
{"_release_save", rlock_release_save,
|
||||
METH_NOARGS, rlock_release_save_doc},
|
||||
{"_recursion_count", (PyCFunction)rlock_recursion_count,
|
||||
{"_recursion_count", rlock_recursion_count,
|
||||
METH_NOARGS, rlock_recursion_count_doc},
|
||||
{"__enter__", _PyCFunction_CAST(rlock_acquire),
|
||||
METH_VARARGS | METH_KEYWORDS, rlock_enter_doc},
|
||||
{"__exit__", (PyCFunction)rlock_release,
|
||||
{"__exit__", rlock_release,
|
||||
METH_VARARGS, rlock_exit_doc},
|
||||
#ifdef HAVE_FORK
|
||||
{"_at_fork_reinit", (PyCFunction)rlock__at_fork_reinit,
|
||||
|
@ -1292,8 +1312,8 @@ static PyMemberDef rlock_type_members[] = {
|
|||
};
|
||||
|
||||
static PyType_Slot rlock_type_slots[] = {
|
||||
{Py_tp_dealloc, (destructor)rlock_dealloc},
|
||||
{Py_tp_repr, (reprfunc)rlock_repr},
|
||||
{Py_tp_dealloc, rlock_dealloc},
|
||||
{Py_tp_repr, rlock_repr},
|
||||
{Py_tp_methods, rlock_methods},
|
||||
{Py_tp_alloc, PyType_GenericAlloc},
|
||||
{Py_tp_new, rlock_new},
|
||||
|
@ -1392,8 +1412,9 @@ typedef struct {
|
|||
} localdummyobject;
|
||||
|
||||
static void
|
||||
localdummy_dealloc(localdummyobject *self)
|
||||
localdummy_dealloc(PyObject *op)
|
||||
{
|
||||
localdummyobject *self = (localdummyobject*)op;
|
||||
if (self->weakreflist != NULL)
|
||||
PyObject_ClearWeakRefs((PyObject *) self);
|
||||
PyTypeObject *tp = Py_TYPE(self);
|
||||
|
@ -1407,7 +1428,7 @@ static PyMemberDef local_dummy_type_members[] = {
|
|||
};
|
||||
|
||||
static PyType_Slot local_dummy_type_slots[] = {
|
||||
{Py_tp_dealloc, (destructor)localdummy_dealloc},
|
||||
{Py_tp_dealloc, localdummy_dealloc},
|
||||
{Py_tp_doc, "Thread-local dummy"},
|
||||
{Py_tp_members, local_dummy_type_members},
|
||||
{0, 0}
|
||||
|
|
Loading…
Reference in New Issue