diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-03-12 11:08:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-12 11:08:30 (GMT) |
commit | 1989763f0d0858ce6274f5e1d725b5b8da91a780 (patch) | |
tree | bf1653613dc1450a466849554a72742b87c0dbe5 /Modules/clinic | |
parent | d2977a3ae2cc6802921b1e3b6e9d13fcfbda872d (diff) | |
download | cpython-1989763f0d0858ce6274f5e1d725b5b8da91a780.zip cpython-1989763f0d0858ce6274f5e1d725b5b8da91a780.tar.gz cpython-1989763f0d0858ce6274f5e1d725b5b8da91a780.tar.bz2 |
bpo-20185: Convert the resource moduel to Argument Clinic. (#545)
Based on patch by Vajrasky Kok.
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/resource.c.h | 164 |
1 files changed, 164 insertions, 0 deletions
diff --git a/Modules/clinic/resource.c.h b/Modules/clinic/resource.c.h new file mode 100644 index 0000000..6393270 --- /dev/null +++ b/Modules/clinic/resource.c.h @@ -0,0 +1,164 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +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; + + if (!PyArg_Parse(arg, "i:getrusage", &who)) { + goto exit; + } + return_value = resource_getrusage_impl(module, who); + +exit: + return return_value; +} + +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; + + if (!PyArg_Parse(arg, "i:getrlimit", &resource)) { + 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)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 **args, Py_ssize_t nargs, PyObject *kwnames) +{ + PyObject *return_value = NULL; + int resource; + PyObject *limits; + + if (!_PyArg_ParseStack(args, nargs, "iO:setrlimit", + &resource, &limits)) { + goto exit; + } + + if (!_PyArg_NoStackKeywords("setrlimit", kwnames)) { + goto exit; + } + return_value = resource_setrlimit_impl(module, resource, limits); + +exit: + return return_value; +} + +#if defined(HAVE_PRLIMIT) + +PyDoc_STRVAR(resource_prlimit__doc__, +"prlimit(pid, resource, [limits])"); + +#define RESOURCE_PRLIMIT_METHODDEF \ + {"prlimit", (PyCFunction)resource_prlimit, METH_VARARGS, resource_prlimit__doc__}, + +static PyObject * +resource_prlimit_impl(PyObject *module, pid_t pid, int resource, + int group_right_1, PyObject *limits); + +static PyObject * +resource_prlimit(PyObject *module, PyObject *args) +{ + PyObject *return_value = NULL; + pid_t pid; + int resource; + int group_right_1 = 0; + PyObject *limits = NULL; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:prlimit", &pid, &resource)) { + goto exit; + } + break; + case 3: + if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "iO:prlimit", &pid, &resource, &limits)) { + goto exit; + } + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "resource.prlimit requires 2 to 3 arguments"); + goto exit; + } + return_value = resource_prlimit_impl(module, pid, resource, group_right_1, 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_PRLIMIT_METHODDEF + #define RESOURCE_PRLIMIT_METHODDEF +#endif /* !defined(RESOURCE_PRLIMIT_METHODDEF) */ +/*[clinic end generated code: output=3af613da48e0f8c9 input=a9049054013a1b77]*/ |