/src/cpython/Modules/clinic/_threadmodule.c.h
Line | Count | Source (jump to first uncovered line) |
1 | | /*[clinic input] |
2 | | preserve |
3 | | [clinic start generated code]*/ |
4 | | |
5 | | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
6 | | # include "pycore_gc.h" // PyGC_Head |
7 | | # include "pycore_runtime.h" // _Py_ID() |
8 | | #endif |
9 | | #include "pycore_modsupport.h" // _PyArg_NoKeywords() |
10 | | |
11 | | static PyObject * |
12 | | lock_new_impl(PyTypeObject *type); |
13 | | |
14 | | static PyObject * |
15 | | lock_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
16 | 0 | { |
17 | 0 | PyObject *return_value = NULL; |
18 | 0 | PyTypeObject *base_tp = clinic_state()->lock_type; |
19 | |
|
20 | 0 | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
21 | 0 | !_PyArg_NoPositional("lock", args)) { |
22 | 0 | goto exit; |
23 | 0 | } |
24 | 0 | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
25 | 0 | !_PyArg_NoKeywords("lock", kwargs)) { |
26 | 0 | goto exit; |
27 | 0 | } |
28 | 0 | return_value = lock_new_impl(type); |
29 | |
|
30 | 0 | exit: |
31 | 0 | return return_value; |
32 | 0 | } |
33 | | |
34 | | static PyObject * |
35 | | rlock_new_impl(PyTypeObject *type); |
36 | | |
37 | | static PyObject * |
38 | | rlock_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
39 | 2.74k | { |
40 | 2.74k | PyObject *return_value = NULL; |
41 | 2.74k | PyTypeObject *base_tp = clinic_state()->rlock_type; |
42 | | |
43 | 2.74k | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
44 | 2.74k | !_PyArg_NoPositional("RLock", args)) { |
45 | 0 | goto exit; |
46 | 0 | } |
47 | 2.74k | if ((type == base_tp || type->tp_init == base_tp->tp_init) && |
48 | 2.74k | !_PyArg_NoKeywords("RLock", kwargs)) { |
49 | 0 | goto exit; |
50 | 0 | } |
51 | 2.74k | return_value = rlock_new_impl(type); |
52 | | |
53 | 2.74k | exit: |
54 | 2.74k | return return_value; |
55 | 2.74k | } |
56 | | |
57 | | #if (defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP) || defined(MS_WINDOWS)) |
58 | | |
59 | | PyDoc_STRVAR(_thread__get_name__doc__, |
60 | | "_get_name($module, /)\n" |
61 | | "--\n" |
62 | | "\n" |
63 | | "Get the name of the current thread."); |
64 | | |
65 | | #define _THREAD__GET_NAME_METHODDEF \ |
66 | | {"_get_name", (PyCFunction)_thread__get_name, METH_NOARGS, _thread__get_name__doc__}, |
67 | | |
68 | | static PyObject * |
69 | | _thread__get_name_impl(PyObject *module); |
70 | | |
71 | | static PyObject * |
72 | | _thread__get_name(PyObject *module, PyObject *Py_UNUSED(ignored)) |
73 | 0 | { |
74 | 0 | return _thread__get_name_impl(module); |
75 | 0 | } |
76 | | |
77 | | #endif /* (defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP) || defined(MS_WINDOWS)) */ |
78 | | |
79 | | #if (defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP) || defined(MS_WINDOWS)) |
80 | | |
81 | | PyDoc_STRVAR(_thread_set_name__doc__, |
82 | | "set_name($module, /, name)\n" |
83 | | "--\n" |
84 | | "\n" |
85 | | "Set the name of the current thread."); |
86 | | |
87 | | #define _THREAD_SET_NAME_METHODDEF \ |
88 | | {"set_name", _PyCFunction_CAST(_thread_set_name), METH_FASTCALL|METH_KEYWORDS, _thread_set_name__doc__}, |
89 | | |
90 | | static PyObject * |
91 | | _thread_set_name_impl(PyObject *module, PyObject *name_obj); |
92 | | |
93 | | static PyObject * |
94 | | _thread_set_name(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
95 | 0 | { |
96 | 0 | PyObject *return_value = NULL; |
97 | 0 | #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
98 | |
|
99 | 0 | #define NUM_KEYWORDS 1 |
100 | 0 | static struct { |
101 | 0 | PyGC_Head _this_is_not_used; |
102 | 0 | PyObject_VAR_HEAD |
103 | 0 | Py_hash_t ob_hash; |
104 | 0 | PyObject *ob_item[NUM_KEYWORDS]; |
105 | 0 | } _kwtuple = { |
106 | 0 | .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
107 | 0 | .ob_hash = -1, |
108 | 0 | .ob_item = { &_Py_ID(name), }, |
109 | 0 | }; |
110 | 0 | #undef NUM_KEYWORDS |
111 | 0 | #define KWTUPLE (&_kwtuple.ob_base.ob_base) |
112 | |
|
113 | | #else // !Py_BUILD_CORE |
114 | | # define KWTUPLE NULL |
115 | | #endif // !Py_BUILD_CORE |
116 | |
|
117 | 0 | static const char * const _keywords[] = {"name", NULL}; |
118 | 0 | static _PyArg_Parser _parser = { |
119 | 0 | .keywords = _keywords, |
120 | 0 | .fname = "set_name", |
121 | 0 | .kwtuple = KWTUPLE, |
122 | 0 | }; |
123 | 0 | #undef KWTUPLE |
124 | 0 | PyObject *argsbuf[1]; |
125 | 0 | PyObject *name_obj; |
126 | |
|
127 | 0 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
128 | 0 | /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
129 | 0 | if (!args) { |
130 | 0 | goto exit; |
131 | 0 | } |
132 | 0 | if (!PyUnicode_Check(args[0])) { |
133 | 0 | _PyArg_BadArgument("set_name", "argument 'name'", "str", args[0]); |
134 | 0 | goto exit; |
135 | 0 | } |
136 | 0 | name_obj = args[0]; |
137 | 0 | return_value = _thread_set_name_impl(module, name_obj); |
138 | |
|
139 | 0 | exit: |
140 | 0 | return return_value; |
141 | 0 | } |
142 | | |
143 | | #endif /* (defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP) || defined(MS_WINDOWS)) */ |
144 | | |
145 | | #ifndef _THREAD__GET_NAME_METHODDEF |
146 | | #define _THREAD__GET_NAME_METHODDEF |
147 | | #endif /* !defined(_THREAD__GET_NAME_METHODDEF) */ |
148 | | |
149 | | #ifndef _THREAD_SET_NAME_METHODDEF |
150 | | #define _THREAD_SET_NAME_METHODDEF |
151 | | #endif /* !defined(_THREAD_SET_NAME_METHODDEF) */ |
152 | | /*[clinic end generated code: output=b381ec5e313198e7 input=a9049054013a1b77]*/ |