2019-02-24 00:08:16 -04:00
|
|
|
/*[clinic input]
|
|
|
|
preserve
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
#if defined(HAVE_SHM_OPEN)
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_posixshmem_shm_open__doc__,
|
2024-05-13 11:03:52 -03:00
|
|
|
"shm_open($module, /, path, flags, mode=511)\n"
|
2019-02-24 00:08:16 -04:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Open a shared memory object. Returns a file descriptor (integer).");
|
|
|
|
|
|
|
|
#define _POSIXSHMEM_SHM_OPEN_METHODDEF \
|
2023-10-19 19:23:49 -03:00
|
|
|
{"shm_open", (PyCFunction)(void(*)(void))_posixshmem_shm_open, METH_VARARGS|METH_KEYWORDS, _posixshmem_shm_open__doc__},
|
2019-02-24 00:08:16 -04:00
|
|
|
|
|
|
|
static int
|
|
|
|
_posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags,
|
|
|
|
int mode);
|
|
|
|
|
|
|
|
static PyObject *
|
2023-10-19 19:23:49 -03:00
|
|
|
_posixshmem_shm_open(PyObject *module, PyObject *args, PyObject *kwargs)
|
2019-02-24 00:08:16 -04:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
2024-05-13 11:03:52 -03:00
|
|
|
static char *_keywords[] = {"path", "flags", "mode", NULL};
|
2019-02-24 00:08:16 -04:00
|
|
|
PyObject *path;
|
|
|
|
int flags;
|
|
|
|
int mode = 511;
|
|
|
|
int _return_value;
|
|
|
|
|
2023-10-19 19:23:49 -03:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ui|i:shm_open", _keywords,
|
|
|
|
&path, &flags, &mode))
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
2019-02-24 00:08:16 -04:00
|
|
|
_return_value = _posixshmem_shm_open_impl(module, path, flags, mode);
|
|
|
|
if ((_return_value == -1) && PyErr_Occurred()) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
return_value = PyLong_FromLong((long)_return_value);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* defined(HAVE_SHM_OPEN) */
|
|
|
|
|
|
|
|
#if defined(HAVE_SHM_UNLINK)
|
|
|
|
|
|
|
|
PyDoc_STRVAR(_posixshmem_shm_unlink__doc__,
|
2024-05-10 07:04:16 -03:00
|
|
|
"shm_unlink($module, path, /)\n"
|
2019-02-24 00:08:16 -04:00
|
|
|
"--\n"
|
|
|
|
"\n"
|
|
|
|
"Remove a shared memory object (similar to unlink()).\n"
|
|
|
|
"\n"
|
|
|
|
"Remove a shared memory object name, and, once all processes have unmapped\n"
|
|
|
|
"the object, de-allocates and destroys the contents of the associated memory\n"
|
|
|
|
"region.");
|
|
|
|
|
|
|
|
#define _POSIXSHMEM_SHM_UNLINK_METHODDEF \
|
2024-05-10 07:04:16 -03:00
|
|
|
{"shm_unlink", (PyCFunction)_posixshmem_shm_unlink, METH_O, _posixshmem_shm_unlink__doc__},
|
2019-02-24 00:08:16 -04:00
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
_posixshmem_shm_unlink_impl(PyObject *module, PyObject *path);
|
|
|
|
|
|
|
|
static PyObject *
|
2024-05-10 07:04:16 -03:00
|
|
|
_posixshmem_shm_unlink(PyObject *module, PyObject *arg)
|
2019-02-24 00:08:16 -04:00
|
|
|
{
|
|
|
|
PyObject *return_value = NULL;
|
|
|
|
PyObject *path;
|
|
|
|
|
2024-05-10 07:04:16 -03:00
|
|
|
if (!PyUnicode_Check(arg)) {
|
|
|
|
PyErr_Format(PyExc_TypeError, "shm_unlink() argument must be str, not %T", arg);
|
2019-03-14 05:32:22 -03:00
|
|
|
goto exit;
|
2024-05-10 07:04:16 -03:00
|
|
|
}
|
|
|
|
path = arg;
|
2019-02-24 00:08:16 -04:00
|
|
|
return_value = _posixshmem_shm_unlink_impl(module, path);
|
|
|
|
|
|
|
|
exit:
|
|
|
|
return return_value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* defined(HAVE_SHM_UNLINK) */
|
|
|
|
|
|
|
|
#ifndef _POSIXSHMEM_SHM_OPEN_METHODDEF
|
|
|
|
#define _POSIXSHMEM_SHM_OPEN_METHODDEF
|
|
|
|
#endif /* !defined(_POSIXSHMEM_SHM_OPEN_METHODDEF) */
|
|
|
|
|
|
|
|
#ifndef _POSIXSHMEM_SHM_UNLINK_METHODDEF
|
|
|
|
#define _POSIXSHMEM_SHM_UNLINK_METHODDEF
|
|
|
|
#endif /* !defined(_POSIXSHMEM_SHM_UNLINK_METHODDEF) */
|
2024-05-13 11:03:52 -03:00
|
|
|
/*[clinic end generated code: output=74588a5abba6e36c input=a9049054013a1b77]*/
|