#include "multiprocessing.h"
#include "clinic/multiprocessing.c.h"
PyObject *
_PyMp_SetError(PyObject *Type, int num)
{ … }
#ifdef MS_WINDOWS
static PyObject *
_multiprocessing_closesocket_impl(PyObject *module, HANDLE handle)
{
int ret;
Py_BEGIN_ALLOW_THREADS
ret = closesocket((SOCKET) handle);
Py_END_ALLOW_THREADS
if (ret)
return PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError());
Py_RETURN_NONE;
}
static PyObject *
_multiprocessing_recv_impl(PyObject *module, HANDLE handle, int size)
{
int nread;
PyObject *buf;
buf = PyBytes_FromStringAndSize(NULL, size);
if (!buf)
return NULL;
Py_BEGIN_ALLOW_THREADS
nread = recv((SOCKET) handle, PyBytes_AS_STRING(buf), size, 0);
Py_END_ALLOW_THREADS
if (nread < 0) {
Py_DECREF(buf);
return PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError());
}
_PyBytes_Resize(&buf, nread);
return buf;
}
static PyObject *
_multiprocessing_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf)
{
int ret, length;
length = (int)Py_MIN(buf->len, INT_MAX);
Py_BEGIN_ALLOW_THREADS
ret = send((SOCKET) handle, buf->buf, length, 0);
Py_END_ALLOW_THREADS
if (ret < 0)
return PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError());
return PyLong_FromLong(ret);
}
#endif
static PyObject *
_multiprocessing_sem_unlink_impl(PyObject *module, const char *name)
{ … }
static PyMethodDef module_methods[] = …;
static int
multiprocessing_exec(PyObject *module)
{ … }
static PyModuleDef_Slot multiprocessing_slots[] = …;
static struct PyModuleDef multiprocessing_module = …;
PyMODINIT_FUNC
PyInit__multiprocessing(void)
{ … }