• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 *
_posixshmem_shm_open(PyObject * module,PyObject * args,PyObject * kwargs)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)(void(*)(void))_posixshmem_shm_unlink, METH_VARARGS|METH_KEYWORDS, _posixshmem_shm_unlink__doc__},
59 
60 static PyObject *
61 _posixshmem_shm_unlink_impl(PyObject *module, PyObject *path);
62 
63 static PyObject *
_posixshmem_shm_unlink(PyObject * module,PyObject * args,PyObject * kwargs)64 _posixshmem_shm_unlink(PyObject *module, PyObject *args, PyObject *kwargs)
65 {
66     PyObject *return_value = NULL;
67     static char *_keywords[] = {"path", NULL};
68     PyObject *path;
69 
70     if (!PyArg_ParseTupleAndKeywords(args, kwargs, "U:shm_unlink", _keywords,
71         &path))
72         goto exit;
73     return_value = _posixshmem_shm_unlink_impl(module, path);
74 
75 exit:
76     return return_value;
77 }
78 
79 #endif /* defined(HAVE_SHM_UNLINK) */
80 
81 #ifndef _POSIXSHMEM_SHM_OPEN_METHODDEF
82     #define _POSIXSHMEM_SHM_OPEN_METHODDEF
83 #endif /* !defined(_POSIXSHMEM_SHM_OPEN_METHODDEF) */
84 
85 #ifndef _POSIXSHMEM_SHM_UNLINK_METHODDEF
86     #define _POSIXSHMEM_SHM_UNLINK_METHODDEF
87 #endif /* !defined(_POSIXSHMEM_SHM_UNLINK_METHODDEF) */
88 /*[clinic end generated code: output=be0661dbed83ea23 input=a9049054013a1b77]*/
89