bpo-20175: Convert Modules/_multiprocessing to the Argument Clinic (GH-14245)

diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
index 806e638..77e6c85 100644
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -9,6 +9,20 @@
 
 #include "multiprocessing.h"
 
+/*[python input]
+class HANDLE_converter(CConverter):
+    type = "HANDLE"
+    format_unit = '"F_HANDLE"'
+
+[python start generated code]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=9fad6080b79ace91]*/
+
+/*[clinic input]
+module _multiprocessing
+[clinic start generated code]*/
+/*[clinic end generated code: output=da39a3ee5e6b4b0d input=01e0745f380ac6e3]*/
+
+#include "clinic/multiprocessing.c.h"
 
 /*
  * Function which raises exceptions based on error codes
@@ -50,14 +64,19 @@
 }
 
 #ifdef MS_WINDOWS
-static PyObject *
-multiprocessing_closesocket(PyObject *self, PyObject *args)
-{
-    HANDLE handle;
-    int ret;
+/*[clinic input]
+_multiprocessing.closesocket
 
-    if (!PyArg_ParseTuple(args, F_HANDLE ":closesocket" , &handle))
-        return NULL;
+    handle: HANDLE
+    /
+
+[clinic start generated code]*/
+
+static PyObject *
+_multiprocessing_closesocket_impl(PyObject *module, HANDLE handle)
+/*[clinic end generated code: output=214f359f900966f4 input=8a20706dd386c6cc]*/
+{
+    int ret;
 
     Py_BEGIN_ALLOW_THREADS
     ret = closesocket((SOCKET) handle);
@@ -68,15 +87,21 @@
     Py_RETURN_NONE;
 }
 
-static PyObject *
-multiprocessing_recv(PyObject *self, PyObject *args)
-{
-    HANDLE handle;
-    int size, nread;
-    PyObject *buf;
+/*[clinic input]
+_multiprocessing.recv
 
-    if (!PyArg_ParseTuple(args, F_HANDLE "i:recv" , &handle, &size))
-        return NULL;
+    handle: HANDLE
+    size: int
+    /
+
+[clinic start generated code]*/
+
+static PyObject *
+_multiprocessing_recv_impl(PyObject *module, HANDLE handle, int size)
+/*[clinic end generated code: output=92322781ba9ff598 input=6a5b0834372cee5b]*/
+{
+    int nread;
+    PyObject *buf;
 
     buf = PyBytes_FromStringAndSize(NULL, size);
     if (!buf)
@@ -94,23 +119,27 @@
     return buf;
 }
 
+/*[clinic input]
+_multiprocessing.send
+
+    handle: HANDLE
+    buf: Py_buffer
+    /
+
+[clinic start generated code]*/
+
 static PyObject *
-multiprocessing_send(PyObject *self, PyObject *args)
+_multiprocessing_send_impl(PyObject *module, HANDLE handle, Py_buffer *buf)
+/*[clinic end generated code: output=52d7df0519c596cb input=41dce742f98d2210]*/
 {
-    HANDLE handle;
-    Py_buffer buf;
     int ret, length;
 
-    if (!PyArg_ParseTuple(args, F_HANDLE "y*:send" , &handle, &buf))
-        return NULL;
-
-    length = (int)Py_MIN(buf.len, INT_MAX);
+    length = (int)Py_MIN(buf->len, INT_MAX);
 
     Py_BEGIN_ALLOW_THREADS
-    ret = send((SOCKET) handle, buf.buf, length, 0);
+    ret = send((SOCKET) handle, buf->buf, length, 0);
     Py_END_ALLOW_THREADS
 
-    PyBuffer_Release(&buf);
     if (ret < 0)
         return PyErr_SetExcFromWindowsErr(PyExc_OSError, WSAGetLastError());
     return PyLong_FromLong(ret);
@@ -118,18 +147,33 @@
 
 #endif
 
+/*[clinic input]
+_multiprocessing.sem_unlink
+
+    name: str
+    /
+
+[clinic start generated code]*/
+
+static PyObject *
+_multiprocessing_sem_unlink_impl(PyObject *module, const char *name)
+/*[clinic end generated code: output=fcbfeb1ed255e647 input=bf939aff9564f1d5]*/
+{
+    return _PyMp_sem_unlink(name);
+}
+
 /*
  * Function table
  */
 
 static PyMethodDef module_methods[] = {
 #ifdef MS_WINDOWS
-    {"closesocket", multiprocessing_closesocket, METH_VARARGS, ""},
-    {"recv", multiprocessing_recv, METH_VARARGS, ""},
-    {"send", multiprocessing_send, METH_VARARGS, ""},
+    _MULTIPROCESSING_CLOSESOCKET_METHODDEF
+    _MULTIPROCESSING_RECV_METHODDEF
+    _MULTIPROCESSING_SEND_METHODDEF
 #endif
 #if !defined(POSIX_SEMAPHORES_NOT_ENABLED) && !defined(__ANDROID__)
-    {"sem_unlink", _PyMp_sem_unlink, METH_VARARGS, ""},
+    _MULTIPROCESSING_SEM_UNLINK_METHODDEF
 #endif
     {NULL}
 };