| 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_abstract.h" // _PyNumber_Index() |
| 10 |
#include "pycore_long.h" // _PyLong_UnsignedInt_Converter() |
| 11 |
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords() |
| 12 |
|
| 13 |
PyDoc_STRVAR(os_stat__doc__, |
| 14 |
"stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n" |
| 15 |
"--\n" |
| 16 |
"\n" |
| 17 |
"Perform a stat system call on the given path.\n" |
| 18 |
"\n" |
| 19 |
" path\n" |
| 20 |
" Path to be examined; can be string, bytes, a path-like object or\n" |
| 21 |
" open-file-descriptor int.\n" |
| 22 |
" dir_fd\n" |
| 23 |
" If not None, it should be a file descriptor open to a directory,\n" |
| 24 |
" and path should be a relative string; path will then be relative to\n" |
| 25 |
" that directory.\n" |
| 26 |
" follow_symlinks\n" |
| 27 |
" If False, and the last element of the path is a symbolic link,\n" |
| 28 |
" stat will examine the symbolic link itself instead of the file\n" |
| 29 |
" the link points to.\n" |
| 30 |
"\n" |
| 31 |
"dir_fd and follow_symlinks may not be implemented\n" |
| 32 |
" on your platform. If they are unavailable, using them will raise a\n" |
| 33 |
" NotImplementedError.\n" |
| 34 |
"\n" |
| 35 |
"It\'s an error to use dir_fd or follow_symlinks when specifying path as\n" |
| 36 |
" an open file descriptor."); |
| 37 |
|
| 38 |
#define OS_STAT_METHODDEF \ |
| 39 |
{"stat", _PyCFunction_CAST(os_stat), METH_FASTCALL|METH_KEYWORDS, os_stat__doc__}, |
| 40 |
|
| 41 |
static PyObject * |
| 42 |
os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks); |
| 43 |
|
| 44 |
static PyObject * |
| 45 |
os_stat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 46 |
{ |
| 47 |
PyObject *return_value = NULL; |
| 48 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 49 |
|
| 50 |
#define NUM_KEYWORDS 3 |
| 51 |
static struct { |
| 52 |
PyGC_Head _this_is_not_used; |
| 53 |
PyObject_VAR_HEAD |
| 54 |
Py_hash_t ob_hash; |
| 55 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 56 |
} _kwtuple = { |
| 57 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 58 |
.ob_hash = -1, |
| 59 |
.ob_item = { &_Py_ID(path), &_Py_ID(dir_fd), &_Py_ID(follow_symlinks), }, |
| 60 |
}; |
| 61 |
#undef NUM_KEYWORDS |
| 62 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 63 |
|
| 64 |
#else // !Py_BUILD_CORE |
| 65 |
# define KWTUPLE NULL |
| 66 |
#endif // !Py_BUILD_CORE |
| 67 |
|
| 68 |
static const char * const _keywords[] = {"path", "dir_fd", "follow_symlinks", NULL}; |
| 69 |
static _PyArg_Parser _parser = { |
| 70 |
.keywords = _keywords, |
| 71 |
.fname = "stat", |
| 72 |
.kwtuple = KWTUPLE, |
| 73 |
}; |
| 74 |
#undef KWTUPLE |
| 75 |
PyObject *argsbuf[3]; |
| 76 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 77 |
path_t path = PATH_T_INITIALIZE_P("stat", "path", 0, 0, 0, 1); |
| 78 |
int dir_fd = DEFAULT_DIR_FD; |
| 79 |
int follow_symlinks = 1; |
| 80 |
|
| 81 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 82 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 83 |
if (!args) { |
| 84 |
goto exit; |
| 85 |
} |
| 86 |
if (!path_converter(args[0], &path)) { |
| 87 |
goto exit; |
| 88 |
} |
| 89 |
if (!noptargs) { |
| 90 |
goto skip_optional_kwonly; |
| 91 |
} |
| 92 |
if (args[1]) { |
| 93 |
if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { |
| 94 |
goto exit; |
| 95 |
} |
| 96 |
if (!--noptargs) { |
| 97 |
goto skip_optional_kwonly; |
| 98 |
} |
| 99 |
} |
| 100 |
follow_symlinks = PyObject_IsTrue(args[2]); |
| 101 |
if (follow_symlinks < 0) { |
| 102 |
goto exit; |
| 103 |
} |
| 104 |
skip_optional_kwonly: |
| 105 |
return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); |
| 106 |
|
| 107 |
exit: |
| 108 |
/* Cleanup for path */ |
| 109 |
path_cleanup(&path); |
| 110 |
|
| 111 |
return return_value; |
| 112 |
} |
| 113 |
|
| 114 |
PyDoc_STRVAR(os_lstat__doc__, |
| 115 |
"lstat($module, /, path, *, dir_fd=None)\n" |
| 116 |
"--\n" |
| 117 |
"\n" |
| 118 |
"Perform a stat system call on the given path, without following symbolic links.\n" |
| 119 |
"\n" |
| 120 |
"Like stat(), but do not follow symbolic links.\n" |
| 121 |
"Equivalent to stat(path, follow_symlinks=False)."); |
| 122 |
|
| 123 |
#define OS_LSTAT_METHODDEF \ |
| 124 |
{"lstat", _PyCFunction_CAST(os_lstat), METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__}, |
| 125 |
|
| 126 |
static PyObject * |
| 127 |
os_lstat_impl(PyObject *module, path_t *path, int dir_fd); |
| 128 |
|
| 129 |
static PyObject * |
| 130 |
os_lstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 131 |
{ |
| 132 |
PyObject *return_value = NULL; |
| 133 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 134 |
|
| 135 |
#define NUM_KEYWORDS 2 |
| 136 |
static struct { |
| 137 |
PyGC_Head _this_is_not_used; |
| 138 |
PyObject_VAR_HEAD |
| 139 |
Py_hash_t ob_hash; |
| 140 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 141 |
} _kwtuple = { |
| 142 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 143 |
.ob_hash = -1, |
| 144 |
.ob_item = { &_Py_ID(path), &_Py_ID(dir_fd), }, |
| 145 |
}; |
| 146 |
#undef NUM_KEYWORDS |
| 147 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 148 |
|
| 149 |
#else // !Py_BUILD_CORE |
| 150 |
# define KWTUPLE NULL |
| 151 |
#endif // !Py_BUILD_CORE |
| 152 |
|
| 153 |
static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
| 154 |
static _PyArg_Parser _parser = { |
| 155 |
.keywords = _keywords, |
| 156 |
.fname = "lstat", |
| 157 |
.kwtuple = KWTUPLE, |
| 158 |
}; |
| 159 |
#undef KWTUPLE |
| 160 |
PyObject *argsbuf[2]; |
| 161 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 162 |
path_t path = PATH_T_INITIALIZE_P("lstat", "path", 0, 0, 0, 0); |
| 163 |
int dir_fd = DEFAULT_DIR_FD; |
| 164 |
|
| 165 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 166 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 167 |
if (!args) { |
| 168 |
goto exit; |
| 169 |
} |
| 170 |
if (!path_converter(args[0], &path)) { |
| 171 |
goto exit; |
| 172 |
} |
| 173 |
if (!noptargs) { |
| 174 |
goto skip_optional_kwonly; |
| 175 |
} |
| 176 |
if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { |
| 177 |
goto exit; |
| 178 |
} |
| 179 |
skip_optional_kwonly: |
| 180 |
return_value = os_lstat_impl(module, &path, dir_fd); |
| 181 |
|
| 182 |
exit: |
| 183 |
/* Cleanup for path */ |
| 184 |
path_cleanup(&path); |
| 185 |
|
| 186 |
return return_value; |
| 187 |
} |
| 188 |
|
| 189 |
PyDoc_STRVAR(os_access__doc__, |
| 190 |
"access($module, /, path, mode, *, dir_fd=None, effective_ids=False,\n" |
| 191 |
" follow_symlinks=True)\n" |
| 192 |
"--\n" |
| 193 |
"\n" |
| 194 |
"Use the real uid/gid to test for access to a path.\n" |
| 195 |
"\n" |
| 196 |
" path\n" |
| 197 |
" Path to be tested; can be string, bytes, or a path-like object.\n" |
| 198 |
" mode\n" |
| 199 |
" Operating-system mode bitfield. Can be F_OK to test existence,\n" |
| 200 |
" or the inclusive-OR of R_OK, W_OK, and X_OK.\n" |
| 201 |
" dir_fd\n" |
| 202 |
" If not None, it should be a file descriptor open to a directory,\n" |
| 203 |
" and path should be relative; path will then be relative to that\n" |
| 204 |
" directory.\n" |
| 205 |
" effective_ids\n" |
| 206 |
" If True, access will use the effective uid/gid instead of\n" |
| 207 |
" the real uid/gid.\n" |
| 208 |
" follow_symlinks\n" |
| 209 |
" If False, and the last element of the path is a symbolic link,\n" |
| 210 |
" access will examine the symbolic link itself instead of the file\n" |
| 211 |
" the link points to.\n" |
| 212 |
"\n" |
| 213 |
"dir_fd, effective_ids, and follow_symlinks may not be implemented\n" |
| 214 |
" on your platform. If they are unavailable, using them will raise a\n" |
| 215 |
" NotImplementedError.\n" |
| 216 |
"\n" |
| 217 |
"Note that most operations will use the effective uid/gid, therefore this\n" |
| 218 |
" routine can be used in a suid/sgid environment to test if the invoking user\n" |
| 219 |
" has the specified access to the path."); |
| 220 |
|
| 221 |
#define OS_ACCESS_METHODDEF \ |
| 222 |
{"access", _PyCFunction_CAST(os_access), METH_FASTCALL|METH_KEYWORDS, os_access__doc__}, |
| 223 |
|
| 224 |
static int |
| 225 |
os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, |
| 226 |
int effective_ids, int follow_symlinks); |
| 227 |
|
| 228 |
static PyObject * |
| 229 |
os_access(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 230 |
{ |
| 231 |
PyObject *return_value = NULL; |
| 232 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 233 |
|
| 234 |
#define NUM_KEYWORDS 5 |
| 235 |
static struct { |
| 236 |
PyGC_Head _this_is_not_used; |
| 237 |
PyObject_VAR_HEAD |
| 238 |
Py_hash_t ob_hash; |
| 239 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 240 |
} _kwtuple = { |
| 241 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 242 |
.ob_hash = -1, |
| 243 |
.ob_item = { &_Py_ID(path), &_Py_ID(mode), &_Py_ID(dir_fd), &_Py_ID(effective_ids), &_Py_ID(follow_symlinks), }, |
| 244 |
}; |
| 245 |
#undef NUM_KEYWORDS |
| 246 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 247 |
|
| 248 |
#else // !Py_BUILD_CORE |
| 249 |
# define KWTUPLE NULL |
| 250 |
#endif // !Py_BUILD_CORE |
| 251 |
|
| 252 |
static const char * const _keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; |
| 253 |
static _PyArg_Parser _parser = { |
| 254 |
.keywords = _keywords, |
| 255 |
.fname = "access", |
| 256 |
.kwtuple = KWTUPLE, |
| 257 |
}; |
| 258 |
#undef KWTUPLE |
| 259 |
PyObject *argsbuf[5]; |
| 260 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 261 |
path_t path = PATH_T_INITIALIZE_P("access", "path", 0, 0, 0, 0); |
| 262 |
int mode; |
| 263 |
int dir_fd = DEFAULT_DIR_FD; |
| 264 |
int effective_ids = 0; |
| 265 |
int follow_symlinks = 1; |
| 266 |
int _return_value; |
| 267 |
|
| 268 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 269 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 270 |
if (!args) { |
| 271 |
goto exit; |
| 272 |
} |
| 273 |
if (!path_converter(args[0], &path)) { |
| 274 |
goto exit; |
| 275 |
} |
| 276 |
mode = PyLong_AsInt(args[1]); |
| 277 |
if (mode == -1 && PyErr_Occurred()) { |
| 278 |
goto exit; |
| 279 |
} |
| 280 |
if (!noptargs) { |
| 281 |
goto skip_optional_kwonly; |
| 282 |
} |
| 283 |
if (args[2]) { |
| 284 |
if (!FACCESSAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { |
| 285 |
goto exit; |
| 286 |
} |
| 287 |
if (!--noptargs) { |
| 288 |
goto skip_optional_kwonly; |
| 289 |
} |
| 290 |
} |
| 291 |
if (args[3]) { |
| 292 |
effective_ids = PyObject_IsTrue(args[3]); |
| 293 |
if (effective_ids < 0) { |
| 294 |
goto exit; |
| 295 |
} |
| 296 |
if (!--noptargs) { |
| 297 |
goto skip_optional_kwonly; |
| 298 |
} |
| 299 |
} |
| 300 |
follow_symlinks = PyObject_IsTrue(args[4]); |
| 301 |
if (follow_symlinks < 0) { |
| 302 |
goto exit; |
| 303 |
} |
| 304 |
skip_optional_kwonly: |
| 305 |
_return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); |
| 306 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 307 |
goto exit; |
| 308 |
} |
| 309 |
return_value = PyBool_FromLong((long)_return_value); |
| 310 |
|
| 311 |
exit: |
| 312 |
/* Cleanup for path */ |
| 313 |
path_cleanup(&path); |
| 314 |
|
| 315 |
return return_value; |
| 316 |
} |
| 317 |
|
| 318 |
#if defined(HAVE_TTYNAME_R) |
| 319 |
|
| 320 |
PyDoc_STRVAR(os_ttyname__doc__, |
| 321 |
"ttyname($module, fd, /)\n" |
| 322 |
"--\n" |
| 323 |
"\n" |
| 324 |
"Return the name of the terminal device connected to \'fd\'.\n" |
| 325 |
"\n" |
| 326 |
" fd\n" |
| 327 |
" Integer file descriptor handle."); |
| 328 |
|
| 329 |
#define OS_TTYNAME_METHODDEF \ |
| 330 |
{"ttyname", (PyCFunction)os_ttyname, METH_O, os_ttyname__doc__}, |
| 331 |
|
| 332 |
static PyObject * |
| 333 |
os_ttyname_impl(PyObject *module, int fd); |
| 334 |
|
| 335 |
static PyObject * |
| 336 |
os_ttyname(PyObject *module, PyObject *arg) |
| 337 |
{ |
| 338 |
PyObject *return_value = NULL; |
| 339 |
int fd; |
| 340 |
|
| 341 |
fd = PyLong_AsInt(arg); |
| 342 |
if (fd == -1 && PyErr_Occurred()) { |
| 343 |
goto exit; |
| 344 |
} |
| 345 |
return_value = os_ttyname_impl(module, fd); |
| 346 |
|
| 347 |
exit: |
| 348 |
return return_value; |
| 349 |
} |
| 350 |
|
| 351 |
#endif /* defined(HAVE_TTYNAME_R) */ |
| 352 |
|
| 353 |
#if defined(HAVE_CTERMID) |
| 354 |
|
| 355 |
PyDoc_STRVAR(os_ctermid__doc__, |
| 356 |
"ctermid($module, /)\n" |
| 357 |
"--\n" |
| 358 |
"\n" |
| 359 |
"Return the name of the controlling terminal for this process."); |
| 360 |
|
| 361 |
#define OS_CTERMID_METHODDEF \ |
| 362 |
{"ctermid", (PyCFunction)os_ctermid, METH_NOARGS, os_ctermid__doc__}, |
| 363 |
|
| 364 |
static PyObject * |
| 365 |
os_ctermid_impl(PyObject *module); |
| 366 |
|
| 367 |
static PyObject * |
| 368 |
os_ctermid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 369 |
{ |
| 370 |
return os_ctermid_impl(module); |
| 371 |
} |
| 372 |
|
| 373 |
#endif /* defined(HAVE_CTERMID) */ |
| 374 |
|
| 375 |
PyDoc_STRVAR(os_chdir__doc__, |
| 376 |
"chdir($module, /, path)\n" |
| 377 |
"--\n" |
| 378 |
"\n" |
| 379 |
"Change the current working directory to the specified path.\n" |
| 380 |
"\n" |
| 381 |
"path may always be specified as a string.\n" |
| 382 |
"On some platforms, path may also be specified as an open file descriptor.\n" |
| 383 |
"If this functionality is unavailable, using it raises an exception."); |
| 384 |
|
| 385 |
#define OS_CHDIR_METHODDEF \ |
| 386 |
{"chdir", _PyCFunction_CAST(os_chdir), METH_FASTCALL|METH_KEYWORDS, os_chdir__doc__}, |
| 387 |
|
| 388 |
static PyObject * |
| 389 |
os_chdir_impl(PyObject *module, path_t *path); |
| 390 |
|
| 391 |
static PyObject * |
| 392 |
os_chdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 393 |
{ |
| 394 |
PyObject *return_value = NULL; |
| 395 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 396 |
|
| 397 |
#define NUM_KEYWORDS 1 |
| 398 |
static struct { |
| 399 |
PyGC_Head _this_is_not_used; |
| 400 |
PyObject_VAR_HEAD |
| 401 |
Py_hash_t ob_hash; |
| 402 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 403 |
} _kwtuple = { |
| 404 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 405 |
.ob_hash = -1, |
| 406 |
.ob_item = { &_Py_ID(path), }, |
| 407 |
}; |
| 408 |
#undef NUM_KEYWORDS |
| 409 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 410 |
|
| 411 |
#else // !Py_BUILD_CORE |
| 412 |
# define KWTUPLE NULL |
| 413 |
#endif // !Py_BUILD_CORE |
| 414 |
|
| 415 |
static const char * const _keywords[] = {"path", NULL}; |
| 416 |
static _PyArg_Parser _parser = { |
| 417 |
.keywords = _keywords, |
| 418 |
.fname = "chdir", |
| 419 |
.kwtuple = KWTUPLE, |
| 420 |
}; |
| 421 |
#undef KWTUPLE |
| 422 |
PyObject *argsbuf[1]; |
| 423 |
path_t path = PATH_T_INITIALIZE_P("chdir", "path", 0, 0, 0, PATH_HAVE_FCHDIR); |
| 424 |
|
| 425 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 426 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 427 |
if (!args) { |
| 428 |
goto exit; |
| 429 |
} |
| 430 |
if (!path_converter(args[0], &path)) { |
| 431 |
goto exit; |
| 432 |
} |
| 433 |
return_value = os_chdir_impl(module, &path); |
| 434 |
|
| 435 |
exit: |
| 436 |
/* Cleanup for path */ |
| 437 |
path_cleanup(&path); |
| 438 |
|
| 439 |
return return_value; |
| 440 |
} |
| 441 |
|
| 442 |
#if defined(HAVE_FCHDIR) |
| 443 |
|
| 444 |
PyDoc_STRVAR(os_fchdir__doc__, |
| 445 |
"fchdir($module, /, fd)\n" |
| 446 |
"--\n" |
| 447 |
"\n" |
| 448 |
"Change to the directory of the given file descriptor.\n" |
| 449 |
"\n" |
| 450 |
"fd must be opened on a directory, not a file.\n" |
| 451 |
"Equivalent to os.chdir(fd)."); |
| 452 |
|
| 453 |
#define OS_FCHDIR_METHODDEF \ |
| 454 |
{"fchdir", _PyCFunction_CAST(os_fchdir), METH_FASTCALL|METH_KEYWORDS, os_fchdir__doc__}, |
| 455 |
|
| 456 |
static PyObject * |
| 457 |
os_fchdir_impl(PyObject *module, int fd); |
| 458 |
|
| 459 |
static PyObject * |
| 460 |
os_fchdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 461 |
{ |
| 462 |
PyObject *return_value = NULL; |
| 463 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 464 |
|
| 465 |
#define NUM_KEYWORDS 1 |
| 466 |
static struct { |
| 467 |
PyGC_Head _this_is_not_used; |
| 468 |
PyObject_VAR_HEAD |
| 469 |
Py_hash_t ob_hash; |
| 470 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 471 |
} _kwtuple = { |
| 472 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 473 |
.ob_hash = -1, |
| 474 |
.ob_item = { &_Py_ID(fd), }, |
| 475 |
}; |
| 476 |
#undef NUM_KEYWORDS |
| 477 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 478 |
|
| 479 |
#else // !Py_BUILD_CORE |
| 480 |
# define KWTUPLE NULL |
| 481 |
#endif // !Py_BUILD_CORE |
| 482 |
|
| 483 |
static const char * const _keywords[] = {"fd", NULL}; |
| 484 |
static _PyArg_Parser _parser = { |
| 485 |
.keywords = _keywords, |
| 486 |
.fname = "fchdir", |
| 487 |
.kwtuple = KWTUPLE, |
| 488 |
}; |
| 489 |
#undef KWTUPLE |
| 490 |
PyObject *argsbuf[1]; |
| 491 |
int fd; |
| 492 |
|
| 493 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 494 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 495 |
if (!args) { |
| 496 |
goto exit; |
| 497 |
} |
| 498 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 499 |
if (fd < 0) { |
| 500 |
goto exit; |
| 501 |
} |
| 502 |
return_value = os_fchdir_impl(module, fd); |
| 503 |
|
| 504 |
exit: |
| 505 |
return return_value; |
| 506 |
} |
| 507 |
|
| 508 |
#endif /* defined(HAVE_FCHDIR) */ |
| 509 |
|
| 510 |
PyDoc_STRVAR(os_chmod__doc__, |
| 511 |
"chmod($module, /, path, mode, *, dir_fd=None,\n" |
| 512 |
" follow_symlinks=(os.name != \'nt\'))\n" |
| 513 |
"--\n" |
| 514 |
"\n" |
| 515 |
"Change the access permissions of a file.\n" |
| 516 |
"\n" |
| 517 |
" path\n" |
| 518 |
" Path to be modified. May always be specified as a str, bytes, or a path-like object.\n" |
| 519 |
" On some platforms, path may also be specified as an open file descriptor.\n" |
| 520 |
" If this functionality is unavailable, using it raises an exception.\n" |
| 521 |
" mode\n" |
| 522 |
" Operating-system mode bitfield.\n" |
| 523 |
" Be careful when using number literals for *mode*. The conventional UNIX notation for\n" |
| 524 |
" numeric modes uses an octal base, which needs to be indicated with a ``0o`` prefix in\n" |
| 525 |
" Python.\n" |
| 526 |
" dir_fd\n" |
| 527 |
" If not None, it should be a file descriptor open to a directory,\n" |
| 528 |
" and path should be relative; path will then be relative to that\n" |
| 529 |
" directory.\n" |
| 530 |
" follow_symlinks\n" |
| 531 |
" If False, and the last element of the path is a symbolic link,\n" |
| 532 |
" chmod will modify the symbolic link itself instead of the file\n" |
| 533 |
" the link points to.\n" |
| 534 |
"\n" |
| 535 |
"It is an error to use dir_fd or follow_symlinks when specifying path as\n" |
| 536 |
" an open file descriptor.\n" |
| 537 |
"dir_fd and follow_symlinks may not be implemented on your platform.\n" |
| 538 |
" If they are unavailable, using them will raise a NotImplementedError."); |
| 539 |
|
| 540 |
#define OS_CHMOD_METHODDEF \ |
| 541 |
{"chmod", _PyCFunction_CAST(os_chmod), METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__}, |
| 542 |
|
| 543 |
static PyObject * |
| 544 |
os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd, |
| 545 |
int follow_symlinks); |
| 546 |
|
| 547 |
static PyObject * |
| 548 |
os_chmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 549 |
{ |
| 550 |
PyObject *return_value = NULL; |
| 551 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 552 |
|
| 553 |
#define NUM_KEYWORDS 4 |
| 554 |
static struct { |
| 555 |
PyGC_Head _this_is_not_used; |
| 556 |
PyObject_VAR_HEAD |
| 557 |
Py_hash_t ob_hash; |
| 558 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 559 |
} _kwtuple = { |
| 560 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 561 |
.ob_hash = -1, |
| 562 |
.ob_item = { &_Py_ID(path), &_Py_ID(mode), &_Py_ID(dir_fd), &_Py_ID(follow_symlinks), }, |
| 563 |
}; |
| 564 |
#undef NUM_KEYWORDS |
| 565 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 566 |
|
| 567 |
#else // !Py_BUILD_CORE |
| 568 |
# define KWTUPLE NULL |
| 569 |
#endif // !Py_BUILD_CORE |
| 570 |
|
| 571 |
static const char * const _keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; |
| 572 |
static _PyArg_Parser _parser = { |
| 573 |
.keywords = _keywords, |
| 574 |
.fname = "chmod", |
| 575 |
.kwtuple = KWTUPLE, |
| 576 |
}; |
| 577 |
#undef KWTUPLE |
| 578 |
PyObject *argsbuf[4]; |
| 579 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 580 |
path_t path = PATH_T_INITIALIZE_P("chmod", "path", 0, 0, 0, PATH_HAVE_FCHMOD); |
| 581 |
int mode; |
| 582 |
int dir_fd = DEFAULT_DIR_FD; |
| 583 |
int follow_symlinks = CHMOD_DEFAULT_FOLLOW_SYMLINKS; |
| 584 |
|
| 585 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 586 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 587 |
if (!args) { |
| 588 |
goto exit; |
| 589 |
} |
| 590 |
if (!path_converter(args[0], &path)) { |
| 591 |
goto exit; |
| 592 |
} |
| 593 |
mode = PyLong_AsInt(args[1]); |
| 594 |
if (mode == -1 && PyErr_Occurred()) { |
| 595 |
goto exit; |
| 596 |
} |
| 597 |
if (!noptargs) { |
| 598 |
goto skip_optional_kwonly; |
| 599 |
} |
| 600 |
if (args[2]) { |
| 601 |
if (!FCHMODAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { |
| 602 |
goto exit; |
| 603 |
} |
| 604 |
if (!--noptargs) { |
| 605 |
goto skip_optional_kwonly; |
| 606 |
} |
| 607 |
} |
| 608 |
follow_symlinks = PyObject_IsTrue(args[3]); |
| 609 |
if (follow_symlinks < 0) { |
| 610 |
goto exit; |
| 611 |
} |
| 612 |
skip_optional_kwonly: |
| 613 |
return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); |
| 614 |
|
| 615 |
exit: |
| 616 |
/* Cleanup for path */ |
| 617 |
path_cleanup(&path); |
| 618 |
|
| 619 |
return return_value; |
| 620 |
} |
| 621 |
|
| 622 |
#if (defined(HAVE_FCHMOD) || defined(MS_WINDOWS)) |
| 623 |
|
| 624 |
PyDoc_STRVAR(os_fchmod__doc__, |
| 625 |
"fchmod($module, /, fd, mode)\n" |
| 626 |
"--\n" |
| 627 |
"\n" |
| 628 |
"Change the access permissions of the file given by file descriptor fd.\n" |
| 629 |
"\n" |
| 630 |
" fd\n" |
| 631 |
" The file descriptor of the file to be modified.\n" |
| 632 |
" mode\n" |
| 633 |
" Operating-system mode bitfield.\n" |
| 634 |
" Be careful when using number literals for *mode*. The conventional UNIX notation for\n" |
| 635 |
" numeric modes uses an octal base, which needs to be indicated with a ``0o`` prefix in\n" |
| 636 |
" Python.\n" |
| 637 |
"\n" |
| 638 |
"Equivalent to os.chmod(fd, mode)."); |
| 639 |
|
| 640 |
#define OS_FCHMOD_METHODDEF \ |
| 641 |
{"fchmod", _PyCFunction_CAST(os_fchmod), METH_FASTCALL|METH_KEYWORDS, os_fchmod__doc__}, |
| 642 |
|
| 643 |
static PyObject * |
| 644 |
os_fchmod_impl(PyObject *module, int fd, int mode); |
| 645 |
|
| 646 |
static PyObject * |
| 647 |
os_fchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 648 |
{ |
| 649 |
PyObject *return_value = NULL; |
| 650 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 651 |
|
| 652 |
#define NUM_KEYWORDS 2 |
| 653 |
static struct { |
| 654 |
PyGC_Head _this_is_not_used; |
| 655 |
PyObject_VAR_HEAD |
| 656 |
Py_hash_t ob_hash; |
| 657 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 658 |
} _kwtuple = { |
| 659 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 660 |
.ob_hash = -1, |
| 661 |
.ob_item = { &_Py_ID(fd), &_Py_ID(mode), }, |
| 662 |
}; |
| 663 |
#undef NUM_KEYWORDS |
| 664 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 665 |
|
| 666 |
#else // !Py_BUILD_CORE |
| 667 |
# define KWTUPLE NULL |
| 668 |
#endif // !Py_BUILD_CORE |
| 669 |
|
| 670 |
static const char * const _keywords[] = {"fd", "mode", NULL}; |
| 671 |
static _PyArg_Parser _parser = { |
| 672 |
.keywords = _keywords, |
| 673 |
.fname = "fchmod", |
| 674 |
.kwtuple = KWTUPLE, |
| 675 |
}; |
| 676 |
#undef KWTUPLE |
| 677 |
PyObject *argsbuf[2]; |
| 678 |
int fd; |
| 679 |
int mode; |
| 680 |
|
| 681 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 682 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 683 |
if (!args) { |
| 684 |
goto exit; |
| 685 |
} |
| 686 |
fd = PyLong_AsInt(args[0]); |
| 687 |
if (fd == -1 && PyErr_Occurred()) { |
| 688 |
goto exit; |
| 689 |
} |
| 690 |
mode = PyLong_AsInt(args[1]); |
| 691 |
if (mode == -1 && PyErr_Occurred()) { |
| 692 |
goto exit; |
| 693 |
} |
| 694 |
return_value = os_fchmod_impl(module, fd, mode); |
| 695 |
|
| 696 |
exit: |
| 697 |
return return_value; |
| 698 |
} |
| 699 |
|
| 700 |
#endif /* (defined(HAVE_FCHMOD) || defined(MS_WINDOWS)) */ |
| 701 |
|
| 702 |
#if (defined(HAVE_LCHMOD) || defined(MS_WINDOWS)) |
| 703 |
|
| 704 |
PyDoc_STRVAR(os_lchmod__doc__, |
| 705 |
"lchmod($module, /, path, mode)\n" |
| 706 |
"--\n" |
| 707 |
"\n" |
| 708 |
"Change the access permissions of a file, without following symbolic links.\n" |
| 709 |
"\n" |
| 710 |
"If path is a symlink, this affects the link itself rather than the target.\n" |
| 711 |
"Equivalent to chmod(path, mode, follow_symlinks=False).\""); |
| 712 |
|
| 713 |
#define OS_LCHMOD_METHODDEF \ |
| 714 |
{"lchmod", _PyCFunction_CAST(os_lchmod), METH_FASTCALL|METH_KEYWORDS, os_lchmod__doc__}, |
| 715 |
|
| 716 |
static PyObject * |
| 717 |
os_lchmod_impl(PyObject *module, path_t *path, int mode); |
| 718 |
|
| 719 |
static PyObject * |
| 720 |
os_lchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 721 |
{ |
| 722 |
PyObject *return_value = NULL; |
| 723 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 724 |
|
| 725 |
#define NUM_KEYWORDS 2 |
| 726 |
static struct { |
| 727 |
PyGC_Head _this_is_not_used; |
| 728 |
PyObject_VAR_HEAD |
| 729 |
Py_hash_t ob_hash; |
| 730 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 731 |
} _kwtuple = { |
| 732 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 733 |
.ob_hash = -1, |
| 734 |
.ob_item = { &_Py_ID(path), &_Py_ID(mode), }, |
| 735 |
}; |
| 736 |
#undef NUM_KEYWORDS |
| 737 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 738 |
|
| 739 |
#else // !Py_BUILD_CORE |
| 740 |
# define KWTUPLE NULL |
| 741 |
#endif // !Py_BUILD_CORE |
| 742 |
|
| 743 |
static const char * const _keywords[] = {"path", "mode", NULL}; |
| 744 |
static _PyArg_Parser _parser = { |
| 745 |
.keywords = _keywords, |
| 746 |
.fname = "lchmod", |
| 747 |
.kwtuple = KWTUPLE, |
| 748 |
}; |
| 749 |
#undef KWTUPLE |
| 750 |
PyObject *argsbuf[2]; |
| 751 |
path_t path = PATH_T_INITIALIZE_P("lchmod", "path", 0, 0, 0, 0); |
| 752 |
int mode; |
| 753 |
|
| 754 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 755 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 756 |
if (!args) { |
| 757 |
goto exit; |
| 758 |
} |
| 759 |
if (!path_converter(args[0], &path)) { |
| 760 |
goto exit; |
| 761 |
} |
| 762 |
mode = PyLong_AsInt(args[1]); |
| 763 |
if (mode == -1 && PyErr_Occurred()) { |
| 764 |
goto exit; |
| 765 |
} |
| 766 |
return_value = os_lchmod_impl(module, &path, mode); |
| 767 |
|
| 768 |
exit: |
| 769 |
/* Cleanup for path */ |
| 770 |
path_cleanup(&path); |
| 771 |
|
| 772 |
return return_value; |
| 773 |
} |
| 774 |
|
| 775 |
#endif /* (defined(HAVE_LCHMOD) || defined(MS_WINDOWS)) */ |
| 776 |
|
| 777 |
#if defined(HAVE_CHFLAGS) |
| 778 |
|
| 779 |
PyDoc_STRVAR(os_chflags__doc__, |
| 780 |
"chflags($module, /, path, flags, follow_symlinks=True)\n" |
| 781 |
"--\n" |
| 782 |
"\n" |
| 783 |
"Set file flags.\n" |
| 784 |
"\n" |
| 785 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 786 |
" link, chflags will change flags on the symbolic link itself instead of the\n" |
| 787 |
" file the link points to.\n" |
| 788 |
"follow_symlinks may not be implemented on your platform. If it is\n" |
| 789 |
"unavailable, using it will raise a NotImplementedError."); |
| 790 |
|
| 791 |
#define OS_CHFLAGS_METHODDEF \ |
| 792 |
{"chflags", _PyCFunction_CAST(os_chflags), METH_FASTCALL|METH_KEYWORDS, os_chflags__doc__}, |
| 793 |
|
| 794 |
static PyObject * |
| 795 |
os_chflags_impl(PyObject *module, path_t *path, unsigned long flags, |
| 796 |
int follow_symlinks); |
| 797 |
|
| 798 |
static PyObject * |
| 799 |
os_chflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 800 |
{ |
| 801 |
PyObject *return_value = NULL; |
| 802 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 803 |
|
| 804 |
#define NUM_KEYWORDS 3 |
| 805 |
static struct { |
| 806 |
PyGC_Head _this_is_not_used; |
| 807 |
PyObject_VAR_HEAD |
| 808 |
Py_hash_t ob_hash; |
| 809 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 810 |
} _kwtuple = { |
| 811 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 812 |
.ob_hash = -1, |
| 813 |
.ob_item = { &_Py_ID(path), &_Py_ID(flags), &_Py_ID(follow_symlinks), }, |
| 814 |
}; |
| 815 |
#undef NUM_KEYWORDS |
| 816 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 817 |
|
| 818 |
#else // !Py_BUILD_CORE |
| 819 |
# define KWTUPLE NULL |
| 820 |
#endif // !Py_BUILD_CORE |
| 821 |
|
| 822 |
static const char * const _keywords[] = {"path", "flags", "follow_symlinks", NULL}; |
| 823 |
static _PyArg_Parser _parser = { |
| 824 |
.keywords = _keywords, |
| 825 |
.fname = "chflags", |
| 826 |
.kwtuple = KWTUPLE, |
| 827 |
}; |
| 828 |
#undef KWTUPLE |
| 829 |
PyObject *argsbuf[3]; |
| 830 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 831 |
path_t path = PATH_T_INITIALIZE_P("chflags", "path", 0, 0, 0, 0); |
| 832 |
unsigned long flags; |
| 833 |
int follow_symlinks = 1; |
| 834 |
|
| 835 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 836 |
/*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 837 |
if (!args) { |
| 838 |
goto exit; |
| 839 |
} |
| 840 |
if (!path_converter(args[0], &path)) { |
| 841 |
goto exit; |
| 842 |
} |
| 843 |
if (!PyIndex_Check(args[1])) { |
| 844 |
_PyArg_BadArgument("chflags", "argument 'flags'", "int", args[1]); |
| 845 |
goto exit; |
| 846 |
} |
| 847 |
flags = PyLong_AsUnsignedLongMask(args[1]); |
| 848 |
if (!noptargs) { |
| 849 |
goto skip_optional_pos; |
| 850 |
} |
| 851 |
follow_symlinks = PyObject_IsTrue(args[2]); |
| 852 |
if (follow_symlinks < 0) { |
| 853 |
goto exit; |
| 854 |
} |
| 855 |
skip_optional_pos: |
| 856 |
return_value = os_chflags_impl(module, &path, flags, follow_symlinks); |
| 857 |
|
| 858 |
exit: |
| 859 |
/* Cleanup for path */ |
| 860 |
path_cleanup(&path); |
| 861 |
|
| 862 |
return return_value; |
| 863 |
} |
| 864 |
|
| 865 |
#endif /* defined(HAVE_CHFLAGS) */ |
| 866 |
|
| 867 |
#if defined(HAVE_LCHFLAGS) |
| 868 |
|
| 869 |
PyDoc_STRVAR(os_lchflags__doc__, |
| 870 |
"lchflags($module, /, path, flags)\n" |
| 871 |
"--\n" |
| 872 |
"\n" |
| 873 |
"Set file flags.\n" |
| 874 |
"\n" |
| 875 |
"This function will not follow symbolic links.\n" |
| 876 |
"Equivalent to chflags(path, flags, follow_symlinks=False)."); |
| 877 |
|
| 878 |
#define OS_LCHFLAGS_METHODDEF \ |
| 879 |
{"lchflags", _PyCFunction_CAST(os_lchflags), METH_FASTCALL|METH_KEYWORDS, os_lchflags__doc__}, |
| 880 |
|
| 881 |
static PyObject * |
| 882 |
os_lchflags_impl(PyObject *module, path_t *path, unsigned long flags); |
| 883 |
|
| 884 |
static PyObject * |
| 885 |
os_lchflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 886 |
{ |
| 887 |
PyObject *return_value = NULL; |
| 888 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 889 |
|
| 890 |
#define NUM_KEYWORDS 2 |
| 891 |
static struct { |
| 892 |
PyGC_Head _this_is_not_used; |
| 893 |
PyObject_VAR_HEAD |
| 894 |
Py_hash_t ob_hash; |
| 895 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 896 |
} _kwtuple = { |
| 897 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 898 |
.ob_hash = -1, |
| 899 |
.ob_item = { &_Py_ID(path), &_Py_ID(flags), }, |
| 900 |
}; |
| 901 |
#undef NUM_KEYWORDS |
| 902 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 903 |
|
| 904 |
#else // !Py_BUILD_CORE |
| 905 |
# define KWTUPLE NULL |
| 906 |
#endif // !Py_BUILD_CORE |
| 907 |
|
| 908 |
static const char * const _keywords[] = {"path", "flags", NULL}; |
| 909 |
static _PyArg_Parser _parser = { |
| 910 |
.keywords = _keywords, |
| 911 |
.fname = "lchflags", |
| 912 |
.kwtuple = KWTUPLE, |
| 913 |
}; |
| 914 |
#undef KWTUPLE |
| 915 |
PyObject *argsbuf[2]; |
| 916 |
path_t path = PATH_T_INITIALIZE_P("lchflags", "path", 0, 0, 0, 0); |
| 917 |
unsigned long flags; |
| 918 |
|
| 919 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 920 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 921 |
if (!args) { |
| 922 |
goto exit; |
| 923 |
} |
| 924 |
if (!path_converter(args[0], &path)) { |
| 925 |
goto exit; |
| 926 |
} |
| 927 |
if (!PyIndex_Check(args[1])) { |
| 928 |
_PyArg_BadArgument("lchflags", "argument 'flags'", "int", args[1]); |
| 929 |
goto exit; |
| 930 |
} |
| 931 |
flags = PyLong_AsUnsignedLongMask(args[1]); |
| 932 |
return_value = os_lchflags_impl(module, &path, flags); |
| 933 |
|
| 934 |
exit: |
| 935 |
/* Cleanup for path */ |
| 936 |
path_cleanup(&path); |
| 937 |
|
| 938 |
return return_value; |
| 939 |
} |
| 940 |
|
| 941 |
#endif /* defined(HAVE_LCHFLAGS) */ |
| 942 |
|
| 943 |
#if defined(HAVE_CHROOT) |
| 944 |
|
| 945 |
PyDoc_STRVAR(os_chroot__doc__, |
| 946 |
"chroot($module, /, path)\n" |
| 947 |
"--\n" |
| 948 |
"\n" |
| 949 |
"Change root directory to path."); |
| 950 |
|
| 951 |
#define OS_CHROOT_METHODDEF \ |
| 952 |
{"chroot", _PyCFunction_CAST(os_chroot), METH_FASTCALL|METH_KEYWORDS, os_chroot__doc__}, |
| 953 |
|
| 954 |
static PyObject * |
| 955 |
os_chroot_impl(PyObject *module, path_t *path); |
| 956 |
|
| 957 |
static PyObject * |
| 958 |
os_chroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 959 |
{ |
| 960 |
PyObject *return_value = NULL; |
| 961 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 962 |
|
| 963 |
#define NUM_KEYWORDS 1 |
| 964 |
static struct { |
| 965 |
PyGC_Head _this_is_not_used; |
| 966 |
PyObject_VAR_HEAD |
| 967 |
Py_hash_t ob_hash; |
| 968 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 969 |
} _kwtuple = { |
| 970 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 971 |
.ob_hash = -1, |
| 972 |
.ob_item = { &_Py_ID(path), }, |
| 973 |
}; |
| 974 |
#undef NUM_KEYWORDS |
| 975 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 976 |
|
| 977 |
#else // !Py_BUILD_CORE |
| 978 |
# define KWTUPLE NULL |
| 979 |
#endif // !Py_BUILD_CORE |
| 980 |
|
| 981 |
static const char * const _keywords[] = {"path", NULL}; |
| 982 |
static _PyArg_Parser _parser = { |
| 983 |
.keywords = _keywords, |
| 984 |
.fname = "chroot", |
| 985 |
.kwtuple = KWTUPLE, |
| 986 |
}; |
| 987 |
#undef KWTUPLE |
| 988 |
PyObject *argsbuf[1]; |
| 989 |
path_t path = PATH_T_INITIALIZE_P("chroot", "path", 0, 0, 0, 0); |
| 990 |
|
| 991 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 992 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 993 |
if (!args) { |
| 994 |
goto exit; |
| 995 |
} |
| 996 |
if (!path_converter(args[0], &path)) { |
| 997 |
goto exit; |
| 998 |
} |
| 999 |
return_value = os_chroot_impl(module, &path); |
| 1000 |
|
| 1001 |
exit: |
| 1002 |
/* Cleanup for path */ |
| 1003 |
path_cleanup(&path); |
| 1004 |
|
| 1005 |
return return_value; |
| 1006 |
} |
| 1007 |
|
| 1008 |
#endif /* defined(HAVE_CHROOT) */ |
| 1009 |
|
| 1010 |
#if defined(HAVE_FSYNC) |
| 1011 |
|
| 1012 |
PyDoc_STRVAR(os_fsync__doc__, |
| 1013 |
"fsync($module, /, fd)\n" |
| 1014 |
"--\n" |
| 1015 |
"\n" |
| 1016 |
"Force write of fd to disk."); |
| 1017 |
|
| 1018 |
#define OS_FSYNC_METHODDEF \ |
| 1019 |
{"fsync", _PyCFunction_CAST(os_fsync), METH_FASTCALL|METH_KEYWORDS, os_fsync__doc__}, |
| 1020 |
|
| 1021 |
static PyObject * |
| 1022 |
os_fsync_impl(PyObject *module, int fd); |
| 1023 |
|
| 1024 |
static PyObject * |
| 1025 |
os_fsync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1026 |
{ |
| 1027 |
PyObject *return_value = NULL; |
| 1028 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1029 |
|
| 1030 |
#define NUM_KEYWORDS 1 |
| 1031 |
static struct { |
| 1032 |
PyGC_Head _this_is_not_used; |
| 1033 |
PyObject_VAR_HEAD |
| 1034 |
Py_hash_t ob_hash; |
| 1035 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1036 |
} _kwtuple = { |
| 1037 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1038 |
.ob_hash = -1, |
| 1039 |
.ob_item = { &_Py_ID(fd), }, |
| 1040 |
}; |
| 1041 |
#undef NUM_KEYWORDS |
| 1042 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1043 |
|
| 1044 |
#else // !Py_BUILD_CORE |
| 1045 |
# define KWTUPLE NULL |
| 1046 |
#endif // !Py_BUILD_CORE |
| 1047 |
|
| 1048 |
static const char * const _keywords[] = {"fd", NULL}; |
| 1049 |
static _PyArg_Parser _parser = { |
| 1050 |
.keywords = _keywords, |
| 1051 |
.fname = "fsync", |
| 1052 |
.kwtuple = KWTUPLE, |
| 1053 |
}; |
| 1054 |
#undef KWTUPLE |
| 1055 |
PyObject *argsbuf[1]; |
| 1056 |
int fd; |
| 1057 |
|
| 1058 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1059 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1060 |
if (!args) { |
| 1061 |
goto exit; |
| 1062 |
} |
| 1063 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 1064 |
if (fd < 0) { |
| 1065 |
goto exit; |
| 1066 |
} |
| 1067 |
return_value = os_fsync_impl(module, fd); |
| 1068 |
|
| 1069 |
exit: |
| 1070 |
return return_value; |
| 1071 |
} |
| 1072 |
|
| 1073 |
#endif /* defined(HAVE_FSYNC) */ |
| 1074 |
|
| 1075 |
#if defined(HAVE_SYNC) |
| 1076 |
|
| 1077 |
PyDoc_STRVAR(os_sync__doc__, |
| 1078 |
"sync($module, /)\n" |
| 1079 |
"--\n" |
| 1080 |
"\n" |
| 1081 |
"Force write of everything to disk."); |
| 1082 |
|
| 1083 |
#define OS_SYNC_METHODDEF \ |
| 1084 |
{"sync", (PyCFunction)os_sync, METH_NOARGS, os_sync__doc__}, |
| 1085 |
|
| 1086 |
static PyObject * |
| 1087 |
os_sync_impl(PyObject *module); |
| 1088 |
|
| 1089 |
static PyObject * |
| 1090 |
os_sync(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 1091 |
{ |
| 1092 |
return os_sync_impl(module); |
| 1093 |
} |
| 1094 |
|
| 1095 |
#endif /* defined(HAVE_SYNC) */ |
| 1096 |
|
| 1097 |
#if defined(HAVE_FDATASYNC) |
| 1098 |
|
| 1099 |
PyDoc_STRVAR(os_fdatasync__doc__, |
| 1100 |
"fdatasync($module, /, fd)\n" |
| 1101 |
"--\n" |
| 1102 |
"\n" |
| 1103 |
"Force write of fd to disk without forcing update of metadata."); |
| 1104 |
|
| 1105 |
#define OS_FDATASYNC_METHODDEF \ |
| 1106 |
{"fdatasync", _PyCFunction_CAST(os_fdatasync), METH_FASTCALL|METH_KEYWORDS, os_fdatasync__doc__}, |
| 1107 |
|
| 1108 |
static PyObject * |
| 1109 |
os_fdatasync_impl(PyObject *module, int fd); |
| 1110 |
|
| 1111 |
static PyObject * |
| 1112 |
os_fdatasync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1113 |
{ |
| 1114 |
PyObject *return_value = NULL; |
| 1115 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1116 |
|
| 1117 |
#define NUM_KEYWORDS 1 |
| 1118 |
static struct { |
| 1119 |
PyGC_Head _this_is_not_used; |
| 1120 |
PyObject_VAR_HEAD |
| 1121 |
Py_hash_t ob_hash; |
| 1122 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1123 |
} _kwtuple = { |
| 1124 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1125 |
.ob_hash = -1, |
| 1126 |
.ob_item = { &_Py_ID(fd), }, |
| 1127 |
}; |
| 1128 |
#undef NUM_KEYWORDS |
| 1129 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1130 |
|
| 1131 |
#else // !Py_BUILD_CORE |
| 1132 |
# define KWTUPLE NULL |
| 1133 |
#endif // !Py_BUILD_CORE |
| 1134 |
|
| 1135 |
static const char * const _keywords[] = {"fd", NULL}; |
| 1136 |
static _PyArg_Parser _parser = { |
| 1137 |
.keywords = _keywords, |
| 1138 |
.fname = "fdatasync", |
| 1139 |
.kwtuple = KWTUPLE, |
| 1140 |
}; |
| 1141 |
#undef KWTUPLE |
| 1142 |
PyObject *argsbuf[1]; |
| 1143 |
int fd; |
| 1144 |
|
| 1145 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1146 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1147 |
if (!args) { |
| 1148 |
goto exit; |
| 1149 |
} |
| 1150 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 1151 |
if (fd < 0) { |
| 1152 |
goto exit; |
| 1153 |
} |
| 1154 |
return_value = os_fdatasync_impl(module, fd); |
| 1155 |
|
| 1156 |
exit: |
| 1157 |
return return_value; |
| 1158 |
} |
| 1159 |
|
| 1160 |
#endif /* defined(HAVE_FDATASYNC) */ |
| 1161 |
|
| 1162 |
#if defined(HAVE_CHOWN) |
| 1163 |
|
| 1164 |
PyDoc_STRVAR(os_chown__doc__, |
| 1165 |
"chown($module, /, path, uid, gid, *, dir_fd=None, follow_symlinks=True)\n" |
| 1166 |
"--\n" |
| 1167 |
"\n" |
| 1168 |
"Change the owner and group id of path to the numeric uid and gid.\\\n" |
| 1169 |
"\n" |
| 1170 |
" path\n" |
| 1171 |
" Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.\n" |
| 1172 |
" dir_fd\n" |
| 1173 |
" If not None, it should be a file descriptor open to a directory,\n" |
| 1174 |
" and path should be relative; path will then be relative to that\n" |
| 1175 |
" directory.\n" |
| 1176 |
" follow_symlinks\n" |
| 1177 |
" If False, and the last element of the path is a symbolic link,\n" |
| 1178 |
" stat will examine the symbolic link itself instead of the file\n" |
| 1179 |
" the link points to.\n" |
| 1180 |
"\n" |
| 1181 |
"path may always be specified as a string.\n" |
| 1182 |
"On some platforms, path may also be specified as an open file descriptor.\n" |
| 1183 |
" If this functionality is unavailable, using it raises an exception.\n" |
| 1184 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 1185 |
" and path should be relative; path will then be relative to that directory.\n" |
| 1186 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 1187 |
" link, chown will modify the symbolic link itself instead of the file the\n" |
| 1188 |
" link points to.\n" |
| 1189 |
"It is an error to use dir_fd or follow_symlinks when specifying path as\n" |
| 1190 |
" an open file descriptor.\n" |
| 1191 |
"dir_fd and follow_symlinks may not be implemented on your platform.\n" |
| 1192 |
" If they are unavailable, using them will raise a NotImplementedError."); |
| 1193 |
|
| 1194 |
#define OS_CHOWN_METHODDEF \ |
| 1195 |
{"chown", _PyCFunction_CAST(os_chown), METH_FASTCALL|METH_KEYWORDS, os_chown__doc__}, |
| 1196 |
|
| 1197 |
static PyObject * |
| 1198 |
os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid, |
| 1199 |
int dir_fd, int follow_symlinks); |
| 1200 |
|
| 1201 |
static PyObject * |
| 1202 |
os_chown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1203 |
{ |
| 1204 |
PyObject *return_value = NULL; |
| 1205 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1206 |
|
| 1207 |
#define NUM_KEYWORDS 5 |
| 1208 |
static struct { |
| 1209 |
PyGC_Head _this_is_not_used; |
| 1210 |
PyObject_VAR_HEAD |
| 1211 |
Py_hash_t ob_hash; |
| 1212 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1213 |
} _kwtuple = { |
| 1214 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1215 |
.ob_hash = -1, |
| 1216 |
.ob_item = { &_Py_ID(path), &_Py_ID(uid), &_Py_ID(gid), &_Py_ID(dir_fd), &_Py_ID(follow_symlinks), }, |
| 1217 |
}; |
| 1218 |
#undef NUM_KEYWORDS |
| 1219 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1220 |
|
| 1221 |
#else // !Py_BUILD_CORE |
| 1222 |
# define KWTUPLE NULL |
| 1223 |
#endif // !Py_BUILD_CORE |
| 1224 |
|
| 1225 |
static const char * const _keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; |
| 1226 |
static _PyArg_Parser _parser = { |
| 1227 |
.keywords = _keywords, |
| 1228 |
.fname = "chown", |
| 1229 |
.kwtuple = KWTUPLE, |
| 1230 |
}; |
| 1231 |
#undef KWTUPLE |
| 1232 |
PyObject *argsbuf[5]; |
| 1233 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
| 1234 |
path_t path = PATH_T_INITIALIZE_P("chown", "path", 0, 0, 0, PATH_HAVE_FCHOWN); |
| 1235 |
uid_t uid; |
| 1236 |
gid_t gid; |
| 1237 |
int dir_fd = DEFAULT_DIR_FD; |
| 1238 |
int follow_symlinks = 1; |
| 1239 |
|
| 1240 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1241 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1242 |
if (!args) { |
| 1243 |
goto exit; |
| 1244 |
} |
| 1245 |
if (!path_converter(args[0], &path)) { |
| 1246 |
goto exit; |
| 1247 |
} |
| 1248 |
if (!_Py_Uid_Converter(args[1], &uid)) { |
| 1249 |
goto exit; |
| 1250 |
} |
| 1251 |
if (!_Py_Gid_Converter(args[2], &gid)) { |
| 1252 |
goto exit; |
| 1253 |
} |
| 1254 |
if (!noptargs) { |
| 1255 |
goto skip_optional_kwonly; |
| 1256 |
} |
| 1257 |
if (args[3]) { |
| 1258 |
if (!FCHOWNAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { |
| 1259 |
goto exit; |
| 1260 |
} |
| 1261 |
if (!--noptargs) { |
| 1262 |
goto skip_optional_kwonly; |
| 1263 |
} |
| 1264 |
} |
| 1265 |
follow_symlinks = PyObject_IsTrue(args[4]); |
| 1266 |
if (follow_symlinks < 0) { |
| 1267 |
goto exit; |
| 1268 |
} |
| 1269 |
skip_optional_kwonly: |
| 1270 |
return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); |
| 1271 |
|
| 1272 |
exit: |
| 1273 |
/* Cleanup for path */ |
| 1274 |
path_cleanup(&path); |
| 1275 |
|
| 1276 |
return return_value; |
| 1277 |
} |
| 1278 |
|
| 1279 |
#endif /* defined(HAVE_CHOWN) */ |
| 1280 |
|
| 1281 |
#if defined(HAVE_FCHOWN) |
| 1282 |
|
| 1283 |
PyDoc_STRVAR(os_fchown__doc__, |
| 1284 |
"fchown($module, /, fd, uid, gid)\n" |
| 1285 |
"--\n" |
| 1286 |
"\n" |
| 1287 |
"Change the owner and group id of the file specified by file descriptor.\n" |
| 1288 |
"\n" |
| 1289 |
"Equivalent to os.chown(fd, uid, gid)."); |
| 1290 |
|
| 1291 |
#define OS_FCHOWN_METHODDEF \ |
| 1292 |
{"fchown", _PyCFunction_CAST(os_fchown), METH_FASTCALL|METH_KEYWORDS, os_fchown__doc__}, |
| 1293 |
|
| 1294 |
static PyObject * |
| 1295 |
os_fchown_impl(PyObject *module, int fd, uid_t uid, gid_t gid); |
| 1296 |
|
| 1297 |
static PyObject * |
| 1298 |
os_fchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1299 |
{ |
| 1300 |
PyObject *return_value = NULL; |
| 1301 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1302 |
|
| 1303 |
#define NUM_KEYWORDS 3 |
| 1304 |
static struct { |
| 1305 |
PyGC_Head _this_is_not_used; |
| 1306 |
PyObject_VAR_HEAD |
| 1307 |
Py_hash_t ob_hash; |
| 1308 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1309 |
} _kwtuple = { |
| 1310 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1311 |
.ob_hash = -1, |
| 1312 |
.ob_item = { &_Py_ID(fd), &_Py_ID(uid), &_Py_ID(gid), }, |
| 1313 |
}; |
| 1314 |
#undef NUM_KEYWORDS |
| 1315 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1316 |
|
| 1317 |
#else // !Py_BUILD_CORE |
| 1318 |
# define KWTUPLE NULL |
| 1319 |
#endif // !Py_BUILD_CORE |
| 1320 |
|
| 1321 |
static const char * const _keywords[] = {"fd", "uid", "gid", NULL}; |
| 1322 |
static _PyArg_Parser _parser = { |
| 1323 |
.keywords = _keywords, |
| 1324 |
.fname = "fchown", |
| 1325 |
.kwtuple = KWTUPLE, |
| 1326 |
}; |
| 1327 |
#undef KWTUPLE |
| 1328 |
PyObject *argsbuf[3]; |
| 1329 |
int fd; |
| 1330 |
uid_t uid; |
| 1331 |
gid_t gid; |
| 1332 |
|
| 1333 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1334 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1335 |
if (!args) { |
| 1336 |
goto exit; |
| 1337 |
} |
| 1338 |
fd = PyLong_AsInt(args[0]); |
| 1339 |
if (fd == -1 && PyErr_Occurred()) { |
| 1340 |
goto exit; |
| 1341 |
} |
| 1342 |
if (!_Py_Uid_Converter(args[1], &uid)) { |
| 1343 |
goto exit; |
| 1344 |
} |
| 1345 |
if (!_Py_Gid_Converter(args[2], &gid)) { |
| 1346 |
goto exit; |
| 1347 |
} |
| 1348 |
return_value = os_fchown_impl(module, fd, uid, gid); |
| 1349 |
|
| 1350 |
exit: |
| 1351 |
return return_value; |
| 1352 |
} |
| 1353 |
|
| 1354 |
#endif /* defined(HAVE_FCHOWN) */ |
| 1355 |
|
| 1356 |
#if defined(HAVE_LCHOWN) |
| 1357 |
|
| 1358 |
PyDoc_STRVAR(os_lchown__doc__, |
| 1359 |
"lchown($module, /, path, uid, gid)\n" |
| 1360 |
"--\n" |
| 1361 |
"\n" |
| 1362 |
"Change the owner and group id of path to the numeric uid and gid.\n" |
| 1363 |
"\n" |
| 1364 |
"This function will not follow symbolic links.\n" |
| 1365 |
"Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); |
| 1366 |
|
| 1367 |
#define OS_LCHOWN_METHODDEF \ |
| 1368 |
{"lchown", _PyCFunction_CAST(os_lchown), METH_FASTCALL|METH_KEYWORDS, os_lchown__doc__}, |
| 1369 |
|
| 1370 |
static PyObject * |
| 1371 |
os_lchown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid); |
| 1372 |
|
| 1373 |
static PyObject * |
| 1374 |
os_lchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1375 |
{ |
| 1376 |
PyObject *return_value = NULL; |
| 1377 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1378 |
|
| 1379 |
#define NUM_KEYWORDS 3 |
| 1380 |
static struct { |
| 1381 |
PyGC_Head _this_is_not_used; |
| 1382 |
PyObject_VAR_HEAD |
| 1383 |
Py_hash_t ob_hash; |
| 1384 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1385 |
} _kwtuple = { |
| 1386 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1387 |
.ob_hash = -1, |
| 1388 |
.ob_item = { &_Py_ID(path), &_Py_ID(uid), &_Py_ID(gid), }, |
| 1389 |
}; |
| 1390 |
#undef NUM_KEYWORDS |
| 1391 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1392 |
|
| 1393 |
#else // !Py_BUILD_CORE |
| 1394 |
# define KWTUPLE NULL |
| 1395 |
#endif // !Py_BUILD_CORE |
| 1396 |
|
| 1397 |
static const char * const _keywords[] = {"path", "uid", "gid", NULL}; |
| 1398 |
static _PyArg_Parser _parser = { |
| 1399 |
.keywords = _keywords, |
| 1400 |
.fname = "lchown", |
| 1401 |
.kwtuple = KWTUPLE, |
| 1402 |
}; |
| 1403 |
#undef KWTUPLE |
| 1404 |
PyObject *argsbuf[3]; |
| 1405 |
path_t path = PATH_T_INITIALIZE_P("lchown", "path", 0, 0, 0, 0); |
| 1406 |
uid_t uid; |
| 1407 |
gid_t gid; |
| 1408 |
|
| 1409 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1410 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1411 |
if (!args) { |
| 1412 |
goto exit; |
| 1413 |
} |
| 1414 |
if (!path_converter(args[0], &path)) { |
| 1415 |
goto exit; |
| 1416 |
} |
| 1417 |
if (!_Py_Uid_Converter(args[1], &uid)) { |
| 1418 |
goto exit; |
| 1419 |
} |
| 1420 |
if (!_Py_Gid_Converter(args[2], &gid)) { |
| 1421 |
goto exit; |
| 1422 |
} |
| 1423 |
return_value = os_lchown_impl(module, &path, uid, gid); |
| 1424 |
|
| 1425 |
exit: |
| 1426 |
/* Cleanup for path */ |
| 1427 |
path_cleanup(&path); |
| 1428 |
|
| 1429 |
return return_value; |
| 1430 |
} |
| 1431 |
|
| 1432 |
#endif /* defined(HAVE_LCHOWN) */ |
| 1433 |
|
| 1434 |
PyDoc_STRVAR(os_getcwd__doc__, |
| 1435 |
"getcwd($module, /)\n" |
| 1436 |
"--\n" |
| 1437 |
"\n" |
| 1438 |
"Return a unicode string representing the current working directory."); |
| 1439 |
|
| 1440 |
#define OS_GETCWD_METHODDEF \ |
| 1441 |
{"getcwd", (PyCFunction)os_getcwd, METH_NOARGS, os_getcwd__doc__}, |
| 1442 |
|
| 1443 |
static PyObject * |
| 1444 |
os_getcwd_impl(PyObject *module); |
| 1445 |
|
| 1446 |
static PyObject * |
| 1447 |
os_getcwd(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 1448 |
{ |
| 1449 |
return os_getcwd_impl(module); |
| 1450 |
} |
| 1451 |
|
| 1452 |
PyDoc_STRVAR(os_getcwdb__doc__, |
| 1453 |
"getcwdb($module, /)\n" |
| 1454 |
"--\n" |
| 1455 |
"\n" |
| 1456 |
"Return a bytes string representing the current working directory."); |
| 1457 |
|
| 1458 |
#define OS_GETCWDB_METHODDEF \ |
| 1459 |
{"getcwdb", (PyCFunction)os_getcwdb, METH_NOARGS, os_getcwdb__doc__}, |
| 1460 |
|
| 1461 |
static PyObject * |
| 1462 |
os_getcwdb_impl(PyObject *module); |
| 1463 |
|
| 1464 |
static PyObject * |
| 1465 |
os_getcwdb(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 1466 |
{ |
| 1467 |
return os_getcwdb_impl(module); |
| 1468 |
} |
| 1469 |
|
| 1470 |
#if defined(HAVE_LINK) |
| 1471 |
|
| 1472 |
PyDoc_STRVAR(os_link__doc__, |
| 1473 |
"link($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None,\n" |
| 1474 |
" follow_symlinks=(os.name != \'nt\'))\n" |
| 1475 |
"--\n" |
| 1476 |
"\n" |
| 1477 |
"Create a hard link to a file.\n" |
| 1478 |
"\n" |
| 1479 |
"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" |
| 1480 |
" descriptor open to a directory, and the respective path string (src or dst)\n" |
| 1481 |
" should be relative; the path will then be relative to that directory.\n" |
| 1482 |
"If follow_symlinks is False, and the last element of src is a symbolic\n" |
| 1483 |
" link, link will create a link to the symbolic link itself instead of the\n" |
| 1484 |
" file the link points to.\n" |
| 1485 |
"src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your\n" |
| 1486 |
" platform. If they are unavailable, using them will raise a\n" |
| 1487 |
" NotImplementedError."); |
| 1488 |
|
| 1489 |
#define OS_LINK_METHODDEF \ |
| 1490 |
{"link", _PyCFunction_CAST(os_link), METH_FASTCALL|METH_KEYWORDS, os_link__doc__}, |
| 1491 |
|
| 1492 |
static PyObject * |
| 1493 |
os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, |
| 1494 |
int dst_dir_fd, int follow_symlinks); |
| 1495 |
|
| 1496 |
static PyObject * |
| 1497 |
os_link(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1498 |
{ |
| 1499 |
PyObject *return_value = NULL; |
| 1500 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1501 |
|
| 1502 |
#define NUM_KEYWORDS 5 |
| 1503 |
static struct { |
| 1504 |
PyGC_Head _this_is_not_used; |
| 1505 |
PyObject_VAR_HEAD |
| 1506 |
Py_hash_t ob_hash; |
| 1507 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1508 |
} _kwtuple = { |
| 1509 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1510 |
.ob_hash = -1, |
| 1511 |
.ob_item = { &_Py_ID(src), &_Py_ID(dst), &_Py_ID(src_dir_fd), &_Py_ID(dst_dir_fd), &_Py_ID(follow_symlinks), }, |
| 1512 |
}; |
| 1513 |
#undef NUM_KEYWORDS |
| 1514 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1515 |
|
| 1516 |
#else // !Py_BUILD_CORE |
| 1517 |
# define KWTUPLE NULL |
| 1518 |
#endif // !Py_BUILD_CORE |
| 1519 |
|
| 1520 |
static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; |
| 1521 |
static _PyArg_Parser _parser = { |
| 1522 |
.keywords = _keywords, |
| 1523 |
.fname = "link", |
| 1524 |
.kwtuple = KWTUPLE, |
| 1525 |
}; |
| 1526 |
#undef KWTUPLE |
| 1527 |
PyObject *argsbuf[5]; |
| 1528 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 1529 |
path_t src = PATH_T_INITIALIZE_P("link", "src", 0, 0, 0, 0); |
| 1530 |
path_t dst = PATH_T_INITIALIZE_P("link", "dst", 0, 0, 0, 0); |
| 1531 |
int src_dir_fd = DEFAULT_DIR_FD; |
| 1532 |
int dst_dir_fd = DEFAULT_DIR_FD; |
| 1533 |
int follow_symlinks = -1; |
| 1534 |
|
| 1535 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1536 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1537 |
if (!args) { |
| 1538 |
goto exit; |
| 1539 |
} |
| 1540 |
if (!path_converter(args[0], &src)) { |
| 1541 |
goto exit; |
| 1542 |
} |
| 1543 |
if (!path_converter(args[1], &dst)) { |
| 1544 |
goto exit; |
| 1545 |
} |
| 1546 |
if (!noptargs) { |
| 1547 |
goto skip_optional_kwonly; |
| 1548 |
} |
| 1549 |
if (args[2]) { |
| 1550 |
if (!dir_fd_converter(args[2], &src_dir_fd)) { |
| 1551 |
goto exit; |
| 1552 |
} |
| 1553 |
if (!--noptargs) { |
| 1554 |
goto skip_optional_kwonly; |
| 1555 |
} |
| 1556 |
} |
| 1557 |
if (args[3]) { |
| 1558 |
if (!dir_fd_converter(args[3], &dst_dir_fd)) { |
| 1559 |
goto exit; |
| 1560 |
} |
| 1561 |
if (!--noptargs) { |
| 1562 |
goto skip_optional_kwonly; |
| 1563 |
} |
| 1564 |
} |
| 1565 |
follow_symlinks = PyObject_IsTrue(args[4]); |
| 1566 |
if (follow_symlinks < 0) { |
| 1567 |
goto exit; |
| 1568 |
} |
| 1569 |
skip_optional_kwonly: |
| 1570 |
return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); |
| 1571 |
|
| 1572 |
exit: |
| 1573 |
/* Cleanup for src */ |
| 1574 |
path_cleanup(&src); |
| 1575 |
/* Cleanup for dst */ |
| 1576 |
path_cleanup(&dst); |
| 1577 |
|
| 1578 |
return return_value; |
| 1579 |
} |
| 1580 |
|
| 1581 |
#endif /* defined(HAVE_LINK) */ |
| 1582 |
|
| 1583 |
PyDoc_STRVAR(os_listdir__doc__, |
| 1584 |
"listdir($module, /, path=None)\n" |
| 1585 |
"--\n" |
| 1586 |
"\n" |
| 1587 |
"Return a list containing the names of the files in the directory.\n" |
| 1588 |
"\n" |
| 1589 |
"path can be specified as either str, bytes, or a path-like object. If path is bytes,\n" |
| 1590 |
" the filenames returned will also be bytes; in all other circumstances\n" |
| 1591 |
" the filenames returned will be str.\n" |
| 1592 |
"If path is None, uses the path=\'.\'.\n" |
| 1593 |
"On some platforms, path may also be specified as an open file descriptor;\\\n" |
| 1594 |
" the file descriptor must refer to a directory.\n" |
| 1595 |
" If this functionality is unavailable, using it raises NotImplementedError.\n" |
| 1596 |
"\n" |
| 1597 |
"The list is in arbitrary order. It does not include the special\n" |
| 1598 |
"entries \'.\' and \'..\' even if they are present in the directory."); |
| 1599 |
|
| 1600 |
#define OS_LISTDIR_METHODDEF \ |
| 1601 |
{"listdir", _PyCFunction_CAST(os_listdir), METH_FASTCALL|METH_KEYWORDS, os_listdir__doc__}, |
| 1602 |
|
| 1603 |
static PyObject * |
| 1604 |
os_listdir_impl(PyObject *module, path_t *path); |
| 1605 |
|
| 1606 |
static PyObject * |
| 1607 |
os_listdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1608 |
{ |
| 1609 |
PyObject *return_value = NULL; |
| 1610 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1611 |
|
| 1612 |
#define NUM_KEYWORDS 1 |
| 1613 |
static struct { |
| 1614 |
PyGC_Head _this_is_not_used; |
| 1615 |
PyObject_VAR_HEAD |
| 1616 |
Py_hash_t ob_hash; |
| 1617 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1618 |
} _kwtuple = { |
| 1619 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1620 |
.ob_hash = -1, |
| 1621 |
.ob_item = { &_Py_ID(path), }, |
| 1622 |
}; |
| 1623 |
#undef NUM_KEYWORDS |
| 1624 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1625 |
|
| 1626 |
#else // !Py_BUILD_CORE |
| 1627 |
# define KWTUPLE NULL |
| 1628 |
#endif // !Py_BUILD_CORE |
| 1629 |
|
| 1630 |
static const char * const _keywords[] = {"path", NULL}; |
| 1631 |
static _PyArg_Parser _parser = { |
| 1632 |
.keywords = _keywords, |
| 1633 |
.fname = "listdir", |
| 1634 |
.kwtuple = KWTUPLE, |
| 1635 |
}; |
| 1636 |
#undef KWTUPLE |
| 1637 |
PyObject *argsbuf[1]; |
| 1638 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 1639 |
path_t path = PATH_T_INITIALIZE_P("listdir", "path", 1, 0, 0, PATH_HAVE_FDOPENDIR); |
| 1640 |
|
| 1641 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1642 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1643 |
if (!args) { |
| 1644 |
goto exit; |
| 1645 |
} |
| 1646 |
if (!noptargs) { |
| 1647 |
goto skip_optional_pos; |
| 1648 |
} |
| 1649 |
if (!path_converter(args[0], &path)) { |
| 1650 |
goto exit; |
| 1651 |
} |
| 1652 |
skip_optional_pos: |
| 1653 |
return_value = os_listdir_impl(module, &path); |
| 1654 |
|
| 1655 |
exit: |
| 1656 |
/* Cleanup for path */ |
| 1657 |
path_cleanup(&path); |
| 1658 |
|
| 1659 |
return return_value; |
| 1660 |
} |
| 1661 |
|
| 1662 |
#if defined(MS_WINDOWS) |
| 1663 |
|
| 1664 |
PyDoc_STRVAR(os_listdrives__doc__, |
| 1665 |
"listdrives($module, /)\n" |
| 1666 |
"--\n" |
| 1667 |
"\n" |
| 1668 |
"Return a list containing the names of drives in the system.\n" |
| 1669 |
"\n" |
| 1670 |
"A drive name typically looks like \'C:\\\\\'."); |
| 1671 |
|
| 1672 |
#define OS_LISTDRIVES_METHODDEF \ |
| 1673 |
{"listdrives", (PyCFunction)os_listdrives, METH_NOARGS, os_listdrives__doc__}, |
| 1674 |
|
| 1675 |
static PyObject * |
| 1676 |
os_listdrives_impl(PyObject *module); |
| 1677 |
|
| 1678 |
static PyObject * |
| 1679 |
os_listdrives(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 1680 |
{ |
| 1681 |
return os_listdrives_impl(module); |
| 1682 |
} |
| 1683 |
|
| 1684 |
#endif /* defined(MS_WINDOWS) */ |
| 1685 |
|
| 1686 |
#if defined(MS_WINDOWS) |
| 1687 |
|
| 1688 |
PyDoc_STRVAR(os_listvolumes__doc__, |
| 1689 |
"listvolumes($module, /)\n" |
| 1690 |
"--\n" |
| 1691 |
"\n" |
| 1692 |
"Return a list containing the volumes in the system.\n" |
| 1693 |
"\n" |
| 1694 |
"Volumes are typically represented as a GUID path."); |
| 1695 |
|
| 1696 |
#define OS_LISTVOLUMES_METHODDEF \ |
| 1697 |
{"listvolumes", (PyCFunction)os_listvolumes, METH_NOARGS, os_listvolumes__doc__}, |
| 1698 |
|
| 1699 |
static PyObject * |
| 1700 |
os_listvolumes_impl(PyObject *module); |
| 1701 |
|
| 1702 |
static PyObject * |
| 1703 |
os_listvolumes(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 1704 |
{ |
| 1705 |
return os_listvolumes_impl(module); |
| 1706 |
} |
| 1707 |
|
| 1708 |
#endif /* defined(MS_WINDOWS) */ |
| 1709 |
|
| 1710 |
#if defined(MS_WINDOWS) |
| 1711 |
|
| 1712 |
PyDoc_STRVAR(os_listmounts__doc__, |
| 1713 |
"listmounts($module, /, volume)\n" |
| 1714 |
"--\n" |
| 1715 |
"\n" |
| 1716 |
"Return a list containing mount points for a particular volume.\n" |
| 1717 |
"\n" |
| 1718 |
"\'volume\' should be a GUID path as returned from os.listvolumes."); |
| 1719 |
|
| 1720 |
#define OS_LISTMOUNTS_METHODDEF \ |
| 1721 |
{"listmounts", _PyCFunction_CAST(os_listmounts), METH_FASTCALL|METH_KEYWORDS, os_listmounts__doc__}, |
| 1722 |
|
| 1723 |
static PyObject * |
| 1724 |
os_listmounts_impl(PyObject *module, path_t *volume); |
| 1725 |
|
| 1726 |
static PyObject * |
| 1727 |
os_listmounts(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1728 |
{ |
| 1729 |
PyObject *return_value = NULL; |
| 1730 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1731 |
|
| 1732 |
#define NUM_KEYWORDS 1 |
| 1733 |
static struct { |
| 1734 |
PyGC_Head _this_is_not_used; |
| 1735 |
PyObject_VAR_HEAD |
| 1736 |
Py_hash_t ob_hash; |
| 1737 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1738 |
} _kwtuple = { |
| 1739 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1740 |
.ob_hash = -1, |
| 1741 |
.ob_item = { &_Py_ID(volume), }, |
| 1742 |
}; |
| 1743 |
#undef NUM_KEYWORDS |
| 1744 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1745 |
|
| 1746 |
#else // !Py_BUILD_CORE |
| 1747 |
# define KWTUPLE NULL |
| 1748 |
#endif // !Py_BUILD_CORE |
| 1749 |
|
| 1750 |
static const char * const _keywords[] = {"volume", NULL}; |
| 1751 |
static _PyArg_Parser _parser = { |
| 1752 |
.keywords = _keywords, |
| 1753 |
.fname = "listmounts", |
| 1754 |
.kwtuple = KWTUPLE, |
| 1755 |
}; |
| 1756 |
#undef KWTUPLE |
| 1757 |
PyObject *argsbuf[1]; |
| 1758 |
path_t volume = PATH_T_INITIALIZE_P("listmounts", "volume", 0, 0, 0, 0); |
| 1759 |
|
| 1760 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1761 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1762 |
if (!args) { |
| 1763 |
goto exit; |
| 1764 |
} |
| 1765 |
if (!path_converter(args[0], &volume)) { |
| 1766 |
goto exit; |
| 1767 |
} |
| 1768 |
return_value = os_listmounts_impl(module, &volume); |
| 1769 |
|
| 1770 |
exit: |
| 1771 |
/* Cleanup for volume */ |
| 1772 |
path_cleanup(&volume); |
| 1773 |
|
| 1774 |
return return_value; |
| 1775 |
} |
| 1776 |
|
| 1777 |
#endif /* defined(MS_WINDOWS) */ |
| 1778 |
|
| 1779 |
#if defined(MS_WINDOWS) |
| 1780 |
|
| 1781 |
PyDoc_STRVAR(os__path_isdevdrive__doc__, |
| 1782 |
"_path_isdevdrive($module, /, path)\n" |
| 1783 |
"--\n" |
| 1784 |
"\n" |
| 1785 |
"Determines whether the specified path is on a Windows Dev Drive."); |
| 1786 |
|
| 1787 |
#define OS__PATH_ISDEVDRIVE_METHODDEF \ |
| 1788 |
{"_path_isdevdrive", _PyCFunction_CAST(os__path_isdevdrive), METH_FASTCALL|METH_KEYWORDS, os__path_isdevdrive__doc__}, |
| 1789 |
|
| 1790 |
static PyObject * |
| 1791 |
os__path_isdevdrive_impl(PyObject *module, path_t *path); |
| 1792 |
|
| 1793 |
static PyObject * |
| 1794 |
os__path_isdevdrive(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1795 |
{ |
| 1796 |
PyObject *return_value = NULL; |
| 1797 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1798 |
|
| 1799 |
#define NUM_KEYWORDS 1 |
| 1800 |
static struct { |
| 1801 |
PyGC_Head _this_is_not_used; |
| 1802 |
PyObject_VAR_HEAD |
| 1803 |
Py_hash_t ob_hash; |
| 1804 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1805 |
} _kwtuple = { |
| 1806 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1807 |
.ob_hash = -1, |
| 1808 |
.ob_item = { &_Py_ID(path), }, |
| 1809 |
}; |
| 1810 |
#undef NUM_KEYWORDS |
| 1811 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1812 |
|
| 1813 |
#else // !Py_BUILD_CORE |
| 1814 |
# define KWTUPLE NULL |
| 1815 |
#endif // !Py_BUILD_CORE |
| 1816 |
|
| 1817 |
static const char * const _keywords[] = {"path", NULL}; |
| 1818 |
static _PyArg_Parser _parser = { |
| 1819 |
.keywords = _keywords, |
| 1820 |
.fname = "_path_isdevdrive", |
| 1821 |
.kwtuple = KWTUPLE, |
| 1822 |
}; |
| 1823 |
#undef KWTUPLE |
| 1824 |
PyObject *argsbuf[1]; |
| 1825 |
path_t path = PATH_T_INITIALIZE_P("_path_isdevdrive", "path", 0, 0, 0, 0); |
| 1826 |
|
| 1827 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1828 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1829 |
if (!args) { |
| 1830 |
goto exit; |
| 1831 |
} |
| 1832 |
if (!path_converter(args[0], &path)) { |
| 1833 |
goto exit; |
| 1834 |
} |
| 1835 |
return_value = os__path_isdevdrive_impl(module, &path); |
| 1836 |
|
| 1837 |
exit: |
| 1838 |
/* Cleanup for path */ |
| 1839 |
path_cleanup(&path); |
| 1840 |
|
| 1841 |
return return_value; |
| 1842 |
} |
| 1843 |
|
| 1844 |
#endif /* defined(MS_WINDOWS) */ |
| 1845 |
|
| 1846 |
#if defined(MS_WINDOWS) |
| 1847 |
|
| 1848 |
PyDoc_STRVAR(os__getfullpathname__doc__, |
| 1849 |
"_getfullpathname($module, path, /)\n" |
| 1850 |
"--\n" |
| 1851 |
"\n"); |
| 1852 |
|
| 1853 |
#define OS__GETFULLPATHNAME_METHODDEF \ |
| 1854 |
{"_getfullpathname", (PyCFunction)os__getfullpathname, METH_O, os__getfullpathname__doc__}, |
| 1855 |
|
| 1856 |
static PyObject * |
| 1857 |
os__getfullpathname_impl(PyObject *module, path_t *path); |
| 1858 |
|
| 1859 |
static PyObject * |
| 1860 |
os__getfullpathname(PyObject *module, PyObject *arg) |
| 1861 |
{ |
| 1862 |
PyObject *return_value = NULL; |
| 1863 |
path_t path = PATH_T_INITIALIZE_P("_getfullpathname", "path", 0, 0, 0, 0); |
| 1864 |
|
| 1865 |
if (!path_converter(arg, &path)) { |
| 1866 |
goto exit; |
| 1867 |
} |
| 1868 |
return_value = os__getfullpathname_impl(module, &path); |
| 1869 |
|
| 1870 |
exit: |
| 1871 |
/* Cleanup for path */ |
| 1872 |
path_cleanup(&path); |
| 1873 |
|
| 1874 |
return return_value; |
| 1875 |
} |
| 1876 |
|
| 1877 |
#endif /* defined(MS_WINDOWS) */ |
| 1878 |
|
| 1879 |
#if defined(MS_WINDOWS) |
| 1880 |
|
| 1881 |
PyDoc_STRVAR(os__getfinalpathname__doc__, |
| 1882 |
"_getfinalpathname($module, path, /)\n" |
| 1883 |
"--\n" |
| 1884 |
"\n" |
| 1885 |
"A helper function for samepath on windows."); |
| 1886 |
|
| 1887 |
#define OS__GETFINALPATHNAME_METHODDEF \ |
| 1888 |
{"_getfinalpathname", (PyCFunction)os__getfinalpathname, METH_O, os__getfinalpathname__doc__}, |
| 1889 |
|
| 1890 |
static PyObject * |
| 1891 |
os__getfinalpathname_impl(PyObject *module, path_t *path); |
| 1892 |
|
| 1893 |
static PyObject * |
| 1894 |
os__getfinalpathname(PyObject *module, PyObject *arg) |
| 1895 |
{ |
| 1896 |
PyObject *return_value = NULL; |
| 1897 |
path_t path = PATH_T_INITIALIZE_P("_getfinalpathname", "path", 0, 0, 0, 0); |
| 1898 |
|
| 1899 |
if (!path_converter(arg, &path)) { |
| 1900 |
goto exit; |
| 1901 |
} |
| 1902 |
return_value = os__getfinalpathname_impl(module, &path); |
| 1903 |
|
| 1904 |
exit: |
| 1905 |
/* Cleanup for path */ |
| 1906 |
path_cleanup(&path); |
| 1907 |
|
| 1908 |
return return_value; |
| 1909 |
} |
| 1910 |
|
| 1911 |
#endif /* defined(MS_WINDOWS) */ |
| 1912 |
|
| 1913 |
#if defined(MS_WINDOWS) |
| 1914 |
|
| 1915 |
PyDoc_STRVAR(os__findfirstfile__doc__, |
| 1916 |
"_findfirstfile($module, path, /)\n" |
| 1917 |
"--\n" |
| 1918 |
"\n" |
| 1919 |
"A function to get the real file name without accessing the file in Windows."); |
| 1920 |
|
| 1921 |
#define OS__FINDFIRSTFILE_METHODDEF \ |
| 1922 |
{"_findfirstfile", (PyCFunction)os__findfirstfile, METH_O, os__findfirstfile__doc__}, |
| 1923 |
|
| 1924 |
static PyObject * |
| 1925 |
os__findfirstfile_impl(PyObject *module, path_t *path); |
| 1926 |
|
| 1927 |
static PyObject * |
| 1928 |
os__findfirstfile(PyObject *module, PyObject *arg) |
| 1929 |
{ |
| 1930 |
PyObject *return_value = NULL; |
| 1931 |
path_t path = PATH_T_INITIALIZE_P("_findfirstfile", "path", 0, 0, 0, 0); |
| 1932 |
|
| 1933 |
if (!path_converter(arg, &path)) { |
| 1934 |
goto exit; |
| 1935 |
} |
| 1936 |
return_value = os__findfirstfile_impl(module, &path); |
| 1937 |
|
| 1938 |
exit: |
| 1939 |
/* Cleanup for path */ |
| 1940 |
path_cleanup(&path); |
| 1941 |
|
| 1942 |
return return_value; |
| 1943 |
} |
| 1944 |
|
| 1945 |
#endif /* defined(MS_WINDOWS) */ |
| 1946 |
|
| 1947 |
#if defined(MS_WINDOWS) |
| 1948 |
|
| 1949 |
PyDoc_STRVAR(os__getvolumepathname__doc__, |
| 1950 |
"_getvolumepathname($module, /, path)\n" |
| 1951 |
"--\n" |
| 1952 |
"\n" |
| 1953 |
"A helper function for ismount on Win32."); |
| 1954 |
|
| 1955 |
#define OS__GETVOLUMEPATHNAME_METHODDEF \ |
| 1956 |
{"_getvolumepathname", _PyCFunction_CAST(os__getvolumepathname), METH_FASTCALL|METH_KEYWORDS, os__getvolumepathname__doc__}, |
| 1957 |
|
| 1958 |
static PyObject * |
| 1959 |
os__getvolumepathname_impl(PyObject *module, path_t *path); |
| 1960 |
|
| 1961 |
static PyObject * |
| 1962 |
os__getvolumepathname(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 1963 |
{ |
| 1964 |
PyObject *return_value = NULL; |
| 1965 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 1966 |
|
| 1967 |
#define NUM_KEYWORDS 1 |
| 1968 |
static struct { |
| 1969 |
PyGC_Head _this_is_not_used; |
| 1970 |
PyObject_VAR_HEAD |
| 1971 |
Py_hash_t ob_hash; |
| 1972 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 1973 |
} _kwtuple = { |
| 1974 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 1975 |
.ob_hash = -1, |
| 1976 |
.ob_item = { &_Py_ID(path), }, |
| 1977 |
}; |
| 1978 |
#undef NUM_KEYWORDS |
| 1979 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 1980 |
|
| 1981 |
#else // !Py_BUILD_CORE |
| 1982 |
# define KWTUPLE NULL |
| 1983 |
#endif // !Py_BUILD_CORE |
| 1984 |
|
| 1985 |
static const char * const _keywords[] = {"path", NULL}; |
| 1986 |
static _PyArg_Parser _parser = { |
| 1987 |
.keywords = _keywords, |
| 1988 |
.fname = "_getvolumepathname", |
| 1989 |
.kwtuple = KWTUPLE, |
| 1990 |
}; |
| 1991 |
#undef KWTUPLE |
| 1992 |
PyObject *argsbuf[1]; |
| 1993 |
path_t path = PATH_T_INITIALIZE_P("_getvolumepathname", "path", 0, 0, 0, 0); |
| 1994 |
|
| 1995 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 1996 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 1997 |
if (!args) { |
| 1998 |
goto exit; |
| 1999 |
} |
| 2000 |
if (!path_converter(args[0], &path)) { |
| 2001 |
goto exit; |
| 2002 |
} |
| 2003 |
return_value = os__getvolumepathname_impl(module, &path); |
| 2004 |
|
| 2005 |
exit: |
| 2006 |
/* Cleanup for path */ |
| 2007 |
path_cleanup(&path); |
| 2008 |
|
| 2009 |
return return_value; |
| 2010 |
} |
| 2011 |
|
| 2012 |
#endif /* defined(MS_WINDOWS) */ |
| 2013 |
|
| 2014 |
#if defined(MS_WINDOWS) |
| 2015 |
|
| 2016 |
PyDoc_STRVAR(os__path_splitroot__doc__, |
| 2017 |
"_path_splitroot($module, /, path)\n" |
| 2018 |
"--\n" |
| 2019 |
"\n" |
| 2020 |
"Removes everything after the root on Win32."); |
| 2021 |
|
| 2022 |
#define OS__PATH_SPLITROOT_METHODDEF \ |
| 2023 |
{"_path_splitroot", _PyCFunction_CAST(os__path_splitroot), METH_FASTCALL|METH_KEYWORDS, os__path_splitroot__doc__}, |
| 2024 |
|
| 2025 |
static PyObject * |
| 2026 |
os__path_splitroot_impl(PyObject *module, path_t *path); |
| 2027 |
|
| 2028 |
static PyObject * |
| 2029 |
os__path_splitroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2030 |
{ |
| 2031 |
PyObject *return_value = NULL; |
| 2032 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2033 |
|
| 2034 |
#define NUM_KEYWORDS 1 |
| 2035 |
static struct { |
| 2036 |
PyGC_Head _this_is_not_used; |
| 2037 |
PyObject_VAR_HEAD |
| 2038 |
Py_hash_t ob_hash; |
| 2039 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2040 |
} _kwtuple = { |
| 2041 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2042 |
.ob_hash = -1, |
| 2043 |
.ob_item = { &_Py_ID(path), }, |
| 2044 |
}; |
| 2045 |
#undef NUM_KEYWORDS |
| 2046 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2047 |
|
| 2048 |
#else // !Py_BUILD_CORE |
| 2049 |
# define KWTUPLE NULL |
| 2050 |
#endif // !Py_BUILD_CORE |
| 2051 |
|
| 2052 |
static const char * const _keywords[] = {"path", NULL}; |
| 2053 |
static _PyArg_Parser _parser = { |
| 2054 |
.keywords = _keywords, |
| 2055 |
.fname = "_path_splitroot", |
| 2056 |
.kwtuple = KWTUPLE, |
| 2057 |
}; |
| 2058 |
#undef KWTUPLE |
| 2059 |
PyObject *argsbuf[1]; |
| 2060 |
path_t path = PATH_T_INITIALIZE_P("_path_splitroot", "path", 0, 0, 0, 0); |
| 2061 |
|
| 2062 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2063 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2064 |
if (!args) { |
| 2065 |
goto exit; |
| 2066 |
} |
| 2067 |
if (!path_converter(args[0], &path)) { |
| 2068 |
goto exit; |
| 2069 |
} |
| 2070 |
return_value = os__path_splitroot_impl(module, &path); |
| 2071 |
|
| 2072 |
exit: |
| 2073 |
/* Cleanup for path */ |
| 2074 |
path_cleanup(&path); |
| 2075 |
|
| 2076 |
return return_value; |
| 2077 |
} |
| 2078 |
|
| 2079 |
#endif /* defined(MS_WINDOWS) */ |
| 2080 |
|
| 2081 |
#if defined(MS_WINDOWS) |
| 2082 |
|
| 2083 |
PyDoc_STRVAR(os__path_exists__doc__, |
| 2084 |
"_path_exists($module, /, path)\n" |
| 2085 |
"--\n" |
| 2086 |
"\n" |
| 2087 |
"Test whether a path exists. Returns False for broken symbolic links."); |
| 2088 |
|
| 2089 |
#define OS__PATH_EXISTS_METHODDEF \ |
| 2090 |
{"_path_exists", _PyCFunction_CAST(os__path_exists), METH_FASTCALL|METH_KEYWORDS, os__path_exists__doc__}, |
| 2091 |
|
| 2092 |
static int |
| 2093 |
os__path_exists_impl(PyObject *module, path_t *path); |
| 2094 |
|
| 2095 |
static PyObject * |
| 2096 |
os__path_exists(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2097 |
{ |
| 2098 |
PyObject *return_value = NULL; |
| 2099 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2100 |
|
| 2101 |
#define NUM_KEYWORDS 1 |
| 2102 |
static struct { |
| 2103 |
PyGC_Head _this_is_not_used; |
| 2104 |
PyObject_VAR_HEAD |
| 2105 |
Py_hash_t ob_hash; |
| 2106 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2107 |
} _kwtuple = { |
| 2108 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2109 |
.ob_hash = -1, |
| 2110 |
.ob_item = { &_Py_ID(path), }, |
| 2111 |
}; |
| 2112 |
#undef NUM_KEYWORDS |
| 2113 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2114 |
|
| 2115 |
#else // !Py_BUILD_CORE |
| 2116 |
# define KWTUPLE NULL |
| 2117 |
#endif // !Py_BUILD_CORE |
| 2118 |
|
| 2119 |
static const char * const _keywords[] = {"path", NULL}; |
| 2120 |
static _PyArg_Parser _parser = { |
| 2121 |
.keywords = _keywords, |
| 2122 |
.fname = "_path_exists", |
| 2123 |
.kwtuple = KWTUPLE, |
| 2124 |
}; |
| 2125 |
#undef KWTUPLE |
| 2126 |
PyObject *argsbuf[1]; |
| 2127 |
path_t path = PATH_T_INITIALIZE_P("_path_exists", "path", 0, 0, 1, 1); |
| 2128 |
int _return_value; |
| 2129 |
|
| 2130 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2131 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2132 |
if (!args) { |
| 2133 |
goto exit; |
| 2134 |
} |
| 2135 |
if (!path_converter(args[0], &path)) { |
| 2136 |
goto exit; |
| 2137 |
} |
| 2138 |
_return_value = os__path_exists_impl(module, &path); |
| 2139 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 2140 |
goto exit; |
| 2141 |
} |
| 2142 |
return_value = PyBool_FromLong((long)_return_value); |
| 2143 |
|
| 2144 |
exit: |
| 2145 |
/* Cleanup for path */ |
| 2146 |
path_cleanup(&path); |
| 2147 |
|
| 2148 |
return return_value; |
| 2149 |
} |
| 2150 |
|
| 2151 |
#endif /* defined(MS_WINDOWS) */ |
| 2152 |
|
| 2153 |
#if defined(MS_WINDOWS) |
| 2154 |
|
| 2155 |
PyDoc_STRVAR(os__path_lexists__doc__, |
| 2156 |
"_path_lexists($module, /, path)\n" |
| 2157 |
"--\n" |
| 2158 |
"\n" |
| 2159 |
"Test whether a path exists. Returns True for broken symbolic links."); |
| 2160 |
|
| 2161 |
#define OS__PATH_LEXISTS_METHODDEF \ |
| 2162 |
{"_path_lexists", _PyCFunction_CAST(os__path_lexists), METH_FASTCALL|METH_KEYWORDS, os__path_lexists__doc__}, |
| 2163 |
|
| 2164 |
static int |
| 2165 |
os__path_lexists_impl(PyObject *module, path_t *path); |
| 2166 |
|
| 2167 |
static PyObject * |
| 2168 |
os__path_lexists(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2169 |
{ |
| 2170 |
PyObject *return_value = NULL; |
| 2171 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2172 |
|
| 2173 |
#define NUM_KEYWORDS 1 |
| 2174 |
static struct { |
| 2175 |
PyGC_Head _this_is_not_used; |
| 2176 |
PyObject_VAR_HEAD |
| 2177 |
Py_hash_t ob_hash; |
| 2178 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2179 |
} _kwtuple = { |
| 2180 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2181 |
.ob_hash = -1, |
| 2182 |
.ob_item = { &_Py_ID(path), }, |
| 2183 |
}; |
| 2184 |
#undef NUM_KEYWORDS |
| 2185 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2186 |
|
| 2187 |
#else // !Py_BUILD_CORE |
| 2188 |
# define KWTUPLE NULL |
| 2189 |
#endif // !Py_BUILD_CORE |
| 2190 |
|
| 2191 |
static const char * const _keywords[] = {"path", NULL}; |
| 2192 |
static _PyArg_Parser _parser = { |
| 2193 |
.keywords = _keywords, |
| 2194 |
.fname = "_path_lexists", |
| 2195 |
.kwtuple = KWTUPLE, |
| 2196 |
}; |
| 2197 |
#undef KWTUPLE |
| 2198 |
PyObject *argsbuf[1]; |
| 2199 |
path_t path = PATH_T_INITIALIZE_P("_path_lexists", "path", 0, 0, 1, 1); |
| 2200 |
int _return_value; |
| 2201 |
|
| 2202 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2203 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2204 |
if (!args) { |
| 2205 |
goto exit; |
| 2206 |
} |
| 2207 |
if (!path_converter(args[0], &path)) { |
| 2208 |
goto exit; |
| 2209 |
} |
| 2210 |
_return_value = os__path_lexists_impl(module, &path); |
| 2211 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 2212 |
goto exit; |
| 2213 |
} |
| 2214 |
return_value = PyBool_FromLong((long)_return_value); |
| 2215 |
|
| 2216 |
exit: |
| 2217 |
/* Cleanup for path */ |
| 2218 |
path_cleanup(&path); |
| 2219 |
|
| 2220 |
return return_value; |
| 2221 |
} |
| 2222 |
|
| 2223 |
#endif /* defined(MS_WINDOWS) */ |
| 2224 |
|
| 2225 |
#if defined(MS_WINDOWS) |
| 2226 |
|
| 2227 |
PyDoc_STRVAR(os__path_isdir__doc__, |
| 2228 |
"_path_isdir($module, /, s)\n" |
| 2229 |
"--\n" |
| 2230 |
"\n" |
| 2231 |
"Return true if the pathname refers to an existing directory."); |
| 2232 |
|
| 2233 |
#define OS__PATH_ISDIR_METHODDEF \ |
| 2234 |
{"_path_isdir", _PyCFunction_CAST(os__path_isdir), METH_FASTCALL|METH_KEYWORDS, os__path_isdir__doc__}, |
| 2235 |
|
| 2236 |
static int |
| 2237 |
os__path_isdir_impl(PyObject *module, path_t *path); |
| 2238 |
|
| 2239 |
static PyObject * |
| 2240 |
os__path_isdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2241 |
{ |
| 2242 |
PyObject *return_value = NULL; |
| 2243 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2244 |
|
| 2245 |
#define NUM_KEYWORDS 1 |
| 2246 |
static struct { |
| 2247 |
PyGC_Head _this_is_not_used; |
| 2248 |
PyObject_VAR_HEAD |
| 2249 |
Py_hash_t ob_hash; |
| 2250 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2251 |
} _kwtuple = { |
| 2252 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2253 |
.ob_hash = -1, |
| 2254 |
.ob_item = { _Py_LATIN1_CHR('s'), }, |
| 2255 |
}; |
| 2256 |
#undef NUM_KEYWORDS |
| 2257 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2258 |
|
| 2259 |
#else // !Py_BUILD_CORE |
| 2260 |
# define KWTUPLE NULL |
| 2261 |
#endif // !Py_BUILD_CORE |
| 2262 |
|
| 2263 |
static const char * const _keywords[] = {"s", NULL}; |
| 2264 |
static _PyArg_Parser _parser = { |
| 2265 |
.keywords = _keywords, |
| 2266 |
.fname = "_path_isdir", |
| 2267 |
.kwtuple = KWTUPLE, |
| 2268 |
}; |
| 2269 |
#undef KWTUPLE |
| 2270 |
PyObject *argsbuf[1]; |
| 2271 |
path_t path = PATH_T_INITIALIZE_P("_path_isdir", "path", 0, 0, 1, 1); |
| 2272 |
int _return_value; |
| 2273 |
|
| 2274 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2275 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2276 |
if (!args) { |
| 2277 |
goto exit; |
| 2278 |
} |
| 2279 |
if (!path_converter(args[0], &path)) { |
| 2280 |
goto exit; |
| 2281 |
} |
| 2282 |
_return_value = os__path_isdir_impl(module, &path); |
| 2283 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 2284 |
goto exit; |
| 2285 |
} |
| 2286 |
return_value = PyBool_FromLong((long)_return_value); |
| 2287 |
|
| 2288 |
exit: |
| 2289 |
/* Cleanup for path */ |
| 2290 |
path_cleanup(&path); |
| 2291 |
|
| 2292 |
return return_value; |
| 2293 |
} |
| 2294 |
|
| 2295 |
#endif /* defined(MS_WINDOWS) */ |
| 2296 |
|
| 2297 |
#if defined(MS_WINDOWS) |
| 2298 |
|
| 2299 |
PyDoc_STRVAR(os__path_isfile__doc__, |
| 2300 |
"_path_isfile($module, /, path)\n" |
| 2301 |
"--\n" |
| 2302 |
"\n" |
| 2303 |
"Test whether a path is a regular file"); |
| 2304 |
|
| 2305 |
#define OS__PATH_ISFILE_METHODDEF \ |
| 2306 |
{"_path_isfile", _PyCFunction_CAST(os__path_isfile), METH_FASTCALL|METH_KEYWORDS, os__path_isfile__doc__}, |
| 2307 |
|
| 2308 |
static int |
| 2309 |
os__path_isfile_impl(PyObject *module, path_t *path); |
| 2310 |
|
| 2311 |
static PyObject * |
| 2312 |
os__path_isfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2313 |
{ |
| 2314 |
PyObject *return_value = NULL; |
| 2315 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2316 |
|
| 2317 |
#define NUM_KEYWORDS 1 |
| 2318 |
static struct { |
| 2319 |
PyGC_Head _this_is_not_used; |
| 2320 |
PyObject_VAR_HEAD |
| 2321 |
Py_hash_t ob_hash; |
| 2322 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2323 |
} _kwtuple = { |
| 2324 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2325 |
.ob_hash = -1, |
| 2326 |
.ob_item = { &_Py_ID(path), }, |
| 2327 |
}; |
| 2328 |
#undef NUM_KEYWORDS |
| 2329 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2330 |
|
| 2331 |
#else // !Py_BUILD_CORE |
| 2332 |
# define KWTUPLE NULL |
| 2333 |
#endif // !Py_BUILD_CORE |
| 2334 |
|
| 2335 |
static const char * const _keywords[] = {"path", NULL}; |
| 2336 |
static _PyArg_Parser _parser = { |
| 2337 |
.keywords = _keywords, |
| 2338 |
.fname = "_path_isfile", |
| 2339 |
.kwtuple = KWTUPLE, |
| 2340 |
}; |
| 2341 |
#undef KWTUPLE |
| 2342 |
PyObject *argsbuf[1]; |
| 2343 |
path_t path = PATH_T_INITIALIZE_P("_path_isfile", "path", 0, 0, 1, 1); |
| 2344 |
int _return_value; |
| 2345 |
|
| 2346 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2347 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2348 |
if (!args) { |
| 2349 |
goto exit; |
| 2350 |
} |
| 2351 |
if (!path_converter(args[0], &path)) { |
| 2352 |
goto exit; |
| 2353 |
} |
| 2354 |
_return_value = os__path_isfile_impl(module, &path); |
| 2355 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 2356 |
goto exit; |
| 2357 |
} |
| 2358 |
return_value = PyBool_FromLong((long)_return_value); |
| 2359 |
|
| 2360 |
exit: |
| 2361 |
/* Cleanup for path */ |
| 2362 |
path_cleanup(&path); |
| 2363 |
|
| 2364 |
return return_value; |
| 2365 |
} |
| 2366 |
|
| 2367 |
#endif /* defined(MS_WINDOWS) */ |
| 2368 |
|
| 2369 |
#if defined(MS_WINDOWS) |
| 2370 |
|
| 2371 |
PyDoc_STRVAR(os__path_islink__doc__, |
| 2372 |
"_path_islink($module, /, path)\n" |
| 2373 |
"--\n" |
| 2374 |
"\n" |
| 2375 |
"Test whether a path is a symbolic link"); |
| 2376 |
|
| 2377 |
#define OS__PATH_ISLINK_METHODDEF \ |
| 2378 |
{"_path_islink", _PyCFunction_CAST(os__path_islink), METH_FASTCALL|METH_KEYWORDS, os__path_islink__doc__}, |
| 2379 |
|
| 2380 |
static int |
| 2381 |
os__path_islink_impl(PyObject *module, path_t *path); |
| 2382 |
|
| 2383 |
static PyObject * |
| 2384 |
os__path_islink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2385 |
{ |
| 2386 |
PyObject *return_value = NULL; |
| 2387 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2388 |
|
| 2389 |
#define NUM_KEYWORDS 1 |
| 2390 |
static struct { |
| 2391 |
PyGC_Head _this_is_not_used; |
| 2392 |
PyObject_VAR_HEAD |
| 2393 |
Py_hash_t ob_hash; |
| 2394 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2395 |
} _kwtuple = { |
| 2396 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2397 |
.ob_hash = -1, |
| 2398 |
.ob_item = { &_Py_ID(path), }, |
| 2399 |
}; |
| 2400 |
#undef NUM_KEYWORDS |
| 2401 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2402 |
|
| 2403 |
#else // !Py_BUILD_CORE |
| 2404 |
# define KWTUPLE NULL |
| 2405 |
#endif // !Py_BUILD_CORE |
| 2406 |
|
| 2407 |
static const char * const _keywords[] = {"path", NULL}; |
| 2408 |
static _PyArg_Parser _parser = { |
| 2409 |
.keywords = _keywords, |
| 2410 |
.fname = "_path_islink", |
| 2411 |
.kwtuple = KWTUPLE, |
| 2412 |
}; |
| 2413 |
#undef KWTUPLE |
| 2414 |
PyObject *argsbuf[1]; |
| 2415 |
path_t path = PATH_T_INITIALIZE_P("_path_islink", "path", 0, 0, 1, 1); |
| 2416 |
int _return_value; |
| 2417 |
|
| 2418 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2419 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2420 |
if (!args) { |
| 2421 |
goto exit; |
| 2422 |
} |
| 2423 |
if (!path_converter(args[0], &path)) { |
| 2424 |
goto exit; |
| 2425 |
} |
| 2426 |
_return_value = os__path_islink_impl(module, &path); |
| 2427 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 2428 |
goto exit; |
| 2429 |
} |
| 2430 |
return_value = PyBool_FromLong((long)_return_value); |
| 2431 |
|
| 2432 |
exit: |
| 2433 |
/* Cleanup for path */ |
| 2434 |
path_cleanup(&path); |
| 2435 |
|
| 2436 |
return return_value; |
| 2437 |
} |
| 2438 |
|
| 2439 |
#endif /* defined(MS_WINDOWS) */ |
| 2440 |
|
| 2441 |
#if defined(MS_WINDOWS) |
| 2442 |
|
| 2443 |
PyDoc_STRVAR(os__path_isjunction__doc__, |
| 2444 |
"_path_isjunction($module, /, path)\n" |
| 2445 |
"--\n" |
| 2446 |
"\n" |
| 2447 |
"Test whether a path is a junction"); |
| 2448 |
|
| 2449 |
#define OS__PATH_ISJUNCTION_METHODDEF \ |
| 2450 |
{"_path_isjunction", _PyCFunction_CAST(os__path_isjunction), METH_FASTCALL|METH_KEYWORDS, os__path_isjunction__doc__}, |
| 2451 |
|
| 2452 |
static int |
| 2453 |
os__path_isjunction_impl(PyObject *module, path_t *path); |
| 2454 |
|
| 2455 |
static PyObject * |
| 2456 |
os__path_isjunction(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2457 |
{ |
| 2458 |
PyObject *return_value = NULL; |
| 2459 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2460 |
|
| 2461 |
#define NUM_KEYWORDS 1 |
| 2462 |
static struct { |
| 2463 |
PyGC_Head _this_is_not_used; |
| 2464 |
PyObject_VAR_HEAD |
| 2465 |
Py_hash_t ob_hash; |
| 2466 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2467 |
} _kwtuple = { |
| 2468 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2469 |
.ob_hash = -1, |
| 2470 |
.ob_item = { &_Py_ID(path), }, |
| 2471 |
}; |
| 2472 |
#undef NUM_KEYWORDS |
| 2473 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2474 |
|
| 2475 |
#else // !Py_BUILD_CORE |
| 2476 |
# define KWTUPLE NULL |
| 2477 |
#endif // !Py_BUILD_CORE |
| 2478 |
|
| 2479 |
static const char * const _keywords[] = {"path", NULL}; |
| 2480 |
static _PyArg_Parser _parser = { |
| 2481 |
.keywords = _keywords, |
| 2482 |
.fname = "_path_isjunction", |
| 2483 |
.kwtuple = KWTUPLE, |
| 2484 |
}; |
| 2485 |
#undef KWTUPLE |
| 2486 |
PyObject *argsbuf[1]; |
| 2487 |
path_t path = PATH_T_INITIALIZE_P("_path_isjunction", "path", 0, 0, 1, 1); |
| 2488 |
int _return_value; |
| 2489 |
|
| 2490 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2491 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2492 |
if (!args) { |
| 2493 |
goto exit; |
| 2494 |
} |
| 2495 |
if (!path_converter(args[0], &path)) { |
| 2496 |
goto exit; |
| 2497 |
} |
| 2498 |
_return_value = os__path_isjunction_impl(module, &path); |
| 2499 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 2500 |
goto exit; |
| 2501 |
} |
| 2502 |
return_value = PyBool_FromLong((long)_return_value); |
| 2503 |
|
| 2504 |
exit: |
| 2505 |
/* Cleanup for path */ |
| 2506 |
path_cleanup(&path); |
| 2507 |
|
| 2508 |
return return_value; |
| 2509 |
} |
| 2510 |
|
| 2511 |
#endif /* defined(MS_WINDOWS) */ |
| 2512 |
|
| 2513 |
PyDoc_STRVAR(os__path_splitroot_ex__doc__, |
| 2514 |
"_path_splitroot_ex($module, /, p)\n" |
| 2515 |
"--\n" |
| 2516 |
"\n" |
| 2517 |
"Split a pathname into drive, root and tail.\n" |
| 2518 |
"\n" |
| 2519 |
"The tail contains anything after the root."); |
| 2520 |
|
| 2521 |
#define OS__PATH_SPLITROOT_EX_METHODDEF \ |
| 2522 |
{"_path_splitroot_ex", _PyCFunction_CAST(os__path_splitroot_ex), METH_FASTCALL|METH_KEYWORDS, os__path_splitroot_ex__doc__}, |
| 2523 |
|
| 2524 |
static PyObject * |
| 2525 |
os__path_splitroot_ex_impl(PyObject *module, path_t *path); |
| 2526 |
|
| 2527 |
static PyObject * |
| 2528 |
os__path_splitroot_ex(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2529 |
{ |
| 2530 |
PyObject *return_value = NULL; |
| 2531 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2532 |
|
| 2533 |
#define NUM_KEYWORDS 1 |
| 2534 |
static struct { |
| 2535 |
PyGC_Head _this_is_not_used; |
| 2536 |
PyObject_VAR_HEAD |
| 2537 |
Py_hash_t ob_hash; |
| 2538 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2539 |
} _kwtuple = { |
| 2540 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2541 |
.ob_hash = -1, |
| 2542 |
.ob_item = { _Py_LATIN1_CHR('p'), }, |
| 2543 |
}; |
| 2544 |
#undef NUM_KEYWORDS |
| 2545 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2546 |
|
| 2547 |
#else // !Py_BUILD_CORE |
| 2548 |
# define KWTUPLE NULL |
| 2549 |
#endif // !Py_BUILD_CORE |
| 2550 |
|
| 2551 |
static const char * const _keywords[] = {"p", NULL}; |
| 2552 |
static _PyArg_Parser _parser = { |
| 2553 |
.keywords = _keywords, |
| 2554 |
.fname = "_path_splitroot_ex", |
| 2555 |
.kwtuple = KWTUPLE, |
| 2556 |
}; |
| 2557 |
#undef KWTUPLE |
| 2558 |
PyObject *argsbuf[1]; |
| 2559 |
path_t path = PATH_T_INITIALIZE("_path_splitroot_ex", "path", 0, 1, 1, 0, 0); |
| 2560 |
|
| 2561 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2562 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2563 |
if (!args) { |
| 2564 |
goto exit; |
| 2565 |
} |
| 2566 |
if (!path_converter(args[0], &path)) { |
| 2567 |
goto exit; |
| 2568 |
} |
| 2569 |
return_value = os__path_splitroot_ex_impl(module, &path); |
| 2570 |
|
| 2571 |
exit: |
| 2572 |
/* Cleanup for path */ |
| 2573 |
path_cleanup(&path); |
| 2574 |
|
| 2575 |
return return_value; |
| 2576 |
} |
| 2577 |
|
| 2578 |
PyDoc_STRVAR(os__path_normpath__doc__, |
| 2579 |
"_path_normpath($module, /, path)\n" |
| 2580 |
"--\n" |
| 2581 |
"\n" |
| 2582 |
"Normalize path, eliminating double slashes, etc."); |
| 2583 |
|
| 2584 |
#define OS__PATH_NORMPATH_METHODDEF \ |
| 2585 |
{"_path_normpath", _PyCFunction_CAST(os__path_normpath), METH_FASTCALL|METH_KEYWORDS, os__path_normpath__doc__}, |
| 2586 |
|
| 2587 |
static PyObject * |
| 2588 |
os__path_normpath_impl(PyObject *module, path_t *path); |
| 2589 |
|
| 2590 |
static PyObject * |
| 2591 |
os__path_normpath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2592 |
{ |
| 2593 |
PyObject *return_value = NULL; |
| 2594 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2595 |
|
| 2596 |
#define NUM_KEYWORDS 1 |
| 2597 |
static struct { |
| 2598 |
PyGC_Head _this_is_not_used; |
| 2599 |
PyObject_VAR_HEAD |
| 2600 |
Py_hash_t ob_hash; |
| 2601 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2602 |
} _kwtuple = { |
| 2603 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2604 |
.ob_hash = -1, |
| 2605 |
.ob_item = { &_Py_ID(path), }, |
| 2606 |
}; |
| 2607 |
#undef NUM_KEYWORDS |
| 2608 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2609 |
|
| 2610 |
#else // !Py_BUILD_CORE |
| 2611 |
# define KWTUPLE NULL |
| 2612 |
#endif // !Py_BUILD_CORE |
| 2613 |
|
| 2614 |
static const char * const _keywords[] = {"path", NULL}; |
| 2615 |
static _PyArg_Parser _parser = { |
| 2616 |
.keywords = _keywords, |
| 2617 |
.fname = "_path_normpath", |
| 2618 |
.kwtuple = KWTUPLE, |
| 2619 |
}; |
| 2620 |
#undef KWTUPLE |
| 2621 |
PyObject *argsbuf[1]; |
| 2622 |
path_t path = PATH_T_INITIALIZE("_path_normpath", "path", 0, 1, 1, 0, 0); |
| 2623 |
|
| 2624 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2625 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2626 |
if (!args) { |
| 2627 |
goto exit; |
| 2628 |
} |
| 2629 |
if (!path_converter(args[0], &path)) { |
| 2630 |
goto exit; |
| 2631 |
} |
| 2632 |
return_value = os__path_normpath_impl(module, &path); |
| 2633 |
|
| 2634 |
exit: |
| 2635 |
/* Cleanup for path */ |
| 2636 |
path_cleanup(&path); |
| 2637 |
|
| 2638 |
return return_value; |
| 2639 |
} |
| 2640 |
|
| 2641 |
PyDoc_STRVAR(os_mkdir__doc__, |
| 2642 |
"mkdir($module, /, path, mode=511, *, dir_fd=None)\n" |
| 2643 |
"--\n" |
| 2644 |
"\n" |
| 2645 |
"Create a directory.\n" |
| 2646 |
"\n" |
| 2647 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 2648 |
" and path should be relative; path will then be relative to that directory.\n" |
| 2649 |
"dir_fd may not be implemented on your platform.\n" |
| 2650 |
" If it is unavailable, using it will raise a NotImplementedError.\n" |
| 2651 |
"\n" |
| 2652 |
"The mode argument is ignored on Windows. Where it is used, the current umask\n" |
| 2653 |
"value is first masked out."); |
| 2654 |
|
| 2655 |
#define OS_MKDIR_METHODDEF \ |
| 2656 |
{"mkdir", _PyCFunction_CAST(os_mkdir), METH_FASTCALL|METH_KEYWORDS, os_mkdir__doc__}, |
| 2657 |
|
| 2658 |
static PyObject * |
| 2659 |
os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd); |
| 2660 |
|
| 2661 |
static PyObject * |
| 2662 |
os_mkdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2663 |
{ |
| 2664 |
PyObject *return_value = NULL; |
| 2665 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2666 |
|
| 2667 |
#define NUM_KEYWORDS 3 |
| 2668 |
static struct { |
| 2669 |
PyGC_Head _this_is_not_used; |
| 2670 |
PyObject_VAR_HEAD |
| 2671 |
Py_hash_t ob_hash; |
| 2672 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2673 |
} _kwtuple = { |
| 2674 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2675 |
.ob_hash = -1, |
| 2676 |
.ob_item = { &_Py_ID(path), &_Py_ID(mode), &_Py_ID(dir_fd), }, |
| 2677 |
}; |
| 2678 |
#undef NUM_KEYWORDS |
| 2679 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2680 |
|
| 2681 |
#else // !Py_BUILD_CORE |
| 2682 |
# define KWTUPLE NULL |
| 2683 |
#endif // !Py_BUILD_CORE |
| 2684 |
|
| 2685 |
static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; |
| 2686 |
static _PyArg_Parser _parser = { |
| 2687 |
.keywords = _keywords, |
| 2688 |
.fname = "mkdir", |
| 2689 |
.kwtuple = KWTUPLE, |
| 2690 |
}; |
| 2691 |
#undef KWTUPLE |
| 2692 |
PyObject *argsbuf[3]; |
| 2693 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 2694 |
path_t path = PATH_T_INITIALIZE_P("mkdir", "path", 0, 0, 0, 0); |
| 2695 |
int mode = 511; |
| 2696 |
int dir_fd = DEFAULT_DIR_FD; |
| 2697 |
|
| 2698 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2699 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2700 |
if (!args) { |
| 2701 |
goto exit; |
| 2702 |
} |
| 2703 |
if (!path_converter(args[0], &path)) { |
| 2704 |
goto exit; |
| 2705 |
} |
| 2706 |
if (!noptargs) { |
| 2707 |
goto skip_optional_pos; |
| 2708 |
} |
| 2709 |
if (args[1]) { |
| 2710 |
mode = PyLong_AsInt(args[1]); |
| 2711 |
if (mode == -1 && PyErr_Occurred()) { |
| 2712 |
goto exit; |
| 2713 |
} |
| 2714 |
if (!--noptargs) { |
| 2715 |
goto skip_optional_pos; |
| 2716 |
} |
| 2717 |
} |
| 2718 |
skip_optional_pos: |
| 2719 |
if (!noptargs) { |
| 2720 |
goto skip_optional_kwonly; |
| 2721 |
} |
| 2722 |
if (!MKDIRAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { |
| 2723 |
goto exit; |
| 2724 |
} |
| 2725 |
skip_optional_kwonly: |
| 2726 |
return_value = os_mkdir_impl(module, &path, mode, dir_fd); |
| 2727 |
|
| 2728 |
exit: |
| 2729 |
/* Cleanup for path */ |
| 2730 |
path_cleanup(&path); |
| 2731 |
|
| 2732 |
return return_value; |
| 2733 |
} |
| 2734 |
|
| 2735 |
#if defined(HAVE_NICE) |
| 2736 |
|
| 2737 |
PyDoc_STRVAR(os_nice__doc__, |
| 2738 |
"nice($module, increment, /)\n" |
| 2739 |
"--\n" |
| 2740 |
"\n" |
| 2741 |
"Add increment to the priority of process and return the new priority."); |
| 2742 |
|
| 2743 |
#define OS_NICE_METHODDEF \ |
| 2744 |
{"nice", (PyCFunction)os_nice, METH_O, os_nice__doc__}, |
| 2745 |
|
| 2746 |
static PyObject * |
| 2747 |
os_nice_impl(PyObject *module, int increment); |
| 2748 |
|
| 2749 |
static PyObject * |
| 2750 |
os_nice(PyObject *module, PyObject *arg) |
| 2751 |
{ |
| 2752 |
PyObject *return_value = NULL; |
| 2753 |
int increment; |
| 2754 |
|
| 2755 |
increment = PyLong_AsInt(arg); |
| 2756 |
if (increment == -1 && PyErr_Occurred()) { |
| 2757 |
goto exit; |
| 2758 |
} |
| 2759 |
return_value = os_nice_impl(module, increment); |
| 2760 |
|
| 2761 |
exit: |
| 2762 |
return return_value; |
| 2763 |
} |
| 2764 |
|
| 2765 |
#endif /* defined(HAVE_NICE) */ |
| 2766 |
|
| 2767 |
#if defined(HAVE_GETPRIORITY) |
| 2768 |
|
| 2769 |
PyDoc_STRVAR(os_getpriority__doc__, |
| 2770 |
"getpriority($module, /, which, who)\n" |
| 2771 |
"--\n" |
| 2772 |
"\n" |
| 2773 |
"Return program scheduling priority."); |
| 2774 |
|
| 2775 |
#define OS_GETPRIORITY_METHODDEF \ |
| 2776 |
{"getpriority", _PyCFunction_CAST(os_getpriority), METH_FASTCALL|METH_KEYWORDS, os_getpriority__doc__}, |
| 2777 |
|
| 2778 |
static PyObject * |
| 2779 |
os_getpriority_impl(PyObject *module, int which, int who); |
| 2780 |
|
| 2781 |
static PyObject * |
| 2782 |
os_getpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2783 |
{ |
| 2784 |
PyObject *return_value = NULL; |
| 2785 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2786 |
|
| 2787 |
#define NUM_KEYWORDS 2 |
| 2788 |
static struct { |
| 2789 |
PyGC_Head _this_is_not_used; |
| 2790 |
PyObject_VAR_HEAD |
| 2791 |
Py_hash_t ob_hash; |
| 2792 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2793 |
} _kwtuple = { |
| 2794 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2795 |
.ob_hash = -1, |
| 2796 |
.ob_item = { &_Py_ID(which), &_Py_ID(who), }, |
| 2797 |
}; |
| 2798 |
#undef NUM_KEYWORDS |
| 2799 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2800 |
|
| 2801 |
#else // !Py_BUILD_CORE |
| 2802 |
# define KWTUPLE NULL |
| 2803 |
#endif // !Py_BUILD_CORE |
| 2804 |
|
| 2805 |
static const char * const _keywords[] = {"which", "who", NULL}; |
| 2806 |
static _PyArg_Parser _parser = { |
| 2807 |
.keywords = _keywords, |
| 2808 |
.fname = "getpriority", |
| 2809 |
.kwtuple = KWTUPLE, |
| 2810 |
}; |
| 2811 |
#undef KWTUPLE |
| 2812 |
PyObject *argsbuf[2]; |
| 2813 |
int which; |
| 2814 |
int who; |
| 2815 |
|
| 2816 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2817 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2818 |
if (!args) { |
| 2819 |
goto exit; |
| 2820 |
} |
| 2821 |
which = PyLong_AsInt(args[0]); |
| 2822 |
if (which == -1 && PyErr_Occurred()) { |
| 2823 |
goto exit; |
| 2824 |
} |
| 2825 |
who = PyLong_AsInt(args[1]); |
| 2826 |
if (who == -1 && PyErr_Occurred()) { |
| 2827 |
goto exit; |
| 2828 |
} |
| 2829 |
return_value = os_getpriority_impl(module, which, who); |
| 2830 |
|
| 2831 |
exit: |
| 2832 |
return return_value; |
| 2833 |
} |
| 2834 |
|
| 2835 |
#endif /* defined(HAVE_GETPRIORITY) */ |
| 2836 |
|
| 2837 |
#if defined(HAVE_SETPRIORITY) |
| 2838 |
|
| 2839 |
PyDoc_STRVAR(os_setpriority__doc__, |
| 2840 |
"setpriority($module, /, which, who, priority)\n" |
| 2841 |
"--\n" |
| 2842 |
"\n" |
| 2843 |
"Set program scheduling priority."); |
| 2844 |
|
| 2845 |
#define OS_SETPRIORITY_METHODDEF \ |
| 2846 |
{"setpriority", _PyCFunction_CAST(os_setpriority), METH_FASTCALL|METH_KEYWORDS, os_setpriority__doc__}, |
| 2847 |
|
| 2848 |
static PyObject * |
| 2849 |
os_setpriority_impl(PyObject *module, int which, int who, int priority); |
| 2850 |
|
| 2851 |
static PyObject * |
| 2852 |
os_setpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2853 |
{ |
| 2854 |
PyObject *return_value = NULL; |
| 2855 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2856 |
|
| 2857 |
#define NUM_KEYWORDS 3 |
| 2858 |
static struct { |
| 2859 |
PyGC_Head _this_is_not_used; |
| 2860 |
PyObject_VAR_HEAD |
| 2861 |
Py_hash_t ob_hash; |
| 2862 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2863 |
} _kwtuple = { |
| 2864 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2865 |
.ob_hash = -1, |
| 2866 |
.ob_item = { &_Py_ID(which), &_Py_ID(who), &_Py_ID(priority), }, |
| 2867 |
}; |
| 2868 |
#undef NUM_KEYWORDS |
| 2869 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2870 |
|
| 2871 |
#else // !Py_BUILD_CORE |
| 2872 |
# define KWTUPLE NULL |
| 2873 |
#endif // !Py_BUILD_CORE |
| 2874 |
|
| 2875 |
static const char * const _keywords[] = {"which", "who", "priority", NULL}; |
| 2876 |
static _PyArg_Parser _parser = { |
| 2877 |
.keywords = _keywords, |
| 2878 |
.fname = "setpriority", |
| 2879 |
.kwtuple = KWTUPLE, |
| 2880 |
}; |
| 2881 |
#undef KWTUPLE |
| 2882 |
PyObject *argsbuf[3]; |
| 2883 |
int which; |
| 2884 |
int who; |
| 2885 |
int priority; |
| 2886 |
|
| 2887 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2888 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2889 |
if (!args) { |
| 2890 |
goto exit; |
| 2891 |
} |
| 2892 |
which = PyLong_AsInt(args[0]); |
| 2893 |
if (which == -1 && PyErr_Occurred()) { |
| 2894 |
goto exit; |
| 2895 |
} |
| 2896 |
who = PyLong_AsInt(args[1]); |
| 2897 |
if (who == -1 && PyErr_Occurred()) { |
| 2898 |
goto exit; |
| 2899 |
} |
| 2900 |
priority = PyLong_AsInt(args[2]); |
| 2901 |
if (priority == -1 && PyErr_Occurred()) { |
| 2902 |
goto exit; |
| 2903 |
} |
| 2904 |
return_value = os_setpriority_impl(module, which, who, priority); |
| 2905 |
|
| 2906 |
exit: |
| 2907 |
return return_value; |
| 2908 |
} |
| 2909 |
|
| 2910 |
#endif /* defined(HAVE_SETPRIORITY) */ |
| 2911 |
|
| 2912 |
PyDoc_STRVAR(os_rename__doc__, |
| 2913 |
"rename($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" |
| 2914 |
"--\n" |
| 2915 |
"\n" |
| 2916 |
"Rename a file or directory.\n" |
| 2917 |
"\n" |
| 2918 |
"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" |
| 2919 |
" descriptor open to a directory, and the respective path string (src or dst)\n" |
| 2920 |
" should be relative; the path will then be relative to that directory.\n" |
| 2921 |
"src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" |
| 2922 |
" If they are unavailable, using them will raise a NotImplementedError."); |
| 2923 |
|
| 2924 |
#define OS_RENAME_METHODDEF \ |
| 2925 |
{"rename", _PyCFunction_CAST(os_rename), METH_FASTCALL|METH_KEYWORDS, os_rename__doc__}, |
| 2926 |
|
| 2927 |
static PyObject * |
| 2928 |
os_rename_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, |
| 2929 |
int dst_dir_fd); |
| 2930 |
|
| 2931 |
static PyObject * |
| 2932 |
os_rename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 2933 |
{ |
| 2934 |
PyObject *return_value = NULL; |
| 2935 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 2936 |
|
| 2937 |
#define NUM_KEYWORDS 4 |
| 2938 |
static struct { |
| 2939 |
PyGC_Head _this_is_not_used; |
| 2940 |
PyObject_VAR_HEAD |
| 2941 |
Py_hash_t ob_hash; |
| 2942 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 2943 |
} _kwtuple = { |
| 2944 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 2945 |
.ob_hash = -1, |
| 2946 |
.ob_item = { &_Py_ID(src), &_Py_ID(dst), &_Py_ID(src_dir_fd), &_Py_ID(dst_dir_fd), }, |
| 2947 |
}; |
| 2948 |
#undef NUM_KEYWORDS |
| 2949 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 2950 |
|
| 2951 |
#else // !Py_BUILD_CORE |
| 2952 |
# define KWTUPLE NULL |
| 2953 |
#endif // !Py_BUILD_CORE |
| 2954 |
|
| 2955 |
static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; |
| 2956 |
static _PyArg_Parser _parser = { |
| 2957 |
.keywords = _keywords, |
| 2958 |
.fname = "rename", |
| 2959 |
.kwtuple = KWTUPLE, |
| 2960 |
}; |
| 2961 |
#undef KWTUPLE |
| 2962 |
PyObject *argsbuf[4]; |
| 2963 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 2964 |
path_t src = PATH_T_INITIALIZE_P("rename", "src", 0, 0, 0, 0); |
| 2965 |
path_t dst = PATH_T_INITIALIZE_P("rename", "dst", 0, 0, 0, 0); |
| 2966 |
int src_dir_fd = DEFAULT_DIR_FD; |
| 2967 |
int dst_dir_fd = DEFAULT_DIR_FD; |
| 2968 |
|
| 2969 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 2970 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 2971 |
if (!args) { |
| 2972 |
goto exit; |
| 2973 |
} |
| 2974 |
if (!path_converter(args[0], &src)) { |
| 2975 |
goto exit; |
| 2976 |
} |
| 2977 |
if (!path_converter(args[1], &dst)) { |
| 2978 |
goto exit; |
| 2979 |
} |
| 2980 |
if (!noptargs) { |
| 2981 |
goto skip_optional_kwonly; |
| 2982 |
} |
| 2983 |
if (args[2]) { |
| 2984 |
if (!dir_fd_converter(args[2], &src_dir_fd)) { |
| 2985 |
goto exit; |
| 2986 |
} |
| 2987 |
if (!--noptargs) { |
| 2988 |
goto skip_optional_kwonly; |
| 2989 |
} |
| 2990 |
} |
| 2991 |
if (!dir_fd_converter(args[3], &dst_dir_fd)) { |
| 2992 |
goto exit; |
| 2993 |
} |
| 2994 |
skip_optional_kwonly: |
| 2995 |
return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); |
| 2996 |
|
| 2997 |
exit: |
| 2998 |
/* Cleanup for src */ |
| 2999 |
path_cleanup(&src); |
| 3000 |
/* Cleanup for dst */ |
| 3001 |
path_cleanup(&dst); |
| 3002 |
|
| 3003 |
return return_value; |
| 3004 |
} |
| 3005 |
|
| 3006 |
PyDoc_STRVAR(os_replace__doc__, |
| 3007 |
"replace($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" |
| 3008 |
"--\n" |
| 3009 |
"\n" |
| 3010 |
"Rename a file or directory, overwriting the destination.\n" |
| 3011 |
"\n" |
| 3012 |
"If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" |
| 3013 |
" descriptor open to a directory, and the respective path string (src or dst)\n" |
| 3014 |
" should be relative; the path will then be relative to that directory.\n" |
| 3015 |
"src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" |
| 3016 |
" If they are unavailable, using them will raise a NotImplementedError."); |
| 3017 |
|
| 3018 |
#define OS_REPLACE_METHODDEF \ |
| 3019 |
{"replace", _PyCFunction_CAST(os_replace), METH_FASTCALL|METH_KEYWORDS, os_replace__doc__}, |
| 3020 |
|
| 3021 |
static PyObject * |
| 3022 |
os_replace_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, |
| 3023 |
int dst_dir_fd); |
| 3024 |
|
| 3025 |
static PyObject * |
| 3026 |
os_replace(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3027 |
{ |
| 3028 |
PyObject *return_value = NULL; |
| 3029 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3030 |
|
| 3031 |
#define NUM_KEYWORDS 4 |
| 3032 |
static struct { |
| 3033 |
PyGC_Head _this_is_not_used; |
| 3034 |
PyObject_VAR_HEAD |
| 3035 |
Py_hash_t ob_hash; |
| 3036 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3037 |
} _kwtuple = { |
| 3038 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3039 |
.ob_hash = -1, |
| 3040 |
.ob_item = { &_Py_ID(src), &_Py_ID(dst), &_Py_ID(src_dir_fd), &_Py_ID(dst_dir_fd), }, |
| 3041 |
}; |
| 3042 |
#undef NUM_KEYWORDS |
| 3043 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3044 |
|
| 3045 |
#else // !Py_BUILD_CORE |
| 3046 |
# define KWTUPLE NULL |
| 3047 |
#endif // !Py_BUILD_CORE |
| 3048 |
|
| 3049 |
static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; |
| 3050 |
static _PyArg_Parser _parser = { |
| 3051 |
.keywords = _keywords, |
| 3052 |
.fname = "replace", |
| 3053 |
.kwtuple = KWTUPLE, |
| 3054 |
}; |
| 3055 |
#undef KWTUPLE |
| 3056 |
PyObject *argsbuf[4]; |
| 3057 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 3058 |
path_t src = PATH_T_INITIALIZE_P("replace", "src", 0, 0, 0, 0); |
| 3059 |
path_t dst = PATH_T_INITIALIZE_P("replace", "dst", 0, 0, 0, 0); |
| 3060 |
int src_dir_fd = DEFAULT_DIR_FD; |
| 3061 |
int dst_dir_fd = DEFAULT_DIR_FD; |
| 3062 |
|
| 3063 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3064 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3065 |
if (!args) { |
| 3066 |
goto exit; |
| 3067 |
} |
| 3068 |
if (!path_converter(args[0], &src)) { |
| 3069 |
goto exit; |
| 3070 |
} |
| 3071 |
if (!path_converter(args[1], &dst)) { |
| 3072 |
goto exit; |
| 3073 |
} |
| 3074 |
if (!noptargs) { |
| 3075 |
goto skip_optional_kwonly; |
| 3076 |
} |
| 3077 |
if (args[2]) { |
| 3078 |
if (!dir_fd_converter(args[2], &src_dir_fd)) { |
| 3079 |
goto exit; |
| 3080 |
} |
| 3081 |
if (!--noptargs) { |
| 3082 |
goto skip_optional_kwonly; |
| 3083 |
} |
| 3084 |
} |
| 3085 |
if (!dir_fd_converter(args[3], &dst_dir_fd)) { |
| 3086 |
goto exit; |
| 3087 |
} |
| 3088 |
skip_optional_kwonly: |
| 3089 |
return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); |
| 3090 |
|
| 3091 |
exit: |
| 3092 |
/* Cleanup for src */ |
| 3093 |
path_cleanup(&src); |
| 3094 |
/* Cleanup for dst */ |
| 3095 |
path_cleanup(&dst); |
| 3096 |
|
| 3097 |
return return_value; |
| 3098 |
} |
| 3099 |
|
| 3100 |
PyDoc_STRVAR(os_rmdir__doc__, |
| 3101 |
"rmdir($module, /, path, *, dir_fd=None)\n" |
| 3102 |
"--\n" |
| 3103 |
"\n" |
| 3104 |
"Remove a directory.\n" |
| 3105 |
"\n" |
| 3106 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 3107 |
" and path should be relative; path will then be relative to that directory.\n" |
| 3108 |
"dir_fd may not be implemented on your platform.\n" |
| 3109 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 3110 |
|
| 3111 |
#define OS_RMDIR_METHODDEF \ |
| 3112 |
{"rmdir", _PyCFunction_CAST(os_rmdir), METH_FASTCALL|METH_KEYWORDS, os_rmdir__doc__}, |
| 3113 |
|
| 3114 |
static PyObject * |
| 3115 |
os_rmdir_impl(PyObject *module, path_t *path, int dir_fd); |
| 3116 |
|
| 3117 |
static PyObject * |
| 3118 |
os_rmdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3119 |
{ |
| 3120 |
PyObject *return_value = NULL; |
| 3121 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3122 |
|
| 3123 |
#define NUM_KEYWORDS 2 |
| 3124 |
static struct { |
| 3125 |
PyGC_Head _this_is_not_used; |
| 3126 |
PyObject_VAR_HEAD |
| 3127 |
Py_hash_t ob_hash; |
| 3128 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3129 |
} _kwtuple = { |
| 3130 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3131 |
.ob_hash = -1, |
| 3132 |
.ob_item = { &_Py_ID(path), &_Py_ID(dir_fd), }, |
| 3133 |
}; |
| 3134 |
#undef NUM_KEYWORDS |
| 3135 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3136 |
|
| 3137 |
#else // !Py_BUILD_CORE |
| 3138 |
# define KWTUPLE NULL |
| 3139 |
#endif // !Py_BUILD_CORE |
| 3140 |
|
| 3141 |
static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
| 3142 |
static _PyArg_Parser _parser = { |
| 3143 |
.keywords = _keywords, |
| 3144 |
.fname = "rmdir", |
| 3145 |
.kwtuple = KWTUPLE, |
| 3146 |
}; |
| 3147 |
#undef KWTUPLE |
| 3148 |
PyObject *argsbuf[2]; |
| 3149 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 3150 |
path_t path = PATH_T_INITIALIZE_P("rmdir", "path", 0, 0, 0, 0); |
| 3151 |
int dir_fd = DEFAULT_DIR_FD; |
| 3152 |
|
| 3153 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3154 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3155 |
if (!args) { |
| 3156 |
goto exit; |
| 3157 |
} |
| 3158 |
if (!path_converter(args[0], &path)) { |
| 3159 |
goto exit; |
| 3160 |
} |
| 3161 |
if (!noptargs) { |
| 3162 |
goto skip_optional_kwonly; |
| 3163 |
} |
| 3164 |
if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { |
| 3165 |
goto exit; |
| 3166 |
} |
| 3167 |
skip_optional_kwonly: |
| 3168 |
return_value = os_rmdir_impl(module, &path, dir_fd); |
| 3169 |
|
| 3170 |
exit: |
| 3171 |
/* Cleanup for path */ |
| 3172 |
path_cleanup(&path); |
| 3173 |
|
| 3174 |
return return_value; |
| 3175 |
} |
| 3176 |
|
| 3177 |
#if defined(HAVE_SYSTEM) && defined(MS_WINDOWS) |
| 3178 |
|
| 3179 |
PyDoc_STRVAR(os_system__doc__, |
| 3180 |
"system($module, /, command)\n" |
| 3181 |
"--\n" |
| 3182 |
"\n" |
| 3183 |
"Execute the command in a subshell."); |
| 3184 |
|
| 3185 |
#define OS_SYSTEM_METHODDEF \ |
| 3186 |
{"system", _PyCFunction_CAST(os_system), METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, |
| 3187 |
|
| 3188 |
static long |
| 3189 |
os_system_impl(PyObject *module, const wchar_t *command); |
| 3190 |
|
| 3191 |
static PyObject * |
| 3192 |
os_system(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3193 |
{ |
| 3194 |
PyObject *return_value = NULL; |
| 3195 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3196 |
|
| 3197 |
#define NUM_KEYWORDS 1 |
| 3198 |
static struct { |
| 3199 |
PyGC_Head _this_is_not_used; |
| 3200 |
PyObject_VAR_HEAD |
| 3201 |
Py_hash_t ob_hash; |
| 3202 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3203 |
} _kwtuple = { |
| 3204 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3205 |
.ob_hash = -1, |
| 3206 |
.ob_item = { &_Py_ID(command), }, |
| 3207 |
}; |
| 3208 |
#undef NUM_KEYWORDS |
| 3209 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3210 |
|
| 3211 |
#else // !Py_BUILD_CORE |
| 3212 |
# define KWTUPLE NULL |
| 3213 |
#endif // !Py_BUILD_CORE |
| 3214 |
|
| 3215 |
static const char * const _keywords[] = {"command", NULL}; |
| 3216 |
static _PyArg_Parser _parser = { |
| 3217 |
.keywords = _keywords, |
| 3218 |
.fname = "system", |
| 3219 |
.kwtuple = KWTUPLE, |
| 3220 |
}; |
| 3221 |
#undef KWTUPLE |
| 3222 |
PyObject *argsbuf[1]; |
| 3223 |
const wchar_t *command = NULL; |
| 3224 |
long _return_value; |
| 3225 |
|
| 3226 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3227 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3228 |
if (!args) { |
| 3229 |
goto exit; |
| 3230 |
} |
| 3231 |
if (!PyUnicode_Check(args[0])) { |
| 3232 |
_PyArg_BadArgument("system", "argument 'command'", "str", args[0]); |
| 3233 |
goto exit; |
| 3234 |
} |
| 3235 |
command = PyUnicode_AsWideCharString(args[0], NULL); |
| 3236 |
if (command == NULL) { |
| 3237 |
goto exit; |
| 3238 |
} |
| 3239 |
_return_value = os_system_impl(module, command); |
| 3240 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 3241 |
goto exit; |
| 3242 |
} |
| 3243 |
return_value = PyLong_FromLong(_return_value); |
| 3244 |
|
| 3245 |
exit: |
| 3246 |
/* Cleanup for command */ |
| 3247 |
PyMem_Free((void *)command); |
| 3248 |
|
| 3249 |
return return_value; |
| 3250 |
} |
| 3251 |
|
| 3252 |
#endif /* defined(HAVE_SYSTEM) && defined(MS_WINDOWS) */ |
| 3253 |
|
| 3254 |
#if defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) |
| 3255 |
|
| 3256 |
PyDoc_STRVAR(os_system__doc__, |
| 3257 |
"system($module, /, command)\n" |
| 3258 |
"--\n" |
| 3259 |
"\n" |
| 3260 |
"Execute the command in a subshell."); |
| 3261 |
|
| 3262 |
#define OS_SYSTEM_METHODDEF \ |
| 3263 |
{"system", _PyCFunction_CAST(os_system), METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, |
| 3264 |
|
| 3265 |
static long |
| 3266 |
os_system_impl(PyObject *module, PyObject *command); |
| 3267 |
|
| 3268 |
static PyObject * |
| 3269 |
os_system(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3270 |
{ |
| 3271 |
PyObject *return_value = NULL; |
| 3272 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3273 |
|
| 3274 |
#define NUM_KEYWORDS 1 |
| 3275 |
static struct { |
| 3276 |
PyGC_Head _this_is_not_used; |
| 3277 |
PyObject_VAR_HEAD |
| 3278 |
Py_hash_t ob_hash; |
| 3279 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3280 |
} _kwtuple = { |
| 3281 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3282 |
.ob_hash = -1, |
| 3283 |
.ob_item = { &_Py_ID(command), }, |
| 3284 |
}; |
| 3285 |
#undef NUM_KEYWORDS |
| 3286 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3287 |
|
| 3288 |
#else // !Py_BUILD_CORE |
| 3289 |
# define KWTUPLE NULL |
| 3290 |
#endif // !Py_BUILD_CORE |
| 3291 |
|
| 3292 |
static const char * const _keywords[] = {"command", NULL}; |
| 3293 |
static _PyArg_Parser _parser = { |
| 3294 |
.keywords = _keywords, |
| 3295 |
.fname = "system", |
| 3296 |
.kwtuple = KWTUPLE, |
| 3297 |
}; |
| 3298 |
#undef KWTUPLE |
| 3299 |
PyObject *argsbuf[1]; |
| 3300 |
PyObject *command = NULL; |
| 3301 |
long _return_value; |
| 3302 |
|
| 3303 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3304 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3305 |
if (!args) { |
| 3306 |
goto exit; |
| 3307 |
} |
| 3308 |
if (!PyUnicode_FSConverter(args[0], &command)) { |
| 3309 |
goto exit; |
| 3310 |
} |
| 3311 |
_return_value = os_system_impl(module, command); |
| 3312 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 3313 |
goto exit; |
| 3314 |
} |
| 3315 |
return_value = PyLong_FromLong(_return_value); |
| 3316 |
|
| 3317 |
exit: |
| 3318 |
/* Cleanup for command */ |
| 3319 |
Py_XDECREF(command); |
| 3320 |
|
| 3321 |
return return_value; |
| 3322 |
} |
| 3323 |
|
| 3324 |
#endif /* defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) */ |
| 3325 |
|
| 3326 |
#if defined(HAVE_UMASK) |
| 3327 |
|
| 3328 |
PyDoc_STRVAR(os_umask__doc__, |
| 3329 |
"umask($module, mask, /)\n" |
| 3330 |
"--\n" |
| 3331 |
"\n" |
| 3332 |
"Set the current numeric umask and return the previous umask."); |
| 3333 |
|
| 3334 |
#define OS_UMASK_METHODDEF \ |
| 3335 |
{"umask", (PyCFunction)os_umask, METH_O, os_umask__doc__}, |
| 3336 |
|
| 3337 |
static PyObject * |
| 3338 |
os_umask_impl(PyObject *module, int mask); |
| 3339 |
|
| 3340 |
static PyObject * |
| 3341 |
os_umask(PyObject *module, PyObject *arg) |
| 3342 |
{ |
| 3343 |
PyObject *return_value = NULL; |
| 3344 |
int mask; |
| 3345 |
|
| 3346 |
mask = PyLong_AsInt(arg); |
| 3347 |
if (mask == -1 && PyErr_Occurred()) { |
| 3348 |
goto exit; |
| 3349 |
} |
| 3350 |
return_value = os_umask_impl(module, mask); |
| 3351 |
|
| 3352 |
exit: |
| 3353 |
return return_value; |
| 3354 |
} |
| 3355 |
|
| 3356 |
#endif /* defined(HAVE_UMASK) */ |
| 3357 |
|
| 3358 |
PyDoc_STRVAR(os_unlink__doc__, |
| 3359 |
"unlink($module, /, path, *, dir_fd=None)\n" |
| 3360 |
"--\n" |
| 3361 |
"\n" |
| 3362 |
"Remove a file (same as remove()).\n" |
| 3363 |
"\n" |
| 3364 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 3365 |
" and path should be relative; path will then be relative to that directory.\n" |
| 3366 |
"dir_fd may not be implemented on your platform.\n" |
| 3367 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 3368 |
|
| 3369 |
#define OS_UNLINK_METHODDEF \ |
| 3370 |
{"unlink", _PyCFunction_CAST(os_unlink), METH_FASTCALL|METH_KEYWORDS, os_unlink__doc__}, |
| 3371 |
|
| 3372 |
static PyObject * |
| 3373 |
os_unlink_impl(PyObject *module, path_t *path, int dir_fd); |
| 3374 |
|
| 3375 |
static PyObject * |
| 3376 |
os_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3377 |
{ |
| 3378 |
PyObject *return_value = NULL; |
| 3379 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3380 |
|
| 3381 |
#define NUM_KEYWORDS 2 |
| 3382 |
static struct { |
| 3383 |
PyGC_Head _this_is_not_used; |
| 3384 |
PyObject_VAR_HEAD |
| 3385 |
Py_hash_t ob_hash; |
| 3386 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3387 |
} _kwtuple = { |
| 3388 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3389 |
.ob_hash = -1, |
| 3390 |
.ob_item = { &_Py_ID(path), &_Py_ID(dir_fd), }, |
| 3391 |
}; |
| 3392 |
#undef NUM_KEYWORDS |
| 3393 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3394 |
|
| 3395 |
#else // !Py_BUILD_CORE |
| 3396 |
# define KWTUPLE NULL |
| 3397 |
#endif // !Py_BUILD_CORE |
| 3398 |
|
| 3399 |
static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
| 3400 |
static _PyArg_Parser _parser = { |
| 3401 |
.keywords = _keywords, |
| 3402 |
.fname = "unlink", |
| 3403 |
.kwtuple = KWTUPLE, |
| 3404 |
}; |
| 3405 |
#undef KWTUPLE |
| 3406 |
PyObject *argsbuf[2]; |
| 3407 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 3408 |
path_t path = PATH_T_INITIALIZE_P("unlink", "path", 0, 0, 0, 0); |
| 3409 |
int dir_fd = DEFAULT_DIR_FD; |
| 3410 |
|
| 3411 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3412 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3413 |
if (!args) { |
| 3414 |
goto exit; |
| 3415 |
} |
| 3416 |
if (!path_converter(args[0], &path)) { |
| 3417 |
goto exit; |
| 3418 |
} |
| 3419 |
if (!noptargs) { |
| 3420 |
goto skip_optional_kwonly; |
| 3421 |
} |
| 3422 |
if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { |
| 3423 |
goto exit; |
| 3424 |
} |
| 3425 |
skip_optional_kwonly: |
| 3426 |
return_value = os_unlink_impl(module, &path, dir_fd); |
| 3427 |
|
| 3428 |
exit: |
| 3429 |
/* Cleanup for path */ |
| 3430 |
path_cleanup(&path); |
| 3431 |
|
| 3432 |
return return_value; |
| 3433 |
} |
| 3434 |
|
| 3435 |
PyDoc_STRVAR(os_remove__doc__, |
| 3436 |
"remove($module, /, path, *, dir_fd=None)\n" |
| 3437 |
"--\n" |
| 3438 |
"\n" |
| 3439 |
"Remove a file (same as unlink()).\n" |
| 3440 |
"\n" |
| 3441 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 3442 |
" and path should be relative; path will then be relative to that directory.\n" |
| 3443 |
"dir_fd may not be implemented on your platform.\n" |
| 3444 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 3445 |
|
| 3446 |
#define OS_REMOVE_METHODDEF \ |
| 3447 |
{"remove", _PyCFunction_CAST(os_remove), METH_FASTCALL|METH_KEYWORDS, os_remove__doc__}, |
| 3448 |
|
| 3449 |
static PyObject * |
| 3450 |
os_remove_impl(PyObject *module, path_t *path, int dir_fd); |
| 3451 |
|
| 3452 |
static PyObject * |
| 3453 |
os_remove(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3454 |
{ |
| 3455 |
PyObject *return_value = NULL; |
| 3456 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3457 |
|
| 3458 |
#define NUM_KEYWORDS 2 |
| 3459 |
static struct { |
| 3460 |
PyGC_Head _this_is_not_used; |
| 3461 |
PyObject_VAR_HEAD |
| 3462 |
Py_hash_t ob_hash; |
| 3463 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3464 |
} _kwtuple = { |
| 3465 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3466 |
.ob_hash = -1, |
| 3467 |
.ob_item = { &_Py_ID(path), &_Py_ID(dir_fd), }, |
| 3468 |
}; |
| 3469 |
#undef NUM_KEYWORDS |
| 3470 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3471 |
|
| 3472 |
#else // !Py_BUILD_CORE |
| 3473 |
# define KWTUPLE NULL |
| 3474 |
#endif // !Py_BUILD_CORE |
| 3475 |
|
| 3476 |
static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
| 3477 |
static _PyArg_Parser _parser = { |
| 3478 |
.keywords = _keywords, |
| 3479 |
.fname = "remove", |
| 3480 |
.kwtuple = KWTUPLE, |
| 3481 |
}; |
| 3482 |
#undef KWTUPLE |
| 3483 |
PyObject *argsbuf[2]; |
| 3484 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 3485 |
path_t path = PATH_T_INITIALIZE_P("remove", "path", 0, 0, 0, 0); |
| 3486 |
int dir_fd = DEFAULT_DIR_FD; |
| 3487 |
|
| 3488 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3489 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3490 |
if (!args) { |
| 3491 |
goto exit; |
| 3492 |
} |
| 3493 |
if (!path_converter(args[0], &path)) { |
| 3494 |
goto exit; |
| 3495 |
} |
| 3496 |
if (!noptargs) { |
| 3497 |
goto skip_optional_kwonly; |
| 3498 |
} |
| 3499 |
if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { |
| 3500 |
goto exit; |
| 3501 |
} |
| 3502 |
skip_optional_kwonly: |
| 3503 |
return_value = os_remove_impl(module, &path, dir_fd); |
| 3504 |
|
| 3505 |
exit: |
| 3506 |
/* Cleanup for path */ |
| 3507 |
path_cleanup(&path); |
| 3508 |
|
| 3509 |
return return_value; |
| 3510 |
} |
| 3511 |
|
| 3512 |
#if defined(HAVE_UNAME) |
| 3513 |
|
| 3514 |
PyDoc_STRVAR(os_uname__doc__, |
| 3515 |
"uname($module, /)\n" |
| 3516 |
"--\n" |
| 3517 |
"\n" |
| 3518 |
"Return an object identifying the current operating system.\n" |
| 3519 |
"\n" |
| 3520 |
"The object behaves like a named tuple with the following fields:\n" |
| 3521 |
" (sysname, nodename, release, version, machine)"); |
| 3522 |
|
| 3523 |
#define OS_UNAME_METHODDEF \ |
| 3524 |
{"uname", (PyCFunction)os_uname, METH_NOARGS, os_uname__doc__}, |
| 3525 |
|
| 3526 |
static PyObject * |
| 3527 |
os_uname_impl(PyObject *module); |
| 3528 |
|
| 3529 |
static PyObject * |
| 3530 |
os_uname(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 3531 |
{ |
| 3532 |
return os_uname_impl(module); |
| 3533 |
} |
| 3534 |
|
| 3535 |
#endif /* defined(HAVE_UNAME) */ |
| 3536 |
|
| 3537 |
PyDoc_STRVAR(os_utime__doc__, |
| 3538 |
"utime($module, /, path, times=None, *, ns=<unrepresentable>,\n" |
| 3539 |
" dir_fd=None, follow_symlinks=True)\n" |
| 3540 |
"--\n" |
| 3541 |
"\n" |
| 3542 |
"Set the access and modified time of path.\n" |
| 3543 |
"\n" |
| 3544 |
"path may always be specified as a string.\n" |
| 3545 |
"On some platforms, path may also be specified as an open file descriptor.\n" |
| 3546 |
" If this functionality is unavailable, using it raises an exception.\n" |
| 3547 |
"\n" |
| 3548 |
"If times is not None, it must be a tuple (atime, mtime);\n" |
| 3549 |
" atime and mtime should be expressed as float seconds since the epoch.\n" |
| 3550 |
"If ns is specified, it must be a tuple (atime_ns, mtime_ns);\n" |
| 3551 |
" atime_ns and mtime_ns should be expressed as integer nanoseconds\n" |
| 3552 |
" since the epoch.\n" |
| 3553 |
"If times is None and ns is unspecified, utime uses the current time.\n" |
| 3554 |
"Specifying tuples for both times and ns is an error.\n" |
| 3555 |
"\n" |
| 3556 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 3557 |
" and path should be relative; path will then be relative to that directory.\n" |
| 3558 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 3559 |
" link, utime will modify the symbolic link itself instead of the file the\n" |
| 3560 |
" link points to.\n" |
| 3561 |
"It is an error to use dir_fd or follow_symlinks when specifying path\n" |
| 3562 |
" as an open file descriptor.\n" |
| 3563 |
"dir_fd and follow_symlinks may not be available on your platform.\n" |
| 3564 |
" If they are unavailable, using them will raise a NotImplementedError."); |
| 3565 |
|
| 3566 |
#define OS_UTIME_METHODDEF \ |
| 3567 |
{"utime", _PyCFunction_CAST(os_utime), METH_FASTCALL|METH_KEYWORDS, os_utime__doc__}, |
| 3568 |
|
| 3569 |
static PyObject * |
| 3570 |
os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, |
| 3571 |
int dir_fd, int follow_symlinks); |
| 3572 |
|
| 3573 |
static PyObject * |
| 3574 |
os_utime(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3575 |
{ |
| 3576 |
PyObject *return_value = NULL; |
| 3577 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3578 |
|
| 3579 |
#define NUM_KEYWORDS 5 |
| 3580 |
static struct { |
| 3581 |
PyGC_Head _this_is_not_used; |
| 3582 |
PyObject_VAR_HEAD |
| 3583 |
Py_hash_t ob_hash; |
| 3584 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3585 |
} _kwtuple = { |
| 3586 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3587 |
.ob_hash = -1, |
| 3588 |
.ob_item = { &_Py_ID(path), &_Py_ID(times), &_Py_ID(ns), &_Py_ID(dir_fd), &_Py_ID(follow_symlinks), }, |
| 3589 |
}; |
| 3590 |
#undef NUM_KEYWORDS |
| 3591 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3592 |
|
| 3593 |
#else // !Py_BUILD_CORE |
| 3594 |
# define KWTUPLE NULL |
| 3595 |
#endif // !Py_BUILD_CORE |
| 3596 |
|
| 3597 |
static const char * const _keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; |
| 3598 |
static _PyArg_Parser _parser = { |
| 3599 |
.keywords = _keywords, |
| 3600 |
.fname = "utime", |
| 3601 |
.kwtuple = KWTUPLE, |
| 3602 |
}; |
| 3603 |
#undef KWTUPLE |
| 3604 |
PyObject *argsbuf[5]; |
| 3605 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 3606 |
path_t path = PATH_T_INITIALIZE_P("utime", "path", 0, 0, 0, PATH_UTIME_HAVE_FD); |
| 3607 |
PyObject *times = Py_None; |
| 3608 |
PyObject *ns = NULL; |
| 3609 |
int dir_fd = DEFAULT_DIR_FD; |
| 3610 |
int follow_symlinks = 1; |
| 3611 |
|
| 3612 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3613 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3614 |
if (!args) { |
| 3615 |
goto exit; |
| 3616 |
} |
| 3617 |
if (!path_converter(args[0], &path)) { |
| 3618 |
goto exit; |
| 3619 |
} |
| 3620 |
if (!noptargs) { |
| 3621 |
goto skip_optional_pos; |
| 3622 |
} |
| 3623 |
if (args[1]) { |
| 3624 |
times = args[1]; |
| 3625 |
if (!--noptargs) { |
| 3626 |
goto skip_optional_pos; |
| 3627 |
} |
| 3628 |
} |
| 3629 |
skip_optional_pos: |
| 3630 |
if (!noptargs) { |
| 3631 |
goto skip_optional_kwonly; |
| 3632 |
} |
| 3633 |
if (args[2]) { |
| 3634 |
ns = args[2]; |
| 3635 |
if (!--noptargs) { |
| 3636 |
goto skip_optional_kwonly; |
| 3637 |
} |
| 3638 |
} |
| 3639 |
if (args[3]) { |
| 3640 |
if (!FUTIMENSAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { |
| 3641 |
goto exit; |
| 3642 |
} |
| 3643 |
if (!--noptargs) { |
| 3644 |
goto skip_optional_kwonly; |
| 3645 |
} |
| 3646 |
} |
| 3647 |
follow_symlinks = PyObject_IsTrue(args[4]); |
| 3648 |
if (follow_symlinks < 0) { |
| 3649 |
goto exit; |
| 3650 |
} |
| 3651 |
skip_optional_kwonly: |
| 3652 |
return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); |
| 3653 |
|
| 3654 |
exit: |
| 3655 |
/* Cleanup for path */ |
| 3656 |
path_cleanup(&path); |
| 3657 |
|
| 3658 |
return return_value; |
| 3659 |
} |
| 3660 |
|
| 3661 |
PyDoc_STRVAR(os__exit__doc__, |
| 3662 |
"_exit($module, /, status)\n" |
| 3663 |
"--\n" |
| 3664 |
"\n" |
| 3665 |
"Exit to the system with specified status, without normal exit processing."); |
| 3666 |
|
| 3667 |
#define OS__EXIT_METHODDEF \ |
| 3668 |
{"_exit", _PyCFunction_CAST(os__exit), METH_FASTCALL|METH_KEYWORDS, os__exit__doc__}, |
| 3669 |
|
| 3670 |
static PyObject * |
| 3671 |
os__exit_impl(PyObject *module, int status); |
| 3672 |
|
| 3673 |
static PyObject * |
| 3674 |
os__exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3675 |
{ |
| 3676 |
PyObject *return_value = NULL; |
| 3677 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3678 |
|
| 3679 |
#define NUM_KEYWORDS 1 |
| 3680 |
static struct { |
| 3681 |
PyGC_Head _this_is_not_used; |
| 3682 |
PyObject_VAR_HEAD |
| 3683 |
Py_hash_t ob_hash; |
| 3684 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3685 |
} _kwtuple = { |
| 3686 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3687 |
.ob_hash = -1, |
| 3688 |
.ob_item = { &_Py_ID(status), }, |
| 3689 |
}; |
| 3690 |
#undef NUM_KEYWORDS |
| 3691 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3692 |
|
| 3693 |
#else // !Py_BUILD_CORE |
| 3694 |
# define KWTUPLE NULL |
| 3695 |
#endif // !Py_BUILD_CORE |
| 3696 |
|
| 3697 |
static const char * const _keywords[] = {"status", NULL}; |
| 3698 |
static _PyArg_Parser _parser = { |
| 3699 |
.keywords = _keywords, |
| 3700 |
.fname = "_exit", |
| 3701 |
.kwtuple = KWTUPLE, |
| 3702 |
}; |
| 3703 |
#undef KWTUPLE |
| 3704 |
PyObject *argsbuf[1]; |
| 3705 |
int status; |
| 3706 |
|
| 3707 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3708 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3709 |
if (!args) { |
| 3710 |
goto exit; |
| 3711 |
} |
| 3712 |
status = PyLong_AsInt(args[0]); |
| 3713 |
if (status == -1 && PyErr_Occurred()) { |
| 3714 |
goto exit; |
| 3715 |
} |
| 3716 |
return_value = os__exit_impl(module, status); |
| 3717 |
|
| 3718 |
exit: |
| 3719 |
return return_value; |
| 3720 |
} |
| 3721 |
|
| 3722 |
#if defined(HAVE_EXECV) |
| 3723 |
|
| 3724 |
PyDoc_STRVAR(os_execv__doc__, |
| 3725 |
"execv($module, path, argv, /)\n" |
| 3726 |
"--\n" |
| 3727 |
"\n" |
| 3728 |
"Execute an executable path with arguments, replacing current process.\n" |
| 3729 |
"\n" |
| 3730 |
" path\n" |
| 3731 |
" Path of executable file.\n" |
| 3732 |
" argv\n" |
| 3733 |
" Tuple or list of strings."); |
| 3734 |
|
| 3735 |
#define OS_EXECV_METHODDEF \ |
| 3736 |
{"execv", _PyCFunction_CAST(os_execv), METH_FASTCALL, os_execv__doc__}, |
| 3737 |
|
| 3738 |
static PyObject * |
| 3739 |
os_execv_impl(PyObject *module, path_t *path, PyObject *argv); |
| 3740 |
|
| 3741 |
static PyObject * |
| 3742 |
os_execv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 3743 |
{ |
| 3744 |
PyObject *return_value = NULL; |
| 3745 |
path_t path = PATH_T_INITIALIZE_P("execv", "path", 0, 0, 0, 0); |
| 3746 |
PyObject *argv; |
| 3747 |
|
| 3748 |
if (!_PyArg_CheckPositional("execv", nargs, 2, 2)) { |
| 3749 |
goto exit; |
| 3750 |
} |
| 3751 |
if (!path_converter(args[0], &path)) { |
| 3752 |
goto exit; |
| 3753 |
} |
| 3754 |
argv = args[1]; |
| 3755 |
return_value = os_execv_impl(module, &path, argv); |
| 3756 |
|
| 3757 |
exit: |
| 3758 |
/* Cleanup for path */ |
| 3759 |
path_cleanup(&path); |
| 3760 |
|
| 3761 |
return return_value; |
| 3762 |
} |
| 3763 |
|
| 3764 |
#endif /* defined(HAVE_EXECV) */ |
| 3765 |
|
| 3766 |
#if defined(HAVE_EXECV) |
| 3767 |
|
| 3768 |
PyDoc_STRVAR(os_execve__doc__, |
| 3769 |
"execve($module, /, path, argv, env)\n" |
| 3770 |
"--\n" |
| 3771 |
"\n" |
| 3772 |
"Execute an executable path with arguments, replacing current process.\n" |
| 3773 |
"\n" |
| 3774 |
" path\n" |
| 3775 |
" Path of executable file.\n" |
| 3776 |
" argv\n" |
| 3777 |
" Tuple or list of strings.\n" |
| 3778 |
" env\n" |
| 3779 |
" Dictionary of strings mapping to strings."); |
| 3780 |
|
| 3781 |
#define OS_EXECVE_METHODDEF \ |
| 3782 |
{"execve", _PyCFunction_CAST(os_execve), METH_FASTCALL|METH_KEYWORDS, os_execve__doc__}, |
| 3783 |
|
| 3784 |
static PyObject * |
| 3785 |
os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env); |
| 3786 |
|
| 3787 |
static PyObject * |
| 3788 |
os_execve(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3789 |
{ |
| 3790 |
PyObject *return_value = NULL; |
| 3791 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3792 |
|
| 3793 |
#define NUM_KEYWORDS 3 |
| 3794 |
static struct { |
| 3795 |
PyGC_Head _this_is_not_used; |
| 3796 |
PyObject_VAR_HEAD |
| 3797 |
Py_hash_t ob_hash; |
| 3798 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3799 |
} _kwtuple = { |
| 3800 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3801 |
.ob_hash = -1, |
| 3802 |
.ob_item = { &_Py_ID(path), &_Py_ID(argv), &_Py_ID(env), }, |
| 3803 |
}; |
| 3804 |
#undef NUM_KEYWORDS |
| 3805 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3806 |
|
| 3807 |
#else // !Py_BUILD_CORE |
| 3808 |
# define KWTUPLE NULL |
| 3809 |
#endif // !Py_BUILD_CORE |
| 3810 |
|
| 3811 |
static const char * const _keywords[] = {"path", "argv", "env", NULL}; |
| 3812 |
static _PyArg_Parser _parser = { |
| 3813 |
.keywords = _keywords, |
| 3814 |
.fname = "execve", |
| 3815 |
.kwtuple = KWTUPLE, |
| 3816 |
}; |
| 3817 |
#undef KWTUPLE |
| 3818 |
PyObject *argsbuf[3]; |
| 3819 |
path_t path = PATH_T_INITIALIZE_P("execve", "path", 0, 0, 0, PATH_HAVE_FEXECVE); |
| 3820 |
PyObject *argv; |
| 3821 |
PyObject *env; |
| 3822 |
|
| 3823 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3824 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3825 |
if (!args) { |
| 3826 |
goto exit; |
| 3827 |
} |
| 3828 |
if (!path_converter(args[0], &path)) { |
| 3829 |
goto exit; |
| 3830 |
} |
| 3831 |
argv = args[1]; |
| 3832 |
env = args[2]; |
| 3833 |
return_value = os_execve_impl(module, &path, argv, env); |
| 3834 |
|
| 3835 |
exit: |
| 3836 |
/* Cleanup for path */ |
| 3837 |
path_cleanup(&path); |
| 3838 |
|
| 3839 |
return return_value; |
| 3840 |
} |
| 3841 |
|
| 3842 |
#endif /* defined(HAVE_EXECV) */ |
| 3843 |
|
| 3844 |
#if defined(HAVE_POSIX_SPAWN) |
| 3845 |
|
| 3846 |
PyDoc_STRVAR(os_posix_spawn__doc__, |
| 3847 |
"posix_spawn($module, path, argv, env, /, *, file_actions=(),\n" |
| 3848 |
" setpgroup=None, resetids=False, setsid=False,\n" |
| 3849 |
" setsigmask=(), setsigdef=(), scheduler=None)\n" |
| 3850 |
"--\n" |
| 3851 |
"\n" |
| 3852 |
"Execute the program specified by path in a new process.\n" |
| 3853 |
"\n" |
| 3854 |
" path\n" |
| 3855 |
" Path of executable file.\n" |
| 3856 |
" argv\n" |
| 3857 |
" Tuple or list of strings.\n" |
| 3858 |
" env\n" |
| 3859 |
" Dictionary of strings mapping to strings.\n" |
| 3860 |
" file_actions\n" |
| 3861 |
" A sequence of file action tuples.\n" |
| 3862 |
" setpgroup\n" |
| 3863 |
" The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" |
| 3864 |
" resetids\n" |
| 3865 |
" If the value is `true` the POSIX_SPAWN_RESETIDS will be activated.\n" |
| 3866 |
" setsid\n" |
| 3867 |
" If the value is `true` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" |
| 3868 |
" setsigmask\n" |
| 3869 |
" The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" |
| 3870 |
" setsigdef\n" |
| 3871 |
" The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" |
| 3872 |
" scheduler\n" |
| 3873 |
" A tuple with the scheduler policy (optional) and parameters."); |
| 3874 |
|
| 3875 |
#define OS_POSIX_SPAWN_METHODDEF \ |
| 3876 |
{"posix_spawn", _PyCFunction_CAST(os_posix_spawn), METH_FASTCALL|METH_KEYWORDS, os_posix_spawn__doc__}, |
| 3877 |
|
| 3878 |
static PyObject * |
| 3879 |
os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv, |
| 3880 |
PyObject *env, PyObject *file_actions, |
| 3881 |
PyObject *setpgroup, int resetids, int setsid, |
| 3882 |
PyObject *setsigmask, PyObject *setsigdef, |
| 3883 |
PyObject *scheduler); |
| 3884 |
|
| 3885 |
static PyObject * |
| 3886 |
os_posix_spawn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 3887 |
{ |
| 3888 |
PyObject *return_value = NULL; |
| 3889 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 3890 |
|
| 3891 |
#define NUM_KEYWORDS 7 |
| 3892 |
static struct { |
| 3893 |
PyGC_Head _this_is_not_used; |
| 3894 |
PyObject_VAR_HEAD |
| 3895 |
Py_hash_t ob_hash; |
| 3896 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 3897 |
} _kwtuple = { |
| 3898 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 3899 |
.ob_hash = -1, |
| 3900 |
.ob_item = { &_Py_ID(file_actions), &_Py_ID(setpgroup), &_Py_ID(resetids), &_Py_ID(setsid), &_Py_ID(setsigmask), &_Py_ID(setsigdef), &_Py_ID(scheduler), }, |
| 3901 |
}; |
| 3902 |
#undef NUM_KEYWORDS |
| 3903 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 3904 |
|
| 3905 |
#else // !Py_BUILD_CORE |
| 3906 |
# define KWTUPLE NULL |
| 3907 |
#endif // !Py_BUILD_CORE |
| 3908 |
|
| 3909 |
static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; |
| 3910 |
static _PyArg_Parser _parser = { |
| 3911 |
.keywords = _keywords, |
| 3912 |
.fname = "posix_spawn", |
| 3913 |
.kwtuple = KWTUPLE, |
| 3914 |
}; |
| 3915 |
#undef KWTUPLE |
| 3916 |
PyObject *argsbuf[10]; |
| 3917 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
| 3918 |
path_t path = PATH_T_INITIALIZE_P("posix_spawn", "path", 0, 0, 0, 0); |
| 3919 |
PyObject *argv; |
| 3920 |
PyObject *env; |
| 3921 |
PyObject *file_actions = NULL; |
| 3922 |
PyObject *setpgroup = NULL; |
| 3923 |
int resetids = 0; |
| 3924 |
int setsid = 0; |
| 3925 |
PyObject *setsigmask = NULL; |
| 3926 |
PyObject *setsigdef = NULL; |
| 3927 |
PyObject *scheduler = NULL; |
| 3928 |
|
| 3929 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 3930 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 3931 |
if (!args) { |
| 3932 |
goto exit; |
| 3933 |
} |
| 3934 |
if (!path_converter(args[0], &path)) { |
| 3935 |
goto exit; |
| 3936 |
} |
| 3937 |
argv = args[1]; |
| 3938 |
env = args[2]; |
| 3939 |
if (!noptargs) { |
| 3940 |
goto skip_optional_kwonly; |
| 3941 |
} |
| 3942 |
if (args[3]) { |
| 3943 |
file_actions = args[3]; |
| 3944 |
if (!--noptargs) { |
| 3945 |
goto skip_optional_kwonly; |
| 3946 |
} |
| 3947 |
} |
| 3948 |
if (args[4]) { |
| 3949 |
setpgroup = args[4]; |
| 3950 |
if (!--noptargs) { |
| 3951 |
goto skip_optional_kwonly; |
| 3952 |
} |
| 3953 |
} |
| 3954 |
if (args[5]) { |
| 3955 |
resetids = PyObject_IsTrue(args[5]); |
| 3956 |
if (resetids < 0) { |
| 3957 |
goto exit; |
| 3958 |
} |
| 3959 |
if (!--noptargs) { |
| 3960 |
goto skip_optional_kwonly; |
| 3961 |
} |
| 3962 |
} |
| 3963 |
if (args[6]) { |
| 3964 |
setsid = PyObject_IsTrue(args[6]); |
| 3965 |
if (setsid < 0) { |
| 3966 |
goto exit; |
| 3967 |
} |
| 3968 |
if (!--noptargs) { |
| 3969 |
goto skip_optional_kwonly; |
| 3970 |
} |
| 3971 |
} |
| 3972 |
if (args[7]) { |
| 3973 |
setsigmask = args[7]; |
| 3974 |
if (!--noptargs) { |
| 3975 |
goto skip_optional_kwonly; |
| 3976 |
} |
| 3977 |
} |
| 3978 |
if (args[8]) { |
| 3979 |
setsigdef = args[8]; |
| 3980 |
if (!--noptargs) { |
| 3981 |
goto skip_optional_kwonly; |
| 3982 |
} |
| 3983 |
} |
| 3984 |
scheduler = args[9]; |
| 3985 |
skip_optional_kwonly: |
| 3986 |
return_value = os_posix_spawn_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); |
| 3987 |
|
| 3988 |
exit: |
| 3989 |
/* Cleanup for path */ |
| 3990 |
path_cleanup(&path); |
| 3991 |
|
| 3992 |
return return_value; |
| 3993 |
} |
| 3994 |
|
| 3995 |
#endif /* defined(HAVE_POSIX_SPAWN) */ |
| 3996 |
|
| 3997 |
#if defined(HAVE_POSIX_SPAWNP) |
| 3998 |
|
| 3999 |
PyDoc_STRVAR(os_posix_spawnp__doc__, |
| 4000 |
"posix_spawnp($module, path, argv, env, /, *, file_actions=(),\n" |
| 4001 |
" setpgroup=None, resetids=False, setsid=False,\n" |
| 4002 |
" setsigmask=(), setsigdef=(), scheduler=None)\n" |
| 4003 |
"--\n" |
| 4004 |
"\n" |
| 4005 |
"Execute the program specified by path in a new process.\n" |
| 4006 |
"\n" |
| 4007 |
" path\n" |
| 4008 |
" Path of executable file.\n" |
| 4009 |
" argv\n" |
| 4010 |
" Tuple or list of strings.\n" |
| 4011 |
" env\n" |
| 4012 |
" Dictionary of strings mapping to strings.\n" |
| 4013 |
" file_actions\n" |
| 4014 |
" A sequence of file action tuples.\n" |
| 4015 |
" setpgroup\n" |
| 4016 |
" The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" |
| 4017 |
" resetids\n" |
| 4018 |
" If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.\n" |
| 4019 |
" setsid\n" |
| 4020 |
" If the value is `True` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" |
| 4021 |
" setsigmask\n" |
| 4022 |
" The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" |
| 4023 |
" setsigdef\n" |
| 4024 |
" The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" |
| 4025 |
" scheduler\n" |
| 4026 |
" A tuple with the scheduler policy (optional) and parameters."); |
| 4027 |
|
| 4028 |
#define OS_POSIX_SPAWNP_METHODDEF \ |
| 4029 |
{"posix_spawnp", _PyCFunction_CAST(os_posix_spawnp), METH_FASTCALL|METH_KEYWORDS, os_posix_spawnp__doc__}, |
| 4030 |
|
| 4031 |
static PyObject * |
| 4032 |
os_posix_spawnp_impl(PyObject *module, path_t *path, PyObject *argv, |
| 4033 |
PyObject *env, PyObject *file_actions, |
| 4034 |
PyObject *setpgroup, int resetids, int setsid, |
| 4035 |
PyObject *setsigmask, PyObject *setsigdef, |
| 4036 |
PyObject *scheduler); |
| 4037 |
|
| 4038 |
static PyObject * |
| 4039 |
os_posix_spawnp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 4040 |
{ |
| 4041 |
PyObject *return_value = NULL; |
| 4042 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 4043 |
|
| 4044 |
#define NUM_KEYWORDS 7 |
| 4045 |
static struct { |
| 4046 |
PyGC_Head _this_is_not_used; |
| 4047 |
PyObject_VAR_HEAD |
| 4048 |
Py_hash_t ob_hash; |
| 4049 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 4050 |
} _kwtuple = { |
| 4051 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 4052 |
.ob_hash = -1, |
| 4053 |
.ob_item = { &_Py_ID(file_actions), &_Py_ID(setpgroup), &_Py_ID(resetids), &_Py_ID(setsid), &_Py_ID(setsigmask), &_Py_ID(setsigdef), &_Py_ID(scheduler), }, |
| 4054 |
}; |
| 4055 |
#undef NUM_KEYWORDS |
| 4056 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 4057 |
|
| 4058 |
#else // !Py_BUILD_CORE |
| 4059 |
# define KWTUPLE NULL |
| 4060 |
#endif // !Py_BUILD_CORE |
| 4061 |
|
| 4062 |
static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; |
| 4063 |
static _PyArg_Parser _parser = { |
| 4064 |
.keywords = _keywords, |
| 4065 |
.fname = "posix_spawnp", |
| 4066 |
.kwtuple = KWTUPLE, |
| 4067 |
}; |
| 4068 |
#undef KWTUPLE |
| 4069 |
PyObject *argsbuf[10]; |
| 4070 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
| 4071 |
path_t path = PATH_T_INITIALIZE_P("posix_spawnp", "path", 0, 0, 0, 0); |
| 4072 |
PyObject *argv; |
| 4073 |
PyObject *env; |
| 4074 |
PyObject *file_actions = NULL; |
| 4075 |
PyObject *setpgroup = NULL; |
| 4076 |
int resetids = 0; |
| 4077 |
int setsid = 0; |
| 4078 |
PyObject *setsigmask = NULL; |
| 4079 |
PyObject *setsigdef = NULL; |
| 4080 |
PyObject *scheduler = NULL; |
| 4081 |
|
| 4082 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 4083 |
/*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 4084 |
if (!args) { |
| 4085 |
goto exit; |
| 4086 |
} |
| 4087 |
if (!path_converter(args[0], &path)) { |
| 4088 |
goto exit; |
| 4089 |
} |
| 4090 |
argv = args[1]; |
| 4091 |
env = args[2]; |
| 4092 |
if (!noptargs) { |
| 4093 |
goto skip_optional_kwonly; |
| 4094 |
} |
| 4095 |
if (args[3]) { |
| 4096 |
file_actions = args[3]; |
| 4097 |
if (!--noptargs) { |
| 4098 |
goto skip_optional_kwonly; |
| 4099 |
} |
| 4100 |
} |
| 4101 |
if (args[4]) { |
| 4102 |
setpgroup = args[4]; |
| 4103 |
if (!--noptargs) { |
| 4104 |
goto skip_optional_kwonly; |
| 4105 |
} |
| 4106 |
} |
| 4107 |
if (args[5]) { |
| 4108 |
resetids = PyObject_IsTrue(args[5]); |
| 4109 |
if (resetids < 0) { |
| 4110 |
goto exit; |
| 4111 |
} |
| 4112 |
if (!--noptargs) { |
| 4113 |
goto skip_optional_kwonly; |
| 4114 |
} |
| 4115 |
} |
| 4116 |
if (args[6]) { |
| 4117 |
setsid = PyObject_IsTrue(args[6]); |
| 4118 |
if (setsid < 0) { |
| 4119 |
goto exit; |
| 4120 |
} |
| 4121 |
if (!--noptargs) { |
| 4122 |
goto skip_optional_kwonly; |
| 4123 |
} |
| 4124 |
} |
| 4125 |
if (args[7]) { |
| 4126 |
setsigmask = args[7]; |
| 4127 |
if (!--noptargs) { |
| 4128 |
goto skip_optional_kwonly; |
| 4129 |
} |
| 4130 |
} |
| 4131 |
if (args[8]) { |
| 4132 |
setsigdef = args[8]; |
| 4133 |
if (!--noptargs) { |
| 4134 |
goto skip_optional_kwonly; |
| 4135 |
} |
| 4136 |
} |
| 4137 |
scheduler = args[9]; |
| 4138 |
skip_optional_kwonly: |
| 4139 |
return_value = os_posix_spawnp_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); |
| 4140 |
|
| 4141 |
exit: |
| 4142 |
/* Cleanup for path */ |
| 4143 |
path_cleanup(&path); |
| 4144 |
|
| 4145 |
return return_value; |
| 4146 |
} |
| 4147 |
|
| 4148 |
#endif /* defined(HAVE_POSIX_SPAWNP) */ |
| 4149 |
|
| 4150 |
#if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) |
| 4151 |
|
| 4152 |
PyDoc_STRVAR(os_spawnv__doc__, |
| 4153 |
"spawnv($module, mode, path, argv, /)\n" |
| 4154 |
"--\n" |
| 4155 |
"\n" |
| 4156 |
"Execute the program specified by path in a new process.\n" |
| 4157 |
"\n" |
| 4158 |
" mode\n" |
| 4159 |
" Mode of process creation.\n" |
| 4160 |
" path\n" |
| 4161 |
" Path of executable file.\n" |
| 4162 |
" argv\n" |
| 4163 |
" Tuple or list of strings."); |
| 4164 |
|
| 4165 |
#define OS_SPAWNV_METHODDEF \ |
| 4166 |
{"spawnv", _PyCFunction_CAST(os_spawnv), METH_FASTCALL, os_spawnv__doc__}, |
| 4167 |
|
| 4168 |
static PyObject * |
| 4169 |
os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv); |
| 4170 |
|
| 4171 |
static PyObject * |
| 4172 |
os_spawnv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 4173 |
{ |
| 4174 |
PyObject *return_value = NULL; |
| 4175 |
int mode; |
| 4176 |
path_t path = PATH_T_INITIALIZE_P("spawnv", "path", 0, 0, 0, 0); |
| 4177 |
PyObject *argv; |
| 4178 |
|
| 4179 |
if (!_PyArg_CheckPositional("spawnv", nargs, 3, 3)) { |
| 4180 |
goto exit; |
| 4181 |
} |
| 4182 |
mode = PyLong_AsInt(args[0]); |
| 4183 |
if (mode == -1 && PyErr_Occurred()) { |
| 4184 |
goto exit; |
| 4185 |
} |
| 4186 |
if (!path_converter(args[1], &path)) { |
| 4187 |
goto exit; |
| 4188 |
} |
| 4189 |
argv = args[2]; |
| 4190 |
return_value = os_spawnv_impl(module, mode, &path, argv); |
| 4191 |
|
| 4192 |
exit: |
| 4193 |
/* Cleanup for path */ |
| 4194 |
path_cleanup(&path); |
| 4195 |
|
| 4196 |
return return_value; |
| 4197 |
} |
| 4198 |
|
| 4199 |
#endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ |
| 4200 |
|
| 4201 |
#if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) |
| 4202 |
|
| 4203 |
PyDoc_STRVAR(os_spawnve__doc__, |
| 4204 |
"spawnve($module, mode, path, argv, env, /)\n" |
| 4205 |
"--\n" |
| 4206 |
"\n" |
| 4207 |
"Execute the program specified by path in a new process.\n" |
| 4208 |
"\n" |
| 4209 |
" mode\n" |
| 4210 |
" Mode of process creation.\n" |
| 4211 |
" path\n" |
| 4212 |
" Path of executable file.\n" |
| 4213 |
" argv\n" |
| 4214 |
" Tuple or list of strings.\n" |
| 4215 |
" env\n" |
| 4216 |
" Dictionary of strings mapping to strings."); |
| 4217 |
|
| 4218 |
#define OS_SPAWNVE_METHODDEF \ |
| 4219 |
{"spawnve", _PyCFunction_CAST(os_spawnve), METH_FASTCALL, os_spawnve__doc__}, |
| 4220 |
|
| 4221 |
static PyObject * |
| 4222 |
os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, |
| 4223 |
PyObject *env); |
| 4224 |
|
| 4225 |
static PyObject * |
| 4226 |
os_spawnve(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 4227 |
{ |
| 4228 |
PyObject *return_value = NULL; |
| 4229 |
int mode; |
| 4230 |
path_t path = PATH_T_INITIALIZE_P("spawnve", "path", 0, 0, 0, 0); |
| 4231 |
PyObject *argv; |
| 4232 |
PyObject *env; |
| 4233 |
|
| 4234 |
if (!_PyArg_CheckPositional("spawnve", nargs, 4, 4)) { |
| 4235 |
goto exit; |
| 4236 |
} |
| 4237 |
mode = PyLong_AsInt(args[0]); |
| 4238 |
if (mode == -1 && PyErr_Occurred()) { |
| 4239 |
goto exit; |
| 4240 |
} |
| 4241 |
if (!path_converter(args[1], &path)) { |
| 4242 |
goto exit; |
| 4243 |
} |
| 4244 |
argv = args[2]; |
| 4245 |
env = args[3]; |
| 4246 |
return_value = os_spawnve_impl(module, mode, &path, argv, env); |
| 4247 |
|
| 4248 |
exit: |
| 4249 |
/* Cleanup for path */ |
| 4250 |
path_cleanup(&path); |
| 4251 |
|
| 4252 |
return return_value; |
| 4253 |
} |
| 4254 |
|
| 4255 |
#endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ |
| 4256 |
|
| 4257 |
#if defined(HAVE_FORK) |
| 4258 |
|
| 4259 |
PyDoc_STRVAR(os_register_at_fork__doc__, |
| 4260 |
"register_at_fork($module, /, *, before=<unrepresentable>,\n" |
| 4261 |
" after_in_child=<unrepresentable>,\n" |
| 4262 |
" after_in_parent=<unrepresentable>)\n" |
| 4263 |
"--\n" |
| 4264 |
"\n" |
| 4265 |
"Register callables to be called when forking a new process.\n" |
| 4266 |
"\n" |
| 4267 |
" before\n" |
| 4268 |
" A callable to be called in the parent before the fork() syscall.\n" |
| 4269 |
" after_in_child\n" |
| 4270 |
" A callable to be called in the child after fork().\n" |
| 4271 |
" after_in_parent\n" |
| 4272 |
" A callable to be called in the parent after fork().\n" |
| 4273 |
"\n" |
| 4274 |
"\'before\' callbacks are called in reverse order.\n" |
| 4275 |
"\'after_in_child\' and \'after_in_parent\' callbacks are called in order."); |
| 4276 |
|
| 4277 |
#define OS_REGISTER_AT_FORK_METHODDEF \ |
| 4278 |
{"register_at_fork", _PyCFunction_CAST(os_register_at_fork), METH_FASTCALL|METH_KEYWORDS, os_register_at_fork__doc__}, |
| 4279 |
|
| 4280 |
static PyObject * |
| 4281 |
os_register_at_fork_impl(PyObject *module, PyObject *before, |
| 4282 |
PyObject *after_in_child, PyObject *after_in_parent); |
| 4283 |
|
| 4284 |
static PyObject * |
| 4285 |
os_register_at_fork(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 4286 |
{ |
| 4287 |
PyObject *return_value = NULL; |
| 4288 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 4289 |
|
| 4290 |
#define NUM_KEYWORDS 3 |
| 4291 |
static struct { |
| 4292 |
PyGC_Head _this_is_not_used; |
| 4293 |
PyObject_VAR_HEAD |
| 4294 |
Py_hash_t ob_hash; |
| 4295 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 4296 |
} _kwtuple = { |
| 4297 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 4298 |
.ob_hash = -1, |
| 4299 |
.ob_item = { &_Py_ID(before), &_Py_ID(after_in_child), &_Py_ID(after_in_parent), }, |
| 4300 |
}; |
| 4301 |
#undef NUM_KEYWORDS |
| 4302 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 4303 |
|
| 4304 |
#else // !Py_BUILD_CORE |
| 4305 |
# define KWTUPLE NULL |
| 4306 |
#endif // !Py_BUILD_CORE |
| 4307 |
|
| 4308 |
static const char * const _keywords[] = {"before", "after_in_child", "after_in_parent", NULL}; |
| 4309 |
static _PyArg_Parser _parser = { |
| 4310 |
.keywords = _keywords, |
| 4311 |
.fname = "register_at_fork", |
| 4312 |
.kwtuple = KWTUPLE, |
| 4313 |
}; |
| 4314 |
#undef KWTUPLE |
| 4315 |
PyObject *argsbuf[3]; |
| 4316 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 4317 |
PyObject *before = NULL; |
| 4318 |
PyObject *after_in_child = NULL; |
| 4319 |
PyObject *after_in_parent = NULL; |
| 4320 |
|
| 4321 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 4322 |
/*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 4323 |
if (!args) { |
| 4324 |
goto exit; |
| 4325 |
} |
| 4326 |
if (!noptargs) { |
| 4327 |
goto skip_optional_kwonly; |
| 4328 |
} |
| 4329 |
if (args[0]) { |
| 4330 |
before = args[0]; |
| 4331 |
if (!--noptargs) { |
| 4332 |
goto skip_optional_kwonly; |
| 4333 |
} |
| 4334 |
} |
| 4335 |
if (args[1]) { |
| 4336 |
after_in_child = args[1]; |
| 4337 |
if (!--noptargs) { |
| 4338 |
goto skip_optional_kwonly; |
| 4339 |
} |
| 4340 |
} |
| 4341 |
after_in_parent = args[2]; |
| 4342 |
skip_optional_kwonly: |
| 4343 |
return_value = os_register_at_fork_impl(module, before, after_in_child, after_in_parent); |
| 4344 |
|
| 4345 |
exit: |
| 4346 |
return return_value; |
| 4347 |
} |
| 4348 |
|
| 4349 |
#endif /* defined(HAVE_FORK) */ |
| 4350 |
|
| 4351 |
#if defined(HAVE_FORK1) |
| 4352 |
|
| 4353 |
PyDoc_STRVAR(os_fork1__doc__, |
| 4354 |
"fork1($module, /)\n" |
| 4355 |
"--\n" |
| 4356 |
"\n" |
| 4357 |
"Fork a child process with a single multiplexed (i.e., not bound) thread.\n" |
| 4358 |
"\n" |
| 4359 |
"Return 0 to child process and PID of child to parent process."); |
| 4360 |
|
| 4361 |
#define OS_FORK1_METHODDEF \ |
| 4362 |
{"fork1", (PyCFunction)os_fork1, METH_NOARGS, os_fork1__doc__}, |
| 4363 |
|
| 4364 |
static PyObject * |
| 4365 |
os_fork1_impl(PyObject *module); |
| 4366 |
|
| 4367 |
static PyObject * |
| 4368 |
os_fork1(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 4369 |
{ |
| 4370 |
return os_fork1_impl(module); |
| 4371 |
} |
| 4372 |
|
| 4373 |
#endif /* defined(HAVE_FORK1) */ |
| 4374 |
|
| 4375 |
#if defined(HAVE_FORK) |
| 4376 |
|
| 4377 |
PyDoc_STRVAR(os_fork__doc__, |
| 4378 |
"fork($module, /)\n" |
| 4379 |
"--\n" |
| 4380 |
"\n" |
| 4381 |
"Fork a child process.\n" |
| 4382 |
"\n" |
| 4383 |
"Return 0 to child process and PID of child to parent process."); |
| 4384 |
|
| 4385 |
#define OS_FORK_METHODDEF \ |
| 4386 |
{"fork", (PyCFunction)os_fork, METH_NOARGS, os_fork__doc__}, |
| 4387 |
|
| 4388 |
static PyObject * |
| 4389 |
os_fork_impl(PyObject *module); |
| 4390 |
|
| 4391 |
static PyObject * |
| 4392 |
os_fork(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 4393 |
{ |
| 4394 |
return os_fork_impl(module); |
| 4395 |
} |
| 4396 |
|
| 4397 |
#endif /* defined(HAVE_FORK) */ |
| 4398 |
|
| 4399 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) |
| 4400 |
|
| 4401 |
PyDoc_STRVAR(os_sched_get_priority_max__doc__, |
| 4402 |
"sched_get_priority_max($module, /, policy)\n" |
| 4403 |
"--\n" |
| 4404 |
"\n" |
| 4405 |
"Get the maximum scheduling priority for policy."); |
| 4406 |
|
| 4407 |
#define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ |
| 4408 |
{"sched_get_priority_max", _PyCFunction_CAST(os_sched_get_priority_max), METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_max__doc__}, |
| 4409 |
|
| 4410 |
static PyObject * |
| 4411 |
os_sched_get_priority_max_impl(PyObject *module, int policy); |
| 4412 |
|
| 4413 |
static PyObject * |
| 4414 |
os_sched_get_priority_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 4415 |
{ |
| 4416 |
PyObject *return_value = NULL; |
| 4417 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 4418 |
|
| 4419 |
#define NUM_KEYWORDS 1 |
| 4420 |
static struct { |
| 4421 |
PyGC_Head _this_is_not_used; |
| 4422 |
PyObject_VAR_HEAD |
| 4423 |
Py_hash_t ob_hash; |
| 4424 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 4425 |
} _kwtuple = { |
| 4426 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 4427 |
.ob_hash = -1, |
| 4428 |
.ob_item = { &_Py_ID(policy), }, |
| 4429 |
}; |
| 4430 |
#undef NUM_KEYWORDS |
| 4431 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 4432 |
|
| 4433 |
#else // !Py_BUILD_CORE |
| 4434 |
# define KWTUPLE NULL |
| 4435 |
#endif // !Py_BUILD_CORE |
| 4436 |
|
| 4437 |
static const char * const _keywords[] = {"policy", NULL}; |
| 4438 |
static _PyArg_Parser _parser = { |
| 4439 |
.keywords = _keywords, |
| 4440 |
.fname = "sched_get_priority_max", |
| 4441 |
.kwtuple = KWTUPLE, |
| 4442 |
}; |
| 4443 |
#undef KWTUPLE |
| 4444 |
PyObject *argsbuf[1]; |
| 4445 |
int policy; |
| 4446 |
|
| 4447 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 4448 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 4449 |
if (!args) { |
| 4450 |
goto exit; |
| 4451 |
} |
| 4452 |
policy = PyLong_AsInt(args[0]); |
| 4453 |
if (policy == -1 && PyErr_Occurred()) { |
| 4454 |
goto exit; |
| 4455 |
} |
| 4456 |
return_value = os_sched_get_priority_max_impl(module, policy); |
| 4457 |
|
| 4458 |
exit: |
| 4459 |
return return_value; |
| 4460 |
} |
| 4461 |
|
| 4462 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */ |
| 4463 |
|
| 4464 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) |
| 4465 |
|
| 4466 |
PyDoc_STRVAR(os_sched_get_priority_min__doc__, |
| 4467 |
"sched_get_priority_min($module, /, policy)\n" |
| 4468 |
"--\n" |
| 4469 |
"\n" |
| 4470 |
"Get the minimum scheduling priority for policy."); |
| 4471 |
|
| 4472 |
#define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ |
| 4473 |
{"sched_get_priority_min", _PyCFunction_CAST(os_sched_get_priority_min), METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_min__doc__}, |
| 4474 |
|
| 4475 |
static PyObject * |
| 4476 |
os_sched_get_priority_min_impl(PyObject *module, int policy); |
| 4477 |
|
| 4478 |
static PyObject * |
| 4479 |
os_sched_get_priority_min(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 4480 |
{ |
| 4481 |
PyObject *return_value = NULL; |
| 4482 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 4483 |
|
| 4484 |
#define NUM_KEYWORDS 1 |
| 4485 |
static struct { |
| 4486 |
PyGC_Head _this_is_not_used; |
| 4487 |
PyObject_VAR_HEAD |
| 4488 |
Py_hash_t ob_hash; |
| 4489 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 4490 |
} _kwtuple = { |
| 4491 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 4492 |
.ob_hash = -1, |
| 4493 |
.ob_item = { &_Py_ID(policy), }, |
| 4494 |
}; |
| 4495 |
#undef NUM_KEYWORDS |
| 4496 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 4497 |
|
| 4498 |
#else // !Py_BUILD_CORE |
| 4499 |
# define KWTUPLE NULL |
| 4500 |
#endif // !Py_BUILD_CORE |
| 4501 |
|
| 4502 |
static const char * const _keywords[] = {"policy", NULL}; |
| 4503 |
static _PyArg_Parser _parser = { |
| 4504 |
.keywords = _keywords, |
| 4505 |
.fname = "sched_get_priority_min", |
| 4506 |
.kwtuple = KWTUPLE, |
| 4507 |
}; |
| 4508 |
#undef KWTUPLE |
| 4509 |
PyObject *argsbuf[1]; |
| 4510 |
int policy; |
| 4511 |
|
| 4512 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 4513 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 4514 |
if (!args) { |
| 4515 |
goto exit; |
| 4516 |
} |
| 4517 |
policy = PyLong_AsInt(args[0]); |
| 4518 |
if (policy == -1 && PyErr_Occurred()) { |
| 4519 |
goto exit; |
| 4520 |
} |
| 4521 |
return_value = os_sched_get_priority_min_impl(module, policy); |
| 4522 |
|
| 4523 |
exit: |
| 4524 |
return return_value; |
| 4525 |
} |
| 4526 |
|
| 4527 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */ |
| 4528 |
|
| 4529 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) |
| 4530 |
|
| 4531 |
PyDoc_STRVAR(os_sched_getscheduler__doc__, |
| 4532 |
"sched_getscheduler($module, pid, /)\n" |
| 4533 |
"--\n" |
| 4534 |
"\n" |
| 4535 |
"Get the scheduling policy for the process identified by pid.\n" |
| 4536 |
"\n" |
| 4537 |
"Passing 0 for pid returns the scheduling policy for the calling process."); |
| 4538 |
|
| 4539 |
#define OS_SCHED_GETSCHEDULER_METHODDEF \ |
| 4540 |
{"sched_getscheduler", (PyCFunction)os_sched_getscheduler, METH_O, os_sched_getscheduler__doc__}, |
| 4541 |
|
| 4542 |
static PyObject * |
| 4543 |
os_sched_getscheduler_impl(PyObject *module, pid_t pid); |
| 4544 |
|
| 4545 |
static PyObject * |
| 4546 |
os_sched_getscheduler(PyObject *module, PyObject *arg) |
| 4547 |
{ |
| 4548 |
PyObject *return_value = NULL; |
| 4549 |
pid_t pid; |
| 4550 |
|
| 4551 |
pid = PyLong_AsPid(arg); |
| 4552 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4553 |
goto exit; |
| 4554 |
} |
| 4555 |
return_value = os_sched_getscheduler_impl(module, pid); |
| 4556 |
|
| 4557 |
exit: |
| 4558 |
return return_value; |
| 4559 |
} |
| 4560 |
|
| 4561 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ |
| 4562 |
|
| 4563 |
#if defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) |
| 4564 |
|
| 4565 |
PyDoc_STRVAR(os_sched_param__doc__, |
| 4566 |
"sched_param(sched_priority)\n" |
| 4567 |
"--\n" |
| 4568 |
"\n" |
| 4569 |
"Currently has only one field: sched_priority\n" |
| 4570 |
"\n" |
| 4571 |
" sched_priority\n" |
| 4572 |
" A scheduling parameter."); |
| 4573 |
|
| 4574 |
static PyObject * |
| 4575 |
os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority); |
| 4576 |
|
| 4577 |
static PyObject * |
| 4578 |
os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
| 4579 |
{ |
| 4580 |
PyObject *return_value = NULL; |
| 4581 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 4582 |
|
| 4583 |
#define NUM_KEYWORDS 1 |
| 4584 |
static struct { |
| 4585 |
PyGC_Head _this_is_not_used; |
| 4586 |
PyObject_VAR_HEAD |
| 4587 |
Py_hash_t ob_hash; |
| 4588 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 4589 |
} _kwtuple = { |
| 4590 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 4591 |
.ob_hash = -1, |
| 4592 |
.ob_item = { &_Py_ID(sched_priority), }, |
| 4593 |
}; |
| 4594 |
#undef NUM_KEYWORDS |
| 4595 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 4596 |
|
| 4597 |
#else // !Py_BUILD_CORE |
| 4598 |
# define KWTUPLE NULL |
| 4599 |
#endif // !Py_BUILD_CORE |
| 4600 |
|
| 4601 |
static const char * const _keywords[] = {"sched_priority", NULL}; |
| 4602 |
static _PyArg_Parser _parser = { |
| 4603 |
.keywords = _keywords, |
| 4604 |
.fname = "sched_param", |
| 4605 |
.kwtuple = KWTUPLE, |
| 4606 |
}; |
| 4607 |
#undef KWTUPLE |
| 4608 |
PyObject *argsbuf[1]; |
| 4609 |
PyObject * const *fastargs; |
| 4610 |
Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
| 4611 |
PyObject *sched_priority; |
| 4612 |
|
| 4613 |
fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, |
| 4614 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 4615 |
if (!fastargs) { |
| 4616 |
goto exit; |
| 4617 |
} |
| 4618 |
sched_priority = fastargs[0]; |
| 4619 |
return_value = os_sched_param_impl(type, sched_priority); |
| 4620 |
|
| 4621 |
exit: |
| 4622 |
return return_value; |
| 4623 |
} |
| 4624 |
|
| 4625 |
#endif /* defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) */ |
| 4626 |
|
| 4627 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) |
| 4628 |
|
| 4629 |
PyDoc_STRVAR(os_sched_setscheduler__doc__, |
| 4630 |
"sched_setscheduler($module, pid, policy, param, /)\n" |
| 4631 |
"--\n" |
| 4632 |
"\n" |
| 4633 |
"Set the scheduling policy for the process identified by pid.\n" |
| 4634 |
"\n" |
| 4635 |
"If pid is 0, the calling process is changed.\n" |
| 4636 |
"param is an instance of sched_param."); |
| 4637 |
|
| 4638 |
#define OS_SCHED_SETSCHEDULER_METHODDEF \ |
| 4639 |
{"sched_setscheduler", _PyCFunction_CAST(os_sched_setscheduler), METH_FASTCALL, os_sched_setscheduler__doc__}, |
| 4640 |
|
| 4641 |
static PyObject * |
| 4642 |
os_sched_setscheduler_impl(PyObject *module, pid_t pid, int policy, |
| 4643 |
PyObject *param_obj); |
| 4644 |
|
| 4645 |
static PyObject * |
| 4646 |
os_sched_setscheduler(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 4647 |
{ |
| 4648 |
PyObject *return_value = NULL; |
| 4649 |
pid_t pid; |
| 4650 |
int policy; |
| 4651 |
PyObject *param_obj; |
| 4652 |
|
| 4653 |
if (!_PyArg_CheckPositional("sched_setscheduler", nargs, 3, 3)) { |
| 4654 |
goto exit; |
| 4655 |
} |
| 4656 |
pid = PyLong_AsPid(args[0]); |
| 4657 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4658 |
goto exit; |
| 4659 |
} |
| 4660 |
policy = PyLong_AsInt(args[1]); |
| 4661 |
if (policy == -1 && PyErr_Occurred()) { |
| 4662 |
goto exit; |
| 4663 |
} |
| 4664 |
param_obj = args[2]; |
| 4665 |
return_value = os_sched_setscheduler_impl(module, pid, policy, param_obj); |
| 4666 |
|
| 4667 |
exit: |
| 4668 |
return return_value; |
| 4669 |
} |
| 4670 |
|
| 4671 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ |
| 4672 |
|
| 4673 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) |
| 4674 |
|
| 4675 |
PyDoc_STRVAR(os_sched_getparam__doc__, |
| 4676 |
"sched_getparam($module, pid, /)\n" |
| 4677 |
"--\n" |
| 4678 |
"\n" |
| 4679 |
"Returns scheduling parameters for the process identified by pid.\n" |
| 4680 |
"\n" |
| 4681 |
"If pid is 0, returns parameters for the calling process.\n" |
| 4682 |
"Return value is an instance of sched_param."); |
| 4683 |
|
| 4684 |
#define OS_SCHED_GETPARAM_METHODDEF \ |
| 4685 |
{"sched_getparam", (PyCFunction)os_sched_getparam, METH_O, os_sched_getparam__doc__}, |
| 4686 |
|
| 4687 |
static PyObject * |
| 4688 |
os_sched_getparam_impl(PyObject *module, pid_t pid); |
| 4689 |
|
| 4690 |
static PyObject * |
| 4691 |
os_sched_getparam(PyObject *module, PyObject *arg) |
| 4692 |
{ |
| 4693 |
PyObject *return_value = NULL; |
| 4694 |
pid_t pid; |
| 4695 |
|
| 4696 |
pid = PyLong_AsPid(arg); |
| 4697 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4698 |
goto exit; |
| 4699 |
} |
| 4700 |
return_value = os_sched_getparam_impl(module, pid); |
| 4701 |
|
| 4702 |
exit: |
| 4703 |
return return_value; |
| 4704 |
} |
| 4705 |
|
| 4706 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */ |
| 4707 |
|
| 4708 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) |
| 4709 |
|
| 4710 |
PyDoc_STRVAR(os_sched_setparam__doc__, |
| 4711 |
"sched_setparam($module, pid, param, /)\n" |
| 4712 |
"--\n" |
| 4713 |
"\n" |
| 4714 |
"Set scheduling parameters for the process identified by pid.\n" |
| 4715 |
"\n" |
| 4716 |
"If pid is 0, sets parameters for the calling process.\n" |
| 4717 |
"param should be an instance of sched_param."); |
| 4718 |
|
| 4719 |
#define OS_SCHED_SETPARAM_METHODDEF \ |
| 4720 |
{"sched_setparam", _PyCFunction_CAST(os_sched_setparam), METH_FASTCALL, os_sched_setparam__doc__}, |
| 4721 |
|
| 4722 |
static PyObject * |
| 4723 |
os_sched_setparam_impl(PyObject *module, pid_t pid, PyObject *param_obj); |
| 4724 |
|
| 4725 |
static PyObject * |
| 4726 |
os_sched_setparam(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 4727 |
{ |
| 4728 |
PyObject *return_value = NULL; |
| 4729 |
pid_t pid; |
| 4730 |
PyObject *param_obj; |
| 4731 |
|
| 4732 |
if (!_PyArg_CheckPositional("sched_setparam", nargs, 2, 2)) { |
| 4733 |
goto exit; |
| 4734 |
} |
| 4735 |
pid = PyLong_AsPid(args[0]); |
| 4736 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4737 |
goto exit; |
| 4738 |
} |
| 4739 |
param_obj = args[1]; |
| 4740 |
return_value = os_sched_setparam_impl(module, pid, param_obj); |
| 4741 |
|
| 4742 |
exit: |
| 4743 |
return return_value; |
| 4744 |
} |
| 4745 |
|
| 4746 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */ |
| 4747 |
|
| 4748 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) |
| 4749 |
|
| 4750 |
PyDoc_STRVAR(os_sched_rr_get_interval__doc__, |
| 4751 |
"sched_rr_get_interval($module, pid, /)\n" |
| 4752 |
"--\n" |
| 4753 |
"\n" |
| 4754 |
"Return the round-robin quantum for the process identified by pid, in seconds.\n" |
| 4755 |
"\n" |
| 4756 |
"Value returned is a float."); |
| 4757 |
|
| 4758 |
#define OS_SCHED_RR_GET_INTERVAL_METHODDEF \ |
| 4759 |
{"sched_rr_get_interval", (PyCFunction)os_sched_rr_get_interval, METH_O, os_sched_rr_get_interval__doc__}, |
| 4760 |
|
| 4761 |
static double |
| 4762 |
os_sched_rr_get_interval_impl(PyObject *module, pid_t pid); |
| 4763 |
|
| 4764 |
static PyObject * |
| 4765 |
os_sched_rr_get_interval(PyObject *module, PyObject *arg) |
| 4766 |
{ |
| 4767 |
PyObject *return_value = NULL; |
| 4768 |
pid_t pid; |
| 4769 |
double _return_value; |
| 4770 |
|
| 4771 |
pid = PyLong_AsPid(arg); |
| 4772 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4773 |
goto exit; |
| 4774 |
} |
| 4775 |
_return_value = os_sched_rr_get_interval_impl(module, pid); |
| 4776 |
if ((_return_value == -1.0) && PyErr_Occurred()) { |
| 4777 |
goto exit; |
| 4778 |
} |
| 4779 |
return_value = PyFloat_FromDouble(_return_value); |
| 4780 |
|
| 4781 |
exit: |
| 4782 |
return return_value; |
| 4783 |
} |
| 4784 |
|
| 4785 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) */ |
| 4786 |
|
| 4787 |
#if defined(HAVE_SCHED_H) |
| 4788 |
|
| 4789 |
PyDoc_STRVAR(os_sched_yield__doc__, |
| 4790 |
"sched_yield($module, /)\n" |
| 4791 |
"--\n" |
| 4792 |
"\n" |
| 4793 |
"Voluntarily relinquish the CPU."); |
| 4794 |
|
| 4795 |
#define OS_SCHED_YIELD_METHODDEF \ |
| 4796 |
{"sched_yield", (PyCFunction)os_sched_yield, METH_NOARGS, os_sched_yield__doc__}, |
| 4797 |
|
| 4798 |
static PyObject * |
| 4799 |
os_sched_yield_impl(PyObject *module); |
| 4800 |
|
| 4801 |
static PyObject * |
| 4802 |
os_sched_yield(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 4803 |
{ |
| 4804 |
return os_sched_yield_impl(module); |
| 4805 |
} |
| 4806 |
|
| 4807 |
#endif /* defined(HAVE_SCHED_H) */ |
| 4808 |
|
| 4809 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) |
| 4810 |
|
| 4811 |
PyDoc_STRVAR(os_sched_setaffinity__doc__, |
| 4812 |
"sched_setaffinity($module, pid, mask, /)\n" |
| 4813 |
"--\n" |
| 4814 |
"\n" |
| 4815 |
"Set the CPU affinity of the process identified by pid to mask.\n" |
| 4816 |
"\n" |
| 4817 |
"mask should be an iterable of integers identifying CPUs."); |
| 4818 |
|
| 4819 |
#define OS_SCHED_SETAFFINITY_METHODDEF \ |
| 4820 |
{"sched_setaffinity", _PyCFunction_CAST(os_sched_setaffinity), METH_FASTCALL, os_sched_setaffinity__doc__}, |
| 4821 |
|
| 4822 |
static PyObject * |
| 4823 |
os_sched_setaffinity_impl(PyObject *module, pid_t pid, PyObject *mask); |
| 4824 |
|
| 4825 |
static PyObject * |
| 4826 |
os_sched_setaffinity(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 4827 |
{ |
| 4828 |
PyObject *return_value = NULL; |
| 4829 |
pid_t pid; |
| 4830 |
PyObject *mask; |
| 4831 |
|
| 4832 |
if (!_PyArg_CheckPositional("sched_setaffinity", nargs, 2, 2)) { |
| 4833 |
goto exit; |
| 4834 |
} |
| 4835 |
pid = PyLong_AsPid(args[0]); |
| 4836 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4837 |
goto exit; |
| 4838 |
} |
| 4839 |
mask = args[1]; |
| 4840 |
return_value = os_sched_setaffinity_impl(module, pid, mask); |
| 4841 |
|
| 4842 |
exit: |
| 4843 |
return return_value; |
| 4844 |
} |
| 4845 |
|
| 4846 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */ |
| 4847 |
|
| 4848 |
#if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) |
| 4849 |
|
| 4850 |
PyDoc_STRVAR(os_sched_getaffinity__doc__, |
| 4851 |
"sched_getaffinity($module, pid, /)\n" |
| 4852 |
"--\n" |
| 4853 |
"\n" |
| 4854 |
"Return the affinity of the process identified by pid (or the current process if zero).\n" |
| 4855 |
"\n" |
| 4856 |
"The affinity is returned as a set of CPU identifiers."); |
| 4857 |
|
| 4858 |
#define OS_SCHED_GETAFFINITY_METHODDEF \ |
| 4859 |
{"sched_getaffinity", (PyCFunction)os_sched_getaffinity, METH_O, os_sched_getaffinity__doc__}, |
| 4860 |
|
| 4861 |
static PyObject * |
| 4862 |
os_sched_getaffinity_impl(PyObject *module, pid_t pid); |
| 4863 |
|
| 4864 |
static PyObject * |
| 4865 |
os_sched_getaffinity(PyObject *module, PyObject *arg) |
| 4866 |
{ |
| 4867 |
PyObject *return_value = NULL; |
| 4868 |
pid_t pid; |
| 4869 |
|
| 4870 |
pid = PyLong_AsPid(arg); |
| 4871 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 4872 |
goto exit; |
| 4873 |
} |
| 4874 |
return_value = os_sched_getaffinity_impl(module, pid); |
| 4875 |
|
| 4876 |
exit: |
| 4877 |
return return_value; |
| 4878 |
} |
| 4879 |
|
| 4880 |
#endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */ |
| 4881 |
|
| 4882 |
#if defined(HAVE_POSIX_OPENPT) |
| 4883 |
|
| 4884 |
PyDoc_STRVAR(os_posix_openpt__doc__, |
| 4885 |
"posix_openpt($module, oflag, /)\n" |
| 4886 |
"--\n" |
| 4887 |
"\n" |
| 4888 |
"Open and return a file descriptor for a master pseudo-terminal device.\n" |
| 4889 |
"\n" |
| 4890 |
"Performs a posix_openpt() C function call. The oflag argument is used to\n" |
| 4891 |
"set file status flags and file access modes as specified in the manual page\n" |
| 4892 |
"of posix_openpt() of your system."); |
| 4893 |
|
| 4894 |
#define OS_POSIX_OPENPT_METHODDEF \ |
| 4895 |
{"posix_openpt", (PyCFunction)os_posix_openpt, METH_O, os_posix_openpt__doc__}, |
| 4896 |
|
| 4897 |
static int |
| 4898 |
os_posix_openpt_impl(PyObject *module, int oflag); |
| 4899 |
|
| 4900 |
static PyObject * |
| 4901 |
os_posix_openpt(PyObject *module, PyObject *arg) |
| 4902 |
{ |
| 4903 |
PyObject *return_value = NULL; |
| 4904 |
int oflag; |
| 4905 |
int _return_value; |
| 4906 |
|
| 4907 |
oflag = PyLong_AsInt(arg); |
| 4908 |
if (oflag == -1 && PyErr_Occurred()) { |
| 4909 |
goto exit; |
| 4910 |
} |
| 4911 |
_return_value = os_posix_openpt_impl(module, oflag); |
| 4912 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 4913 |
goto exit; |
| 4914 |
} |
| 4915 |
return_value = PyLong_FromLong((long)_return_value); |
| 4916 |
|
| 4917 |
exit: |
| 4918 |
return return_value; |
| 4919 |
} |
| 4920 |
|
| 4921 |
#endif /* defined(HAVE_POSIX_OPENPT) */ |
| 4922 |
|
| 4923 |
#if defined(HAVE_GRANTPT) |
| 4924 |
|
| 4925 |
PyDoc_STRVAR(os_grantpt__doc__, |
| 4926 |
"grantpt($module, fd, /)\n" |
| 4927 |
"--\n" |
| 4928 |
"\n" |
| 4929 |
"Grant access to the slave pseudo-terminal device.\n" |
| 4930 |
"\n" |
| 4931 |
" fd\n" |
| 4932 |
" File descriptor of a master pseudo-terminal device.\n" |
| 4933 |
"\n" |
| 4934 |
"Performs a grantpt() C function call."); |
| 4935 |
|
| 4936 |
#define OS_GRANTPT_METHODDEF \ |
| 4937 |
{"grantpt", (PyCFunction)os_grantpt, METH_O, os_grantpt__doc__}, |
| 4938 |
|
| 4939 |
static PyObject * |
| 4940 |
os_grantpt_impl(PyObject *module, int fd); |
| 4941 |
|
| 4942 |
static PyObject * |
| 4943 |
os_grantpt(PyObject *module, PyObject *arg) |
| 4944 |
{ |
| 4945 |
PyObject *return_value = NULL; |
| 4946 |
int fd; |
| 4947 |
|
| 4948 |
fd = PyObject_AsFileDescriptor(arg); |
| 4949 |
if (fd < 0) { |
| 4950 |
goto exit; |
| 4951 |
} |
| 4952 |
return_value = os_grantpt_impl(module, fd); |
| 4953 |
|
| 4954 |
exit: |
| 4955 |
return return_value; |
| 4956 |
} |
| 4957 |
|
| 4958 |
#endif /* defined(HAVE_GRANTPT) */ |
| 4959 |
|
| 4960 |
#if defined(HAVE_UNLOCKPT) |
| 4961 |
|
| 4962 |
PyDoc_STRVAR(os_unlockpt__doc__, |
| 4963 |
"unlockpt($module, fd, /)\n" |
| 4964 |
"--\n" |
| 4965 |
"\n" |
| 4966 |
"Unlock a pseudo-terminal master/slave pair.\n" |
| 4967 |
"\n" |
| 4968 |
" fd\n" |
| 4969 |
" File descriptor of a master pseudo-terminal device.\n" |
| 4970 |
"\n" |
| 4971 |
"Performs an unlockpt() C function call."); |
| 4972 |
|
| 4973 |
#define OS_UNLOCKPT_METHODDEF \ |
| 4974 |
{"unlockpt", (PyCFunction)os_unlockpt, METH_O, os_unlockpt__doc__}, |
| 4975 |
|
| 4976 |
static PyObject * |
| 4977 |
os_unlockpt_impl(PyObject *module, int fd); |
| 4978 |
|
| 4979 |
static PyObject * |
| 4980 |
os_unlockpt(PyObject *module, PyObject *arg) |
| 4981 |
{ |
| 4982 |
PyObject *return_value = NULL; |
| 4983 |
int fd; |
| 4984 |
|
| 4985 |
fd = PyObject_AsFileDescriptor(arg); |
| 4986 |
if (fd < 0) { |
| 4987 |
goto exit; |
| 4988 |
} |
| 4989 |
return_value = os_unlockpt_impl(module, fd); |
| 4990 |
|
| 4991 |
exit: |
| 4992 |
return return_value; |
| 4993 |
} |
| 4994 |
|
| 4995 |
#endif /* defined(HAVE_UNLOCKPT) */ |
| 4996 |
|
| 4997 |
#if (defined(HAVE_PTSNAME) || defined(HAVE_PTSNAME_R)) |
| 4998 |
|
| 4999 |
PyDoc_STRVAR(os_ptsname__doc__, |
| 5000 |
"ptsname($module, fd, /)\n" |
| 5001 |
"--\n" |
| 5002 |
"\n" |
| 5003 |
"Return the name of the slave pseudo-terminal device.\n" |
| 5004 |
"\n" |
| 5005 |
" fd\n" |
| 5006 |
" File descriptor of a master pseudo-terminal device.\n" |
| 5007 |
"\n" |
| 5008 |
"If the ptsname_r() C function is available, it is called;\n" |
| 5009 |
"otherwise, performs a ptsname() C function call."); |
| 5010 |
|
| 5011 |
#define OS_PTSNAME_METHODDEF \ |
| 5012 |
{"ptsname", (PyCFunction)os_ptsname, METH_O, os_ptsname__doc__}, |
| 5013 |
|
| 5014 |
static PyObject * |
| 5015 |
os_ptsname_impl(PyObject *module, int fd); |
| 5016 |
|
| 5017 |
static PyObject * |
| 5018 |
os_ptsname(PyObject *module, PyObject *arg) |
| 5019 |
{ |
| 5020 |
PyObject *return_value = NULL; |
| 5021 |
int fd; |
| 5022 |
|
| 5023 |
fd = PyObject_AsFileDescriptor(arg); |
| 5024 |
if (fd < 0) { |
| 5025 |
goto exit; |
| 5026 |
} |
| 5027 |
return_value = os_ptsname_impl(module, fd); |
| 5028 |
|
| 5029 |
exit: |
| 5030 |
return return_value; |
| 5031 |
} |
| 5032 |
|
| 5033 |
#endif /* (defined(HAVE_PTSNAME) || defined(HAVE_PTSNAME_R)) */ |
| 5034 |
|
| 5035 |
#if (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) |
| 5036 |
|
| 5037 |
PyDoc_STRVAR(os_openpty__doc__, |
| 5038 |
"openpty($module, /)\n" |
| 5039 |
"--\n" |
| 5040 |
"\n" |
| 5041 |
"Open a pseudo-terminal.\n" |
| 5042 |
"\n" |
| 5043 |
"Return a tuple of (master_fd, slave_fd) containing open file descriptors\n" |
| 5044 |
"for both the master and slave ends."); |
| 5045 |
|
| 5046 |
#define OS_OPENPTY_METHODDEF \ |
| 5047 |
{"openpty", (PyCFunction)os_openpty, METH_NOARGS, os_openpty__doc__}, |
| 5048 |
|
| 5049 |
static PyObject * |
| 5050 |
os_openpty_impl(PyObject *module); |
| 5051 |
|
| 5052 |
static PyObject * |
| 5053 |
os_openpty(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5054 |
{ |
| 5055 |
return os_openpty_impl(module); |
| 5056 |
} |
| 5057 |
|
| 5058 |
#endif /* (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) */ |
| 5059 |
|
| 5060 |
#if (defined(HAVE_LOGIN_TTY) || defined(HAVE_FALLBACK_LOGIN_TTY)) |
| 5061 |
|
| 5062 |
PyDoc_STRVAR(os_login_tty__doc__, |
| 5063 |
"login_tty($module, fd, /)\n" |
| 5064 |
"--\n" |
| 5065 |
"\n" |
| 5066 |
"Prepare the tty of which fd is a file descriptor for a new login session.\n" |
| 5067 |
"\n" |
| 5068 |
"Make the calling process a session leader; make the tty the\n" |
| 5069 |
"controlling tty, the stdin, the stdout, and the stderr of the\n" |
| 5070 |
"calling process; close fd."); |
| 5071 |
|
| 5072 |
#define OS_LOGIN_TTY_METHODDEF \ |
| 5073 |
{"login_tty", (PyCFunction)os_login_tty, METH_O, os_login_tty__doc__}, |
| 5074 |
|
| 5075 |
static PyObject * |
| 5076 |
os_login_tty_impl(PyObject *module, int fd); |
| 5077 |
|
| 5078 |
static PyObject * |
| 5079 |
os_login_tty(PyObject *module, PyObject *arg) |
| 5080 |
{ |
| 5081 |
PyObject *return_value = NULL; |
| 5082 |
int fd; |
| 5083 |
|
| 5084 |
fd = PyObject_AsFileDescriptor(arg); |
| 5085 |
if (fd < 0) { |
| 5086 |
goto exit; |
| 5087 |
} |
| 5088 |
return_value = os_login_tty_impl(module, fd); |
| 5089 |
|
| 5090 |
exit: |
| 5091 |
return return_value; |
| 5092 |
} |
| 5093 |
|
| 5094 |
#endif /* (defined(HAVE_LOGIN_TTY) || defined(HAVE_FALLBACK_LOGIN_TTY)) */ |
| 5095 |
|
| 5096 |
#if defined(HAVE_FORKPTY) |
| 5097 |
|
| 5098 |
PyDoc_STRVAR(os_forkpty__doc__, |
| 5099 |
"forkpty($module, /)\n" |
| 5100 |
"--\n" |
| 5101 |
"\n" |
| 5102 |
"Fork a new process with a new pseudo-terminal as controlling tty.\n" |
| 5103 |
"\n" |
| 5104 |
"Returns a tuple of (pid, master_fd).\n" |
| 5105 |
"Like fork(), return pid of 0 to the child process,\n" |
| 5106 |
"and pid of child to the parent process.\n" |
| 5107 |
"To both, return fd of newly opened pseudo-terminal."); |
| 5108 |
|
| 5109 |
#define OS_FORKPTY_METHODDEF \ |
| 5110 |
{"forkpty", (PyCFunction)os_forkpty, METH_NOARGS, os_forkpty__doc__}, |
| 5111 |
|
| 5112 |
static PyObject * |
| 5113 |
os_forkpty_impl(PyObject *module); |
| 5114 |
|
| 5115 |
static PyObject * |
| 5116 |
os_forkpty(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5117 |
{ |
| 5118 |
return os_forkpty_impl(module); |
| 5119 |
} |
| 5120 |
|
| 5121 |
#endif /* defined(HAVE_FORKPTY) */ |
| 5122 |
|
| 5123 |
#if defined(HAVE_GETEGID) |
| 5124 |
|
| 5125 |
PyDoc_STRVAR(os_getegid__doc__, |
| 5126 |
"getegid($module, /)\n" |
| 5127 |
"--\n" |
| 5128 |
"\n" |
| 5129 |
"Return the current process\'s effective group id."); |
| 5130 |
|
| 5131 |
#define OS_GETEGID_METHODDEF \ |
| 5132 |
{"getegid", (PyCFunction)os_getegid, METH_NOARGS, os_getegid__doc__}, |
| 5133 |
|
| 5134 |
static PyObject * |
| 5135 |
os_getegid_impl(PyObject *module); |
| 5136 |
|
| 5137 |
static PyObject * |
| 5138 |
os_getegid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5139 |
{ |
| 5140 |
return os_getegid_impl(module); |
| 5141 |
} |
| 5142 |
|
| 5143 |
#endif /* defined(HAVE_GETEGID) */ |
| 5144 |
|
| 5145 |
#if defined(HAVE_GETEUID) |
| 5146 |
|
| 5147 |
PyDoc_STRVAR(os_geteuid__doc__, |
| 5148 |
"geteuid($module, /)\n" |
| 5149 |
"--\n" |
| 5150 |
"\n" |
| 5151 |
"Return the current process\'s effective user id."); |
| 5152 |
|
| 5153 |
#define OS_GETEUID_METHODDEF \ |
| 5154 |
{"geteuid", (PyCFunction)os_geteuid, METH_NOARGS, os_geteuid__doc__}, |
| 5155 |
|
| 5156 |
static PyObject * |
| 5157 |
os_geteuid_impl(PyObject *module); |
| 5158 |
|
| 5159 |
static PyObject * |
| 5160 |
os_geteuid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5161 |
{ |
| 5162 |
return os_geteuid_impl(module); |
| 5163 |
} |
| 5164 |
|
| 5165 |
#endif /* defined(HAVE_GETEUID) */ |
| 5166 |
|
| 5167 |
#if defined(HAVE_GETGID) |
| 5168 |
|
| 5169 |
PyDoc_STRVAR(os_getgid__doc__, |
| 5170 |
"getgid($module, /)\n" |
| 5171 |
"--\n" |
| 5172 |
"\n" |
| 5173 |
"Return the current process\'s group id."); |
| 5174 |
|
| 5175 |
#define OS_GETGID_METHODDEF \ |
| 5176 |
{"getgid", (PyCFunction)os_getgid, METH_NOARGS, os_getgid__doc__}, |
| 5177 |
|
| 5178 |
static PyObject * |
| 5179 |
os_getgid_impl(PyObject *module); |
| 5180 |
|
| 5181 |
static PyObject * |
| 5182 |
os_getgid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5183 |
{ |
| 5184 |
return os_getgid_impl(module); |
| 5185 |
} |
| 5186 |
|
| 5187 |
#endif /* defined(HAVE_GETGID) */ |
| 5188 |
|
| 5189 |
#if defined(HAVE_GETPID) |
| 5190 |
|
| 5191 |
PyDoc_STRVAR(os_getpid__doc__, |
| 5192 |
"getpid($module, /)\n" |
| 5193 |
"--\n" |
| 5194 |
"\n" |
| 5195 |
"Return the current process id."); |
| 5196 |
|
| 5197 |
#define OS_GETPID_METHODDEF \ |
| 5198 |
{"getpid", (PyCFunction)os_getpid, METH_NOARGS, os_getpid__doc__}, |
| 5199 |
|
| 5200 |
static PyObject * |
| 5201 |
os_getpid_impl(PyObject *module); |
| 5202 |
|
| 5203 |
static PyObject * |
| 5204 |
os_getpid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5205 |
{ |
| 5206 |
return os_getpid_impl(module); |
| 5207 |
} |
| 5208 |
|
| 5209 |
#endif /* defined(HAVE_GETPID) */ |
| 5210 |
|
| 5211 |
#if defined(HAVE_GETGROUPLIST) && defined(__APPLE__) |
| 5212 |
|
| 5213 |
PyDoc_STRVAR(os_getgrouplist__doc__, |
| 5214 |
"getgrouplist($module, user, group, /)\n" |
| 5215 |
"--\n" |
| 5216 |
"\n" |
| 5217 |
"Returns a list of groups to which a user belongs.\n" |
| 5218 |
"\n" |
| 5219 |
" user\n" |
| 5220 |
" username to lookup\n" |
| 5221 |
" group\n" |
| 5222 |
" base group id of the user"); |
| 5223 |
|
| 5224 |
#define OS_GETGROUPLIST_METHODDEF \ |
| 5225 |
{"getgrouplist", _PyCFunction_CAST(os_getgrouplist), METH_FASTCALL, os_getgrouplist__doc__}, |
| 5226 |
|
| 5227 |
static PyObject * |
| 5228 |
os_getgrouplist_impl(PyObject *module, const char *user, int basegid); |
| 5229 |
|
| 5230 |
static PyObject * |
| 5231 |
os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5232 |
{ |
| 5233 |
PyObject *return_value = NULL; |
| 5234 |
const char *user; |
| 5235 |
int basegid; |
| 5236 |
|
| 5237 |
if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { |
| 5238 |
goto exit; |
| 5239 |
} |
| 5240 |
if (!PyUnicode_Check(args[0])) { |
| 5241 |
_PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); |
| 5242 |
goto exit; |
| 5243 |
} |
| 5244 |
Py_ssize_t user_length; |
| 5245 |
user = PyUnicode_AsUTF8AndSize(args[0], &user_length); |
| 5246 |
if (user == NULL) { |
| 5247 |
goto exit; |
| 5248 |
} |
| 5249 |
if (strlen(user) != (size_t)user_length) { |
| 5250 |
PyErr_SetString(PyExc_ValueError, "embedded null character"); |
| 5251 |
goto exit; |
| 5252 |
} |
| 5253 |
basegid = PyLong_AsInt(args[1]); |
| 5254 |
if (basegid == -1 && PyErr_Occurred()) { |
| 5255 |
goto exit; |
| 5256 |
} |
| 5257 |
return_value = os_getgrouplist_impl(module, user, basegid); |
| 5258 |
|
| 5259 |
exit: |
| 5260 |
return return_value; |
| 5261 |
} |
| 5262 |
|
| 5263 |
#endif /* defined(HAVE_GETGROUPLIST) && defined(__APPLE__) */ |
| 5264 |
|
| 5265 |
#if defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) |
| 5266 |
|
| 5267 |
PyDoc_STRVAR(os_getgrouplist__doc__, |
| 5268 |
"getgrouplist($module, user, group, /)\n" |
| 5269 |
"--\n" |
| 5270 |
"\n" |
| 5271 |
"Returns a list of groups to which a user belongs.\n" |
| 5272 |
"\n" |
| 5273 |
" user\n" |
| 5274 |
" username to lookup\n" |
| 5275 |
" group\n" |
| 5276 |
" base group id of the user"); |
| 5277 |
|
| 5278 |
#define OS_GETGROUPLIST_METHODDEF \ |
| 5279 |
{"getgrouplist", _PyCFunction_CAST(os_getgrouplist), METH_FASTCALL, os_getgrouplist__doc__}, |
| 5280 |
|
| 5281 |
static PyObject * |
| 5282 |
os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid); |
| 5283 |
|
| 5284 |
static PyObject * |
| 5285 |
os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5286 |
{ |
| 5287 |
PyObject *return_value = NULL; |
| 5288 |
const char *user; |
| 5289 |
gid_t basegid; |
| 5290 |
|
| 5291 |
if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { |
| 5292 |
goto exit; |
| 5293 |
} |
| 5294 |
if (!PyUnicode_Check(args[0])) { |
| 5295 |
_PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); |
| 5296 |
goto exit; |
| 5297 |
} |
| 5298 |
Py_ssize_t user_length; |
| 5299 |
user = PyUnicode_AsUTF8AndSize(args[0], &user_length); |
| 5300 |
if (user == NULL) { |
| 5301 |
goto exit; |
| 5302 |
} |
| 5303 |
if (strlen(user) != (size_t)user_length) { |
| 5304 |
PyErr_SetString(PyExc_ValueError, "embedded null character"); |
| 5305 |
goto exit; |
| 5306 |
} |
| 5307 |
if (!_Py_Gid_Converter(args[1], &basegid)) { |
| 5308 |
goto exit; |
| 5309 |
} |
| 5310 |
return_value = os_getgrouplist_impl(module, user, basegid); |
| 5311 |
|
| 5312 |
exit: |
| 5313 |
return return_value; |
| 5314 |
} |
| 5315 |
|
| 5316 |
#endif /* defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) */ |
| 5317 |
|
| 5318 |
#if defined(HAVE_GETGROUPS) |
| 5319 |
|
| 5320 |
PyDoc_STRVAR(os_getgroups__doc__, |
| 5321 |
"getgroups($module, /)\n" |
| 5322 |
"--\n" |
| 5323 |
"\n" |
| 5324 |
"Return list of supplemental group IDs for the process."); |
| 5325 |
|
| 5326 |
#define OS_GETGROUPS_METHODDEF \ |
| 5327 |
{"getgroups", (PyCFunction)os_getgroups, METH_NOARGS, os_getgroups__doc__}, |
| 5328 |
|
| 5329 |
static PyObject * |
| 5330 |
os_getgroups_impl(PyObject *module); |
| 5331 |
|
| 5332 |
static PyObject * |
| 5333 |
os_getgroups(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5334 |
{ |
| 5335 |
return os_getgroups_impl(module); |
| 5336 |
} |
| 5337 |
|
| 5338 |
#endif /* defined(HAVE_GETGROUPS) */ |
| 5339 |
|
| 5340 |
#if defined(HAVE_INITGROUPS) && defined(__APPLE__) |
| 5341 |
|
| 5342 |
PyDoc_STRVAR(os_initgroups__doc__, |
| 5343 |
"initgroups($module, username, gid, /)\n" |
| 5344 |
"--\n" |
| 5345 |
"\n" |
| 5346 |
"Initialize the group access list.\n" |
| 5347 |
"\n" |
| 5348 |
"Call the system initgroups() to initialize the group access list with all of\n" |
| 5349 |
"the groups of which the specified username is a member, plus the specified\n" |
| 5350 |
"group id."); |
| 5351 |
|
| 5352 |
#define OS_INITGROUPS_METHODDEF \ |
| 5353 |
{"initgroups", _PyCFunction_CAST(os_initgroups), METH_FASTCALL, os_initgroups__doc__}, |
| 5354 |
|
| 5355 |
static PyObject * |
| 5356 |
os_initgroups_impl(PyObject *module, PyObject *oname, int gid); |
| 5357 |
|
| 5358 |
static PyObject * |
| 5359 |
os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5360 |
{ |
| 5361 |
PyObject *return_value = NULL; |
| 5362 |
PyObject *oname = NULL; |
| 5363 |
int gid; |
| 5364 |
|
| 5365 |
if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { |
| 5366 |
goto exit; |
| 5367 |
} |
| 5368 |
if (!PyUnicode_FSConverter(args[0], &oname)) { |
| 5369 |
goto exit; |
| 5370 |
} |
| 5371 |
gid = PyLong_AsInt(args[1]); |
| 5372 |
if (gid == -1 && PyErr_Occurred()) { |
| 5373 |
goto exit; |
| 5374 |
} |
| 5375 |
return_value = os_initgroups_impl(module, oname, gid); |
| 5376 |
|
| 5377 |
exit: |
| 5378 |
/* Cleanup for oname */ |
| 5379 |
Py_XDECREF(oname); |
| 5380 |
|
| 5381 |
return return_value; |
| 5382 |
} |
| 5383 |
|
| 5384 |
#endif /* defined(HAVE_INITGROUPS) && defined(__APPLE__) */ |
| 5385 |
|
| 5386 |
#if defined(HAVE_INITGROUPS) && !defined(__APPLE__) |
| 5387 |
|
| 5388 |
PyDoc_STRVAR(os_initgroups__doc__, |
| 5389 |
"initgroups($module, username, gid, /)\n" |
| 5390 |
"--\n" |
| 5391 |
"\n" |
| 5392 |
"Initialize the group access list.\n" |
| 5393 |
"\n" |
| 5394 |
"Call the system initgroups() to initialize the group access list with all of\n" |
| 5395 |
"the groups of which the specified username is a member, plus the specified\n" |
| 5396 |
"group id."); |
| 5397 |
|
| 5398 |
#define OS_INITGROUPS_METHODDEF \ |
| 5399 |
{"initgroups", _PyCFunction_CAST(os_initgroups), METH_FASTCALL, os_initgroups__doc__}, |
| 5400 |
|
| 5401 |
static PyObject * |
| 5402 |
os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid); |
| 5403 |
|
| 5404 |
static PyObject * |
| 5405 |
os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5406 |
{ |
| 5407 |
PyObject *return_value = NULL; |
| 5408 |
PyObject *oname = NULL; |
| 5409 |
gid_t gid; |
| 5410 |
|
| 5411 |
if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { |
| 5412 |
goto exit; |
| 5413 |
} |
| 5414 |
if (!PyUnicode_FSConverter(args[0], &oname)) { |
| 5415 |
goto exit; |
| 5416 |
} |
| 5417 |
if (!_Py_Gid_Converter(args[1], &gid)) { |
| 5418 |
goto exit; |
| 5419 |
} |
| 5420 |
return_value = os_initgroups_impl(module, oname, gid); |
| 5421 |
|
| 5422 |
exit: |
| 5423 |
/* Cleanup for oname */ |
| 5424 |
Py_XDECREF(oname); |
| 5425 |
|
| 5426 |
return return_value; |
| 5427 |
} |
| 5428 |
|
| 5429 |
#endif /* defined(HAVE_INITGROUPS) && !defined(__APPLE__) */ |
| 5430 |
|
| 5431 |
#if defined(HAVE_GETPGID) |
| 5432 |
|
| 5433 |
PyDoc_STRVAR(os_getpgid__doc__, |
| 5434 |
"getpgid($module, /, pid)\n" |
| 5435 |
"--\n" |
| 5436 |
"\n" |
| 5437 |
"Call the system call getpgid(), and return the result."); |
| 5438 |
|
| 5439 |
#define OS_GETPGID_METHODDEF \ |
| 5440 |
{"getpgid", _PyCFunction_CAST(os_getpgid), METH_FASTCALL|METH_KEYWORDS, os_getpgid__doc__}, |
| 5441 |
|
| 5442 |
static PyObject * |
| 5443 |
os_getpgid_impl(PyObject *module, pid_t pid); |
| 5444 |
|
| 5445 |
static PyObject * |
| 5446 |
os_getpgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 5447 |
{ |
| 5448 |
PyObject *return_value = NULL; |
| 5449 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 5450 |
|
| 5451 |
#define NUM_KEYWORDS 1 |
| 5452 |
static struct { |
| 5453 |
PyGC_Head _this_is_not_used; |
| 5454 |
PyObject_VAR_HEAD |
| 5455 |
Py_hash_t ob_hash; |
| 5456 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 5457 |
} _kwtuple = { |
| 5458 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 5459 |
.ob_hash = -1, |
| 5460 |
.ob_item = { &_Py_ID(pid), }, |
| 5461 |
}; |
| 5462 |
#undef NUM_KEYWORDS |
| 5463 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 5464 |
|
| 5465 |
#else // !Py_BUILD_CORE |
| 5466 |
# define KWTUPLE NULL |
| 5467 |
#endif // !Py_BUILD_CORE |
| 5468 |
|
| 5469 |
static const char * const _keywords[] = {"pid", NULL}; |
| 5470 |
static _PyArg_Parser _parser = { |
| 5471 |
.keywords = _keywords, |
| 5472 |
.fname = "getpgid", |
| 5473 |
.kwtuple = KWTUPLE, |
| 5474 |
}; |
| 5475 |
#undef KWTUPLE |
| 5476 |
PyObject *argsbuf[1]; |
| 5477 |
pid_t pid; |
| 5478 |
|
| 5479 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 5480 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 5481 |
if (!args) { |
| 5482 |
goto exit; |
| 5483 |
} |
| 5484 |
pid = PyLong_AsPid(args[0]); |
| 5485 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 5486 |
goto exit; |
| 5487 |
} |
| 5488 |
return_value = os_getpgid_impl(module, pid); |
| 5489 |
|
| 5490 |
exit: |
| 5491 |
return return_value; |
| 5492 |
} |
| 5493 |
|
| 5494 |
#endif /* defined(HAVE_GETPGID) */ |
| 5495 |
|
| 5496 |
#if defined(HAVE_GETPGRP) |
| 5497 |
|
| 5498 |
PyDoc_STRVAR(os_getpgrp__doc__, |
| 5499 |
"getpgrp($module, /)\n" |
| 5500 |
"--\n" |
| 5501 |
"\n" |
| 5502 |
"Return the current process group id."); |
| 5503 |
|
| 5504 |
#define OS_GETPGRP_METHODDEF \ |
| 5505 |
{"getpgrp", (PyCFunction)os_getpgrp, METH_NOARGS, os_getpgrp__doc__}, |
| 5506 |
|
| 5507 |
static PyObject * |
| 5508 |
os_getpgrp_impl(PyObject *module); |
| 5509 |
|
| 5510 |
static PyObject * |
| 5511 |
os_getpgrp(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5512 |
{ |
| 5513 |
return os_getpgrp_impl(module); |
| 5514 |
} |
| 5515 |
|
| 5516 |
#endif /* defined(HAVE_GETPGRP) */ |
| 5517 |
|
| 5518 |
#if defined(HAVE_SETPGRP) |
| 5519 |
|
| 5520 |
PyDoc_STRVAR(os_setpgrp__doc__, |
| 5521 |
"setpgrp($module, /)\n" |
| 5522 |
"--\n" |
| 5523 |
"\n" |
| 5524 |
"Make the current process the leader of its process group."); |
| 5525 |
|
| 5526 |
#define OS_SETPGRP_METHODDEF \ |
| 5527 |
{"setpgrp", (PyCFunction)os_setpgrp, METH_NOARGS, os_setpgrp__doc__}, |
| 5528 |
|
| 5529 |
static PyObject * |
| 5530 |
os_setpgrp_impl(PyObject *module); |
| 5531 |
|
| 5532 |
static PyObject * |
| 5533 |
os_setpgrp(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5534 |
{ |
| 5535 |
return os_setpgrp_impl(module); |
| 5536 |
} |
| 5537 |
|
| 5538 |
#endif /* defined(HAVE_SETPGRP) */ |
| 5539 |
|
| 5540 |
#if defined(HAVE_GETPPID) |
| 5541 |
|
| 5542 |
PyDoc_STRVAR(os_getppid__doc__, |
| 5543 |
"getppid($module, /)\n" |
| 5544 |
"--\n" |
| 5545 |
"\n" |
| 5546 |
"Return the parent\'s process id.\n" |
| 5547 |
"\n" |
| 5548 |
"If the parent process has already exited, Windows machines will still\n" |
| 5549 |
"return its id; others systems will return the id of the \'init\' process (1)."); |
| 5550 |
|
| 5551 |
#define OS_GETPPID_METHODDEF \ |
| 5552 |
{"getppid", (PyCFunction)os_getppid, METH_NOARGS, os_getppid__doc__}, |
| 5553 |
|
| 5554 |
static PyObject * |
| 5555 |
os_getppid_impl(PyObject *module); |
| 5556 |
|
| 5557 |
static PyObject * |
| 5558 |
os_getppid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5559 |
{ |
| 5560 |
return os_getppid_impl(module); |
| 5561 |
} |
| 5562 |
|
| 5563 |
#endif /* defined(HAVE_GETPPID) */ |
| 5564 |
|
| 5565 |
#if defined(HAVE_GETLOGIN) |
| 5566 |
|
| 5567 |
PyDoc_STRVAR(os_getlogin__doc__, |
| 5568 |
"getlogin($module, /)\n" |
| 5569 |
"--\n" |
| 5570 |
"\n" |
| 5571 |
"Return the actual login name."); |
| 5572 |
|
| 5573 |
#define OS_GETLOGIN_METHODDEF \ |
| 5574 |
{"getlogin", (PyCFunction)os_getlogin, METH_NOARGS, os_getlogin__doc__}, |
| 5575 |
|
| 5576 |
static PyObject * |
| 5577 |
os_getlogin_impl(PyObject *module); |
| 5578 |
|
| 5579 |
static PyObject * |
| 5580 |
os_getlogin(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5581 |
{ |
| 5582 |
return os_getlogin_impl(module); |
| 5583 |
} |
| 5584 |
|
| 5585 |
#endif /* defined(HAVE_GETLOGIN) */ |
| 5586 |
|
| 5587 |
#if defined(HAVE_GETUID) |
| 5588 |
|
| 5589 |
PyDoc_STRVAR(os_getuid__doc__, |
| 5590 |
"getuid($module, /)\n" |
| 5591 |
"--\n" |
| 5592 |
"\n" |
| 5593 |
"Return the current process\'s user id."); |
| 5594 |
|
| 5595 |
#define OS_GETUID_METHODDEF \ |
| 5596 |
{"getuid", (PyCFunction)os_getuid, METH_NOARGS, os_getuid__doc__}, |
| 5597 |
|
| 5598 |
static PyObject * |
| 5599 |
os_getuid_impl(PyObject *module); |
| 5600 |
|
| 5601 |
static PyObject * |
| 5602 |
os_getuid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 5603 |
{ |
| 5604 |
return os_getuid_impl(module); |
| 5605 |
} |
| 5606 |
|
| 5607 |
#endif /* defined(HAVE_GETUID) */ |
| 5608 |
|
| 5609 |
#if defined(HAVE_KILL) |
| 5610 |
|
| 5611 |
PyDoc_STRVAR(os_kill__doc__, |
| 5612 |
"kill($module, pid, signal, /)\n" |
| 5613 |
"--\n" |
| 5614 |
"\n" |
| 5615 |
"Kill a process with a signal."); |
| 5616 |
|
| 5617 |
#define OS_KILL_METHODDEF \ |
| 5618 |
{"kill", _PyCFunction_CAST(os_kill), METH_FASTCALL, os_kill__doc__}, |
| 5619 |
|
| 5620 |
static PyObject * |
| 5621 |
os_kill_impl(PyObject *module, pid_t pid, Py_ssize_t signal); |
| 5622 |
|
| 5623 |
static PyObject * |
| 5624 |
os_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5625 |
{ |
| 5626 |
PyObject *return_value = NULL; |
| 5627 |
pid_t pid; |
| 5628 |
Py_ssize_t signal; |
| 5629 |
|
| 5630 |
if (!_PyArg_CheckPositional("kill", nargs, 2, 2)) { |
| 5631 |
goto exit; |
| 5632 |
} |
| 5633 |
pid = PyLong_AsPid(args[0]); |
| 5634 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 5635 |
goto exit; |
| 5636 |
} |
| 5637 |
{ |
| 5638 |
Py_ssize_t ival = -1; |
| 5639 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 5640 |
if (iobj != NULL) { |
| 5641 |
ival = PyLong_AsSsize_t(iobj); |
| 5642 |
Py_DECREF(iobj); |
| 5643 |
} |
| 5644 |
if (ival == -1 && PyErr_Occurred()) { |
| 5645 |
goto exit; |
| 5646 |
} |
| 5647 |
signal = ival; |
| 5648 |
} |
| 5649 |
return_value = os_kill_impl(module, pid, signal); |
| 5650 |
|
| 5651 |
exit: |
| 5652 |
return return_value; |
| 5653 |
} |
| 5654 |
|
| 5655 |
#endif /* defined(HAVE_KILL) */ |
| 5656 |
|
| 5657 |
#if defined(HAVE_KILLPG) |
| 5658 |
|
| 5659 |
PyDoc_STRVAR(os_killpg__doc__, |
| 5660 |
"killpg($module, pgid, signal, /)\n" |
| 5661 |
"--\n" |
| 5662 |
"\n" |
| 5663 |
"Kill a process group with a signal."); |
| 5664 |
|
| 5665 |
#define OS_KILLPG_METHODDEF \ |
| 5666 |
{"killpg", _PyCFunction_CAST(os_killpg), METH_FASTCALL, os_killpg__doc__}, |
| 5667 |
|
| 5668 |
static PyObject * |
| 5669 |
os_killpg_impl(PyObject *module, pid_t pgid, int signal); |
| 5670 |
|
| 5671 |
static PyObject * |
| 5672 |
os_killpg(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5673 |
{ |
| 5674 |
PyObject *return_value = NULL; |
| 5675 |
pid_t pgid; |
| 5676 |
int signal; |
| 5677 |
|
| 5678 |
if (!_PyArg_CheckPositional("killpg", nargs, 2, 2)) { |
| 5679 |
goto exit; |
| 5680 |
} |
| 5681 |
pgid = PyLong_AsPid(args[0]); |
| 5682 |
if (pgid == (pid_t)(-1) && PyErr_Occurred()) { |
| 5683 |
goto exit; |
| 5684 |
} |
| 5685 |
signal = PyLong_AsInt(args[1]); |
| 5686 |
if (signal == -1 && PyErr_Occurred()) { |
| 5687 |
goto exit; |
| 5688 |
} |
| 5689 |
return_value = os_killpg_impl(module, pgid, signal); |
| 5690 |
|
| 5691 |
exit: |
| 5692 |
return return_value; |
| 5693 |
} |
| 5694 |
|
| 5695 |
#endif /* defined(HAVE_KILLPG) */ |
| 5696 |
|
| 5697 |
#if defined(HAVE_PLOCK) |
| 5698 |
|
| 5699 |
PyDoc_STRVAR(os_plock__doc__, |
| 5700 |
"plock($module, op, /)\n" |
| 5701 |
"--\n" |
| 5702 |
"\n" |
| 5703 |
"Lock program segments into memory.\");"); |
| 5704 |
|
| 5705 |
#define OS_PLOCK_METHODDEF \ |
| 5706 |
{"plock", (PyCFunction)os_plock, METH_O, os_plock__doc__}, |
| 5707 |
|
| 5708 |
static PyObject * |
| 5709 |
os_plock_impl(PyObject *module, int op); |
| 5710 |
|
| 5711 |
static PyObject * |
| 5712 |
os_plock(PyObject *module, PyObject *arg) |
| 5713 |
{ |
| 5714 |
PyObject *return_value = NULL; |
| 5715 |
int op; |
| 5716 |
|
| 5717 |
op = PyLong_AsInt(arg); |
| 5718 |
if (op == -1 && PyErr_Occurred()) { |
| 5719 |
goto exit; |
| 5720 |
} |
| 5721 |
return_value = os_plock_impl(module, op); |
| 5722 |
|
| 5723 |
exit: |
| 5724 |
return return_value; |
| 5725 |
} |
| 5726 |
|
| 5727 |
#endif /* defined(HAVE_PLOCK) */ |
| 5728 |
|
| 5729 |
#if defined(HAVE_SETUID) |
| 5730 |
|
| 5731 |
PyDoc_STRVAR(os_setuid__doc__, |
| 5732 |
"setuid($module, uid, /)\n" |
| 5733 |
"--\n" |
| 5734 |
"\n" |
| 5735 |
"Set the current process\'s user id."); |
| 5736 |
|
| 5737 |
#define OS_SETUID_METHODDEF \ |
| 5738 |
{"setuid", (PyCFunction)os_setuid, METH_O, os_setuid__doc__}, |
| 5739 |
|
| 5740 |
static PyObject * |
| 5741 |
os_setuid_impl(PyObject *module, uid_t uid); |
| 5742 |
|
| 5743 |
static PyObject * |
| 5744 |
os_setuid(PyObject *module, PyObject *arg) |
| 5745 |
{ |
| 5746 |
PyObject *return_value = NULL; |
| 5747 |
uid_t uid; |
| 5748 |
|
| 5749 |
if (!_Py_Uid_Converter(arg, &uid)) { |
| 5750 |
goto exit; |
| 5751 |
} |
| 5752 |
return_value = os_setuid_impl(module, uid); |
| 5753 |
|
| 5754 |
exit: |
| 5755 |
return return_value; |
| 5756 |
} |
| 5757 |
|
| 5758 |
#endif /* defined(HAVE_SETUID) */ |
| 5759 |
|
| 5760 |
#if defined(HAVE_SETEUID) |
| 5761 |
|
| 5762 |
PyDoc_STRVAR(os_seteuid__doc__, |
| 5763 |
"seteuid($module, euid, /)\n" |
| 5764 |
"--\n" |
| 5765 |
"\n" |
| 5766 |
"Set the current process\'s effective user id."); |
| 5767 |
|
| 5768 |
#define OS_SETEUID_METHODDEF \ |
| 5769 |
{"seteuid", (PyCFunction)os_seteuid, METH_O, os_seteuid__doc__}, |
| 5770 |
|
| 5771 |
static PyObject * |
| 5772 |
os_seteuid_impl(PyObject *module, uid_t euid); |
| 5773 |
|
| 5774 |
static PyObject * |
| 5775 |
os_seteuid(PyObject *module, PyObject *arg) |
| 5776 |
{ |
| 5777 |
PyObject *return_value = NULL; |
| 5778 |
uid_t euid; |
| 5779 |
|
| 5780 |
if (!_Py_Uid_Converter(arg, &euid)) { |
| 5781 |
goto exit; |
| 5782 |
} |
| 5783 |
return_value = os_seteuid_impl(module, euid); |
| 5784 |
|
| 5785 |
exit: |
| 5786 |
return return_value; |
| 5787 |
} |
| 5788 |
|
| 5789 |
#endif /* defined(HAVE_SETEUID) */ |
| 5790 |
|
| 5791 |
#if defined(HAVE_SETEGID) |
| 5792 |
|
| 5793 |
PyDoc_STRVAR(os_setegid__doc__, |
| 5794 |
"setegid($module, egid, /)\n" |
| 5795 |
"--\n" |
| 5796 |
"\n" |
| 5797 |
"Set the current process\'s effective group id."); |
| 5798 |
|
| 5799 |
#define OS_SETEGID_METHODDEF \ |
| 5800 |
{"setegid", (PyCFunction)os_setegid, METH_O, os_setegid__doc__}, |
| 5801 |
|
| 5802 |
static PyObject * |
| 5803 |
os_setegid_impl(PyObject *module, gid_t egid); |
| 5804 |
|
| 5805 |
static PyObject * |
| 5806 |
os_setegid(PyObject *module, PyObject *arg) |
| 5807 |
{ |
| 5808 |
PyObject *return_value = NULL; |
| 5809 |
gid_t egid; |
| 5810 |
|
| 5811 |
if (!_Py_Gid_Converter(arg, &egid)) { |
| 5812 |
goto exit; |
| 5813 |
} |
| 5814 |
return_value = os_setegid_impl(module, egid); |
| 5815 |
|
| 5816 |
exit: |
| 5817 |
return return_value; |
| 5818 |
} |
| 5819 |
|
| 5820 |
#endif /* defined(HAVE_SETEGID) */ |
| 5821 |
|
| 5822 |
#if defined(HAVE_SETREUID) |
| 5823 |
|
| 5824 |
PyDoc_STRVAR(os_setreuid__doc__, |
| 5825 |
"setreuid($module, ruid, euid, /)\n" |
| 5826 |
"--\n" |
| 5827 |
"\n" |
| 5828 |
"Set the current process\'s real and effective user ids."); |
| 5829 |
|
| 5830 |
#define OS_SETREUID_METHODDEF \ |
| 5831 |
{"setreuid", _PyCFunction_CAST(os_setreuid), METH_FASTCALL, os_setreuid__doc__}, |
| 5832 |
|
| 5833 |
static PyObject * |
| 5834 |
os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid); |
| 5835 |
|
| 5836 |
static PyObject * |
| 5837 |
os_setreuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5838 |
{ |
| 5839 |
PyObject *return_value = NULL; |
| 5840 |
uid_t ruid; |
| 5841 |
uid_t euid; |
| 5842 |
|
| 5843 |
if (!_PyArg_CheckPositional("setreuid", nargs, 2, 2)) { |
| 5844 |
goto exit; |
| 5845 |
} |
| 5846 |
if (!_Py_Uid_Converter(args[0], &ruid)) { |
| 5847 |
goto exit; |
| 5848 |
} |
| 5849 |
if (!_Py_Uid_Converter(args[1], &euid)) { |
| 5850 |
goto exit; |
| 5851 |
} |
| 5852 |
return_value = os_setreuid_impl(module, ruid, euid); |
| 5853 |
|
| 5854 |
exit: |
| 5855 |
return return_value; |
| 5856 |
} |
| 5857 |
|
| 5858 |
#endif /* defined(HAVE_SETREUID) */ |
| 5859 |
|
| 5860 |
#if defined(HAVE_SETREGID) |
| 5861 |
|
| 5862 |
PyDoc_STRVAR(os_setregid__doc__, |
| 5863 |
"setregid($module, rgid, egid, /)\n" |
| 5864 |
"--\n" |
| 5865 |
"\n" |
| 5866 |
"Set the current process\'s real and effective group ids."); |
| 5867 |
|
| 5868 |
#define OS_SETREGID_METHODDEF \ |
| 5869 |
{"setregid", _PyCFunction_CAST(os_setregid), METH_FASTCALL, os_setregid__doc__}, |
| 5870 |
|
| 5871 |
static PyObject * |
| 5872 |
os_setregid_impl(PyObject *module, gid_t rgid, gid_t egid); |
| 5873 |
|
| 5874 |
static PyObject * |
| 5875 |
os_setregid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 5876 |
{ |
| 5877 |
PyObject *return_value = NULL; |
| 5878 |
gid_t rgid; |
| 5879 |
gid_t egid; |
| 5880 |
|
| 5881 |
if (!_PyArg_CheckPositional("setregid", nargs, 2, 2)) { |
| 5882 |
goto exit; |
| 5883 |
} |
| 5884 |
if (!_Py_Gid_Converter(args[0], &rgid)) { |
| 5885 |
goto exit; |
| 5886 |
} |
| 5887 |
if (!_Py_Gid_Converter(args[1], &egid)) { |
| 5888 |
goto exit; |
| 5889 |
} |
| 5890 |
return_value = os_setregid_impl(module, rgid, egid); |
| 5891 |
|
| 5892 |
exit: |
| 5893 |
return return_value; |
| 5894 |
} |
| 5895 |
|
| 5896 |
#endif /* defined(HAVE_SETREGID) */ |
| 5897 |
|
| 5898 |
#if defined(HAVE_SETGID) |
| 5899 |
|
| 5900 |
PyDoc_STRVAR(os_setgid__doc__, |
| 5901 |
"setgid($module, gid, /)\n" |
| 5902 |
"--\n" |
| 5903 |
"\n" |
| 5904 |
"Set the current process\'s group id."); |
| 5905 |
|
| 5906 |
#define OS_SETGID_METHODDEF \ |
| 5907 |
{"setgid", (PyCFunction)os_setgid, METH_O, os_setgid__doc__}, |
| 5908 |
|
| 5909 |
static PyObject * |
| 5910 |
os_setgid_impl(PyObject *module, gid_t gid); |
| 5911 |
|
| 5912 |
static PyObject * |
| 5913 |
os_setgid(PyObject *module, PyObject *arg) |
| 5914 |
{ |
| 5915 |
PyObject *return_value = NULL; |
| 5916 |
gid_t gid; |
| 5917 |
|
| 5918 |
if (!_Py_Gid_Converter(arg, &gid)) { |
| 5919 |
goto exit; |
| 5920 |
} |
| 5921 |
return_value = os_setgid_impl(module, gid); |
| 5922 |
|
| 5923 |
exit: |
| 5924 |
return return_value; |
| 5925 |
} |
| 5926 |
|
| 5927 |
#endif /* defined(HAVE_SETGID) */ |
| 5928 |
|
| 5929 |
#if defined(HAVE_SETGROUPS) |
| 5930 |
|
| 5931 |
PyDoc_STRVAR(os_setgroups__doc__, |
| 5932 |
"setgroups($module, groups, /)\n" |
| 5933 |
"--\n" |
| 5934 |
"\n" |
| 5935 |
"Set the groups of the current process to list."); |
| 5936 |
|
| 5937 |
#define OS_SETGROUPS_METHODDEF \ |
| 5938 |
{"setgroups", (PyCFunction)os_setgroups, METH_O, os_setgroups__doc__}, |
| 5939 |
|
| 5940 |
#endif /* defined(HAVE_SETGROUPS) */ |
| 5941 |
|
| 5942 |
#if defined(HAVE_WAIT3) |
| 5943 |
|
| 5944 |
PyDoc_STRVAR(os_wait3__doc__, |
| 5945 |
"wait3($module, /, options)\n" |
| 5946 |
"--\n" |
| 5947 |
"\n" |
| 5948 |
"Wait for completion of a child process.\n" |
| 5949 |
"\n" |
| 5950 |
"Returns a tuple of information about the child process:\n" |
| 5951 |
" (pid, status, rusage)"); |
| 5952 |
|
| 5953 |
#define OS_WAIT3_METHODDEF \ |
| 5954 |
{"wait3", _PyCFunction_CAST(os_wait3), METH_FASTCALL|METH_KEYWORDS, os_wait3__doc__}, |
| 5955 |
|
| 5956 |
static PyObject * |
| 5957 |
os_wait3_impl(PyObject *module, int options); |
| 5958 |
|
| 5959 |
static PyObject * |
| 5960 |
os_wait3(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 5961 |
{ |
| 5962 |
PyObject *return_value = NULL; |
| 5963 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 5964 |
|
| 5965 |
#define NUM_KEYWORDS 1 |
| 5966 |
static struct { |
| 5967 |
PyGC_Head _this_is_not_used; |
| 5968 |
PyObject_VAR_HEAD |
| 5969 |
Py_hash_t ob_hash; |
| 5970 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 5971 |
} _kwtuple = { |
| 5972 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 5973 |
.ob_hash = -1, |
| 5974 |
.ob_item = { &_Py_ID(options), }, |
| 5975 |
}; |
| 5976 |
#undef NUM_KEYWORDS |
| 5977 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 5978 |
|
| 5979 |
#else // !Py_BUILD_CORE |
| 5980 |
# define KWTUPLE NULL |
| 5981 |
#endif // !Py_BUILD_CORE |
| 5982 |
|
| 5983 |
static const char * const _keywords[] = {"options", NULL}; |
| 5984 |
static _PyArg_Parser _parser = { |
| 5985 |
.keywords = _keywords, |
| 5986 |
.fname = "wait3", |
| 5987 |
.kwtuple = KWTUPLE, |
| 5988 |
}; |
| 5989 |
#undef KWTUPLE |
| 5990 |
PyObject *argsbuf[1]; |
| 5991 |
int options; |
| 5992 |
|
| 5993 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 5994 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 5995 |
if (!args) { |
| 5996 |
goto exit; |
| 5997 |
} |
| 5998 |
options = PyLong_AsInt(args[0]); |
| 5999 |
if (options == -1 && PyErr_Occurred()) { |
| 6000 |
goto exit; |
| 6001 |
} |
| 6002 |
return_value = os_wait3_impl(module, options); |
| 6003 |
|
| 6004 |
exit: |
| 6005 |
return return_value; |
| 6006 |
} |
| 6007 |
|
| 6008 |
#endif /* defined(HAVE_WAIT3) */ |
| 6009 |
|
| 6010 |
#if defined(HAVE_WAIT4) |
| 6011 |
|
| 6012 |
PyDoc_STRVAR(os_wait4__doc__, |
| 6013 |
"wait4($module, /, pid, options)\n" |
| 6014 |
"--\n" |
| 6015 |
"\n" |
| 6016 |
"Wait for completion of a specific child process.\n" |
| 6017 |
"\n" |
| 6018 |
"Returns a tuple of information about the child process:\n" |
| 6019 |
" (pid, status, rusage)"); |
| 6020 |
|
| 6021 |
#define OS_WAIT4_METHODDEF \ |
| 6022 |
{"wait4", _PyCFunction_CAST(os_wait4), METH_FASTCALL|METH_KEYWORDS, os_wait4__doc__}, |
| 6023 |
|
| 6024 |
static PyObject * |
| 6025 |
os_wait4_impl(PyObject *module, pid_t pid, int options); |
| 6026 |
|
| 6027 |
static PyObject * |
| 6028 |
os_wait4(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6029 |
{ |
| 6030 |
PyObject *return_value = NULL; |
| 6031 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6032 |
|
| 6033 |
#define NUM_KEYWORDS 2 |
| 6034 |
static struct { |
| 6035 |
PyGC_Head _this_is_not_used; |
| 6036 |
PyObject_VAR_HEAD |
| 6037 |
Py_hash_t ob_hash; |
| 6038 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6039 |
} _kwtuple = { |
| 6040 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6041 |
.ob_hash = -1, |
| 6042 |
.ob_item = { &_Py_ID(pid), &_Py_ID(options), }, |
| 6043 |
}; |
| 6044 |
#undef NUM_KEYWORDS |
| 6045 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6046 |
|
| 6047 |
#else // !Py_BUILD_CORE |
| 6048 |
# define KWTUPLE NULL |
| 6049 |
#endif // !Py_BUILD_CORE |
| 6050 |
|
| 6051 |
static const char * const _keywords[] = {"pid", "options", NULL}; |
| 6052 |
static _PyArg_Parser _parser = { |
| 6053 |
.keywords = _keywords, |
| 6054 |
.fname = "wait4", |
| 6055 |
.kwtuple = KWTUPLE, |
| 6056 |
}; |
| 6057 |
#undef KWTUPLE |
| 6058 |
PyObject *argsbuf[2]; |
| 6059 |
pid_t pid; |
| 6060 |
int options; |
| 6061 |
|
| 6062 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6063 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6064 |
if (!args) { |
| 6065 |
goto exit; |
| 6066 |
} |
| 6067 |
pid = PyLong_AsPid(args[0]); |
| 6068 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 6069 |
goto exit; |
| 6070 |
} |
| 6071 |
options = PyLong_AsInt(args[1]); |
| 6072 |
if (options == -1 && PyErr_Occurred()) { |
| 6073 |
goto exit; |
| 6074 |
} |
| 6075 |
return_value = os_wait4_impl(module, pid, options); |
| 6076 |
|
| 6077 |
exit: |
| 6078 |
return return_value; |
| 6079 |
} |
| 6080 |
|
| 6081 |
#endif /* defined(HAVE_WAIT4) */ |
| 6082 |
|
| 6083 |
#if defined(HAVE_WAITID) |
| 6084 |
|
| 6085 |
PyDoc_STRVAR(os_waitid__doc__, |
| 6086 |
"waitid($module, idtype, id, options, /)\n" |
| 6087 |
"--\n" |
| 6088 |
"\n" |
| 6089 |
"Returns the result of waiting for a process or processes.\n" |
| 6090 |
"\n" |
| 6091 |
" idtype\n" |
| 6092 |
" Must be one of be P_PID, P_PGID or P_ALL.\n" |
| 6093 |
" id\n" |
| 6094 |
" The id to wait on.\n" |
| 6095 |
" options\n" |
| 6096 |
" Constructed from the ORing of one or more of WEXITED, WSTOPPED\n" |
| 6097 |
" or WCONTINUED and additionally may be ORed with WNOHANG or WNOWAIT.\n" |
| 6098 |
"\n" |
| 6099 |
"Returns either waitid_result or None if WNOHANG is specified and there are\n" |
| 6100 |
"no children in a waitable state."); |
| 6101 |
|
| 6102 |
#define OS_WAITID_METHODDEF \ |
| 6103 |
{"waitid", _PyCFunction_CAST(os_waitid), METH_FASTCALL, os_waitid__doc__}, |
| 6104 |
|
| 6105 |
static PyObject * |
| 6106 |
os_waitid_impl(PyObject *module, idtype_t idtype, id_t id, int options); |
| 6107 |
|
| 6108 |
static PyObject * |
| 6109 |
os_waitid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 6110 |
{ |
| 6111 |
PyObject *return_value = NULL; |
| 6112 |
idtype_t idtype; |
| 6113 |
id_t id; |
| 6114 |
int options; |
| 6115 |
|
| 6116 |
if (!_PyArg_CheckPositional("waitid", nargs, 3, 3)) { |
| 6117 |
goto exit; |
| 6118 |
} |
| 6119 |
if (!idtype_t_converter(args[0], &idtype)) { |
| 6120 |
goto exit; |
| 6121 |
} |
| 6122 |
id = (id_t)PyLong_AsPid(args[1]); |
| 6123 |
if (id == (id_t)(-1) && PyErr_Occurred()) { |
| 6124 |
goto exit; |
| 6125 |
} |
| 6126 |
options = PyLong_AsInt(args[2]); |
| 6127 |
if (options == -1 && PyErr_Occurred()) { |
| 6128 |
goto exit; |
| 6129 |
} |
| 6130 |
return_value = os_waitid_impl(module, idtype, id, options); |
| 6131 |
|
| 6132 |
exit: |
| 6133 |
return return_value; |
| 6134 |
} |
| 6135 |
|
| 6136 |
#endif /* defined(HAVE_WAITID) */ |
| 6137 |
|
| 6138 |
#if defined(HAVE_WAITPID) |
| 6139 |
|
| 6140 |
PyDoc_STRVAR(os_waitpid__doc__, |
| 6141 |
"waitpid($module, pid, options, /)\n" |
| 6142 |
"--\n" |
| 6143 |
"\n" |
| 6144 |
"Wait for completion of a given child process.\n" |
| 6145 |
"\n" |
| 6146 |
"Returns a tuple of information regarding the child process:\n" |
| 6147 |
" (pid, status)\n" |
| 6148 |
"\n" |
| 6149 |
"The options argument is ignored on Windows."); |
| 6150 |
|
| 6151 |
#define OS_WAITPID_METHODDEF \ |
| 6152 |
{"waitpid", _PyCFunction_CAST(os_waitpid), METH_FASTCALL, os_waitpid__doc__}, |
| 6153 |
|
| 6154 |
static PyObject * |
| 6155 |
os_waitpid_impl(PyObject *module, pid_t pid, int options); |
| 6156 |
|
| 6157 |
static PyObject * |
| 6158 |
os_waitpid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 6159 |
{ |
| 6160 |
PyObject *return_value = NULL; |
| 6161 |
pid_t pid; |
| 6162 |
int options; |
| 6163 |
|
| 6164 |
if (!_PyArg_CheckPositional("waitpid", nargs, 2, 2)) { |
| 6165 |
goto exit; |
| 6166 |
} |
| 6167 |
pid = PyLong_AsPid(args[0]); |
| 6168 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 6169 |
goto exit; |
| 6170 |
} |
| 6171 |
options = PyLong_AsInt(args[1]); |
| 6172 |
if (options == -1 && PyErr_Occurred()) { |
| 6173 |
goto exit; |
| 6174 |
} |
| 6175 |
return_value = os_waitpid_impl(module, pid, options); |
| 6176 |
|
| 6177 |
exit: |
| 6178 |
return return_value; |
| 6179 |
} |
| 6180 |
|
| 6181 |
#endif /* defined(HAVE_WAITPID) */ |
| 6182 |
|
| 6183 |
#if !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) |
| 6184 |
|
| 6185 |
PyDoc_STRVAR(os_waitpid__doc__, |
| 6186 |
"waitpid($module, pid, options, /)\n" |
| 6187 |
"--\n" |
| 6188 |
"\n" |
| 6189 |
"Wait for completion of a given process.\n" |
| 6190 |
"\n" |
| 6191 |
"Returns a tuple of information regarding the process:\n" |
| 6192 |
" (pid, status << 8)\n" |
| 6193 |
"\n" |
| 6194 |
"The options argument is ignored on Windows."); |
| 6195 |
|
| 6196 |
#define OS_WAITPID_METHODDEF \ |
| 6197 |
{"waitpid", _PyCFunction_CAST(os_waitpid), METH_FASTCALL, os_waitpid__doc__}, |
| 6198 |
|
| 6199 |
static PyObject * |
| 6200 |
os_waitpid_impl(PyObject *module, intptr_t pid, int options); |
| 6201 |
|
| 6202 |
static PyObject * |
| 6203 |
os_waitpid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 6204 |
{ |
| 6205 |
PyObject *return_value = NULL; |
| 6206 |
intptr_t pid; |
| 6207 |
int options; |
| 6208 |
|
| 6209 |
if (!_PyArg_CheckPositional("waitpid", nargs, 2, 2)) { |
| 6210 |
goto exit; |
| 6211 |
} |
| 6212 |
pid = (intptr_t)PyLong_AsVoidPtr(args[0]); |
| 6213 |
if (!pid && PyErr_Occurred()) { |
| 6214 |
goto exit; |
| 6215 |
} |
| 6216 |
options = PyLong_AsInt(args[1]); |
| 6217 |
if (options == -1 && PyErr_Occurred()) { |
| 6218 |
goto exit; |
| 6219 |
} |
| 6220 |
return_value = os_waitpid_impl(module, pid, options); |
| 6221 |
|
| 6222 |
exit: |
| 6223 |
return return_value; |
| 6224 |
} |
| 6225 |
|
| 6226 |
#endif /* !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) */ |
| 6227 |
|
| 6228 |
#if defined(HAVE_WAIT) |
| 6229 |
|
| 6230 |
PyDoc_STRVAR(os_wait__doc__, |
| 6231 |
"wait($module, /)\n" |
| 6232 |
"--\n" |
| 6233 |
"\n" |
| 6234 |
"Wait for completion of a child process.\n" |
| 6235 |
"\n" |
| 6236 |
"Returns a tuple of information about the child process:\n" |
| 6237 |
" (pid, status)"); |
| 6238 |
|
| 6239 |
#define OS_WAIT_METHODDEF \ |
| 6240 |
{"wait", (PyCFunction)os_wait, METH_NOARGS, os_wait__doc__}, |
| 6241 |
|
| 6242 |
static PyObject * |
| 6243 |
os_wait_impl(PyObject *module); |
| 6244 |
|
| 6245 |
static PyObject * |
| 6246 |
os_wait(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 6247 |
{ |
| 6248 |
return os_wait_impl(module); |
| 6249 |
} |
| 6250 |
|
| 6251 |
#endif /* defined(HAVE_WAIT) */ |
| 6252 |
|
| 6253 |
#if (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) |
| 6254 |
|
| 6255 |
PyDoc_STRVAR(os_pidfd_open__doc__, |
| 6256 |
"pidfd_open($module, /, pid, flags=0)\n" |
| 6257 |
"--\n" |
| 6258 |
"\n" |
| 6259 |
"Return a file descriptor referring to the process *pid*.\n" |
| 6260 |
"\n" |
| 6261 |
"The descriptor can be used to perform process management without races and\n" |
| 6262 |
"signals."); |
| 6263 |
|
| 6264 |
#define OS_PIDFD_OPEN_METHODDEF \ |
| 6265 |
{"pidfd_open", _PyCFunction_CAST(os_pidfd_open), METH_FASTCALL|METH_KEYWORDS, os_pidfd_open__doc__}, |
| 6266 |
|
| 6267 |
static PyObject * |
| 6268 |
os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags); |
| 6269 |
|
| 6270 |
static PyObject * |
| 6271 |
os_pidfd_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6272 |
{ |
| 6273 |
PyObject *return_value = NULL; |
| 6274 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6275 |
|
| 6276 |
#define NUM_KEYWORDS 2 |
| 6277 |
static struct { |
| 6278 |
PyGC_Head _this_is_not_used; |
| 6279 |
PyObject_VAR_HEAD |
| 6280 |
Py_hash_t ob_hash; |
| 6281 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6282 |
} _kwtuple = { |
| 6283 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6284 |
.ob_hash = -1, |
| 6285 |
.ob_item = { &_Py_ID(pid), &_Py_ID(flags), }, |
| 6286 |
}; |
| 6287 |
#undef NUM_KEYWORDS |
| 6288 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6289 |
|
| 6290 |
#else // !Py_BUILD_CORE |
| 6291 |
# define KWTUPLE NULL |
| 6292 |
#endif // !Py_BUILD_CORE |
| 6293 |
|
| 6294 |
static const char * const _keywords[] = {"pid", "flags", NULL}; |
| 6295 |
static _PyArg_Parser _parser = { |
| 6296 |
.keywords = _keywords, |
| 6297 |
.fname = "pidfd_open", |
| 6298 |
.kwtuple = KWTUPLE, |
| 6299 |
}; |
| 6300 |
#undef KWTUPLE |
| 6301 |
PyObject *argsbuf[2]; |
| 6302 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 6303 |
pid_t pid; |
| 6304 |
unsigned int flags = 0; |
| 6305 |
|
| 6306 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6307 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6308 |
if (!args) { |
| 6309 |
goto exit; |
| 6310 |
} |
| 6311 |
pid = PyLong_AsPid(args[0]); |
| 6312 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 6313 |
goto exit; |
| 6314 |
} |
| 6315 |
if (!noptargs) { |
| 6316 |
goto skip_optional_pos; |
| 6317 |
} |
| 6318 |
if (!_PyLong_UnsignedInt_Converter(args[1], &flags)) { |
| 6319 |
goto exit; |
| 6320 |
} |
| 6321 |
skip_optional_pos: |
| 6322 |
return_value = os_pidfd_open_impl(module, pid, flags); |
| 6323 |
|
| 6324 |
exit: |
| 6325 |
return return_value; |
| 6326 |
} |
| 6327 |
|
| 6328 |
#endif /* (defined(__linux__) && defined(__NR_pidfd_open) && !(defined(__ANDROID__) && __ANDROID_API__ < 31)) */ |
| 6329 |
|
| 6330 |
#if defined(HAVE_SETNS) |
| 6331 |
|
| 6332 |
PyDoc_STRVAR(os_setns__doc__, |
| 6333 |
"setns($module, /, fd, nstype=0)\n" |
| 6334 |
"--\n" |
| 6335 |
"\n" |
| 6336 |
"Move the calling thread into different namespaces.\n" |
| 6337 |
"\n" |
| 6338 |
" fd\n" |
| 6339 |
" A file descriptor to a namespace.\n" |
| 6340 |
" nstype\n" |
| 6341 |
" Type of namespace."); |
| 6342 |
|
| 6343 |
#define OS_SETNS_METHODDEF \ |
| 6344 |
{"setns", _PyCFunction_CAST(os_setns), METH_FASTCALL|METH_KEYWORDS, os_setns__doc__}, |
| 6345 |
|
| 6346 |
static PyObject * |
| 6347 |
os_setns_impl(PyObject *module, int fd, int nstype); |
| 6348 |
|
| 6349 |
static PyObject * |
| 6350 |
os_setns(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6351 |
{ |
| 6352 |
PyObject *return_value = NULL; |
| 6353 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6354 |
|
| 6355 |
#define NUM_KEYWORDS 2 |
| 6356 |
static struct { |
| 6357 |
PyGC_Head _this_is_not_used; |
| 6358 |
PyObject_VAR_HEAD |
| 6359 |
Py_hash_t ob_hash; |
| 6360 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6361 |
} _kwtuple = { |
| 6362 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6363 |
.ob_hash = -1, |
| 6364 |
.ob_item = { &_Py_ID(fd), &_Py_ID(nstype), }, |
| 6365 |
}; |
| 6366 |
#undef NUM_KEYWORDS |
| 6367 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6368 |
|
| 6369 |
#else // !Py_BUILD_CORE |
| 6370 |
# define KWTUPLE NULL |
| 6371 |
#endif // !Py_BUILD_CORE |
| 6372 |
|
| 6373 |
static const char * const _keywords[] = {"fd", "nstype", NULL}; |
| 6374 |
static _PyArg_Parser _parser = { |
| 6375 |
.keywords = _keywords, |
| 6376 |
.fname = "setns", |
| 6377 |
.kwtuple = KWTUPLE, |
| 6378 |
}; |
| 6379 |
#undef KWTUPLE |
| 6380 |
PyObject *argsbuf[2]; |
| 6381 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 6382 |
int fd; |
| 6383 |
int nstype = 0; |
| 6384 |
|
| 6385 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6386 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6387 |
if (!args) { |
| 6388 |
goto exit; |
| 6389 |
} |
| 6390 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 6391 |
if (fd < 0) { |
| 6392 |
goto exit; |
| 6393 |
} |
| 6394 |
if (!noptargs) { |
| 6395 |
goto skip_optional_pos; |
| 6396 |
} |
| 6397 |
nstype = PyLong_AsInt(args[1]); |
| 6398 |
if (nstype == -1 && PyErr_Occurred()) { |
| 6399 |
goto exit; |
| 6400 |
} |
| 6401 |
skip_optional_pos: |
| 6402 |
return_value = os_setns_impl(module, fd, nstype); |
| 6403 |
|
| 6404 |
exit: |
| 6405 |
return return_value; |
| 6406 |
} |
| 6407 |
|
| 6408 |
#endif /* defined(HAVE_SETNS) */ |
| 6409 |
|
| 6410 |
#if defined(HAVE_UNSHARE) |
| 6411 |
|
| 6412 |
PyDoc_STRVAR(os_unshare__doc__, |
| 6413 |
"unshare($module, /, flags)\n" |
| 6414 |
"--\n" |
| 6415 |
"\n" |
| 6416 |
"Disassociate parts of a process (or thread) execution context.\n" |
| 6417 |
"\n" |
| 6418 |
" flags\n" |
| 6419 |
" Namespaces to be unshared."); |
| 6420 |
|
| 6421 |
#define OS_UNSHARE_METHODDEF \ |
| 6422 |
{"unshare", _PyCFunction_CAST(os_unshare), METH_FASTCALL|METH_KEYWORDS, os_unshare__doc__}, |
| 6423 |
|
| 6424 |
static PyObject * |
| 6425 |
os_unshare_impl(PyObject *module, int flags); |
| 6426 |
|
| 6427 |
static PyObject * |
| 6428 |
os_unshare(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6429 |
{ |
| 6430 |
PyObject *return_value = NULL; |
| 6431 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6432 |
|
| 6433 |
#define NUM_KEYWORDS 1 |
| 6434 |
static struct { |
| 6435 |
PyGC_Head _this_is_not_used; |
| 6436 |
PyObject_VAR_HEAD |
| 6437 |
Py_hash_t ob_hash; |
| 6438 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6439 |
} _kwtuple = { |
| 6440 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6441 |
.ob_hash = -1, |
| 6442 |
.ob_item = { &_Py_ID(flags), }, |
| 6443 |
}; |
| 6444 |
#undef NUM_KEYWORDS |
| 6445 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6446 |
|
| 6447 |
#else // !Py_BUILD_CORE |
| 6448 |
# define KWTUPLE NULL |
| 6449 |
#endif // !Py_BUILD_CORE |
| 6450 |
|
| 6451 |
static const char * const _keywords[] = {"flags", NULL}; |
| 6452 |
static _PyArg_Parser _parser = { |
| 6453 |
.keywords = _keywords, |
| 6454 |
.fname = "unshare", |
| 6455 |
.kwtuple = KWTUPLE, |
| 6456 |
}; |
| 6457 |
#undef KWTUPLE |
| 6458 |
PyObject *argsbuf[1]; |
| 6459 |
int flags; |
| 6460 |
|
| 6461 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6462 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6463 |
if (!args) { |
| 6464 |
goto exit; |
| 6465 |
} |
| 6466 |
flags = PyLong_AsInt(args[0]); |
| 6467 |
if (flags == -1 && PyErr_Occurred()) { |
| 6468 |
goto exit; |
| 6469 |
} |
| 6470 |
return_value = os_unshare_impl(module, flags); |
| 6471 |
|
| 6472 |
exit: |
| 6473 |
return return_value; |
| 6474 |
} |
| 6475 |
|
| 6476 |
#endif /* defined(HAVE_UNSHARE) */ |
| 6477 |
|
| 6478 |
#if (defined(HAVE_READLINK) || defined(MS_WINDOWS)) |
| 6479 |
|
| 6480 |
PyDoc_STRVAR(os_readlink__doc__, |
| 6481 |
"readlink($module, /, path, *, dir_fd=None)\n" |
| 6482 |
"--\n" |
| 6483 |
"\n" |
| 6484 |
"Return a string representing the path to which the symbolic link points.\n" |
| 6485 |
"\n" |
| 6486 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 6487 |
"and path should be relative; path will then be relative to that directory.\n" |
| 6488 |
"\n" |
| 6489 |
"dir_fd may not be implemented on your platform. If it is unavailable,\n" |
| 6490 |
"using it will raise a NotImplementedError."); |
| 6491 |
|
| 6492 |
#define OS_READLINK_METHODDEF \ |
| 6493 |
{"readlink", _PyCFunction_CAST(os_readlink), METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, |
| 6494 |
|
| 6495 |
static PyObject * |
| 6496 |
os_readlink_impl(PyObject *module, path_t *path, int dir_fd); |
| 6497 |
|
| 6498 |
static PyObject * |
| 6499 |
os_readlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6500 |
{ |
| 6501 |
PyObject *return_value = NULL; |
| 6502 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6503 |
|
| 6504 |
#define NUM_KEYWORDS 2 |
| 6505 |
static struct { |
| 6506 |
PyGC_Head _this_is_not_used; |
| 6507 |
PyObject_VAR_HEAD |
| 6508 |
Py_hash_t ob_hash; |
| 6509 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6510 |
} _kwtuple = { |
| 6511 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6512 |
.ob_hash = -1, |
| 6513 |
.ob_item = { &_Py_ID(path), &_Py_ID(dir_fd), }, |
| 6514 |
}; |
| 6515 |
#undef NUM_KEYWORDS |
| 6516 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6517 |
|
| 6518 |
#else // !Py_BUILD_CORE |
| 6519 |
# define KWTUPLE NULL |
| 6520 |
#endif // !Py_BUILD_CORE |
| 6521 |
|
| 6522 |
static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
| 6523 |
static _PyArg_Parser _parser = { |
| 6524 |
.keywords = _keywords, |
| 6525 |
.fname = "readlink", |
| 6526 |
.kwtuple = KWTUPLE, |
| 6527 |
}; |
| 6528 |
#undef KWTUPLE |
| 6529 |
PyObject *argsbuf[2]; |
| 6530 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 6531 |
path_t path = PATH_T_INITIALIZE_P("readlink", "path", 0, 0, 0, 0); |
| 6532 |
int dir_fd = DEFAULT_DIR_FD; |
| 6533 |
|
| 6534 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6535 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6536 |
if (!args) { |
| 6537 |
goto exit; |
| 6538 |
} |
| 6539 |
if (!path_converter(args[0], &path)) { |
| 6540 |
goto exit; |
| 6541 |
} |
| 6542 |
if (!noptargs) { |
| 6543 |
goto skip_optional_kwonly; |
| 6544 |
} |
| 6545 |
if (!READLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { |
| 6546 |
goto exit; |
| 6547 |
} |
| 6548 |
skip_optional_kwonly: |
| 6549 |
return_value = os_readlink_impl(module, &path, dir_fd); |
| 6550 |
|
| 6551 |
exit: |
| 6552 |
/* Cleanup for path */ |
| 6553 |
path_cleanup(&path); |
| 6554 |
|
| 6555 |
return return_value; |
| 6556 |
} |
| 6557 |
|
| 6558 |
#endif /* (defined(HAVE_READLINK) || defined(MS_WINDOWS)) */ |
| 6559 |
|
| 6560 |
#if defined(HAVE_SYMLINK) |
| 6561 |
|
| 6562 |
PyDoc_STRVAR(os_symlink__doc__, |
| 6563 |
"symlink($module, /, src, dst, target_is_directory=False, *, dir_fd=None)\n" |
| 6564 |
"--\n" |
| 6565 |
"\n" |
| 6566 |
"Create a symbolic link pointing to src named dst.\n" |
| 6567 |
"\n" |
| 6568 |
"target_is_directory is required on Windows if the target is to be\n" |
| 6569 |
" interpreted as a directory. (On Windows, symlink requires\n" |
| 6570 |
" Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n" |
| 6571 |
" target_is_directory is ignored on non-Windows platforms.\n" |
| 6572 |
"\n" |
| 6573 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 6574 |
" and path should be relative; path will then be relative to that directory.\n" |
| 6575 |
"dir_fd may not be implemented on your platform.\n" |
| 6576 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 6577 |
|
| 6578 |
#define OS_SYMLINK_METHODDEF \ |
| 6579 |
{"symlink", _PyCFunction_CAST(os_symlink), METH_FASTCALL|METH_KEYWORDS, os_symlink__doc__}, |
| 6580 |
|
| 6581 |
static PyObject * |
| 6582 |
os_symlink_impl(PyObject *module, path_t *src, path_t *dst, |
| 6583 |
int target_is_directory, int dir_fd); |
| 6584 |
|
| 6585 |
static PyObject * |
| 6586 |
os_symlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6587 |
{ |
| 6588 |
PyObject *return_value = NULL; |
| 6589 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6590 |
|
| 6591 |
#define NUM_KEYWORDS 4 |
| 6592 |
static struct { |
| 6593 |
PyGC_Head _this_is_not_used; |
| 6594 |
PyObject_VAR_HEAD |
| 6595 |
Py_hash_t ob_hash; |
| 6596 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6597 |
} _kwtuple = { |
| 6598 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6599 |
.ob_hash = -1, |
| 6600 |
.ob_item = { &_Py_ID(src), &_Py_ID(dst), &_Py_ID(target_is_directory), &_Py_ID(dir_fd), }, |
| 6601 |
}; |
| 6602 |
#undef NUM_KEYWORDS |
| 6603 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6604 |
|
| 6605 |
#else // !Py_BUILD_CORE |
| 6606 |
# define KWTUPLE NULL |
| 6607 |
#endif // !Py_BUILD_CORE |
| 6608 |
|
| 6609 |
static const char * const _keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; |
| 6610 |
static _PyArg_Parser _parser = { |
| 6611 |
.keywords = _keywords, |
| 6612 |
.fname = "symlink", |
| 6613 |
.kwtuple = KWTUPLE, |
| 6614 |
}; |
| 6615 |
#undef KWTUPLE |
| 6616 |
PyObject *argsbuf[4]; |
| 6617 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 6618 |
path_t src = PATH_T_INITIALIZE_P("symlink", "src", 0, 0, 0, 0); |
| 6619 |
path_t dst = PATH_T_INITIALIZE_P("symlink", "dst", 0, 0, 0, 0); |
| 6620 |
int target_is_directory = 0; |
| 6621 |
int dir_fd = DEFAULT_DIR_FD; |
| 6622 |
|
| 6623 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6624 |
/*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6625 |
if (!args) { |
| 6626 |
goto exit; |
| 6627 |
} |
| 6628 |
if (!path_converter(args[0], &src)) { |
| 6629 |
goto exit; |
| 6630 |
} |
| 6631 |
if (!path_converter(args[1], &dst)) { |
| 6632 |
goto exit; |
| 6633 |
} |
| 6634 |
if (!noptargs) { |
| 6635 |
goto skip_optional_pos; |
| 6636 |
} |
| 6637 |
if (args[2]) { |
| 6638 |
target_is_directory = PyObject_IsTrue(args[2]); |
| 6639 |
if (target_is_directory < 0) { |
| 6640 |
goto exit; |
| 6641 |
} |
| 6642 |
if (!--noptargs) { |
| 6643 |
goto skip_optional_pos; |
| 6644 |
} |
| 6645 |
} |
| 6646 |
skip_optional_pos: |
| 6647 |
if (!noptargs) { |
| 6648 |
goto skip_optional_kwonly; |
| 6649 |
} |
| 6650 |
if (!SYMLINKAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { |
| 6651 |
goto exit; |
| 6652 |
} |
| 6653 |
skip_optional_kwonly: |
| 6654 |
return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); |
| 6655 |
|
| 6656 |
exit: |
| 6657 |
/* Cleanup for src */ |
| 6658 |
path_cleanup(&src); |
| 6659 |
/* Cleanup for dst */ |
| 6660 |
path_cleanup(&dst); |
| 6661 |
|
| 6662 |
return return_value; |
| 6663 |
} |
| 6664 |
|
| 6665 |
#endif /* defined(HAVE_SYMLINK) */ |
| 6666 |
|
| 6667 |
PyDoc_STRVAR(os_times__doc__, |
| 6668 |
"times($module, /)\n" |
| 6669 |
"--\n" |
| 6670 |
"\n" |
| 6671 |
"Return a collection containing process timing information.\n" |
| 6672 |
"\n" |
| 6673 |
"The object returned behaves like a named tuple with these fields:\n" |
| 6674 |
" (utime, stime, cutime, cstime, elapsed_time)\n" |
| 6675 |
"All fields are floating-point numbers."); |
| 6676 |
|
| 6677 |
#define OS_TIMES_METHODDEF \ |
| 6678 |
{"times", (PyCFunction)os_times, METH_NOARGS, os_times__doc__}, |
| 6679 |
|
| 6680 |
static PyObject * |
| 6681 |
os_times_impl(PyObject *module); |
| 6682 |
|
| 6683 |
static PyObject * |
| 6684 |
os_times(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 6685 |
{ |
| 6686 |
return os_times_impl(module); |
| 6687 |
} |
| 6688 |
|
| 6689 |
#if defined(HAVE_TIMERFD_CREATE) |
| 6690 |
|
| 6691 |
PyDoc_STRVAR(os_timerfd_create__doc__, |
| 6692 |
"timerfd_create($module, clockid, /, *, flags=0)\n" |
| 6693 |
"--\n" |
| 6694 |
"\n" |
| 6695 |
"Create and return a timer file descriptor.\n" |
| 6696 |
"\n" |
| 6697 |
" clockid\n" |
| 6698 |
" A valid clock ID constant as timer file descriptor.\n" |
| 6699 |
"\n" |
| 6700 |
" time.CLOCK_REALTIME\n" |
| 6701 |
" time.CLOCK_MONOTONIC\n" |
| 6702 |
" time.CLOCK_BOOTTIME\n" |
| 6703 |
" flags\n" |
| 6704 |
" 0 or a bit mask of os.TFD_NONBLOCK or os.TFD_CLOEXEC.\n" |
| 6705 |
"\n" |
| 6706 |
" os.TFD_NONBLOCK\n" |
| 6707 |
" If *TFD_NONBLOCK* is set as a flag, read doesn\'t blocks.\n" |
| 6708 |
" If *TFD_NONBLOCK* is not set as a flag, read block until the timer fires.\n" |
| 6709 |
"\n" |
| 6710 |
" os.TFD_CLOEXEC\n" |
| 6711 |
" If *TFD_CLOEXEC* is set as a flag, enable the close-on-exec flag"); |
| 6712 |
|
| 6713 |
#define OS_TIMERFD_CREATE_METHODDEF \ |
| 6714 |
{"timerfd_create", _PyCFunction_CAST(os_timerfd_create), METH_FASTCALL|METH_KEYWORDS, os_timerfd_create__doc__}, |
| 6715 |
|
| 6716 |
static PyObject * |
| 6717 |
os_timerfd_create_impl(PyObject *module, int clockid, int flags); |
| 6718 |
|
| 6719 |
static PyObject * |
| 6720 |
os_timerfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6721 |
{ |
| 6722 |
PyObject *return_value = NULL; |
| 6723 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6724 |
|
| 6725 |
#define NUM_KEYWORDS 1 |
| 6726 |
static struct { |
| 6727 |
PyGC_Head _this_is_not_used; |
| 6728 |
PyObject_VAR_HEAD |
| 6729 |
Py_hash_t ob_hash; |
| 6730 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6731 |
} _kwtuple = { |
| 6732 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6733 |
.ob_hash = -1, |
| 6734 |
.ob_item = { &_Py_ID(flags), }, |
| 6735 |
}; |
| 6736 |
#undef NUM_KEYWORDS |
| 6737 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6738 |
|
| 6739 |
#else // !Py_BUILD_CORE |
| 6740 |
# define KWTUPLE NULL |
| 6741 |
#endif // !Py_BUILD_CORE |
| 6742 |
|
| 6743 |
static const char * const _keywords[] = {"", "flags", NULL}; |
| 6744 |
static _PyArg_Parser _parser = { |
| 6745 |
.keywords = _keywords, |
| 6746 |
.fname = "timerfd_create", |
| 6747 |
.kwtuple = KWTUPLE, |
| 6748 |
}; |
| 6749 |
#undef KWTUPLE |
| 6750 |
PyObject *argsbuf[2]; |
| 6751 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 6752 |
int clockid; |
| 6753 |
int flags = 0; |
| 6754 |
|
| 6755 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6756 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6757 |
if (!args) { |
| 6758 |
goto exit; |
| 6759 |
} |
| 6760 |
clockid = PyLong_AsInt(args[0]); |
| 6761 |
if (clockid == -1 && PyErr_Occurred()) { |
| 6762 |
goto exit; |
| 6763 |
} |
| 6764 |
if (!noptargs) { |
| 6765 |
goto skip_optional_kwonly; |
| 6766 |
} |
| 6767 |
flags = PyLong_AsInt(args[1]); |
| 6768 |
if (flags == -1 && PyErr_Occurred()) { |
| 6769 |
goto exit; |
| 6770 |
} |
| 6771 |
skip_optional_kwonly: |
| 6772 |
return_value = os_timerfd_create_impl(module, clockid, flags); |
| 6773 |
|
| 6774 |
exit: |
| 6775 |
return return_value; |
| 6776 |
} |
| 6777 |
|
| 6778 |
#endif /* defined(HAVE_TIMERFD_CREATE) */ |
| 6779 |
|
| 6780 |
#if defined(HAVE_TIMERFD_CREATE) |
| 6781 |
|
| 6782 |
PyDoc_STRVAR(os_timerfd_settime__doc__, |
| 6783 |
"timerfd_settime($module, fd, /, *, flags=0, initial=0.0, interval=0.0)\n" |
| 6784 |
"--\n" |
| 6785 |
"\n" |
| 6786 |
"Alter a timer file descriptor\'s internal timer in seconds.\n" |
| 6787 |
"\n" |
| 6788 |
" fd\n" |
| 6789 |
" A timer file descriptor.\n" |
| 6790 |
" flags\n" |
| 6791 |
" 0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET.\n" |
| 6792 |
" initial\n" |
| 6793 |
" The initial expiration time, in seconds.\n" |
| 6794 |
" interval\n" |
| 6795 |
" The timer\'s interval, in seconds."); |
| 6796 |
|
| 6797 |
#define OS_TIMERFD_SETTIME_METHODDEF \ |
| 6798 |
{"timerfd_settime", _PyCFunction_CAST(os_timerfd_settime), METH_FASTCALL|METH_KEYWORDS, os_timerfd_settime__doc__}, |
| 6799 |
|
| 6800 |
static PyObject * |
| 6801 |
os_timerfd_settime_impl(PyObject *module, int fd, int flags, |
| 6802 |
double initial_double, double interval_double); |
| 6803 |
|
| 6804 |
static PyObject * |
| 6805 |
os_timerfd_settime(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6806 |
{ |
| 6807 |
PyObject *return_value = NULL; |
| 6808 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6809 |
|
| 6810 |
#define NUM_KEYWORDS 3 |
| 6811 |
static struct { |
| 6812 |
PyGC_Head _this_is_not_used; |
| 6813 |
PyObject_VAR_HEAD |
| 6814 |
Py_hash_t ob_hash; |
| 6815 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6816 |
} _kwtuple = { |
| 6817 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6818 |
.ob_hash = -1, |
| 6819 |
.ob_item = { &_Py_ID(flags), &_Py_ID(initial), &_Py_ID(interval), }, |
| 6820 |
}; |
| 6821 |
#undef NUM_KEYWORDS |
| 6822 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6823 |
|
| 6824 |
#else // !Py_BUILD_CORE |
| 6825 |
# define KWTUPLE NULL |
| 6826 |
#endif // !Py_BUILD_CORE |
| 6827 |
|
| 6828 |
static const char * const _keywords[] = {"", "flags", "initial", "interval", NULL}; |
| 6829 |
static _PyArg_Parser _parser = { |
| 6830 |
.keywords = _keywords, |
| 6831 |
.fname = "timerfd_settime", |
| 6832 |
.kwtuple = KWTUPLE, |
| 6833 |
}; |
| 6834 |
#undef KWTUPLE |
| 6835 |
PyObject *argsbuf[4]; |
| 6836 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 6837 |
int fd; |
| 6838 |
int flags = 0; |
| 6839 |
double initial_double = 0.0; |
| 6840 |
double interval_double = 0.0; |
| 6841 |
|
| 6842 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6843 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6844 |
if (!args) { |
| 6845 |
goto exit; |
| 6846 |
} |
| 6847 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 6848 |
if (fd < 0) { |
| 6849 |
goto exit; |
| 6850 |
} |
| 6851 |
if (!noptargs) { |
| 6852 |
goto skip_optional_kwonly; |
| 6853 |
} |
| 6854 |
if (args[1]) { |
| 6855 |
flags = PyLong_AsInt(args[1]); |
| 6856 |
if (flags == -1 && PyErr_Occurred()) { |
| 6857 |
goto exit; |
| 6858 |
} |
| 6859 |
if (!--noptargs) { |
| 6860 |
goto skip_optional_kwonly; |
| 6861 |
} |
| 6862 |
} |
| 6863 |
if (args[2]) { |
| 6864 |
if (PyFloat_CheckExact(args[2])) { |
| 6865 |
initial_double = PyFloat_AS_DOUBLE(args[2]); |
| 6866 |
} |
| 6867 |
else |
| 6868 |
{ |
| 6869 |
initial_double = PyFloat_AsDouble(args[2]); |
| 6870 |
if (initial_double == -1.0 && PyErr_Occurred()) { |
| 6871 |
goto exit; |
| 6872 |
} |
| 6873 |
} |
| 6874 |
if (!--noptargs) { |
| 6875 |
goto skip_optional_kwonly; |
| 6876 |
} |
| 6877 |
} |
| 6878 |
if (PyFloat_CheckExact(args[3])) { |
| 6879 |
interval_double = PyFloat_AS_DOUBLE(args[3]); |
| 6880 |
} |
| 6881 |
else |
| 6882 |
{ |
| 6883 |
interval_double = PyFloat_AsDouble(args[3]); |
| 6884 |
if (interval_double == -1.0 && PyErr_Occurred()) { |
| 6885 |
goto exit; |
| 6886 |
} |
| 6887 |
} |
| 6888 |
skip_optional_kwonly: |
| 6889 |
return_value = os_timerfd_settime_impl(module, fd, flags, initial_double, interval_double); |
| 6890 |
|
| 6891 |
exit: |
| 6892 |
return return_value; |
| 6893 |
} |
| 6894 |
|
| 6895 |
#endif /* defined(HAVE_TIMERFD_CREATE) */ |
| 6896 |
|
| 6897 |
#if defined(HAVE_TIMERFD_CREATE) |
| 6898 |
|
| 6899 |
PyDoc_STRVAR(os_timerfd_settime_ns__doc__, |
| 6900 |
"timerfd_settime_ns($module, fd, /, *, flags=0, initial=0, interval=0)\n" |
| 6901 |
"--\n" |
| 6902 |
"\n" |
| 6903 |
"Alter a timer file descriptor\'s internal timer in nanoseconds.\n" |
| 6904 |
"\n" |
| 6905 |
" fd\n" |
| 6906 |
" A timer file descriptor.\n" |
| 6907 |
" flags\n" |
| 6908 |
" 0 or a bit mask of TFD_TIMER_ABSTIME or TFD_TIMER_CANCEL_ON_SET.\n" |
| 6909 |
" initial\n" |
| 6910 |
" initial expiration timing in seconds.\n" |
| 6911 |
" interval\n" |
| 6912 |
" interval for the timer in seconds."); |
| 6913 |
|
| 6914 |
#define OS_TIMERFD_SETTIME_NS_METHODDEF \ |
| 6915 |
{"timerfd_settime_ns", _PyCFunction_CAST(os_timerfd_settime_ns), METH_FASTCALL|METH_KEYWORDS, os_timerfd_settime_ns__doc__}, |
| 6916 |
|
| 6917 |
static PyObject * |
| 6918 |
os_timerfd_settime_ns_impl(PyObject *module, int fd, int flags, |
| 6919 |
long long initial, long long interval); |
| 6920 |
|
| 6921 |
static PyObject * |
| 6922 |
os_timerfd_settime_ns(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 6923 |
{ |
| 6924 |
PyObject *return_value = NULL; |
| 6925 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 6926 |
|
| 6927 |
#define NUM_KEYWORDS 3 |
| 6928 |
static struct { |
| 6929 |
PyGC_Head _this_is_not_used; |
| 6930 |
PyObject_VAR_HEAD |
| 6931 |
Py_hash_t ob_hash; |
| 6932 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 6933 |
} _kwtuple = { |
| 6934 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 6935 |
.ob_hash = -1, |
| 6936 |
.ob_item = { &_Py_ID(flags), &_Py_ID(initial), &_Py_ID(interval), }, |
| 6937 |
}; |
| 6938 |
#undef NUM_KEYWORDS |
| 6939 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 6940 |
|
| 6941 |
#else // !Py_BUILD_CORE |
| 6942 |
# define KWTUPLE NULL |
| 6943 |
#endif // !Py_BUILD_CORE |
| 6944 |
|
| 6945 |
static const char * const _keywords[] = {"", "flags", "initial", "interval", NULL}; |
| 6946 |
static _PyArg_Parser _parser = { |
| 6947 |
.keywords = _keywords, |
| 6948 |
.fname = "timerfd_settime_ns", |
| 6949 |
.kwtuple = KWTUPLE, |
| 6950 |
}; |
| 6951 |
#undef KWTUPLE |
| 6952 |
PyObject *argsbuf[4]; |
| 6953 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 6954 |
int fd; |
| 6955 |
int flags = 0; |
| 6956 |
long long initial = 0; |
| 6957 |
long long interval = 0; |
| 6958 |
|
| 6959 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 6960 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 6961 |
if (!args) { |
| 6962 |
goto exit; |
| 6963 |
} |
| 6964 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 6965 |
if (fd < 0) { |
| 6966 |
goto exit; |
| 6967 |
} |
| 6968 |
if (!noptargs) { |
| 6969 |
goto skip_optional_kwonly; |
| 6970 |
} |
| 6971 |
if (args[1]) { |
| 6972 |
flags = PyLong_AsInt(args[1]); |
| 6973 |
if (flags == -1 && PyErr_Occurred()) { |
| 6974 |
goto exit; |
| 6975 |
} |
| 6976 |
if (!--noptargs) { |
| 6977 |
goto skip_optional_kwonly; |
| 6978 |
} |
| 6979 |
} |
| 6980 |
if (args[2]) { |
| 6981 |
initial = PyLong_AsLongLong(args[2]); |
| 6982 |
if (initial == -1 && PyErr_Occurred()) { |
| 6983 |
goto exit; |
| 6984 |
} |
| 6985 |
if (!--noptargs) { |
| 6986 |
goto skip_optional_kwonly; |
| 6987 |
} |
| 6988 |
} |
| 6989 |
interval = PyLong_AsLongLong(args[3]); |
| 6990 |
if (interval == -1 && PyErr_Occurred()) { |
| 6991 |
goto exit; |
| 6992 |
} |
| 6993 |
skip_optional_kwonly: |
| 6994 |
return_value = os_timerfd_settime_ns_impl(module, fd, flags, initial, interval); |
| 6995 |
|
| 6996 |
exit: |
| 6997 |
return return_value; |
| 6998 |
} |
| 6999 |
|
| 7000 |
#endif /* defined(HAVE_TIMERFD_CREATE) */ |
| 7001 |
|
| 7002 |
#if defined(HAVE_TIMERFD_CREATE) |
| 7003 |
|
| 7004 |
PyDoc_STRVAR(os_timerfd_gettime__doc__, |
| 7005 |
"timerfd_gettime($module, fd, /)\n" |
| 7006 |
"--\n" |
| 7007 |
"\n" |
| 7008 |
"Return a tuple of a timer file descriptor\'s (interval, next expiration) in float seconds.\n" |
| 7009 |
"\n" |
| 7010 |
" fd\n" |
| 7011 |
" A timer file descriptor."); |
| 7012 |
|
| 7013 |
#define OS_TIMERFD_GETTIME_METHODDEF \ |
| 7014 |
{"timerfd_gettime", (PyCFunction)os_timerfd_gettime, METH_O, os_timerfd_gettime__doc__}, |
| 7015 |
|
| 7016 |
static PyObject * |
| 7017 |
os_timerfd_gettime_impl(PyObject *module, int fd); |
| 7018 |
|
| 7019 |
static PyObject * |
| 7020 |
os_timerfd_gettime(PyObject *module, PyObject *arg) |
| 7021 |
{ |
| 7022 |
PyObject *return_value = NULL; |
| 7023 |
int fd; |
| 7024 |
|
| 7025 |
fd = PyObject_AsFileDescriptor(arg); |
| 7026 |
if (fd < 0) { |
| 7027 |
goto exit; |
| 7028 |
} |
| 7029 |
return_value = os_timerfd_gettime_impl(module, fd); |
| 7030 |
|
| 7031 |
exit: |
| 7032 |
return return_value; |
| 7033 |
} |
| 7034 |
|
| 7035 |
#endif /* defined(HAVE_TIMERFD_CREATE) */ |
| 7036 |
|
| 7037 |
#if defined(HAVE_TIMERFD_CREATE) |
| 7038 |
|
| 7039 |
PyDoc_STRVAR(os_timerfd_gettime_ns__doc__, |
| 7040 |
"timerfd_gettime_ns($module, fd, /)\n" |
| 7041 |
"--\n" |
| 7042 |
"\n" |
| 7043 |
"Return a tuple of a timer file descriptor\'s (interval, next expiration) in nanoseconds.\n" |
| 7044 |
"\n" |
| 7045 |
" fd\n" |
| 7046 |
" A timer file descriptor."); |
| 7047 |
|
| 7048 |
#define OS_TIMERFD_GETTIME_NS_METHODDEF \ |
| 7049 |
{"timerfd_gettime_ns", (PyCFunction)os_timerfd_gettime_ns, METH_O, os_timerfd_gettime_ns__doc__}, |
| 7050 |
|
| 7051 |
static PyObject * |
| 7052 |
os_timerfd_gettime_ns_impl(PyObject *module, int fd); |
| 7053 |
|
| 7054 |
static PyObject * |
| 7055 |
os_timerfd_gettime_ns(PyObject *module, PyObject *arg) |
| 7056 |
{ |
| 7057 |
PyObject *return_value = NULL; |
| 7058 |
int fd; |
| 7059 |
|
| 7060 |
fd = PyObject_AsFileDescriptor(arg); |
| 7061 |
if (fd < 0) { |
| 7062 |
goto exit; |
| 7063 |
} |
| 7064 |
return_value = os_timerfd_gettime_ns_impl(module, fd); |
| 7065 |
|
| 7066 |
exit: |
| 7067 |
return return_value; |
| 7068 |
} |
| 7069 |
|
| 7070 |
#endif /* defined(HAVE_TIMERFD_CREATE) */ |
| 7071 |
|
| 7072 |
#if defined(HAVE_GETSID) |
| 7073 |
|
| 7074 |
PyDoc_STRVAR(os_getsid__doc__, |
| 7075 |
"getsid($module, pid, /)\n" |
| 7076 |
"--\n" |
| 7077 |
"\n" |
| 7078 |
"Call the system call getsid(pid) and return the result."); |
| 7079 |
|
| 7080 |
#define OS_GETSID_METHODDEF \ |
| 7081 |
{"getsid", (PyCFunction)os_getsid, METH_O, os_getsid__doc__}, |
| 7082 |
|
| 7083 |
static PyObject * |
| 7084 |
os_getsid_impl(PyObject *module, pid_t pid); |
| 7085 |
|
| 7086 |
static PyObject * |
| 7087 |
os_getsid(PyObject *module, PyObject *arg) |
| 7088 |
{ |
| 7089 |
PyObject *return_value = NULL; |
| 7090 |
pid_t pid; |
| 7091 |
|
| 7092 |
pid = PyLong_AsPid(arg); |
| 7093 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 7094 |
goto exit; |
| 7095 |
} |
| 7096 |
return_value = os_getsid_impl(module, pid); |
| 7097 |
|
| 7098 |
exit: |
| 7099 |
return return_value; |
| 7100 |
} |
| 7101 |
|
| 7102 |
#endif /* defined(HAVE_GETSID) */ |
| 7103 |
|
| 7104 |
#if defined(HAVE_SETSID) |
| 7105 |
|
| 7106 |
PyDoc_STRVAR(os_setsid__doc__, |
| 7107 |
"setsid($module, /)\n" |
| 7108 |
"--\n" |
| 7109 |
"\n" |
| 7110 |
"Call the system call setsid()."); |
| 7111 |
|
| 7112 |
#define OS_SETSID_METHODDEF \ |
| 7113 |
{"setsid", (PyCFunction)os_setsid, METH_NOARGS, os_setsid__doc__}, |
| 7114 |
|
| 7115 |
static PyObject * |
| 7116 |
os_setsid_impl(PyObject *module); |
| 7117 |
|
| 7118 |
static PyObject * |
| 7119 |
os_setsid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 7120 |
{ |
| 7121 |
return os_setsid_impl(module); |
| 7122 |
} |
| 7123 |
|
| 7124 |
#endif /* defined(HAVE_SETSID) */ |
| 7125 |
|
| 7126 |
#if defined(HAVE_SETPGID) |
| 7127 |
|
| 7128 |
PyDoc_STRVAR(os_setpgid__doc__, |
| 7129 |
"setpgid($module, pid, pgrp, /)\n" |
| 7130 |
"--\n" |
| 7131 |
"\n" |
| 7132 |
"Call the system call setpgid(pid, pgrp)."); |
| 7133 |
|
| 7134 |
#define OS_SETPGID_METHODDEF \ |
| 7135 |
{"setpgid", _PyCFunction_CAST(os_setpgid), METH_FASTCALL, os_setpgid__doc__}, |
| 7136 |
|
| 7137 |
static PyObject * |
| 7138 |
os_setpgid_impl(PyObject *module, pid_t pid, pid_t pgrp); |
| 7139 |
|
| 7140 |
static PyObject * |
| 7141 |
os_setpgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7142 |
{ |
| 7143 |
PyObject *return_value = NULL; |
| 7144 |
pid_t pid; |
| 7145 |
pid_t pgrp; |
| 7146 |
|
| 7147 |
if (!_PyArg_CheckPositional("setpgid", nargs, 2, 2)) { |
| 7148 |
goto exit; |
| 7149 |
} |
| 7150 |
pid = PyLong_AsPid(args[0]); |
| 7151 |
if (pid == (pid_t)(-1) && PyErr_Occurred()) { |
| 7152 |
goto exit; |
| 7153 |
} |
| 7154 |
pgrp = PyLong_AsPid(args[1]); |
| 7155 |
if (pgrp == (pid_t)(-1) && PyErr_Occurred()) { |
| 7156 |
goto exit; |
| 7157 |
} |
| 7158 |
return_value = os_setpgid_impl(module, pid, pgrp); |
| 7159 |
|
| 7160 |
exit: |
| 7161 |
return return_value; |
| 7162 |
} |
| 7163 |
|
| 7164 |
#endif /* defined(HAVE_SETPGID) */ |
| 7165 |
|
| 7166 |
#if defined(HAVE_TCGETPGRP) |
| 7167 |
|
| 7168 |
PyDoc_STRVAR(os_tcgetpgrp__doc__, |
| 7169 |
"tcgetpgrp($module, fd, /)\n" |
| 7170 |
"--\n" |
| 7171 |
"\n" |
| 7172 |
"Return the process group associated with the terminal specified by fd."); |
| 7173 |
|
| 7174 |
#define OS_TCGETPGRP_METHODDEF \ |
| 7175 |
{"tcgetpgrp", (PyCFunction)os_tcgetpgrp, METH_O, os_tcgetpgrp__doc__}, |
| 7176 |
|
| 7177 |
static PyObject * |
| 7178 |
os_tcgetpgrp_impl(PyObject *module, int fd); |
| 7179 |
|
| 7180 |
static PyObject * |
| 7181 |
os_tcgetpgrp(PyObject *module, PyObject *arg) |
| 7182 |
{ |
| 7183 |
PyObject *return_value = NULL; |
| 7184 |
int fd; |
| 7185 |
|
| 7186 |
fd = PyLong_AsInt(arg); |
| 7187 |
if (fd == -1 && PyErr_Occurred()) { |
| 7188 |
goto exit; |
| 7189 |
} |
| 7190 |
return_value = os_tcgetpgrp_impl(module, fd); |
| 7191 |
|
| 7192 |
exit: |
| 7193 |
return return_value; |
| 7194 |
} |
| 7195 |
|
| 7196 |
#endif /* defined(HAVE_TCGETPGRP) */ |
| 7197 |
|
| 7198 |
#if defined(HAVE_TCSETPGRP) |
| 7199 |
|
| 7200 |
PyDoc_STRVAR(os_tcsetpgrp__doc__, |
| 7201 |
"tcsetpgrp($module, fd, pgid, /)\n" |
| 7202 |
"--\n" |
| 7203 |
"\n" |
| 7204 |
"Set the process group associated with the terminal specified by fd."); |
| 7205 |
|
| 7206 |
#define OS_TCSETPGRP_METHODDEF \ |
| 7207 |
{"tcsetpgrp", _PyCFunction_CAST(os_tcsetpgrp), METH_FASTCALL, os_tcsetpgrp__doc__}, |
| 7208 |
|
| 7209 |
static PyObject * |
| 7210 |
os_tcsetpgrp_impl(PyObject *module, int fd, pid_t pgid); |
| 7211 |
|
| 7212 |
static PyObject * |
| 7213 |
os_tcsetpgrp(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7214 |
{ |
| 7215 |
PyObject *return_value = NULL; |
| 7216 |
int fd; |
| 7217 |
pid_t pgid; |
| 7218 |
|
| 7219 |
if (!_PyArg_CheckPositional("tcsetpgrp", nargs, 2, 2)) { |
| 7220 |
goto exit; |
| 7221 |
} |
| 7222 |
fd = PyLong_AsInt(args[0]); |
| 7223 |
if (fd == -1 && PyErr_Occurred()) { |
| 7224 |
goto exit; |
| 7225 |
} |
| 7226 |
pgid = PyLong_AsPid(args[1]); |
| 7227 |
if (pgid == (pid_t)(-1) && PyErr_Occurred()) { |
| 7228 |
goto exit; |
| 7229 |
} |
| 7230 |
return_value = os_tcsetpgrp_impl(module, fd, pgid); |
| 7231 |
|
| 7232 |
exit: |
| 7233 |
return return_value; |
| 7234 |
} |
| 7235 |
|
| 7236 |
#endif /* defined(HAVE_TCSETPGRP) */ |
| 7237 |
|
| 7238 |
PyDoc_STRVAR(os_open__doc__, |
| 7239 |
"open($module, /, path, flags, mode=511, *, dir_fd=None)\n" |
| 7240 |
"--\n" |
| 7241 |
"\n" |
| 7242 |
"Open a file for low level IO. Returns a file descriptor (integer).\n" |
| 7243 |
"\n" |
| 7244 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 7245 |
" and path should be relative; path will then be relative to that directory.\n" |
| 7246 |
"dir_fd may not be implemented on your platform.\n" |
| 7247 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 7248 |
|
| 7249 |
#define OS_OPEN_METHODDEF \ |
| 7250 |
{"open", _PyCFunction_CAST(os_open), METH_FASTCALL|METH_KEYWORDS, os_open__doc__}, |
| 7251 |
|
| 7252 |
static int |
| 7253 |
os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd); |
| 7254 |
|
| 7255 |
static PyObject * |
| 7256 |
os_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 7257 |
{ |
| 7258 |
PyObject *return_value = NULL; |
| 7259 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 7260 |
|
| 7261 |
#define NUM_KEYWORDS 4 |
| 7262 |
static struct { |
| 7263 |
PyGC_Head _this_is_not_used; |
| 7264 |
PyObject_VAR_HEAD |
| 7265 |
Py_hash_t ob_hash; |
| 7266 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 7267 |
} _kwtuple = { |
| 7268 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 7269 |
.ob_hash = -1, |
| 7270 |
.ob_item = { &_Py_ID(path), &_Py_ID(flags), &_Py_ID(mode), &_Py_ID(dir_fd), }, |
| 7271 |
}; |
| 7272 |
#undef NUM_KEYWORDS |
| 7273 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 7274 |
|
| 7275 |
#else // !Py_BUILD_CORE |
| 7276 |
# define KWTUPLE NULL |
| 7277 |
#endif // !Py_BUILD_CORE |
| 7278 |
|
| 7279 |
static const char * const _keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; |
| 7280 |
static _PyArg_Parser _parser = { |
| 7281 |
.keywords = _keywords, |
| 7282 |
.fname = "open", |
| 7283 |
.kwtuple = KWTUPLE, |
| 7284 |
}; |
| 7285 |
#undef KWTUPLE |
| 7286 |
PyObject *argsbuf[4]; |
| 7287 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 7288 |
path_t path = PATH_T_INITIALIZE_P("open", "path", 0, 0, 0, 0); |
| 7289 |
int flags; |
| 7290 |
int mode = 511; |
| 7291 |
int dir_fd = DEFAULT_DIR_FD; |
| 7292 |
int _return_value; |
| 7293 |
|
| 7294 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 7295 |
/*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 7296 |
if (!args) { |
| 7297 |
goto exit; |
| 7298 |
} |
| 7299 |
if (!path_converter(args[0], &path)) { |
| 7300 |
goto exit; |
| 7301 |
} |
| 7302 |
flags = PyLong_AsInt(args[1]); |
| 7303 |
if (flags == -1 && PyErr_Occurred()) { |
| 7304 |
goto exit; |
| 7305 |
} |
| 7306 |
if (!noptargs) { |
| 7307 |
goto skip_optional_pos; |
| 7308 |
} |
| 7309 |
if (args[2]) { |
| 7310 |
mode = PyLong_AsInt(args[2]); |
| 7311 |
if (mode == -1 && PyErr_Occurred()) { |
| 7312 |
goto exit; |
| 7313 |
} |
| 7314 |
if (!--noptargs) { |
| 7315 |
goto skip_optional_pos; |
| 7316 |
} |
| 7317 |
} |
| 7318 |
skip_optional_pos: |
| 7319 |
if (!noptargs) { |
| 7320 |
goto skip_optional_kwonly; |
| 7321 |
} |
| 7322 |
if (!OPENAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { |
| 7323 |
goto exit; |
| 7324 |
} |
| 7325 |
skip_optional_kwonly: |
| 7326 |
_return_value = os_open_impl(module, &path, flags, mode, dir_fd); |
| 7327 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7328 |
goto exit; |
| 7329 |
} |
| 7330 |
return_value = PyLong_FromLong((long)_return_value); |
| 7331 |
|
| 7332 |
exit: |
| 7333 |
/* Cleanup for path */ |
| 7334 |
path_cleanup(&path); |
| 7335 |
|
| 7336 |
return return_value; |
| 7337 |
} |
| 7338 |
|
| 7339 |
PyDoc_STRVAR(os_close__doc__, |
| 7340 |
"close($module, /, fd)\n" |
| 7341 |
"--\n" |
| 7342 |
"\n" |
| 7343 |
"Close a file descriptor."); |
| 7344 |
|
| 7345 |
#define OS_CLOSE_METHODDEF \ |
| 7346 |
{"close", _PyCFunction_CAST(os_close), METH_FASTCALL|METH_KEYWORDS, os_close__doc__}, |
| 7347 |
|
| 7348 |
static PyObject * |
| 7349 |
os_close_impl(PyObject *module, int fd); |
| 7350 |
|
| 7351 |
static PyObject * |
| 7352 |
os_close(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 7353 |
{ |
| 7354 |
PyObject *return_value = NULL; |
| 7355 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 7356 |
|
| 7357 |
#define NUM_KEYWORDS 1 |
| 7358 |
static struct { |
| 7359 |
PyGC_Head _this_is_not_used; |
| 7360 |
PyObject_VAR_HEAD |
| 7361 |
Py_hash_t ob_hash; |
| 7362 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 7363 |
} _kwtuple = { |
| 7364 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 7365 |
.ob_hash = -1, |
| 7366 |
.ob_item = { &_Py_ID(fd), }, |
| 7367 |
}; |
| 7368 |
#undef NUM_KEYWORDS |
| 7369 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 7370 |
|
| 7371 |
#else // !Py_BUILD_CORE |
| 7372 |
# define KWTUPLE NULL |
| 7373 |
#endif // !Py_BUILD_CORE |
| 7374 |
|
| 7375 |
static const char * const _keywords[] = {"fd", NULL}; |
| 7376 |
static _PyArg_Parser _parser = { |
| 7377 |
.keywords = _keywords, |
| 7378 |
.fname = "close", |
| 7379 |
.kwtuple = KWTUPLE, |
| 7380 |
}; |
| 7381 |
#undef KWTUPLE |
| 7382 |
PyObject *argsbuf[1]; |
| 7383 |
int fd; |
| 7384 |
|
| 7385 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 7386 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 7387 |
if (!args) { |
| 7388 |
goto exit; |
| 7389 |
} |
| 7390 |
fd = PyLong_AsInt(args[0]); |
| 7391 |
if (fd == -1 && PyErr_Occurred()) { |
| 7392 |
goto exit; |
| 7393 |
} |
| 7394 |
return_value = os_close_impl(module, fd); |
| 7395 |
|
| 7396 |
exit: |
| 7397 |
return return_value; |
| 7398 |
} |
| 7399 |
|
| 7400 |
PyDoc_STRVAR(os_closerange__doc__, |
| 7401 |
"closerange($module, fd_low, fd_high, /)\n" |
| 7402 |
"--\n" |
| 7403 |
"\n" |
| 7404 |
"Closes all file descriptors in [fd_low, fd_high), ignoring errors."); |
| 7405 |
|
| 7406 |
#define OS_CLOSERANGE_METHODDEF \ |
| 7407 |
{"closerange", _PyCFunction_CAST(os_closerange), METH_FASTCALL, os_closerange__doc__}, |
| 7408 |
|
| 7409 |
static PyObject * |
| 7410 |
os_closerange_impl(PyObject *module, int fd_low, int fd_high); |
| 7411 |
|
| 7412 |
static PyObject * |
| 7413 |
os_closerange(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7414 |
{ |
| 7415 |
PyObject *return_value = NULL; |
| 7416 |
int fd_low; |
| 7417 |
int fd_high; |
| 7418 |
|
| 7419 |
if (!_PyArg_CheckPositional("closerange", nargs, 2, 2)) { |
| 7420 |
goto exit; |
| 7421 |
} |
| 7422 |
fd_low = PyLong_AsInt(args[0]); |
| 7423 |
if (fd_low == -1 && PyErr_Occurred()) { |
| 7424 |
goto exit; |
| 7425 |
} |
| 7426 |
fd_high = PyLong_AsInt(args[1]); |
| 7427 |
if (fd_high == -1 && PyErr_Occurred()) { |
| 7428 |
goto exit; |
| 7429 |
} |
| 7430 |
return_value = os_closerange_impl(module, fd_low, fd_high); |
| 7431 |
|
| 7432 |
exit: |
| 7433 |
return return_value; |
| 7434 |
} |
| 7435 |
|
| 7436 |
PyDoc_STRVAR(os_dup__doc__, |
| 7437 |
"dup($module, fd, /)\n" |
| 7438 |
"--\n" |
| 7439 |
"\n" |
| 7440 |
"Return a duplicate of a file descriptor."); |
| 7441 |
|
| 7442 |
#define OS_DUP_METHODDEF \ |
| 7443 |
{"dup", (PyCFunction)os_dup, METH_O, os_dup__doc__}, |
| 7444 |
|
| 7445 |
static int |
| 7446 |
os_dup_impl(PyObject *module, int fd); |
| 7447 |
|
| 7448 |
static PyObject * |
| 7449 |
os_dup(PyObject *module, PyObject *arg) |
| 7450 |
{ |
| 7451 |
PyObject *return_value = NULL; |
| 7452 |
int fd; |
| 7453 |
int _return_value; |
| 7454 |
|
| 7455 |
fd = PyLong_AsInt(arg); |
| 7456 |
if (fd == -1 && PyErr_Occurred()) { |
| 7457 |
goto exit; |
| 7458 |
} |
| 7459 |
_return_value = os_dup_impl(module, fd); |
| 7460 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7461 |
goto exit; |
| 7462 |
} |
| 7463 |
return_value = PyLong_FromLong((long)_return_value); |
| 7464 |
|
| 7465 |
exit: |
| 7466 |
return return_value; |
| 7467 |
} |
| 7468 |
|
| 7469 |
#if ((defined(HAVE_DUP3) || defined(F_DUPFD) || defined(MS_WINDOWS))) |
| 7470 |
|
| 7471 |
PyDoc_STRVAR(os_dup2__doc__, |
| 7472 |
"dup2($module, /, fd, fd2, inheritable=True)\n" |
| 7473 |
"--\n" |
| 7474 |
"\n" |
| 7475 |
"Duplicate file descriptor."); |
| 7476 |
|
| 7477 |
#define OS_DUP2_METHODDEF \ |
| 7478 |
{"dup2", _PyCFunction_CAST(os_dup2), METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__}, |
| 7479 |
|
| 7480 |
static int |
| 7481 |
os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable); |
| 7482 |
|
| 7483 |
static PyObject * |
| 7484 |
os_dup2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 7485 |
{ |
| 7486 |
PyObject *return_value = NULL; |
| 7487 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 7488 |
|
| 7489 |
#define NUM_KEYWORDS 3 |
| 7490 |
static struct { |
| 7491 |
PyGC_Head _this_is_not_used; |
| 7492 |
PyObject_VAR_HEAD |
| 7493 |
Py_hash_t ob_hash; |
| 7494 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 7495 |
} _kwtuple = { |
| 7496 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 7497 |
.ob_hash = -1, |
| 7498 |
.ob_item = { &_Py_ID(fd), &_Py_ID(fd2), &_Py_ID(inheritable), }, |
| 7499 |
}; |
| 7500 |
#undef NUM_KEYWORDS |
| 7501 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 7502 |
|
| 7503 |
#else // !Py_BUILD_CORE |
| 7504 |
# define KWTUPLE NULL |
| 7505 |
#endif // !Py_BUILD_CORE |
| 7506 |
|
| 7507 |
static const char * const _keywords[] = {"fd", "fd2", "inheritable", NULL}; |
| 7508 |
static _PyArg_Parser _parser = { |
| 7509 |
.keywords = _keywords, |
| 7510 |
.fname = "dup2", |
| 7511 |
.kwtuple = KWTUPLE, |
| 7512 |
}; |
| 7513 |
#undef KWTUPLE |
| 7514 |
PyObject *argsbuf[3]; |
| 7515 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 7516 |
int fd; |
| 7517 |
int fd2; |
| 7518 |
int inheritable = 1; |
| 7519 |
int _return_value; |
| 7520 |
|
| 7521 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 7522 |
/*minpos*/ 2, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 7523 |
if (!args) { |
| 7524 |
goto exit; |
| 7525 |
} |
| 7526 |
fd = PyLong_AsInt(args[0]); |
| 7527 |
if (fd == -1 && PyErr_Occurred()) { |
| 7528 |
goto exit; |
| 7529 |
} |
| 7530 |
fd2 = PyLong_AsInt(args[1]); |
| 7531 |
if (fd2 == -1 && PyErr_Occurred()) { |
| 7532 |
goto exit; |
| 7533 |
} |
| 7534 |
if (!noptargs) { |
| 7535 |
goto skip_optional_pos; |
| 7536 |
} |
| 7537 |
inheritable = PyObject_IsTrue(args[2]); |
| 7538 |
if (inheritable < 0) { |
| 7539 |
goto exit; |
| 7540 |
} |
| 7541 |
skip_optional_pos: |
| 7542 |
_return_value = os_dup2_impl(module, fd, fd2, inheritable); |
| 7543 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7544 |
goto exit; |
| 7545 |
} |
| 7546 |
return_value = PyLong_FromLong((long)_return_value); |
| 7547 |
|
| 7548 |
exit: |
| 7549 |
return return_value; |
| 7550 |
} |
| 7551 |
|
| 7552 |
#endif /* ((defined(HAVE_DUP3) || defined(F_DUPFD) || defined(MS_WINDOWS))) */ |
| 7553 |
|
| 7554 |
#if defined(HAVE_LOCKF) |
| 7555 |
|
| 7556 |
PyDoc_STRVAR(os_lockf__doc__, |
| 7557 |
"lockf($module, fd, command, length, /)\n" |
| 7558 |
"--\n" |
| 7559 |
"\n" |
| 7560 |
"Apply, test or remove a POSIX lock on an open file descriptor.\n" |
| 7561 |
"\n" |
| 7562 |
" fd\n" |
| 7563 |
" An open file descriptor.\n" |
| 7564 |
" command\n" |
| 7565 |
" One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.\n" |
| 7566 |
" length\n" |
| 7567 |
" The number of bytes to lock, starting at the current position."); |
| 7568 |
|
| 7569 |
#define OS_LOCKF_METHODDEF \ |
| 7570 |
{"lockf", _PyCFunction_CAST(os_lockf), METH_FASTCALL, os_lockf__doc__}, |
| 7571 |
|
| 7572 |
static PyObject * |
| 7573 |
os_lockf_impl(PyObject *module, int fd, int command, Py_off_t length); |
| 7574 |
|
| 7575 |
static PyObject * |
| 7576 |
os_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7577 |
{ |
| 7578 |
PyObject *return_value = NULL; |
| 7579 |
int fd; |
| 7580 |
int command; |
| 7581 |
Py_off_t length; |
| 7582 |
|
| 7583 |
if (!_PyArg_CheckPositional("lockf", nargs, 3, 3)) { |
| 7584 |
goto exit; |
| 7585 |
} |
| 7586 |
fd = PyLong_AsInt(args[0]); |
| 7587 |
if (fd == -1 && PyErr_Occurred()) { |
| 7588 |
goto exit; |
| 7589 |
} |
| 7590 |
command = PyLong_AsInt(args[1]); |
| 7591 |
if (command == -1 && PyErr_Occurred()) { |
| 7592 |
goto exit; |
| 7593 |
} |
| 7594 |
if (!Py_off_t_converter(args[2], &length)) { |
| 7595 |
goto exit; |
| 7596 |
} |
| 7597 |
return_value = os_lockf_impl(module, fd, command, length); |
| 7598 |
|
| 7599 |
exit: |
| 7600 |
return return_value; |
| 7601 |
} |
| 7602 |
|
| 7603 |
#endif /* defined(HAVE_LOCKF) */ |
| 7604 |
|
| 7605 |
PyDoc_STRVAR(os_lseek__doc__, |
| 7606 |
"lseek($module, fd, position, whence, /)\n" |
| 7607 |
"--\n" |
| 7608 |
"\n" |
| 7609 |
"Set the position of a file descriptor. Return the new position.\n" |
| 7610 |
"\n" |
| 7611 |
" fd\n" |
| 7612 |
" An open file descriptor, as returned by os.open().\n" |
| 7613 |
" position\n" |
| 7614 |
" Position, interpreted relative to \'whence\'.\n" |
| 7615 |
" whence\n" |
| 7616 |
" The relative position to seek from. Valid values are:\n" |
| 7617 |
" - SEEK_SET: seek from the start of the file.\n" |
| 7618 |
" - SEEK_CUR: seek from the current file position.\n" |
| 7619 |
" - SEEK_END: seek from the end of the file.\n" |
| 7620 |
"\n" |
| 7621 |
"The return value is the number of bytes relative to the beginning of the file."); |
| 7622 |
|
| 7623 |
#define OS_LSEEK_METHODDEF \ |
| 7624 |
{"lseek", _PyCFunction_CAST(os_lseek), METH_FASTCALL, os_lseek__doc__}, |
| 7625 |
|
| 7626 |
static Py_off_t |
| 7627 |
os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how); |
| 7628 |
|
| 7629 |
static PyObject * |
| 7630 |
os_lseek(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7631 |
{ |
| 7632 |
PyObject *return_value = NULL; |
| 7633 |
int fd; |
| 7634 |
Py_off_t position; |
| 7635 |
int how; |
| 7636 |
Py_off_t _return_value; |
| 7637 |
|
| 7638 |
if (!_PyArg_CheckPositional("lseek", nargs, 3, 3)) { |
| 7639 |
goto exit; |
| 7640 |
} |
| 7641 |
fd = PyLong_AsInt(args[0]); |
| 7642 |
if (fd == -1 && PyErr_Occurred()) { |
| 7643 |
goto exit; |
| 7644 |
} |
| 7645 |
if (!Py_off_t_converter(args[1], &position)) { |
| 7646 |
goto exit; |
| 7647 |
} |
| 7648 |
how = PyLong_AsInt(args[2]); |
| 7649 |
if (how == -1 && PyErr_Occurred()) { |
| 7650 |
goto exit; |
| 7651 |
} |
| 7652 |
_return_value = os_lseek_impl(module, fd, position, how); |
| 7653 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7654 |
goto exit; |
| 7655 |
} |
| 7656 |
return_value = PyLong_FromPy_off_t(_return_value); |
| 7657 |
|
| 7658 |
exit: |
| 7659 |
return return_value; |
| 7660 |
} |
| 7661 |
|
| 7662 |
PyDoc_STRVAR(os_read__doc__, |
| 7663 |
"read($module, fd, length, /)\n" |
| 7664 |
"--\n" |
| 7665 |
"\n" |
| 7666 |
"Read from a file descriptor. Returns a bytes object."); |
| 7667 |
|
| 7668 |
#define OS_READ_METHODDEF \ |
| 7669 |
{"read", _PyCFunction_CAST(os_read), METH_FASTCALL, os_read__doc__}, |
| 7670 |
|
| 7671 |
static PyObject * |
| 7672 |
os_read_impl(PyObject *module, int fd, Py_ssize_t length); |
| 7673 |
|
| 7674 |
static PyObject * |
| 7675 |
os_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7676 |
{ |
| 7677 |
PyObject *return_value = NULL; |
| 7678 |
int fd; |
| 7679 |
Py_ssize_t length; |
| 7680 |
|
| 7681 |
if (!_PyArg_CheckPositional("read", nargs, 2, 2)) { |
| 7682 |
goto exit; |
| 7683 |
} |
| 7684 |
fd = PyLong_AsInt(args[0]); |
| 7685 |
if (fd == -1 && PyErr_Occurred()) { |
| 7686 |
goto exit; |
| 7687 |
} |
| 7688 |
{ |
| 7689 |
Py_ssize_t ival = -1; |
| 7690 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 7691 |
if (iobj != NULL) { |
| 7692 |
ival = PyLong_AsSsize_t(iobj); |
| 7693 |
Py_DECREF(iobj); |
| 7694 |
} |
| 7695 |
if (ival == -1 && PyErr_Occurred()) { |
| 7696 |
goto exit; |
| 7697 |
} |
| 7698 |
length = ival; |
| 7699 |
} |
| 7700 |
return_value = os_read_impl(module, fd, length); |
| 7701 |
|
| 7702 |
exit: |
| 7703 |
return return_value; |
| 7704 |
} |
| 7705 |
|
| 7706 |
PyDoc_STRVAR(os_readinto__doc__, |
| 7707 |
"readinto($module, fd, buffer, /)\n" |
| 7708 |
"--\n" |
| 7709 |
"\n" |
| 7710 |
"Read into a buffer object from a file descriptor.\n" |
| 7711 |
"\n" |
| 7712 |
"The buffer should be mutable and bytes-like. On success, returns the number of\n" |
| 7713 |
"bytes read. Less bytes may be read than the size of the buffer. The underlying\n" |
| 7714 |
"system call will be retried when interrupted by a signal, unless the signal\n" |
| 7715 |
"handler raises an exception. Other errors will not be retried and an error will\n" |
| 7716 |
"be raised.\n" |
| 7717 |
"\n" |
| 7718 |
"Returns 0 if *fd* is at end of file or if the provided *buffer* has length 0\n" |
| 7719 |
"(which can be used to check for errors without reading data). Never returns\n" |
| 7720 |
"negative."); |
| 7721 |
|
| 7722 |
#define OS_READINTO_METHODDEF \ |
| 7723 |
{"readinto", _PyCFunction_CAST(os_readinto), METH_FASTCALL, os_readinto__doc__}, |
| 7724 |
|
| 7725 |
static Py_ssize_t |
| 7726 |
os_readinto_impl(PyObject *module, int fd, Py_buffer *buffer); |
| 7727 |
|
| 7728 |
static PyObject * |
| 7729 |
os_readinto(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7730 |
{ |
| 7731 |
PyObject *return_value = NULL; |
| 7732 |
int fd; |
| 7733 |
Py_buffer buffer = {NULL, NULL}; |
| 7734 |
Py_ssize_t _return_value; |
| 7735 |
|
| 7736 |
if (!_PyArg_CheckPositional("readinto", nargs, 2, 2)) { |
| 7737 |
goto exit; |
| 7738 |
} |
| 7739 |
fd = PyLong_AsInt(args[0]); |
| 7740 |
if (fd == -1 && PyErr_Occurred()) { |
| 7741 |
goto exit; |
| 7742 |
} |
| 7743 |
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_WRITABLE) < 0) { |
| 7744 |
_PyArg_BadArgument("readinto", "argument 2", "read-write bytes-like object", args[1]); |
| 7745 |
goto exit; |
| 7746 |
} |
| 7747 |
_return_value = os_readinto_impl(module, fd, &buffer); |
| 7748 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7749 |
goto exit; |
| 7750 |
} |
| 7751 |
return_value = PyLong_FromSsize_t(_return_value); |
| 7752 |
|
| 7753 |
exit: |
| 7754 |
/* Cleanup for buffer */ |
| 7755 |
if (buffer.obj) { |
| 7756 |
PyBuffer_Release(&buffer); |
| 7757 |
} |
| 7758 |
|
| 7759 |
return return_value; |
| 7760 |
} |
| 7761 |
|
| 7762 |
#if defined(HAVE_READV) |
| 7763 |
|
| 7764 |
PyDoc_STRVAR(os_readv__doc__, |
| 7765 |
"readv($module, fd, buffers, /)\n" |
| 7766 |
"--\n" |
| 7767 |
"\n" |
| 7768 |
"Read from a file descriptor fd into an iterable of buffers.\n" |
| 7769 |
"\n" |
| 7770 |
"The buffers should be mutable buffers accepting bytes.\n" |
| 7771 |
"readv will transfer data into each buffer until it is full\n" |
| 7772 |
"and then move on to the next buffer in the sequence to hold\n" |
| 7773 |
"the rest of the data.\n" |
| 7774 |
"\n" |
| 7775 |
"readv returns the total number of bytes read,\n" |
| 7776 |
"which may be less than the total capacity of all the buffers."); |
| 7777 |
|
| 7778 |
#define OS_READV_METHODDEF \ |
| 7779 |
{"readv", _PyCFunction_CAST(os_readv), METH_FASTCALL, os_readv__doc__}, |
| 7780 |
|
| 7781 |
static Py_ssize_t |
| 7782 |
os_readv_impl(PyObject *module, int fd, PyObject *buffers); |
| 7783 |
|
| 7784 |
static PyObject * |
| 7785 |
os_readv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7786 |
{ |
| 7787 |
PyObject *return_value = NULL; |
| 7788 |
int fd; |
| 7789 |
PyObject *buffers; |
| 7790 |
Py_ssize_t _return_value; |
| 7791 |
|
| 7792 |
if (!_PyArg_CheckPositional("readv", nargs, 2, 2)) { |
| 7793 |
goto exit; |
| 7794 |
} |
| 7795 |
fd = PyLong_AsInt(args[0]); |
| 7796 |
if (fd == -1 && PyErr_Occurred()) { |
| 7797 |
goto exit; |
| 7798 |
} |
| 7799 |
buffers = args[1]; |
| 7800 |
_return_value = os_readv_impl(module, fd, buffers); |
| 7801 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7802 |
goto exit; |
| 7803 |
} |
| 7804 |
return_value = PyLong_FromSsize_t(_return_value); |
| 7805 |
|
| 7806 |
exit: |
| 7807 |
return return_value; |
| 7808 |
} |
| 7809 |
|
| 7810 |
#endif /* defined(HAVE_READV) */ |
| 7811 |
|
| 7812 |
#if defined(HAVE_PREAD) |
| 7813 |
|
| 7814 |
PyDoc_STRVAR(os_pread__doc__, |
| 7815 |
"pread($module, fd, length, offset, /)\n" |
| 7816 |
"--\n" |
| 7817 |
"\n" |
| 7818 |
"Read a number of bytes from a file descriptor starting at a particular offset.\n" |
| 7819 |
"\n" |
| 7820 |
"Read length bytes from file descriptor fd, starting at offset bytes from\n" |
| 7821 |
"the beginning of the file. The file offset remains unchanged."); |
| 7822 |
|
| 7823 |
#define OS_PREAD_METHODDEF \ |
| 7824 |
{"pread", _PyCFunction_CAST(os_pread), METH_FASTCALL, os_pread__doc__}, |
| 7825 |
|
| 7826 |
static PyObject * |
| 7827 |
os_pread_impl(PyObject *module, int fd, Py_ssize_t length, Py_off_t offset); |
| 7828 |
|
| 7829 |
static PyObject * |
| 7830 |
os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7831 |
{ |
| 7832 |
PyObject *return_value = NULL; |
| 7833 |
int fd; |
| 7834 |
Py_ssize_t length; |
| 7835 |
Py_off_t offset; |
| 7836 |
|
| 7837 |
if (!_PyArg_CheckPositional("pread", nargs, 3, 3)) { |
| 7838 |
goto exit; |
| 7839 |
} |
| 7840 |
fd = PyLong_AsInt(args[0]); |
| 7841 |
if (fd == -1 && PyErr_Occurred()) { |
| 7842 |
goto exit; |
| 7843 |
} |
| 7844 |
{ |
| 7845 |
Py_ssize_t ival = -1; |
| 7846 |
PyObject *iobj = _PyNumber_Index(args[1]); |
| 7847 |
if (iobj != NULL) { |
| 7848 |
ival = PyLong_AsSsize_t(iobj); |
| 7849 |
Py_DECREF(iobj); |
| 7850 |
} |
| 7851 |
if (ival == -1 && PyErr_Occurred()) { |
| 7852 |
goto exit; |
| 7853 |
} |
| 7854 |
length = ival; |
| 7855 |
} |
| 7856 |
if (!Py_off_t_converter(args[2], &offset)) { |
| 7857 |
goto exit; |
| 7858 |
} |
| 7859 |
return_value = os_pread_impl(module, fd, length, offset); |
| 7860 |
|
| 7861 |
exit: |
| 7862 |
return return_value; |
| 7863 |
} |
| 7864 |
|
| 7865 |
#endif /* defined(HAVE_PREAD) */ |
| 7866 |
|
| 7867 |
#if (defined(HAVE_PREADV) || defined (HAVE_PREADV2)) |
| 7868 |
|
| 7869 |
PyDoc_STRVAR(os_preadv__doc__, |
| 7870 |
"preadv($module, fd, buffers, offset, flags=0, /)\n" |
| 7871 |
"--\n" |
| 7872 |
"\n" |
| 7873 |
"Reads from a file descriptor into a number of mutable bytes-like objects.\n" |
| 7874 |
"\n" |
| 7875 |
"Combines the functionality of readv() and pread(). As readv(), it will\n" |
| 7876 |
"transfer data into each buffer until it is full and then move on to the next\n" |
| 7877 |
"buffer in the sequence to hold the rest of the data. Its fourth argument,\n" |
| 7878 |
"specifies the file offset at which the input operation is to be performed. It\n" |
| 7879 |
"will return the total number of bytes read (which can be less than the total\n" |
| 7880 |
"capacity of all the objects).\n" |
| 7881 |
"\n" |
| 7882 |
"The flags argument contains a bitwise OR of zero or more of the following flags:\n" |
| 7883 |
"\n" |
| 7884 |
"- RWF_HIPRI\n" |
| 7885 |
"- RWF_NOWAIT\n" |
| 7886 |
"\n" |
| 7887 |
"Using non-zero flags requires Linux 4.6 or newer."); |
| 7888 |
|
| 7889 |
#define OS_PREADV_METHODDEF \ |
| 7890 |
{"preadv", _PyCFunction_CAST(os_preadv), METH_FASTCALL, os_preadv__doc__}, |
| 7891 |
|
| 7892 |
static Py_ssize_t |
| 7893 |
os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, |
| 7894 |
int flags); |
| 7895 |
|
| 7896 |
static PyObject * |
| 7897 |
os_preadv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7898 |
{ |
| 7899 |
PyObject *return_value = NULL; |
| 7900 |
int fd; |
| 7901 |
PyObject *buffers; |
| 7902 |
Py_off_t offset; |
| 7903 |
int flags = 0; |
| 7904 |
Py_ssize_t _return_value; |
| 7905 |
|
| 7906 |
if (!_PyArg_CheckPositional("preadv", nargs, 3, 4)) { |
| 7907 |
goto exit; |
| 7908 |
} |
| 7909 |
fd = PyLong_AsInt(args[0]); |
| 7910 |
if (fd == -1 && PyErr_Occurred()) { |
| 7911 |
goto exit; |
| 7912 |
} |
| 7913 |
buffers = args[1]; |
| 7914 |
if (!Py_off_t_converter(args[2], &offset)) { |
| 7915 |
goto exit; |
| 7916 |
} |
| 7917 |
if (nargs < 4) { |
| 7918 |
goto skip_optional; |
| 7919 |
} |
| 7920 |
flags = PyLong_AsInt(args[3]); |
| 7921 |
if (flags == -1 && PyErr_Occurred()) { |
| 7922 |
goto exit; |
| 7923 |
} |
| 7924 |
skip_optional: |
| 7925 |
_return_value = os_preadv_impl(module, fd, buffers, offset, flags); |
| 7926 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7927 |
goto exit; |
| 7928 |
} |
| 7929 |
return_value = PyLong_FromSsize_t(_return_value); |
| 7930 |
|
| 7931 |
exit: |
| 7932 |
return return_value; |
| 7933 |
} |
| 7934 |
|
| 7935 |
#endif /* (defined(HAVE_PREADV) || defined (HAVE_PREADV2)) */ |
| 7936 |
|
| 7937 |
PyDoc_STRVAR(os_write__doc__, |
| 7938 |
"write($module, fd, data, /)\n" |
| 7939 |
"--\n" |
| 7940 |
"\n" |
| 7941 |
"Write a bytes object to a file descriptor."); |
| 7942 |
|
| 7943 |
#define OS_WRITE_METHODDEF \ |
| 7944 |
{"write", _PyCFunction_CAST(os_write), METH_FASTCALL, os_write__doc__}, |
| 7945 |
|
| 7946 |
static Py_ssize_t |
| 7947 |
os_write_impl(PyObject *module, int fd, Py_buffer *data); |
| 7948 |
|
| 7949 |
static PyObject * |
| 7950 |
os_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 7951 |
{ |
| 7952 |
PyObject *return_value = NULL; |
| 7953 |
int fd; |
| 7954 |
Py_buffer data = {NULL, NULL}; |
| 7955 |
Py_ssize_t _return_value; |
| 7956 |
|
| 7957 |
if (!_PyArg_CheckPositional("write", nargs, 2, 2)) { |
| 7958 |
goto exit; |
| 7959 |
} |
| 7960 |
fd = PyLong_AsInt(args[0]); |
| 7961 |
if (fd == -1 && PyErr_Occurred()) { |
| 7962 |
goto exit; |
| 7963 |
} |
| 7964 |
if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { |
| 7965 |
goto exit; |
| 7966 |
} |
| 7967 |
_return_value = os_write_impl(module, fd, &data); |
| 7968 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 7969 |
goto exit; |
| 7970 |
} |
| 7971 |
return_value = PyLong_FromSsize_t(_return_value); |
| 7972 |
|
| 7973 |
exit: |
| 7974 |
/* Cleanup for data */ |
| 7975 |
if (data.obj) { |
| 7976 |
PyBuffer_Release(&data); |
| 7977 |
} |
| 7978 |
|
| 7979 |
return return_value; |
| 7980 |
} |
| 7981 |
|
| 7982 |
#if defined(HAVE_SENDFILE) && defined(__APPLE__) |
| 7983 |
|
| 7984 |
PyDoc_STRVAR(os_sendfile__doc__, |
| 7985 |
"sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" |
| 7986 |
" trailers=(), flags=0)\n" |
| 7987 |
"--\n" |
| 7988 |
"\n" |
| 7989 |
"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); |
| 7990 |
|
| 7991 |
#define OS_SENDFILE_METHODDEF \ |
| 7992 |
{"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, |
| 7993 |
|
| 7994 |
static PyObject * |
| 7995 |
os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, |
| 7996 |
Py_off_t sbytes, PyObject *headers, PyObject *trailers, |
| 7997 |
int flags); |
| 7998 |
|
| 7999 |
static PyObject * |
| 8000 |
os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8001 |
{ |
| 8002 |
PyObject *return_value = NULL; |
| 8003 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8004 |
|
| 8005 |
#define NUM_KEYWORDS 7 |
| 8006 |
static struct { |
| 8007 |
PyGC_Head _this_is_not_used; |
| 8008 |
PyObject_VAR_HEAD |
| 8009 |
Py_hash_t ob_hash; |
| 8010 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8011 |
} _kwtuple = { |
| 8012 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8013 |
.ob_hash = -1, |
| 8014 |
.ob_item = { &_Py_ID(out_fd), &_Py_ID(in_fd), &_Py_ID(offset), &_Py_ID(count), &_Py_ID(headers), &_Py_ID(trailers), &_Py_ID(flags), }, |
| 8015 |
}; |
| 8016 |
#undef NUM_KEYWORDS |
| 8017 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8018 |
|
| 8019 |
#else // !Py_BUILD_CORE |
| 8020 |
# define KWTUPLE NULL |
| 8021 |
#endif // !Py_BUILD_CORE |
| 8022 |
|
| 8023 |
static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; |
| 8024 |
static _PyArg_Parser _parser = { |
| 8025 |
.keywords = _keywords, |
| 8026 |
.fname = "sendfile", |
| 8027 |
.kwtuple = KWTUPLE, |
| 8028 |
}; |
| 8029 |
#undef KWTUPLE |
| 8030 |
PyObject *argsbuf[7]; |
| 8031 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; |
| 8032 |
int out_fd; |
| 8033 |
int in_fd; |
| 8034 |
Py_off_t offset; |
| 8035 |
Py_off_t sbytes; |
| 8036 |
PyObject *headers = NULL; |
| 8037 |
PyObject *trailers = NULL; |
| 8038 |
int flags = 0; |
| 8039 |
|
| 8040 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8041 |
/*minpos*/ 4, /*maxpos*/ 7, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8042 |
if (!args) { |
| 8043 |
goto exit; |
| 8044 |
} |
| 8045 |
out_fd = PyLong_AsInt(args[0]); |
| 8046 |
if (out_fd == -1 && PyErr_Occurred()) { |
| 8047 |
goto exit; |
| 8048 |
} |
| 8049 |
in_fd = PyLong_AsInt(args[1]); |
| 8050 |
if (in_fd == -1 && PyErr_Occurred()) { |
| 8051 |
goto exit; |
| 8052 |
} |
| 8053 |
if (!Py_off_t_converter(args[2], &offset)) { |
| 8054 |
goto exit; |
| 8055 |
} |
| 8056 |
if (!Py_off_t_converter(args[3], &sbytes)) { |
| 8057 |
goto exit; |
| 8058 |
} |
| 8059 |
if (!noptargs) { |
| 8060 |
goto skip_optional_pos; |
| 8061 |
} |
| 8062 |
if (args[4]) { |
| 8063 |
headers = args[4]; |
| 8064 |
if (!--noptargs) { |
| 8065 |
goto skip_optional_pos; |
| 8066 |
} |
| 8067 |
} |
| 8068 |
if (args[5]) { |
| 8069 |
trailers = args[5]; |
| 8070 |
if (!--noptargs) { |
| 8071 |
goto skip_optional_pos; |
| 8072 |
} |
| 8073 |
} |
| 8074 |
flags = PyLong_AsInt(args[6]); |
| 8075 |
if (flags == -1 && PyErr_Occurred()) { |
| 8076 |
goto exit; |
| 8077 |
} |
| 8078 |
skip_optional_pos: |
| 8079 |
return_value = os_sendfile_impl(module, out_fd, in_fd, offset, sbytes, headers, trailers, flags); |
| 8080 |
|
| 8081 |
exit: |
| 8082 |
return return_value; |
| 8083 |
} |
| 8084 |
|
| 8085 |
#endif /* defined(HAVE_SENDFILE) && defined(__APPLE__) */ |
| 8086 |
|
| 8087 |
#if defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) |
| 8088 |
|
| 8089 |
PyDoc_STRVAR(os_sendfile__doc__, |
| 8090 |
"sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" |
| 8091 |
" trailers=(), flags=0)\n" |
| 8092 |
"--\n" |
| 8093 |
"\n" |
| 8094 |
"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); |
| 8095 |
|
| 8096 |
#define OS_SENDFILE_METHODDEF \ |
| 8097 |
{"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, |
| 8098 |
|
| 8099 |
static PyObject * |
| 8100 |
os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, |
| 8101 |
Py_ssize_t count, PyObject *headers, PyObject *trailers, |
| 8102 |
int flags); |
| 8103 |
|
| 8104 |
static PyObject * |
| 8105 |
os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8106 |
{ |
| 8107 |
PyObject *return_value = NULL; |
| 8108 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8109 |
|
| 8110 |
#define NUM_KEYWORDS 7 |
| 8111 |
static struct { |
| 8112 |
PyGC_Head _this_is_not_used; |
| 8113 |
PyObject_VAR_HEAD |
| 8114 |
Py_hash_t ob_hash; |
| 8115 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8116 |
} _kwtuple = { |
| 8117 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8118 |
.ob_hash = -1, |
| 8119 |
.ob_item = { &_Py_ID(out_fd), &_Py_ID(in_fd), &_Py_ID(offset), &_Py_ID(count), &_Py_ID(headers), &_Py_ID(trailers), &_Py_ID(flags), }, |
| 8120 |
}; |
| 8121 |
#undef NUM_KEYWORDS |
| 8122 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8123 |
|
| 8124 |
#else // !Py_BUILD_CORE |
| 8125 |
# define KWTUPLE NULL |
| 8126 |
#endif // !Py_BUILD_CORE |
| 8127 |
|
| 8128 |
static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; |
| 8129 |
static _PyArg_Parser _parser = { |
| 8130 |
.keywords = _keywords, |
| 8131 |
.fname = "sendfile", |
| 8132 |
.kwtuple = KWTUPLE, |
| 8133 |
}; |
| 8134 |
#undef KWTUPLE |
| 8135 |
PyObject *argsbuf[7]; |
| 8136 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; |
| 8137 |
int out_fd; |
| 8138 |
int in_fd; |
| 8139 |
Py_off_t offset; |
| 8140 |
Py_ssize_t count; |
| 8141 |
PyObject *headers = NULL; |
| 8142 |
PyObject *trailers = NULL; |
| 8143 |
int flags = 0; |
| 8144 |
|
| 8145 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8146 |
/*minpos*/ 4, /*maxpos*/ 7, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8147 |
if (!args) { |
| 8148 |
goto exit; |
| 8149 |
} |
| 8150 |
out_fd = PyLong_AsInt(args[0]); |
| 8151 |
if (out_fd == -1 && PyErr_Occurred()) { |
| 8152 |
goto exit; |
| 8153 |
} |
| 8154 |
in_fd = PyLong_AsInt(args[1]); |
| 8155 |
if (in_fd == -1 && PyErr_Occurred()) { |
| 8156 |
goto exit; |
| 8157 |
} |
| 8158 |
if (!Py_off_t_converter(args[2], &offset)) { |
| 8159 |
goto exit; |
| 8160 |
} |
| 8161 |
{ |
| 8162 |
Py_ssize_t ival = -1; |
| 8163 |
PyObject *iobj = _PyNumber_Index(args[3]); |
| 8164 |
if (iobj != NULL) { |
| 8165 |
ival = PyLong_AsSsize_t(iobj); |
| 8166 |
Py_DECREF(iobj); |
| 8167 |
} |
| 8168 |
if (ival == -1 && PyErr_Occurred()) { |
| 8169 |
goto exit; |
| 8170 |
} |
| 8171 |
count = ival; |
| 8172 |
} |
| 8173 |
if (!noptargs) { |
| 8174 |
goto skip_optional_pos; |
| 8175 |
} |
| 8176 |
if (args[4]) { |
| 8177 |
headers = args[4]; |
| 8178 |
if (!--noptargs) { |
| 8179 |
goto skip_optional_pos; |
| 8180 |
} |
| 8181 |
} |
| 8182 |
if (args[5]) { |
| 8183 |
trailers = args[5]; |
| 8184 |
if (!--noptargs) { |
| 8185 |
goto skip_optional_pos; |
| 8186 |
} |
| 8187 |
} |
| 8188 |
flags = PyLong_AsInt(args[6]); |
| 8189 |
if (flags == -1 && PyErr_Occurred()) { |
| 8190 |
goto exit; |
| 8191 |
} |
| 8192 |
skip_optional_pos: |
| 8193 |
return_value = os_sendfile_impl(module, out_fd, in_fd, offset, count, headers, trailers, flags); |
| 8194 |
|
| 8195 |
exit: |
| 8196 |
return return_value; |
| 8197 |
} |
| 8198 |
|
| 8199 |
#endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) */ |
| 8200 |
|
| 8201 |
#if defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) |
| 8202 |
|
| 8203 |
PyDoc_STRVAR(os_sendfile__doc__, |
| 8204 |
"sendfile($module, /, out_fd, in_fd, offset, count)\n" |
| 8205 |
"--\n" |
| 8206 |
"\n" |
| 8207 |
"Copy count bytes from file descriptor in_fd to file descriptor out_fd."); |
| 8208 |
|
| 8209 |
#define OS_SENDFILE_METHODDEF \ |
| 8210 |
{"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, |
| 8211 |
|
| 8212 |
static PyObject * |
| 8213 |
os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, |
| 8214 |
Py_ssize_t count); |
| 8215 |
|
| 8216 |
static PyObject * |
| 8217 |
os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8218 |
{ |
| 8219 |
PyObject *return_value = NULL; |
| 8220 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8221 |
|
| 8222 |
#define NUM_KEYWORDS 4 |
| 8223 |
static struct { |
| 8224 |
PyGC_Head _this_is_not_used; |
| 8225 |
PyObject_VAR_HEAD |
| 8226 |
Py_hash_t ob_hash; |
| 8227 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8228 |
} _kwtuple = { |
| 8229 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8230 |
.ob_hash = -1, |
| 8231 |
.ob_item = { &_Py_ID(out_fd), &_Py_ID(in_fd), &_Py_ID(offset), &_Py_ID(count), }, |
| 8232 |
}; |
| 8233 |
#undef NUM_KEYWORDS |
| 8234 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8235 |
|
| 8236 |
#else // !Py_BUILD_CORE |
| 8237 |
# define KWTUPLE NULL |
| 8238 |
#endif // !Py_BUILD_CORE |
| 8239 |
|
| 8240 |
static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", NULL}; |
| 8241 |
static _PyArg_Parser _parser = { |
| 8242 |
.keywords = _keywords, |
| 8243 |
.fname = "sendfile", |
| 8244 |
.kwtuple = KWTUPLE, |
| 8245 |
}; |
| 8246 |
#undef KWTUPLE |
| 8247 |
PyObject *argsbuf[4]; |
| 8248 |
int out_fd; |
| 8249 |
int in_fd; |
| 8250 |
PyObject *offobj; |
| 8251 |
Py_ssize_t count; |
| 8252 |
|
| 8253 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8254 |
/*minpos*/ 4, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8255 |
if (!args) { |
| 8256 |
goto exit; |
| 8257 |
} |
| 8258 |
out_fd = PyLong_AsInt(args[0]); |
| 8259 |
if (out_fd == -1 && PyErr_Occurred()) { |
| 8260 |
goto exit; |
| 8261 |
} |
| 8262 |
in_fd = PyLong_AsInt(args[1]); |
| 8263 |
if (in_fd == -1 && PyErr_Occurred()) { |
| 8264 |
goto exit; |
| 8265 |
} |
| 8266 |
offobj = args[2]; |
| 8267 |
{ |
| 8268 |
Py_ssize_t ival = -1; |
| 8269 |
PyObject *iobj = _PyNumber_Index(args[3]); |
| 8270 |
if (iobj != NULL) { |
| 8271 |
ival = PyLong_AsSsize_t(iobj); |
| 8272 |
Py_DECREF(iobj); |
| 8273 |
} |
| 8274 |
if (ival == -1 && PyErr_Occurred()) { |
| 8275 |
goto exit; |
| 8276 |
} |
| 8277 |
count = ival; |
| 8278 |
} |
| 8279 |
return_value = os_sendfile_impl(module, out_fd, in_fd, offobj, count); |
| 8280 |
|
| 8281 |
exit: |
| 8282 |
return return_value; |
| 8283 |
} |
| 8284 |
|
| 8285 |
#endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) */ |
| 8286 |
|
| 8287 |
#if defined(__APPLE__) |
| 8288 |
|
| 8289 |
PyDoc_STRVAR(os__fcopyfile__doc__, |
| 8290 |
"_fcopyfile($module, in_fd, out_fd, flags, /)\n" |
| 8291 |
"--\n" |
| 8292 |
"\n" |
| 8293 |
"Efficiently copy content or metadata of 2 regular file descriptors (macOS)."); |
| 8294 |
|
| 8295 |
#define OS__FCOPYFILE_METHODDEF \ |
| 8296 |
{"_fcopyfile", _PyCFunction_CAST(os__fcopyfile), METH_FASTCALL, os__fcopyfile__doc__}, |
| 8297 |
|
| 8298 |
static PyObject * |
| 8299 |
os__fcopyfile_impl(PyObject *module, int in_fd, int out_fd, int flags); |
| 8300 |
|
| 8301 |
static PyObject * |
| 8302 |
os__fcopyfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 8303 |
{ |
| 8304 |
PyObject *return_value = NULL; |
| 8305 |
int in_fd; |
| 8306 |
int out_fd; |
| 8307 |
int flags; |
| 8308 |
|
| 8309 |
if (!_PyArg_CheckPositional("_fcopyfile", nargs, 3, 3)) { |
| 8310 |
goto exit; |
| 8311 |
} |
| 8312 |
in_fd = PyLong_AsInt(args[0]); |
| 8313 |
if (in_fd == -1 && PyErr_Occurred()) { |
| 8314 |
goto exit; |
| 8315 |
} |
| 8316 |
out_fd = PyLong_AsInt(args[1]); |
| 8317 |
if (out_fd == -1 && PyErr_Occurred()) { |
| 8318 |
goto exit; |
| 8319 |
} |
| 8320 |
flags = PyLong_AsInt(args[2]); |
| 8321 |
if (flags == -1 && PyErr_Occurred()) { |
| 8322 |
goto exit; |
| 8323 |
} |
| 8324 |
return_value = os__fcopyfile_impl(module, in_fd, out_fd, flags); |
| 8325 |
|
| 8326 |
exit: |
| 8327 |
return return_value; |
| 8328 |
} |
| 8329 |
|
| 8330 |
#endif /* defined(__APPLE__) */ |
| 8331 |
|
| 8332 |
PyDoc_STRVAR(os_fstat__doc__, |
| 8333 |
"fstat($module, /, fd)\n" |
| 8334 |
"--\n" |
| 8335 |
"\n" |
| 8336 |
"Perform a stat system call on the given file descriptor.\n" |
| 8337 |
"\n" |
| 8338 |
"Like stat(), but for an open file descriptor.\n" |
| 8339 |
"Equivalent to os.stat(fd)."); |
| 8340 |
|
| 8341 |
#define OS_FSTAT_METHODDEF \ |
| 8342 |
{"fstat", _PyCFunction_CAST(os_fstat), METH_FASTCALL|METH_KEYWORDS, os_fstat__doc__}, |
| 8343 |
|
| 8344 |
static PyObject * |
| 8345 |
os_fstat_impl(PyObject *module, int fd); |
| 8346 |
|
| 8347 |
static PyObject * |
| 8348 |
os_fstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8349 |
{ |
| 8350 |
PyObject *return_value = NULL; |
| 8351 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8352 |
|
| 8353 |
#define NUM_KEYWORDS 1 |
| 8354 |
static struct { |
| 8355 |
PyGC_Head _this_is_not_used; |
| 8356 |
PyObject_VAR_HEAD |
| 8357 |
Py_hash_t ob_hash; |
| 8358 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8359 |
} _kwtuple = { |
| 8360 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8361 |
.ob_hash = -1, |
| 8362 |
.ob_item = { &_Py_ID(fd), }, |
| 8363 |
}; |
| 8364 |
#undef NUM_KEYWORDS |
| 8365 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8366 |
|
| 8367 |
#else // !Py_BUILD_CORE |
| 8368 |
# define KWTUPLE NULL |
| 8369 |
#endif // !Py_BUILD_CORE |
| 8370 |
|
| 8371 |
static const char * const _keywords[] = {"fd", NULL}; |
| 8372 |
static _PyArg_Parser _parser = { |
| 8373 |
.keywords = _keywords, |
| 8374 |
.fname = "fstat", |
| 8375 |
.kwtuple = KWTUPLE, |
| 8376 |
}; |
| 8377 |
#undef KWTUPLE |
| 8378 |
PyObject *argsbuf[1]; |
| 8379 |
int fd; |
| 8380 |
|
| 8381 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8382 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8383 |
if (!args) { |
| 8384 |
goto exit; |
| 8385 |
} |
| 8386 |
fd = PyLong_AsInt(args[0]); |
| 8387 |
if (fd == -1 && PyErr_Occurred()) { |
| 8388 |
goto exit; |
| 8389 |
} |
| 8390 |
return_value = os_fstat_impl(module, fd); |
| 8391 |
|
| 8392 |
exit: |
| 8393 |
return return_value; |
| 8394 |
} |
| 8395 |
|
| 8396 |
PyDoc_STRVAR(os_isatty__doc__, |
| 8397 |
"isatty($module, fd, /)\n" |
| 8398 |
"--\n" |
| 8399 |
"\n" |
| 8400 |
"Return True if the fd is connected to a terminal.\n" |
| 8401 |
"\n" |
| 8402 |
"Return True if the file descriptor is an open file descriptor\n" |
| 8403 |
"connected to the slave end of a terminal."); |
| 8404 |
|
| 8405 |
#define OS_ISATTY_METHODDEF \ |
| 8406 |
{"isatty", (PyCFunction)os_isatty, METH_O, os_isatty__doc__}, |
| 8407 |
|
| 8408 |
static int |
| 8409 |
os_isatty_impl(PyObject *module, int fd); |
| 8410 |
|
| 8411 |
static PyObject * |
| 8412 |
os_isatty(PyObject *module, PyObject *arg) |
| 8413 |
{ |
| 8414 |
PyObject *return_value = NULL; |
| 8415 |
int fd; |
| 8416 |
int _return_value; |
| 8417 |
|
| 8418 |
fd = PyLong_AsInt(arg); |
| 8419 |
if (fd == -1 && PyErr_Occurred()) { |
| 8420 |
goto exit; |
| 8421 |
} |
| 8422 |
_return_value = os_isatty_impl(module, fd); |
| 8423 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 8424 |
goto exit; |
| 8425 |
} |
| 8426 |
return_value = PyBool_FromLong((long)_return_value); |
| 8427 |
|
| 8428 |
exit: |
| 8429 |
return return_value; |
| 8430 |
} |
| 8431 |
|
| 8432 |
#if defined(HAVE_PIPE) |
| 8433 |
|
| 8434 |
PyDoc_STRVAR(os_pipe__doc__, |
| 8435 |
"pipe($module, /)\n" |
| 8436 |
"--\n" |
| 8437 |
"\n" |
| 8438 |
"Create a pipe.\n" |
| 8439 |
"\n" |
| 8440 |
"Returns a tuple of two file descriptors:\n" |
| 8441 |
" (read_fd, write_fd)"); |
| 8442 |
|
| 8443 |
#define OS_PIPE_METHODDEF \ |
| 8444 |
{"pipe", (PyCFunction)os_pipe, METH_NOARGS, os_pipe__doc__}, |
| 8445 |
|
| 8446 |
static PyObject * |
| 8447 |
os_pipe_impl(PyObject *module); |
| 8448 |
|
| 8449 |
static PyObject * |
| 8450 |
os_pipe(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 8451 |
{ |
| 8452 |
return os_pipe_impl(module); |
| 8453 |
} |
| 8454 |
|
| 8455 |
#endif /* defined(HAVE_PIPE) */ |
| 8456 |
|
| 8457 |
#if defined(HAVE_PIPE2) |
| 8458 |
|
| 8459 |
PyDoc_STRVAR(os_pipe2__doc__, |
| 8460 |
"pipe2($module, flags, /)\n" |
| 8461 |
"--\n" |
| 8462 |
"\n" |
| 8463 |
"Create a pipe with flags set atomically.\n" |
| 8464 |
"\n" |
| 8465 |
"Returns a tuple of two file descriptors:\n" |
| 8466 |
" (read_fd, write_fd)\n" |
| 8467 |
"\n" |
| 8468 |
"flags can be constructed by ORing together one or more of these values:\n" |
| 8469 |
"O_NONBLOCK, O_CLOEXEC."); |
| 8470 |
|
| 8471 |
#define OS_PIPE2_METHODDEF \ |
| 8472 |
{"pipe2", (PyCFunction)os_pipe2, METH_O, os_pipe2__doc__}, |
| 8473 |
|
| 8474 |
static PyObject * |
| 8475 |
os_pipe2_impl(PyObject *module, int flags); |
| 8476 |
|
| 8477 |
static PyObject * |
| 8478 |
os_pipe2(PyObject *module, PyObject *arg) |
| 8479 |
{ |
| 8480 |
PyObject *return_value = NULL; |
| 8481 |
int flags; |
| 8482 |
|
| 8483 |
flags = PyLong_AsInt(arg); |
| 8484 |
if (flags == -1 && PyErr_Occurred()) { |
| 8485 |
goto exit; |
| 8486 |
} |
| 8487 |
return_value = os_pipe2_impl(module, flags); |
| 8488 |
|
| 8489 |
exit: |
| 8490 |
return return_value; |
| 8491 |
} |
| 8492 |
|
| 8493 |
#endif /* defined(HAVE_PIPE2) */ |
| 8494 |
|
| 8495 |
#if defined(HAVE_WRITEV) |
| 8496 |
|
| 8497 |
PyDoc_STRVAR(os_writev__doc__, |
| 8498 |
"writev($module, fd, buffers, /)\n" |
| 8499 |
"--\n" |
| 8500 |
"\n" |
| 8501 |
"Iterate over buffers, and write the contents of each to a file descriptor.\n" |
| 8502 |
"\n" |
| 8503 |
"Returns the total number of bytes written.\n" |
| 8504 |
"buffers must be a sequence of bytes-like objects."); |
| 8505 |
|
| 8506 |
#define OS_WRITEV_METHODDEF \ |
| 8507 |
{"writev", _PyCFunction_CAST(os_writev), METH_FASTCALL, os_writev__doc__}, |
| 8508 |
|
| 8509 |
static Py_ssize_t |
| 8510 |
os_writev_impl(PyObject *module, int fd, PyObject *buffers); |
| 8511 |
|
| 8512 |
static PyObject * |
| 8513 |
os_writev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 8514 |
{ |
| 8515 |
PyObject *return_value = NULL; |
| 8516 |
int fd; |
| 8517 |
PyObject *buffers; |
| 8518 |
Py_ssize_t _return_value; |
| 8519 |
|
| 8520 |
if (!_PyArg_CheckPositional("writev", nargs, 2, 2)) { |
| 8521 |
goto exit; |
| 8522 |
} |
| 8523 |
fd = PyLong_AsInt(args[0]); |
| 8524 |
if (fd == -1 && PyErr_Occurred()) { |
| 8525 |
goto exit; |
| 8526 |
} |
| 8527 |
buffers = args[1]; |
| 8528 |
_return_value = os_writev_impl(module, fd, buffers); |
| 8529 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 8530 |
goto exit; |
| 8531 |
} |
| 8532 |
return_value = PyLong_FromSsize_t(_return_value); |
| 8533 |
|
| 8534 |
exit: |
| 8535 |
return return_value; |
| 8536 |
} |
| 8537 |
|
| 8538 |
#endif /* defined(HAVE_WRITEV) */ |
| 8539 |
|
| 8540 |
#if defined(HAVE_PWRITE) |
| 8541 |
|
| 8542 |
PyDoc_STRVAR(os_pwrite__doc__, |
| 8543 |
"pwrite($module, fd, buffer, offset, /)\n" |
| 8544 |
"--\n" |
| 8545 |
"\n" |
| 8546 |
"Write bytes to a file descriptor starting at a particular offset.\n" |
| 8547 |
"\n" |
| 8548 |
"Write buffer to fd, starting at offset bytes from the beginning of\n" |
| 8549 |
"the file. Returns the number of bytes written. Does not change the\n" |
| 8550 |
"current file offset."); |
| 8551 |
|
| 8552 |
#define OS_PWRITE_METHODDEF \ |
| 8553 |
{"pwrite", _PyCFunction_CAST(os_pwrite), METH_FASTCALL, os_pwrite__doc__}, |
| 8554 |
|
| 8555 |
static Py_ssize_t |
| 8556 |
os_pwrite_impl(PyObject *module, int fd, Py_buffer *buffer, Py_off_t offset); |
| 8557 |
|
| 8558 |
static PyObject * |
| 8559 |
os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 8560 |
{ |
| 8561 |
PyObject *return_value = NULL; |
| 8562 |
int fd; |
| 8563 |
Py_buffer buffer = {NULL, NULL}; |
| 8564 |
Py_off_t offset; |
| 8565 |
Py_ssize_t _return_value; |
| 8566 |
|
| 8567 |
if (!_PyArg_CheckPositional("pwrite", nargs, 3, 3)) { |
| 8568 |
goto exit; |
| 8569 |
} |
| 8570 |
fd = PyLong_AsInt(args[0]); |
| 8571 |
if (fd == -1 && PyErr_Occurred()) { |
| 8572 |
goto exit; |
| 8573 |
} |
| 8574 |
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { |
| 8575 |
goto exit; |
| 8576 |
} |
| 8577 |
if (!Py_off_t_converter(args[2], &offset)) { |
| 8578 |
goto exit; |
| 8579 |
} |
| 8580 |
_return_value = os_pwrite_impl(module, fd, &buffer, offset); |
| 8581 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 8582 |
goto exit; |
| 8583 |
} |
| 8584 |
return_value = PyLong_FromSsize_t(_return_value); |
| 8585 |
|
| 8586 |
exit: |
| 8587 |
/* Cleanup for buffer */ |
| 8588 |
if (buffer.obj) { |
| 8589 |
PyBuffer_Release(&buffer); |
| 8590 |
} |
| 8591 |
|
| 8592 |
return return_value; |
| 8593 |
} |
| 8594 |
|
| 8595 |
#endif /* defined(HAVE_PWRITE) */ |
| 8596 |
|
| 8597 |
#if (defined(HAVE_PWRITEV) || defined (HAVE_PWRITEV2)) |
| 8598 |
|
| 8599 |
PyDoc_STRVAR(os_pwritev__doc__, |
| 8600 |
"pwritev($module, fd, buffers, offset, flags=0, /)\n" |
| 8601 |
"--\n" |
| 8602 |
"\n" |
| 8603 |
"Writes the contents of bytes-like objects to a file descriptor at a given offset.\n" |
| 8604 |
"\n" |
| 8605 |
"Combines the functionality of writev() and pwrite(). All buffers must be a sequence\n" |
| 8606 |
"of bytes-like objects. Buffers are processed in array order. Entire contents of first\n" |
| 8607 |
"buffer is written before proceeding to second, and so on. The operating system may\n" |
| 8608 |
"set a limit (sysconf() value SC_IOV_MAX) on the number of buffers that can be used.\n" |
| 8609 |
"This function writes the contents of each object to the file descriptor and returns\n" |
| 8610 |
"the total number of bytes written.\n" |
| 8611 |
"\n" |
| 8612 |
"The flags argument contains a bitwise OR of zero or more of the following flags:\n" |
| 8613 |
"\n" |
| 8614 |
"- RWF_DSYNC\n" |
| 8615 |
"- RWF_SYNC\n" |
| 8616 |
"- RWF_APPEND\n" |
| 8617 |
"\n" |
| 8618 |
"Using non-zero flags requires Linux 4.7 or newer."); |
| 8619 |
|
| 8620 |
#define OS_PWRITEV_METHODDEF \ |
| 8621 |
{"pwritev", _PyCFunction_CAST(os_pwritev), METH_FASTCALL, os_pwritev__doc__}, |
| 8622 |
|
| 8623 |
static Py_ssize_t |
| 8624 |
os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, |
| 8625 |
int flags); |
| 8626 |
|
| 8627 |
static PyObject * |
| 8628 |
os_pwritev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 8629 |
{ |
| 8630 |
PyObject *return_value = NULL; |
| 8631 |
int fd; |
| 8632 |
PyObject *buffers; |
| 8633 |
Py_off_t offset; |
| 8634 |
int flags = 0; |
| 8635 |
Py_ssize_t _return_value; |
| 8636 |
|
| 8637 |
if (!_PyArg_CheckPositional("pwritev", nargs, 3, 4)) { |
| 8638 |
goto exit; |
| 8639 |
} |
| 8640 |
fd = PyLong_AsInt(args[0]); |
| 8641 |
if (fd == -1 && PyErr_Occurred()) { |
| 8642 |
goto exit; |
| 8643 |
} |
| 8644 |
buffers = args[1]; |
| 8645 |
if (!Py_off_t_converter(args[2], &offset)) { |
| 8646 |
goto exit; |
| 8647 |
} |
| 8648 |
if (nargs < 4) { |
| 8649 |
goto skip_optional; |
| 8650 |
} |
| 8651 |
flags = PyLong_AsInt(args[3]); |
| 8652 |
if (flags == -1 && PyErr_Occurred()) { |
| 8653 |
goto exit; |
| 8654 |
} |
| 8655 |
skip_optional: |
| 8656 |
_return_value = os_pwritev_impl(module, fd, buffers, offset, flags); |
| 8657 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 8658 |
goto exit; |
| 8659 |
} |
| 8660 |
return_value = PyLong_FromSsize_t(_return_value); |
| 8661 |
|
| 8662 |
exit: |
| 8663 |
return return_value; |
| 8664 |
} |
| 8665 |
|
| 8666 |
#endif /* (defined(HAVE_PWRITEV) || defined (HAVE_PWRITEV2)) */ |
| 8667 |
|
| 8668 |
#if defined(HAVE_COPY_FILE_RANGE) |
| 8669 |
|
| 8670 |
PyDoc_STRVAR(os_copy_file_range__doc__, |
| 8671 |
"copy_file_range($module, /, src, dst, count, offset_src=None,\n" |
| 8672 |
" offset_dst=None)\n" |
| 8673 |
"--\n" |
| 8674 |
"\n" |
| 8675 |
"Copy count bytes from one file descriptor to another.\n" |
| 8676 |
"\n" |
| 8677 |
" src\n" |
| 8678 |
" Source file descriptor.\n" |
| 8679 |
" dst\n" |
| 8680 |
" Destination file descriptor.\n" |
| 8681 |
" count\n" |
| 8682 |
" Number of bytes to copy.\n" |
| 8683 |
" offset_src\n" |
| 8684 |
" Starting offset in src.\n" |
| 8685 |
" offset_dst\n" |
| 8686 |
" Starting offset in dst.\n" |
| 8687 |
"\n" |
| 8688 |
"If offset_src is None, then src is read from the current position;\n" |
| 8689 |
"respectively for offset_dst."); |
| 8690 |
|
| 8691 |
#define OS_COPY_FILE_RANGE_METHODDEF \ |
| 8692 |
{"copy_file_range", _PyCFunction_CAST(os_copy_file_range), METH_FASTCALL|METH_KEYWORDS, os_copy_file_range__doc__}, |
| 8693 |
|
| 8694 |
static PyObject * |
| 8695 |
os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, |
| 8696 |
PyObject *offset_src, PyObject *offset_dst); |
| 8697 |
|
| 8698 |
static PyObject * |
| 8699 |
os_copy_file_range(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8700 |
{ |
| 8701 |
PyObject *return_value = NULL; |
| 8702 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8703 |
|
| 8704 |
#define NUM_KEYWORDS 5 |
| 8705 |
static struct { |
| 8706 |
PyGC_Head _this_is_not_used; |
| 8707 |
PyObject_VAR_HEAD |
| 8708 |
Py_hash_t ob_hash; |
| 8709 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8710 |
} _kwtuple = { |
| 8711 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8712 |
.ob_hash = -1, |
| 8713 |
.ob_item = { &_Py_ID(src), &_Py_ID(dst), &_Py_ID(count), &_Py_ID(offset_src), &_Py_ID(offset_dst), }, |
| 8714 |
}; |
| 8715 |
#undef NUM_KEYWORDS |
| 8716 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8717 |
|
| 8718 |
#else // !Py_BUILD_CORE |
| 8719 |
# define KWTUPLE NULL |
| 8720 |
#endif // !Py_BUILD_CORE |
| 8721 |
|
| 8722 |
static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", NULL}; |
| 8723 |
static _PyArg_Parser _parser = { |
| 8724 |
.keywords = _keywords, |
| 8725 |
.fname = "copy_file_range", |
| 8726 |
.kwtuple = KWTUPLE, |
| 8727 |
}; |
| 8728 |
#undef KWTUPLE |
| 8729 |
PyObject *argsbuf[5]; |
| 8730 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
| 8731 |
int src; |
| 8732 |
int dst; |
| 8733 |
Py_ssize_t count; |
| 8734 |
PyObject *offset_src = Py_None; |
| 8735 |
PyObject *offset_dst = Py_None; |
| 8736 |
|
| 8737 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8738 |
/*minpos*/ 3, /*maxpos*/ 5, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8739 |
if (!args) { |
| 8740 |
goto exit; |
| 8741 |
} |
| 8742 |
src = PyLong_AsInt(args[0]); |
| 8743 |
if (src == -1 && PyErr_Occurred()) { |
| 8744 |
goto exit; |
| 8745 |
} |
| 8746 |
dst = PyLong_AsInt(args[1]); |
| 8747 |
if (dst == -1 && PyErr_Occurred()) { |
| 8748 |
goto exit; |
| 8749 |
} |
| 8750 |
{ |
| 8751 |
Py_ssize_t ival = -1; |
| 8752 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 8753 |
if (iobj != NULL) { |
| 8754 |
ival = PyLong_AsSsize_t(iobj); |
| 8755 |
Py_DECREF(iobj); |
| 8756 |
} |
| 8757 |
if (ival == -1 && PyErr_Occurred()) { |
| 8758 |
goto exit; |
| 8759 |
} |
| 8760 |
count = ival; |
| 8761 |
} |
| 8762 |
if (!noptargs) { |
| 8763 |
goto skip_optional_pos; |
| 8764 |
} |
| 8765 |
if (args[3]) { |
| 8766 |
offset_src = args[3]; |
| 8767 |
if (!--noptargs) { |
| 8768 |
goto skip_optional_pos; |
| 8769 |
} |
| 8770 |
} |
| 8771 |
offset_dst = args[4]; |
| 8772 |
skip_optional_pos: |
| 8773 |
return_value = os_copy_file_range_impl(module, src, dst, count, offset_src, offset_dst); |
| 8774 |
|
| 8775 |
exit: |
| 8776 |
return return_value; |
| 8777 |
} |
| 8778 |
|
| 8779 |
#endif /* defined(HAVE_COPY_FILE_RANGE) */ |
| 8780 |
|
| 8781 |
#if ((defined(HAVE_SPLICE) && !defined(_AIX))) |
| 8782 |
|
| 8783 |
PyDoc_STRVAR(os_splice__doc__, |
| 8784 |
"splice($module, /, src, dst, count, offset_src=None, offset_dst=None,\n" |
| 8785 |
" flags=0)\n" |
| 8786 |
"--\n" |
| 8787 |
"\n" |
| 8788 |
"Transfer count bytes from one pipe to a descriptor or vice versa.\n" |
| 8789 |
"\n" |
| 8790 |
" src\n" |
| 8791 |
" Source file descriptor.\n" |
| 8792 |
" dst\n" |
| 8793 |
" Destination file descriptor.\n" |
| 8794 |
" count\n" |
| 8795 |
" Number of bytes to copy.\n" |
| 8796 |
" offset_src\n" |
| 8797 |
" Starting offset in src.\n" |
| 8798 |
" offset_dst\n" |
| 8799 |
" Starting offset in dst.\n" |
| 8800 |
" flags\n" |
| 8801 |
" Flags to modify the semantics of the call.\n" |
| 8802 |
"\n" |
| 8803 |
"If offset_src is None, then src is read from the current position;\n" |
| 8804 |
"respectively for offset_dst. The offset associated to the file\n" |
| 8805 |
"descriptor that refers to a pipe must be None."); |
| 8806 |
|
| 8807 |
#define OS_SPLICE_METHODDEF \ |
| 8808 |
{"splice", _PyCFunction_CAST(os_splice), METH_FASTCALL|METH_KEYWORDS, os_splice__doc__}, |
| 8809 |
|
| 8810 |
static PyObject * |
| 8811 |
os_splice_impl(PyObject *module, int src, int dst, Py_ssize_t count, |
| 8812 |
PyObject *offset_src, PyObject *offset_dst, |
| 8813 |
unsigned int flags); |
| 8814 |
|
| 8815 |
static PyObject * |
| 8816 |
os_splice(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8817 |
{ |
| 8818 |
PyObject *return_value = NULL; |
| 8819 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8820 |
|
| 8821 |
#define NUM_KEYWORDS 6 |
| 8822 |
static struct { |
| 8823 |
PyGC_Head _this_is_not_used; |
| 8824 |
PyObject_VAR_HEAD |
| 8825 |
Py_hash_t ob_hash; |
| 8826 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8827 |
} _kwtuple = { |
| 8828 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8829 |
.ob_hash = -1, |
| 8830 |
.ob_item = { &_Py_ID(src), &_Py_ID(dst), &_Py_ID(count), &_Py_ID(offset_src), &_Py_ID(offset_dst), &_Py_ID(flags), }, |
| 8831 |
}; |
| 8832 |
#undef NUM_KEYWORDS |
| 8833 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8834 |
|
| 8835 |
#else // !Py_BUILD_CORE |
| 8836 |
# define KWTUPLE NULL |
| 8837 |
#endif // !Py_BUILD_CORE |
| 8838 |
|
| 8839 |
static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", "flags", NULL}; |
| 8840 |
static _PyArg_Parser _parser = { |
| 8841 |
.keywords = _keywords, |
| 8842 |
.fname = "splice", |
| 8843 |
.kwtuple = KWTUPLE, |
| 8844 |
}; |
| 8845 |
#undef KWTUPLE |
| 8846 |
PyObject *argsbuf[6]; |
| 8847 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
| 8848 |
int src; |
| 8849 |
int dst; |
| 8850 |
Py_ssize_t count; |
| 8851 |
PyObject *offset_src = Py_None; |
| 8852 |
PyObject *offset_dst = Py_None; |
| 8853 |
unsigned int flags = 0; |
| 8854 |
|
| 8855 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8856 |
/*minpos*/ 3, /*maxpos*/ 6, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8857 |
if (!args) { |
| 8858 |
goto exit; |
| 8859 |
} |
| 8860 |
src = PyLong_AsInt(args[0]); |
| 8861 |
if (src == -1 && PyErr_Occurred()) { |
| 8862 |
goto exit; |
| 8863 |
} |
| 8864 |
dst = PyLong_AsInt(args[1]); |
| 8865 |
if (dst == -1 && PyErr_Occurred()) { |
| 8866 |
goto exit; |
| 8867 |
} |
| 8868 |
{ |
| 8869 |
Py_ssize_t ival = -1; |
| 8870 |
PyObject *iobj = _PyNumber_Index(args[2]); |
| 8871 |
if (iobj != NULL) { |
| 8872 |
ival = PyLong_AsSsize_t(iobj); |
| 8873 |
Py_DECREF(iobj); |
| 8874 |
} |
| 8875 |
if (ival == -1 && PyErr_Occurred()) { |
| 8876 |
goto exit; |
| 8877 |
} |
| 8878 |
count = ival; |
| 8879 |
} |
| 8880 |
if (!noptargs) { |
| 8881 |
goto skip_optional_pos; |
| 8882 |
} |
| 8883 |
if (args[3]) { |
| 8884 |
offset_src = args[3]; |
| 8885 |
if (!--noptargs) { |
| 8886 |
goto skip_optional_pos; |
| 8887 |
} |
| 8888 |
} |
| 8889 |
if (args[4]) { |
| 8890 |
offset_dst = args[4]; |
| 8891 |
if (!--noptargs) { |
| 8892 |
goto skip_optional_pos; |
| 8893 |
} |
| 8894 |
} |
| 8895 |
if (!_PyLong_UnsignedInt_Converter(args[5], &flags)) { |
| 8896 |
goto exit; |
| 8897 |
} |
| 8898 |
skip_optional_pos: |
| 8899 |
return_value = os_splice_impl(module, src, dst, count, offset_src, offset_dst, flags); |
| 8900 |
|
| 8901 |
exit: |
| 8902 |
return return_value; |
| 8903 |
} |
| 8904 |
|
| 8905 |
#endif /* ((defined(HAVE_SPLICE) && !defined(_AIX))) */ |
| 8906 |
|
| 8907 |
#if defined(HAVE_MKFIFO) |
| 8908 |
|
| 8909 |
PyDoc_STRVAR(os_mkfifo__doc__, |
| 8910 |
"mkfifo($module, /, path, mode=438, *, dir_fd=None)\n" |
| 8911 |
"--\n" |
| 8912 |
"\n" |
| 8913 |
"Create a \"fifo\" (a POSIX named pipe).\n" |
| 8914 |
"\n" |
| 8915 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 8916 |
" and path should be relative; path will then be relative to that directory.\n" |
| 8917 |
"dir_fd may not be implemented on your platform.\n" |
| 8918 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 8919 |
|
| 8920 |
#define OS_MKFIFO_METHODDEF \ |
| 8921 |
{"mkfifo", _PyCFunction_CAST(os_mkfifo), METH_FASTCALL|METH_KEYWORDS, os_mkfifo__doc__}, |
| 8922 |
|
| 8923 |
static PyObject * |
| 8924 |
os_mkfifo_impl(PyObject *module, path_t *path, int mode, int dir_fd); |
| 8925 |
|
| 8926 |
static PyObject * |
| 8927 |
os_mkfifo(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 8928 |
{ |
| 8929 |
PyObject *return_value = NULL; |
| 8930 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 8931 |
|
| 8932 |
#define NUM_KEYWORDS 3 |
| 8933 |
static struct { |
| 8934 |
PyGC_Head _this_is_not_used; |
| 8935 |
PyObject_VAR_HEAD |
| 8936 |
Py_hash_t ob_hash; |
| 8937 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 8938 |
} _kwtuple = { |
| 8939 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 8940 |
.ob_hash = -1, |
| 8941 |
.ob_item = { &_Py_ID(path), &_Py_ID(mode), &_Py_ID(dir_fd), }, |
| 8942 |
}; |
| 8943 |
#undef NUM_KEYWORDS |
| 8944 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 8945 |
|
| 8946 |
#else // !Py_BUILD_CORE |
| 8947 |
# define KWTUPLE NULL |
| 8948 |
#endif // !Py_BUILD_CORE |
| 8949 |
|
| 8950 |
static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; |
| 8951 |
static _PyArg_Parser _parser = { |
| 8952 |
.keywords = _keywords, |
| 8953 |
.fname = "mkfifo", |
| 8954 |
.kwtuple = KWTUPLE, |
| 8955 |
}; |
| 8956 |
#undef KWTUPLE |
| 8957 |
PyObject *argsbuf[3]; |
| 8958 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 8959 |
path_t path = PATH_T_INITIALIZE_P("mkfifo", "path", 0, 0, 0, 0); |
| 8960 |
int mode = 438; |
| 8961 |
int dir_fd = DEFAULT_DIR_FD; |
| 8962 |
|
| 8963 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 8964 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 8965 |
if (!args) { |
| 8966 |
goto exit; |
| 8967 |
} |
| 8968 |
if (!path_converter(args[0], &path)) { |
| 8969 |
goto exit; |
| 8970 |
} |
| 8971 |
if (!noptargs) { |
| 8972 |
goto skip_optional_pos; |
| 8973 |
} |
| 8974 |
if (args[1]) { |
| 8975 |
mode = PyLong_AsInt(args[1]); |
| 8976 |
if (mode == -1 && PyErr_Occurred()) { |
| 8977 |
goto exit; |
| 8978 |
} |
| 8979 |
if (!--noptargs) { |
| 8980 |
goto skip_optional_pos; |
| 8981 |
} |
| 8982 |
} |
| 8983 |
skip_optional_pos: |
| 8984 |
if (!noptargs) { |
| 8985 |
goto skip_optional_kwonly; |
| 8986 |
} |
| 8987 |
if (!MKFIFOAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { |
| 8988 |
goto exit; |
| 8989 |
} |
| 8990 |
skip_optional_kwonly: |
| 8991 |
return_value = os_mkfifo_impl(module, &path, mode, dir_fd); |
| 8992 |
|
| 8993 |
exit: |
| 8994 |
/* Cleanup for path */ |
| 8995 |
path_cleanup(&path); |
| 8996 |
|
| 8997 |
return return_value; |
| 8998 |
} |
| 8999 |
|
| 9000 |
#endif /* defined(HAVE_MKFIFO) */ |
| 9001 |
|
| 9002 |
#if (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) |
| 9003 |
|
| 9004 |
PyDoc_STRVAR(os_mknod__doc__, |
| 9005 |
"mknod($module, /, path, mode=384, device=0, *, dir_fd=None)\n" |
| 9006 |
"--\n" |
| 9007 |
"\n" |
| 9008 |
"Create a node in the file system.\n" |
| 9009 |
"\n" |
| 9010 |
"Create a node in the file system (file, device special file or named pipe)\n" |
| 9011 |
"at path. mode specifies both the permissions to use and the\n" |
| 9012 |
"type of node to be created, being combined (bitwise OR) with one of\n" |
| 9013 |
"S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. If S_IFCHR or S_IFBLK is set on mode,\n" |
| 9014 |
"device defines the newly created device special file (probably using\n" |
| 9015 |
"os.makedev()). Otherwise device is ignored.\n" |
| 9016 |
"\n" |
| 9017 |
"If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
| 9018 |
" and path should be relative; path will then be relative to that directory.\n" |
| 9019 |
"dir_fd may not be implemented on your platform.\n" |
| 9020 |
" If it is unavailable, using it will raise a NotImplementedError."); |
| 9021 |
|
| 9022 |
#define OS_MKNOD_METHODDEF \ |
| 9023 |
{"mknod", _PyCFunction_CAST(os_mknod), METH_FASTCALL|METH_KEYWORDS, os_mknod__doc__}, |
| 9024 |
|
| 9025 |
static PyObject * |
| 9026 |
os_mknod_impl(PyObject *module, path_t *path, int mode, dev_t device, |
| 9027 |
int dir_fd); |
| 9028 |
|
| 9029 |
static PyObject * |
| 9030 |
os_mknod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9031 |
{ |
| 9032 |
PyObject *return_value = NULL; |
| 9033 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9034 |
|
| 9035 |
#define NUM_KEYWORDS 4 |
| 9036 |
static struct { |
| 9037 |
PyGC_Head _this_is_not_used; |
| 9038 |
PyObject_VAR_HEAD |
| 9039 |
Py_hash_t ob_hash; |
| 9040 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9041 |
} _kwtuple = { |
| 9042 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9043 |
.ob_hash = -1, |
| 9044 |
.ob_item = { &_Py_ID(path), &_Py_ID(mode), &_Py_ID(device), &_Py_ID(dir_fd), }, |
| 9045 |
}; |
| 9046 |
#undef NUM_KEYWORDS |
| 9047 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9048 |
|
| 9049 |
#else // !Py_BUILD_CORE |
| 9050 |
# define KWTUPLE NULL |
| 9051 |
#endif // !Py_BUILD_CORE |
| 9052 |
|
| 9053 |
static const char * const _keywords[] = {"path", "mode", "device", "dir_fd", NULL}; |
| 9054 |
static _PyArg_Parser _parser = { |
| 9055 |
.keywords = _keywords, |
| 9056 |
.fname = "mknod", |
| 9057 |
.kwtuple = KWTUPLE, |
| 9058 |
}; |
| 9059 |
#undef KWTUPLE |
| 9060 |
PyObject *argsbuf[4]; |
| 9061 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 9062 |
path_t path = PATH_T_INITIALIZE_P("mknod", "path", 0, 0, 0, 0); |
| 9063 |
int mode = 384; |
| 9064 |
dev_t device = 0; |
| 9065 |
int dir_fd = DEFAULT_DIR_FD; |
| 9066 |
|
| 9067 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9068 |
/*minpos*/ 1, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9069 |
if (!args) { |
| 9070 |
goto exit; |
| 9071 |
} |
| 9072 |
if (!path_converter(args[0], &path)) { |
| 9073 |
goto exit; |
| 9074 |
} |
| 9075 |
if (!noptargs) { |
| 9076 |
goto skip_optional_pos; |
| 9077 |
} |
| 9078 |
if (args[1]) { |
| 9079 |
mode = PyLong_AsInt(args[1]); |
| 9080 |
if (mode == -1 && PyErr_Occurred()) { |
| 9081 |
goto exit; |
| 9082 |
} |
| 9083 |
if (!--noptargs) { |
| 9084 |
goto skip_optional_pos; |
| 9085 |
} |
| 9086 |
} |
| 9087 |
if (args[2]) { |
| 9088 |
if (!_Py_Dev_Converter(args[2], &device)) { |
| 9089 |
goto exit; |
| 9090 |
} |
| 9091 |
if (!--noptargs) { |
| 9092 |
goto skip_optional_pos; |
| 9093 |
} |
| 9094 |
} |
| 9095 |
skip_optional_pos: |
| 9096 |
if (!noptargs) { |
| 9097 |
goto skip_optional_kwonly; |
| 9098 |
} |
| 9099 |
if (!MKNODAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { |
| 9100 |
goto exit; |
| 9101 |
} |
| 9102 |
skip_optional_kwonly: |
| 9103 |
return_value = os_mknod_impl(module, &path, mode, device, dir_fd); |
| 9104 |
|
| 9105 |
exit: |
| 9106 |
/* Cleanup for path */ |
| 9107 |
path_cleanup(&path); |
| 9108 |
|
| 9109 |
return return_value; |
| 9110 |
} |
| 9111 |
|
| 9112 |
#endif /* (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) */ |
| 9113 |
|
| 9114 |
#if defined(HAVE_DEVICE_MACROS) |
| 9115 |
|
| 9116 |
PyDoc_STRVAR(os_major__doc__, |
| 9117 |
"major($module, device, /)\n" |
| 9118 |
"--\n" |
| 9119 |
"\n" |
| 9120 |
"Extracts a device major number from a raw device number."); |
| 9121 |
|
| 9122 |
#define OS_MAJOR_METHODDEF \ |
| 9123 |
{"major", (PyCFunction)os_major, METH_O, os_major__doc__}, |
| 9124 |
|
| 9125 |
static PyObject * |
| 9126 |
os_major_impl(PyObject *module, dev_t device); |
| 9127 |
|
| 9128 |
static PyObject * |
| 9129 |
os_major(PyObject *module, PyObject *arg) |
| 9130 |
{ |
| 9131 |
PyObject *return_value = NULL; |
| 9132 |
dev_t device; |
| 9133 |
|
| 9134 |
if (!_Py_Dev_Converter(arg, &device)) { |
| 9135 |
goto exit; |
| 9136 |
} |
| 9137 |
return_value = os_major_impl(module, device); |
| 9138 |
|
| 9139 |
exit: |
| 9140 |
return return_value; |
| 9141 |
} |
| 9142 |
|
| 9143 |
#endif /* defined(HAVE_DEVICE_MACROS) */ |
| 9144 |
|
| 9145 |
#if defined(HAVE_DEVICE_MACROS) |
| 9146 |
|
| 9147 |
PyDoc_STRVAR(os_minor__doc__, |
| 9148 |
"minor($module, device, /)\n" |
| 9149 |
"--\n" |
| 9150 |
"\n" |
| 9151 |
"Extracts a device minor number from a raw device number."); |
| 9152 |
|
| 9153 |
#define OS_MINOR_METHODDEF \ |
| 9154 |
{"minor", (PyCFunction)os_minor, METH_O, os_minor__doc__}, |
| 9155 |
|
| 9156 |
static PyObject * |
| 9157 |
os_minor_impl(PyObject *module, dev_t device); |
| 9158 |
|
| 9159 |
static PyObject * |
| 9160 |
os_minor(PyObject *module, PyObject *arg) |
| 9161 |
{ |
| 9162 |
PyObject *return_value = NULL; |
| 9163 |
dev_t device; |
| 9164 |
|
| 9165 |
if (!_Py_Dev_Converter(arg, &device)) { |
| 9166 |
goto exit; |
| 9167 |
} |
| 9168 |
return_value = os_minor_impl(module, device); |
| 9169 |
|
| 9170 |
exit: |
| 9171 |
return return_value; |
| 9172 |
} |
| 9173 |
|
| 9174 |
#endif /* defined(HAVE_DEVICE_MACROS) */ |
| 9175 |
|
| 9176 |
#if defined(HAVE_DEVICE_MACROS) |
| 9177 |
|
| 9178 |
PyDoc_STRVAR(os_makedev__doc__, |
| 9179 |
"makedev($module, major, minor, /)\n" |
| 9180 |
"--\n" |
| 9181 |
"\n" |
| 9182 |
"Composes a raw device number from the major and minor device numbers."); |
| 9183 |
|
| 9184 |
#define OS_MAKEDEV_METHODDEF \ |
| 9185 |
{"makedev", _PyCFunction_CAST(os_makedev), METH_FASTCALL, os_makedev__doc__}, |
| 9186 |
|
| 9187 |
static dev_t |
| 9188 |
os_makedev_impl(PyObject *module, dev_t major, dev_t minor); |
| 9189 |
|
| 9190 |
static PyObject * |
| 9191 |
os_makedev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 9192 |
{ |
| 9193 |
PyObject *return_value = NULL; |
| 9194 |
dev_t major; |
| 9195 |
dev_t minor; |
| 9196 |
dev_t _return_value; |
| 9197 |
|
| 9198 |
if (!_PyArg_CheckPositional("makedev", nargs, 2, 2)) { |
| 9199 |
goto exit; |
| 9200 |
} |
| 9201 |
if (!_Py_Dev_Converter(args[0], &major)) { |
| 9202 |
goto exit; |
| 9203 |
} |
| 9204 |
if (!_Py_Dev_Converter(args[1], &minor)) { |
| 9205 |
goto exit; |
| 9206 |
} |
| 9207 |
_return_value = os_makedev_impl(module, major, minor); |
| 9208 |
if ((_return_value == (dev_t)-1) && PyErr_Occurred()) { |
| 9209 |
goto exit; |
| 9210 |
} |
| 9211 |
return_value = _PyLong_FromDev(_return_value); |
| 9212 |
|
| 9213 |
exit: |
| 9214 |
return return_value; |
| 9215 |
} |
| 9216 |
|
| 9217 |
#endif /* defined(HAVE_DEVICE_MACROS) */ |
| 9218 |
|
| 9219 |
#if (defined HAVE_FTRUNCATE || defined MS_WINDOWS) |
| 9220 |
|
| 9221 |
PyDoc_STRVAR(os_ftruncate__doc__, |
| 9222 |
"ftruncate($module, fd, length, /)\n" |
| 9223 |
"--\n" |
| 9224 |
"\n" |
| 9225 |
"Truncate a file, specified by file descriptor, to a specific length."); |
| 9226 |
|
| 9227 |
#define OS_FTRUNCATE_METHODDEF \ |
| 9228 |
{"ftruncate", _PyCFunction_CAST(os_ftruncate), METH_FASTCALL, os_ftruncate__doc__}, |
| 9229 |
|
| 9230 |
static PyObject * |
| 9231 |
os_ftruncate_impl(PyObject *module, int fd, Py_off_t length); |
| 9232 |
|
| 9233 |
static PyObject * |
| 9234 |
os_ftruncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 9235 |
{ |
| 9236 |
PyObject *return_value = NULL; |
| 9237 |
int fd; |
| 9238 |
Py_off_t length; |
| 9239 |
|
| 9240 |
if (!_PyArg_CheckPositional("ftruncate", nargs, 2, 2)) { |
| 9241 |
goto exit; |
| 9242 |
} |
| 9243 |
fd = PyLong_AsInt(args[0]); |
| 9244 |
if (fd == -1 && PyErr_Occurred()) { |
| 9245 |
goto exit; |
| 9246 |
} |
| 9247 |
if (!Py_off_t_converter(args[1], &length)) { |
| 9248 |
goto exit; |
| 9249 |
} |
| 9250 |
return_value = os_ftruncate_impl(module, fd, length); |
| 9251 |
|
| 9252 |
exit: |
| 9253 |
return return_value; |
| 9254 |
} |
| 9255 |
|
| 9256 |
#endif /* (defined HAVE_FTRUNCATE || defined MS_WINDOWS) */ |
| 9257 |
|
| 9258 |
#if (defined HAVE_TRUNCATE || defined MS_WINDOWS) |
| 9259 |
|
| 9260 |
PyDoc_STRVAR(os_truncate__doc__, |
| 9261 |
"truncate($module, /, path, length)\n" |
| 9262 |
"--\n" |
| 9263 |
"\n" |
| 9264 |
"Truncate a file, specified by path, to a specific length.\n" |
| 9265 |
"\n" |
| 9266 |
"On some platforms, path may also be specified as an open file descriptor.\n" |
| 9267 |
" If this functionality is unavailable, using it raises an exception."); |
| 9268 |
|
| 9269 |
#define OS_TRUNCATE_METHODDEF \ |
| 9270 |
{"truncate", _PyCFunction_CAST(os_truncate), METH_FASTCALL|METH_KEYWORDS, os_truncate__doc__}, |
| 9271 |
|
| 9272 |
static PyObject * |
| 9273 |
os_truncate_impl(PyObject *module, path_t *path, Py_off_t length); |
| 9274 |
|
| 9275 |
static PyObject * |
| 9276 |
os_truncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9277 |
{ |
| 9278 |
PyObject *return_value = NULL; |
| 9279 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9280 |
|
| 9281 |
#define NUM_KEYWORDS 2 |
| 9282 |
static struct { |
| 9283 |
PyGC_Head _this_is_not_used; |
| 9284 |
PyObject_VAR_HEAD |
| 9285 |
Py_hash_t ob_hash; |
| 9286 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9287 |
} _kwtuple = { |
| 9288 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9289 |
.ob_hash = -1, |
| 9290 |
.ob_item = { &_Py_ID(path), &_Py_ID(length), }, |
| 9291 |
}; |
| 9292 |
#undef NUM_KEYWORDS |
| 9293 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9294 |
|
| 9295 |
#else // !Py_BUILD_CORE |
| 9296 |
# define KWTUPLE NULL |
| 9297 |
#endif // !Py_BUILD_CORE |
| 9298 |
|
| 9299 |
static const char * const _keywords[] = {"path", "length", NULL}; |
| 9300 |
static _PyArg_Parser _parser = { |
| 9301 |
.keywords = _keywords, |
| 9302 |
.fname = "truncate", |
| 9303 |
.kwtuple = KWTUPLE, |
| 9304 |
}; |
| 9305 |
#undef KWTUPLE |
| 9306 |
PyObject *argsbuf[2]; |
| 9307 |
path_t path = PATH_T_INITIALIZE_P("truncate", "path", 0, 0, 0, PATH_HAVE_FTRUNCATE); |
| 9308 |
Py_off_t length; |
| 9309 |
|
| 9310 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9311 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9312 |
if (!args) { |
| 9313 |
goto exit; |
| 9314 |
} |
| 9315 |
if (!path_converter(args[0], &path)) { |
| 9316 |
goto exit; |
| 9317 |
} |
| 9318 |
if (!Py_off_t_converter(args[1], &length)) { |
| 9319 |
goto exit; |
| 9320 |
} |
| 9321 |
return_value = os_truncate_impl(module, &path, length); |
| 9322 |
|
| 9323 |
exit: |
| 9324 |
/* Cleanup for path */ |
| 9325 |
path_cleanup(&path); |
| 9326 |
|
| 9327 |
return return_value; |
| 9328 |
} |
| 9329 |
|
| 9330 |
#endif /* (defined HAVE_TRUNCATE || defined MS_WINDOWS) */ |
| 9331 |
|
| 9332 |
#if (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG) && !defined(__wasi__)) |
| 9333 |
|
| 9334 |
PyDoc_STRVAR(os_posix_fallocate__doc__, |
| 9335 |
"posix_fallocate($module, fd, offset, length, /)\n" |
| 9336 |
"--\n" |
| 9337 |
"\n" |
| 9338 |
"Ensure a file has allocated at least a particular number of bytes on disk.\n" |
| 9339 |
"\n" |
| 9340 |
"Ensure that the file specified by fd encompasses a range of bytes\n" |
| 9341 |
"starting at offset bytes from the beginning and continuing for length bytes."); |
| 9342 |
|
| 9343 |
#define OS_POSIX_FALLOCATE_METHODDEF \ |
| 9344 |
{"posix_fallocate", _PyCFunction_CAST(os_posix_fallocate), METH_FASTCALL, os_posix_fallocate__doc__}, |
| 9345 |
|
| 9346 |
static PyObject * |
| 9347 |
os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset, |
| 9348 |
Py_off_t length); |
| 9349 |
|
| 9350 |
static PyObject * |
| 9351 |
os_posix_fallocate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 9352 |
{ |
| 9353 |
PyObject *return_value = NULL; |
| 9354 |
int fd; |
| 9355 |
Py_off_t offset; |
| 9356 |
Py_off_t length; |
| 9357 |
|
| 9358 |
if (!_PyArg_CheckPositional("posix_fallocate", nargs, 3, 3)) { |
| 9359 |
goto exit; |
| 9360 |
} |
| 9361 |
fd = PyLong_AsInt(args[0]); |
| 9362 |
if (fd == -1 && PyErr_Occurred()) { |
| 9363 |
goto exit; |
| 9364 |
} |
| 9365 |
if (!Py_off_t_converter(args[1], &offset)) { |
| 9366 |
goto exit; |
| 9367 |
} |
| 9368 |
if (!Py_off_t_converter(args[2], &length)) { |
| 9369 |
goto exit; |
| 9370 |
} |
| 9371 |
return_value = os_posix_fallocate_impl(module, fd, offset, length); |
| 9372 |
|
| 9373 |
exit: |
| 9374 |
return return_value; |
| 9375 |
} |
| 9376 |
|
| 9377 |
#endif /* (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG) && !defined(__wasi__)) */ |
| 9378 |
|
| 9379 |
#if (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) |
| 9380 |
|
| 9381 |
PyDoc_STRVAR(os_posix_fadvise__doc__, |
| 9382 |
"posix_fadvise($module, fd, offset, length, advice, /)\n" |
| 9383 |
"--\n" |
| 9384 |
"\n" |
| 9385 |
"Announce an intention to access data in a specific pattern.\n" |
| 9386 |
"\n" |
| 9387 |
"Announce an intention to access data in a specific pattern, thus allowing\n" |
| 9388 |
"the kernel to make optimizations.\n" |
| 9389 |
"The advice applies to the region of the file specified by fd starting at\n" |
| 9390 |
"offset and continuing for length bytes.\n" |
| 9391 |
"advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,\n" |
| 9392 |
"POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or\n" |
| 9393 |
"POSIX_FADV_DONTNEED."); |
| 9394 |
|
| 9395 |
#define OS_POSIX_FADVISE_METHODDEF \ |
| 9396 |
{"posix_fadvise", _PyCFunction_CAST(os_posix_fadvise), METH_FASTCALL, os_posix_fadvise__doc__}, |
| 9397 |
|
| 9398 |
static PyObject * |
| 9399 |
os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset, |
| 9400 |
Py_off_t length, int advice); |
| 9401 |
|
| 9402 |
static PyObject * |
| 9403 |
os_posix_fadvise(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 9404 |
{ |
| 9405 |
PyObject *return_value = NULL; |
| 9406 |
int fd; |
| 9407 |
Py_off_t offset; |
| 9408 |
Py_off_t length; |
| 9409 |
int advice; |
| 9410 |
|
| 9411 |
if (!_PyArg_CheckPositional("posix_fadvise", nargs, 4, 4)) { |
| 9412 |
goto exit; |
| 9413 |
} |
| 9414 |
fd = PyLong_AsInt(args[0]); |
| 9415 |
if (fd == -1 && PyErr_Occurred()) { |
| 9416 |
goto exit; |
| 9417 |
} |
| 9418 |
if (!Py_off_t_converter(args[1], &offset)) { |
| 9419 |
goto exit; |
| 9420 |
} |
| 9421 |
if (!Py_off_t_converter(args[2], &length)) { |
| 9422 |
goto exit; |
| 9423 |
} |
| 9424 |
advice = PyLong_AsInt(args[3]); |
| 9425 |
if (advice == -1 && PyErr_Occurred()) { |
| 9426 |
goto exit; |
| 9427 |
} |
| 9428 |
return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); |
| 9429 |
|
| 9430 |
exit: |
| 9431 |
return return_value; |
| 9432 |
} |
| 9433 |
|
| 9434 |
#endif /* (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) */ |
| 9435 |
|
| 9436 |
#if defined(MS_WINDOWS) |
| 9437 |
|
| 9438 |
PyDoc_STRVAR(os_putenv__doc__, |
| 9439 |
"putenv($module, name, value, /)\n" |
| 9440 |
"--\n" |
| 9441 |
"\n" |
| 9442 |
"Change or add an environment variable."); |
| 9443 |
|
| 9444 |
#define OS_PUTENV_METHODDEF \ |
| 9445 |
{"putenv", _PyCFunction_CAST(os_putenv), METH_FASTCALL, os_putenv__doc__}, |
| 9446 |
|
| 9447 |
static PyObject * |
| 9448 |
os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); |
| 9449 |
|
| 9450 |
static PyObject * |
| 9451 |
os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 9452 |
{ |
| 9453 |
PyObject *return_value = NULL; |
| 9454 |
PyObject *name; |
| 9455 |
PyObject *value; |
| 9456 |
|
| 9457 |
if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { |
| 9458 |
goto exit; |
| 9459 |
} |
| 9460 |
if (!PyUnicode_Check(args[0])) { |
| 9461 |
_PyArg_BadArgument("putenv", "argument 1", "str", args[0]); |
| 9462 |
goto exit; |
| 9463 |
} |
| 9464 |
name = args[0]; |
| 9465 |
if (!PyUnicode_Check(args[1])) { |
| 9466 |
_PyArg_BadArgument("putenv", "argument 2", "str", args[1]); |
| 9467 |
goto exit; |
| 9468 |
} |
| 9469 |
value = args[1]; |
| 9470 |
return_value = os_putenv_impl(module, name, value); |
| 9471 |
|
| 9472 |
exit: |
| 9473 |
return return_value; |
| 9474 |
} |
| 9475 |
|
| 9476 |
#endif /* defined(MS_WINDOWS) */ |
| 9477 |
|
| 9478 |
#if !defined(MS_WINDOWS) |
| 9479 |
|
| 9480 |
PyDoc_STRVAR(os_putenv__doc__, |
| 9481 |
"putenv($module, name, value, /)\n" |
| 9482 |
"--\n" |
| 9483 |
"\n" |
| 9484 |
"Change or add an environment variable."); |
| 9485 |
|
| 9486 |
#define OS_PUTENV_METHODDEF \ |
| 9487 |
{"putenv", _PyCFunction_CAST(os_putenv), METH_FASTCALL, os_putenv__doc__}, |
| 9488 |
|
| 9489 |
static PyObject * |
| 9490 |
os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); |
| 9491 |
|
| 9492 |
static PyObject * |
| 9493 |
os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 9494 |
{ |
| 9495 |
PyObject *return_value = NULL; |
| 9496 |
PyObject *name = NULL; |
| 9497 |
PyObject *value = NULL; |
| 9498 |
|
| 9499 |
if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { |
| 9500 |
goto exit; |
| 9501 |
} |
| 9502 |
if (!PyUnicode_FSConverter(args[0], &name)) { |
| 9503 |
goto exit; |
| 9504 |
} |
| 9505 |
if (!PyUnicode_FSConverter(args[1], &value)) { |
| 9506 |
goto exit; |
| 9507 |
} |
| 9508 |
return_value = os_putenv_impl(module, name, value); |
| 9509 |
|
| 9510 |
exit: |
| 9511 |
/* Cleanup for name */ |
| 9512 |
Py_XDECREF(name); |
| 9513 |
/* Cleanup for value */ |
| 9514 |
Py_XDECREF(value); |
| 9515 |
|
| 9516 |
return return_value; |
| 9517 |
} |
| 9518 |
|
| 9519 |
#endif /* !defined(MS_WINDOWS) */ |
| 9520 |
|
| 9521 |
#if defined(MS_WINDOWS) |
| 9522 |
|
| 9523 |
PyDoc_STRVAR(os_unsetenv__doc__, |
| 9524 |
"unsetenv($module, name, /)\n" |
| 9525 |
"--\n" |
| 9526 |
"\n" |
| 9527 |
"Delete an environment variable."); |
| 9528 |
|
| 9529 |
#define OS_UNSETENV_METHODDEF \ |
| 9530 |
{"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__}, |
| 9531 |
|
| 9532 |
static PyObject * |
| 9533 |
os_unsetenv_impl(PyObject *module, PyObject *name); |
| 9534 |
|
| 9535 |
static PyObject * |
| 9536 |
os_unsetenv(PyObject *module, PyObject *arg) |
| 9537 |
{ |
| 9538 |
PyObject *return_value = NULL; |
| 9539 |
PyObject *name; |
| 9540 |
|
| 9541 |
if (!PyUnicode_Check(arg)) { |
| 9542 |
_PyArg_BadArgument("unsetenv", "argument", "str", arg); |
| 9543 |
goto exit; |
| 9544 |
} |
| 9545 |
name = arg; |
| 9546 |
return_value = os_unsetenv_impl(module, name); |
| 9547 |
|
| 9548 |
exit: |
| 9549 |
return return_value; |
| 9550 |
} |
| 9551 |
|
| 9552 |
#endif /* defined(MS_WINDOWS) */ |
| 9553 |
|
| 9554 |
#if !defined(MS_WINDOWS) |
| 9555 |
|
| 9556 |
PyDoc_STRVAR(os_unsetenv__doc__, |
| 9557 |
"unsetenv($module, name, /)\n" |
| 9558 |
"--\n" |
| 9559 |
"\n" |
| 9560 |
"Delete an environment variable."); |
| 9561 |
|
| 9562 |
#define OS_UNSETENV_METHODDEF \ |
| 9563 |
{"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__}, |
| 9564 |
|
| 9565 |
static PyObject * |
| 9566 |
os_unsetenv_impl(PyObject *module, PyObject *name); |
| 9567 |
|
| 9568 |
static PyObject * |
| 9569 |
os_unsetenv(PyObject *module, PyObject *arg) |
| 9570 |
{ |
| 9571 |
PyObject *return_value = NULL; |
| 9572 |
PyObject *name = NULL; |
| 9573 |
|
| 9574 |
if (!PyUnicode_FSConverter(arg, &name)) { |
| 9575 |
goto exit; |
| 9576 |
} |
| 9577 |
return_value = os_unsetenv_impl(module, name); |
| 9578 |
|
| 9579 |
exit: |
| 9580 |
/* Cleanup for name */ |
| 9581 |
Py_XDECREF(name); |
| 9582 |
|
| 9583 |
return return_value; |
| 9584 |
} |
| 9585 |
|
| 9586 |
#endif /* !defined(MS_WINDOWS) */ |
| 9587 |
|
| 9588 |
PyDoc_STRVAR(os_strerror__doc__, |
| 9589 |
"strerror($module, code, /)\n" |
| 9590 |
"--\n" |
| 9591 |
"\n" |
| 9592 |
"Translate an error code to a message string."); |
| 9593 |
|
| 9594 |
#define OS_STRERROR_METHODDEF \ |
| 9595 |
{"strerror", (PyCFunction)os_strerror, METH_O, os_strerror__doc__}, |
| 9596 |
|
| 9597 |
static PyObject * |
| 9598 |
os_strerror_impl(PyObject *module, int code); |
| 9599 |
|
| 9600 |
static PyObject * |
| 9601 |
os_strerror(PyObject *module, PyObject *arg) |
| 9602 |
{ |
| 9603 |
PyObject *return_value = NULL; |
| 9604 |
int code; |
| 9605 |
|
| 9606 |
code = PyLong_AsInt(arg); |
| 9607 |
if (code == -1 && PyErr_Occurred()) { |
| 9608 |
goto exit; |
| 9609 |
} |
| 9610 |
return_value = os_strerror_impl(module, code); |
| 9611 |
|
| 9612 |
exit: |
| 9613 |
return return_value; |
| 9614 |
} |
| 9615 |
|
| 9616 |
#if defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) |
| 9617 |
|
| 9618 |
PyDoc_STRVAR(os_WCOREDUMP__doc__, |
| 9619 |
"WCOREDUMP($module, status, /)\n" |
| 9620 |
"--\n" |
| 9621 |
"\n" |
| 9622 |
"Return True if the process returning status was dumped to a core file."); |
| 9623 |
|
| 9624 |
#define OS_WCOREDUMP_METHODDEF \ |
| 9625 |
{"WCOREDUMP", (PyCFunction)os_WCOREDUMP, METH_O, os_WCOREDUMP__doc__}, |
| 9626 |
|
| 9627 |
static int |
| 9628 |
os_WCOREDUMP_impl(PyObject *module, int status); |
| 9629 |
|
| 9630 |
static PyObject * |
| 9631 |
os_WCOREDUMP(PyObject *module, PyObject *arg) |
| 9632 |
{ |
| 9633 |
PyObject *return_value = NULL; |
| 9634 |
int status; |
| 9635 |
int _return_value; |
| 9636 |
|
| 9637 |
status = PyLong_AsInt(arg); |
| 9638 |
if (status == -1 && PyErr_Occurred()) { |
| 9639 |
goto exit; |
| 9640 |
} |
| 9641 |
_return_value = os_WCOREDUMP_impl(module, status); |
| 9642 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 9643 |
goto exit; |
| 9644 |
} |
| 9645 |
return_value = PyBool_FromLong((long)_return_value); |
| 9646 |
|
| 9647 |
exit: |
| 9648 |
return return_value; |
| 9649 |
} |
| 9650 |
|
| 9651 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) */ |
| 9652 |
|
| 9653 |
#if defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) |
| 9654 |
|
| 9655 |
PyDoc_STRVAR(os_WIFCONTINUED__doc__, |
| 9656 |
"WIFCONTINUED($module, /, status)\n" |
| 9657 |
"--\n" |
| 9658 |
"\n" |
| 9659 |
"Return True if a particular process was continued from a job control stop.\n" |
| 9660 |
"\n" |
| 9661 |
"Return True if the process returning status was continued from a\n" |
| 9662 |
"job control stop."); |
| 9663 |
|
| 9664 |
#define OS_WIFCONTINUED_METHODDEF \ |
| 9665 |
{"WIFCONTINUED", _PyCFunction_CAST(os_WIFCONTINUED), METH_FASTCALL|METH_KEYWORDS, os_WIFCONTINUED__doc__}, |
| 9666 |
|
| 9667 |
static int |
| 9668 |
os_WIFCONTINUED_impl(PyObject *module, int status); |
| 9669 |
|
| 9670 |
static PyObject * |
| 9671 |
os_WIFCONTINUED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9672 |
{ |
| 9673 |
PyObject *return_value = NULL; |
| 9674 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9675 |
|
| 9676 |
#define NUM_KEYWORDS 1 |
| 9677 |
static struct { |
| 9678 |
PyGC_Head _this_is_not_used; |
| 9679 |
PyObject_VAR_HEAD |
| 9680 |
Py_hash_t ob_hash; |
| 9681 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9682 |
} _kwtuple = { |
| 9683 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9684 |
.ob_hash = -1, |
| 9685 |
.ob_item = { &_Py_ID(status), }, |
| 9686 |
}; |
| 9687 |
#undef NUM_KEYWORDS |
| 9688 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9689 |
|
| 9690 |
#else // !Py_BUILD_CORE |
| 9691 |
# define KWTUPLE NULL |
| 9692 |
#endif // !Py_BUILD_CORE |
| 9693 |
|
| 9694 |
static const char * const _keywords[] = {"status", NULL}; |
| 9695 |
static _PyArg_Parser _parser = { |
| 9696 |
.keywords = _keywords, |
| 9697 |
.fname = "WIFCONTINUED", |
| 9698 |
.kwtuple = KWTUPLE, |
| 9699 |
}; |
| 9700 |
#undef KWTUPLE |
| 9701 |
PyObject *argsbuf[1]; |
| 9702 |
int status; |
| 9703 |
int _return_value; |
| 9704 |
|
| 9705 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9706 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9707 |
if (!args) { |
| 9708 |
goto exit; |
| 9709 |
} |
| 9710 |
status = PyLong_AsInt(args[0]); |
| 9711 |
if (status == -1 && PyErr_Occurred()) { |
| 9712 |
goto exit; |
| 9713 |
} |
| 9714 |
_return_value = os_WIFCONTINUED_impl(module, status); |
| 9715 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 9716 |
goto exit; |
| 9717 |
} |
| 9718 |
return_value = PyBool_FromLong((long)_return_value); |
| 9719 |
|
| 9720 |
exit: |
| 9721 |
return return_value; |
| 9722 |
} |
| 9723 |
|
| 9724 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) */ |
| 9725 |
|
| 9726 |
#if defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) |
| 9727 |
|
| 9728 |
PyDoc_STRVAR(os_WIFSTOPPED__doc__, |
| 9729 |
"WIFSTOPPED($module, /, status)\n" |
| 9730 |
"--\n" |
| 9731 |
"\n" |
| 9732 |
"Return True if the process returning status was stopped."); |
| 9733 |
|
| 9734 |
#define OS_WIFSTOPPED_METHODDEF \ |
| 9735 |
{"WIFSTOPPED", _PyCFunction_CAST(os_WIFSTOPPED), METH_FASTCALL|METH_KEYWORDS, os_WIFSTOPPED__doc__}, |
| 9736 |
|
| 9737 |
static int |
| 9738 |
os_WIFSTOPPED_impl(PyObject *module, int status); |
| 9739 |
|
| 9740 |
static PyObject * |
| 9741 |
os_WIFSTOPPED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9742 |
{ |
| 9743 |
PyObject *return_value = NULL; |
| 9744 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9745 |
|
| 9746 |
#define NUM_KEYWORDS 1 |
| 9747 |
static struct { |
| 9748 |
PyGC_Head _this_is_not_used; |
| 9749 |
PyObject_VAR_HEAD |
| 9750 |
Py_hash_t ob_hash; |
| 9751 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9752 |
} _kwtuple = { |
| 9753 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9754 |
.ob_hash = -1, |
| 9755 |
.ob_item = { &_Py_ID(status), }, |
| 9756 |
}; |
| 9757 |
#undef NUM_KEYWORDS |
| 9758 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9759 |
|
| 9760 |
#else // !Py_BUILD_CORE |
| 9761 |
# define KWTUPLE NULL |
| 9762 |
#endif // !Py_BUILD_CORE |
| 9763 |
|
| 9764 |
static const char * const _keywords[] = {"status", NULL}; |
| 9765 |
static _PyArg_Parser _parser = { |
| 9766 |
.keywords = _keywords, |
| 9767 |
.fname = "WIFSTOPPED", |
| 9768 |
.kwtuple = KWTUPLE, |
| 9769 |
}; |
| 9770 |
#undef KWTUPLE |
| 9771 |
PyObject *argsbuf[1]; |
| 9772 |
int status; |
| 9773 |
int _return_value; |
| 9774 |
|
| 9775 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9776 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9777 |
if (!args) { |
| 9778 |
goto exit; |
| 9779 |
} |
| 9780 |
status = PyLong_AsInt(args[0]); |
| 9781 |
if (status == -1 && PyErr_Occurred()) { |
| 9782 |
goto exit; |
| 9783 |
} |
| 9784 |
_return_value = os_WIFSTOPPED_impl(module, status); |
| 9785 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 9786 |
goto exit; |
| 9787 |
} |
| 9788 |
return_value = PyBool_FromLong((long)_return_value); |
| 9789 |
|
| 9790 |
exit: |
| 9791 |
return return_value; |
| 9792 |
} |
| 9793 |
|
| 9794 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) */ |
| 9795 |
|
| 9796 |
#if defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) |
| 9797 |
|
| 9798 |
PyDoc_STRVAR(os_WIFSIGNALED__doc__, |
| 9799 |
"WIFSIGNALED($module, /, status)\n" |
| 9800 |
"--\n" |
| 9801 |
"\n" |
| 9802 |
"Return True if the process returning status was terminated by a signal."); |
| 9803 |
|
| 9804 |
#define OS_WIFSIGNALED_METHODDEF \ |
| 9805 |
{"WIFSIGNALED", _PyCFunction_CAST(os_WIFSIGNALED), METH_FASTCALL|METH_KEYWORDS, os_WIFSIGNALED__doc__}, |
| 9806 |
|
| 9807 |
static int |
| 9808 |
os_WIFSIGNALED_impl(PyObject *module, int status); |
| 9809 |
|
| 9810 |
static PyObject * |
| 9811 |
os_WIFSIGNALED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9812 |
{ |
| 9813 |
PyObject *return_value = NULL; |
| 9814 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9815 |
|
| 9816 |
#define NUM_KEYWORDS 1 |
| 9817 |
static struct { |
| 9818 |
PyGC_Head _this_is_not_used; |
| 9819 |
PyObject_VAR_HEAD |
| 9820 |
Py_hash_t ob_hash; |
| 9821 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9822 |
} _kwtuple = { |
| 9823 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9824 |
.ob_hash = -1, |
| 9825 |
.ob_item = { &_Py_ID(status), }, |
| 9826 |
}; |
| 9827 |
#undef NUM_KEYWORDS |
| 9828 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9829 |
|
| 9830 |
#else // !Py_BUILD_CORE |
| 9831 |
# define KWTUPLE NULL |
| 9832 |
#endif // !Py_BUILD_CORE |
| 9833 |
|
| 9834 |
static const char * const _keywords[] = {"status", NULL}; |
| 9835 |
static _PyArg_Parser _parser = { |
| 9836 |
.keywords = _keywords, |
| 9837 |
.fname = "WIFSIGNALED", |
| 9838 |
.kwtuple = KWTUPLE, |
| 9839 |
}; |
| 9840 |
#undef KWTUPLE |
| 9841 |
PyObject *argsbuf[1]; |
| 9842 |
int status; |
| 9843 |
int _return_value; |
| 9844 |
|
| 9845 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9846 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9847 |
if (!args) { |
| 9848 |
goto exit; |
| 9849 |
} |
| 9850 |
status = PyLong_AsInt(args[0]); |
| 9851 |
if (status == -1 && PyErr_Occurred()) { |
| 9852 |
goto exit; |
| 9853 |
} |
| 9854 |
_return_value = os_WIFSIGNALED_impl(module, status); |
| 9855 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 9856 |
goto exit; |
| 9857 |
} |
| 9858 |
return_value = PyBool_FromLong((long)_return_value); |
| 9859 |
|
| 9860 |
exit: |
| 9861 |
return return_value; |
| 9862 |
} |
| 9863 |
|
| 9864 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) */ |
| 9865 |
|
| 9866 |
#if defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) |
| 9867 |
|
| 9868 |
PyDoc_STRVAR(os_WIFEXITED__doc__, |
| 9869 |
"WIFEXITED($module, /, status)\n" |
| 9870 |
"--\n" |
| 9871 |
"\n" |
| 9872 |
"Return True if the process returning status exited via the exit() system call."); |
| 9873 |
|
| 9874 |
#define OS_WIFEXITED_METHODDEF \ |
| 9875 |
{"WIFEXITED", _PyCFunction_CAST(os_WIFEXITED), METH_FASTCALL|METH_KEYWORDS, os_WIFEXITED__doc__}, |
| 9876 |
|
| 9877 |
static int |
| 9878 |
os_WIFEXITED_impl(PyObject *module, int status); |
| 9879 |
|
| 9880 |
static PyObject * |
| 9881 |
os_WIFEXITED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9882 |
{ |
| 9883 |
PyObject *return_value = NULL; |
| 9884 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9885 |
|
| 9886 |
#define NUM_KEYWORDS 1 |
| 9887 |
static struct { |
| 9888 |
PyGC_Head _this_is_not_used; |
| 9889 |
PyObject_VAR_HEAD |
| 9890 |
Py_hash_t ob_hash; |
| 9891 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9892 |
} _kwtuple = { |
| 9893 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9894 |
.ob_hash = -1, |
| 9895 |
.ob_item = { &_Py_ID(status), }, |
| 9896 |
}; |
| 9897 |
#undef NUM_KEYWORDS |
| 9898 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9899 |
|
| 9900 |
#else // !Py_BUILD_CORE |
| 9901 |
# define KWTUPLE NULL |
| 9902 |
#endif // !Py_BUILD_CORE |
| 9903 |
|
| 9904 |
static const char * const _keywords[] = {"status", NULL}; |
| 9905 |
static _PyArg_Parser _parser = { |
| 9906 |
.keywords = _keywords, |
| 9907 |
.fname = "WIFEXITED", |
| 9908 |
.kwtuple = KWTUPLE, |
| 9909 |
}; |
| 9910 |
#undef KWTUPLE |
| 9911 |
PyObject *argsbuf[1]; |
| 9912 |
int status; |
| 9913 |
int _return_value; |
| 9914 |
|
| 9915 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9916 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9917 |
if (!args) { |
| 9918 |
goto exit; |
| 9919 |
} |
| 9920 |
status = PyLong_AsInt(args[0]); |
| 9921 |
if (status == -1 && PyErr_Occurred()) { |
| 9922 |
goto exit; |
| 9923 |
} |
| 9924 |
_return_value = os_WIFEXITED_impl(module, status); |
| 9925 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 9926 |
goto exit; |
| 9927 |
} |
| 9928 |
return_value = PyBool_FromLong((long)_return_value); |
| 9929 |
|
| 9930 |
exit: |
| 9931 |
return return_value; |
| 9932 |
} |
| 9933 |
|
| 9934 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) */ |
| 9935 |
|
| 9936 |
#if defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) |
| 9937 |
|
| 9938 |
PyDoc_STRVAR(os_WEXITSTATUS__doc__, |
| 9939 |
"WEXITSTATUS($module, /, status)\n" |
| 9940 |
"--\n" |
| 9941 |
"\n" |
| 9942 |
"Return the process return code from status."); |
| 9943 |
|
| 9944 |
#define OS_WEXITSTATUS_METHODDEF \ |
| 9945 |
{"WEXITSTATUS", _PyCFunction_CAST(os_WEXITSTATUS), METH_FASTCALL|METH_KEYWORDS, os_WEXITSTATUS__doc__}, |
| 9946 |
|
| 9947 |
static int |
| 9948 |
os_WEXITSTATUS_impl(PyObject *module, int status); |
| 9949 |
|
| 9950 |
static PyObject * |
| 9951 |
os_WEXITSTATUS(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 9952 |
{ |
| 9953 |
PyObject *return_value = NULL; |
| 9954 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 9955 |
|
| 9956 |
#define NUM_KEYWORDS 1 |
| 9957 |
static struct { |
| 9958 |
PyGC_Head _this_is_not_used; |
| 9959 |
PyObject_VAR_HEAD |
| 9960 |
Py_hash_t ob_hash; |
| 9961 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 9962 |
} _kwtuple = { |
| 9963 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 9964 |
.ob_hash = -1, |
| 9965 |
.ob_item = { &_Py_ID(status), }, |
| 9966 |
}; |
| 9967 |
#undef NUM_KEYWORDS |
| 9968 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 9969 |
|
| 9970 |
#else // !Py_BUILD_CORE |
| 9971 |
# define KWTUPLE NULL |
| 9972 |
#endif // !Py_BUILD_CORE |
| 9973 |
|
| 9974 |
static const char * const _keywords[] = {"status", NULL}; |
| 9975 |
static _PyArg_Parser _parser = { |
| 9976 |
.keywords = _keywords, |
| 9977 |
.fname = "WEXITSTATUS", |
| 9978 |
.kwtuple = KWTUPLE, |
| 9979 |
}; |
| 9980 |
#undef KWTUPLE |
| 9981 |
PyObject *argsbuf[1]; |
| 9982 |
int status; |
| 9983 |
int _return_value; |
| 9984 |
|
| 9985 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 9986 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 9987 |
if (!args) { |
| 9988 |
goto exit; |
| 9989 |
} |
| 9990 |
status = PyLong_AsInt(args[0]); |
| 9991 |
if (status == -1 && PyErr_Occurred()) { |
| 9992 |
goto exit; |
| 9993 |
} |
| 9994 |
_return_value = os_WEXITSTATUS_impl(module, status); |
| 9995 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 9996 |
goto exit; |
| 9997 |
} |
| 9998 |
return_value = PyLong_FromLong((long)_return_value); |
| 9999 |
|
| 10000 |
exit: |
| 10001 |
return return_value; |
| 10002 |
} |
| 10003 |
|
| 10004 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) */ |
| 10005 |
|
| 10006 |
#if defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) |
| 10007 |
|
| 10008 |
PyDoc_STRVAR(os_WTERMSIG__doc__, |
| 10009 |
"WTERMSIG($module, /, status)\n" |
| 10010 |
"--\n" |
| 10011 |
"\n" |
| 10012 |
"Return the signal that terminated the process that provided the status value."); |
| 10013 |
|
| 10014 |
#define OS_WTERMSIG_METHODDEF \ |
| 10015 |
{"WTERMSIG", _PyCFunction_CAST(os_WTERMSIG), METH_FASTCALL|METH_KEYWORDS, os_WTERMSIG__doc__}, |
| 10016 |
|
| 10017 |
static int |
| 10018 |
os_WTERMSIG_impl(PyObject *module, int status); |
| 10019 |
|
| 10020 |
static PyObject * |
| 10021 |
os_WTERMSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10022 |
{ |
| 10023 |
PyObject *return_value = NULL; |
| 10024 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10025 |
|
| 10026 |
#define NUM_KEYWORDS 1 |
| 10027 |
static struct { |
| 10028 |
PyGC_Head _this_is_not_used; |
| 10029 |
PyObject_VAR_HEAD |
| 10030 |
Py_hash_t ob_hash; |
| 10031 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10032 |
} _kwtuple = { |
| 10033 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10034 |
.ob_hash = -1, |
| 10035 |
.ob_item = { &_Py_ID(status), }, |
| 10036 |
}; |
| 10037 |
#undef NUM_KEYWORDS |
| 10038 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10039 |
|
| 10040 |
#else // !Py_BUILD_CORE |
| 10041 |
# define KWTUPLE NULL |
| 10042 |
#endif // !Py_BUILD_CORE |
| 10043 |
|
| 10044 |
static const char * const _keywords[] = {"status", NULL}; |
| 10045 |
static _PyArg_Parser _parser = { |
| 10046 |
.keywords = _keywords, |
| 10047 |
.fname = "WTERMSIG", |
| 10048 |
.kwtuple = KWTUPLE, |
| 10049 |
}; |
| 10050 |
#undef KWTUPLE |
| 10051 |
PyObject *argsbuf[1]; |
| 10052 |
int status; |
| 10053 |
int _return_value; |
| 10054 |
|
| 10055 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10056 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10057 |
if (!args) { |
| 10058 |
goto exit; |
| 10059 |
} |
| 10060 |
status = PyLong_AsInt(args[0]); |
| 10061 |
if (status == -1 && PyErr_Occurred()) { |
| 10062 |
goto exit; |
| 10063 |
} |
| 10064 |
_return_value = os_WTERMSIG_impl(module, status); |
| 10065 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 10066 |
goto exit; |
| 10067 |
} |
| 10068 |
return_value = PyLong_FromLong((long)_return_value); |
| 10069 |
|
| 10070 |
exit: |
| 10071 |
return return_value; |
| 10072 |
} |
| 10073 |
|
| 10074 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) */ |
| 10075 |
|
| 10076 |
#if defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) |
| 10077 |
|
| 10078 |
PyDoc_STRVAR(os_WSTOPSIG__doc__, |
| 10079 |
"WSTOPSIG($module, /, status)\n" |
| 10080 |
"--\n" |
| 10081 |
"\n" |
| 10082 |
"Return the signal that stopped the process that provided the status value."); |
| 10083 |
|
| 10084 |
#define OS_WSTOPSIG_METHODDEF \ |
| 10085 |
{"WSTOPSIG", _PyCFunction_CAST(os_WSTOPSIG), METH_FASTCALL|METH_KEYWORDS, os_WSTOPSIG__doc__}, |
| 10086 |
|
| 10087 |
static int |
| 10088 |
os_WSTOPSIG_impl(PyObject *module, int status); |
| 10089 |
|
| 10090 |
static PyObject * |
| 10091 |
os_WSTOPSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10092 |
{ |
| 10093 |
PyObject *return_value = NULL; |
| 10094 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10095 |
|
| 10096 |
#define NUM_KEYWORDS 1 |
| 10097 |
static struct { |
| 10098 |
PyGC_Head _this_is_not_used; |
| 10099 |
PyObject_VAR_HEAD |
| 10100 |
Py_hash_t ob_hash; |
| 10101 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10102 |
} _kwtuple = { |
| 10103 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10104 |
.ob_hash = -1, |
| 10105 |
.ob_item = { &_Py_ID(status), }, |
| 10106 |
}; |
| 10107 |
#undef NUM_KEYWORDS |
| 10108 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10109 |
|
| 10110 |
#else // !Py_BUILD_CORE |
| 10111 |
# define KWTUPLE NULL |
| 10112 |
#endif // !Py_BUILD_CORE |
| 10113 |
|
| 10114 |
static const char * const _keywords[] = {"status", NULL}; |
| 10115 |
static _PyArg_Parser _parser = { |
| 10116 |
.keywords = _keywords, |
| 10117 |
.fname = "WSTOPSIG", |
| 10118 |
.kwtuple = KWTUPLE, |
| 10119 |
}; |
| 10120 |
#undef KWTUPLE |
| 10121 |
PyObject *argsbuf[1]; |
| 10122 |
int status; |
| 10123 |
int _return_value; |
| 10124 |
|
| 10125 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10126 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10127 |
if (!args) { |
| 10128 |
goto exit; |
| 10129 |
} |
| 10130 |
status = PyLong_AsInt(args[0]); |
| 10131 |
if (status == -1 && PyErr_Occurred()) { |
| 10132 |
goto exit; |
| 10133 |
} |
| 10134 |
_return_value = os_WSTOPSIG_impl(module, status); |
| 10135 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 10136 |
goto exit; |
| 10137 |
} |
| 10138 |
return_value = PyLong_FromLong((long)_return_value); |
| 10139 |
|
| 10140 |
exit: |
| 10141 |
return return_value; |
| 10142 |
} |
| 10143 |
|
| 10144 |
#endif /* defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) */ |
| 10145 |
|
| 10146 |
#if (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) |
| 10147 |
|
| 10148 |
PyDoc_STRVAR(os_fstatvfs__doc__, |
| 10149 |
"fstatvfs($module, fd, /)\n" |
| 10150 |
"--\n" |
| 10151 |
"\n" |
| 10152 |
"Perform an fstatvfs system call on the given fd.\n" |
| 10153 |
"\n" |
| 10154 |
"Equivalent to statvfs(fd)."); |
| 10155 |
|
| 10156 |
#define OS_FSTATVFS_METHODDEF \ |
| 10157 |
{"fstatvfs", (PyCFunction)os_fstatvfs, METH_O, os_fstatvfs__doc__}, |
| 10158 |
|
| 10159 |
static PyObject * |
| 10160 |
os_fstatvfs_impl(PyObject *module, int fd); |
| 10161 |
|
| 10162 |
static PyObject * |
| 10163 |
os_fstatvfs(PyObject *module, PyObject *arg) |
| 10164 |
{ |
| 10165 |
PyObject *return_value = NULL; |
| 10166 |
int fd; |
| 10167 |
|
| 10168 |
fd = PyLong_AsInt(arg); |
| 10169 |
if (fd == -1 && PyErr_Occurred()) { |
| 10170 |
goto exit; |
| 10171 |
} |
| 10172 |
return_value = os_fstatvfs_impl(module, fd); |
| 10173 |
|
| 10174 |
exit: |
| 10175 |
return return_value; |
| 10176 |
} |
| 10177 |
|
| 10178 |
#endif /* (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) */ |
| 10179 |
|
| 10180 |
#if (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) |
| 10181 |
|
| 10182 |
PyDoc_STRVAR(os_statvfs__doc__, |
| 10183 |
"statvfs($module, /, path)\n" |
| 10184 |
"--\n" |
| 10185 |
"\n" |
| 10186 |
"Perform a statvfs system call on the given path.\n" |
| 10187 |
"\n" |
| 10188 |
"path may always be specified as a string.\n" |
| 10189 |
"On some platforms, path may also be specified as an open file descriptor.\n" |
| 10190 |
" If this functionality is unavailable, using it raises an exception."); |
| 10191 |
|
| 10192 |
#define OS_STATVFS_METHODDEF \ |
| 10193 |
{"statvfs", _PyCFunction_CAST(os_statvfs), METH_FASTCALL|METH_KEYWORDS, os_statvfs__doc__}, |
| 10194 |
|
| 10195 |
static PyObject * |
| 10196 |
os_statvfs_impl(PyObject *module, path_t *path); |
| 10197 |
|
| 10198 |
static PyObject * |
| 10199 |
os_statvfs(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10200 |
{ |
| 10201 |
PyObject *return_value = NULL; |
| 10202 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10203 |
|
| 10204 |
#define NUM_KEYWORDS 1 |
| 10205 |
static struct { |
| 10206 |
PyGC_Head _this_is_not_used; |
| 10207 |
PyObject_VAR_HEAD |
| 10208 |
Py_hash_t ob_hash; |
| 10209 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10210 |
} _kwtuple = { |
| 10211 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10212 |
.ob_hash = -1, |
| 10213 |
.ob_item = { &_Py_ID(path), }, |
| 10214 |
}; |
| 10215 |
#undef NUM_KEYWORDS |
| 10216 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10217 |
|
| 10218 |
#else // !Py_BUILD_CORE |
| 10219 |
# define KWTUPLE NULL |
| 10220 |
#endif // !Py_BUILD_CORE |
| 10221 |
|
| 10222 |
static const char * const _keywords[] = {"path", NULL}; |
| 10223 |
static _PyArg_Parser _parser = { |
| 10224 |
.keywords = _keywords, |
| 10225 |
.fname = "statvfs", |
| 10226 |
.kwtuple = KWTUPLE, |
| 10227 |
}; |
| 10228 |
#undef KWTUPLE |
| 10229 |
PyObject *argsbuf[1]; |
| 10230 |
path_t path = PATH_T_INITIALIZE_P("statvfs", "path", 0, 0, 0, PATH_HAVE_FSTATVFS); |
| 10231 |
|
| 10232 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10233 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10234 |
if (!args) { |
| 10235 |
goto exit; |
| 10236 |
} |
| 10237 |
if (!path_converter(args[0], &path)) { |
| 10238 |
goto exit; |
| 10239 |
} |
| 10240 |
return_value = os_statvfs_impl(module, &path); |
| 10241 |
|
| 10242 |
exit: |
| 10243 |
/* Cleanup for path */ |
| 10244 |
path_cleanup(&path); |
| 10245 |
|
| 10246 |
return return_value; |
| 10247 |
} |
| 10248 |
|
| 10249 |
#endif /* (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) */ |
| 10250 |
|
| 10251 |
#if defined(MS_WINDOWS) |
| 10252 |
|
| 10253 |
PyDoc_STRVAR(os__getdiskusage__doc__, |
| 10254 |
"_getdiskusage($module, /, path)\n" |
| 10255 |
"--\n" |
| 10256 |
"\n" |
| 10257 |
"Return disk usage statistics about the given path as a (total, free) tuple."); |
| 10258 |
|
| 10259 |
#define OS__GETDISKUSAGE_METHODDEF \ |
| 10260 |
{"_getdiskusage", _PyCFunction_CAST(os__getdiskusage), METH_FASTCALL|METH_KEYWORDS, os__getdiskusage__doc__}, |
| 10261 |
|
| 10262 |
static PyObject * |
| 10263 |
os__getdiskusage_impl(PyObject *module, path_t *path); |
| 10264 |
|
| 10265 |
static PyObject * |
| 10266 |
os__getdiskusage(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10267 |
{ |
| 10268 |
PyObject *return_value = NULL; |
| 10269 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10270 |
|
| 10271 |
#define NUM_KEYWORDS 1 |
| 10272 |
static struct { |
| 10273 |
PyGC_Head _this_is_not_used; |
| 10274 |
PyObject_VAR_HEAD |
| 10275 |
Py_hash_t ob_hash; |
| 10276 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10277 |
} _kwtuple = { |
| 10278 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10279 |
.ob_hash = -1, |
| 10280 |
.ob_item = { &_Py_ID(path), }, |
| 10281 |
}; |
| 10282 |
#undef NUM_KEYWORDS |
| 10283 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10284 |
|
| 10285 |
#else // !Py_BUILD_CORE |
| 10286 |
# define KWTUPLE NULL |
| 10287 |
#endif // !Py_BUILD_CORE |
| 10288 |
|
| 10289 |
static const char * const _keywords[] = {"path", NULL}; |
| 10290 |
static _PyArg_Parser _parser = { |
| 10291 |
.keywords = _keywords, |
| 10292 |
.fname = "_getdiskusage", |
| 10293 |
.kwtuple = KWTUPLE, |
| 10294 |
}; |
| 10295 |
#undef KWTUPLE |
| 10296 |
PyObject *argsbuf[1]; |
| 10297 |
path_t path = PATH_T_INITIALIZE_P("_getdiskusage", "path", 0, 0, 0, 0); |
| 10298 |
|
| 10299 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10300 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10301 |
if (!args) { |
| 10302 |
goto exit; |
| 10303 |
} |
| 10304 |
if (!path_converter(args[0], &path)) { |
| 10305 |
goto exit; |
| 10306 |
} |
| 10307 |
return_value = os__getdiskusage_impl(module, &path); |
| 10308 |
|
| 10309 |
exit: |
| 10310 |
/* Cleanup for path */ |
| 10311 |
path_cleanup(&path); |
| 10312 |
|
| 10313 |
return return_value; |
| 10314 |
} |
| 10315 |
|
| 10316 |
#endif /* defined(MS_WINDOWS) */ |
| 10317 |
|
| 10318 |
#if defined(HAVE_FPATHCONF) |
| 10319 |
|
| 10320 |
PyDoc_STRVAR(os_fpathconf__doc__, |
| 10321 |
"fpathconf($module, fd, name, /)\n" |
| 10322 |
"--\n" |
| 10323 |
"\n" |
| 10324 |
"Return the configuration limit name for the file descriptor fd.\n" |
| 10325 |
"\n" |
| 10326 |
"If there is no limit, return -1."); |
| 10327 |
|
| 10328 |
#define OS_FPATHCONF_METHODDEF \ |
| 10329 |
{"fpathconf", _PyCFunction_CAST(os_fpathconf), METH_FASTCALL, os_fpathconf__doc__}, |
| 10330 |
|
| 10331 |
static long |
| 10332 |
os_fpathconf_impl(PyObject *module, int fd, int name); |
| 10333 |
|
| 10334 |
static PyObject * |
| 10335 |
os_fpathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 10336 |
{ |
| 10337 |
PyObject *return_value = NULL; |
| 10338 |
int fd; |
| 10339 |
int name; |
| 10340 |
long _return_value; |
| 10341 |
|
| 10342 |
if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) { |
| 10343 |
goto exit; |
| 10344 |
} |
| 10345 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 10346 |
if (fd < 0) { |
| 10347 |
goto exit; |
| 10348 |
} |
| 10349 |
if (!conv_confname(module, args[1], &name, "pathconf_names")) { |
| 10350 |
goto exit; |
| 10351 |
} |
| 10352 |
_return_value = os_fpathconf_impl(module, fd, name); |
| 10353 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 10354 |
goto exit; |
| 10355 |
} |
| 10356 |
return_value = PyLong_FromLong(_return_value); |
| 10357 |
|
| 10358 |
exit: |
| 10359 |
return return_value; |
| 10360 |
} |
| 10361 |
|
| 10362 |
#endif /* defined(HAVE_FPATHCONF) */ |
| 10363 |
|
| 10364 |
#if defined(HAVE_PATHCONF) |
| 10365 |
|
| 10366 |
PyDoc_STRVAR(os_pathconf__doc__, |
| 10367 |
"pathconf($module, /, path, name)\n" |
| 10368 |
"--\n" |
| 10369 |
"\n" |
| 10370 |
"Return the configuration limit name for the file or directory path.\n" |
| 10371 |
"\n" |
| 10372 |
"If there is no limit, return -1.\n" |
| 10373 |
"On some platforms, path may also be specified as an open file descriptor.\n" |
| 10374 |
" If this functionality is unavailable, using it raises an exception."); |
| 10375 |
|
| 10376 |
#define OS_PATHCONF_METHODDEF \ |
| 10377 |
{"pathconf", _PyCFunction_CAST(os_pathconf), METH_FASTCALL|METH_KEYWORDS, os_pathconf__doc__}, |
| 10378 |
|
| 10379 |
static long |
| 10380 |
os_pathconf_impl(PyObject *module, path_t *path, int name); |
| 10381 |
|
| 10382 |
static PyObject * |
| 10383 |
os_pathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10384 |
{ |
| 10385 |
PyObject *return_value = NULL; |
| 10386 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10387 |
|
| 10388 |
#define NUM_KEYWORDS 2 |
| 10389 |
static struct { |
| 10390 |
PyGC_Head _this_is_not_used; |
| 10391 |
PyObject_VAR_HEAD |
| 10392 |
Py_hash_t ob_hash; |
| 10393 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10394 |
} _kwtuple = { |
| 10395 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10396 |
.ob_hash = -1, |
| 10397 |
.ob_item = { &_Py_ID(path), &_Py_ID(name), }, |
| 10398 |
}; |
| 10399 |
#undef NUM_KEYWORDS |
| 10400 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10401 |
|
| 10402 |
#else // !Py_BUILD_CORE |
| 10403 |
# define KWTUPLE NULL |
| 10404 |
#endif // !Py_BUILD_CORE |
| 10405 |
|
| 10406 |
static const char * const _keywords[] = {"path", "name", NULL}; |
| 10407 |
static _PyArg_Parser _parser = { |
| 10408 |
.keywords = _keywords, |
| 10409 |
.fname = "pathconf", |
| 10410 |
.kwtuple = KWTUPLE, |
| 10411 |
}; |
| 10412 |
#undef KWTUPLE |
| 10413 |
PyObject *argsbuf[2]; |
| 10414 |
path_t path = PATH_T_INITIALIZE_P("pathconf", "path", 0, 0, 0, PATH_HAVE_FPATHCONF); |
| 10415 |
int name; |
| 10416 |
long _return_value; |
| 10417 |
|
| 10418 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10419 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10420 |
if (!args) { |
| 10421 |
goto exit; |
| 10422 |
} |
| 10423 |
if (!path_converter(args[0], &path)) { |
| 10424 |
goto exit; |
| 10425 |
} |
| 10426 |
if (!conv_confname(module, args[1], &name, "pathconf_names")) { |
| 10427 |
goto exit; |
| 10428 |
} |
| 10429 |
_return_value = os_pathconf_impl(module, &path, name); |
| 10430 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 10431 |
goto exit; |
| 10432 |
} |
| 10433 |
return_value = PyLong_FromLong(_return_value); |
| 10434 |
|
| 10435 |
exit: |
| 10436 |
/* Cleanup for path */ |
| 10437 |
path_cleanup(&path); |
| 10438 |
|
| 10439 |
return return_value; |
| 10440 |
} |
| 10441 |
|
| 10442 |
#endif /* defined(HAVE_PATHCONF) */ |
| 10443 |
|
| 10444 |
#if defined(HAVE_CONFSTR) |
| 10445 |
|
| 10446 |
PyDoc_STRVAR(os_confstr__doc__, |
| 10447 |
"confstr($module, name, /)\n" |
| 10448 |
"--\n" |
| 10449 |
"\n" |
| 10450 |
"Return a string-valued system configuration variable."); |
| 10451 |
|
| 10452 |
#define OS_CONFSTR_METHODDEF \ |
| 10453 |
{"confstr", (PyCFunction)os_confstr, METH_O, os_confstr__doc__}, |
| 10454 |
|
| 10455 |
static PyObject * |
| 10456 |
os_confstr_impl(PyObject *module, int name); |
| 10457 |
|
| 10458 |
static PyObject * |
| 10459 |
os_confstr(PyObject *module, PyObject *arg) |
| 10460 |
{ |
| 10461 |
PyObject *return_value = NULL; |
| 10462 |
int name; |
| 10463 |
|
| 10464 |
if (!conv_confname(module, arg, &name, "confstr_names")) { |
| 10465 |
goto exit; |
| 10466 |
} |
| 10467 |
return_value = os_confstr_impl(module, name); |
| 10468 |
|
| 10469 |
exit: |
| 10470 |
return return_value; |
| 10471 |
} |
| 10472 |
|
| 10473 |
#endif /* defined(HAVE_CONFSTR) */ |
| 10474 |
|
| 10475 |
#if defined(HAVE_SYSCONF) |
| 10476 |
|
| 10477 |
PyDoc_STRVAR(os_sysconf__doc__, |
| 10478 |
"sysconf($module, name, /)\n" |
| 10479 |
"--\n" |
| 10480 |
"\n" |
| 10481 |
"Return an integer-valued system configuration variable."); |
| 10482 |
|
| 10483 |
#define OS_SYSCONF_METHODDEF \ |
| 10484 |
{"sysconf", (PyCFunction)os_sysconf, METH_O, os_sysconf__doc__}, |
| 10485 |
|
| 10486 |
static long |
| 10487 |
os_sysconf_impl(PyObject *module, int name); |
| 10488 |
|
| 10489 |
static PyObject * |
| 10490 |
os_sysconf(PyObject *module, PyObject *arg) |
| 10491 |
{ |
| 10492 |
PyObject *return_value = NULL; |
| 10493 |
int name; |
| 10494 |
long _return_value; |
| 10495 |
|
| 10496 |
if (!conv_confname(module, arg, &name, "sysconf_names")) { |
| 10497 |
goto exit; |
| 10498 |
} |
| 10499 |
_return_value = os_sysconf_impl(module, name); |
| 10500 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 10501 |
goto exit; |
| 10502 |
} |
| 10503 |
return_value = PyLong_FromLong(_return_value); |
| 10504 |
|
| 10505 |
exit: |
| 10506 |
return return_value; |
| 10507 |
} |
| 10508 |
|
| 10509 |
#endif /* defined(HAVE_SYSCONF) */ |
| 10510 |
|
| 10511 |
PyDoc_STRVAR(os_abort__doc__, |
| 10512 |
"abort($module, /)\n" |
| 10513 |
"--\n" |
| 10514 |
"\n" |
| 10515 |
"Abort the interpreter immediately.\n" |
| 10516 |
"\n" |
| 10517 |
"This function \'dumps core\' or otherwise fails in the hardest way possible\n" |
| 10518 |
"on the hosting operating system. This function never returns."); |
| 10519 |
|
| 10520 |
#define OS_ABORT_METHODDEF \ |
| 10521 |
{"abort", (PyCFunction)os_abort, METH_NOARGS, os_abort__doc__}, |
| 10522 |
|
| 10523 |
static PyObject * |
| 10524 |
os_abort_impl(PyObject *module); |
| 10525 |
|
| 10526 |
static PyObject * |
| 10527 |
os_abort(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 10528 |
{ |
| 10529 |
return os_abort_impl(module); |
| 10530 |
} |
| 10531 |
|
| 10532 |
#if defined(MS_WINDOWS) |
| 10533 |
|
| 10534 |
PyDoc_STRVAR(os_startfile__doc__, |
| 10535 |
"startfile($module, /, filepath, operation=<unrepresentable>,\n" |
| 10536 |
" arguments=<unrepresentable>, cwd=None, show_cmd=1)\n" |
| 10537 |
"--\n" |
| 10538 |
"\n" |
| 10539 |
"Start a file with its associated application.\n" |
| 10540 |
"\n" |
| 10541 |
"When \"operation\" is not specified or \"open\", this acts like\n" |
| 10542 |
"double-clicking the file in Explorer, or giving the file name as an\n" |
| 10543 |
"argument to the DOS \"start\" command: the file is opened with whatever\n" |
| 10544 |
"application (if any) its extension is associated.\n" |
| 10545 |
"When another \"operation\" is given, it specifies what should be done with\n" |
| 10546 |
"the file. A typical operation is \"print\".\n" |
| 10547 |
"\n" |
| 10548 |
"\"arguments\" is passed to the application, but should be omitted if the\n" |
| 10549 |
"file is a document.\n" |
| 10550 |
"\n" |
| 10551 |
"\"cwd\" is the working directory for the operation. If \"filepath\" is\n" |
| 10552 |
"relative, it will be resolved against this directory. This argument\n" |
| 10553 |
"should usually be an absolute path.\n" |
| 10554 |
"\n" |
| 10555 |
"\"show_cmd\" can be used to override the recommended visibility option.\n" |
| 10556 |
"See the Windows ShellExecute documentation for values.\n" |
| 10557 |
"\n" |
| 10558 |
"startfile returns as soon as the associated application is launched.\n" |
| 10559 |
"There is no option to wait for the application to close, and no way\n" |
| 10560 |
"to retrieve the application\'s exit status.\n" |
| 10561 |
"\n" |
| 10562 |
"The filepath is relative to the current directory. If you want to use\n" |
| 10563 |
"an absolute path, make sure the first character is not a slash (\"/\");\n" |
| 10564 |
"the underlying Win32 ShellExecute function doesn\'t work if it is."); |
| 10565 |
|
| 10566 |
#define OS_STARTFILE_METHODDEF \ |
| 10567 |
{"startfile", _PyCFunction_CAST(os_startfile), METH_FASTCALL|METH_KEYWORDS, os_startfile__doc__}, |
| 10568 |
|
| 10569 |
static PyObject * |
| 10570 |
os_startfile_impl(PyObject *module, path_t *filepath, |
| 10571 |
const wchar_t *operation, const wchar_t *arguments, |
| 10572 |
path_t *cwd, int show_cmd); |
| 10573 |
|
| 10574 |
static PyObject * |
| 10575 |
os_startfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10576 |
{ |
| 10577 |
PyObject *return_value = NULL; |
| 10578 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10579 |
|
| 10580 |
#define NUM_KEYWORDS 5 |
| 10581 |
static struct { |
| 10582 |
PyGC_Head _this_is_not_used; |
| 10583 |
PyObject_VAR_HEAD |
| 10584 |
Py_hash_t ob_hash; |
| 10585 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10586 |
} _kwtuple = { |
| 10587 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10588 |
.ob_hash = -1, |
| 10589 |
.ob_item = { &_Py_ID(filepath), &_Py_ID(operation), &_Py_ID(arguments), &_Py_ID(cwd), &_Py_ID(show_cmd), }, |
| 10590 |
}; |
| 10591 |
#undef NUM_KEYWORDS |
| 10592 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10593 |
|
| 10594 |
#else // !Py_BUILD_CORE |
| 10595 |
# define KWTUPLE NULL |
| 10596 |
#endif // !Py_BUILD_CORE |
| 10597 |
|
| 10598 |
static const char * const _keywords[] = {"filepath", "operation", "arguments", "cwd", "show_cmd", NULL}; |
| 10599 |
static _PyArg_Parser _parser = { |
| 10600 |
.keywords = _keywords, |
| 10601 |
.fname = "startfile", |
| 10602 |
.kwtuple = KWTUPLE, |
| 10603 |
}; |
| 10604 |
#undef KWTUPLE |
| 10605 |
PyObject *argsbuf[5]; |
| 10606 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 10607 |
path_t filepath = PATH_T_INITIALIZE_P("startfile", "filepath", 0, 0, 0, 0); |
| 10608 |
const wchar_t *operation = NULL; |
| 10609 |
const wchar_t *arguments = NULL; |
| 10610 |
path_t cwd = PATH_T_INITIALIZE_P("startfile", "cwd", 1, 0, 0, 0); |
| 10611 |
int show_cmd = 1; |
| 10612 |
|
| 10613 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10614 |
/*minpos*/ 1, /*maxpos*/ 5, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10615 |
if (!args) { |
| 10616 |
goto exit; |
| 10617 |
} |
| 10618 |
if (!path_converter(args[0], &filepath)) { |
| 10619 |
goto exit; |
| 10620 |
} |
| 10621 |
if (!noptargs) { |
| 10622 |
goto skip_optional_pos; |
| 10623 |
} |
| 10624 |
if (args[1]) { |
| 10625 |
if (!PyUnicode_Check(args[1])) { |
| 10626 |
_PyArg_BadArgument("startfile", "argument 'operation'", "str", args[1]); |
| 10627 |
goto exit; |
| 10628 |
} |
| 10629 |
operation = PyUnicode_AsWideCharString(args[1], NULL); |
| 10630 |
if (operation == NULL) { |
| 10631 |
goto exit; |
| 10632 |
} |
| 10633 |
if (!--noptargs) { |
| 10634 |
goto skip_optional_pos; |
| 10635 |
} |
| 10636 |
} |
| 10637 |
if (args[2]) { |
| 10638 |
if (!PyUnicode_Check(args[2])) { |
| 10639 |
_PyArg_BadArgument("startfile", "argument 'arguments'", "str", args[2]); |
| 10640 |
goto exit; |
| 10641 |
} |
| 10642 |
arguments = PyUnicode_AsWideCharString(args[2], NULL); |
| 10643 |
if (arguments == NULL) { |
| 10644 |
goto exit; |
| 10645 |
} |
| 10646 |
if (!--noptargs) { |
| 10647 |
goto skip_optional_pos; |
| 10648 |
} |
| 10649 |
} |
| 10650 |
if (args[3]) { |
| 10651 |
if (!path_converter(args[3], &cwd)) { |
| 10652 |
goto exit; |
| 10653 |
} |
| 10654 |
if (!--noptargs) { |
| 10655 |
goto skip_optional_pos; |
| 10656 |
} |
| 10657 |
} |
| 10658 |
show_cmd = PyLong_AsInt(args[4]); |
| 10659 |
if (show_cmd == -1 && PyErr_Occurred()) { |
| 10660 |
goto exit; |
| 10661 |
} |
| 10662 |
skip_optional_pos: |
| 10663 |
return_value = os_startfile_impl(module, &filepath, operation, arguments, &cwd, show_cmd); |
| 10664 |
|
| 10665 |
exit: |
| 10666 |
/* Cleanup for filepath */ |
| 10667 |
path_cleanup(&filepath); |
| 10668 |
/* Cleanup for operation */ |
| 10669 |
PyMem_Free((void *)operation); |
| 10670 |
/* Cleanup for arguments */ |
| 10671 |
PyMem_Free((void *)arguments); |
| 10672 |
/* Cleanup for cwd */ |
| 10673 |
path_cleanup(&cwd); |
| 10674 |
|
| 10675 |
return return_value; |
| 10676 |
} |
| 10677 |
|
| 10678 |
#endif /* defined(MS_WINDOWS) */ |
| 10679 |
|
| 10680 |
#if defined(HAVE_GETLOADAVG) |
| 10681 |
|
| 10682 |
PyDoc_STRVAR(os_getloadavg__doc__, |
| 10683 |
"getloadavg($module, /)\n" |
| 10684 |
"--\n" |
| 10685 |
"\n" |
| 10686 |
"Return average recent system load information.\n" |
| 10687 |
"\n" |
| 10688 |
"Return the number of processes in the system run queue averaged over\n" |
| 10689 |
"the last 1, 5, and 15 minutes as a tuple of three floats.\n" |
| 10690 |
"Raises OSError if the load average was unobtainable."); |
| 10691 |
|
| 10692 |
#define OS_GETLOADAVG_METHODDEF \ |
| 10693 |
{"getloadavg", (PyCFunction)os_getloadavg, METH_NOARGS, os_getloadavg__doc__}, |
| 10694 |
|
| 10695 |
static PyObject * |
| 10696 |
os_getloadavg_impl(PyObject *module); |
| 10697 |
|
| 10698 |
static PyObject * |
| 10699 |
os_getloadavg(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 10700 |
{ |
| 10701 |
return os_getloadavg_impl(module); |
| 10702 |
} |
| 10703 |
|
| 10704 |
#endif /* defined(HAVE_GETLOADAVG) */ |
| 10705 |
|
| 10706 |
PyDoc_STRVAR(os_device_encoding__doc__, |
| 10707 |
"device_encoding($module, /, fd)\n" |
| 10708 |
"--\n" |
| 10709 |
"\n" |
| 10710 |
"Return a string describing the encoding of a terminal\'s file descriptor.\n" |
| 10711 |
"\n" |
| 10712 |
"The file descriptor must be attached to a terminal.\n" |
| 10713 |
"If the device is not a terminal, return None."); |
| 10714 |
|
| 10715 |
#define OS_DEVICE_ENCODING_METHODDEF \ |
| 10716 |
{"device_encoding", _PyCFunction_CAST(os_device_encoding), METH_FASTCALL|METH_KEYWORDS, os_device_encoding__doc__}, |
| 10717 |
|
| 10718 |
static PyObject * |
| 10719 |
os_device_encoding_impl(PyObject *module, int fd); |
| 10720 |
|
| 10721 |
static PyObject * |
| 10722 |
os_device_encoding(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10723 |
{ |
| 10724 |
PyObject *return_value = NULL; |
| 10725 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10726 |
|
| 10727 |
#define NUM_KEYWORDS 1 |
| 10728 |
static struct { |
| 10729 |
PyGC_Head _this_is_not_used; |
| 10730 |
PyObject_VAR_HEAD |
| 10731 |
Py_hash_t ob_hash; |
| 10732 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10733 |
} _kwtuple = { |
| 10734 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10735 |
.ob_hash = -1, |
| 10736 |
.ob_item = { &_Py_ID(fd), }, |
| 10737 |
}; |
| 10738 |
#undef NUM_KEYWORDS |
| 10739 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10740 |
|
| 10741 |
#else // !Py_BUILD_CORE |
| 10742 |
# define KWTUPLE NULL |
| 10743 |
#endif // !Py_BUILD_CORE |
| 10744 |
|
| 10745 |
static const char * const _keywords[] = {"fd", NULL}; |
| 10746 |
static _PyArg_Parser _parser = { |
| 10747 |
.keywords = _keywords, |
| 10748 |
.fname = "device_encoding", |
| 10749 |
.kwtuple = KWTUPLE, |
| 10750 |
}; |
| 10751 |
#undef KWTUPLE |
| 10752 |
PyObject *argsbuf[1]; |
| 10753 |
int fd; |
| 10754 |
|
| 10755 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10756 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10757 |
if (!args) { |
| 10758 |
goto exit; |
| 10759 |
} |
| 10760 |
fd = PyLong_AsInt(args[0]); |
| 10761 |
if (fd == -1 && PyErr_Occurred()) { |
| 10762 |
goto exit; |
| 10763 |
} |
| 10764 |
return_value = os_device_encoding_impl(module, fd); |
| 10765 |
|
| 10766 |
exit: |
| 10767 |
return return_value; |
| 10768 |
} |
| 10769 |
|
| 10770 |
#if defined(HAVE_SETRESUID) |
| 10771 |
|
| 10772 |
PyDoc_STRVAR(os_setresuid__doc__, |
| 10773 |
"setresuid($module, ruid, euid, suid, /)\n" |
| 10774 |
"--\n" |
| 10775 |
"\n" |
| 10776 |
"Set the current process\'s real, effective, and saved user ids."); |
| 10777 |
|
| 10778 |
#define OS_SETRESUID_METHODDEF \ |
| 10779 |
{"setresuid", _PyCFunction_CAST(os_setresuid), METH_FASTCALL, os_setresuid__doc__}, |
| 10780 |
|
| 10781 |
static PyObject * |
| 10782 |
os_setresuid_impl(PyObject *module, uid_t ruid, uid_t euid, uid_t suid); |
| 10783 |
|
| 10784 |
static PyObject * |
| 10785 |
os_setresuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 10786 |
{ |
| 10787 |
PyObject *return_value = NULL; |
| 10788 |
uid_t ruid; |
| 10789 |
uid_t euid; |
| 10790 |
uid_t suid; |
| 10791 |
|
| 10792 |
if (!_PyArg_CheckPositional("setresuid", nargs, 3, 3)) { |
| 10793 |
goto exit; |
| 10794 |
} |
| 10795 |
if (!_Py_Uid_Converter(args[0], &ruid)) { |
| 10796 |
goto exit; |
| 10797 |
} |
| 10798 |
if (!_Py_Uid_Converter(args[1], &euid)) { |
| 10799 |
goto exit; |
| 10800 |
} |
| 10801 |
if (!_Py_Uid_Converter(args[2], &suid)) { |
| 10802 |
goto exit; |
| 10803 |
} |
| 10804 |
return_value = os_setresuid_impl(module, ruid, euid, suid); |
| 10805 |
|
| 10806 |
exit: |
| 10807 |
return return_value; |
| 10808 |
} |
| 10809 |
|
| 10810 |
#endif /* defined(HAVE_SETRESUID) */ |
| 10811 |
|
| 10812 |
#if defined(HAVE_SETRESGID) |
| 10813 |
|
| 10814 |
PyDoc_STRVAR(os_setresgid__doc__, |
| 10815 |
"setresgid($module, rgid, egid, sgid, /)\n" |
| 10816 |
"--\n" |
| 10817 |
"\n" |
| 10818 |
"Set the current process\'s real, effective, and saved group ids."); |
| 10819 |
|
| 10820 |
#define OS_SETRESGID_METHODDEF \ |
| 10821 |
{"setresgid", _PyCFunction_CAST(os_setresgid), METH_FASTCALL, os_setresgid__doc__}, |
| 10822 |
|
| 10823 |
static PyObject * |
| 10824 |
os_setresgid_impl(PyObject *module, gid_t rgid, gid_t egid, gid_t sgid); |
| 10825 |
|
| 10826 |
static PyObject * |
| 10827 |
os_setresgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 10828 |
{ |
| 10829 |
PyObject *return_value = NULL; |
| 10830 |
gid_t rgid; |
| 10831 |
gid_t egid; |
| 10832 |
gid_t sgid; |
| 10833 |
|
| 10834 |
if (!_PyArg_CheckPositional("setresgid", nargs, 3, 3)) { |
| 10835 |
goto exit; |
| 10836 |
} |
| 10837 |
if (!_Py_Gid_Converter(args[0], &rgid)) { |
| 10838 |
goto exit; |
| 10839 |
} |
| 10840 |
if (!_Py_Gid_Converter(args[1], &egid)) { |
| 10841 |
goto exit; |
| 10842 |
} |
| 10843 |
if (!_Py_Gid_Converter(args[2], &sgid)) { |
| 10844 |
goto exit; |
| 10845 |
} |
| 10846 |
return_value = os_setresgid_impl(module, rgid, egid, sgid); |
| 10847 |
|
| 10848 |
exit: |
| 10849 |
return return_value; |
| 10850 |
} |
| 10851 |
|
| 10852 |
#endif /* defined(HAVE_SETRESGID) */ |
| 10853 |
|
| 10854 |
#if defined(HAVE_GETRESUID) |
| 10855 |
|
| 10856 |
PyDoc_STRVAR(os_getresuid__doc__, |
| 10857 |
"getresuid($module, /)\n" |
| 10858 |
"--\n" |
| 10859 |
"\n" |
| 10860 |
"Return a tuple of the current process\'s real, effective, and saved user ids."); |
| 10861 |
|
| 10862 |
#define OS_GETRESUID_METHODDEF \ |
| 10863 |
{"getresuid", (PyCFunction)os_getresuid, METH_NOARGS, os_getresuid__doc__}, |
| 10864 |
|
| 10865 |
static PyObject * |
| 10866 |
os_getresuid_impl(PyObject *module); |
| 10867 |
|
| 10868 |
static PyObject * |
| 10869 |
os_getresuid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 10870 |
{ |
| 10871 |
return os_getresuid_impl(module); |
| 10872 |
} |
| 10873 |
|
| 10874 |
#endif /* defined(HAVE_GETRESUID) */ |
| 10875 |
|
| 10876 |
#if defined(HAVE_GETRESGID) |
| 10877 |
|
| 10878 |
PyDoc_STRVAR(os_getresgid__doc__, |
| 10879 |
"getresgid($module, /)\n" |
| 10880 |
"--\n" |
| 10881 |
"\n" |
| 10882 |
"Return a tuple of the current process\'s real, effective, and saved group ids."); |
| 10883 |
|
| 10884 |
#define OS_GETRESGID_METHODDEF \ |
| 10885 |
{"getresgid", (PyCFunction)os_getresgid, METH_NOARGS, os_getresgid__doc__}, |
| 10886 |
|
| 10887 |
static PyObject * |
| 10888 |
os_getresgid_impl(PyObject *module); |
| 10889 |
|
| 10890 |
static PyObject * |
| 10891 |
os_getresgid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 10892 |
{ |
| 10893 |
return os_getresgid_impl(module); |
| 10894 |
} |
| 10895 |
|
| 10896 |
#endif /* defined(HAVE_GETRESGID) */ |
| 10897 |
|
| 10898 |
#if defined(USE_XATTRS) |
| 10899 |
|
| 10900 |
PyDoc_STRVAR(os_getxattr__doc__, |
| 10901 |
"getxattr($module, /, path, attribute, *, follow_symlinks=True)\n" |
| 10902 |
"--\n" |
| 10903 |
"\n" |
| 10904 |
"Return the value of extended attribute attribute on path.\n" |
| 10905 |
"\n" |
| 10906 |
"path may be either a string, a path-like object, or an open file descriptor.\n" |
| 10907 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 10908 |
" link, getxattr will examine the symbolic link itself instead of the file\n" |
| 10909 |
" the link points to."); |
| 10910 |
|
| 10911 |
#define OS_GETXATTR_METHODDEF \ |
| 10912 |
{"getxattr", _PyCFunction_CAST(os_getxattr), METH_FASTCALL|METH_KEYWORDS, os_getxattr__doc__}, |
| 10913 |
|
| 10914 |
static PyObject * |
| 10915 |
os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute, |
| 10916 |
int follow_symlinks); |
| 10917 |
|
| 10918 |
static PyObject * |
| 10919 |
os_getxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 10920 |
{ |
| 10921 |
PyObject *return_value = NULL; |
| 10922 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 10923 |
|
| 10924 |
#define NUM_KEYWORDS 3 |
| 10925 |
static struct { |
| 10926 |
PyGC_Head _this_is_not_used; |
| 10927 |
PyObject_VAR_HEAD |
| 10928 |
Py_hash_t ob_hash; |
| 10929 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 10930 |
} _kwtuple = { |
| 10931 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 10932 |
.ob_hash = -1, |
| 10933 |
.ob_item = { &_Py_ID(path), &_Py_ID(attribute), &_Py_ID(follow_symlinks), }, |
| 10934 |
}; |
| 10935 |
#undef NUM_KEYWORDS |
| 10936 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 10937 |
|
| 10938 |
#else // !Py_BUILD_CORE |
| 10939 |
# define KWTUPLE NULL |
| 10940 |
#endif // !Py_BUILD_CORE |
| 10941 |
|
| 10942 |
static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; |
| 10943 |
static _PyArg_Parser _parser = { |
| 10944 |
.keywords = _keywords, |
| 10945 |
.fname = "getxattr", |
| 10946 |
.kwtuple = KWTUPLE, |
| 10947 |
}; |
| 10948 |
#undef KWTUPLE |
| 10949 |
PyObject *argsbuf[3]; |
| 10950 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 10951 |
path_t path = PATH_T_INITIALIZE_P("getxattr", "path", 0, 0, 0, 1); |
| 10952 |
path_t attribute = PATH_T_INITIALIZE_P("getxattr", "attribute", 0, 0, 0, 0); |
| 10953 |
int follow_symlinks = 1; |
| 10954 |
|
| 10955 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 10956 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 10957 |
if (!args) { |
| 10958 |
goto exit; |
| 10959 |
} |
| 10960 |
if (!path_converter(args[0], &path)) { |
| 10961 |
goto exit; |
| 10962 |
} |
| 10963 |
if (!path_converter(args[1], &attribute)) { |
| 10964 |
goto exit; |
| 10965 |
} |
| 10966 |
if (!noptargs) { |
| 10967 |
goto skip_optional_kwonly; |
| 10968 |
} |
| 10969 |
follow_symlinks = PyObject_IsTrue(args[2]); |
| 10970 |
if (follow_symlinks < 0) { |
| 10971 |
goto exit; |
| 10972 |
} |
| 10973 |
skip_optional_kwonly: |
| 10974 |
return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); |
| 10975 |
|
| 10976 |
exit: |
| 10977 |
/* Cleanup for path */ |
| 10978 |
path_cleanup(&path); |
| 10979 |
/* Cleanup for attribute */ |
| 10980 |
path_cleanup(&attribute); |
| 10981 |
|
| 10982 |
return return_value; |
| 10983 |
} |
| 10984 |
|
| 10985 |
#endif /* defined(USE_XATTRS) */ |
| 10986 |
|
| 10987 |
#if defined(USE_XATTRS) |
| 10988 |
|
| 10989 |
PyDoc_STRVAR(os_setxattr__doc__, |
| 10990 |
"setxattr($module, /, path, attribute, value, flags=0, *,\n" |
| 10991 |
" follow_symlinks=True)\n" |
| 10992 |
"--\n" |
| 10993 |
"\n" |
| 10994 |
"Set extended attribute attribute on path to value.\n" |
| 10995 |
"\n" |
| 10996 |
"path may be either a string, a path-like object, or an open file descriptor.\n" |
| 10997 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 10998 |
" link, setxattr will modify the symbolic link itself instead of the file\n" |
| 10999 |
" the link points to."); |
| 11000 |
|
| 11001 |
#define OS_SETXATTR_METHODDEF \ |
| 11002 |
{"setxattr", _PyCFunction_CAST(os_setxattr), METH_FASTCALL|METH_KEYWORDS, os_setxattr__doc__}, |
| 11003 |
|
| 11004 |
static PyObject * |
| 11005 |
os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute, |
| 11006 |
Py_buffer *value, int flags, int follow_symlinks); |
| 11007 |
|
| 11008 |
static PyObject * |
| 11009 |
os_setxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11010 |
{ |
| 11011 |
PyObject *return_value = NULL; |
| 11012 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11013 |
|
| 11014 |
#define NUM_KEYWORDS 5 |
| 11015 |
static struct { |
| 11016 |
PyGC_Head _this_is_not_used; |
| 11017 |
PyObject_VAR_HEAD |
| 11018 |
Py_hash_t ob_hash; |
| 11019 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11020 |
} _kwtuple = { |
| 11021 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11022 |
.ob_hash = -1, |
| 11023 |
.ob_item = { &_Py_ID(path), &_Py_ID(attribute), &_Py_ID(value), &_Py_ID(flags), &_Py_ID(follow_symlinks), }, |
| 11024 |
}; |
| 11025 |
#undef NUM_KEYWORDS |
| 11026 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11027 |
|
| 11028 |
#else // !Py_BUILD_CORE |
| 11029 |
# define KWTUPLE NULL |
| 11030 |
#endif // !Py_BUILD_CORE |
| 11031 |
|
| 11032 |
static const char * const _keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; |
| 11033 |
static _PyArg_Parser _parser = { |
| 11034 |
.keywords = _keywords, |
| 11035 |
.fname = "setxattr", |
| 11036 |
.kwtuple = KWTUPLE, |
| 11037 |
}; |
| 11038 |
#undef KWTUPLE |
| 11039 |
PyObject *argsbuf[5]; |
| 11040 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3; |
| 11041 |
path_t path = PATH_T_INITIALIZE_P("setxattr", "path", 0, 0, 0, 1); |
| 11042 |
path_t attribute = PATH_T_INITIALIZE_P("setxattr", "attribute", 0, 0, 0, 0); |
| 11043 |
Py_buffer value = {NULL, NULL}; |
| 11044 |
int flags = 0; |
| 11045 |
int follow_symlinks = 1; |
| 11046 |
|
| 11047 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11048 |
/*minpos*/ 3, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11049 |
if (!args) { |
| 11050 |
goto exit; |
| 11051 |
} |
| 11052 |
if (!path_converter(args[0], &path)) { |
| 11053 |
goto exit; |
| 11054 |
} |
| 11055 |
if (!path_converter(args[1], &attribute)) { |
| 11056 |
goto exit; |
| 11057 |
} |
| 11058 |
if (PyObject_GetBuffer(args[2], &value, PyBUF_SIMPLE) != 0) { |
| 11059 |
goto exit; |
| 11060 |
} |
| 11061 |
if (!noptargs) { |
| 11062 |
goto skip_optional_pos; |
| 11063 |
} |
| 11064 |
if (args[3]) { |
| 11065 |
flags = PyLong_AsInt(args[3]); |
| 11066 |
if (flags == -1 && PyErr_Occurred()) { |
| 11067 |
goto exit; |
| 11068 |
} |
| 11069 |
if (!--noptargs) { |
| 11070 |
goto skip_optional_pos; |
| 11071 |
} |
| 11072 |
} |
| 11073 |
skip_optional_pos: |
| 11074 |
if (!noptargs) { |
| 11075 |
goto skip_optional_kwonly; |
| 11076 |
} |
| 11077 |
follow_symlinks = PyObject_IsTrue(args[4]); |
| 11078 |
if (follow_symlinks < 0) { |
| 11079 |
goto exit; |
| 11080 |
} |
| 11081 |
skip_optional_kwonly: |
| 11082 |
return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); |
| 11083 |
|
| 11084 |
exit: |
| 11085 |
/* Cleanup for path */ |
| 11086 |
path_cleanup(&path); |
| 11087 |
/* Cleanup for attribute */ |
| 11088 |
path_cleanup(&attribute); |
| 11089 |
/* Cleanup for value */ |
| 11090 |
if (value.obj) { |
| 11091 |
PyBuffer_Release(&value); |
| 11092 |
} |
| 11093 |
|
| 11094 |
return return_value; |
| 11095 |
} |
| 11096 |
|
| 11097 |
#endif /* defined(USE_XATTRS) */ |
| 11098 |
|
| 11099 |
#if defined(USE_XATTRS) |
| 11100 |
|
| 11101 |
PyDoc_STRVAR(os_removexattr__doc__, |
| 11102 |
"removexattr($module, /, path, attribute, *, follow_symlinks=True)\n" |
| 11103 |
"--\n" |
| 11104 |
"\n" |
| 11105 |
"Remove extended attribute attribute on path.\n" |
| 11106 |
"\n" |
| 11107 |
"path may be either a string, a path-like object, or an open file descriptor.\n" |
| 11108 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 11109 |
" link, removexattr will modify the symbolic link itself instead of the file\n" |
| 11110 |
" the link points to."); |
| 11111 |
|
| 11112 |
#define OS_REMOVEXATTR_METHODDEF \ |
| 11113 |
{"removexattr", _PyCFunction_CAST(os_removexattr), METH_FASTCALL|METH_KEYWORDS, os_removexattr__doc__}, |
| 11114 |
|
| 11115 |
static PyObject * |
| 11116 |
os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute, |
| 11117 |
int follow_symlinks); |
| 11118 |
|
| 11119 |
static PyObject * |
| 11120 |
os_removexattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11121 |
{ |
| 11122 |
PyObject *return_value = NULL; |
| 11123 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11124 |
|
| 11125 |
#define NUM_KEYWORDS 3 |
| 11126 |
static struct { |
| 11127 |
PyGC_Head _this_is_not_used; |
| 11128 |
PyObject_VAR_HEAD |
| 11129 |
Py_hash_t ob_hash; |
| 11130 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11131 |
} _kwtuple = { |
| 11132 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11133 |
.ob_hash = -1, |
| 11134 |
.ob_item = { &_Py_ID(path), &_Py_ID(attribute), &_Py_ID(follow_symlinks), }, |
| 11135 |
}; |
| 11136 |
#undef NUM_KEYWORDS |
| 11137 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11138 |
|
| 11139 |
#else // !Py_BUILD_CORE |
| 11140 |
# define KWTUPLE NULL |
| 11141 |
#endif // !Py_BUILD_CORE |
| 11142 |
|
| 11143 |
static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; |
| 11144 |
static _PyArg_Parser _parser = { |
| 11145 |
.keywords = _keywords, |
| 11146 |
.fname = "removexattr", |
| 11147 |
.kwtuple = KWTUPLE, |
| 11148 |
}; |
| 11149 |
#undef KWTUPLE |
| 11150 |
PyObject *argsbuf[3]; |
| 11151 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
| 11152 |
path_t path = PATH_T_INITIALIZE_P("removexattr", "path", 0, 0, 0, 1); |
| 11153 |
path_t attribute = PATH_T_INITIALIZE_P("removexattr", "attribute", 0, 0, 0, 0); |
| 11154 |
int follow_symlinks = 1; |
| 11155 |
|
| 11156 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11157 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11158 |
if (!args) { |
| 11159 |
goto exit; |
| 11160 |
} |
| 11161 |
if (!path_converter(args[0], &path)) { |
| 11162 |
goto exit; |
| 11163 |
} |
| 11164 |
if (!path_converter(args[1], &attribute)) { |
| 11165 |
goto exit; |
| 11166 |
} |
| 11167 |
if (!noptargs) { |
| 11168 |
goto skip_optional_kwonly; |
| 11169 |
} |
| 11170 |
follow_symlinks = PyObject_IsTrue(args[2]); |
| 11171 |
if (follow_symlinks < 0) { |
| 11172 |
goto exit; |
| 11173 |
} |
| 11174 |
skip_optional_kwonly: |
| 11175 |
return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); |
| 11176 |
|
| 11177 |
exit: |
| 11178 |
/* Cleanup for path */ |
| 11179 |
path_cleanup(&path); |
| 11180 |
/* Cleanup for attribute */ |
| 11181 |
path_cleanup(&attribute); |
| 11182 |
|
| 11183 |
return return_value; |
| 11184 |
} |
| 11185 |
|
| 11186 |
#endif /* defined(USE_XATTRS) */ |
| 11187 |
|
| 11188 |
#if defined(USE_XATTRS) |
| 11189 |
|
| 11190 |
PyDoc_STRVAR(os_listxattr__doc__, |
| 11191 |
"listxattr($module, /, path=None, *, follow_symlinks=True)\n" |
| 11192 |
"--\n" |
| 11193 |
"\n" |
| 11194 |
"Return a list of extended attributes on path.\n" |
| 11195 |
"\n" |
| 11196 |
"path may be either None, a string, a path-like object, or an open file descriptor.\n" |
| 11197 |
"if path is None, listxattr will examine the current directory.\n" |
| 11198 |
"If follow_symlinks is False, and the last element of the path is a symbolic\n" |
| 11199 |
" link, listxattr will examine the symbolic link itself instead of the file\n" |
| 11200 |
" the link points to."); |
| 11201 |
|
| 11202 |
#define OS_LISTXATTR_METHODDEF \ |
| 11203 |
{"listxattr", _PyCFunction_CAST(os_listxattr), METH_FASTCALL|METH_KEYWORDS, os_listxattr__doc__}, |
| 11204 |
|
| 11205 |
static PyObject * |
| 11206 |
os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks); |
| 11207 |
|
| 11208 |
static PyObject * |
| 11209 |
os_listxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11210 |
{ |
| 11211 |
PyObject *return_value = NULL; |
| 11212 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11213 |
|
| 11214 |
#define NUM_KEYWORDS 2 |
| 11215 |
static struct { |
| 11216 |
PyGC_Head _this_is_not_used; |
| 11217 |
PyObject_VAR_HEAD |
| 11218 |
Py_hash_t ob_hash; |
| 11219 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11220 |
} _kwtuple = { |
| 11221 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11222 |
.ob_hash = -1, |
| 11223 |
.ob_item = { &_Py_ID(path), &_Py_ID(follow_symlinks), }, |
| 11224 |
}; |
| 11225 |
#undef NUM_KEYWORDS |
| 11226 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11227 |
|
| 11228 |
#else // !Py_BUILD_CORE |
| 11229 |
# define KWTUPLE NULL |
| 11230 |
#endif // !Py_BUILD_CORE |
| 11231 |
|
| 11232 |
static const char * const _keywords[] = {"path", "follow_symlinks", NULL}; |
| 11233 |
static _PyArg_Parser _parser = { |
| 11234 |
.keywords = _keywords, |
| 11235 |
.fname = "listxattr", |
| 11236 |
.kwtuple = KWTUPLE, |
| 11237 |
}; |
| 11238 |
#undef KWTUPLE |
| 11239 |
PyObject *argsbuf[2]; |
| 11240 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 11241 |
path_t path = PATH_T_INITIALIZE_P("listxattr", "path", 1, 0, 0, 1); |
| 11242 |
int follow_symlinks = 1; |
| 11243 |
|
| 11244 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11245 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11246 |
if (!args) { |
| 11247 |
goto exit; |
| 11248 |
} |
| 11249 |
if (!noptargs) { |
| 11250 |
goto skip_optional_pos; |
| 11251 |
} |
| 11252 |
if (args[0]) { |
| 11253 |
if (!path_converter(args[0], &path)) { |
| 11254 |
goto exit; |
| 11255 |
} |
| 11256 |
if (!--noptargs) { |
| 11257 |
goto skip_optional_pos; |
| 11258 |
} |
| 11259 |
} |
| 11260 |
skip_optional_pos: |
| 11261 |
if (!noptargs) { |
| 11262 |
goto skip_optional_kwonly; |
| 11263 |
} |
| 11264 |
follow_symlinks = PyObject_IsTrue(args[1]); |
| 11265 |
if (follow_symlinks < 0) { |
| 11266 |
goto exit; |
| 11267 |
} |
| 11268 |
skip_optional_kwonly: |
| 11269 |
return_value = os_listxattr_impl(module, &path, follow_symlinks); |
| 11270 |
|
| 11271 |
exit: |
| 11272 |
/* Cleanup for path */ |
| 11273 |
path_cleanup(&path); |
| 11274 |
|
| 11275 |
return return_value; |
| 11276 |
} |
| 11277 |
|
| 11278 |
#endif /* defined(USE_XATTRS) */ |
| 11279 |
|
| 11280 |
PyDoc_STRVAR(os_urandom__doc__, |
| 11281 |
"urandom($module, size, /)\n" |
| 11282 |
"--\n" |
| 11283 |
"\n" |
| 11284 |
"Return a bytes object containing random bytes suitable for cryptographic use."); |
| 11285 |
|
| 11286 |
#define OS_URANDOM_METHODDEF \ |
| 11287 |
{"urandom", (PyCFunction)os_urandom, METH_O, os_urandom__doc__}, |
| 11288 |
|
| 11289 |
static PyObject * |
| 11290 |
os_urandom_impl(PyObject *module, Py_ssize_t size); |
| 11291 |
|
| 11292 |
static PyObject * |
| 11293 |
os_urandom(PyObject *module, PyObject *arg) |
| 11294 |
{ |
| 11295 |
PyObject *return_value = NULL; |
| 11296 |
Py_ssize_t size; |
| 11297 |
|
| 11298 |
{ |
| 11299 |
Py_ssize_t ival = -1; |
| 11300 |
PyObject *iobj = _PyNumber_Index(arg); |
| 11301 |
if (iobj != NULL) { |
| 11302 |
ival = PyLong_AsSsize_t(iobj); |
| 11303 |
Py_DECREF(iobj); |
| 11304 |
} |
| 11305 |
if (ival == -1 && PyErr_Occurred()) { |
| 11306 |
goto exit; |
| 11307 |
} |
| 11308 |
size = ival; |
| 11309 |
} |
| 11310 |
return_value = os_urandom_impl(module, size); |
| 11311 |
|
| 11312 |
exit: |
| 11313 |
return return_value; |
| 11314 |
} |
| 11315 |
|
| 11316 |
#if defined(HAVE_MEMFD_CREATE) |
| 11317 |
|
| 11318 |
PyDoc_STRVAR(os_memfd_create__doc__, |
| 11319 |
"memfd_create($module, /, name, flags=MFD_CLOEXEC)\n" |
| 11320 |
"--\n" |
| 11321 |
"\n"); |
| 11322 |
|
| 11323 |
#define OS_MEMFD_CREATE_METHODDEF \ |
| 11324 |
{"memfd_create", _PyCFunction_CAST(os_memfd_create), METH_FASTCALL|METH_KEYWORDS, os_memfd_create__doc__}, |
| 11325 |
|
| 11326 |
static PyObject * |
| 11327 |
os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags); |
| 11328 |
|
| 11329 |
static PyObject * |
| 11330 |
os_memfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11331 |
{ |
| 11332 |
PyObject *return_value = NULL; |
| 11333 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11334 |
|
| 11335 |
#define NUM_KEYWORDS 2 |
| 11336 |
static struct { |
| 11337 |
PyGC_Head _this_is_not_used; |
| 11338 |
PyObject_VAR_HEAD |
| 11339 |
Py_hash_t ob_hash; |
| 11340 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11341 |
} _kwtuple = { |
| 11342 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11343 |
.ob_hash = -1, |
| 11344 |
.ob_item = { &_Py_ID(name), &_Py_ID(flags), }, |
| 11345 |
}; |
| 11346 |
#undef NUM_KEYWORDS |
| 11347 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11348 |
|
| 11349 |
#else // !Py_BUILD_CORE |
| 11350 |
# define KWTUPLE NULL |
| 11351 |
#endif // !Py_BUILD_CORE |
| 11352 |
|
| 11353 |
static const char * const _keywords[] = {"name", "flags", NULL}; |
| 11354 |
static _PyArg_Parser _parser = { |
| 11355 |
.keywords = _keywords, |
| 11356 |
.fname = "memfd_create", |
| 11357 |
.kwtuple = KWTUPLE, |
| 11358 |
}; |
| 11359 |
#undef KWTUPLE |
| 11360 |
PyObject *argsbuf[2]; |
| 11361 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 11362 |
PyObject *name = NULL; |
| 11363 |
unsigned int flags = MFD_CLOEXEC; |
| 11364 |
|
| 11365 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11366 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11367 |
if (!args) { |
| 11368 |
goto exit; |
| 11369 |
} |
| 11370 |
if (!PyUnicode_FSConverter(args[0], &name)) { |
| 11371 |
goto exit; |
| 11372 |
} |
| 11373 |
if (!noptargs) { |
| 11374 |
goto skip_optional_pos; |
| 11375 |
} |
| 11376 |
flags = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); |
| 11377 |
if (flags == (unsigned int)-1 && PyErr_Occurred()) { |
| 11378 |
goto exit; |
| 11379 |
} |
| 11380 |
skip_optional_pos: |
| 11381 |
return_value = os_memfd_create_impl(module, name, flags); |
| 11382 |
|
| 11383 |
exit: |
| 11384 |
/* Cleanup for name */ |
| 11385 |
Py_XDECREF(name); |
| 11386 |
|
| 11387 |
return return_value; |
| 11388 |
} |
| 11389 |
|
| 11390 |
#endif /* defined(HAVE_MEMFD_CREATE) */ |
| 11391 |
|
| 11392 |
#if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) |
| 11393 |
|
| 11394 |
PyDoc_STRVAR(os_eventfd__doc__, |
| 11395 |
"eventfd($module, /, initval, flags=EFD_CLOEXEC)\n" |
| 11396 |
"--\n" |
| 11397 |
"\n" |
| 11398 |
"Creates and returns an event notification file descriptor."); |
| 11399 |
|
| 11400 |
#define OS_EVENTFD_METHODDEF \ |
| 11401 |
{"eventfd", _PyCFunction_CAST(os_eventfd), METH_FASTCALL|METH_KEYWORDS, os_eventfd__doc__}, |
| 11402 |
|
| 11403 |
static PyObject * |
| 11404 |
os_eventfd_impl(PyObject *module, unsigned int initval, int flags); |
| 11405 |
|
| 11406 |
static PyObject * |
| 11407 |
os_eventfd(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11408 |
{ |
| 11409 |
PyObject *return_value = NULL; |
| 11410 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11411 |
|
| 11412 |
#define NUM_KEYWORDS 2 |
| 11413 |
static struct { |
| 11414 |
PyGC_Head _this_is_not_used; |
| 11415 |
PyObject_VAR_HEAD |
| 11416 |
Py_hash_t ob_hash; |
| 11417 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11418 |
} _kwtuple = { |
| 11419 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11420 |
.ob_hash = -1, |
| 11421 |
.ob_item = { &_Py_ID(initval), &_Py_ID(flags), }, |
| 11422 |
}; |
| 11423 |
#undef NUM_KEYWORDS |
| 11424 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11425 |
|
| 11426 |
#else // !Py_BUILD_CORE |
| 11427 |
# define KWTUPLE NULL |
| 11428 |
#endif // !Py_BUILD_CORE |
| 11429 |
|
| 11430 |
static const char * const _keywords[] = {"initval", "flags", NULL}; |
| 11431 |
static _PyArg_Parser _parser = { |
| 11432 |
.keywords = _keywords, |
| 11433 |
.fname = "eventfd", |
| 11434 |
.kwtuple = KWTUPLE, |
| 11435 |
}; |
| 11436 |
#undef KWTUPLE |
| 11437 |
PyObject *argsbuf[2]; |
| 11438 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 11439 |
unsigned int initval; |
| 11440 |
int flags = EFD_CLOEXEC; |
| 11441 |
|
| 11442 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11443 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11444 |
if (!args) { |
| 11445 |
goto exit; |
| 11446 |
} |
| 11447 |
if (!_PyLong_UnsignedInt_Converter(args[0], &initval)) { |
| 11448 |
goto exit; |
| 11449 |
} |
| 11450 |
if (!noptargs) { |
| 11451 |
goto skip_optional_pos; |
| 11452 |
} |
| 11453 |
flags = PyLong_AsInt(args[1]); |
| 11454 |
if (flags == -1 && PyErr_Occurred()) { |
| 11455 |
goto exit; |
| 11456 |
} |
| 11457 |
skip_optional_pos: |
| 11458 |
return_value = os_eventfd_impl(module, initval, flags); |
| 11459 |
|
| 11460 |
exit: |
| 11461 |
return return_value; |
| 11462 |
} |
| 11463 |
|
| 11464 |
#endif /* (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) */ |
| 11465 |
|
| 11466 |
#if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) |
| 11467 |
|
| 11468 |
PyDoc_STRVAR(os_eventfd_read__doc__, |
| 11469 |
"eventfd_read($module, /, fd)\n" |
| 11470 |
"--\n" |
| 11471 |
"\n" |
| 11472 |
"Read eventfd value"); |
| 11473 |
|
| 11474 |
#define OS_EVENTFD_READ_METHODDEF \ |
| 11475 |
{"eventfd_read", _PyCFunction_CAST(os_eventfd_read), METH_FASTCALL|METH_KEYWORDS, os_eventfd_read__doc__}, |
| 11476 |
|
| 11477 |
static PyObject * |
| 11478 |
os_eventfd_read_impl(PyObject *module, int fd); |
| 11479 |
|
| 11480 |
static PyObject * |
| 11481 |
os_eventfd_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11482 |
{ |
| 11483 |
PyObject *return_value = NULL; |
| 11484 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11485 |
|
| 11486 |
#define NUM_KEYWORDS 1 |
| 11487 |
static struct { |
| 11488 |
PyGC_Head _this_is_not_used; |
| 11489 |
PyObject_VAR_HEAD |
| 11490 |
Py_hash_t ob_hash; |
| 11491 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11492 |
} _kwtuple = { |
| 11493 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11494 |
.ob_hash = -1, |
| 11495 |
.ob_item = { &_Py_ID(fd), }, |
| 11496 |
}; |
| 11497 |
#undef NUM_KEYWORDS |
| 11498 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11499 |
|
| 11500 |
#else // !Py_BUILD_CORE |
| 11501 |
# define KWTUPLE NULL |
| 11502 |
#endif // !Py_BUILD_CORE |
| 11503 |
|
| 11504 |
static const char * const _keywords[] = {"fd", NULL}; |
| 11505 |
static _PyArg_Parser _parser = { |
| 11506 |
.keywords = _keywords, |
| 11507 |
.fname = "eventfd_read", |
| 11508 |
.kwtuple = KWTUPLE, |
| 11509 |
}; |
| 11510 |
#undef KWTUPLE |
| 11511 |
PyObject *argsbuf[1]; |
| 11512 |
int fd; |
| 11513 |
|
| 11514 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11515 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11516 |
if (!args) { |
| 11517 |
goto exit; |
| 11518 |
} |
| 11519 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 11520 |
if (fd < 0) { |
| 11521 |
goto exit; |
| 11522 |
} |
| 11523 |
return_value = os_eventfd_read_impl(module, fd); |
| 11524 |
|
| 11525 |
exit: |
| 11526 |
return return_value; |
| 11527 |
} |
| 11528 |
|
| 11529 |
#endif /* (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) */ |
| 11530 |
|
| 11531 |
#if (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) |
| 11532 |
|
| 11533 |
PyDoc_STRVAR(os_eventfd_write__doc__, |
| 11534 |
"eventfd_write($module, /, fd, value)\n" |
| 11535 |
"--\n" |
| 11536 |
"\n" |
| 11537 |
"Write eventfd value."); |
| 11538 |
|
| 11539 |
#define OS_EVENTFD_WRITE_METHODDEF \ |
| 11540 |
{"eventfd_write", _PyCFunction_CAST(os_eventfd_write), METH_FASTCALL|METH_KEYWORDS, os_eventfd_write__doc__}, |
| 11541 |
|
| 11542 |
static PyObject * |
| 11543 |
os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value); |
| 11544 |
|
| 11545 |
static PyObject * |
| 11546 |
os_eventfd_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11547 |
{ |
| 11548 |
PyObject *return_value = NULL; |
| 11549 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11550 |
|
| 11551 |
#define NUM_KEYWORDS 2 |
| 11552 |
static struct { |
| 11553 |
PyGC_Head _this_is_not_used; |
| 11554 |
PyObject_VAR_HEAD |
| 11555 |
Py_hash_t ob_hash; |
| 11556 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11557 |
} _kwtuple = { |
| 11558 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11559 |
.ob_hash = -1, |
| 11560 |
.ob_item = { &_Py_ID(fd), &_Py_ID(value), }, |
| 11561 |
}; |
| 11562 |
#undef NUM_KEYWORDS |
| 11563 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11564 |
|
| 11565 |
#else // !Py_BUILD_CORE |
| 11566 |
# define KWTUPLE NULL |
| 11567 |
#endif // !Py_BUILD_CORE |
| 11568 |
|
| 11569 |
static const char * const _keywords[] = {"fd", "value", NULL}; |
| 11570 |
static _PyArg_Parser _parser = { |
| 11571 |
.keywords = _keywords, |
| 11572 |
.fname = "eventfd_write", |
| 11573 |
.kwtuple = KWTUPLE, |
| 11574 |
}; |
| 11575 |
#undef KWTUPLE |
| 11576 |
PyObject *argsbuf[2]; |
| 11577 |
int fd; |
| 11578 |
unsigned long long value; |
| 11579 |
|
| 11580 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 11581 |
/*minpos*/ 2, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 11582 |
if (!args) { |
| 11583 |
goto exit; |
| 11584 |
} |
| 11585 |
fd = PyObject_AsFileDescriptor(args[0]); |
| 11586 |
if (fd < 0) { |
| 11587 |
goto exit; |
| 11588 |
} |
| 11589 |
if (!_PyLong_UnsignedLongLong_Converter(args[1], &value)) { |
| 11590 |
goto exit; |
| 11591 |
} |
| 11592 |
return_value = os_eventfd_write_impl(module, fd, value); |
| 11593 |
|
| 11594 |
exit: |
| 11595 |
return return_value; |
| 11596 |
} |
| 11597 |
|
| 11598 |
#endif /* (defined(HAVE_EVENTFD) && defined(EFD_CLOEXEC)) */ |
| 11599 |
|
| 11600 |
#if (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) |
| 11601 |
|
| 11602 |
PyDoc_STRVAR(os_get_terminal_size__doc__, |
| 11603 |
"get_terminal_size($module, fd=<unrepresentable>, /)\n" |
| 11604 |
"--\n" |
| 11605 |
"\n" |
| 11606 |
"Return the size of the terminal window as (columns, lines).\n" |
| 11607 |
"\n" |
| 11608 |
"The optional argument fd (default standard output) specifies\n" |
| 11609 |
"which file descriptor should be queried.\n" |
| 11610 |
"\n" |
| 11611 |
"If the file descriptor is not connected to a terminal, an OSError\n" |
| 11612 |
"is thrown.\n" |
| 11613 |
"\n" |
| 11614 |
"This function will only be defined if an implementation is\n" |
| 11615 |
"available for this system.\n" |
| 11616 |
"\n" |
| 11617 |
"shutil.get_terminal_size is the high-level function which should\n" |
| 11618 |
"normally be used, os.get_terminal_size is the low-level implementation."); |
| 11619 |
|
| 11620 |
#define OS_GET_TERMINAL_SIZE_METHODDEF \ |
| 11621 |
{"get_terminal_size", _PyCFunction_CAST(os_get_terminal_size), METH_FASTCALL, os_get_terminal_size__doc__}, |
| 11622 |
|
| 11623 |
static PyObject * |
| 11624 |
os_get_terminal_size_impl(PyObject *module, int fd); |
| 11625 |
|
| 11626 |
static PyObject * |
| 11627 |
os_get_terminal_size(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 11628 |
{ |
| 11629 |
PyObject *return_value = NULL; |
| 11630 |
int fd = fileno(stdout); |
| 11631 |
|
| 11632 |
if (!_PyArg_CheckPositional("get_terminal_size", nargs, 0, 1)) { |
| 11633 |
goto exit; |
| 11634 |
} |
| 11635 |
if (nargs < 1) { |
| 11636 |
goto skip_optional; |
| 11637 |
} |
| 11638 |
fd = PyLong_AsInt(args[0]); |
| 11639 |
if (fd == -1 && PyErr_Occurred()) { |
| 11640 |
goto exit; |
| 11641 |
} |
| 11642 |
skip_optional: |
| 11643 |
return_value = os_get_terminal_size_impl(module, fd); |
| 11644 |
|
| 11645 |
exit: |
| 11646 |
return return_value; |
| 11647 |
} |
| 11648 |
|
| 11649 |
#endif /* (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) */ |
| 11650 |
|
| 11651 |
PyDoc_STRVAR(os_cpu_count__doc__, |
| 11652 |
"cpu_count($module, /)\n" |
| 11653 |
"--\n" |
| 11654 |
"\n" |
| 11655 |
"Return the number of logical CPUs in the system.\n" |
| 11656 |
"\n" |
| 11657 |
"Return None if indeterminable."); |
| 11658 |
|
| 11659 |
#define OS_CPU_COUNT_METHODDEF \ |
| 11660 |
{"cpu_count", (PyCFunction)os_cpu_count, METH_NOARGS, os_cpu_count__doc__}, |
| 11661 |
|
| 11662 |
static PyObject * |
| 11663 |
os_cpu_count_impl(PyObject *module); |
| 11664 |
|
| 11665 |
static PyObject * |
| 11666 |
os_cpu_count(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 11667 |
{ |
| 11668 |
return os_cpu_count_impl(module); |
| 11669 |
} |
| 11670 |
|
| 11671 |
PyDoc_STRVAR(os_get_inheritable__doc__, |
| 11672 |
"get_inheritable($module, fd, /)\n" |
| 11673 |
"--\n" |
| 11674 |
"\n" |
| 11675 |
"Get the close-on-exe flag of the specified file descriptor."); |
| 11676 |
|
| 11677 |
#define OS_GET_INHERITABLE_METHODDEF \ |
| 11678 |
{"get_inheritable", (PyCFunction)os_get_inheritable, METH_O, os_get_inheritable__doc__}, |
| 11679 |
|
| 11680 |
static int |
| 11681 |
os_get_inheritable_impl(PyObject *module, int fd); |
| 11682 |
|
| 11683 |
static PyObject * |
| 11684 |
os_get_inheritable(PyObject *module, PyObject *arg) |
| 11685 |
{ |
| 11686 |
PyObject *return_value = NULL; |
| 11687 |
int fd; |
| 11688 |
int _return_value; |
| 11689 |
|
| 11690 |
fd = PyLong_AsInt(arg); |
| 11691 |
if (fd == -1 && PyErr_Occurred()) { |
| 11692 |
goto exit; |
| 11693 |
} |
| 11694 |
_return_value = os_get_inheritable_impl(module, fd); |
| 11695 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 11696 |
goto exit; |
| 11697 |
} |
| 11698 |
return_value = PyBool_FromLong((long)_return_value); |
| 11699 |
|
| 11700 |
exit: |
| 11701 |
return return_value; |
| 11702 |
} |
| 11703 |
|
| 11704 |
PyDoc_STRVAR(os_set_inheritable__doc__, |
| 11705 |
"set_inheritable($module, fd, inheritable, /)\n" |
| 11706 |
"--\n" |
| 11707 |
"\n" |
| 11708 |
"Set the inheritable flag of the specified file descriptor."); |
| 11709 |
|
| 11710 |
#define OS_SET_INHERITABLE_METHODDEF \ |
| 11711 |
{"set_inheritable", _PyCFunction_CAST(os_set_inheritable), METH_FASTCALL, os_set_inheritable__doc__}, |
| 11712 |
|
| 11713 |
static PyObject * |
| 11714 |
os_set_inheritable_impl(PyObject *module, int fd, int inheritable); |
| 11715 |
|
| 11716 |
static PyObject * |
| 11717 |
os_set_inheritable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 11718 |
{ |
| 11719 |
PyObject *return_value = NULL; |
| 11720 |
int fd; |
| 11721 |
int inheritable; |
| 11722 |
|
| 11723 |
if (!_PyArg_CheckPositional("set_inheritable", nargs, 2, 2)) { |
| 11724 |
goto exit; |
| 11725 |
} |
| 11726 |
fd = PyLong_AsInt(args[0]); |
| 11727 |
if (fd == -1 && PyErr_Occurred()) { |
| 11728 |
goto exit; |
| 11729 |
} |
| 11730 |
inheritable = PyLong_AsInt(args[1]); |
| 11731 |
if (inheritable == -1 && PyErr_Occurred()) { |
| 11732 |
goto exit; |
| 11733 |
} |
| 11734 |
return_value = os_set_inheritable_impl(module, fd, inheritable); |
| 11735 |
|
| 11736 |
exit: |
| 11737 |
return return_value; |
| 11738 |
} |
| 11739 |
|
| 11740 |
#if defined(MS_WINDOWS) |
| 11741 |
|
| 11742 |
PyDoc_STRVAR(os_get_handle_inheritable__doc__, |
| 11743 |
"get_handle_inheritable($module, handle, /)\n" |
| 11744 |
"--\n" |
| 11745 |
"\n" |
| 11746 |
"Get the close-on-exe flag of the specified file descriptor."); |
| 11747 |
|
| 11748 |
#define OS_GET_HANDLE_INHERITABLE_METHODDEF \ |
| 11749 |
{"get_handle_inheritable", (PyCFunction)os_get_handle_inheritable, METH_O, os_get_handle_inheritable__doc__}, |
| 11750 |
|
| 11751 |
static int |
| 11752 |
os_get_handle_inheritable_impl(PyObject *module, intptr_t handle); |
| 11753 |
|
| 11754 |
static PyObject * |
| 11755 |
os_get_handle_inheritable(PyObject *module, PyObject *arg) |
| 11756 |
{ |
| 11757 |
PyObject *return_value = NULL; |
| 11758 |
intptr_t handle; |
| 11759 |
int _return_value; |
| 11760 |
|
| 11761 |
handle = (intptr_t)PyLong_AsVoidPtr(arg); |
| 11762 |
if (!handle && PyErr_Occurred()) { |
| 11763 |
goto exit; |
| 11764 |
} |
| 11765 |
_return_value = os_get_handle_inheritable_impl(module, handle); |
| 11766 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 11767 |
goto exit; |
| 11768 |
} |
| 11769 |
return_value = PyBool_FromLong((long)_return_value); |
| 11770 |
|
| 11771 |
exit: |
| 11772 |
return return_value; |
| 11773 |
} |
| 11774 |
|
| 11775 |
#endif /* defined(MS_WINDOWS) */ |
| 11776 |
|
| 11777 |
#if defined(MS_WINDOWS) |
| 11778 |
|
| 11779 |
PyDoc_STRVAR(os_set_handle_inheritable__doc__, |
| 11780 |
"set_handle_inheritable($module, handle, inheritable, /)\n" |
| 11781 |
"--\n" |
| 11782 |
"\n" |
| 11783 |
"Set the inheritable flag of the specified handle."); |
| 11784 |
|
| 11785 |
#define OS_SET_HANDLE_INHERITABLE_METHODDEF \ |
| 11786 |
{"set_handle_inheritable", _PyCFunction_CAST(os_set_handle_inheritable), METH_FASTCALL, os_set_handle_inheritable__doc__}, |
| 11787 |
|
| 11788 |
static PyObject * |
| 11789 |
os_set_handle_inheritable_impl(PyObject *module, intptr_t handle, |
| 11790 |
int inheritable); |
| 11791 |
|
| 11792 |
static PyObject * |
| 11793 |
os_set_handle_inheritable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 11794 |
{ |
| 11795 |
PyObject *return_value = NULL; |
| 11796 |
intptr_t handle; |
| 11797 |
int inheritable; |
| 11798 |
|
| 11799 |
if (!_PyArg_CheckPositional("set_handle_inheritable", nargs, 2, 2)) { |
| 11800 |
goto exit; |
| 11801 |
} |
| 11802 |
handle = (intptr_t)PyLong_AsVoidPtr(args[0]); |
| 11803 |
if (!handle && PyErr_Occurred()) { |
| 11804 |
goto exit; |
| 11805 |
} |
| 11806 |
inheritable = PyObject_IsTrue(args[1]); |
| 11807 |
if (inheritable < 0) { |
| 11808 |
goto exit; |
| 11809 |
} |
| 11810 |
return_value = os_set_handle_inheritable_impl(module, handle, inheritable); |
| 11811 |
|
| 11812 |
exit: |
| 11813 |
return return_value; |
| 11814 |
} |
| 11815 |
|
| 11816 |
#endif /* defined(MS_WINDOWS) */ |
| 11817 |
|
| 11818 |
PyDoc_STRVAR(os_get_blocking__doc__, |
| 11819 |
"get_blocking($module, fd, /)\n" |
| 11820 |
"--\n" |
| 11821 |
"\n" |
| 11822 |
"Get the blocking mode of the file descriptor.\n" |
| 11823 |
"\n" |
| 11824 |
"Return False if the O_NONBLOCK flag is set, True if the flag is cleared."); |
| 11825 |
|
| 11826 |
#define OS_GET_BLOCKING_METHODDEF \ |
| 11827 |
{"get_blocking", (PyCFunction)os_get_blocking, METH_O, os_get_blocking__doc__}, |
| 11828 |
|
| 11829 |
static int |
| 11830 |
os_get_blocking_impl(PyObject *module, int fd); |
| 11831 |
|
| 11832 |
static PyObject * |
| 11833 |
os_get_blocking(PyObject *module, PyObject *arg) |
| 11834 |
{ |
| 11835 |
PyObject *return_value = NULL; |
| 11836 |
int fd; |
| 11837 |
int _return_value; |
| 11838 |
|
| 11839 |
fd = PyLong_AsInt(arg); |
| 11840 |
if (fd == -1 && PyErr_Occurred()) { |
| 11841 |
goto exit; |
| 11842 |
} |
| 11843 |
_return_value = os_get_blocking_impl(module, fd); |
| 11844 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 11845 |
goto exit; |
| 11846 |
} |
| 11847 |
return_value = PyBool_FromLong((long)_return_value); |
| 11848 |
|
| 11849 |
exit: |
| 11850 |
return return_value; |
| 11851 |
} |
| 11852 |
|
| 11853 |
PyDoc_STRVAR(os_set_blocking__doc__, |
| 11854 |
"set_blocking($module, fd, blocking, /)\n" |
| 11855 |
"--\n" |
| 11856 |
"\n" |
| 11857 |
"Set the blocking mode of the specified file descriptor.\n" |
| 11858 |
"\n" |
| 11859 |
"Set the O_NONBLOCK flag if blocking is False,\n" |
| 11860 |
"clear the O_NONBLOCK flag otherwise."); |
| 11861 |
|
| 11862 |
#define OS_SET_BLOCKING_METHODDEF \ |
| 11863 |
{"set_blocking", _PyCFunction_CAST(os_set_blocking), METH_FASTCALL, os_set_blocking__doc__}, |
| 11864 |
|
| 11865 |
static PyObject * |
| 11866 |
os_set_blocking_impl(PyObject *module, int fd, int blocking); |
| 11867 |
|
| 11868 |
static PyObject * |
| 11869 |
os_set_blocking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
| 11870 |
{ |
| 11871 |
PyObject *return_value = NULL; |
| 11872 |
int fd; |
| 11873 |
int blocking; |
| 11874 |
|
| 11875 |
if (!_PyArg_CheckPositional("set_blocking", nargs, 2, 2)) { |
| 11876 |
goto exit; |
| 11877 |
} |
| 11878 |
fd = PyLong_AsInt(args[0]); |
| 11879 |
if (fd == -1 && PyErr_Occurred()) { |
| 11880 |
goto exit; |
| 11881 |
} |
| 11882 |
blocking = PyObject_IsTrue(args[1]); |
| 11883 |
if (blocking < 0) { |
| 11884 |
goto exit; |
| 11885 |
} |
| 11886 |
return_value = os_set_blocking_impl(module, fd, blocking); |
| 11887 |
|
| 11888 |
exit: |
| 11889 |
return return_value; |
| 11890 |
} |
| 11891 |
|
| 11892 |
PyDoc_STRVAR(os_DirEntry_is_symlink__doc__, |
| 11893 |
"is_symlink($self, /)\n" |
| 11894 |
"--\n" |
| 11895 |
"\n" |
| 11896 |
"Return True if the entry is a symbolic link; cached per entry."); |
| 11897 |
|
| 11898 |
#define OS_DIRENTRY_IS_SYMLINK_METHODDEF \ |
| 11899 |
{"is_symlink", _PyCFunction_CAST(os_DirEntry_is_symlink), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_symlink__doc__}, |
| 11900 |
|
| 11901 |
static int |
| 11902 |
os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class); |
| 11903 |
|
| 11904 |
static PyObject * |
| 11905 |
os_DirEntry_is_symlink(PyObject *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11906 |
{ |
| 11907 |
PyObject *return_value = NULL; |
| 11908 |
int _return_value; |
| 11909 |
|
| 11910 |
if (nargs || (kwnames && PyTuple_GET_SIZE(kwnames))) { |
| 11911 |
PyErr_SetString(PyExc_TypeError, "is_symlink() takes no arguments"); |
| 11912 |
goto exit; |
| 11913 |
} |
| 11914 |
_return_value = os_DirEntry_is_symlink_impl((DirEntry *)self, defining_class); |
| 11915 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 11916 |
goto exit; |
| 11917 |
} |
| 11918 |
return_value = PyBool_FromLong((long)_return_value); |
| 11919 |
|
| 11920 |
exit: |
| 11921 |
return return_value; |
| 11922 |
} |
| 11923 |
|
| 11924 |
PyDoc_STRVAR(os_DirEntry_is_junction__doc__, |
| 11925 |
"is_junction($self, /)\n" |
| 11926 |
"--\n" |
| 11927 |
"\n" |
| 11928 |
"Return True if the entry is a junction; cached per entry."); |
| 11929 |
|
| 11930 |
#define OS_DIRENTRY_IS_JUNCTION_METHODDEF \ |
| 11931 |
{"is_junction", (PyCFunction)os_DirEntry_is_junction, METH_NOARGS, os_DirEntry_is_junction__doc__}, |
| 11932 |
|
| 11933 |
static int |
| 11934 |
os_DirEntry_is_junction_impl(DirEntry *self); |
| 11935 |
|
| 11936 |
static PyObject * |
| 11937 |
os_DirEntry_is_junction(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 11938 |
{ |
| 11939 |
PyObject *return_value = NULL; |
| 11940 |
int _return_value; |
| 11941 |
|
| 11942 |
_return_value = os_DirEntry_is_junction_impl((DirEntry *)self); |
| 11943 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 11944 |
goto exit; |
| 11945 |
} |
| 11946 |
return_value = PyBool_FromLong((long)_return_value); |
| 11947 |
|
| 11948 |
exit: |
| 11949 |
return return_value; |
| 11950 |
} |
| 11951 |
|
| 11952 |
PyDoc_STRVAR(os_DirEntry_stat__doc__, |
| 11953 |
"stat($self, /, *, follow_symlinks=True)\n" |
| 11954 |
"--\n" |
| 11955 |
"\n" |
| 11956 |
"Return stat_result object for the entry; cached per entry."); |
| 11957 |
|
| 11958 |
#define OS_DIRENTRY_STAT_METHODDEF \ |
| 11959 |
{"stat", _PyCFunction_CAST(os_DirEntry_stat), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_stat__doc__}, |
| 11960 |
|
| 11961 |
static PyObject * |
| 11962 |
os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class, |
| 11963 |
int follow_symlinks); |
| 11964 |
|
| 11965 |
static PyObject * |
| 11966 |
os_DirEntry_stat(PyObject *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 11967 |
{ |
| 11968 |
PyObject *return_value = NULL; |
| 11969 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 11970 |
|
| 11971 |
#define NUM_KEYWORDS 1 |
| 11972 |
static struct { |
| 11973 |
PyGC_Head _this_is_not_used; |
| 11974 |
PyObject_VAR_HEAD |
| 11975 |
Py_hash_t ob_hash; |
| 11976 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 11977 |
} _kwtuple = { |
| 11978 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 11979 |
.ob_hash = -1, |
| 11980 |
.ob_item = { &_Py_ID(follow_symlinks), }, |
| 11981 |
}; |
| 11982 |
#undef NUM_KEYWORDS |
| 11983 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 11984 |
|
| 11985 |
#else // !Py_BUILD_CORE |
| 11986 |
# define KWTUPLE NULL |
| 11987 |
#endif // !Py_BUILD_CORE |
| 11988 |
|
| 11989 |
static const char * const _keywords[] = {"follow_symlinks", NULL}; |
| 11990 |
static _PyArg_Parser _parser = { |
| 11991 |
.keywords = _keywords, |
| 11992 |
.fname = "stat", |
| 11993 |
.kwtuple = KWTUPLE, |
| 11994 |
}; |
| 11995 |
#undef KWTUPLE |
| 11996 |
PyObject *argsbuf[1]; |
| 11997 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 11998 |
int follow_symlinks = 1; |
| 11999 |
|
| 12000 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12001 |
/*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12002 |
if (!args) { |
| 12003 |
goto exit; |
| 12004 |
} |
| 12005 |
if (!noptargs) { |
| 12006 |
goto skip_optional_kwonly; |
| 12007 |
} |
| 12008 |
follow_symlinks = PyObject_IsTrue(args[0]); |
| 12009 |
if (follow_symlinks < 0) { |
| 12010 |
goto exit; |
| 12011 |
} |
| 12012 |
skip_optional_kwonly: |
| 12013 |
return_value = os_DirEntry_stat_impl((DirEntry *)self, defining_class, follow_symlinks); |
| 12014 |
|
| 12015 |
exit: |
| 12016 |
return return_value; |
| 12017 |
} |
| 12018 |
|
| 12019 |
PyDoc_STRVAR(os_DirEntry_is_dir__doc__, |
| 12020 |
"is_dir($self, /, *, follow_symlinks=True)\n" |
| 12021 |
"--\n" |
| 12022 |
"\n" |
| 12023 |
"Return True if the entry is a directory; cached per entry."); |
| 12024 |
|
| 12025 |
#define OS_DIRENTRY_IS_DIR_METHODDEF \ |
| 12026 |
{"is_dir", _PyCFunction_CAST(os_DirEntry_is_dir), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_dir__doc__}, |
| 12027 |
|
| 12028 |
static int |
| 12029 |
os_DirEntry_is_dir_impl(DirEntry *self, PyTypeObject *defining_class, |
| 12030 |
int follow_symlinks); |
| 12031 |
|
| 12032 |
static PyObject * |
| 12033 |
os_DirEntry_is_dir(PyObject *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12034 |
{ |
| 12035 |
PyObject *return_value = NULL; |
| 12036 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12037 |
|
| 12038 |
#define NUM_KEYWORDS 1 |
| 12039 |
static struct { |
| 12040 |
PyGC_Head _this_is_not_used; |
| 12041 |
PyObject_VAR_HEAD |
| 12042 |
Py_hash_t ob_hash; |
| 12043 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12044 |
} _kwtuple = { |
| 12045 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12046 |
.ob_hash = -1, |
| 12047 |
.ob_item = { &_Py_ID(follow_symlinks), }, |
| 12048 |
}; |
| 12049 |
#undef NUM_KEYWORDS |
| 12050 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12051 |
|
| 12052 |
#else // !Py_BUILD_CORE |
| 12053 |
# define KWTUPLE NULL |
| 12054 |
#endif // !Py_BUILD_CORE |
| 12055 |
|
| 12056 |
static const char * const _keywords[] = {"follow_symlinks", NULL}; |
| 12057 |
static _PyArg_Parser _parser = { |
| 12058 |
.keywords = _keywords, |
| 12059 |
.fname = "is_dir", |
| 12060 |
.kwtuple = KWTUPLE, |
| 12061 |
}; |
| 12062 |
#undef KWTUPLE |
| 12063 |
PyObject *argsbuf[1]; |
| 12064 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 12065 |
int follow_symlinks = 1; |
| 12066 |
int _return_value; |
| 12067 |
|
| 12068 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12069 |
/*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12070 |
if (!args) { |
| 12071 |
goto exit; |
| 12072 |
} |
| 12073 |
if (!noptargs) { |
| 12074 |
goto skip_optional_kwonly; |
| 12075 |
} |
| 12076 |
follow_symlinks = PyObject_IsTrue(args[0]); |
| 12077 |
if (follow_symlinks < 0) { |
| 12078 |
goto exit; |
| 12079 |
} |
| 12080 |
skip_optional_kwonly: |
| 12081 |
_return_value = os_DirEntry_is_dir_impl((DirEntry *)self, defining_class, follow_symlinks); |
| 12082 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 12083 |
goto exit; |
| 12084 |
} |
| 12085 |
return_value = PyBool_FromLong((long)_return_value); |
| 12086 |
|
| 12087 |
exit: |
| 12088 |
return return_value; |
| 12089 |
} |
| 12090 |
|
| 12091 |
PyDoc_STRVAR(os_DirEntry_is_file__doc__, |
| 12092 |
"is_file($self, /, *, follow_symlinks=True)\n" |
| 12093 |
"--\n" |
| 12094 |
"\n" |
| 12095 |
"Return True if the entry is a file; cached per entry."); |
| 12096 |
|
| 12097 |
#define OS_DIRENTRY_IS_FILE_METHODDEF \ |
| 12098 |
{"is_file", _PyCFunction_CAST(os_DirEntry_is_file), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_file__doc__}, |
| 12099 |
|
| 12100 |
static int |
| 12101 |
os_DirEntry_is_file_impl(DirEntry *self, PyTypeObject *defining_class, |
| 12102 |
int follow_symlinks); |
| 12103 |
|
| 12104 |
static PyObject * |
| 12105 |
os_DirEntry_is_file(PyObject *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12106 |
{ |
| 12107 |
PyObject *return_value = NULL; |
| 12108 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12109 |
|
| 12110 |
#define NUM_KEYWORDS 1 |
| 12111 |
static struct { |
| 12112 |
PyGC_Head _this_is_not_used; |
| 12113 |
PyObject_VAR_HEAD |
| 12114 |
Py_hash_t ob_hash; |
| 12115 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12116 |
} _kwtuple = { |
| 12117 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12118 |
.ob_hash = -1, |
| 12119 |
.ob_item = { &_Py_ID(follow_symlinks), }, |
| 12120 |
}; |
| 12121 |
#undef NUM_KEYWORDS |
| 12122 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12123 |
|
| 12124 |
#else // !Py_BUILD_CORE |
| 12125 |
# define KWTUPLE NULL |
| 12126 |
#endif // !Py_BUILD_CORE |
| 12127 |
|
| 12128 |
static const char * const _keywords[] = {"follow_symlinks", NULL}; |
| 12129 |
static _PyArg_Parser _parser = { |
| 12130 |
.keywords = _keywords, |
| 12131 |
.fname = "is_file", |
| 12132 |
.kwtuple = KWTUPLE, |
| 12133 |
}; |
| 12134 |
#undef KWTUPLE |
| 12135 |
PyObject *argsbuf[1]; |
| 12136 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 12137 |
int follow_symlinks = 1; |
| 12138 |
int _return_value; |
| 12139 |
|
| 12140 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12141 |
/*minpos*/ 0, /*maxpos*/ 0, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12142 |
if (!args) { |
| 12143 |
goto exit; |
| 12144 |
} |
| 12145 |
if (!noptargs) { |
| 12146 |
goto skip_optional_kwonly; |
| 12147 |
} |
| 12148 |
follow_symlinks = PyObject_IsTrue(args[0]); |
| 12149 |
if (follow_symlinks < 0) { |
| 12150 |
goto exit; |
| 12151 |
} |
| 12152 |
skip_optional_kwonly: |
| 12153 |
_return_value = os_DirEntry_is_file_impl((DirEntry *)self, defining_class, follow_symlinks); |
| 12154 |
if ((_return_value == -1) && PyErr_Occurred()) { |
| 12155 |
goto exit; |
| 12156 |
} |
| 12157 |
return_value = PyBool_FromLong((long)_return_value); |
| 12158 |
|
| 12159 |
exit: |
| 12160 |
return return_value; |
| 12161 |
} |
| 12162 |
|
| 12163 |
PyDoc_STRVAR(os_DirEntry_inode__doc__, |
| 12164 |
"inode($self, /)\n" |
| 12165 |
"--\n" |
| 12166 |
"\n" |
| 12167 |
"Return inode of the entry; cached per entry."); |
| 12168 |
|
| 12169 |
#define OS_DIRENTRY_INODE_METHODDEF \ |
| 12170 |
{"inode", (PyCFunction)os_DirEntry_inode, METH_NOARGS, os_DirEntry_inode__doc__}, |
| 12171 |
|
| 12172 |
static PyObject * |
| 12173 |
os_DirEntry_inode_impl(DirEntry *self); |
| 12174 |
|
| 12175 |
static PyObject * |
| 12176 |
os_DirEntry_inode(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 12177 |
{ |
| 12178 |
return os_DirEntry_inode_impl((DirEntry *)self); |
| 12179 |
} |
| 12180 |
|
| 12181 |
PyDoc_STRVAR(os_DirEntry___fspath____doc__, |
| 12182 |
"__fspath__($self, /)\n" |
| 12183 |
"--\n" |
| 12184 |
"\n" |
| 12185 |
"Returns the path for the entry."); |
| 12186 |
|
| 12187 |
#define OS_DIRENTRY___FSPATH___METHODDEF \ |
| 12188 |
{"__fspath__", (PyCFunction)os_DirEntry___fspath__, METH_NOARGS, os_DirEntry___fspath____doc__}, |
| 12189 |
|
| 12190 |
static PyObject * |
| 12191 |
os_DirEntry___fspath___impl(DirEntry *self); |
| 12192 |
|
| 12193 |
static PyObject * |
| 12194 |
os_DirEntry___fspath__(PyObject *self, PyObject *Py_UNUSED(ignored)) |
| 12195 |
{ |
| 12196 |
return os_DirEntry___fspath___impl((DirEntry *)self); |
| 12197 |
} |
| 12198 |
|
| 12199 |
PyDoc_STRVAR(os_scandir__doc__, |
| 12200 |
"scandir($module, /, path=None)\n" |
| 12201 |
"--\n" |
| 12202 |
"\n" |
| 12203 |
"Return an iterator of DirEntry objects for given path.\n" |
| 12204 |
"\n" |
| 12205 |
"path can be specified as either str, bytes, or a path-like object. If path\n" |
| 12206 |
"is bytes, the names of yielded DirEntry objects will also be bytes; in\n" |
| 12207 |
"all other circumstances they will be str.\n" |
| 12208 |
"\n" |
| 12209 |
"If path is None, uses the path=\'.\'."); |
| 12210 |
|
| 12211 |
#define OS_SCANDIR_METHODDEF \ |
| 12212 |
{"scandir", _PyCFunction_CAST(os_scandir), METH_FASTCALL|METH_KEYWORDS, os_scandir__doc__}, |
| 12213 |
|
| 12214 |
static PyObject * |
| 12215 |
os_scandir_impl(PyObject *module, path_t *path); |
| 12216 |
|
| 12217 |
static PyObject * |
| 12218 |
os_scandir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12219 |
{ |
| 12220 |
PyObject *return_value = NULL; |
| 12221 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12222 |
|
| 12223 |
#define NUM_KEYWORDS 1 |
| 12224 |
static struct { |
| 12225 |
PyGC_Head _this_is_not_used; |
| 12226 |
PyObject_VAR_HEAD |
| 12227 |
Py_hash_t ob_hash; |
| 12228 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12229 |
} _kwtuple = { |
| 12230 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12231 |
.ob_hash = -1, |
| 12232 |
.ob_item = { &_Py_ID(path), }, |
| 12233 |
}; |
| 12234 |
#undef NUM_KEYWORDS |
| 12235 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12236 |
|
| 12237 |
#else // !Py_BUILD_CORE |
| 12238 |
# define KWTUPLE NULL |
| 12239 |
#endif // !Py_BUILD_CORE |
| 12240 |
|
| 12241 |
static const char * const _keywords[] = {"path", NULL}; |
| 12242 |
static _PyArg_Parser _parser = { |
| 12243 |
.keywords = _keywords, |
| 12244 |
.fname = "scandir", |
| 12245 |
.kwtuple = KWTUPLE, |
| 12246 |
}; |
| 12247 |
#undef KWTUPLE |
| 12248 |
PyObject *argsbuf[1]; |
| 12249 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0; |
| 12250 |
path_t path = PATH_T_INITIALIZE_P("scandir", "path", 1, 0, 0, PATH_HAVE_FDOPENDIR); |
| 12251 |
|
| 12252 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12253 |
/*minpos*/ 0, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12254 |
if (!args) { |
| 12255 |
goto exit; |
| 12256 |
} |
| 12257 |
if (!noptargs) { |
| 12258 |
goto skip_optional_pos; |
| 12259 |
} |
| 12260 |
if (!path_converter(args[0], &path)) { |
| 12261 |
goto exit; |
| 12262 |
} |
| 12263 |
skip_optional_pos: |
| 12264 |
return_value = os_scandir_impl(module, &path); |
| 12265 |
|
| 12266 |
exit: |
| 12267 |
/* Cleanup for path */ |
| 12268 |
path_cleanup(&path); |
| 12269 |
|
| 12270 |
return return_value; |
| 12271 |
} |
| 12272 |
|
| 12273 |
PyDoc_STRVAR(os_fspath__doc__, |
| 12274 |
"fspath($module, /, path)\n" |
| 12275 |
"--\n" |
| 12276 |
"\n" |
| 12277 |
"Return the file system path representation of the object.\n" |
| 12278 |
"\n" |
| 12279 |
"If the object is str or bytes, then allow it to pass through as-is. If the\n" |
| 12280 |
"object defines __fspath__(), then return the result of that method. All other\n" |
| 12281 |
"types raise a TypeError."); |
| 12282 |
|
| 12283 |
#define OS_FSPATH_METHODDEF \ |
| 12284 |
{"fspath", _PyCFunction_CAST(os_fspath), METH_FASTCALL|METH_KEYWORDS, os_fspath__doc__}, |
| 12285 |
|
| 12286 |
static PyObject * |
| 12287 |
os_fspath_impl(PyObject *module, PyObject *path); |
| 12288 |
|
| 12289 |
static PyObject * |
| 12290 |
os_fspath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12291 |
{ |
| 12292 |
PyObject *return_value = NULL; |
| 12293 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12294 |
|
| 12295 |
#define NUM_KEYWORDS 1 |
| 12296 |
static struct { |
| 12297 |
PyGC_Head _this_is_not_used; |
| 12298 |
PyObject_VAR_HEAD |
| 12299 |
Py_hash_t ob_hash; |
| 12300 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12301 |
} _kwtuple = { |
| 12302 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12303 |
.ob_hash = -1, |
| 12304 |
.ob_item = { &_Py_ID(path), }, |
| 12305 |
}; |
| 12306 |
#undef NUM_KEYWORDS |
| 12307 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12308 |
|
| 12309 |
#else // !Py_BUILD_CORE |
| 12310 |
# define KWTUPLE NULL |
| 12311 |
#endif // !Py_BUILD_CORE |
| 12312 |
|
| 12313 |
static const char * const _keywords[] = {"path", NULL}; |
| 12314 |
static _PyArg_Parser _parser = { |
| 12315 |
.keywords = _keywords, |
| 12316 |
.fname = "fspath", |
| 12317 |
.kwtuple = KWTUPLE, |
| 12318 |
}; |
| 12319 |
#undef KWTUPLE |
| 12320 |
PyObject *argsbuf[1]; |
| 12321 |
PyObject *path; |
| 12322 |
|
| 12323 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12324 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12325 |
if (!args) { |
| 12326 |
goto exit; |
| 12327 |
} |
| 12328 |
path = args[0]; |
| 12329 |
return_value = os_fspath_impl(module, path); |
| 12330 |
|
| 12331 |
exit: |
| 12332 |
return return_value; |
| 12333 |
} |
| 12334 |
|
| 12335 |
#if defined(HAVE_GETRANDOM_SYSCALL) |
| 12336 |
|
| 12337 |
PyDoc_STRVAR(os_getrandom__doc__, |
| 12338 |
"getrandom($module, /, size, flags=0)\n" |
| 12339 |
"--\n" |
| 12340 |
"\n" |
| 12341 |
"Obtain a series of random bytes."); |
| 12342 |
|
| 12343 |
#define OS_GETRANDOM_METHODDEF \ |
| 12344 |
{"getrandom", _PyCFunction_CAST(os_getrandom), METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, |
| 12345 |
|
| 12346 |
static PyObject * |
| 12347 |
os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags); |
| 12348 |
|
| 12349 |
static PyObject * |
| 12350 |
os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12351 |
{ |
| 12352 |
PyObject *return_value = NULL; |
| 12353 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12354 |
|
| 12355 |
#define NUM_KEYWORDS 2 |
| 12356 |
static struct { |
| 12357 |
PyGC_Head _this_is_not_used; |
| 12358 |
PyObject_VAR_HEAD |
| 12359 |
Py_hash_t ob_hash; |
| 12360 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12361 |
} _kwtuple = { |
| 12362 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12363 |
.ob_hash = -1, |
| 12364 |
.ob_item = { &_Py_ID(size), &_Py_ID(flags), }, |
| 12365 |
}; |
| 12366 |
#undef NUM_KEYWORDS |
| 12367 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12368 |
|
| 12369 |
#else // !Py_BUILD_CORE |
| 12370 |
# define KWTUPLE NULL |
| 12371 |
#endif // !Py_BUILD_CORE |
| 12372 |
|
| 12373 |
static const char * const _keywords[] = {"size", "flags", NULL}; |
| 12374 |
static _PyArg_Parser _parser = { |
| 12375 |
.keywords = _keywords, |
| 12376 |
.fname = "getrandom", |
| 12377 |
.kwtuple = KWTUPLE, |
| 12378 |
}; |
| 12379 |
#undef KWTUPLE |
| 12380 |
PyObject *argsbuf[2]; |
| 12381 |
Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
| 12382 |
Py_ssize_t size; |
| 12383 |
int flags = 0; |
| 12384 |
|
| 12385 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12386 |
/*minpos*/ 1, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12387 |
if (!args) { |
| 12388 |
goto exit; |
| 12389 |
} |
| 12390 |
{ |
| 12391 |
Py_ssize_t ival = -1; |
| 12392 |
PyObject *iobj = _PyNumber_Index(args[0]); |
| 12393 |
if (iobj != NULL) { |
| 12394 |
ival = PyLong_AsSsize_t(iobj); |
| 12395 |
Py_DECREF(iobj); |
| 12396 |
} |
| 12397 |
if (ival == -1 && PyErr_Occurred()) { |
| 12398 |
goto exit; |
| 12399 |
} |
| 12400 |
size = ival; |
| 12401 |
} |
| 12402 |
if (!noptargs) { |
| 12403 |
goto skip_optional_pos; |
| 12404 |
} |
| 12405 |
flags = PyLong_AsInt(args[1]); |
| 12406 |
if (flags == -1 && PyErr_Occurred()) { |
| 12407 |
goto exit; |
| 12408 |
} |
| 12409 |
skip_optional_pos: |
| 12410 |
return_value = os_getrandom_impl(module, size, flags); |
| 12411 |
|
| 12412 |
exit: |
| 12413 |
return return_value; |
| 12414 |
} |
| 12415 |
|
| 12416 |
#endif /* defined(HAVE_GETRANDOM_SYSCALL) */ |
| 12417 |
|
| 12418 |
#if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) |
| 12419 |
|
| 12420 |
PyDoc_STRVAR(os__add_dll_directory__doc__, |
| 12421 |
"_add_dll_directory($module, /, path)\n" |
| 12422 |
"--\n" |
| 12423 |
"\n" |
| 12424 |
"Add a path to the DLL search path.\n" |
| 12425 |
"\n" |
| 12426 |
"This search path is used when resolving dependencies for imported\n" |
| 12427 |
"extension modules (the module itself is resolved through sys.path),\n" |
| 12428 |
"and also by ctypes.\n" |
| 12429 |
"\n" |
| 12430 |
"Returns an opaque value that may be passed to os.remove_dll_directory\n" |
| 12431 |
"to remove this directory from the search path."); |
| 12432 |
|
| 12433 |
#define OS__ADD_DLL_DIRECTORY_METHODDEF \ |
| 12434 |
{"_add_dll_directory", _PyCFunction_CAST(os__add_dll_directory), METH_FASTCALL|METH_KEYWORDS, os__add_dll_directory__doc__}, |
| 12435 |
|
| 12436 |
static PyObject * |
| 12437 |
os__add_dll_directory_impl(PyObject *module, path_t *path); |
| 12438 |
|
| 12439 |
static PyObject * |
| 12440 |
os__add_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12441 |
{ |
| 12442 |
PyObject *return_value = NULL; |
| 12443 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12444 |
|
| 12445 |
#define NUM_KEYWORDS 1 |
| 12446 |
static struct { |
| 12447 |
PyGC_Head _this_is_not_used; |
| 12448 |
PyObject_VAR_HEAD |
| 12449 |
Py_hash_t ob_hash; |
| 12450 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12451 |
} _kwtuple = { |
| 12452 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12453 |
.ob_hash = -1, |
| 12454 |
.ob_item = { &_Py_ID(path), }, |
| 12455 |
}; |
| 12456 |
#undef NUM_KEYWORDS |
| 12457 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12458 |
|
| 12459 |
#else // !Py_BUILD_CORE |
| 12460 |
# define KWTUPLE NULL |
| 12461 |
#endif // !Py_BUILD_CORE |
| 12462 |
|
| 12463 |
static const char * const _keywords[] = {"path", NULL}; |
| 12464 |
static _PyArg_Parser _parser = { |
| 12465 |
.keywords = _keywords, |
| 12466 |
.fname = "_add_dll_directory", |
| 12467 |
.kwtuple = KWTUPLE, |
| 12468 |
}; |
| 12469 |
#undef KWTUPLE |
| 12470 |
PyObject *argsbuf[1]; |
| 12471 |
path_t path = PATH_T_INITIALIZE_P("_add_dll_directory", "path", 0, 0, 0, 0); |
| 12472 |
|
| 12473 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12474 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12475 |
if (!args) { |
| 12476 |
goto exit; |
| 12477 |
} |
| 12478 |
if (!path_converter(args[0], &path)) { |
| 12479 |
goto exit; |
| 12480 |
} |
| 12481 |
return_value = os__add_dll_directory_impl(module, &path); |
| 12482 |
|
| 12483 |
exit: |
| 12484 |
/* Cleanup for path */ |
| 12485 |
path_cleanup(&path); |
| 12486 |
|
| 12487 |
return return_value; |
| 12488 |
} |
| 12489 |
|
| 12490 |
#endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) */ |
| 12491 |
|
| 12492 |
#if (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) |
| 12493 |
|
| 12494 |
PyDoc_STRVAR(os__remove_dll_directory__doc__, |
| 12495 |
"_remove_dll_directory($module, /, cookie)\n" |
| 12496 |
"--\n" |
| 12497 |
"\n" |
| 12498 |
"Removes a path from the DLL search path.\n" |
| 12499 |
"\n" |
| 12500 |
"The parameter is an opaque value that was returned from\n" |
| 12501 |
"os.add_dll_directory. You can only remove directories that you added\n" |
| 12502 |
"yourself."); |
| 12503 |
|
| 12504 |
#define OS__REMOVE_DLL_DIRECTORY_METHODDEF \ |
| 12505 |
{"_remove_dll_directory", _PyCFunction_CAST(os__remove_dll_directory), METH_FASTCALL|METH_KEYWORDS, os__remove_dll_directory__doc__}, |
| 12506 |
|
| 12507 |
static PyObject * |
| 12508 |
os__remove_dll_directory_impl(PyObject *module, PyObject *cookie); |
| 12509 |
|
| 12510 |
static PyObject * |
| 12511 |
os__remove_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12512 |
{ |
| 12513 |
PyObject *return_value = NULL; |
| 12514 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12515 |
|
| 12516 |
#define NUM_KEYWORDS 1 |
| 12517 |
static struct { |
| 12518 |
PyGC_Head _this_is_not_used; |
| 12519 |
PyObject_VAR_HEAD |
| 12520 |
Py_hash_t ob_hash; |
| 12521 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12522 |
} _kwtuple = { |
| 12523 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12524 |
.ob_hash = -1, |
| 12525 |
.ob_item = { &_Py_ID(cookie), }, |
| 12526 |
}; |
| 12527 |
#undef NUM_KEYWORDS |
| 12528 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12529 |
|
| 12530 |
#else // !Py_BUILD_CORE |
| 12531 |
# define KWTUPLE NULL |
| 12532 |
#endif // !Py_BUILD_CORE |
| 12533 |
|
| 12534 |
static const char * const _keywords[] = {"cookie", NULL}; |
| 12535 |
static _PyArg_Parser _parser = { |
| 12536 |
.keywords = _keywords, |
| 12537 |
.fname = "_remove_dll_directory", |
| 12538 |
.kwtuple = KWTUPLE, |
| 12539 |
}; |
| 12540 |
#undef KWTUPLE |
| 12541 |
PyObject *argsbuf[1]; |
| 12542 |
PyObject *cookie; |
| 12543 |
|
| 12544 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12545 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12546 |
if (!args) { |
| 12547 |
goto exit; |
| 12548 |
} |
| 12549 |
cookie = args[0]; |
| 12550 |
return_value = os__remove_dll_directory_impl(module, cookie); |
| 12551 |
|
| 12552 |
exit: |
| 12553 |
return return_value; |
| 12554 |
} |
| 12555 |
|
| 12556 |
#endif /* (defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)) */ |
| 12557 |
|
| 12558 |
#if (defined(WIFEXITED) || defined(MS_WINDOWS)) |
| 12559 |
|
| 12560 |
PyDoc_STRVAR(os_waitstatus_to_exitcode__doc__, |
| 12561 |
"waitstatus_to_exitcode($module, /, status)\n" |
| 12562 |
"--\n" |
| 12563 |
"\n" |
| 12564 |
"Convert a wait status to an exit code.\n" |
| 12565 |
"\n" |
| 12566 |
"On Unix:\n" |
| 12567 |
"\n" |
| 12568 |
"* If WIFEXITED(status) is true, return WEXITSTATUS(status).\n" |
| 12569 |
"* If WIFSIGNALED(status) is true, return -WTERMSIG(status).\n" |
| 12570 |
"* Otherwise, raise a ValueError.\n" |
| 12571 |
"\n" |
| 12572 |
"On Windows, return status shifted right by 8 bits.\n" |
| 12573 |
"\n" |
| 12574 |
"On Unix, if the process is being traced or if waitpid() was called with\n" |
| 12575 |
"WUNTRACED option, the caller must first check if WIFSTOPPED(status) is true.\n" |
| 12576 |
"This function must not be called if WIFSTOPPED(status) is true."); |
| 12577 |
|
| 12578 |
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF \ |
| 12579 |
{"waitstatus_to_exitcode", _PyCFunction_CAST(os_waitstatus_to_exitcode), METH_FASTCALL|METH_KEYWORDS, os_waitstatus_to_exitcode__doc__}, |
| 12580 |
|
| 12581 |
static PyObject * |
| 12582 |
os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj); |
| 12583 |
|
| 12584 |
static PyObject * |
| 12585 |
os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12586 |
{ |
| 12587 |
PyObject *return_value = NULL; |
| 12588 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12589 |
|
| 12590 |
#define NUM_KEYWORDS 1 |
| 12591 |
static struct { |
| 12592 |
PyGC_Head _this_is_not_used; |
| 12593 |
PyObject_VAR_HEAD |
| 12594 |
Py_hash_t ob_hash; |
| 12595 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12596 |
} _kwtuple = { |
| 12597 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12598 |
.ob_hash = -1, |
| 12599 |
.ob_item = { &_Py_ID(status), }, |
| 12600 |
}; |
| 12601 |
#undef NUM_KEYWORDS |
| 12602 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12603 |
|
| 12604 |
#else // !Py_BUILD_CORE |
| 12605 |
# define KWTUPLE NULL |
| 12606 |
#endif // !Py_BUILD_CORE |
| 12607 |
|
| 12608 |
static const char * const _keywords[] = {"status", NULL}; |
| 12609 |
static _PyArg_Parser _parser = { |
| 12610 |
.keywords = _keywords, |
| 12611 |
.fname = "waitstatus_to_exitcode", |
| 12612 |
.kwtuple = KWTUPLE, |
| 12613 |
}; |
| 12614 |
#undef KWTUPLE |
| 12615 |
PyObject *argsbuf[1]; |
| 12616 |
PyObject *status_obj; |
| 12617 |
|
| 12618 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12619 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12620 |
if (!args) { |
| 12621 |
goto exit; |
| 12622 |
} |
| 12623 |
status_obj = args[0]; |
| 12624 |
return_value = os_waitstatus_to_exitcode_impl(module, status_obj); |
| 12625 |
|
| 12626 |
exit: |
| 12627 |
return return_value; |
| 12628 |
} |
| 12629 |
|
| 12630 |
#endif /* (defined(WIFEXITED) || defined(MS_WINDOWS)) */ |
| 12631 |
|
| 12632 |
#if defined(MS_WINDOWS) |
| 12633 |
|
| 12634 |
PyDoc_STRVAR(os__supports_virtual_terminal__doc__, |
| 12635 |
"_supports_virtual_terminal($module, /)\n" |
| 12636 |
"--\n" |
| 12637 |
"\n" |
| 12638 |
"Checks if virtual terminal is supported in windows"); |
| 12639 |
|
| 12640 |
#define OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF \ |
| 12641 |
{"_supports_virtual_terminal", (PyCFunction)os__supports_virtual_terminal, METH_NOARGS, os__supports_virtual_terminal__doc__}, |
| 12642 |
|
| 12643 |
static PyObject * |
| 12644 |
os__supports_virtual_terminal_impl(PyObject *module); |
| 12645 |
|
| 12646 |
static PyObject * |
| 12647 |
os__supports_virtual_terminal(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 12648 |
{ |
| 12649 |
return os__supports_virtual_terminal_impl(module); |
| 12650 |
} |
| 12651 |
|
| 12652 |
#endif /* defined(MS_WINDOWS) */ |
| 12653 |
|
| 12654 |
PyDoc_STRVAR(os__inputhook__doc__, |
| 12655 |
"_inputhook($module, /)\n" |
| 12656 |
"--\n" |
| 12657 |
"\n" |
| 12658 |
"Calls PyOS_CallInputHook droppong the GIL first"); |
| 12659 |
|
| 12660 |
#define OS__INPUTHOOK_METHODDEF \ |
| 12661 |
{"_inputhook", (PyCFunction)os__inputhook, METH_NOARGS, os__inputhook__doc__}, |
| 12662 |
|
| 12663 |
static PyObject * |
| 12664 |
os__inputhook_impl(PyObject *module); |
| 12665 |
|
| 12666 |
static PyObject * |
| 12667 |
os__inputhook(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 12668 |
{ |
| 12669 |
return os__inputhook_impl(module); |
| 12670 |
} |
| 12671 |
|
| 12672 |
PyDoc_STRVAR(os__is_inputhook_installed__doc__, |
| 12673 |
"_is_inputhook_installed($module, /)\n" |
| 12674 |
"--\n" |
| 12675 |
"\n" |
| 12676 |
"Checks if PyOS_CallInputHook is set"); |
| 12677 |
|
| 12678 |
#define OS__IS_INPUTHOOK_INSTALLED_METHODDEF \ |
| 12679 |
{"_is_inputhook_installed", (PyCFunction)os__is_inputhook_installed, METH_NOARGS, os__is_inputhook_installed__doc__}, |
| 12680 |
|
| 12681 |
static PyObject * |
| 12682 |
os__is_inputhook_installed_impl(PyObject *module); |
| 12683 |
|
| 12684 |
static PyObject * |
| 12685 |
os__is_inputhook_installed(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 12686 |
{ |
| 12687 |
return os__is_inputhook_installed_impl(module); |
| 12688 |
} |
| 12689 |
|
| 12690 |
PyDoc_STRVAR(os__create_environ__doc__, |
| 12691 |
"_create_environ($module, /)\n" |
| 12692 |
"--\n" |
| 12693 |
"\n" |
| 12694 |
"Create the environment dictionary."); |
| 12695 |
|
| 12696 |
#define OS__CREATE_ENVIRON_METHODDEF \ |
| 12697 |
{"_create_environ", (PyCFunction)os__create_environ, METH_NOARGS, os__create_environ__doc__}, |
| 12698 |
|
| 12699 |
static PyObject * |
| 12700 |
os__create_environ_impl(PyObject *module); |
| 12701 |
|
| 12702 |
static PyObject * |
| 12703 |
os__create_environ(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 12704 |
{ |
| 12705 |
return os__create_environ_impl(module); |
| 12706 |
} |
| 12707 |
|
| 12708 |
#if defined(__EMSCRIPTEN__) |
| 12709 |
|
| 12710 |
PyDoc_STRVAR(os__emscripten_debugger__doc__, |
| 12711 |
"_emscripten_debugger($module, /)\n" |
| 12712 |
"--\n" |
| 12713 |
"\n" |
| 12714 |
"Create a breakpoint for the JavaScript debugger. Emscripten only."); |
| 12715 |
|
| 12716 |
#define OS__EMSCRIPTEN_DEBUGGER_METHODDEF \ |
| 12717 |
{"_emscripten_debugger", (PyCFunction)os__emscripten_debugger, METH_NOARGS, os__emscripten_debugger__doc__}, |
| 12718 |
|
| 12719 |
static PyObject * |
| 12720 |
os__emscripten_debugger_impl(PyObject *module); |
| 12721 |
|
| 12722 |
static PyObject * |
| 12723 |
os__emscripten_debugger(PyObject *module, PyObject *Py_UNUSED(ignored)) |
| 12724 |
{ |
| 12725 |
return os__emscripten_debugger_impl(module); |
| 12726 |
} |
| 12727 |
|
| 12728 |
#endif /* defined(__EMSCRIPTEN__) */ |
| 12729 |
|
| 12730 |
#if defined(__EMSCRIPTEN__) |
| 12731 |
|
| 12732 |
PyDoc_STRVAR(os__emscripten_log__doc__, |
| 12733 |
"_emscripten_log($module, /, arg)\n" |
| 12734 |
"--\n" |
| 12735 |
"\n" |
| 12736 |
"Log something to the JS console. Emscripten only."); |
| 12737 |
|
| 12738 |
#define OS__EMSCRIPTEN_LOG_METHODDEF \ |
| 12739 |
{"_emscripten_log", _PyCFunction_CAST(os__emscripten_log), METH_FASTCALL|METH_KEYWORDS, os__emscripten_log__doc__}, |
| 12740 |
|
| 12741 |
static PyObject * |
| 12742 |
os__emscripten_log_impl(PyObject *module, const char *arg); |
| 12743 |
|
| 12744 |
static PyObject * |
| 12745 |
os__emscripten_log(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
| 12746 |
{ |
| 12747 |
PyObject *return_value = NULL; |
| 12748 |
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) |
| 12749 |
|
| 12750 |
#define NUM_KEYWORDS 1 |
| 12751 |
static struct { |
| 12752 |
PyGC_Head _this_is_not_used; |
| 12753 |
PyObject_VAR_HEAD |
| 12754 |
Py_hash_t ob_hash; |
| 12755 |
PyObject *ob_item[NUM_KEYWORDS]; |
| 12756 |
} _kwtuple = { |
| 12757 |
.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS) |
| 12758 |
.ob_hash = -1, |
| 12759 |
.ob_item = { &_Py_ID(arg), }, |
| 12760 |
}; |
| 12761 |
#undef NUM_KEYWORDS |
| 12762 |
#define KWTUPLE (&_kwtuple.ob_base.ob_base) |
| 12763 |
|
| 12764 |
#else // !Py_BUILD_CORE |
| 12765 |
# define KWTUPLE NULL |
| 12766 |
#endif // !Py_BUILD_CORE |
| 12767 |
|
| 12768 |
static const char * const _keywords[] = {"arg", NULL}; |
| 12769 |
static _PyArg_Parser _parser = { |
| 12770 |
.keywords = _keywords, |
| 12771 |
.fname = "_emscripten_log", |
| 12772 |
.kwtuple = KWTUPLE, |
| 12773 |
}; |
| 12774 |
#undef KWTUPLE |
| 12775 |
PyObject *argsbuf[1]; |
| 12776 |
const char *arg; |
| 12777 |
|
| 12778 |
args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, |
| 12779 |
/*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf); |
| 12780 |
if (!args) { |
| 12781 |
goto exit; |
| 12782 |
} |
| 12783 |
if (!PyUnicode_Check(args[0])) { |
| 12784 |
_PyArg_BadArgument("_emscripten_log", "argument 'arg'", "str", args[0]); |
| 12785 |
goto exit; |
| 12786 |
} |
| 12787 |
Py_ssize_t arg_length; |
| 12788 |
arg = PyUnicode_AsUTF8AndSize(args[0], &arg_length); |
| 12789 |
if (arg == NULL) { |
| 12790 |
goto exit; |
| 12791 |
} |
| 12792 |
if (strlen(arg) != (size_t)arg_length) { |
| 12793 |
PyErr_SetString(PyExc_ValueError, "embedded null character"); |
| 12794 |
goto exit; |
| 12795 |
} |
| 12796 |
return_value = os__emscripten_log_impl(module, arg); |
| 12797 |
|
| 12798 |
exit: |
| 12799 |
return return_value; |
| 12800 |
} |
| 12801 |
|
| 12802 |
#endif /* defined(__EMSCRIPTEN__) */ |
| 12803 |
|
| 12804 |
#ifndef OS_TTYNAME_METHODDEF |
| 12805 |
#define OS_TTYNAME_METHODDEF |
| 12806 |
#endif /* !defined(OS_TTYNAME_METHODDEF) */ |
| 12807 |
|
| 12808 |
#ifndef OS_CTERMID_METHODDEF |
| 12809 |
#define OS_CTERMID_METHODDEF |
| 12810 |
#endif /* !defined(OS_CTERMID_METHODDEF) */ |
| 12811 |
|
| 12812 |
#ifndef OS_FCHDIR_METHODDEF |
| 12813 |
#define OS_FCHDIR_METHODDEF |
| 12814 |
#endif /* !defined(OS_FCHDIR_METHODDEF) */ |
| 12815 |
|
| 12816 |
#ifndef OS_FCHMOD_METHODDEF |
| 12817 |
#define OS_FCHMOD_METHODDEF |
| 12818 |
#endif /* !defined(OS_FCHMOD_METHODDEF) */ |
| 12819 |
|
| 12820 |
#ifndef OS_LCHMOD_METHODDEF |
| 12821 |
#define OS_LCHMOD_METHODDEF |
| 12822 |
#endif /* !defined(OS_LCHMOD_METHODDEF) */ |
| 12823 |
|
| 12824 |
#ifndef OS_CHFLAGS_METHODDEF |
| 12825 |
#define OS_CHFLAGS_METHODDEF |
| 12826 |
#endif /* !defined(OS_CHFLAGS_METHODDEF) */ |
| 12827 |
|
| 12828 |
#ifndef OS_LCHFLAGS_METHODDEF |
| 12829 |
#define OS_LCHFLAGS_METHODDEF |
| 12830 |
#endif /* !defined(OS_LCHFLAGS_METHODDEF) */ |
| 12831 |
|
| 12832 |
#ifndef OS_CHROOT_METHODDEF |
| 12833 |
#define OS_CHROOT_METHODDEF |
| 12834 |
#endif /* !defined(OS_CHROOT_METHODDEF) */ |
| 12835 |
|
| 12836 |
#ifndef OS_FSYNC_METHODDEF |
| 12837 |
#define OS_FSYNC_METHODDEF |
| 12838 |
#endif /* !defined(OS_FSYNC_METHODDEF) */ |
| 12839 |
|
| 12840 |
#ifndef OS_SYNC_METHODDEF |
| 12841 |
#define OS_SYNC_METHODDEF |
| 12842 |
#endif /* !defined(OS_SYNC_METHODDEF) */ |
| 12843 |
|
| 12844 |
#ifndef OS_FDATASYNC_METHODDEF |
| 12845 |
#define OS_FDATASYNC_METHODDEF |
| 12846 |
#endif /* !defined(OS_FDATASYNC_METHODDEF) */ |
| 12847 |
|
| 12848 |
#ifndef OS_CHOWN_METHODDEF |
| 12849 |
#define OS_CHOWN_METHODDEF |
| 12850 |
#endif /* !defined(OS_CHOWN_METHODDEF) */ |
| 12851 |
|
| 12852 |
#ifndef OS_FCHOWN_METHODDEF |
| 12853 |
#define OS_FCHOWN_METHODDEF |
| 12854 |
#endif /* !defined(OS_FCHOWN_METHODDEF) */ |
| 12855 |
|
| 12856 |
#ifndef OS_LCHOWN_METHODDEF |
| 12857 |
#define OS_LCHOWN_METHODDEF |
| 12858 |
#endif /* !defined(OS_LCHOWN_METHODDEF) */ |
| 12859 |
|
| 12860 |
#ifndef OS_LINK_METHODDEF |
| 12861 |
#define OS_LINK_METHODDEF |
| 12862 |
#endif /* !defined(OS_LINK_METHODDEF) */ |
| 12863 |
|
| 12864 |
#ifndef OS_LISTDRIVES_METHODDEF |
| 12865 |
#define OS_LISTDRIVES_METHODDEF |
| 12866 |
#endif /* !defined(OS_LISTDRIVES_METHODDEF) */ |
| 12867 |
|
| 12868 |
#ifndef OS_LISTVOLUMES_METHODDEF |
| 12869 |
#define OS_LISTVOLUMES_METHODDEF |
| 12870 |
#endif /* !defined(OS_LISTVOLUMES_METHODDEF) */ |
| 12871 |
|
| 12872 |
#ifndef OS_LISTMOUNTS_METHODDEF |
| 12873 |
#define OS_LISTMOUNTS_METHODDEF |
| 12874 |
#endif /* !defined(OS_LISTMOUNTS_METHODDEF) */ |
| 12875 |
|
| 12876 |
#ifndef OS__PATH_ISDEVDRIVE_METHODDEF |
| 12877 |
#define OS__PATH_ISDEVDRIVE_METHODDEF |
| 12878 |
#endif /* !defined(OS__PATH_ISDEVDRIVE_METHODDEF) */ |
| 12879 |
|
| 12880 |
#ifndef OS__GETFULLPATHNAME_METHODDEF |
| 12881 |
#define OS__GETFULLPATHNAME_METHODDEF |
| 12882 |
#endif /* !defined(OS__GETFULLPATHNAME_METHODDEF) */ |
| 12883 |
|
| 12884 |
#ifndef OS__GETFINALPATHNAME_METHODDEF |
| 12885 |
#define OS__GETFINALPATHNAME_METHODDEF |
| 12886 |
#endif /* !defined(OS__GETFINALPATHNAME_METHODDEF) */ |
| 12887 |
|
| 12888 |
#ifndef OS__FINDFIRSTFILE_METHODDEF |
| 12889 |
#define OS__FINDFIRSTFILE_METHODDEF |
| 12890 |
#endif /* !defined(OS__FINDFIRSTFILE_METHODDEF) */ |
| 12891 |
|
| 12892 |
#ifndef OS__GETVOLUMEPATHNAME_METHODDEF |
| 12893 |
#define OS__GETVOLUMEPATHNAME_METHODDEF |
| 12894 |
#endif /* !defined(OS__GETVOLUMEPATHNAME_METHODDEF) */ |
| 12895 |
|
| 12896 |
#ifndef OS__PATH_SPLITROOT_METHODDEF |
| 12897 |
#define OS__PATH_SPLITROOT_METHODDEF |
| 12898 |
#endif /* !defined(OS__PATH_SPLITROOT_METHODDEF) */ |
| 12899 |
|
| 12900 |
#ifndef OS__PATH_EXISTS_METHODDEF |
| 12901 |
#define OS__PATH_EXISTS_METHODDEF |
| 12902 |
#endif /* !defined(OS__PATH_EXISTS_METHODDEF) */ |
| 12903 |
|
| 12904 |
#ifndef OS__PATH_LEXISTS_METHODDEF |
| 12905 |
#define OS__PATH_LEXISTS_METHODDEF |
| 12906 |
#endif /* !defined(OS__PATH_LEXISTS_METHODDEF) */ |
| 12907 |
|
| 12908 |
#ifndef OS__PATH_ISDIR_METHODDEF |
| 12909 |
#define OS__PATH_ISDIR_METHODDEF |
| 12910 |
#endif /* !defined(OS__PATH_ISDIR_METHODDEF) */ |
| 12911 |
|
| 12912 |
#ifndef OS__PATH_ISFILE_METHODDEF |
| 12913 |
#define OS__PATH_ISFILE_METHODDEF |
| 12914 |
#endif /* !defined(OS__PATH_ISFILE_METHODDEF) */ |
| 12915 |
|
| 12916 |
#ifndef OS__PATH_ISLINK_METHODDEF |
| 12917 |
#define OS__PATH_ISLINK_METHODDEF |
| 12918 |
#endif /* !defined(OS__PATH_ISLINK_METHODDEF) */ |
| 12919 |
|
| 12920 |
#ifndef OS__PATH_ISJUNCTION_METHODDEF |
| 12921 |
#define OS__PATH_ISJUNCTION_METHODDEF |
| 12922 |
#endif /* !defined(OS__PATH_ISJUNCTION_METHODDEF) */ |
| 12923 |
|
| 12924 |
#ifndef OS_NICE_METHODDEF |
| 12925 |
#define OS_NICE_METHODDEF |
| 12926 |
#endif /* !defined(OS_NICE_METHODDEF) */ |
| 12927 |
|
| 12928 |
#ifndef OS_GETPRIORITY_METHODDEF |
| 12929 |
#define OS_GETPRIORITY_METHODDEF |
| 12930 |
#endif /* !defined(OS_GETPRIORITY_METHODDEF) */ |
| 12931 |
|
| 12932 |
#ifndef OS_SETPRIORITY_METHODDEF |
| 12933 |
#define OS_SETPRIORITY_METHODDEF |
| 12934 |
#endif /* !defined(OS_SETPRIORITY_METHODDEF) */ |
| 12935 |
|
| 12936 |
#ifndef OS_SYSTEM_METHODDEF |
| 12937 |
#define OS_SYSTEM_METHODDEF |
| 12938 |
#endif /* !defined(OS_SYSTEM_METHODDEF) */ |
| 12939 |
|
| 12940 |
#ifndef OS_UMASK_METHODDEF |
| 12941 |
#define OS_UMASK_METHODDEF |
| 12942 |
#endif /* !defined(OS_UMASK_METHODDEF) */ |
| 12943 |
|
| 12944 |
#ifndef OS_UNAME_METHODDEF |
| 12945 |
#define OS_UNAME_METHODDEF |
| 12946 |
#endif /* !defined(OS_UNAME_METHODDEF) */ |
| 12947 |
|
| 12948 |
#ifndef OS_EXECV_METHODDEF |
| 12949 |
#define OS_EXECV_METHODDEF |
| 12950 |
#endif /* !defined(OS_EXECV_METHODDEF) */ |
| 12951 |
|
| 12952 |
#ifndef OS_EXECVE_METHODDEF |
| 12953 |
#define OS_EXECVE_METHODDEF |
| 12954 |
#endif /* !defined(OS_EXECVE_METHODDEF) */ |
| 12955 |
|
| 12956 |
#ifndef OS_POSIX_SPAWN_METHODDEF |
| 12957 |
#define OS_POSIX_SPAWN_METHODDEF |
| 12958 |
#endif /* !defined(OS_POSIX_SPAWN_METHODDEF) */ |
| 12959 |
|
| 12960 |
#ifndef OS_POSIX_SPAWNP_METHODDEF |
| 12961 |
#define OS_POSIX_SPAWNP_METHODDEF |
| 12962 |
#endif /* !defined(OS_POSIX_SPAWNP_METHODDEF) */ |
| 12963 |
|
| 12964 |
#ifndef OS_SPAWNV_METHODDEF |
| 12965 |
#define OS_SPAWNV_METHODDEF |
| 12966 |
#endif /* !defined(OS_SPAWNV_METHODDEF) */ |
| 12967 |
|
| 12968 |
#ifndef OS_SPAWNVE_METHODDEF |
| 12969 |
#define OS_SPAWNVE_METHODDEF |
| 12970 |
#endif /* !defined(OS_SPAWNVE_METHODDEF) */ |
| 12971 |
|
| 12972 |
#ifndef OS_REGISTER_AT_FORK_METHODDEF |
| 12973 |
#define OS_REGISTER_AT_FORK_METHODDEF |
| 12974 |
#endif /* !defined(OS_REGISTER_AT_FORK_METHODDEF) */ |
| 12975 |
|
| 12976 |
#ifndef OS_FORK1_METHODDEF |
| 12977 |
#define OS_FORK1_METHODDEF |
| 12978 |
#endif /* !defined(OS_FORK1_METHODDEF) */ |
| 12979 |
|
| 12980 |
#ifndef OS_FORK_METHODDEF |
| 12981 |
#define OS_FORK_METHODDEF |
| 12982 |
#endif /* !defined(OS_FORK_METHODDEF) */ |
| 12983 |
|
| 12984 |
#ifndef OS_SCHED_GET_PRIORITY_MAX_METHODDEF |
| 12985 |
#define OS_SCHED_GET_PRIORITY_MAX_METHODDEF |
| 12986 |
#endif /* !defined(OS_SCHED_GET_PRIORITY_MAX_METHODDEF) */ |
| 12987 |
|
| 12988 |
#ifndef OS_SCHED_GET_PRIORITY_MIN_METHODDEF |
| 12989 |
#define OS_SCHED_GET_PRIORITY_MIN_METHODDEF |
| 12990 |
#endif /* !defined(OS_SCHED_GET_PRIORITY_MIN_METHODDEF) */ |
| 12991 |
|
| 12992 |
#ifndef OS_SCHED_GETSCHEDULER_METHODDEF |
| 12993 |
#define OS_SCHED_GETSCHEDULER_METHODDEF |
| 12994 |
#endif /* !defined(OS_SCHED_GETSCHEDULER_METHODDEF) */ |
| 12995 |
|
| 12996 |
#ifndef OS_SCHED_SETSCHEDULER_METHODDEF |
| 12997 |
#define OS_SCHED_SETSCHEDULER_METHODDEF |
| 12998 |
#endif /* !defined(OS_SCHED_SETSCHEDULER_METHODDEF) */ |
| 12999 |
|
| 13000 |
#ifndef OS_SCHED_GETPARAM_METHODDEF |
| 13001 |
#define OS_SCHED_GETPARAM_METHODDEF |
| 13002 |
#endif /* !defined(OS_SCHED_GETPARAM_METHODDEF) */ |
| 13003 |
|
| 13004 |
#ifndef OS_SCHED_SETPARAM_METHODDEF |
| 13005 |
#define OS_SCHED_SETPARAM_METHODDEF |
| 13006 |
#endif /* !defined(OS_SCHED_SETPARAM_METHODDEF) */ |
| 13007 |
|
| 13008 |
#ifndef OS_SCHED_RR_GET_INTERVAL_METHODDEF |
| 13009 |
#define OS_SCHED_RR_GET_INTERVAL_METHODDEF |
| 13010 |
#endif /* !defined(OS_SCHED_RR_GET_INTERVAL_METHODDEF) */ |
| 13011 |
|
| 13012 |
#ifndef OS_SCHED_YIELD_METHODDEF |
| 13013 |
#define OS_SCHED_YIELD_METHODDEF |
| 13014 |
#endif /* !defined(OS_SCHED_YIELD_METHODDEF) */ |
| 13015 |
|
| 13016 |
#ifndef OS_SCHED_SETAFFINITY_METHODDEF |
| 13017 |
#define OS_SCHED_SETAFFINITY_METHODDEF |
| 13018 |
#endif /* !defined(OS_SCHED_SETAFFINITY_METHODDEF) */ |
| 13019 |
|
| 13020 |
#ifndef OS_SCHED_GETAFFINITY_METHODDEF |
| 13021 |
#define OS_SCHED_GETAFFINITY_METHODDEF |
| 13022 |
#endif /* !defined(OS_SCHED_GETAFFINITY_METHODDEF) */ |
| 13023 |
|
| 13024 |
#ifndef OS_POSIX_OPENPT_METHODDEF |
| 13025 |
#define OS_POSIX_OPENPT_METHODDEF |
| 13026 |
#endif /* !defined(OS_POSIX_OPENPT_METHODDEF) */ |
| 13027 |
|
| 13028 |
#ifndef OS_GRANTPT_METHODDEF |
| 13029 |
#define OS_GRANTPT_METHODDEF |
| 13030 |
#endif /* !defined(OS_GRANTPT_METHODDEF) */ |
| 13031 |
|
| 13032 |
#ifndef OS_UNLOCKPT_METHODDEF |
| 13033 |
#define OS_UNLOCKPT_METHODDEF |
| 13034 |
#endif /* !defined(OS_UNLOCKPT_METHODDEF) */ |
| 13035 |
|
| 13036 |
#ifndef OS_PTSNAME_METHODDEF |
| 13037 |
#define OS_PTSNAME_METHODDEF |
| 13038 |
#endif /* !defined(OS_PTSNAME_METHODDEF) */ |
| 13039 |
|
| 13040 |
#ifndef OS_OPENPTY_METHODDEF |
| 13041 |
#define OS_OPENPTY_METHODDEF |
| 13042 |
#endif /* !defined(OS_OPENPTY_METHODDEF) */ |
| 13043 |
|
| 13044 |
#ifndef OS_LOGIN_TTY_METHODDEF |
| 13045 |
#define OS_LOGIN_TTY_METHODDEF |
| 13046 |
#endif /* !defined(OS_LOGIN_TTY_METHODDEF) */ |
| 13047 |
|
| 13048 |
#ifndef OS_FORKPTY_METHODDEF |
| 13049 |
#define OS_FORKPTY_METHODDEF |
| 13050 |
#endif /* !defined(OS_FORKPTY_METHODDEF) */ |
| 13051 |
|
| 13052 |
#ifndef OS_GETEGID_METHODDEF |
| 13053 |
#define OS_GETEGID_METHODDEF |
| 13054 |
#endif /* !defined(OS_GETEGID_METHODDEF) */ |
| 13055 |
|
| 13056 |
#ifndef OS_GETEUID_METHODDEF |
| 13057 |
#define OS_GETEUID_METHODDEF |
| 13058 |
#endif /* !defined(OS_GETEUID_METHODDEF) */ |
| 13059 |
|
| 13060 |
#ifndef OS_GETGID_METHODDEF |
| 13061 |
#define OS_GETGID_METHODDEF |
| 13062 |
#endif /* !defined(OS_GETGID_METHODDEF) */ |
| 13063 |
|
| 13064 |
#ifndef OS_GETPID_METHODDEF |
| 13065 |
#define OS_GETPID_METHODDEF |
| 13066 |
#endif /* !defined(OS_GETPID_METHODDEF) */ |
| 13067 |
|
| 13068 |
#ifndef OS_GETGROUPLIST_METHODDEF |
| 13069 |
#define OS_GETGROUPLIST_METHODDEF |
| 13070 |
#endif /* !defined(OS_GETGROUPLIST_METHODDEF) */ |
| 13071 |
|
| 13072 |
#ifndef OS_GETGROUPS_METHODDEF |
| 13073 |
#define OS_GETGROUPS_METHODDEF |
| 13074 |
#endif /* !defined(OS_GETGROUPS_METHODDEF) */ |
| 13075 |
|
| 13076 |
#ifndef OS_INITGROUPS_METHODDEF |
| 13077 |
#define OS_INITGROUPS_METHODDEF |
| 13078 |
#endif /* !defined(OS_INITGROUPS_METHODDEF) */ |
| 13079 |
|
| 13080 |
#ifndef OS_GETPGID_METHODDEF |
| 13081 |
#define OS_GETPGID_METHODDEF |
| 13082 |
#endif /* !defined(OS_GETPGID_METHODDEF) */ |
| 13083 |
|
| 13084 |
#ifndef OS_GETPGRP_METHODDEF |
| 13085 |
#define OS_GETPGRP_METHODDEF |
| 13086 |
#endif /* !defined(OS_GETPGRP_METHODDEF) */ |
| 13087 |
|
| 13088 |
#ifndef OS_SETPGRP_METHODDEF |
| 13089 |
#define OS_SETPGRP_METHODDEF |
| 13090 |
#endif /* !defined(OS_SETPGRP_METHODDEF) */ |
| 13091 |
|
| 13092 |
#ifndef OS_GETPPID_METHODDEF |
| 13093 |
#define OS_GETPPID_METHODDEF |
| 13094 |
#endif /* !defined(OS_GETPPID_METHODDEF) */ |
| 13095 |
|
| 13096 |
#ifndef OS_GETLOGIN_METHODDEF |
| 13097 |
#define OS_GETLOGIN_METHODDEF |
| 13098 |
#endif /* !defined(OS_GETLOGIN_METHODDEF) */ |
| 13099 |
|
| 13100 |
#ifndef OS_GETUID_METHODDEF |
| 13101 |
#define OS_GETUID_METHODDEF |
| 13102 |
#endif /* !defined(OS_GETUID_METHODDEF) */ |
| 13103 |
|
| 13104 |
#ifndef OS_KILL_METHODDEF |
| 13105 |
#define OS_KILL_METHODDEF |
| 13106 |
#endif /* !defined(OS_KILL_METHODDEF) */ |
| 13107 |
|
| 13108 |
#ifndef OS_KILLPG_METHODDEF |
| 13109 |
#define OS_KILLPG_METHODDEF |
| 13110 |
#endif /* !defined(OS_KILLPG_METHODDEF) */ |
| 13111 |
|
| 13112 |
#ifndef OS_PLOCK_METHODDEF |
| 13113 |
#define OS_PLOCK_METHODDEF |
| 13114 |
#endif /* !defined(OS_PLOCK_METHODDEF) */ |
| 13115 |
|
| 13116 |
#ifndef OS_SETUID_METHODDEF |
| 13117 |
#define OS_SETUID_METHODDEF |
| 13118 |
#endif /* !defined(OS_SETUID_METHODDEF) */ |
| 13119 |
|
| 13120 |
#ifndef OS_SETEUID_METHODDEF |
| 13121 |
#define OS_SETEUID_METHODDEF |
| 13122 |
#endif /* !defined(OS_SETEUID_METHODDEF) */ |
| 13123 |
|
| 13124 |
#ifndef OS_SETEGID_METHODDEF |
| 13125 |
#define OS_SETEGID_METHODDEF |
| 13126 |
#endif /* !defined(OS_SETEGID_METHODDEF) */ |
| 13127 |
|
| 13128 |
#ifndef OS_SETREUID_METHODDEF |
| 13129 |
#define OS_SETREUID_METHODDEF |
| 13130 |
#endif /* !defined(OS_SETREUID_METHODDEF) */ |
| 13131 |
|
| 13132 |
#ifndef OS_SETREGID_METHODDEF |
| 13133 |
#define OS_SETREGID_METHODDEF |
| 13134 |
#endif /* !defined(OS_SETREGID_METHODDEF) */ |
| 13135 |
|
| 13136 |
#ifndef OS_SETGID_METHODDEF |
| 13137 |
#define OS_SETGID_METHODDEF |
| 13138 |
#endif /* !defined(OS_SETGID_METHODDEF) */ |
| 13139 |
|
| 13140 |
#ifndef OS_SETGROUPS_METHODDEF |
| 13141 |
#define OS_SETGROUPS_METHODDEF |
| 13142 |
#endif /* !defined(OS_SETGROUPS_METHODDEF) */ |
| 13143 |
|
| 13144 |
#ifndef OS_WAIT3_METHODDEF |
| 13145 |
#define OS_WAIT3_METHODDEF |
| 13146 |
#endif /* !defined(OS_WAIT3_METHODDEF) */ |
| 13147 |
|
| 13148 |
#ifndef OS_WAIT4_METHODDEF |
| 13149 |
#define OS_WAIT4_METHODDEF |
| 13150 |
#endif /* !defined(OS_WAIT4_METHODDEF) */ |
| 13151 |
|
| 13152 |
#ifndef OS_WAITID_METHODDEF |
| 13153 |
#define OS_WAITID_METHODDEF |
| 13154 |
#endif /* !defined(OS_WAITID_METHODDEF) */ |
| 13155 |
|
| 13156 |
#ifndef OS_WAITPID_METHODDEF |
| 13157 |
#define OS_WAITPID_METHODDEF |
| 13158 |
#endif /* !defined(OS_WAITPID_METHODDEF) */ |
| 13159 |
|
| 13160 |
#ifndef OS_WAIT_METHODDEF |
| 13161 |
#define OS_WAIT_METHODDEF |
| 13162 |
#endif /* !defined(OS_WAIT_METHODDEF) */ |
| 13163 |
|
| 13164 |
#ifndef OS_PIDFD_OPEN_METHODDEF |
| 13165 |
#define OS_PIDFD_OPEN_METHODDEF |
| 13166 |
#endif /* !defined(OS_PIDFD_OPEN_METHODDEF) */ |
| 13167 |
|
| 13168 |
#ifndef OS_SETNS_METHODDEF |
| 13169 |
#define OS_SETNS_METHODDEF |
| 13170 |
#endif /* !defined(OS_SETNS_METHODDEF) */ |
| 13171 |
|
| 13172 |
#ifndef OS_UNSHARE_METHODDEF |
| 13173 |
#define OS_UNSHARE_METHODDEF |
| 13174 |
#endif /* !defined(OS_UNSHARE_METHODDEF) */ |
| 13175 |
|
| 13176 |
#ifndef OS_READLINK_METHODDEF |
| 13177 |
#define OS_READLINK_METHODDEF |
| 13178 |
#endif /* !defined(OS_READLINK_METHODDEF) */ |
| 13179 |
|
| 13180 |
#ifndef OS_SYMLINK_METHODDEF |
| 13181 |
#define OS_SYMLINK_METHODDEF |
| 13182 |
#endif /* !defined(OS_SYMLINK_METHODDEF) */ |
| 13183 |
|
| 13184 |
#ifndef OS_TIMERFD_CREATE_METHODDEF |
| 13185 |
#define OS_TIMERFD_CREATE_METHODDEF |
| 13186 |
#endif /* !defined(OS_TIMERFD_CREATE_METHODDEF) */ |
| 13187 |
|
| 13188 |
#ifndef OS_TIMERFD_SETTIME_METHODDEF |
| 13189 |
#define OS_TIMERFD_SETTIME_METHODDEF |
| 13190 |
#endif /* !defined(OS_TIMERFD_SETTIME_METHODDEF) */ |
| 13191 |
|
| 13192 |
#ifndef OS_TIMERFD_SETTIME_NS_METHODDEF |
| 13193 |
#define OS_TIMERFD_SETTIME_NS_METHODDEF |
| 13194 |
#endif /* !defined(OS_TIMERFD_SETTIME_NS_METHODDEF) */ |
| 13195 |
|
| 13196 |
#ifndef OS_TIMERFD_GETTIME_METHODDEF |
| 13197 |
#define OS_TIMERFD_GETTIME_METHODDEF |
| 13198 |
#endif /* !defined(OS_TIMERFD_GETTIME_METHODDEF) */ |
| 13199 |
|
| 13200 |
#ifndef OS_TIMERFD_GETTIME_NS_METHODDEF |
| 13201 |
#define OS_TIMERFD_GETTIME_NS_METHODDEF |
| 13202 |
#endif /* !defined(OS_TIMERFD_GETTIME_NS_METHODDEF) */ |
| 13203 |
|
| 13204 |
#ifndef OS_GETSID_METHODDEF |
| 13205 |
#define OS_GETSID_METHODDEF |
| 13206 |
#endif /* !defined(OS_GETSID_METHODDEF) */ |
| 13207 |
|
| 13208 |
#ifndef OS_SETSID_METHODDEF |
| 13209 |
#define OS_SETSID_METHODDEF |
| 13210 |
#endif /* !defined(OS_SETSID_METHODDEF) */ |
| 13211 |
|
| 13212 |
#ifndef OS_SETPGID_METHODDEF |
| 13213 |
#define OS_SETPGID_METHODDEF |
| 13214 |
#endif /* !defined(OS_SETPGID_METHODDEF) */ |
| 13215 |
|
| 13216 |
#ifndef OS_TCGETPGRP_METHODDEF |
| 13217 |
#define OS_TCGETPGRP_METHODDEF |
| 13218 |
#endif /* !defined(OS_TCGETPGRP_METHODDEF) */ |
| 13219 |
|
| 13220 |
#ifndef OS_TCSETPGRP_METHODDEF |
| 13221 |
#define OS_TCSETPGRP_METHODDEF |
| 13222 |
#endif /* !defined(OS_TCSETPGRP_METHODDEF) */ |
| 13223 |
|
| 13224 |
#ifndef OS_DUP2_METHODDEF |
| 13225 |
#define OS_DUP2_METHODDEF |
| 13226 |
#endif /* !defined(OS_DUP2_METHODDEF) */ |
| 13227 |
|
| 13228 |
#ifndef OS_LOCKF_METHODDEF |
| 13229 |
#define OS_LOCKF_METHODDEF |
| 13230 |
#endif /* !defined(OS_LOCKF_METHODDEF) */ |
| 13231 |
|
| 13232 |
#ifndef OS_READV_METHODDEF |
| 13233 |
#define OS_READV_METHODDEF |
| 13234 |
#endif /* !defined(OS_READV_METHODDEF) */ |
| 13235 |
|
| 13236 |
#ifndef OS_PREAD_METHODDEF |
| 13237 |
#define OS_PREAD_METHODDEF |
| 13238 |
#endif /* !defined(OS_PREAD_METHODDEF) */ |
| 13239 |
|
| 13240 |
#ifndef OS_PREADV_METHODDEF |
| 13241 |
#define OS_PREADV_METHODDEF |
| 13242 |
#endif /* !defined(OS_PREADV_METHODDEF) */ |
| 13243 |
|
| 13244 |
#ifndef OS_SENDFILE_METHODDEF |
| 13245 |
#define OS_SENDFILE_METHODDEF |
| 13246 |
#endif /* !defined(OS_SENDFILE_METHODDEF) */ |
| 13247 |
|
| 13248 |
#ifndef OS__FCOPYFILE_METHODDEF |
| 13249 |
#define OS__FCOPYFILE_METHODDEF |
| 13250 |
#endif /* !defined(OS__FCOPYFILE_METHODDEF) */ |
| 13251 |
|
| 13252 |
#ifndef OS_PIPE_METHODDEF |
| 13253 |
#define OS_PIPE_METHODDEF |
| 13254 |
#endif /* !defined(OS_PIPE_METHODDEF) */ |
| 13255 |
|
| 13256 |
#ifndef OS_PIPE2_METHODDEF |
| 13257 |
#define OS_PIPE2_METHODDEF |
| 13258 |
#endif /* !defined(OS_PIPE2_METHODDEF) */ |
| 13259 |
|
| 13260 |
#ifndef OS_WRITEV_METHODDEF |
| 13261 |
#define OS_WRITEV_METHODDEF |
| 13262 |
#endif /* !defined(OS_WRITEV_METHODDEF) */ |
| 13263 |
|
| 13264 |
#ifndef OS_PWRITE_METHODDEF |
| 13265 |
#define OS_PWRITE_METHODDEF |
| 13266 |
#endif /* !defined(OS_PWRITE_METHODDEF) */ |
| 13267 |
|
| 13268 |
#ifndef OS_PWRITEV_METHODDEF |
| 13269 |
#define OS_PWRITEV_METHODDEF |
| 13270 |
#endif /* !defined(OS_PWRITEV_METHODDEF) */ |
| 13271 |
|
| 13272 |
#ifndef OS_COPY_FILE_RANGE_METHODDEF |
| 13273 |
#define OS_COPY_FILE_RANGE_METHODDEF |
| 13274 |
#endif /* !defined(OS_COPY_FILE_RANGE_METHODDEF) */ |
| 13275 |
|
| 13276 |
#ifndef OS_SPLICE_METHODDEF |
| 13277 |
#define OS_SPLICE_METHODDEF |
| 13278 |
#endif /* !defined(OS_SPLICE_METHODDEF) */ |
| 13279 |
|
| 13280 |
#ifndef OS_MKFIFO_METHODDEF |
| 13281 |
#define OS_MKFIFO_METHODDEF |
| 13282 |
#endif /* !defined(OS_MKFIFO_METHODDEF) */ |
| 13283 |
|
| 13284 |
#ifndef OS_MKNOD_METHODDEF |
| 13285 |
#define OS_MKNOD_METHODDEF |
| 13286 |
#endif /* !defined(OS_MKNOD_METHODDEF) */ |
| 13287 |
|
| 13288 |
#ifndef OS_MAJOR_METHODDEF |
| 13289 |
#define OS_MAJOR_METHODDEF |
| 13290 |
#endif /* !defined(OS_MAJOR_METHODDEF) */ |
| 13291 |
|
| 13292 |
#ifndef OS_MINOR_METHODDEF |
| 13293 |
#define OS_MINOR_METHODDEF |
| 13294 |
#endif /* !defined(OS_MINOR_METHODDEF) */ |
| 13295 |
|
| 13296 |
#ifndef OS_MAKEDEV_METHODDEF |
| 13297 |
#define OS_MAKEDEV_METHODDEF |
| 13298 |
#endif /* !defined(OS_MAKEDEV_METHODDEF) */ |
| 13299 |
|
| 13300 |
#ifndef OS_FTRUNCATE_METHODDEF |
| 13301 |
#define OS_FTRUNCATE_METHODDEF |
| 13302 |
#endif /* !defined(OS_FTRUNCATE_METHODDEF) */ |
| 13303 |
|
| 13304 |
#ifndef OS_TRUNCATE_METHODDEF |
| 13305 |
#define OS_TRUNCATE_METHODDEF |
| 13306 |
#endif /* !defined(OS_TRUNCATE_METHODDEF) */ |
| 13307 |
|
| 13308 |
#ifndef OS_POSIX_FALLOCATE_METHODDEF |
| 13309 |
#define OS_POSIX_FALLOCATE_METHODDEF |
| 13310 |
#endif /* !defined(OS_POSIX_FALLOCATE_METHODDEF) */ |
| 13311 |
|
| 13312 |
#ifndef OS_POSIX_FADVISE_METHODDEF |
| 13313 |
#define OS_POSIX_FADVISE_METHODDEF |
| 13314 |
#endif /* !defined(OS_POSIX_FADVISE_METHODDEF) */ |
| 13315 |
|
| 13316 |
#ifndef OS_PUTENV_METHODDEF |
| 13317 |
#define OS_PUTENV_METHODDEF |
| 13318 |
#endif /* !defined(OS_PUTENV_METHODDEF) */ |
| 13319 |
|
| 13320 |
#ifndef OS_UNSETENV_METHODDEF |
| 13321 |
#define OS_UNSETENV_METHODDEF |
| 13322 |
#endif /* !defined(OS_UNSETENV_METHODDEF) */ |
| 13323 |
|
| 13324 |
#ifndef OS_WCOREDUMP_METHODDEF |
| 13325 |
#define OS_WCOREDUMP_METHODDEF |
| 13326 |
#endif /* !defined(OS_WCOREDUMP_METHODDEF) */ |
| 13327 |
|
| 13328 |
#ifndef OS_WIFCONTINUED_METHODDEF |
| 13329 |
#define OS_WIFCONTINUED_METHODDEF |
| 13330 |
#endif /* !defined(OS_WIFCONTINUED_METHODDEF) */ |
| 13331 |
|
| 13332 |
#ifndef OS_WIFSTOPPED_METHODDEF |
| 13333 |
#define OS_WIFSTOPPED_METHODDEF |
| 13334 |
#endif /* !defined(OS_WIFSTOPPED_METHODDEF) */ |
| 13335 |
|
| 13336 |
#ifndef OS_WIFSIGNALED_METHODDEF |
| 13337 |
#define OS_WIFSIGNALED_METHODDEF |
| 13338 |
#endif /* !defined(OS_WIFSIGNALED_METHODDEF) */ |
| 13339 |
|
| 13340 |
#ifndef OS_WIFEXITED_METHODDEF |
| 13341 |
#define OS_WIFEXITED_METHODDEF |
| 13342 |
#endif /* !defined(OS_WIFEXITED_METHODDEF) */ |
| 13343 |
|
| 13344 |
#ifndef OS_WEXITSTATUS_METHODDEF |
| 13345 |
#define OS_WEXITSTATUS_METHODDEF |
| 13346 |
#endif /* !defined(OS_WEXITSTATUS_METHODDEF) */ |
| 13347 |
|
| 13348 |
#ifndef OS_WTERMSIG_METHODDEF |
| 13349 |
#define OS_WTERMSIG_METHODDEF |
| 13350 |
#endif /* !defined(OS_WTERMSIG_METHODDEF) */ |
| 13351 |
|
| 13352 |
#ifndef OS_WSTOPSIG_METHODDEF |
| 13353 |
#define OS_WSTOPSIG_METHODDEF |
| 13354 |
#endif /* !defined(OS_WSTOPSIG_METHODDEF) */ |
| 13355 |
|
| 13356 |
#ifndef OS_FSTATVFS_METHODDEF |
| 13357 |
#define OS_FSTATVFS_METHODDEF |
| 13358 |
#endif /* !defined(OS_FSTATVFS_METHODDEF) */ |
| 13359 |
|
| 13360 |
#ifndef OS_STATVFS_METHODDEF |
| 13361 |
#define OS_STATVFS_METHODDEF |
| 13362 |
#endif /* !defined(OS_STATVFS_METHODDEF) */ |
| 13363 |
|
| 13364 |
#ifndef OS__GETDISKUSAGE_METHODDEF |
| 13365 |
#define OS__GETDISKUSAGE_METHODDEF |
| 13366 |
#endif /* !defined(OS__GETDISKUSAGE_METHODDEF) */ |
| 13367 |
|
| 13368 |
#ifndef OS_FPATHCONF_METHODDEF |
| 13369 |
#define OS_FPATHCONF_METHODDEF |
| 13370 |
#endif /* !defined(OS_FPATHCONF_METHODDEF) */ |
| 13371 |
|
| 13372 |
#ifndef OS_PATHCONF_METHODDEF |
| 13373 |
#define OS_PATHCONF_METHODDEF |
| 13374 |
#endif /* !defined(OS_PATHCONF_METHODDEF) */ |
| 13375 |
|
| 13376 |
#ifndef OS_CONFSTR_METHODDEF |
| 13377 |
#define OS_CONFSTR_METHODDEF |
| 13378 |
#endif /* !defined(OS_CONFSTR_METHODDEF) */ |
| 13379 |
|
| 13380 |
#ifndef OS_SYSCONF_METHODDEF |
| 13381 |
#define OS_SYSCONF_METHODDEF |
| 13382 |
#endif /* !defined(OS_SYSCONF_METHODDEF) */ |
| 13383 |
|
| 13384 |
#ifndef OS_STARTFILE_METHODDEF |
| 13385 |
#define OS_STARTFILE_METHODDEF |
| 13386 |
#endif /* !defined(OS_STARTFILE_METHODDEF) */ |
| 13387 |
|
| 13388 |
#ifndef OS_GETLOADAVG_METHODDEF |
| 13389 |
#define OS_GETLOADAVG_METHODDEF |
| 13390 |
#endif /* !defined(OS_GETLOADAVG_METHODDEF) */ |
| 13391 |
|
| 13392 |
#ifndef OS_SETRESUID_METHODDEF |
| 13393 |
#define OS_SETRESUID_METHODDEF |
| 13394 |
#endif /* !defined(OS_SETRESUID_METHODDEF) */ |
| 13395 |
|
| 13396 |
#ifndef OS_SETRESGID_METHODDEF |
| 13397 |
#define OS_SETRESGID_METHODDEF |
| 13398 |
#endif /* !defined(OS_SETRESGID_METHODDEF) */ |
| 13399 |
|
| 13400 |
#ifndef OS_GETRESUID_METHODDEF |
| 13401 |
#define OS_GETRESUID_METHODDEF |
| 13402 |
#endif /* !defined(OS_GETRESUID_METHODDEF) */ |
| 13403 |
|
| 13404 |
#ifndef OS_GETRESGID_METHODDEF |
| 13405 |
#define OS_GETRESGID_METHODDEF |
| 13406 |
#endif /* !defined(OS_GETRESGID_METHODDEF) */ |
| 13407 |
|
| 13408 |
#ifndef OS_GETXATTR_METHODDEF |
| 13409 |
#define OS_GETXATTR_METHODDEF |
| 13410 |
#endif /* !defined(OS_GETXATTR_METHODDEF) */ |
| 13411 |
|
| 13412 |
#ifndef OS_SETXATTR_METHODDEF |
| 13413 |
#define OS_SETXATTR_METHODDEF |
| 13414 |
#endif /* !defined(OS_SETXATTR_METHODDEF) */ |
| 13415 |
|
| 13416 |
#ifndef OS_REMOVEXATTR_METHODDEF |
| 13417 |
#define OS_REMOVEXATTR_METHODDEF |
| 13418 |
#endif /* !defined(OS_REMOVEXATTR_METHODDEF) */ |
| 13419 |
|
| 13420 |
#ifndef OS_LISTXATTR_METHODDEF |
| 13421 |
#define OS_LISTXATTR_METHODDEF |
| 13422 |
#endif /* !defined(OS_LISTXATTR_METHODDEF) */ |
| 13423 |
|
| 13424 |
#ifndef OS_MEMFD_CREATE_METHODDEF |
| 13425 |
#define OS_MEMFD_CREATE_METHODDEF |
| 13426 |
#endif /* !defined(OS_MEMFD_CREATE_METHODDEF) */ |
| 13427 |
|
| 13428 |
#ifndef OS_EVENTFD_METHODDEF |
| 13429 |
#define OS_EVENTFD_METHODDEF |
| 13430 |
#endif /* !defined(OS_EVENTFD_METHODDEF) */ |
| 13431 |
|
| 13432 |
#ifndef OS_EVENTFD_READ_METHODDEF |
| 13433 |
#define OS_EVENTFD_READ_METHODDEF |
| 13434 |
#endif /* !defined(OS_EVENTFD_READ_METHODDEF) */ |
| 13435 |
|
| 13436 |
#ifndef OS_EVENTFD_WRITE_METHODDEF |
| 13437 |
#define OS_EVENTFD_WRITE_METHODDEF |
| 13438 |
#endif /* !defined(OS_EVENTFD_WRITE_METHODDEF) */ |
| 13439 |
|
| 13440 |
#ifndef OS_GET_TERMINAL_SIZE_METHODDEF |
| 13441 |
#define OS_GET_TERMINAL_SIZE_METHODDEF |
| 13442 |
#endif /* !defined(OS_GET_TERMINAL_SIZE_METHODDEF) */ |
| 13443 |
|
| 13444 |
#ifndef OS_GET_HANDLE_INHERITABLE_METHODDEF |
| 13445 |
#define OS_GET_HANDLE_INHERITABLE_METHODDEF |
| 13446 |
#endif /* !defined(OS_GET_HANDLE_INHERITABLE_METHODDEF) */ |
| 13447 |
|
| 13448 |
#ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF |
| 13449 |
#define OS_SET_HANDLE_INHERITABLE_METHODDEF |
| 13450 |
#endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ |
| 13451 |
|
| 13452 |
#ifndef OS_GETRANDOM_METHODDEF |
| 13453 |
#define OS_GETRANDOM_METHODDEF |
| 13454 |
#endif /* !defined(OS_GETRANDOM_METHODDEF) */ |
| 13455 |
|
| 13456 |
#ifndef OS__ADD_DLL_DIRECTORY_METHODDEF |
| 13457 |
#define OS__ADD_DLL_DIRECTORY_METHODDEF |
| 13458 |
#endif /* !defined(OS__ADD_DLL_DIRECTORY_METHODDEF) */ |
| 13459 |
|
| 13460 |
#ifndef OS__REMOVE_DLL_DIRECTORY_METHODDEF |
| 13461 |
#define OS__REMOVE_DLL_DIRECTORY_METHODDEF |
| 13462 |
#endif /* !defined(OS__REMOVE_DLL_DIRECTORY_METHODDEF) */ |
| 13463 |
|
| 13464 |
#ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF |
| 13465 |
#define OS_WAITSTATUS_TO_EXITCODE_METHODDEF |
| 13466 |
#endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ |
| 13467 |
|
| 13468 |
#ifndef OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF |
| 13469 |
#define OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF |
| 13470 |
#endif /* !defined(OS__SUPPORTS_VIRTUAL_TERMINAL_METHODDEF) */ |
| 13471 |
|
| 13472 |
#ifndef OS__EMSCRIPTEN_DEBUGGER_METHODDEF |
| 13473 |
#define OS__EMSCRIPTEN_DEBUGGER_METHODDEF |
| 13474 |
#endif /* !defined(OS__EMSCRIPTEN_DEBUGGER_METHODDEF) */ |
| 13475 |
|
| 13476 |
#ifndef OS__EMSCRIPTEN_LOG_METHODDEF |
| 13477 |
#define OS__EMSCRIPTEN_LOG_METHODDEF |
| 13478 |
#endif /* !defined(OS__EMSCRIPTEN_LOG_METHODDEF) */ |
| 13479 |
/*[clinic end generated code: output=291f607b7a26ca5e input=a9049054013a1b77]*/ |