Debian Codegraph @

Modules/clinic/_threadmodule.c.h

raw
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_UnpackKeywords()
10
11 #if (defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP) || defined(MS_WINDOWS))
12
13 PyDoc_STRVAR(_thread__get_name__doc__,
14 "_get_name($module, /)\n"
15 "--\n"
16 "\n"
17 "Get the name of the current thread.");
18
19 #define _THREAD__GET_NAME_METHODDEF \
20 {"_get_name", (PyCFunction)_thread__get_name, METH_NOARGS, _thread__get_name__doc__},
21
22 static PyObject *
23 _thread__get_name_impl(PyObject *module);
24
25 static PyObject *
26 _thread__get_name(PyObject *module, PyObject *Py_UNUSED(ignored))
27 {
28 return _thread__get_name_impl(module);
29 }
30
31 #endif /* (defined(HAVE_PTHREAD_GETNAME_NP) || defined(HAVE_PTHREAD_GET_NAME_NP) || defined(MS_WINDOWS)) */
32
33 #if (defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP) || defined(MS_WINDOWS))
34
35 PyDoc_STRVAR(_thread_set_name__doc__,
36 "set_name($module, /, name)\n"
37 "--\n"
38 "\n"
39 "Set the name of the current thread.");
40
41 #define _THREAD_SET_NAME_METHODDEF \
42 {"set_name", _PyCFunction_CAST(_thread_set_name), METH_FASTCALL|METH_KEYWORDS, _thread_set_name__doc__},
43
44 static PyObject *
45 _thread_set_name_impl(PyObject *module, PyObject *name_obj);
46
47 static PyObject *
48 _thread_set_name(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
49 {
50 PyObject *return_value = NULL;
51 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
52
53 #define NUM_KEYWORDS 1
54 static struct {
55 PyGC_Head _this_is_not_used;
56 PyObject_VAR_HEAD
57 Py_hash_t ob_hash;
58 PyObject *ob_item[NUM_KEYWORDS];
59 } _kwtuple = {
60 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
61 .ob_hash = -1,
62 .ob_item = { &_Py_ID(name), },
63 };
64 #undef NUM_KEYWORDS
65 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
66
67 #else // !Py_BUILD_CORE
68 # define KWTUPLE NULL
69 #endif // !Py_BUILD_CORE
70
71 static const char * const _keywords[] = {"name", NULL};
72 static _PyArg_Parser _parser = {
73 .keywords = _keywords,
74 .fname = "set_name",
75 .kwtuple = KWTUPLE,
76 };
77 #undef KWTUPLE
78 PyObject *argsbuf[1];
79 PyObject *name_obj;
80
81 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
82 /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
83 if (!args) {
84 goto exit;
85 }
86 if (!PyUnicode_Check(args[0])) {
87 _PyArg_BadArgument("set_name", "argument 'name'", "str", args[0]);
88 goto exit;
89 }
90 name_obj = args[0];
91 return_value = _thread_set_name_impl(module, name_obj);
92
93 exit:
94 return return_value;
95 }
96
97 #endif /* (defined(HAVE_PTHREAD_SETNAME_NP) || defined(HAVE_PTHREAD_SET_NAME_NP) || defined(MS_WINDOWS)) */
98
99 #ifndef _THREAD__GET_NAME_METHODDEF
100 #define _THREAD__GET_NAME_METHODDEF
101 #endif /* !defined(_THREAD__GET_NAME_METHODDEF) */
102
103 #ifndef _THREAD_SET_NAME_METHODDEF
104 #define _THREAD_SET_NAME_METHODDEF
105 #endif /* !defined(_THREAD_SET_NAME_METHODDEF) */
106 /*[clinic end generated code: output=e978dc4615b9bc35 input=a9049054013a1b77]*/