| 1 |
/*[clinic input] |
| 2 |
preserve |
| 3 |
[clinic start generated code]*/ |
| 4 |
|
| 5 |
#if defined(HAVE_SHM_OPEN) |
| 6 |
|
| 7 |
PyDoc_STRVAR(_posixshmem_shm_open__doc__, |
| 8 |
"shm_open($module, /, path, flags, mode=511)\n" |
| 9 |
"--\n" |
| 10 |
"\n" |
| 11 |
"Open a shared memory object. Returns a file descriptor (integer)."); |
| 12 |
|
| 13 |
#define _POSIXSHMEM_SHM_OPEN_METHODDEF \ |
| 14 |
{"shm_open", (PyCFunction)(void(*)(void))_posixshmem_shm_open, METH_VARARGS|METH_KEYWORDS, _posixshmem_shm_open__doc__}, |
| 15 |
|
| 16 |
static int |
| 17 |
_posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags, |
| 18 |
int mode); |
| 19 |
|
| 20 |
static PyObject * |
| 21 |
_posixshmem_shm_open(PyObject *module, PyObject *args, PyObject *kwargs) |
| 22 |
{ |
| 23 |
PyObject *return_value = NULL; |
| 24 |
static char *_keywords[] = {"path", "flags", "mode", NULL}; |
| 25 |
PyObject *path; |
| 26 |
int flags; |
| 27 |
int mode = 511; |
| 28 |
int _return_value; |
| 29 |
|
| 30 |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ui|i:shm_open", _keywords, |
| 31 |
&path, &flags, &mode)) |
| 32 |
goto exit; |
| 33 |
_return_value = _posixshmem_shm_open_impl(module, path, flags, mode); |
| 34 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 35 |
goto exit; |
| 36 |
} |
| 37 |
return_value = PyLong_FromLong((long)_return_value); |
| 38 |
|
| 39 |
exit: |
| 40 |
return return_value; |
| 41 |
} |
| 42 |
|
| 43 |
#endif /* defined(HAVE_SHM_OPEN) */ |
| 44 |
|
| 45 |
#if defined(HAVE_SHM_UNLINK) |
| 46 |
|
| 47 |
PyDoc_STRVAR(_posixshmem_shm_unlink__doc__, |
| 48 |
"shm_unlink($module, path, /)\n" |
| 49 |
"--\n" |
| 50 |
"\n" |
| 51 |
"Remove a shared memory object (similar to unlink()).\n" |
| 52 |
"\n" |
| 53 |
"Remove a shared memory object name, and, once all processes have unmapped\n" |
| 54 |
"the object, de-allocates and destroys the contents of the associated memory\n" |
| 55 |
"region."); |
| 56 |
|
| 57 |
#define _POSIXSHMEM_SHM_UNLINK_METHODDEF \ |
| 58 |
{"shm_unlink", (PyCFunction)_posixshmem_shm_unlink, METH_O, _posixshmem_shm_unlink__doc__}, |
| 59 |
|
| 60 |
static PyObject * |
| 61 |
_posixshmem_shm_unlink_impl(PyObject *module, PyObject *path); |
| 62 |
|
| 63 |
static PyObject * |
| 64 |
_posixshmem_shm_unlink(PyObject *module, PyObject *arg) |
| 65 |
{ |
| 66 |
PyObject *return_value = NULL; |
| 67 |
PyObject *path; |
| 68 |
|
| 69 |
if (!PyUnicode_Check(arg)) { |
| 70 |
PyErr_Format(PyExc_TypeError, "shm_unlink() argument must be str, not %T", arg); |
| 71 |
goto exit; |
| 72 |
} |
| 73 |
path = arg; |
| 74 |
return_value = _posixshmem_shm_unlink_impl(module, path); |
| 75 |
|
| 76 |
exit: |
| 77 |
return return_value; |
| 78 |
} |
| 79 |
|
| 80 |
#endif /* defined(HAVE_SHM_UNLINK) */ |
| 81 |
|
| 82 |
#ifndef _POSIXSHMEM_SHM_OPEN_METHODDEF |
| 83 |
#define _POSIXSHMEM_SHM_OPEN_METHODDEF |
| 84 |
#endif /* !defined(_POSIXSHMEM_SHM_OPEN_METHODDEF) */ |
| 85 |
|
| 86 |
#ifndef _POSIXSHMEM_SHM_UNLINK_METHODDEF |
| 87 |
#define _POSIXSHMEM_SHM_UNLINK_METHODDEF |
| 88 |
#endif /* !defined(_POSIXSHMEM_SHM_UNLINK_METHODDEF) */ |
| 89 |
/*[clinic end generated code: output=74588a5abba6e36c input=a9049054013a1b77]*/ |