| 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 |
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION() |
| 10 |
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
| 11 |
|
| 12 |
#if defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) |
| 13 |
|
| 14 |
PyDoc_STRVAR(_multiprocessing_SemLock_acquire__doc__, |
| 15 |
"acquire($self, /, block=True, timeout=None)\n" |
| 16 |
"--\n" |
| 17 |
"\n" |
| 18 |
"Acquire the semaphore/lock."); |
| 19 |
|
| 20 |
#define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF \ |
| 21 |
{"acquire", _PyCFunction_CAST(_multiprocessing_SemLock_acquire), METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__}, |
| 22 |
|
| 23 |
static PyObject * |
| 24 |
_multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking, |
| 25 |
PyObject *timeout_obj); |
| 26 |
|
| 27 |
static PyObject * |
| 28 |
_multiprocessing_SemLock_acquire(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 29 |
{ |
| 30 |
PyObject *return_value = NULL; |
| 31 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 32 |
|
| 33 |
#define NUM_KEYWORDS 2 |
| 34 |
static struct { |
| 35 |
PyGC_Head _this_is_not_used; |
| 36 |
PyObject_VAR_HEAD |
| 37 |
Py_hash_t ob_hash; |
| 38 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 39 |
} _kwtuple = { |
| 40 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 41 |
.ob_hash = -1, |
| 42 |
.ob_item = { &_Py_ID(block), &_Py_ID(timeout), }, |
| 43 |
}; |
| 44 |
#undef NUM_KEYWORDS |
| 45 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 46 |
|
| 47 |
#else // !Py_BUILD_CORE |
| 48 |
# define KWTUPLE NULL |
| 49 |
#endif // !Py_BUILD_CORE |
| 50 |
|
| 51 |
static const char * const _keywords[] = {"block", "timeout", NULL}; |
| 52 |
static _PyArg_Parser _parser = { |
| 53 |
.keywords = _keywords, |
| 54 |
.fname = "acquire", |
| 55 |
.kwtuple = KWTUPLE, |
| 56 |
}; |
| 57 |
#undef KWTUPLE |
| 58 |
PyObject *argsbuf[2]; |
| 59 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 60 |
int blocking = 1; |
| 61 |
PyObject *timeout_obj = Py_None; |
| 62 |
|
| 63 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 64 |
/*minpos*/ 0, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 65 |
if (!args) { |
| 66 |
goto exit; |
| 67 |
} |
| 68 |
if (!noptargs) { |
| 69 |
goto skip_optional_pos; |
| 70 |
} |
| 71 |
if (args[0]) { |
| 72 |
blocking = PyObject_IsTrue(args[0]); |
| 73 |
if (blocking < 0) { |
| 74 |
goto exit; |
| 75 |
} |
| 76 |
if (!--noptargs) { |
| 77 |
goto skip_optional_pos; |
| 78 |
} |
| 79 |
} |
| 80 |
timeout_obj = args[1]; |
| 81 |
skip_optional_pos: |
| 82 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 83 |
return_value = _multiprocessing_SemLock_acquire_impl((SemLockObject *)self, blocking, timeout_obj); |
| 84 |
Py_END_CRITICAL_SECTION(); |
| 85 |
|
| 86 |
exit: |
| 87 |
return return_value; |
| 88 |
} |
| 89 |
|
| 90 |
#endif /* defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) */ |
| 91 |
|
| 92 |
#if defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) |
| 93 |
|
| 94 |
PyDoc_STRVAR(_multiprocessing_SemLock_release__doc__, |
| 95 |
"release($self, /)\n" |
| 96 |
"--\n" |
| 97 |
"\n" |
| 98 |
"Release the semaphore/lock."); |
| 99 |
|
| 100 |
#define _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF \ |
| 101 |
{"release", (PyCFunction)_multiprocessing_SemLock_release, METH_NOARGS, _multiprocessing_SemLock_release__doc__}, |
| 102 |
|
| 103 |
static PyObject * |
| 104 |
_multiprocessing_SemLock_release_impl(SemLockObject *self); |
| 105 |
|
| 106 |
static PyObject * |
| 107 |
_multiprocessing_SemLock_release(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 108 |
{ |
| 109 |
PyObject *return_value = NULL; |
| 110 |
|
| 111 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 112 |
return_value = _multiprocessing_SemLock_release_impl((SemLockObject *)self); |
| 113 |
Py_END_CRITICAL_SECTION(); |
| 114 |
|
| 115 |
return return_value; |
| 116 |
} |
| 117 |
|
| 118 |
#endif /* defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) */ |
| 119 |
|
| 120 |
#if defined(HAVE_MP_SEMAPHORE) && !defined(MS_WINDOWS) |
| 121 |
|
| 122 |
PyDoc_STRVAR(_multiprocessing_SemLock_acquire__doc__, |
| 123 |
"acquire($self, /, block=True, timeout=None)\n" |
| 124 |
"--\n" |
| 125 |
"\n" |
| 126 |
"Acquire the semaphore/lock."); |
| 127 |
|
| 128 |
#define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF \ |
| 129 |
{"acquire", _PyCFunction_CAST(_multiprocessing_SemLock_acquire), METH_FASTCALL|METH_KEYWORDS, _multiprocessing_SemLock_acquire__doc__}, |
| 130 |
|
| 131 |
static PyObject * |
| 132 |
_multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking, |
| 133 |
PyObject *timeout_obj); |
| 134 |
|
| 135 |
static PyObject * |
| 136 |
_multiprocessing_SemLock_acquire(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 137 |
{ |
| 138 |
PyObject *return_value = NULL; |
| 139 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 140 |
|
| 141 |
#define NUM_KEYWORDS 2 |
| 142 |
static struct { |
| 143 |
PyGC_Head _this_is_not_used; |
| 144 |
PyObject_VAR_HEAD |
| 145 |
Py_hash_t ob_hash; |
| 146 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 147 |
} _kwtuple = { |
| 148 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 149 |
.ob_hash = -1, |
| 150 |
.ob_item = { &_Py_ID(block), &_Py_ID(timeout), }, |
| 151 |
}; |
| 152 |
#undef NUM_KEYWORDS |
| 153 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 154 |
|
| 155 |
#else // !Py_BUILD_CORE |
| 156 |
# define KWTUPLE NULL |
| 157 |
#endif // !Py_BUILD_CORE |
| 158 |
|
| 159 |
static const char * const _keywords[] = {"block", "timeout", NULL}; |
| 160 |
static _PyArg_Parser _parser = { |
| 161 |
.keywords = _keywords, |
| 162 |
.fname = "acquire", |
| 163 |
.kwtuple = KWTUPLE, |
| 164 |
}; |
| 165 |
#undef KWTUPLE |
| 166 |
PyObject *argsbuf[2]; |
| 167 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 168 |
int blocking = 1; |
| 169 |
PyObject *timeout_obj = Py_None; |
| 170 |
|
| 171 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 172 |
/*minpos*/ 0, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 173 |
if (!args) { |
| 174 |
goto exit; |
| 175 |
} |
| 176 |
if (!noptargs) { |
| 177 |
goto skip_optional_pos; |
| 178 |
} |
| 179 |
if (args[0]) { |
| 180 |
blocking = PyObject_IsTrue(args[0]); |
| 181 |
if (blocking < 0) { |
| 182 |
goto exit; |
| 183 |
} |
| 184 |
if (!--noptargs) { |
| 185 |
goto skip_optional_pos; |
| 186 |
} |
| 187 |
} |
| 188 |
timeout_obj = args[1]; |
| 189 |
skip_optional_pos: |
| 190 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 191 |
return_value = _multiprocessing_SemLock_acquire_impl((SemLockObject *)self, blocking, timeout_obj); |
| 192 |
Py_END_CRITICAL_SECTION(); |
| 193 |
|
| 194 |
exit: |
| 195 |
return return_value; |
| 196 |
} |
| 197 |
|
| 198 |
#endif /* defined(HAVE_MP_SEMAPHORE) && !defined(MS_WINDOWS) */ |
| 199 |
|
| 200 |
#if defined(HAVE_MP_SEMAPHORE) && !defined(MS_WINDOWS) |
| 201 |
|
| 202 |
PyDoc_STRVAR(_multiprocessing_SemLock_release__doc__, |
| 203 |
"release($self, /)\n" |
| 204 |
"--\n" |
| 205 |
"\n" |
| 206 |
"Release the semaphore/lock."); |
| 207 |
|
| 208 |
#define _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF \ |
| 209 |
{"release", (PyCFunction)_multiprocessing_SemLock_release, METH_NOARGS, _multiprocessing_SemLock_release__doc__}, |
| 210 |
|
| 211 |
static PyObject * |
| 212 |
_multiprocessing_SemLock_release_impl(SemLockObject *self); |
| 213 |
|
| 214 |
static PyObject * |
| 215 |
_multiprocessing_SemLock_release(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 216 |
{ |
| 217 |
PyObject *return_value = NULL; |
| 218 |
|
| 219 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 220 |
return_value = _multiprocessing_SemLock_release_impl((SemLockObject *)self); |
| 221 |
Py_END_CRITICAL_SECTION(); |
| 222 |
|
| 223 |
return return_value; |
| 224 |
} |
| 225 |
|
| 226 |
#endif /* defined(HAVE_MP_SEMAPHORE) && !defined(MS_WINDOWS) */ |
| 227 |
|
| 228 |
#if defined(HAVE_MP_SEMAPHORE) |
| 229 |
|
| 230 |
static PyObject * |
| 231 |
_multiprocessing_SemLock_impl(PyTypeObject *type, int kind, int value, |
| 232 |
int maxvalue, const char *name, int unlink); |
| 233 |
|
| 234 |
static PyObject * |
| 235 |
_multiprocessing_SemLock(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 236 |
{ |
| 237 |
PyObject *return_value = NULL; |
| 238 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 239 |
|
| 240 |
#define NUM_KEYWORDS 5 |
| 241 |
static struct { |
| 242 |
PyGC_Head _this_is_not_used; |
| 243 |
PyObject_VAR_HEAD |
| 244 |
Py_hash_t ob_hash; |
| 245 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 246 |
} _kwtuple = { |
| 247 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 248 |
.ob_hash = -1, |
| 249 |
.ob_item = { &_Py_ID(kind), &_Py_ID(value), &_Py_ID(maxvalue), &_Py_ID(name), &_Py_ID(unlink), }, |
| 250 |
}; |
| 251 |
#undef NUM_KEYWORDS |
| 252 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 253 |
|
| 254 |
#else // !Py_BUILD_CORE |
| 255 |
# define KWTUPLE NULL |
| 256 |
#endif // !Py_BUILD_CORE |
| 257 |
|
| 258 |
static const char * const _keywords[] = {"kind", "value", "maxvalue", "name", "unlink", NULL}; |
| 259 |
static _PyArg_Parser _parser = { |
| 260 |
.keywords = _keywords, |
| 261 |
.fname = "SemLock", |
| 262 |
.kwtuple = KWTUPLE, |
| 263 |
}; |
| 264 |
#undef KWTUPLE |
| 265 |
PyObject *argsbuf[5]; |
| 266 |
PyObject * const *fastargs; |
| 267 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 268 |
int kind; |
| 269 |
int value; |
| 270 |
int maxvalue; |
| 271 |
const char *name; |
| 272 |
int unlink; |
| 273 |
|
| 274 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 275 |
/*minpos*/ 5, /*maxpos*/ 5, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 276 |
if (!fastargs) { |
| 277 |
goto exit; |
| 278 |
} |
| 279 |
kind = PyLong_AsInt(fastargs[0]); |
| 280 |
if (kind == -1 && PyErr_Occurred()) { |
| 281 |
goto exit; |
| 282 |
} |
| 283 |
value = PyLong_AsInt(fastargs[1]); |
| 284 |
if (value == -1 && PyErr_Occurred()) { |
| 285 |
goto exit; |
| 286 |
} |
| 287 |
maxvalue = PyLong_AsInt(fastargs[2]); |
| 288 |
if (maxvalue == -1 && PyErr_Occurred()) { |
| 289 |
goto exit; |
| 290 |
} |
| 291 |
if (!PyUnicode_Check(fastargs[3])) { |
| 292 |
_PyArg_BadArgument("SemLock", "argument 'name'", "str", fastargs[3]); |
| 293 |
goto exit; |
| 294 |
} |
| 295 |
Py_ssize_t name_length; |
| 296 |
name = PyUnicode_AsUTF8AndSize(fastargs[3], &name_length); |
| 297 |
if (name == NULL) { |
| 298 |
goto exit; |
| 299 |
} |
| 300 |
if (strlen(name) != (size_t)name_length) { |
| 301 |
PyErr_SetString(PyExc_ValueError, "embedded null character"); |
| 302 |
goto exit; |
| 303 |
} |
| 304 |
unlink = PyObject_IsTrue(fastargs[4]); |
| 305 |
if (unlink < 0) { |
| 306 |
goto exit; |
| 307 |
} |
| 308 |
return_value = _multiprocessing_SemLock_impl(type, kind, value, maxvalue, name, unlink); |
| 309 |
|
| 310 |
exit: |
| 311 |
return return_value; |
| 312 |
} |
| 313 |
|
| 314 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 315 |
|
| 316 |
#if defined(HAVE_MP_SEMAPHORE) |
| 317 |
|
| 318 |
PyDoc_STRVAR(_multiprocessing_SemLock__rebuild__doc__, |
| 319 |
"_rebuild($type, handle, kind, maxvalue, name, /)\n" |
| 320 |
"--\n" |
| 321 |
"\n"); |
| 322 |
|
| 323 |
#define _MULTIPROCESSING_SEMLOCK__REBUILD_METHODDEF \ |
| 324 |
{"_rebuild", _PyCFunction_CAST(_multiprocessing_SemLock__rebuild), METH_FASTCALL|METH_CLASS, _multiprocessing_SemLock__rebuild__doc__}, |
| 325 |
|
| 326 |
static PyObject * |
| 327 |
_multiprocessing_SemLock__rebuild_impl(PyTypeObject *type, SEM_HANDLE handle, |
| 328 |
int kind, int maxvalue, |
| 329 |
const char *name); |
| 330 |
|
| 331 |
static PyObject * |
| 332 |
_multiprocessing_SemLock__rebuild(PyObject *type, PyObject *const *args, Py_ssize_t nargs) |
| 333 |
{ |
| 334 |
PyObject *return_value = NULL; |
| 335 |
SEM_HANDLE handle; |
| 336 |
int kind; |
| 337 |
int maxvalue; |
| 338 |
const char *name; |
| 339 |
|
| 340 |
if (!_PyArg_ParseStack(args, nargs, ""F_SEM_HANDLE"iiz:_rebuild", |
| 341 |
&handle, &kind, &maxvalue, &name)) { |
| 342 |
goto exit; |
| 343 |
} |
| 344 |
return_value = _multiprocessing_SemLock__rebuild_impl((PyTypeObject *)type, handle, kind, maxvalue, name); |
| 345 |
|
| 346 |
exit: |
| 347 |
return return_value; |
| 348 |
} |
| 349 |
|
| 350 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 351 |
|
| 352 |
#if defined(HAVE_MP_SEMAPHORE) |
| 353 |
|
| 354 |
PyDoc_STRVAR(_multiprocessing_SemLock__count__doc__, |
| 355 |
"_count($self, /)\n" |
| 356 |
"--\n" |
| 357 |
"\n" |
| 358 |
"Num of `acquire()`s minus num of `release()`s for this process."); |
| 359 |
|
| 360 |
#define _MULTIPROCESSING_SEMLOCK__COUNT_METHODDEF \ |
| 361 |
{"_count", (PyCFunction)_multiprocessing_SemLock__count, METH_NOARGS, _multiprocessing_SemLock__count__doc__}, |
| 362 |
|
| 363 |
static PyObject * |
| 364 |
_multiprocessing_SemLock__count_impl(SemLockObject *self); |
| 365 |
|
| 366 |
static PyObject * |
| 367 |
_multiprocessing_SemLock__count(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 368 |
{ |
| 369 |
PyObject *return_value = NULL; |
| 370 |
|
| 371 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 372 |
return_value = _multiprocessing_SemLock__count_impl((SemLockObject *)self); |
| 373 |
Py_END_CRITICAL_SECTION(); |
| 374 |
|
| 375 |
return return_value; |
| 376 |
} |
| 377 |
|
| 378 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 379 |
|
| 380 |
#if defined(HAVE_MP_SEMAPHORE) |
| 381 |
|
| 382 |
PyDoc_STRVAR(_multiprocessing_SemLock__is_mine__doc__, |
| 383 |
"_is_mine($self, /)\n" |
| 384 |
"--\n" |
| 385 |
"\n" |
| 386 |
"Whether the lock is owned by this thread."); |
| 387 |
|
| 388 |
#define _MULTIPROCESSING_SEMLOCK__IS_MINE_METHODDEF \ |
| 389 |
{"_is_mine", (PyCFunction)_multiprocessing_SemLock__is_mine, METH_NOARGS, _multiprocessing_SemLock__is_mine__doc__}, |
| 390 |
|
| 391 |
static PyObject * |
| 392 |
_multiprocessing_SemLock__is_mine_impl(SemLockObject *self); |
| 393 |
|
| 394 |
static PyObject * |
| 395 |
_multiprocessing_SemLock__is_mine(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 396 |
{ |
| 397 |
return _multiprocessing_SemLock__is_mine_impl((SemLockObject *)self); |
| 398 |
} |
| 399 |
|
| 400 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 401 |
|
| 402 |
#if defined(HAVE_MP_SEMAPHORE) |
| 403 |
|
| 404 |
PyDoc_STRVAR(_multiprocessing_SemLock__get_value__doc__, |
| 405 |
"_get_value($self, /)\n" |
| 406 |
"--\n" |
| 407 |
"\n" |
| 408 |
"Get the value of the semaphore."); |
| 409 |
|
| 410 |
#define _MULTIPROCESSING_SEMLOCK__GET_VALUE_METHODDEF \ |
| 411 |
{"_get_value", (PyCFunction)_multiprocessing_SemLock__get_value, METH_NOARGS, _multiprocessing_SemLock__get_value__doc__}, |
| 412 |
|
| 413 |
static PyObject * |
| 414 |
_multiprocessing_SemLock__get_value_impl(SemLockObject *self); |
| 415 |
|
| 416 |
static PyObject * |
| 417 |
_multiprocessing_SemLock__get_value(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 418 |
{ |
| 419 |
return _multiprocessing_SemLock__get_value_impl((SemLockObject *)self); |
| 420 |
} |
| 421 |
|
| 422 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 423 |
|
| 424 |
#if defined(HAVE_MP_SEMAPHORE) |
| 425 |
|
| 426 |
PyDoc_STRVAR(_multiprocessing_SemLock__is_zero__doc__, |
| 427 |
"_is_zero($self, /)\n" |
| 428 |
"--\n" |
| 429 |
"\n" |
| 430 |
"Return whether semaphore has value zero."); |
| 431 |
|
| 432 |
#define _MULTIPROCESSING_SEMLOCK__IS_ZERO_METHODDEF \ |
| 433 |
{"_is_zero", (PyCFunction)_multiprocessing_SemLock__is_zero, METH_NOARGS, _multiprocessing_SemLock__is_zero__doc__}, |
| 434 |
|
| 435 |
static PyObject * |
| 436 |
_multiprocessing_SemLock__is_zero_impl(SemLockObject *self); |
| 437 |
|
| 438 |
static PyObject * |
| 439 |
_multiprocessing_SemLock__is_zero(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 440 |
{ |
| 441 |
return _multiprocessing_SemLock__is_zero_impl((SemLockObject *)self); |
| 442 |
} |
| 443 |
|
| 444 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 445 |
|
| 446 |
#if defined(HAVE_MP_SEMAPHORE) |
| 447 |
|
| 448 |
PyDoc_STRVAR(_multiprocessing_SemLock__after_fork__doc__, |
| 449 |
"_after_fork($self, /)\n" |
| 450 |
"--\n" |
| 451 |
"\n" |
| 452 |
"Rezero the net acquisition count after fork()."); |
| 453 |
|
| 454 |
#define _MULTIPROCESSING_SEMLOCK__AFTER_FORK_METHODDEF \ |
| 455 |
{"_after_fork", (PyCFunction)_multiprocessing_SemLock__after_fork, METH_NOARGS, _multiprocessing_SemLock__after_fork__doc__}, |
| 456 |
|
| 457 |
static PyObject * |
| 458 |
_multiprocessing_SemLock__after_fork_impl(SemLockObject *self); |
| 459 |
|
| 460 |
static PyObject * |
| 461 |
_multiprocessing_SemLock__after_fork(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 462 |
{ |
| 463 |
return _multiprocessing_SemLock__after_fork_impl((SemLockObject *)self); |
| 464 |
} |
| 465 |
|
| 466 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 467 |
|
| 468 |
#if defined(HAVE_MP_SEMAPHORE) |
| 469 |
|
| 470 |
PyDoc_STRVAR(_multiprocessing_SemLock___enter____doc__, |
| 471 |
"__enter__($self, /)\n" |
| 472 |
"--\n" |
| 473 |
"\n" |
| 474 |
"Enter the semaphore/lock."); |
| 475 |
|
| 476 |
#define _MULTIPROCESSING_SEMLOCK___ENTER___METHODDEF \ |
| 477 |
{"__enter__", (PyCFunction)_multiprocessing_SemLock___enter__, METH_NOARGS, _multiprocessing_SemLock___enter____doc__}, |
| 478 |
|
| 479 |
static PyObject * |
| 480 |
_multiprocessing_SemLock___enter___impl(SemLockObject *self); |
| 481 |
|
| 482 |
static PyObject * |
| 483 |
_multiprocessing_SemLock___enter__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 484 |
{ |
| 485 |
PyObject *return_value = NULL; |
| 486 |
|
| 487 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 488 |
return_value = _multiprocessing_SemLock___enter___impl((SemLockObject *)self); |
| 489 |
Py_END_CRITICAL_SECTION(); |
| 490 |
|
| 491 |
return return_value; |
| 492 |
} |
| 493 |
|
| 494 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 495 |
|
| 496 |
#if defined(HAVE_MP_SEMAPHORE) |
| 497 |
|
| 498 |
PyDoc_STRVAR(_multiprocessing_SemLock___exit____doc__, |
| 499 |
"__exit__($self, exc_type=None, exc_value=None, exc_tb=None, /)\n" |
| 500 |
"--\n" |
| 501 |
"\n" |
| 502 |
"Exit the semaphore/lock."); |
| 503 |
|
| 504 |
#define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF \ |
| 505 |
{"__exit__", _PyCFunction_CAST(_multiprocessing_SemLock___exit__), METH_FASTCALL, _multiprocessing_SemLock___exit____doc__}, |
| 506 |
|
| 507 |
static PyObject * |
| 508 |
_multiprocessing_SemLock___exit___impl(SemLockObject *self, |
| 509 |
PyObject *exc_type, |
| 510 |
PyObject *exc_value, PyObject *exc_tb); |
| 511 |
|
| 512 |
static PyObject * |
| 513 |
_multiprocessing_SemLock___exit__(PyObject *self, PyObject *const *args, Py_ssize_t nargs) |
| 514 |
{ |
| 515 |
PyObject *return_value = NULL; |
| 516 |
PyObject *exc_type = Py_None; |
| 517 |
PyObject *exc_value = Py_None; |
| 518 |
PyObject *exc_tb = Py_None; |
| 519 |
|
| 520 |
if (!_PyArg_CheckPositional("__exit__", nargs, 0, 3)) { |
| 521 |
goto exit; |
| 522 |
} |
| 523 |
if (nargs < 1) { |
| 524 |
goto skip_optional; |
| 525 |
} |
| 526 |
exc_type = args[0]; |
| 527 |
if (nargs < 2) { |
| 528 |
goto skip_optional; |
| 529 |
} |
| 530 |
exc_value = args[1]; |
| 531 |
if (nargs < 3) { |
| 532 |
goto skip_optional; |
| 533 |
} |
| 534 |
exc_tb = args[2]; |
| 535 |
skip_optional: |
| 536 |
Py_BEGIN_CRITICAL_SECTION(self); |
| 537 |
return_value = _multiprocessing_SemLock___exit___impl((SemLockObject *)self, exc_type, exc_value, exc_tb); |
| 538 |
Py_END_CRITICAL_SECTION(); |
| 539 |
|
| 540 |
exit: |
| 541 |
return return_value; |
| 542 |
} |
| 543 |
|
| 544 |
#endif /* defined(HAVE_MP_SEMAPHORE) */ |
| 545 |
|
| 546 |
#ifndef _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF |
| 547 |
#define _MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF |
| 548 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK_ACQUIRE_METHODDEF) */ |
| 549 |
|
| 550 |
#ifndef _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF |
| 551 |
#define _MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF |
| 552 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK_RELEASE_METHODDEF) */ |
| 553 |
|
| 554 |
#ifndef _MULTIPROCESSING_SEMLOCK__REBUILD_METHODDEF |
| 555 |
#define _MULTIPROCESSING_SEMLOCK__REBUILD_METHODDEF |
| 556 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK__REBUILD_METHODDEF) */ |
| 557 |
|
| 558 |
#ifndef _MULTIPROCESSING_SEMLOCK__COUNT_METHODDEF |
| 559 |
#define _MULTIPROCESSING_SEMLOCK__COUNT_METHODDEF |
| 560 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK__COUNT_METHODDEF) */ |
| 561 |
|
| 562 |
#ifndef _MULTIPROCESSING_SEMLOCK__IS_MINE_METHODDEF |
| 563 |
#define _MULTIPROCESSING_SEMLOCK__IS_MINE_METHODDEF |
| 564 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK__IS_MINE_METHODDEF) */ |
| 565 |
|
| 566 |
#ifndef _MULTIPROCESSING_SEMLOCK__GET_VALUE_METHODDEF |
| 567 |
#define _MULTIPROCESSING_SEMLOCK__GET_VALUE_METHODDEF |
| 568 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK__GET_VALUE_METHODDEF) */ |
| 569 |
|
| 570 |
#ifndef _MULTIPROCESSING_SEMLOCK__IS_ZERO_METHODDEF |
| 571 |
#define _MULTIPROCESSING_SEMLOCK__IS_ZERO_METHODDEF |
| 572 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK__IS_ZERO_METHODDEF) */ |
| 573 |
|
| 574 |
#ifndef _MULTIPROCESSING_SEMLOCK__AFTER_FORK_METHODDEF |
| 575 |
#define _MULTIPROCESSING_SEMLOCK__AFTER_FORK_METHODDEF |
| 576 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK__AFTER_FORK_METHODDEF) */ |
| 577 |
|
| 578 |
#ifndef _MULTIPROCESSING_SEMLOCK___ENTER___METHODDEF |
| 579 |
#define _MULTIPROCESSING_SEMLOCK___ENTER___METHODDEF |
| 580 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK___ENTER___METHODDEF) */ |
| 581 |
|
| 582 |
#ifndef _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF |
| 583 |
#define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF |
| 584 |
#endif /* !defined(_MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF) */ |
| 585 |
/*[clinic end generated code: output=d1e349d4ee3d4bbf input=a9049054013a1b77]*/ |