0
0
mirror of https://github.com/python/cpython.git synced 2024-12-01 03:01:36 +01:00
cpython/Modules/clinic/resource.c.h
Victor Stinner ad73674283
gh-107603: Argument Clinic: Only include pycore_gc.h if needed (#108726)
Argument Clinic now only includes pycore_gc.h if PyGC_Head is needed,
and only includes pycore_runtime.h if _Py_ID() is needed.

* Add 'condition' optional argument to Clinic.add_include().
* deprecate_keyword_use() includes pycore_runtime.h when using
  the _PyID() function.
* Fix rendering of includes: comments start at the column 35.
* Mark PC/clinic/_wmimodule.cpp.h and
  "Objects/stringlib/clinic/*.h.h" header files as generated in
  .gitattributes.

Effects:

* 42 header files generated by AC no longer include the internal C
  API, instead of 4 header files before. For example,
  Modules/clinic/_abc.c.h no longer includes the internal C API.
* Fix _testclinic_depr.c.h: it now always includes pycore_runtime.h
  to get _Py_ID().
2023-08-31 23:42:34 +02:00

176 lines
4.2 KiB
C
Generated

/*[clinic input]
preserve
[clinic start generated code]*/
#if defined(HAVE_GETRUSAGE)
PyDoc_STRVAR(resource_getrusage__doc__,
"getrusage($module, who, /)\n"
"--\n"
"\n");
#define RESOURCE_GETRUSAGE_METHODDEF \
{"getrusage", (PyCFunction)resource_getrusage, METH_O, resource_getrusage__doc__},
static PyObject *
resource_getrusage_impl(PyObject *module, int who);
static PyObject *
resource_getrusage(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int who;
who = PyLong_AsInt(arg);
if (who == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = resource_getrusage_impl(module, who);
exit:
return return_value;
}
#endif /* defined(HAVE_GETRUSAGE) */
PyDoc_STRVAR(resource_getrlimit__doc__,
"getrlimit($module, resource, /)\n"
"--\n"
"\n");
#define RESOURCE_GETRLIMIT_METHODDEF \
{"getrlimit", (PyCFunction)resource_getrlimit, METH_O, resource_getrlimit__doc__},
static PyObject *
resource_getrlimit_impl(PyObject *module, int resource);
static PyObject *
resource_getrlimit(PyObject *module, PyObject *arg)
{
PyObject *return_value = NULL;
int resource;
resource = PyLong_AsInt(arg);
if (resource == -1 && PyErr_Occurred()) {
goto exit;
}
return_value = resource_getrlimit_impl(module, resource);
exit:
return return_value;
}
PyDoc_STRVAR(resource_setrlimit__doc__,
"setrlimit($module, resource, limits, /)\n"
"--\n"
"\n");
#define RESOURCE_SETRLIMIT_METHODDEF \
{"setrlimit", _PyCFunction_CAST(resource_setrlimit), METH_FASTCALL, resource_setrlimit__doc__},
static PyObject *
resource_setrlimit_impl(PyObject *module, int resource, PyObject *limits);
static PyObject *
resource_setrlimit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
int resource;
PyObject *limits;
if (!_PyArg_CheckPositional("setrlimit", nargs, 2, 2)) {
goto exit;
}
resource = PyLong_AsInt(args[0]);
if (resource == -1 && PyErr_Occurred()) {
goto exit;
}
limits = args[1];
return_value = resource_setrlimit_impl(module, resource, limits);
exit:
return return_value;
}
#if defined(HAVE_PRLIMIT)
PyDoc_STRVAR(resource_prlimit__doc__,
"prlimit($module, pid, resource, limits=None, /)\n"
"--\n"
"\n");
#define RESOURCE_PRLIMIT_METHODDEF \
{"prlimit", _PyCFunction_CAST(resource_prlimit), METH_FASTCALL, resource_prlimit__doc__},
static PyObject *
resource_prlimit_impl(PyObject *module, pid_t pid, int resource,
PyObject *limits);
static PyObject *
resource_prlimit(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
pid_t pid;
int resource;
PyObject *limits = Py_None;
if (!_PyArg_CheckPositional("prlimit", nargs, 2, 3)) {
goto exit;
}
pid = PyLong_AsPid(args[0]);
if (pid == -1 && PyErr_Occurred()) {
goto exit;
}
resource = PyLong_AsInt(args[1]);
if (resource == -1 && PyErr_Occurred()) {
goto exit;
}
if (nargs < 3) {
goto skip_optional;
}
limits = args[2];
skip_optional:
return_value = resource_prlimit_impl(module, pid, resource, limits);
exit:
return return_value;
}
#endif /* defined(HAVE_PRLIMIT) */
PyDoc_STRVAR(resource_getpagesize__doc__,
"getpagesize($module, /)\n"
"--\n"
"\n");
#define RESOURCE_GETPAGESIZE_METHODDEF \
{"getpagesize", (PyCFunction)resource_getpagesize, METH_NOARGS, resource_getpagesize__doc__},
static int
resource_getpagesize_impl(PyObject *module);
static PyObject *
resource_getpagesize(PyObject *module, PyObject *Py_UNUSED(ignored))
{
PyObject *return_value = NULL;
int _return_value;
_return_value = resource_getpagesize_impl(module);
if ((_return_value == -1) && PyErr_Occurred()) {
goto exit;
}
return_value = PyLong_FromLong((long)_return_value);
exit:
return return_value;
}
#ifndef RESOURCE_GETRUSAGE_METHODDEF
#define RESOURCE_GETRUSAGE_METHODDEF
#endif /* !defined(RESOURCE_GETRUSAGE_METHODDEF) */
#ifndef RESOURCE_PRLIMIT_METHODDEF
#define RESOURCE_PRLIMIT_METHODDEF
#endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */
/*[clinic end generated code: output=2376b9a3f03777aa input=a9049054013a1b77]*/