1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #include "pycore_modsupport.h" // _PyArg_CheckPositional()
6
7 #if defined(MS_WINDOWS)
8
9 PyDoc_STRVAR(_multiprocessing_closesocket__doc__,
10 "closesocket($module, handle, /)\n"
11 "--\n"
12 "\n");
13
14 #define _MULTIPROCESSING_CLOSESOCKET_METHODDEF \
15 {"closesocket", (PyCFunction)_multiprocessing_closesocket, METH_O, _multiprocessing_closesocket__doc__},
16
17 static PyObject *
18 _multiprocessing_closesocket_impl(PyObject *module, HANDLE handle);
19
20 static PyObject *
_multiprocessing_closesocket(PyObject * module,PyObject * arg)21 _multiprocessing_closesocket(PyObject *module, PyObject *arg)
22 {
23 PyObject *return_value = NULL;
24 HANDLE handle;
25
26 handle = PyLong_AsVoidPtr(arg);
27 if (!handle && PyErr_Occurred()) {
28 goto exit;
29 }
30 return_value = _multiprocessing_closesocket_impl(module, handle);
31
32 exit:
33 return return_value;
34 }
35
36 #endif /* defined(MS_WINDOWS) */
37
38 #if defined(MS_WINDOWS)
39
40 PyDoc_STRVAR(_multiprocessing_recv__doc__,
41 "recv($module, handle, size, /)\n"
42 "--\n"
43 "\n");
44
45 #define _MULTIPROCESSING_RECV_METHODDEF \
46 {"recv", _PyCFunction_CAST(_multiprocessing_recv), METH_FASTCALL, _multiprocessing_recv__doc__},
47
48 static PyObject *
49 _multiprocessing_recv_impl(PyObject *module, HANDLE handle, int size);
50
51 static PyObject *
_multiprocessing_recv(PyObject * module,PyObject * const * args,Py_ssize_t nargs)52 _multiprocessing_recv(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
53 {
54 PyObject *return_value = NULL;
55 HANDLE handle;
56 int size;
57
58 if (!_PyArg_CheckPositional("recv", nargs, 2, 2)) {
59 goto exit;
60 }
61 handle = PyLong_AsVoidPtr(args[0]);
62 if (!handle && PyErr_Occurred()) {
63 goto exit;
64 }
65 size = PyLong_AsInt(args[1]);
66 if (size == -1 && PyErr_Occurred()) {
67 goto exit;
68 }
69 return_value = _multiprocessing_recv_impl(module, handle, size);
70
71 exit:
72 return return_value;
73 }
74
75 #endif /* defined(MS_WINDOWS) */
76
77 #if defined(MS_WINDOWS)
78
79 PyDoc_STRVAR(_multiprocessing_send__doc__,
80 "send($module, handle, buf, /)\n"
81 "--\n"
82 "\n");
83
84 #define _MULTIPROCESSING_SEND_METHODDEF \
85 {"send", _PyCFunction_CAST(_multiprocessing_send), METH_FASTCALL, _multiprocessing_send__doc__},
86
87 static PyObject *
88 _multiprocessing_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf);
89
90 static PyObject *
_multiprocessing_send(PyObject * module,PyObject * const * args,Py_ssize_t nargs)91 _multiprocessing_send(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
92 {
93 PyObject *return_value = NULL;
94 HANDLE handle;
95 Py_buffer buf = {NULL, NULL};
96
97 if (!_PyArg_CheckPositional("send", nargs, 2, 2)) {
98 goto exit;
99 }
100 handle = PyLong_AsVoidPtr(args[0]);
101 if (!handle && PyErr_Occurred()) {
102 goto exit;
103 }
104 if (PyObject_GetBuffer(args[1], &buf, PyBUF_SIMPLE) != 0) {
105 goto exit;
106 }
107 return_value = _multiprocessing_send_impl(module, handle, &buf);
108
109 exit:
110 /* Cleanup for buf */
111 if (buf.obj) {
112 PyBuffer_Release(&buf);
113 }
114
115 return return_value;
116 }
117
118 #endif /* defined(MS_WINDOWS) */
119
120 PyDoc_STRVAR(_multiprocessing_sem_unlink__doc__,
121 "sem_unlink($module, name, /)\n"
122 "--\n"
123 "\n");
124
125 #define _MULTIPROCESSING_SEM_UNLINK_METHODDEF \
126 {"sem_unlink", (PyCFunction)_multiprocessing_sem_unlink, METH_O, _multiprocessing_sem_unlink__doc__},
127
128 static PyObject *
129 _multiprocessing_sem_unlink_impl(PyObject *module, const char *name);
130
131 static PyObject *
_multiprocessing_sem_unlink(PyObject * module,PyObject * arg)132 _multiprocessing_sem_unlink(PyObject *module, PyObject *arg)
133 {
134 PyObject *return_value = NULL;
135 const char *name;
136
137 if (!PyUnicode_Check(arg)) {
138 _PyArg_BadArgument("sem_unlink", "argument", "str", arg);
139 goto exit;
140 }
141 Py_ssize_t name_length;
142 name = PyUnicode_AsUTF8AndSize(arg, &name_length);
143 if (name == NULL) {
144 goto exit;
145 }
146 if (strlen(name) != (size_t)name_length) {
147 PyErr_SetString(PyExc_ValueError, "embedded null character");
148 goto exit;
149 }
150 return_value = _multiprocessing_sem_unlink_impl(module, name);
151
152 exit:
153 return return_value;
154 }
155
156 #ifndef _MULTIPROCESSING_CLOSESOCKET_METHODDEF
157 #define _MULTIPROCESSING_CLOSESOCKET_METHODDEF
158 #endif /* !defined(_MULTIPROCESSING_CLOSESOCKET_METHODDEF) */
159
160 #ifndef _MULTIPROCESSING_RECV_METHODDEF
161 #define _MULTIPROCESSING_RECV_METHODDEF
162 #endif /* !defined(_MULTIPROCESSING_RECV_METHODDEF) */
163
164 #ifndef _MULTIPROCESSING_SEND_METHODDEF
165 #define _MULTIPROCESSING_SEND_METHODDEF
166 #endif /* !defined(_MULTIPROCESSING_SEND_METHODDEF) */
167 /*[clinic end generated code: output=73b4cb8428d816da input=a9049054013a1b77]*/
168