mirror of
https://github.com/python/cpython.git
synced 2024-11-27 23:47:29 +01:00
be5e8a0103
Move the following private functions and structures to pycore_modsupport.h internal C API: * _PyArg_BadArgument() * _PyArg_CheckPositional() * _PyArg_NoKeywords() * _PyArg_NoPositional() * _PyArg_ParseStack() * _PyArg_ParseStackAndKeywords() * _PyArg_Parser structure * _PyArg_UnpackKeywords() * _PyArg_UnpackKeywordsWithVararg() * _PyArg_UnpackStack() * _Py_ANY_VARARGS() Changes: * Python/getargs.h now includes pycore_modsupport.h to export functions. * clinic.py now adds pycore_modsupport.h when one of these functions is used. * Add pycore_modsupport.h includes when a C extension uses one of these functions. * Define Py_BUILD_CORE_MODULE in C extensions which now include directly or indirectly (via code generated by Argument Clinic) pycore_modsupport.h: * _csv * _curses_panel * _dbm * _gdbm * _multiprocessing.posixshmem * _sqlite.row * _statistics * grp * resource * syslog * _testcapi: bad_get() no longer uses METH_FASTCALL calling convention but METH_VARARGS. Replace _PyArg_UnpackStack() with PyArg_ParseTuple(). * _testcapi: add PYTESTCAPI_NEED_INTERNAL_API macro which is defined by _testcapi sub-modules which need the internal C API (pycore_modsupport.h): exceptions.c, float.c, vectorcall.c, watchers.c. * Remove Include/cpython/modsupport.h header file. Include/modsupport.h no longer includes the removed header file. * Fix mypy clinic.py
76 lines
2.3 KiB
C
Generated
76 lines
2.3 KiB
C
Generated
/*[clinic input]
|
|
preserve
|
|
[clinic start generated code]*/
|
|
|
|
#include "pycore_abstract.h" // _PyNumber_Index()
|
|
#include "pycore_modsupport.h" // _PyArg_CheckPositional()
|
|
|
|
PyDoc_STRVAR(_testinternalcapi_benchmark_locks__doc__,
|
|
"benchmark_locks($module, num_threads, use_pymutex=True,\n"
|
|
" critical_section_length=1, time_ms=1000, /)\n"
|
|
"--\n"
|
|
"\n");
|
|
|
|
#define _TESTINTERNALCAPI_BENCHMARK_LOCKS_METHODDEF \
|
|
{"benchmark_locks", _PyCFunction_CAST(_testinternalcapi_benchmark_locks), METH_FASTCALL, _testinternalcapi_benchmark_locks__doc__},
|
|
|
|
static PyObject *
|
|
_testinternalcapi_benchmark_locks_impl(PyObject *module,
|
|
Py_ssize_t num_threads,
|
|
int use_pymutex,
|
|
int critical_section_length,
|
|
int time_ms);
|
|
|
|
static PyObject *
|
|
_testinternalcapi_benchmark_locks(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|
{
|
|
PyObject *return_value = NULL;
|
|
Py_ssize_t num_threads;
|
|
int use_pymutex = 1;
|
|
int critical_section_length = 1;
|
|
int time_ms = 1000;
|
|
|
|
if (!_PyArg_CheckPositional("benchmark_locks", nargs, 1, 4)) {
|
|
goto exit;
|
|
}
|
|
{
|
|
Py_ssize_t ival = -1;
|
|
PyObject *iobj = _PyNumber_Index(args[0]);
|
|
if (iobj != NULL) {
|
|
ival = PyLong_AsSsize_t(iobj);
|
|
Py_DECREF(iobj);
|
|
}
|
|
if (ival == -1 && PyErr_Occurred()) {
|
|
goto exit;
|
|
}
|
|
num_threads = ival;
|
|
}
|
|
if (nargs < 2) {
|
|
goto skip_optional;
|
|
}
|
|
use_pymutex = PyObject_IsTrue(args[1]);
|
|
if (use_pymutex < 0) {
|
|
goto exit;
|
|
}
|
|
if (nargs < 3) {
|
|
goto skip_optional;
|
|
}
|
|
critical_section_length = PyLong_AsInt(args[2]);
|
|
if (critical_section_length == -1 && PyErr_Occurred()) {
|
|
goto exit;
|
|
}
|
|
if (nargs < 4) {
|
|
goto skip_optional;
|
|
}
|
|
time_ms = PyLong_AsInt(args[3]);
|
|
if (time_ms == -1 && PyErr_Occurred()) {
|
|
goto exit;
|
|
}
|
|
skip_optional:
|
|
return_value = _testinternalcapi_benchmark_locks_impl(module, num_threads, use_pymutex, critical_section_length, time_ms);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
/*[clinic end generated code: output=105105d759c0c271 input=a9049054013a1b77]*/
|