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