Home | History | Annotate | Download | only in clinic
      1 /*[clinic input]
      2 preserve
      3 [clinic start generated code]*/
      4 
      5 PyDoc_STRVAR(os_stat__doc__,
      6 "stat($module, /, path, *, dir_fd=None, follow_symlinks=True)\n"
      7 "--\n"
      8 "\n"
      9 "Perform a stat system call on the given path.\n"
     10 "\n"
     11 "  path\n"
     12 "    Path to be examined; can be string, bytes, path-like object or\n"
     13 "    open-file-descriptor int.\n"
     14 "  dir_fd\n"
     15 "    If not None, it should be a file descriptor open to a directory,\n"
     16 "    and path should be a relative string; path will then be relative to\n"
     17 "    that directory.\n"
     18 "  follow_symlinks\n"
     19 "    If False, and the last element of the path is a symbolic link,\n"
     20 "    stat will examine the symbolic link itself instead of the file\n"
     21 "    the link points to.\n"
     22 "\n"
     23 "dir_fd and follow_symlinks may not be implemented\n"
     24 "  on your platform.  If they are unavailable, using them will raise a\n"
     25 "  NotImplementedError.\n"
     26 "\n"
     27 "It\'s an error to use dir_fd or follow_symlinks when specifying path as\n"
     28 "  an open file descriptor.");
     29 
     30 #define OS_STAT_METHODDEF    \
     31     {"stat", (PyCFunction)os_stat, METH_FASTCALL, os_stat__doc__},
     32 
     33 static PyObject *
     34 os_stat_impl(PyObject *module, path_t *path, int dir_fd, int follow_symlinks);
     35 
     36 static PyObject *
     37 os_stat(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
     38 {
     39     PyObject *return_value = NULL;
     40     static const char * const _keywords[] = {"path", "dir_fd", "follow_symlinks", NULL};
     41     static _PyArg_Parser _parser = {"O&|$O&p:stat", _keywords, 0};
     42     path_t path = PATH_T_INITIALIZE("stat", "path", 0, 1);
     43     int dir_fd = DEFAULT_DIR_FD;
     44     int follow_symlinks = 1;
     45 
     46     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
     47         path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
     48         goto exit;
     49     }
     50     return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks);
     51 
     52 exit:
     53     /* Cleanup for path */
     54     path_cleanup(&path);
     55 
     56     return return_value;
     57 }
     58 
     59 PyDoc_STRVAR(os_lstat__doc__,
     60 "lstat($module, /, path, *, dir_fd=None)\n"
     61 "--\n"
     62 "\n"
     63 "Perform a stat system call on the given path, without following symbolic links.\n"
     64 "\n"
     65 "Like stat(), but do not follow symbolic links.\n"
     66 "Equivalent to stat(path, follow_symlinks=False).");
     67 
     68 #define OS_LSTAT_METHODDEF    \
     69     {"lstat", (PyCFunction)os_lstat, METH_FASTCALL, os_lstat__doc__},
     70 
     71 static PyObject *
     72 os_lstat_impl(PyObject *module, path_t *path, int dir_fd);
     73 
     74 static PyObject *
     75 os_lstat(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
     76 {
     77     PyObject *return_value = NULL;
     78     static const char * const _keywords[] = {"path", "dir_fd", NULL};
     79     static _PyArg_Parser _parser = {"O&|$O&:lstat", _keywords, 0};
     80     path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0);
     81     int dir_fd = DEFAULT_DIR_FD;
     82 
     83     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
     84         path_converter, &path, FSTATAT_DIR_FD_CONVERTER, &dir_fd)) {
     85         goto exit;
     86     }
     87     return_value = os_lstat_impl(module, &path, dir_fd);
     88 
     89 exit:
     90     /* Cleanup for path */
     91     path_cleanup(&path);
     92 
     93     return return_value;
     94 }
     95 
     96 PyDoc_STRVAR(os_access__doc__,
     97 "access($module, /, path, mode, *, dir_fd=None, effective_ids=False,\n"
     98 "       follow_symlinks=True)\n"
     99 "--\n"
    100 "\n"
    101 "Use the real uid/gid to test for access to a path.\n"
    102 "\n"
    103 "  path\n"
    104 "    Path to be tested; can be string or bytes\n"
    105 "  mode\n"
    106 "    Operating-system mode bitfield.  Can be F_OK to test existence,\n"
    107 "    or the inclusive-OR of R_OK, W_OK, and X_OK.\n"
    108 "  dir_fd\n"
    109 "    If not None, it should be a file descriptor open to a directory,\n"
    110 "    and path should be relative; path will then be relative to that\n"
    111 "    directory.\n"
    112 "  effective_ids\n"
    113 "    If True, access will use the effective uid/gid instead of\n"
    114 "    the real uid/gid.\n"
    115 "  follow_symlinks\n"
    116 "    If False, and the last element of the path is a symbolic link,\n"
    117 "    access will examine the symbolic link itself instead of the file\n"
    118 "    the link points to.\n"
    119 "\n"
    120 "dir_fd, effective_ids, and follow_symlinks may not be implemented\n"
    121 "  on your platform.  If they are unavailable, using them will raise a\n"
    122 "  NotImplementedError.\n"
    123 "\n"
    124 "Note that most operations will use the effective uid/gid, therefore this\n"
    125 "  routine can be used in a suid/sgid environment to test if the invoking user\n"
    126 "  has the specified access to the path.");
    127 
    128 #define OS_ACCESS_METHODDEF    \
    129     {"access", (PyCFunction)os_access, METH_FASTCALL, os_access__doc__},
    130 
    131 static int
    132 os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd,
    133                int effective_ids, int follow_symlinks);
    134 
    135 static PyObject *
    136 os_access(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    137 {
    138     PyObject *return_value = NULL;
    139     static const char * const _keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL};
    140     static _PyArg_Parser _parser = {"O&i|$O&pp:access", _keywords, 0};
    141     path_t path = PATH_T_INITIALIZE("access", "path", 0, 0);
    142     int mode;
    143     int dir_fd = DEFAULT_DIR_FD;
    144     int effective_ids = 0;
    145     int follow_symlinks = 1;
    146     int _return_value;
    147 
    148     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    149         path_converter, &path, &mode, FACCESSAT_DIR_FD_CONVERTER, &dir_fd, &effective_ids, &follow_symlinks)) {
    150         goto exit;
    151     }
    152     _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks);
    153     if ((_return_value == -1) && PyErr_Occurred()) {
    154         goto exit;
    155     }
    156     return_value = PyBool_FromLong((long)_return_value);
    157 
    158 exit:
    159     /* Cleanup for path */
    160     path_cleanup(&path);
    161 
    162     return return_value;
    163 }
    164 
    165 #if defined(HAVE_TTYNAME)
    166 
    167 PyDoc_STRVAR(os_ttyname__doc__,
    168 "ttyname($module, fd, /)\n"
    169 "--\n"
    170 "\n"
    171 "Return the name of the terminal device connected to \'fd\'.\n"
    172 "\n"
    173 "  fd\n"
    174 "    Integer file descriptor handle.");
    175 
    176 #define OS_TTYNAME_METHODDEF    \
    177     {"ttyname", (PyCFunction)os_ttyname, METH_O, os_ttyname__doc__},
    178 
    179 static char *
    180 os_ttyname_impl(PyObject *module, int fd);
    181 
    182 static PyObject *
    183 os_ttyname(PyObject *module, PyObject *arg)
    184 {
    185     PyObject *return_value = NULL;
    186     int fd;
    187     char *_return_value;
    188 
    189     if (!PyArg_Parse(arg, "i:ttyname", &fd)) {
    190         goto exit;
    191     }
    192     _return_value = os_ttyname_impl(module, fd);
    193     if (_return_value == NULL) {
    194         goto exit;
    195     }
    196     return_value = PyUnicode_DecodeFSDefault(_return_value);
    197 
    198 exit:
    199     return return_value;
    200 }
    201 
    202 #endif /* defined(HAVE_TTYNAME) */
    203 
    204 #if defined(HAVE_CTERMID)
    205 
    206 PyDoc_STRVAR(os_ctermid__doc__,
    207 "ctermid($module, /)\n"
    208 "--\n"
    209 "\n"
    210 "Return the name of the controlling terminal for this process.");
    211 
    212 #define OS_CTERMID_METHODDEF    \
    213     {"ctermid", (PyCFunction)os_ctermid, METH_NOARGS, os_ctermid__doc__},
    214 
    215 static PyObject *
    216 os_ctermid_impl(PyObject *module);
    217 
    218 static PyObject *
    219 os_ctermid(PyObject *module, PyObject *Py_UNUSED(ignored))
    220 {
    221     return os_ctermid_impl(module);
    222 }
    223 
    224 #endif /* defined(HAVE_CTERMID) */
    225 
    226 PyDoc_STRVAR(os_chdir__doc__,
    227 "chdir($module, /, path)\n"
    228 "--\n"
    229 "\n"
    230 "Change the current working directory to the specified path.\n"
    231 "\n"
    232 "path may always be specified as a string.\n"
    233 "On some platforms, path may also be specified as an open file descriptor.\n"
    234 "  If this functionality is unavailable, using it raises an exception.");
    235 
    236 #define OS_CHDIR_METHODDEF    \
    237     {"chdir", (PyCFunction)os_chdir, METH_FASTCALL, os_chdir__doc__},
    238 
    239 static PyObject *
    240 os_chdir_impl(PyObject *module, path_t *path);
    241 
    242 static PyObject *
    243 os_chdir(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    244 {
    245     PyObject *return_value = NULL;
    246     static const char * const _keywords[] = {"path", NULL};
    247     static _PyArg_Parser _parser = {"O&:chdir", _keywords, 0};
    248     path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR);
    249 
    250     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    251         path_converter, &path)) {
    252         goto exit;
    253     }
    254     return_value = os_chdir_impl(module, &path);
    255 
    256 exit:
    257     /* Cleanup for path */
    258     path_cleanup(&path);
    259 
    260     return return_value;
    261 }
    262 
    263 #if defined(HAVE_FCHDIR)
    264 
    265 PyDoc_STRVAR(os_fchdir__doc__,
    266 "fchdir($module, /, fd)\n"
    267 "--\n"
    268 "\n"
    269 "Change to the directory of the given file descriptor.\n"
    270 "\n"
    271 "fd must be opened on a directory, not a file.\n"
    272 "Equivalent to os.chdir(fd).");
    273 
    274 #define OS_FCHDIR_METHODDEF    \
    275     {"fchdir", (PyCFunction)os_fchdir, METH_FASTCALL, os_fchdir__doc__},
    276 
    277 static PyObject *
    278 os_fchdir_impl(PyObject *module, int fd);
    279 
    280 static PyObject *
    281 os_fchdir(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    282 {
    283     PyObject *return_value = NULL;
    284     static const char * const _keywords[] = {"fd", NULL};
    285     static _PyArg_Parser _parser = {"O&:fchdir", _keywords, 0};
    286     int fd;
    287 
    288     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    289         fildes_converter, &fd)) {
    290         goto exit;
    291     }
    292     return_value = os_fchdir_impl(module, fd);
    293 
    294 exit:
    295     return return_value;
    296 }
    297 
    298 #endif /* defined(HAVE_FCHDIR) */
    299 
    300 PyDoc_STRVAR(os_chmod__doc__,
    301 "chmod($module, /, path, mode, *, dir_fd=None, follow_symlinks=True)\n"
    302 "--\n"
    303 "\n"
    304 "Change the access permissions of a file.\n"
    305 "\n"
    306 "  path\n"
    307 "    Path to be modified.  May always be specified as a str or bytes.\n"
    308 "    On some platforms, path may also be specified as an open file descriptor.\n"
    309 "    If this functionality is unavailable, using it raises an exception.\n"
    310 "  mode\n"
    311 "    Operating-system mode bitfield.\n"
    312 "  dir_fd\n"
    313 "    If not None, it should be a file descriptor open to a directory,\n"
    314 "    and path should be relative; path will then be relative to that\n"
    315 "    directory.\n"
    316 "  follow_symlinks\n"
    317 "    If False, and the last element of the path is a symbolic link,\n"
    318 "    chmod will modify the symbolic link itself instead of the file\n"
    319 "    the link points to.\n"
    320 "\n"
    321 "It is an error to use dir_fd or follow_symlinks when specifying path as\n"
    322 "  an open file descriptor.\n"
    323 "dir_fd and follow_symlinks may not be implemented on your platform.\n"
    324 "  If they are unavailable, using them will raise a NotImplementedError.");
    325 
    326 #define OS_CHMOD_METHODDEF    \
    327     {"chmod", (PyCFunction)os_chmod, METH_FASTCALL, os_chmod__doc__},
    328 
    329 static PyObject *
    330 os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd,
    331               int follow_symlinks);
    332 
    333 static PyObject *
    334 os_chmod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    335 {
    336     PyObject *return_value = NULL;
    337     static const char * const _keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL};
    338     static _PyArg_Parser _parser = {"O&i|$O&p:chmod", _keywords, 0};
    339     path_t path = PATH_T_INITIALIZE("chmod", "path", 0, PATH_HAVE_FCHMOD);
    340     int mode;
    341     int dir_fd = DEFAULT_DIR_FD;
    342     int follow_symlinks = 1;
    343 
    344     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    345         path_converter, &path, &mode, FCHMODAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
    346         goto exit;
    347     }
    348     return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks);
    349 
    350 exit:
    351     /* Cleanup for path */
    352     path_cleanup(&path);
    353 
    354     return return_value;
    355 }
    356 
    357 #if defined(HAVE_FCHMOD)
    358 
    359 PyDoc_STRVAR(os_fchmod__doc__,
    360 "fchmod($module, /, fd, mode)\n"
    361 "--\n"
    362 "\n"
    363 "Change the access permissions of the file given by file descriptor fd.\n"
    364 "\n"
    365 "Equivalent to os.chmod(fd, mode).");
    366 
    367 #define OS_FCHMOD_METHODDEF    \
    368     {"fchmod", (PyCFunction)os_fchmod, METH_FASTCALL, os_fchmod__doc__},
    369 
    370 static PyObject *
    371 os_fchmod_impl(PyObject *module, int fd, int mode);
    372 
    373 static PyObject *
    374 os_fchmod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    375 {
    376     PyObject *return_value = NULL;
    377     static const char * const _keywords[] = {"fd", "mode", NULL};
    378     static _PyArg_Parser _parser = {"ii:fchmod", _keywords, 0};
    379     int fd;
    380     int mode;
    381 
    382     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    383         &fd, &mode)) {
    384         goto exit;
    385     }
    386     return_value = os_fchmod_impl(module, fd, mode);
    387 
    388 exit:
    389     return return_value;
    390 }
    391 
    392 #endif /* defined(HAVE_FCHMOD) */
    393 
    394 #if defined(HAVE_LCHMOD)
    395 
    396 PyDoc_STRVAR(os_lchmod__doc__,
    397 "lchmod($module, /, path, mode)\n"
    398 "--\n"
    399 "\n"
    400 "Change the access permissions of a file, without following symbolic links.\n"
    401 "\n"
    402 "If path is a symlink, this affects the link itself rather than the target.\n"
    403 "Equivalent to chmod(path, mode, follow_symlinks=False).\"");
    404 
    405 #define OS_LCHMOD_METHODDEF    \
    406     {"lchmod", (PyCFunction)os_lchmod, METH_FASTCALL, os_lchmod__doc__},
    407 
    408 static PyObject *
    409 os_lchmod_impl(PyObject *module, path_t *path, int mode);
    410 
    411 static PyObject *
    412 os_lchmod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    413 {
    414     PyObject *return_value = NULL;
    415     static const char * const _keywords[] = {"path", "mode", NULL};
    416     static _PyArg_Parser _parser = {"O&i:lchmod", _keywords, 0};
    417     path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0);
    418     int mode;
    419 
    420     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    421         path_converter, &path, &mode)) {
    422         goto exit;
    423     }
    424     return_value = os_lchmod_impl(module, &path, mode);
    425 
    426 exit:
    427     /* Cleanup for path */
    428     path_cleanup(&path);
    429 
    430     return return_value;
    431 }
    432 
    433 #endif /* defined(HAVE_LCHMOD) */
    434 
    435 #if defined(HAVE_CHFLAGS)
    436 
    437 PyDoc_STRVAR(os_chflags__doc__,
    438 "chflags($module, /, path, flags, follow_symlinks=True)\n"
    439 "--\n"
    440 "\n"
    441 "Set file flags.\n"
    442 "\n"
    443 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
    444 "  link, chflags will change flags on the symbolic link itself instead of the\n"
    445 "  file the link points to.\n"
    446 "follow_symlinks may not be implemented on your platform.  If it is\n"
    447 "unavailable, using it will raise a NotImplementedError.");
    448 
    449 #define OS_CHFLAGS_METHODDEF    \
    450     {"chflags", (PyCFunction)os_chflags, METH_FASTCALL, os_chflags__doc__},
    451 
    452 static PyObject *
    453 os_chflags_impl(PyObject *module, path_t *path, unsigned long flags,
    454                 int follow_symlinks);
    455 
    456 static PyObject *
    457 os_chflags(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    458 {
    459     PyObject *return_value = NULL;
    460     static const char * const _keywords[] = {"path", "flags", "follow_symlinks", NULL};
    461     static _PyArg_Parser _parser = {"O&k|p:chflags", _keywords, 0};
    462     path_t path = PATH_T_INITIALIZE("chflags", "path", 0, 0);
    463     unsigned long flags;
    464     int follow_symlinks = 1;
    465 
    466     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    467         path_converter, &path, &flags, &follow_symlinks)) {
    468         goto exit;
    469     }
    470     return_value = os_chflags_impl(module, &path, flags, follow_symlinks);
    471 
    472 exit:
    473     /* Cleanup for path */
    474     path_cleanup(&path);
    475 
    476     return return_value;
    477 }
    478 
    479 #endif /* defined(HAVE_CHFLAGS) */
    480 
    481 #if defined(HAVE_LCHFLAGS)
    482 
    483 PyDoc_STRVAR(os_lchflags__doc__,
    484 "lchflags($module, /, path, flags)\n"
    485 "--\n"
    486 "\n"
    487 "Set file flags.\n"
    488 "\n"
    489 "This function will not follow symbolic links.\n"
    490 "Equivalent to chflags(path, flags, follow_symlinks=False).");
    491 
    492 #define OS_LCHFLAGS_METHODDEF    \
    493     {"lchflags", (PyCFunction)os_lchflags, METH_FASTCALL, os_lchflags__doc__},
    494 
    495 static PyObject *
    496 os_lchflags_impl(PyObject *module, path_t *path, unsigned long flags);
    497 
    498 static PyObject *
    499 os_lchflags(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    500 {
    501     PyObject *return_value = NULL;
    502     static const char * const _keywords[] = {"path", "flags", NULL};
    503     static _PyArg_Parser _parser = {"O&k:lchflags", _keywords, 0};
    504     path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0);
    505     unsigned long flags;
    506 
    507     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    508         path_converter, &path, &flags)) {
    509         goto exit;
    510     }
    511     return_value = os_lchflags_impl(module, &path, flags);
    512 
    513 exit:
    514     /* Cleanup for path */
    515     path_cleanup(&path);
    516 
    517     return return_value;
    518 }
    519 
    520 #endif /* defined(HAVE_LCHFLAGS) */
    521 
    522 #if defined(HAVE_CHROOT)
    523 
    524 PyDoc_STRVAR(os_chroot__doc__,
    525 "chroot($module, /, path)\n"
    526 "--\n"
    527 "\n"
    528 "Change root directory to path.");
    529 
    530 #define OS_CHROOT_METHODDEF    \
    531     {"chroot", (PyCFunction)os_chroot, METH_FASTCALL, os_chroot__doc__},
    532 
    533 static PyObject *
    534 os_chroot_impl(PyObject *module, path_t *path);
    535 
    536 static PyObject *
    537 os_chroot(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    538 {
    539     PyObject *return_value = NULL;
    540     static const char * const _keywords[] = {"path", NULL};
    541     static _PyArg_Parser _parser = {"O&:chroot", _keywords, 0};
    542     path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0);
    543 
    544     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    545         path_converter, &path)) {
    546         goto exit;
    547     }
    548     return_value = os_chroot_impl(module, &path);
    549 
    550 exit:
    551     /* Cleanup for path */
    552     path_cleanup(&path);
    553 
    554     return return_value;
    555 }
    556 
    557 #endif /* defined(HAVE_CHROOT) */
    558 
    559 #if defined(HAVE_FSYNC)
    560 
    561 PyDoc_STRVAR(os_fsync__doc__,
    562 "fsync($module, /, fd)\n"
    563 "--\n"
    564 "\n"
    565 "Force write of fd to disk.");
    566 
    567 #define OS_FSYNC_METHODDEF    \
    568     {"fsync", (PyCFunction)os_fsync, METH_FASTCALL, os_fsync__doc__},
    569 
    570 static PyObject *
    571 os_fsync_impl(PyObject *module, int fd);
    572 
    573 static PyObject *
    574 os_fsync(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    575 {
    576     PyObject *return_value = NULL;
    577     static const char * const _keywords[] = {"fd", NULL};
    578     static _PyArg_Parser _parser = {"O&:fsync", _keywords, 0};
    579     int fd;
    580 
    581     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    582         fildes_converter, &fd)) {
    583         goto exit;
    584     }
    585     return_value = os_fsync_impl(module, fd);
    586 
    587 exit:
    588     return return_value;
    589 }
    590 
    591 #endif /* defined(HAVE_FSYNC) */
    592 
    593 #if defined(HAVE_SYNC)
    594 
    595 PyDoc_STRVAR(os_sync__doc__,
    596 "sync($module, /)\n"
    597 "--\n"
    598 "\n"
    599 "Force write of everything to disk.");
    600 
    601 #define OS_SYNC_METHODDEF    \
    602     {"sync", (PyCFunction)os_sync, METH_NOARGS, os_sync__doc__},
    603 
    604 static PyObject *
    605 os_sync_impl(PyObject *module);
    606 
    607 static PyObject *
    608 os_sync(PyObject *module, PyObject *Py_UNUSED(ignored))
    609 {
    610     return os_sync_impl(module);
    611 }
    612 
    613 #endif /* defined(HAVE_SYNC) */
    614 
    615 #if defined(HAVE_FDATASYNC)
    616 
    617 PyDoc_STRVAR(os_fdatasync__doc__,
    618 "fdatasync($module, /, fd)\n"
    619 "--\n"
    620 "\n"
    621 "Force write of fd to disk without forcing update of metadata.");
    622 
    623 #define OS_FDATASYNC_METHODDEF    \
    624     {"fdatasync", (PyCFunction)os_fdatasync, METH_FASTCALL, os_fdatasync__doc__},
    625 
    626 static PyObject *
    627 os_fdatasync_impl(PyObject *module, int fd);
    628 
    629 static PyObject *
    630 os_fdatasync(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    631 {
    632     PyObject *return_value = NULL;
    633     static const char * const _keywords[] = {"fd", NULL};
    634     static _PyArg_Parser _parser = {"O&:fdatasync", _keywords, 0};
    635     int fd;
    636 
    637     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    638         fildes_converter, &fd)) {
    639         goto exit;
    640     }
    641     return_value = os_fdatasync_impl(module, fd);
    642 
    643 exit:
    644     return return_value;
    645 }
    646 
    647 #endif /* defined(HAVE_FDATASYNC) */
    648 
    649 #if defined(HAVE_CHOWN)
    650 
    651 PyDoc_STRVAR(os_chown__doc__,
    652 "chown($module, /, path, uid, gid, *, dir_fd=None, follow_symlinks=True)\n"
    653 "--\n"
    654 "\n"
    655 "Change the owner and group id of path to the numeric uid and gid.\\\n"
    656 "\n"
    657 "  path\n"
    658 "    Path to be examined; can be string, bytes, or open-file-descriptor int.\n"
    659 "  dir_fd\n"
    660 "    If not None, it should be a file descriptor open to a directory,\n"
    661 "    and path should be relative; path will then be relative to that\n"
    662 "    directory.\n"
    663 "  follow_symlinks\n"
    664 "    If False, and the last element of the path is a symbolic link,\n"
    665 "    stat will examine the symbolic link itself instead of the file\n"
    666 "    the link points to.\n"
    667 "\n"
    668 "path may always be specified as a string.\n"
    669 "On some platforms, path may also be specified as an open file descriptor.\n"
    670 "  If this functionality is unavailable, using it raises an exception.\n"
    671 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
    672 "  and path should be relative; path will then be relative to that directory.\n"
    673 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
    674 "  link, chown will modify the symbolic link itself instead of the file the\n"
    675 "  link points to.\n"
    676 "It is an error to use dir_fd or follow_symlinks when specifying path as\n"
    677 "  an open file descriptor.\n"
    678 "dir_fd and follow_symlinks may not be implemented on your platform.\n"
    679 "  If they are unavailable, using them will raise a NotImplementedError.");
    680 
    681 #define OS_CHOWN_METHODDEF    \
    682     {"chown", (PyCFunction)os_chown, METH_FASTCALL, os_chown__doc__},
    683 
    684 static PyObject *
    685 os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid,
    686               int dir_fd, int follow_symlinks);
    687 
    688 static PyObject *
    689 os_chown(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    690 {
    691     PyObject *return_value = NULL;
    692     static const char * const _keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL};
    693     static _PyArg_Parser _parser = {"O&O&O&|$O&p:chown", _keywords, 0};
    694     path_t path = PATH_T_INITIALIZE("chown", "path", 0, PATH_HAVE_FCHOWN);
    695     uid_t uid;
    696     gid_t gid;
    697     int dir_fd = DEFAULT_DIR_FD;
    698     int follow_symlinks = 1;
    699 
    700     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    701         path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid, FCHOWNAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
    702         goto exit;
    703     }
    704     return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks);
    705 
    706 exit:
    707     /* Cleanup for path */
    708     path_cleanup(&path);
    709 
    710     return return_value;
    711 }
    712 
    713 #endif /* defined(HAVE_CHOWN) */
    714 
    715 #if defined(HAVE_FCHOWN)
    716 
    717 PyDoc_STRVAR(os_fchown__doc__,
    718 "fchown($module, /, fd, uid, gid)\n"
    719 "--\n"
    720 "\n"
    721 "Change the owner and group id of the file specified by file descriptor.\n"
    722 "\n"
    723 "Equivalent to os.chown(fd, uid, gid).");
    724 
    725 #define OS_FCHOWN_METHODDEF    \
    726     {"fchown", (PyCFunction)os_fchown, METH_FASTCALL, os_fchown__doc__},
    727 
    728 static PyObject *
    729 os_fchown_impl(PyObject *module, int fd, uid_t uid, gid_t gid);
    730 
    731 static PyObject *
    732 os_fchown(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    733 {
    734     PyObject *return_value = NULL;
    735     static const char * const _keywords[] = {"fd", "uid", "gid", NULL};
    736     static _PyArg_Parser _parser = {"iO&O&:fchown", _keywords, 0};
    737     int fd;
    738     uid_t uid;
    739     gid_t gid;
    740 
    741     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    742         &fd, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) {
    743         goto exit;
    744     }
    745     return_value = os_fchown_impl(module, fd, uid, gid);
    746 
    747 exit:
    748     return return_value;
    749 }
    750 
    751 #endif /* defined(HAVE_FCHOWN) */
    752 
    753 #if defined(HAVE_LCHOWN)
    754 
    755 PyDoc_STRVAR(os_lchown__doc__,
    756 "lchown($module, /, path, uid, gid)\n"
    757 "--\n"
    758 "\n"
    759 "Change the owner and group id of path to the numeric uid and gid.\n"
    760 "\n"
    761 "This function will not follow symbolic links.\n"
    762 "Equivalent to os.chown(path, uid, gid, follow_symlinks=False).");
    763 
    764 #define OS_LCHOWN_METHODDEF    \
    765     {"lchown", (PyCFunction)os_lchown, METH_FASTCALL, os_lchown__doc__},
    766 
    767 static PyObject *
    768 os_lchown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid);
    769 
    770 static PyObject *
    771 os_lchown(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    772 {
    773     PyObject *return_value = NULL;
    774     static const char * const _keywords[] = {"path", "uid", "gid", NULL};
    775     static _PyArg_Parser _parser = {"O&O&O&:lchown", _keywords, 0};
    776     path_t path = PATH_T_INITIALIZE("lchown", "path", 0, 0);
    777     uid_t uid;
    778     gid_t gid;
    779 
    780     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    781         path_converter, &path, _Py_Uid_Converter, &uid, _Py_Gid_Converter, &gid)) {
    782         goto exit;
    783     }
    784     return_value = os_lchown_impl(module, &path, uid, gid);
    785 
    786 exit:
    787     /* Cleanup for path */
    788     path_cleanup(&path);
    789 
    790     return return_value;
    791 }
    792 
    793 #endif /* defined(HAVE_LCHOWN) */
    794 
    795 PyDoc_STRVAR(os_getcwd__doc__,
    796 "getcwd($module, /)\n"
    797 "--\n"
    798 "\n"
    799 "Return a unicode string representing the current working directory.");
    800 
    801 #define OS_GETCWD_METHODDEF    \
    802     {"getcwd", (PyCFunction)os_getcwd, METH_NOARGS, os_getcwd__doc__},
    803 
    804 static PyObject *
    805 os_getcwd_impl(PyObject *module);
    806 
    807 static PyObject *
    808 os_getcwd(PyObject *module, PyObject *Py_UNUSED(ignored))
    809 {
    810     return os_getcwd_impl(module);
    811 }
    812 
    813 PyDoc_STRVAR(os_getcwdb__doc__,
    814 "getcwdb($module, /)\n"
    815 "--\n"
    816 "\n"
    817 "Return a bytes string representing the current working directory.");
    818 
    819 #define OS_GETCWDB_METHODDEF    \
    820     {"getcwdb", (PyCFunction)os_getcwdb, METH_NOARGS, os_getcwdb__doc__},
    821 
    822 static PyObject *
    823 os_getcwdb_impl(PyObject *module);
    824 
    825 static PyObject *
    826 os_getcwdb(PyObject *module, PyObject *Py_UNUSED(ignored))
    827 {
    828     return os_getcwdb_impl(module);
    829 }
    830 
    831 #if defined(HAVE_LINK)
    832 
    833 PyDoc_STRVAR(os_link__doc__,
    834 "link($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None,\n"
    835 "     follow_symlinks=True)\n"
    836 "--\n"
    837 "\n"
    838 "Create a hard link to a file.\n"
    839 "\n"
    840 "If either src_dir_fd or dst_dir_fd is not None, it should be a file\n"
    841 "  descriptor open to a directory, and the respective path string (src or dst)\n"
    842 "  should be relative; the path will then be relative to that directory.\n"
    843 "If follow_symlinks is False, and the last element of src is a symbolic\n"
    844 "  link, link will create a link to the symbolic link itself instead of the\n"
    845 "  file the link points to.\n"
    846 "src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your\n"
    847 "  platform.  If they are unavailable, using them will raise a\n"
    848 "  NotImplementedError.");
    849 
    850 #define OS_LINK_METHODDEF    \
    851     {"link", (PyCFunction)os_link, METH_FASTCALL, os_link__doc__},
    852 
    853 static PyObject *
    854 os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd,
    855              int dst_dir_fd, int follow_symlinks);
    856 
    857 static PyObject *
    858 os_link(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    859 {
    860     PyObject *return_value = NULL;
    861     static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL};
    862     static _PyArg_Parser _parser = {"O&O&|$O&O&p:link", _keywords, 0};
    863     path_t src = PATH_T_INITIALIZE("link", "src", 0, 0);
    864     path_t dst = PATH_T_INITIALIZE("link", "dst", 0, 0);
    865     int src_dir_fd = DEFAULT_DIR_FD;
    866     int dst_dir_fd = DEFAULT_DIR_FD;
    867     int follow_symlinks = 1;
    868 
    869     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    870         path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd, &follow_symlinks)) {
    871         goto exit;
    872     }
    873     return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks);
    874 
    875 exit:
    876     /* Cleanup for src */
    877     path_cleanup(&src);
    878     /* Cleanup for dst */
    879     path_cleanup(&dst);
    880 
    881     return return_value;
    882 }
    883 
    884 #endif /* defined(HAVE_LINK) */
    885 
    886 PyDoc_STRVAR(os_listdir__doc__,
    887 "listdir($module, /, path=None)\n"
    888 "--\n"
    889 "\n"
    890 "Return a list containing the names of the files in the directory.\n"
    891 "\n"
    892 "path can be specified as either str or bytes.  If path is bytes,\n"
    893 "  the filenames returned will also be bytes; in all other circumstances\n"
    894 "  the filenames returned will be str.\n"
    895 "If path is None, uses the path=\'.\'.\n"
    896 "On some platforms, path may also be specified as an open file descriptor;\\\n"
    897 "  the file descriptor must refer to a directory.\n"
    898 "  If this functionality is unavailable, using it raises NotImplementedError.\n"
    899 "\n"
    900 "The list is in arbitrary order.  It does not include the special\n"
    901 "entries \'.\' and \'..\' even if they are present in the directory.");
    902 
    903 #define OS_LISTDIR_METHODDEF    \
    904     {"listdir", (PyCFunction)os_listdir, METH_FASTCALL, os_listdir__doc__},
    905 
    906 static PyObject *
    907 os_listdir_impl(PyObject *module, path_t *path);
    908 
    909 static PyObject *
    910 os_listdir(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
    911 {
    912     PyObject *return_value = NULL;
    913     static const char * const _keywords[] = {"path", NULL};
    914     static _PyArg_Parser _parser = {"|O&:listdir", _keywords, 0};
    915     path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR);
    916 
    917     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
    918         path_converter, &path)) {
    919         goto exit;
    920     }
    921     return_value = os_listdir_impl(module, &path);
    922 
    923 exit:
    924     /* Cleanup for path */
    925     path_cleanup(&path);
    926 
    927     return return_value;
    928 }
    929 
    930 #if defined(MS_WINDOWS)
    931 
    932 PyDoc_STRVAR(os__getfullpathname__doc__,
    933 "_getfullpathname($module, path, /)\n"
    934 "--\n"
    935 "\n");
    936 
    937 #define OS__GETFULLPATHNAME_METHODDEF    \
    938     {"_getfullpathname", (PyCFunction)os__getfullpathname, METH_O, os__getfullpathname__doc__},
    939 
    940 static PyObject *
    941 os__getfullpathname_impl(PyObject *module, path_t *path);
    942 
    943 static PyObject *
    944 os__getfullpathname(PyObject *module, PyObject *arg)
    945 {
    946     PyObject *return_value = NULL;
    947     path_t path = PATH_T_INITIALIZE("_getfullpathname", "path", 0, 0);
    948 
    949     if (!PyArg_Parse(arg, "O&:_getfullpathname", path_converter, &path)) {
    950         goto exit;
    951     }
    952     return_value = os__getfullpathname_impl(module, &path);
    953 
    954 exit:
    955     /* Cleanup for path */
    956     path_cleanup(&path);
    957 
    958     return return_value;
    959 }
    960 
    961 #endif /* defined(MS_WINDOWS) */
    962 
    963 #if defined(MS_WINDOWS)
    964 
    965 PyDoc_STRVAR(os__getfinalpathname__doc__,
    966 "_getfinalpathname($module, path, /)\n"
    967 "--\n"
    968 "\n"
    969 "A helper function for samepath on windows.");
    970 
    971 #define OS__GETFINALPATHNAME_METHODDEF    \
    972     {"_getfinalpathname", (PyCFunction)os__getfinalpathname, METH_O, os__getfinalpathname__doc__},
    973 
    974 static PyObject *
    975 os__getfinalpathname_impl(PyObject *module, PyObject *path);
    976 
    977 static PyObject *
    978 os__getfinalpathname(PyObject *module, PyObject *arg)
    979 {
    980     PyObject *return_value = NULL;
    981     PyObject *path;
    982 
    983     if (!PyArg_Parse(arg, "U:_getfinalpathname", &path)) {
    984         goto exit;
    985     }
    986     return_value = os__getfinalpathname_impl(module, path);
    987 
    988 exit:
    989     return return_value;
    990 }
    991 
    992 #endif /* defined(MS_WINDOWS) */
    993 
    994 #if defined(MS_WINDOWS)
    995 
    996 PyDoc_STRVAR(os__isdir__doc__,
    997 "_isdir($module, path, /)\n"
    998 "--\n"
    999 "\n"
   1000 "Return true if the pathname refers to an existing directory.");
   1001 
   1002 #define OS__ISDIR_METHODDEF    \
   1003     {"_isdir", (PyCFunction)os__isdir, METH_O, os__isdir__doc__},
   1004 
   1005 static PyObject *
   1006 os__isdir_impl(PyObject *module, path_t *path);
   1007 
   1008 static PyObject *
   1009 os__isdir(PyObject *module, PyObject *arg)
   1010 {
   1011     PyObject *return_value = NULL;
   1012     path_t path = PATH_T_INITIALIZE("_isdir", "path", 0, 0);
   1013 
   1014     if (!PyArg_Parse(arg, "O&:_isdir", path_converter, &path)) {
   1015         goto exit;
   1016     }
   1017     return_value = os__isdir_impl(module, &path);
   1018 
   1019 exit:
   1020     /* Cleanup for path */
   1021     path_cleanup(&path);
   1022 
   1023     return return_value;
   1024 }
   1025 
   1026 #endif /* defined(MS_WINDOWS) */
   1027 
   1028 #if defined(MS_WINDOWS)
   1029 
   1030 PyDoc_STRVAR(os__getvolumepathname__doc__,
   1031 "_getvolumepathname($module, /, path)\n"
   1032 "--\n"
   1033 "\n"
   1034 "A helper function for ismount on Win32.");
   1035 
   1036 #define OS__GETVOLUMEPATHNAME_METHODDEF    \
   1037     {"_getvolumepathname", (PyCFunction)os__getvolumepathname, METH_FASTCALL, os__getvolumepathname__doc__},
   1038 
   1039 static PyObject *
   1040 os__getvolumepathname_impl(PyObject *module, PyObject *path);
   1041 
   1042 static PyObject *
   1043 os__getvolumepathname(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1044 {
   1045     PyObject *return_value = NULL;
   1046     static const char * const _keywords[] = {"path", NULL};
   1047     static _PyArg_Parser _parser = {"U:_getvolumepathname", _keywords, 0};
   1048     PyObject *path;
   1049 
   1050     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1051         &path)) {
   1052         goto exit;
   1053     }
   1054     return_value = os__getvolumepathname_impl(module, path);
   1055 
   1056 exit:
   1057     return return_value;
   1058 }
   1059 
   1060 #endif /* defined(MS_WINDOWS) */
   1061 
   1062 PyDoc_STRVAR(os_mkdir__doc__,
   1063 "mkdir($module, /, path, mode=511, *, dir_fd=None)\n"
   1064 "--\n"
   1065 "\n"
   1066 "Create a directory.\n"
   1067 "\n"
   1068 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   1069 "  and path should be relative; path will then be relative to that directory.\n"
   1070 "dir_fd may not be implemented on your platform.\n"
   1071 "  If it is unavailable, using it will raise a NotImplementedError.\n"
   1072 "\n"
   1073 "The mode argument is ignored on Windows.");
   1074 
   1075 #define OS_MKDIR_METHODDEF    \
   1076     {"mkdir", (PyCFunction)os_mkdir, METH_FASTCALL, os_mkdir__doc__},
   1077 
   1078 static PyObject *
   1079 os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd);
   1080 
   1081 static PyObject *
   1082 os_mkdir(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1083 {
   1084     PyObject *return_value = NULL;
   1085     static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL};
   1086     static _PyArg_Parser _parser = {"O&|i$O&:mkdir", _keywords, 0};
   1087     path_t path = PATH_T_INITIALIZE("mkdir", "path", 0, 0);
   1088     int mode = 511;
   1089     int dir_fd = DEFAULT_DIR_FD;
   1090 
   1091     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1092         path_converter, &path, &mode, MKDIRAT_DIR_FD_CONVERTER, &dir_fd)) {
   1093         goto exit;
   1094     }
   1095     return_value = os_mkdir_impl(module, &path, mode, dir_fd);
   1096 
   1097 exit:
   1098     /* Cleanup for path */
   1099     path_cleanup(&path);
   1100 
   1101     return return_value;
   1102 }
   1103 
   1104 #if defined(HAVE_NICE)
   1105 
   1106 PyDoc_STRVAR(os_nice__doc__,
   1107 "nice($module, increment, /)\n"
   1108 "--\n"
   1109 "\n"
   1110 "Add increment to the priority of process and return the new priority.");
   1111 
   1112 #define OS_NICE_METHODDEF    \
   1113     {"nice", (PyCFunction)os_nice, METH_O, os_nice__doc__},
   1114 
   1115 static PyObject *
   1116 os_nice_impl(PyObject *module, int increment);
   1117 
   1118 static PyObject *
   1119 os_nice(PyObject *module, PyObject *arg)
   1120 {
   1121     PyObject *return_value = NULL;
   1122     int increment;
   1123 
   1124     if (!PyArg_Parse(arg, "i:nice", &increment)) {
   1125         goto exit;
   1126     }
   1127     return_value = os_nice_impl(module, increment);
   1128 
   1129 exit:
   1130     return return_value;
   1131 }
   1132 
   1133 #endif /* defined(HAVE_NICE) */
   1134 
   1135 #if defined(HAVE_GETPRIORITY)
   1136 
   1137 PyDoc_STRVAR(os_getpriority__doc__,
   1138 "getpriority($module, /, which, who)\n"
   1139 "--\n"
   1140 "\n"
   1141 "Return program scheduling priority.");
   1142 
   1143 #define OS_GETPRIORITY_METHODDEF    \
   1144     {"getpriority", (PyCFunction)os_getpriority, METH_FASTCALL, os_getpriority__doc__},
   1145 
   1146 static PyObject *
   1147 os_getpriority_impl(PyObject *module, int which, int who);
   1148 
   1149 static PyObject *
   1150 os_getpriority(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1151 {
   1152     PyObject *return_value = NULL;
   1153     static const char * const _keywords[] = {"which", "who", NULL};
   1154     static _PyArg_Parser _parser = {"ii:getpriority", _keywords, 0};
   1155     int which;
   1156     int who;
   1157 
   1158     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1159         &which, &who)) {
   1160         goto exit;
   1161     }
   1162     return_value = os_getpriority_impl(module, which, who);
   1163 
   1164 exit:
   1165     return return_value;
   1166 }
   1167 
   1168 #endif /* defined(HAVE_GETPRIORITY) */
   1169 
   1170 #if defined(HAVE_SETPRIORITY)
   1171 
   1172 PyDoc_STRVAR(os_setpriority__doc__,
   1173 "setpriority($module, /, which, who, priority)\n"
   1174 "--\n"
   1175 "\n"
   1176 "Set program scheduling priority.");
   1177 
   1178 #define OS_SETPRIORITY_METHODDEF    \
   1179     {"setpriority", (PyCFunction)os_setpriority, METH_FASTCALL, os_setpriority__doc__},
   1180 
   1181 static PyObject *
   1182 os_setpriority_impl(PyObject *module, int which, int who, int priority);
   1183 
   1184 static PyObject *
   1185 os_setpriority(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1186 {
   1187     PyObject *return_value = NULL;
   1188     static const char * const _keywords[] = {"which", "who", "priority", NULL};
   1189     static _PyArg_Parser _parser = {"iii:setpriority", _keywords, 0};
   1190     int which;
   1191     int who;
   1192     int priority;
   1193 
   1194     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1195         &which, &who, &priority)) {
   1196         goto exit;
   1197     }
   1198     return_value = os_setpriority_impl(module, which, who, priority);
   1199 
   1200 exit:
   1201     return return_value;
   1202 }
   1203 
   1204 #endif /* defined(HAVE_SETPRIORITY) */
   1205 
   1206 PyDoc_STRVAR(os_rename__doc__,
   1207 "rename($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n"
   1208 "--\n"
   1209 "\n"
   1210 "Rename a file or directory.\n"
   1211 "\n"
   1212 "If either src_dir_fd or dst_dir_fd is not None, it should be a file\n"
   1213 "  descriptor open to a directory, and the respective path string (src or dst)\n"
   1214 "  should be relative; the path will then be relative to that directory.\n"
   1215 "src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n"
   1216 "  If they are unavailable, using them will raise a NotImplementedError.");
   1217 
   1218 #define OS_RENAME_METHODDEF    \
   1219     {"rename", (PyCFunction)os_rename, METH_FASTCALL, os_rename__doc__},
   1220 
   1221 static PyObject *
   1222 os_rename_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd,
   1223                int dst_dir_fd);
   1224 
   1225 static PyObject *
   1226 os_rename(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1227 {
   1228     PyObject *return_value = NULL;
   1229     static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL};
   1230     static _PyArg_Parser _parser = {"O&O&|$O&O&:rename", _keywords, 0};
   1231     path_t src = PATH_T_INITIALIZE("rename", "src", 0, 0);
   1232     path_t dst = PATH_T_INITIALIZE("rename", "dst", 0, 0);
   1233     int src_dir_fd = DEFAULT_DIR_FD;
   1234     int dst_dir_fd = DEFAULT_DIR_FD;
   1235 
   1236     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1237         path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) {
   1238         goto exit;
   1239     }
   1240     return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd);
   1241 
   1242 exit:
   1243     /* Cleanup for src */
   1244     path_cleanup(&src);
   1245     /* Cleanup for dst */
   1246     path_cleanup(&dst);
   1247 
   1248     return return_value;
   1249 }
   1250 
   1251 PyDoc_STRVAR(os_replace__doc__,
   1252 "replace($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n"
   1253 "--\n"
   1254 "\n"
   1255 "Rename a file or directory, overwriting the destination.\n"
   1256 "\n"
   1257 "If either src_dir_fd or dst_dir_fd is not None, it should be a file\n"
   1258 "  descriptor open to a directory, and the respective path string (src or dst)\n"
   1259 "  should be relative; the path will then be relative to that directory.\n"
   1260 "src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n"
   1261 "  If they are unavailable, using them will raise a NotImplementedError.\"");
   1262 
   1263 #define OS_REPLACE_METHODDEF    \
   1264     {"replace", (PyCFunction)os_replace, METH_FASTCALL, os_replace__doc__},
   1265 
   1266 static PyObject *
   1267 os_replace_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd,
   1268                 int dst_dir_fd);
   1269 
   1270 static PyObject *
   1271 os_replace(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1272 {
   1273     PyObject *return_value = NULL;
   1274     static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL};
   1275     static _PyArg_Parser _parser = {"O&O&|$O&O&:replace", _keywords, 0};
   1276     path_t src = PATH_T_INITIALIZE("replace", "src", 0, 0);
   1277     path_t dst = PATH_T_INITIALIZE("replace", "dst", 0, 0);
   1278     int src_dir_fd = DEFAULT_DIR_FD;
   1279     int dst_dir_fd = DEFAULT_DIR_FD;
   1280 
   1281     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1282         path_converter, &src, path_converter, &dst, dir_fd_converter, &src_dir_fd, dir_fd_converter, &dst_dir_fd)) {
   1283         goto exit;
   1284     }
   1285     return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd);
   1286 
   1287 exit:
   1288     /* Cleanup for src */
   1289     path_cleanup(&src);
   1290     /* Cleanup for dst */
   1291     path_cleanup(&dst);
   1292 
   1293     return return_value;
   1294 }
   1295 
   1296 PyDoc_STRVAR(os_rmdir__doc__,
   1297 "rmdir($module, /, path, *, dir_fd=None)\n"
   1298 "--\n"
   1299 "\n"
   1300 "Remove a directory.\n"
   1301 "\n"
   1302 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   1303 "  and path should be relative; path will then be relative to that directory.\n"
   1304 "dir_fd may not be implemented on your platform.\n"
   1305 "  If it is unavailable, using it will raise a NotImplementedError.");
   1306 
   1307 #define OS_RMDIR_METHODDEF    \
   1308     {"rmdir", (PyCFunction)os_rmdir, METH_FASTCALL, os_rmdir__doc__},
   1309 
   1310 static PyObject *
   1311 os_rmdir_impl(PyObject *module, path_t *path, int dir_fd);
   1312 
   1313 static PyObject *
   1314 os_rmdir(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1315 {
   1316     PyObject *return_value = NULL;
   1317     static const char * const _keywords[] = {"path", "dir_fd", NULL};
   1318     static _PyArg_Parser _parser = {"O&|$O&:rmdir", _keywords, 0};
   1319     path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0);
   1320     int dir_fd = DEFAULT_DIR_FD;
   1321 
   1322     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1323         path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
   1324         goto exit;
   1325     }
   1326     return_value = os_rmdir_impl(module, &path, dir_fd);
   1327 
   1328 exit:
   1329     /* Cleanup for path */
   1330     path_cleanup(&path);
   1331 
   1332     return return_value;
   1333 }
   1334 
   1335 #if defined(HAVE_SYSTEM) && defined(MS_WINDOWS)
   1336 
   1337 PyDoc_STRVAR(os_system__doc__,
   1338 "system($module, /, command)\n"
   1339 "--\n"
   1340 "\n"
   1341 "Execute the command in a subshell.");
   1342 
   1343 #define OS_SYSTEM_METHODDEF    \
   1344     {"system", (PyCFunction)os_system, METH_FASTCALL, os_system__doc__},
   1345 
   1346 static long
   1347 os_system_impl(PyObject *module, Py_UNICODE *command);
   1348 
   1349 static PyObject *
   1350 os_system(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1351 {
   1352     PyObject *return_value = NULL;
   1353     static const char * const _keywords[] = {"command", NULL};
   1354     static _PyArg_Parser _parser = {"u:system", _keywords, 0};
   1355     Py_UNICODE *command;
   1356     long _return_value;
   1357 
   1358     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1359         &command)) {
   1360         goto exit;
   1361     }
   1362     _return_value = os_system_impl(module, command);
   1363     if ((_return_value == -1) && PyErr_Occurred()) {
   1364         goto exit;
   1365     }
   1366     return_value = PyLong_FromLong(_return_value);
   1367 
   1368 exit:
   1369     return return_value;
   1370 }
   1371 
   1372 #endif /* defined(HAVE_SYSTEM) && defined(MS_WINDOWS) */
   1373 
   1374 #if defined(HAVE_SYSTEM) && !defined(MS_WINDOWS)
   1375 
   1376 PyDoc_STRVAR(os_system__doc__,
   1377 "system($module, /, command)\n"
   1378 "--\n"
   1379 "\n"
   1380 "Execute the command in a subshell.");
   1381 
   1382 #define OS_SYSTEM_METHODDEF    \
   1383     {"system", (PyCFunction)os_system, METH_FASTCALL, os_system__doc__},
   1384 
   1385 static long
   1386 os_system_impl(PyObject *module, PyObject *command);
   1387 
   1388 static PyObject *
   1389 os_system(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1390 {
   1391     PyObject *return_value = NULL;
   1392     static const char * const _keywords[] = {"command", NULL};
   1393     static _PyArg_Parser _parser = {"O&:system", _keywords, 0};
   1394     PyObject *command = NULL;
   1395     long _return_value;
   1396 
   1397     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1398         PyUnicode_FSConverter, &command)) {
   1399         goto exit;
   1400     }
   1401     _return_value = os_system_impl(module, command);
   1402     if ((_return_value == -1) && PyErr_Occurred()) {
   1403         goto exit;
   1404     }
   1405     return_value = PyLong_FromLong(_return_value);
   1406 
   1407 exit:
   1408     /* Cleanup for command */
   1409     Py_XDECREF(command);
   1410 
   1411     return return_value;
   1412 }
   1413 
   1414 #endif /* defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) */
   1415 
   1416 PyDoc_STRVAR(os_umask__doc__,
   1417 "umask($module, mask, /)\n"
   1418 "--\n"
   1419 "\n"
   1420 "Set the current numeric umask and return the previous umask.");
   1421 
   1422 #define OS_UMASK_METHODDEF    \
   1423     {"umask", (PyCFunction)os_umask, METH_O, os_umask__doc__},
   1424 
   1425 static PyObject *
   1426 os_umask_impl(PyObject *module, int mask);
   1427 
   1428 static PyObject *
   1429 os_umask(PyObject *module, PyObject *arg)
   1430 {
   1431     PyObject *return_value = NULL;
   1432     int mask;
   1433 
   1434     if (!PyArg_Parse(arg, "i:umask", &mask)) {
   1435         goto exit;
   1436     }
   1437     return_value = os_umask_impl(module, mask);
   1438 
   1439 exit:
   1440     return return_value;
   1441 }
   1442 
   1443 PyDoc_STRVAR(os_unlink__doc__,
   1444 "unlink($module, /, path, *, dir_fd=None)\n"
   1445 "--\n"
   1446 "\n"
   1447 "Remove a file (same as remove()).\n"
   1448 "\n"
   1449 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   1450 "  and path should be relative; path will then be relative to that directory.\n"
   1451 "dir_fd may not be implemented on your platform.\n"
   1452 "  If it is unavailable, using it will raise a NotImplementedError.");
   1453 
   1454 #define OS_UNLINK_METHODDEF    \
   1455     {"unlink", (PyCFunction)os_unlink, METH_FASTCALL, os_unlink__doc__},
   1456 
   1457 static PyObject *
   1458 os_unlink_impl(PyObject *module, path_t *path, int dir_fd);
   1459 
   1460 static PyObject *
   1461 os_unlink(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1462 {
   1463     PyObject *return_value = NULL;
   1464     static const char * const _keywords[] = {"path", "dir_fd", NULL};
   1465     static _PyArg_Parser _parser = {"O&|$O&:unlink", _keywords, 0};
   1466     path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0);
   1467     int dir_fd = DEFAULT_DIR_FD;
   1468 
   1469     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1470         path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
   1471         goto exit;
   1472     }
   1473     return_value = os_unlink_impl(module, &path, dir_fd);
   1474 
   1475 exit:
   1476     /* Cleanup for path */
   1477     path_cleanup(&path);
   1478 
   1479     return return_value;
   1480 }
   1481 
   1482 PyDoc_STRVAR(os_remove__doc__,
   1483 "remove($module, /, path, *, dir_fd=None)\n"
   1484 "--\n"
   1485 "\n"
   1486 "Remove a file (same as unlink()).\n"
   1487 "\n"
   1488 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   1489 "  and path should be relative; path will then be relative to that directory.\n"
   1490 "dir_fd may not be implemented on your platform.\n"
   1491 "  If it is unavailable, using it will raise a NotImplementedError.");
   1492 
   1493 #define OS_REMOVE_METHODDEF    \
   1494     {"remove", (PyCFunction)os_remove, METH_FASTCALL, os_remove__doc__},
   1495 
   1496 static PyObject *
   1497 os_remove_impl(PyObject *module, path_t *path, int dir_fd);
   1498 
   1499 static PyObject *
   1500 os_remove(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1501 {
   1502     PyObject *return_value = NULL;
   1503     static const char * const _keywords[] = {"path", "dir_fd", NULL};
   1504     static _PyArg_Parser _parser = {"O&|$O&:remove", _keywords, 0};
   1505     path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0);
   1506     int dir_fd = DEFAULT_DIR_FD;
   1507 
   1508     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1509         path_converter, &path, UNLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
   1510         goto exit;
   1511     }
   1512     return_value = os_remove_impl(module, &path, dir_fd);
   1513 
   1514 exit:
   1515     /* Cleanup for path */
   1516     path_cleanup(&path);
   1517 
   1518     return return_value;
   1519 }
   1520 
   1521 #if defined(HAVE_UNAME)
   1522 
   1523 PyDoc_STRVAR(os_uname__doc__,
   1524 "uname($module, /)\n"
   1525 "--\n"
   1526 "\n"
   1527 "Return an object identifying the current operating system.\n"
   1528 "\n"
   1529 "The object behaves like a named tuple with the following fields:\n"
   1530 "  (sysname, nodename, release, version, machine)");
   1531 
   1532 #define OS_UNAME_METHODDEF    \
   1533     {"uname", (PyCFunction)os_uname, METH_NOARGS, os_uname__doc__},
   1534 
   1535 static PyObject *
   1536 os_uname_impl(PyObject *module);
   1537 
   1538 static PyObject *
   1539 os_uname(PyObject *module, PyObject *Py_UNUSED(ignored))
   1540 {
   1541     return os_uname_impl(module);
   1542 }
   1543 
   1544 #endif /* defined(HAVE_UNAME) */
   1545 
   1546 PyDoc_STRVAR(os_utime__doc__,
   1547 "utime($module, /, path, times=None, *, ns=None, dir_fd=None,\n"
   1548 "      follow_symlinks=True)\n"
   1549 "--\n"
   1550 "\n"
   1551 "Set the access and modified time of path.\n"
   1552 "\n"
   1553 "path may always be specified as a string.\n"
   1554 "On some platforms, path may also be specified as an open file descriptor.\n"
   1555 "  If this functionality is unavailable, using it raises an exception.\n"
   1556 "\n"
   1557 "If times is not None, it must be a tuple (atime, mtime);\n"
   1558 "    atime and mtime should be expressed as float seconds since the epoch.\n"
   1559 "If ns is specified, it must be a tuple (atime_ns, mtime_ns);\n"
   1560 "    atime_ns and mtime_ns should be expressed as integer nanoseconds\n"
   1561 "    since the epoch.\n"
   1562 "If times is None and ns is unspecified, utime uses the current time.\n"
   1563 "Specifying tuples for both times and ns is an error.\n"
   1564 "\n"
   1565 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   1566 "  and path should be relative; path will then be relative to that directory.\n"
   1567 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
   1568 "  link, utime will modify the symbolic link itself instead of the file the\n"
   1569 "  link points to.\n"
   1570 "It is an error to use dir_fd or follow_symlinks when specifying path\n"
   1571 "  as an open file descriptor.\n"
   1572 "dir_fd and follow_symlinks may not be available on your platform.\n"
   1573 "  If they are unavailable, using them will raise a NotImplementedError.");
   1574 
   1575 #define OS_UTIME_METHODDEF    \
   1576     {"utime", (PyCFunction)os_utime, METH_FASTCALL, os_utime__doc__},
   1577 
   1578 static PyObject *
   1579 os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns,
   1580               int dir_fd, int follow_symlinks);
   1581 
   1582 static PyObject *
   1583 os_utime(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1584 {
   1585     PyObject *return_value = NULL;
   1586     static const char * const _keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL};
   1587     static _PyArg_Parser _parser = {"O&|O$OO&p:utime", _keywords, 0};
   1588     path_t path = PATH_T_INITIALIZE("utime", "path", 0, PATH_UTIME_HAVE_FD);
   1589     PyObject *times = NULL;
   1590     PyObject *ns = NULL;
   1591     int dir_fd = DEFAULT_DIR_FD;
   1592     int follow_symlinks = 1;
   1593 
   1594     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1595         path_converter, &path, &times, &ns, FUTIMENSAT_DIR_FD_CONVERTER, &dir_fd, &follow_symlinks)) {
   1596         goto exit;
   1597     }
   1598     return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks);
   1599 
   1600 exit:
   1601     /* Cleanup for path */
   1602     path_cleanup(&path);
   1603 
   1604     return return_value;
   1605 }
   1606 
   1607 PyDoc_STRVAR(os__exit__doc__,
   1608 "_exit($module, /, status)\n"
   1609 "--\n"
   1610 "\n"
   1611 "Exit to the system with specified status, without normal exit processing.");
   1612 
   1613 #define OS__EXIT_METHODDEF    \
   1614     {"_exit", (PyCFunction)os__exit, METH_FASTCALL, os__exit__doc__},
   1615 
   1616 static PyObject *
   1617 os__exit_impl(PyObject *module, int status);
   1618 
   1619 static PyObject *
   1620 os__exit(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1621 {
   1622     PyObject *return_value = NULL;
   1623     static const char * const _keywords[] = {"status", NULL};
   1624     static _PyArg_Parser _parser = {"i:_exit", _keywords, 0};
   1625     int status;
   1626 
   1627     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1628         &status)) {
   1629         goto exit;
   1630     }
   1631     return_value = os__exit_impl(module, status);
   1632 
   1633 exit:
   1634     return return_value;
   1635 }
   1636 
   1637 #if defined(HAVE_EXECV)
   1638 
   1639 PyDoc_STRVAR(os_execv__doc__,
   1640 "execv($module, path, argv, /)\n"
   1641 "--\n"
   1642 "\n"
   1643 "Execute an executable path with arguments, replacing current process.\n"
   1644 "\n"
   1645 "  path\n"
   1646 "    Path of executable file.\n"
   1647 "  argv\n"
   1648 "    Tuple or list of strings.");
   1649 
   1650 #define OS_EXECV_METHODDEF    \
   1651     {"execv", (PyCFunction)os_execv, METH_VARARGS, os_execv__doc__},
   1652 
   1653 static PyObject *
   1654 os_execv_impl(PyObject *module, path_t *path, PyObject *argv);
   1655 
   1656 static PyObject *
   1657 os_execv(PyObject *module, PyObject *args)
   1658 {
   1659     PyObject *return_value = NULL;
   1660     path_t path = PATH_T_INITIALIZE("execv", "path", 0, 0);
   1661     PyObject *argv;
   1662 
   1663     if (!PyArg_ParseTuple(args, "O&O:execv",
   1664         path_converter, &path, &argv)) {
   1665         goto exit;
   1666     }
   1667     return_value = os_execv_impl(module, &path, argv);
   1668 
   1669 exit:
   1670     /* Cleanup for path */
   1671     path_cleanup(&path);
   1672 
   1673     return return_value;
   1674 }
   1675 
   1676 #endif /* defined(HAVE_EXECV) */
   1677 
   1678 #if defined(HAVE_EXECV)
   1679 
   1680 PyDoc_STRVAR(os_execve__doc__,
   1681 "execve($module, /, path, argv, env)\n"
   1682 "--\n"
   1683 "\n"
   1684 "Execute an executable path with arguments, replacing current process.\n"
   1685 "\n"
   1686 "  path\n"
   1687 "    Path of executable file.\n"
   1688 "  argv\n"
   1689 "    Tuple or list of strings.\n"
   1690 "  env\n"
   1691 "    Dictionary of strings mapping to strings.");
   1692 
   1693 #define OS_EXECVE_METHODDEF    \
   1694     {"execve", (PyCFunction)os_execve, METH_FASTCALL, os_execve__doc__},
   1695 
   1696 static PyObject *
   1697 os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env);
   1698 
   1699 static PyObject *
   1700 os_execve(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1701 {
   1702     PyObject *return_value = NULL;
   1703     static const char * const _keywords[] = {"path", "argv", "env", NULL};
   1704     static _PyArg_Parser _parser = {"O&OO:execve", _keywords, 0};
   1705     path_t path = PATH_T_INITIALIZE("execve", "path", 0, PATH_HAVE_FEXECVE);
   1706     PyObject *argv;
   1707     PyObject *env;
   1708 
   1709     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1710         path_converter, &path, &argv, &env)) {
   1711         goto exit;
   1712     }
   1713     return_value = os_execve_impl(module, &path, argv, env);
   1714 
   1715 exit:
   1716     /* Cleanup for path */
   1717     path_cleanup(&path);
   1718 
   1719     return return_value;
   1720 }
   1721 
   1722 #endif /* defined(HAVE_EXECV) */
   1723 
   1724 #if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV))
   1725 
   1726 PyDoc_STRVAR(os_spawnv__doc__,
   1727 "spawnv($module, mode, path, argv, /)\n"
   1728 "--\n"
   1729 "\n"
   1730 "Execute the program specified by path in a new process.\n"
   1731 "\n"
   1732 "  mode\n"
   1733 "    Mode of process creation.\n"
   1734 "  path\n"
   1735 "    Path of executable file.\n"
   1736 "  argv\n"
   1737 "    Tuple or list of strings.");
   1738 
   1739 #define OS_SPAWNV_METHODDEF    \
   1740     {"spawnv", (PyCFunction)os_spawnv, METH_VARARGS, os_spawnv__doc__},
   1741 
   1742 static PyObject *
   1743 os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv);
   1744 
   1745 static PyObject *
   1746 os_spawnv(PyObject *module, PyObject *args)
   1747 {
   1748     PyObject *return_value = NULL;
   1749     int mode;
   1750     path_t path = PATH_T_INITIALIZE("spawnv", "path", 0, 0);
   1751     PyObject *argv;
   1752 
   1753     if (!PyArg_ParseTuple(args, "iO&O:spawnv",
   1754         &mode, path_converter, &path, &argv)) {
   1755         goto exit;
   1756     }
   1757     return_value = os_spawnv_impl(module, mode, &path, argv);
   1758 
   1759 exit:
   1760     /* Cleanup for path */
   1761     path_cleanup(&path);
   1762 
   1763     return return_value;
   1764 }
   1765 
   1766 #endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV)) */
   1767 
   1768 #if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV))
   1769 
   1770 PyDoc_STRVAR(os_spawnve__doc__,
   1771 "spawnve($module, mode, path, argv, env, /)\n"
   1772 "--\n"
   1773 "\n"
   1774 "Execute the program specified by path in a new process.\n"
   1775 "\n"
   1776 "  mode\n"
   1777 "    Mode of process creation.\n"
   1778 "  path\n"
   1779 "    Path of executable file.\n"
   1780 "  argv\n"
   1781 "    Tuple or list of strings.\n"
   1782 "  env\n"
   1783 "    Dictionary of strings mapping to strings.");
   1784 
   1785 #define OS_SPAWNVE_METHODDEF    \
   1786     {"spawnve", (PyCFunction)os_spawnve, METH_VARARGS, os_spawnve__doc__},
   1787 
   1788 static PyObject *
   1789 os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
   1790                 PyObject *env);
   1791 
   1792 static PyObject *
   1793 os_spawnve(PyObject *module, PyObject *args)
   1794 {
   1795     PyObject *return_value = NULL;
   1796     int mode;
   1797     path_t path = PATH_T_INITIALIZE("spawnve", "path", 0, 0);
   1798     PyObject *argv;
   1799     PyObject *env;
   1800 
   1801     if (!PyArg_ParseTuple(args, "iO&OO:spawnve",
   1802         &mode, path_converter, &path, &argv, &env)) {
   1803         goto exit;
   1804     }
   1805     return_value = os_spawnve_impl(module, mode, &path, argv, env);
   1806 
   1807 exit:
   1808     /* Cleanup for path */
   1809     path_cleanup(&path);
   1810 
   1811     return return_value;
   1812 }
   1813 
   1814 #endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV)) */
   1815 
   1816 #if defined(HAVE_FORK1)
   1817 
   1818 PyDoc_STRVAR(os_fork1__doc__,
   1819 "fork1($module, /)\n"
   1820 "--\n"
   1821 "\n"
   1822 "Fork a child process with a single multiplexed (i.e., not bound) thread.\n"
   1823 "\n"
   1824 "Return 0 to child process and PID of child to parent process.");
   1825 
   1826 #define OS_FORK1_METHODDEF    \
   1827     {"fork1", (PyCFunction)os_fork1, METH_NOARGS, os_fork1__doc__},
   1828 
   1829 static PyObject *
   1830 os_fork1_impl(PyObject *module);
   1831 
   1832 static PyObject *
   1833 os_fork1(PyObject *module, PyObject *Py_UNUSED(ignored))
   1834 {
   1835     return os_fork1_impl(module);
   1836 }
   1837 
   1838 #endif /* defined(HAVE_FORK1) */
   1839 
   1840 #if defined(HAVE_FORK)
   1841 
   1842 PyDoc_STRVAR(os_fork__doc__,
   1843 "fork($module, /)\n"
   1844 "--\n"
   1845 "\n"
   1846 "Fork a child process.\n"
   1847 "\n"
   1848 "Return 0 to child process and PID of child to parent process.");
   1849 
   1850 #define OS_FORK_METHODDEF    \
   1851     {"fork", (PyCFunction)os_fork, METH_NOARGS, os_fork__doc__},
   1852 
   1853 static PyObject *
   1854 os_fork_impl(PyObject *module);
   1855 
   1856 static PyObject *
   1857 os_fork(PyObject *module, PyObject *Py_UNUSED(ignored))
   1858 {
   1859     return os_fork_impl(module);
   1860 }
   1861 
   1862 #endif /* defined(HAVE_FORK) */
   1863 
   1864 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX)
   1865 
   1866 PyDoc_STRVAR(os_sched_get_priority_max__doc__,
   1867 "sched_get_priority_max($module, /, policy)\n"
   1868 "--\n"
   1869 "\n"
   1870 "Get the maximum scheduling priority for policy.");
   1871 
   1872 #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF    \
   1873     {"sched_get_priority_max", (PyCFunction)os_sched_get_priority_max, METH_FASTCALL, os_sched_get_priority_max__doc__},
   1874 
   1875 static PyObject *
   1876 os_sched_get_priority_max_impl(PyObject *module, int policy);
   1877 
   1878 static PyObject *
   1879 os_sched_get_priority_max(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1880 {
   1881     PyObject *return_value = NULL;
   1882     static const char * const _keywords[] = {"policy", NULL};
   1883     static _PyArg_Parser _parser = {"i:sched_get_priority_max", _keywords, 0};
   1884     int policy;
   1885 
   1886     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1887         &policy)) {
   1888         goto exit;
   1889     }
   1890     return_value = os_sched_get_priority_max_impl(module, policy);
   1891 
   1892 exit:
   1893     return return_value;
   1894 }
   1895 
   1896 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */
   1897 
   1898 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX)
   1899 
   1900 PyDoc_STRVAR(os_sched_get_priority_min__doc__,
   1901 "sched_get_priority_min($module, /, policy)\n"
   1902 "--\n"
   1903 "\n"
   1904 "Get the minimum scheduling priority for policy.");
   1905 
   1906 #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF    \
   1907     {"sched_get_priority_min", (PyCFunction)os_sched_get_priority_min, METH_FASTCALL, os_sched_get_priority_min__doc__},
   1908 
   1909 static PyObject *
   1910 os_sched_get_priority_min_impl(PyObject *module, int policy);
   1911 
   1912 static PyObject *
   1913 os_sched_get_priority_min(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   1914 {
   1915     PyObject *return_value = NULL;
   1916     static const char * const _keywords[] = {"policy", NULL};
   1917     static _PyArg_Parser _parser = {"i:sched_get_priority_min", _keywords, 0};
   1918     int policy;
   1919 
   1920     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   1921         &policy)) {
   1922         goto exit;
   1923     }
   1924     return_value = os_sched_get_priority_min_impl(module, policy);
   1925 
   1926 exit:
   1927     return return_value;
   1928 }
   1929 
   1930 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */
   1931 
   1932 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER)
   1933 
   1934 PyDoc_STRVAR(os_sched_getscheduler__doc__,
   1935 "sched_getscheduler($module, pid, /)\n"
   1936 "--\n"
   1937 "\n"
   1938 "Get the scheduling policy for the process identifiedy by pid.\n"
   1939 "\n"
   1940 "Passing 0 for pid returns the scheduling policy for the calling process.");
   1941 
   1942 #define OS_SCHED_GETSCHEDULER_METHODDEF    \
   1943     {"sched_getscheduler", (PyCFunction)os_sched_getscheduler, METH_O, os_sched_getscheduler__doc__},
   1944 
   1945 static PyObject *
   1946 os_sched_getscheduler_impl(PyObject *module, pid_t pid);
   1947 
   1948 static PyObject *
   1949 os_sched_getscheduler(PyObject *module, PyObject *arg)
   1950 {
   1951     PyObject *return_value = NULL;
   1952     pid_t pid;
   1953 
   1954     if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getscheduler", &pid)) {
   1955         goto exit;
   1956     }
   1957     return_value = os_sched_getscheduler_impl(module, pid);
   1958 
   1959 exit:
   1960     return return_value;
   1961 }
   1962 
   1963 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */
   1964 
   1965 #if defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SCHED_SETPARAM))
   1966 
   1967 PyDoc_STRVAR(os_sched_param__doc__,
   1968 "sched_param(sched_priority)\n"
   1969 "--\n"
   1970 "\n"
   1971 "Current has only one field: sched_priority\");\n"
   1972 "\n"
   1973 "  sched_priority\n"
   1974 "    A scheduling parameter.");
   1975 
   1976 static PyObject *
   1977 os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority);
   1978 
   1979 static PyObject *
   1980 os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs)
   1981 {
   1982     PyObject *return_value = NULL;
   1983     static const char * const _keywords[] = {"sched_priority", NULL};
   1984     static _PyArg_Parser _parser = {"O:sched_param", _keywords, 0};
   1985     PyObject *sched_priority;
   1986 
   1987     if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
   1988         &sched_priority)) {
   1989         goto exit;
   1990     }
   1991     return_value = os_sched_param_impl(type, sched_priority);
   1992 
   1993 exit:
   1994     return return_value;
   1995 }
   1996 
   1997 #endif /* defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETSCHEDULER) || defined(HAVE_SCHED_SETPARAM)) */
   1998 
   1999 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER)
   2000 
   2001 PyDoc_STRVAR(os_sched_setscheduler__doc__,
   2002 "sched_setscheduler($module, pid, policy, param, /)\n"
   2003 "--\n"
   2004 "\n"
   2005 "Set the scheduling policy for the process identified by pid.\n"
   2006 "\n"
   2007 "If pid is 0, the calling process is changed.\n"
   2008 "param is an instance of sched_param.");
   2009 
   2010 #define OS_SCHED_SETSCHEDULER_METHODDEF    \
   2011     {"sched_setscheduler", (PyCFunction)os_sched_setscheduler, METH_VARARGS, os_sched_setscheduler__doc__},
   2012 
   2013 static PyObject *
   2014 os_sched_setscheduler_impl(PyObject *module, pid_t pid, int policy,
   2015                            struct sched_param *param);
   2016 
   2017 static PyObject *
   2018 os_sched_setscheduler(PyObject *module, PyObject *args)
   2019 {
   2020     PyObject *return_value = NULL;
   2021     pid_t pid;
   2022     int policy;
   2023     struct sched_param param;
   2024 
   2025     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "iO&:sched_setscheduler",
   2026         &pid, &policy, convert_sched_param, &param)) {
   2027         goto exit;
   2028     }
   2029     return_value = os_sched_setscheduler_impl(module, pid, policy, &param);
   2030 
   2031 exit:
   2032     return return_value;
   2033 }
   2034 
   2035 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */
   2036 
   2037 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM)
   2038 
   2039 PyDoc_STRVAR(os_sched_getparam__doc__,
   2040 "sched_getparam($module, pid, /)\n"
   2041 "--\n"
   2042 "\n"
   2043 "Returns scheduling parameters for the process identified by pid.\n"
   2044 "\n"
   2045 "If pid is 0, returns parameters for the calling process.\n"
   2046 "Return value is an instance of sched_param.");
   2047 
   2048 #define OS_SCHED_GETPARAM_METHODDEF    \
   2049     {"sched_getparam", (PyCFunction)os_sched_getparam, METH_O, os_sched_getparam__doc__},
   2050 
   2051 static PyObject *
   2052 os_sched_getparam_impl(PyObject *module, pid_t pid);
   2053 
   2054 static PyObject *
   2055 os_sched_getparam(PyObject *module, PyObject *arg)
   2056 {
   2057     PyObject *return_value = NULL;
   2058     pid_t pid;
   2059 
   2060     if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getparam", &pid)) {
   2061         goto exit;
   2062     }
   2063     return_value = os_sched_getparam_impl(module, pid);
   2064 
   2065 exit:
   2066     return return_value;
   2067 }
   2068 
   2069 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */
   2070 
   2071 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM)
   2072 
   2073 PyDoc_STRVAR(os_sched_setparam__doc__,
   2074 "sched_setparam($module, pid, param, /)\n"
   2075 "--\n"
   2076 "\n"
   2077 "Set scheduling parameters for the process identified by pid.\n"
   2078 "\n"
   2079 "If pid is 0, sets parameters for the calling process.\n"
   2080 "param should be an instance of sched_param.");
   2081 
   2082 #define OS_SCHED_SETPARAM_METHODDEF    \
   2083     {"sched_setparam", (PyCFunction)os_sched_setparam, METH_VARARGS, os_sched_setparam__doc__},
   2084 
   2085 static PyObject *
   2086 os_sched_setparam_impl(PyObject *module, pid_t pid,
   2087                        struct sched_param *param);
   2088 
   2089 static PyObject *
   2090 os_sched_setparam(PyObject *module, PyObject *args)
   2091 {
   2092     PyObject *return_value = NULL;
   2093     pid_t pid;
   2094     struct sched_param param;
   2095 
   2096     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "O&:sched_setparam",
   2097         &pid, convert_sched_param, &param)) {
   2098         goto exit;
   2099     }
   2100     return_value = os_sched_setparam_impl(module, pid, &param);
   2101 
   2102 exit:
   2103     return return_value;
   2104 }
   2105 
   2106 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */
   2107 
   2108 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL)
   2109 
   2110 PyDoc_STRVAR(os_sched_rr_get_interval__doc__,
   2111 "sched_rr_get_interval($module, pid, /)\n"
   2112 "--\n"
   2113 "\n"
   2114 "Return the round-robin quantum for the process identified by pid, in seconds.\n"
   2115 "\n"
   2116 "Value returned is a float.");
   2117 
   2118 #define OS_SCHED_RR_GET_INTERVAL_METHODDEF    \
   2119     {"sched_rr_get_interval", (PyCFunction)os_sched_rr_get_interval, METH_O, os_sched_rr_get_interval__doc__},
   2120 
   2121 static double
   2122 os_sched_rr_get_interval_impl(PyObject *module, pid_t pid);
   2123 
   2124 static PyObject *
   2125 os_sched_rr_get_interval(PyObject *module, PyObject *arg)
   2126 {
   2127     PyObject *return_value = NULL;
   2128     pid_t pid;
   2129     double _return_value;
   2130 
   2131     if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_rr_get_interval", &pid)) {
   2132         goto exit;
   2133     }
   2134     _return_value = os_sched_rr_get_interval_impl(module, pid);
   2135     if ((_return_value == -1.0) && PyErr_Occurred()) {
   2136         goto exit;
   2137     }
   2138     return_value = PyFloat_FromDouble(_return_value);
   2139 
   2140 exit:
   2141     return return_value;
   2142 }
   2143 
   2144 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) */
   2145 
   2146 #if defined(HAVE_SCHED_H)
   2147 
   2148 PyDoc_STRVAR(os_sched_yield__doc__,
   2149 "sched_yield($module, /)\n"
   2150 "--\n"
   2151 "\n"
   2152 "Voluntarily relinquish the CPU.");
   2153 
   2154 #define OS_SCHED_YIELD_METHODDEF    \
   2155     {"sched_yield", (PyCFunction)os_sched_yield, METH_NOARGS, os_sched_yield__doc__},
   2156 
   2157 static PyObject *
   2158 os_sched_yield_impl(PyObject *module);
   2159 
   2160 static PyObject *
   2161 os_sched_yield(PyObject *module, PyObject *Py_UNUSED(ignored))
   2162 {
   2163     return os_sched_yield_impl(module);
   2164 }
   2165 
   2166 #endif /* defined(HAVE_SCHED_H) */
   2167 
   2168 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY)
   2169 
   2170 PyDoc_STRVAR(os_sched_setaffinity__doc__,
   2171 "sched_setaffinity($module, pid, mask, /)\n"
   2172 "--\n"
   2173 "\n"
   2174 "Set the CPU affinity of the process identified by pid to mask.\n"
   2175 "\n"
   2176 "mask should be an iterable of integers identifying CPUs.");
   2177 
   2178 #define OS_SCHED_SETAFFINITY_METHODDEF    \
   2179     {"sched_setaffinity", (PyCFunction)os_sched_setaffinity, METH_VARARGS, os_sched_setaffinity__doc__},
   2180 
   2181 static PyObject *
   2182 os_sched_setaffinity_impl(PyObject *module, pid_t pid, PyObject *mask);
   2183 
   2184 static PyObject *
   2185 os_sched_setaffinity(PyObject *module, PyObject *args)
   2186 {
   2187     PyObject *return_value = NULL;
   2188     pid_t pid;
   2189     PyObject *mask;
   2190 
   2191     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "O:sched_setaffinity",
   2192         &pid, &mask)) {
   2193         goto exit;
   2194     }
   2195     return_value = os_sched_setaffinity_impl(module, pid, mask);
   2196 
   2197 exit:
   2198     return return_value;
   2199 }
   2200 
   2201 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */
   2202 
   2203 #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY)
   2204 
   2205 PyDoc_STRVAR(os_sched_getaffinity__doc__,
   2206 "sched_getaffinity($module, pid, /)\n"
   2207 "--\n"
   2208 "\n"
   2209 "Return the affinity of the process identified by pid (or the current process if zero).\n"
   2210 "\n"
   2211 "The affinity is returned as a set of CPU identifiers.");
   2212 
   2213 #define OS_SCHED_GETAFFINITY_METHODDEF    \
   2214     {"sched_getaffinity", (PyCFunction)os_sched_getaffinity, METH_O, os_sched_getaffinity__doc__},
   2215 
   2216 static PyObject *
   2217 os_sched_getaffinity_impl(PyObject *module, pid_t pid);
   2218 
   2219 static PyObject *
   2220 os_sched_getaffinity(PyObject *module, PyObject *arg)
   2221 {
   2222     PyObject *return_value = NULL;
   2223     pid_t pid;
   2224 
   2225     if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getaffinity", &pid)) {
   2226         goto exit;
   2227     }
   2228     return_value = os_sched_getaffinity_impl(module, pid);
   2229 
   2230 exit:
   2231     return return_value;
   2232 }
   2233 
   2234 #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */
   2235 
   2236 #if (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX))
   2237 
   2238 PyDoc_STRVAR(os_openpty__doc__,
   2239 "openpty($module, /)\n"
   2240 "--\n"
   2241 "\n"
   2242 "Open a pseudo-terminal.\n"
   2243 "\n"
   2244 "Return a tuple of (master_fd, slave_fd) containing open file descriptors\n"
   2245 "for both the master and slave ends.");
   2246 
   2247 #define OS_OPENPTY_METHODDEF    \
   2248     {"openpty", (PyCFunction)os_openpty, METH_NOARGS, os_openpty__doc__},
   2249 
   2250 static PyObject *
   2251 os_openpty_impl(PyObject *module);
   2252 
   2253 static PyObject *
   2254 os_openpty(PyObject *module, PyObject *Py_UNUSED(ignored))
   2255 {
   2256     return os_openpty_impl(module);
   2257 }
   2258 
   2259 #endif /* (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) */
   2260 
   2261 #if defined(HAVE_FORKPTY)
   2262 
   2263 PyDoc_STRVAR(os_forkpty__doc__,
   2264 "forkpty($module, /)\n"
   2265 "--\n"
   2266 "\n"
   2267 "Fork a new process with a new pseudo-terminal as controlling tty.\n"
   2268 "\n"
   2269 "Returns a tuple of (pid, master_fd).\n"
   2270 "Like fork(), return pid of 0 to the child process,\n"
   2271 "and pid of child to the parent process.\n"
   2272 "To both, return fd of newly opened pseudo-terminal.");
   2273 
   2274 #define OS_FORKPTY_METHODDEF    \
   2275     {"forkpty", (PyCFunction)os_forkpty, METH_NOARGS, os_forkpty__doc__},
   2276 
   2277 static PyObject *
   2278 os_forkpty_impl(PyObject *module);
   2279 
   2280 static PyObject *
   2281 os_forkpty(PyObject *module, PyObject *Py_UNUSED(ignored))
   2282 {
   2283     return os_forkpty_impl(module);
   2284 }
   2285 
   2286 #endif /* defined(HAVE_FORKPTY) */
   2287 
   2288 #if defined(HAVE_GETEGID)
   2289 
   2290 PyDoc_STRVAR(os_getegid__doc__,
   2291 "getegid($module, /)\n"
   2292 "--\n"
   2293 "\n"
   2294 "Return the current process\'s effective group id.");
   2295 
   2296 #define OS_GETEGID_METHODDEF    \
   2297     {"getegid", (PyCFunction)os_getegid, METH_NOARGS, os_getegid__doc__},
   2298 
   2299 static PyObject *
   2300 os_getegid_impl(PyObject *module);
   2301 
   2302 static PyObject *
   2303 os_getegid(PyObject *module, PyObject *Py_UNUSED(ignored))
   2304 {
   2305     return os_getegid_impl(module);
   2306 }
   2307 
   2308 #endif /* defined(HAVE_GETEGID) */
   2309 
   2310 #if defined(HAVE_GETEUID)
   2311 
   2312 PyDoc_STRVAR(os_geteuid__doc__,
   2313 "geteuid($module, /)\n"
   2314 "--\n"
   2315 "\n"
   2316 "Return the current process\'s effective user id.");
   2317 
   2318 #define OS_GETEUID_METHODDEF    \
   2319     {"geteuid", (PyCFunction)os_geteuid, METH_NOARGS, os_geteuid__doc__},
   2320 
   2321 static PyObject *
   2322 os_geteuid_impl(PyObject *module);
   2323 
   2324 static PyObject *
   2325 os_geteuid(PyObject *module, PyObject *Py_UNUSED(ignored))
   2326 {
   2327     return os_geteuid_impl(module);
   2328 }
   2329 
   2330 #endif /* defined(HAVE_GETEUID) */
   2331 
   2332 #if defined(HAVE_GETGID)
   2333 
   2334 PyDoc_STRVAR(os_getgid__doc__,
   2335 "getgid($module, /)\n"
   2336 "--\n"
   2337 "\n"
   2338 "Return the current process\'s group id.");
   2339 
   2340 #define OS_GETGID_METHODDEF    \
   2341     {"getgid", (PyCFunction)os_getgid, METH_NOARGS, os_getgid__doc__},
   2342 
   2343 static PyObject *
   2344 os_getgid_impl(PyObject *module);
   2345 
   2346 static PyObject *
   2347 os_getgid(PyObject *module, PyObject *Py_UNUSED(ignored))
   2348 {
   2349     return os_getgid_impl(module);
   2350 }
   2351 
   2352 #endif /* defined(HAVE_GETGID) */
   2353 
   2354 #if defined(HAVE_GETPID)
   2355 
   2356 PyDoc_STRVAR(os_getpid__doc__,
   2357 "getpid($module, /)\n"
   2358 "--\n"
   2359 "\n"
   2360 "Return the current process id.");
   2361 
   2362 #define OS_GETPID_METHODDEF    \
   2363     {"getpid", (PyCFunction)os_getpid, METH_NOARGS, os_getpid__doc__},
   2364 
   2365 static PyObject *
   2366 os_getpid_impl(PyObject *module);
   2367 
   2368 static PyObject *
   2369 os_getpid(PyObject *module, PyObject *Py_UNUSED(ignored))
   2370 {
   2371     return os_getpid_impl(module);
   2372 }
   2373 
   2374 #endif /* defined(HAVE_GETPID) */
   2375 
   2376 #if defined(HAVE_GETGROUPS)
   2377 
   2378 PyDoc_STRVAR(os_getgroups__doc__,
   2379 "getgroups($module, /)\n"
   2380 "--\n"
   2381 "\n"
   2382 "Return list of supplemental group IDs for the process.");
   2383 
   2384 #define OS_GETGROUPS_METHODDEF    \
   2385     {"getgroups", (PyCFunction)os_getgroups, METH_NOARGS, os_getgroups__doc__},
   2386 
   2387 static PyObject *
   2388 os_getgroups_impl(PyObject *module);
   2389 
   2390 static PyObject *
   2391 os_getgroups(PyObject *module, PyObject *Py_UNUSED(ignored))
   2392 {
   2393     return os_getgroups_impl(module);
   2394 }
   2395 
   2396 #endif /* defined(HAVE_GETGROUPS) */
   2397 
   2398 #if defined(HAVE_GETPGID)
   2399 
   2400 PyDoc_STRVAR(os_getpgid__doc__,
   2401 "getpgid($module, /, pid)\n"
   2402 "--\n"
   2403 "\n"
   2404 "Call the system call getpgid(), and return the result.");
   2405 
   2406 #define OS_GETPGID_METHODDEF    \
   2407     {"getpgid", (PyCFunction)os_getpgid, METH_FASTCALL, os_getpgid__doc__},
   2408 
   2409 static PyObject *
   2410 os_getpgid_impl(PyObject *module, pid_t pid);
   2411 
   2412 static PyObject *
   2413 os_getpgid(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   2414 {
   2415     PyObject *return_value = NULL;
   2416     static const char * const _keywords[] = {"pid", NULL};
   2417     static _PyArg_Parser _parser = {"" _Py_PARSE_PID ":getpgid", _keywords, 0};
   2418     pid_t pid;
   2419 
   2420     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   2421         &pid)) {
   2422         goto exit;
   2423     }
   2424     return_value = os_getpgid_impl(module, pid);
   2425 
   2426 exit:
   2427     return return_value;
   2428 }
   2429 
   2430 #endif /* defined(HAVE_GETPGID) */
   2431 
   2432 #if defined(HAVE_GETPGRP)
   2433 
   2434 PyDoc_STRVAR(os_getpgrp__doc__,
   2435 "getpgrp($module, /)\n"
   2436 "--\n"
   2437 "\n"
   2438 "Return the current process group id.");
   2439 
   2440 #define OS_GETPGRP_METHODDEF    \
   2441     {"getpgrp", (PyCFunction)os_getpgrp, METH_NOARGS, os_getpgrp__doc__},
   2442 
   2443 static PyObject *
   2444 os_getpgrp_impl(PyObject *module);
   2445 
   2446 static PyObject *
   2447 os_getpgrp(PyObject *module, PyObject *Py_UNUSED(ignored))
   2448 {
   2449     return os_getpgrp_impl(module);
   2450 }
   2451 
   2452 #endif /* defined(HAVE_GETPGRP) */
   2453 
   2454 #if defined(HAVE_SETPGRP)
   2455 
   2456 PyDoc_STRVAR(os_setpgrp__doc__,
   2457 "setpgrp($module, /)\n"
   2458 "--\n"
   2459 "\n"
   2460 "Make the current process the leader of its process group.");
   2461 
   2462 #define OS_SETPGRP_METHODDEF    \
   2463     {"setpgrp", (PyCFunction)os_setpgrp, METH_NOARGS, os_setpgrp__doc__},
   2464 
   2465 static PyObject *
   2466 os_setpgrp_impl(PyObject *module);
   2467 
   2468 static PyObject *
   2469 os_setpgrp(PyObject *module, PyObject *Py_UNUSED(ignored))
   2470 {
   2471     return os_setpgrp_impl(module);
   2472 }
   2473 
   2474 #endif /* defined(HAVE_SETPGRP) */
   2475 
   2476 #if defined(HAVE_GETPPID)
   2477 
   2478 PyDoc_STRVAR(os_getppid__doc__,
   2479 "getppid($module, /)\n"
   2480 "--\n"
   2481 "\n"
   2482 "Return the parent\'s process id.\n"
   2483 "\n"
   2484 "If the parent process has already exited, Windows machines will still\n"
   2485 "return its id; others systems will return the id of the \'init\' process (1).");
   2486 
   2487 #define OS_GETPPID_METHODDEF    \
   2488     {"getppid", (PyCFunction)os_getppid, METH_NOARGS, os_getppid__doc__},
   2489 
   2490 static PyObject *
   2491 os_getppid_impl(PyObject *module);
   2492 
   2493 static PyObject *
   2494 os_getppid(PyObject *module, PyObject *Py_UNUSED(ignored))
   2495 {
   2496     return os_getppid_impl(module);
   2497 }
   2498 
   2499 #endif /* defined(HAVE_GETPPID) */
   2500 
   2501 #if defined(HAVE_GETLOGIN)
   2502 
   2503 PyDoc_STRVAR(os_getlogin__doc__,
   2504 "getlogin($module, /)\n"
   2505 "--\n"
   2506 "\n"
   2507 "Return the actual login name.");
   2508 
   2509 #define OS_GETLOGIN_METHODDEF    \
   2510     {"getlogin", (PyCFunction)os_getlogin, METH_NOARGS, os_getlogin__doc__},
   2511 
   2512 static PyObject *
   2513 os_getlogin_impl(PyObject *module);
   2514 
   2515 static PyObject *
   2516 os_getlogin(PyObject *module, PyObject *Py_UNUSED(ignored))
   2517 {
   2518     return os_getlogin_impl(module);
   2519 }
   2520 
   2521 #endif /* defined(HAVE_GETLOGIN) */
   2522 
   2523 #if defined(HAVE_GETUID)
   2524 
   2525 PyDoc_STRVAR(os_getuid__doc__,
   2526 "getuid($module, /)\n"
   2527 "--\n"
   2528 "\n"
   2529 "Return the current process\'s user id.");
   2530 
   2531 #define OS_GETUID_METHODDEF    \
   2532     {"getuid", (PyCFunction)os_getuid, METH_NOARGS, os_getuid__doc__},
   2533 
   2534 static PyObject *
   2535 os_getuid_impl(PyObject *module);
   2536 
   2537 static PyObject *
   2538 os_getuid(PyObject *module, PyObject *Py_UNUSED(ignored))
   2539 {
   2540     return os_getuid_impl(module);
   2541 }
   2542 
   2543 #endif /* defined(HAVE_GETUID) */
   2544 
   2545 #if defined(HAVE_KILL)
   2546 
   2547 PyDoc_STRVAR(os_kill__doc__,
   2548 "kill($module, pid, signal, /)\n"
   2549 "--\n"
   2550 "\n"
   2551 "Kill a process with a signal.");
   2552 
   2553 #define OS_KILL_METHODDEF    \
   2554     {"kill", (PyCFunction)os_kill, METH_VARARGS, os_kill__doc__},
   2555 
   2556 static PyObject *
   2557 os_kill_impl(PyObject *module, pid_t pid, Py_ssize_t signal);
   2558 
   2559 static PyObject *
   2560 os_kill(PyObject *module, PyObject *args)
   2561 {
   2562     PyObject *return_value = NULL;
   2563     pid_t pid;
   2564     Py_ssize_t signal;
   2565 
   2566     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "n:kill",
   2567         &pid, &signal)) {
   2568         goto exit;
   2569     }
   2570     return_value = os_kill_impl(module, pid, signal);
   2571 
   2572 exit:
   2573     return return_value;
   2574 }
   2575 
   2576 #endif /* defined(HAVE_KILL) */
   2577 
   2578 #if defined(HAVE_KILLPG)
   2579 
   2580 PyDoc_STRVAR(os_killpg__doc__,
   2581 "killpg($module, pgid, signal, /)\n"
   2582 "--\n"
   2583 "\n"
   2584 "Kill a process group with a signal.");
   2585 
   2586 #define OS_KILLPG_METHODDEF    \
   2587     {"killpg", (PyCFunction)os_killpg, METH_VARARGS, os_killpg__doc__},
   2588 
   2589 static PyObject *
   2590 os_killpg_impl(PyObject *module, pid_t pgid, int signal);
   2591 
   2592 static PyObject *
   2593 os_killpg(PyObject *module, PyObject *args)
   2594 {
   2595     PyObject *return_value = NULL;
   2596     pid_t pgid;
   2597     int signal;
   2598 
   2599     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:killpg",
   2600         &pgid, &signal)) {
   2601         goto exit;
   2602     }
   2603     return_value = os_killpg_impl(module, pgid, signal);
   2604 
   2605 exit:
   2606     return return_value;
   2607 }
   2608 
   2609 #endif /* defined(HAVE_KILLPG) */
   2610 
   2611 #if defined(HAVE_PLOCK)
   2612 
   2613 PyDoc_STRVAR(os_plock__doc__,
   2614 "plock($module, op, /)\n"
   2615 "--\n"
   2616 "\n"
   2617 "Lock program segments into memory.\");");
   2618 
   2619 #define OS_PLOCK_METHODDEF    \
   2620     {"plock", (PyCFunction)os_plock, METH_O, os_plock__doc__},
   2621 
   2622 static PyObject *
   2623 os_plock_impl(PyObject *module, int op);
   2624 
   2625 static PyObject *
   2626 os_plock(PyObject *module, PyObject *arg)
   2627 {
   2628     PyObject *return_value = NULL;
   2629     int op;
   2630 
   2631     if (!PyArg_Parse(arg, "i:plock", &op)) {
   2632         goto exit;
   2633     }
   2634     return_value = os_plock_impl(module, op);
   2635 
   2636 exit:
   2637     return return_value;
   2638 }
   2639 
   2640 #endif /* defined(HAVE_PLOCK) */
   2641 
   2642 #if defined(HAVE_SETUID)
   2643 
   2644 PyDoc_STRVAR(os_setuid__doc__,
   2645 "setuid($module, uid, /)\n"
   2646 "--\n"
   2647 "\n"
   2648 "Set the current process\'s user id.");
   2649 
   2650 #define OS_SETUID_METHODDEF    \
   2651     {"setuid", (PyCFunction)os_setuid, METH_O, os_setuid__doc__},
   2652 
   2653 static PyObject *
   2654 os_setuid_impl(PyObject *module, uid_t uid);
   2655 
   2656 static PyObject *
   2657 os_setuid(PyObject *module, PyObject *arg)
   2658 {
   2659     PyObject *return_value = NULL;
   2660     uid_t uid;
   2661 
   2662     if (!PyArg_Parse(arg, "O&:setuid", _Py_Uid_Converter, &uid)) {
   2663         goto exit;
   2664     }
   2665     return_value = os_setuid_impl(module, uid);
   2666 
   2667 exit:
   2668     return return_value;
   2669 }
   2670 
   2671 #endif /* defined(HAVE_SETUID) */
   2672 
   2673 #if defined(HAVE_SETEUID)
   2674 
   2675 PyDoc_STRVAR(os_seteuid__doc__,
   2676 "seteuid($module, euid, /)\n"
   2677 "--\n"
   2678 "\n"
   2679 "Set the current process\'s effective user id.");
   2680 
   2681 #define OS_SETEUID_METHODDEF    \
   2682     {"seteuid", (PyCFunction)os_seteuid, METH_O, os_seteuid__doc__},
   2683 
   2684 static PyObject *
   2685 os_seteuid_impl(PyObject *module, uid_t euid);
   2686 
   2687 static PyObject *
   2688 os_seteuid(PyObject *module, PyObject *arg)
   2689 {
   2690     PyObject *return_value = NULL;
   2691     uid_t euid;
   2692 
   2693     if (!PyArg_Parse(arg, "O&:seteuid", _Py_Uid_Converter, &euid)) {
   2694         goto exit;
   2695     }
   2696     return_value = os_seteuid_impl(module, euid);
   2697 
   2698 exit:
   2699     return return_value;
   2700 }
   2701 
   2702 #endif /* defined(HAVE_SETEUID) */
   2703 
   2704 #if defined(HAVE_SETEGID)
   2705 
   2706 PyDoc_STRVAR(os_setegid__doc__,
   2707 "setegid($module, egid, /)\n"
   2708 "--\n"
   2709 "\n"
   2710 "Set the current process\'s effective group id.");
   2711 
   2712 #define OS_SETEGID_METHODDEF    \
   2713     {"setegid", (PyCFunction)os_setegid, METH_O, os_setegid__doc__},
   2714 
   2715 static PyObject *
   2716 os_setegid_impl(PyObject *module, gid_t egid);
   2717 
   2718 static PyObject *
   2719 os_setegid(PyObject *module, PyObject *arg)
   2720 {
   2721     PyObject *return_value = NULL;
   2722     gid_t egid;
   2723 
   2724     if (!PyArg_Parse(arg, "O&:setegid", _Py_Gid_Converter, &egid)) {
   2725         goto exit;
   2726     }
   2727     return_value = os_setegid_impl(module, egid);
   2728 
   2729 exit:
   2730     return return_value;
   2731 }
   2732 
   2733 #endif /* defined(HAVE_SETEGID) */
   2734 
   2735 #if defined(HAVE_SETREUID)
   2736 
   2737 PyDoc_STRVAR(os_setreuid__doc__,
   2738 "setreuid($module, ruid, euid, /)\n"
   2739 "--\n"
   2740 "\n"
   2741 "Set the current process\'s real and effective user ids.");
   2742 
   2743 #define OS_SETREUID_METHODDEF    \
   2744     {"setreuid", (PyCFunction)os_setreuid, METH_VARARGS, os_setreuid__doc__},
   2745 
   2746 static PyObject *
   2747 os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid);
   2748 
   2749 static PyObject *
   2750 os_setreuid(PyObject *module, PyObject *args)
   2751 {
   2752     PyObject *return_value = NULL;
   2753     uid_t ruid;
   2754     uid_t euid;
   2755 
   2756     if (!PyArg_ParseTuple(args, "O&O&:setreuid",
   2757         _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid)) {
   2758         goto exit;
   2759     }
   2760     return_value = os_setreuid_impl(module, ruid, euid);
   2761 
   2762 exit:
   2763     return return_value;
   2764 }
   2765 
   2766 #endif /* defined(HAVE_SETREUID) */
   2767 
   2768 #if defined(HAVE_SETREGID)
   2769 
   2770 PyDoc_STRVAR(os_setregid__doc__,
   2771 "setregid($module, rgid, egid, /)\n"
   2772 "--\n"
   2773 "\n"
   2774 "Set the current process\'s real and effective group ids.");
   2775 
   2776 #define OS_SETREGID_METHODDEF    \
   2777     {"setregid", (PyCFunction)os_setregid, METH_VARARGS, os_setregid__doc__},
   2778 
   2779 static PyObject *
   2780 os_setregid_impl(PyObject *module, gid_t rgid, gid_t egid);
   2781 
   2782 static PyObject *
   2783 os_setregid(PyObject *module, PyObject *args)
   2784 {
   2785     PyObject *return_value = NULL;
   2786     gid_t rgid;
   2787     gid_t egid;
   2788 
   2789     if (!PyArg_ParseTuple(args, "O&O&:setregid",
   2790         _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid)) {
   2791         goto exit;
   2792     }
   2793     return_value = os_setregid_impl(module, rgid, egid);
   2794 
   2795 exit:
   2796     return return_value;
   2797 }
   2798 
   2799 #endif /* defined(HAVE_SETREGID) */
   2800 
   2801 #if defined(HAVE_SETGID)
   2802 
   2803 PyDoc_STRVAR(os_setgid__doc__,
   2804 "setgid($module, gid, /)\n"
   2805 "--\n"
   2806 "\n"
   2807 "Set the current process\'s group id.");
   2808 
   2809 #define OS_SETGID_METHODDEF    \
   2810     {"setgid", (PyCFunction)os_setgid, METH_O, os_setgid__doc__},
   2811 
   2812 static PyObject *
   2813 os_setgid_impl(PyObject *module, gid_t gid);
   2814 
   2815 static PyObject *
   2816 os_setgid(PyObject *module, PyObject *arg)
   2817 {
   2818     PyObject *return_value = NULL;
   2819     gid_t gid;
   2820 
   2821     if (!PyArg_Parse(arg, "O&:setgid", _Py_Gid_Converter, &gid)) {
   2822         goto exit;
   2823     }
   2824     return_value = os_setgid_impl(module, gid);
   2825 
   2826 exit:
   2827     return return_value;
   2828 }
   2829 
   2830 #endif /* defined(HAVE_SETGID) */
   2831 
   2832 #if defined(HAVE_SETGROUPS)
   2833 
   2834 PyDoc_STRVAR(os_setgroups__doc__,
   2835 "setgroups($module, groups, /)\n"
   2836 "--\n"
   2837 "\n"
   2838 "Set the groups of the current process to list.");
   2839 
   2840 #define OS_SETGROUPS_METHODDEF    \
   2841     {"setgroups", (PyCFunction)os_setgroups, METH_O, os_setgroups__doc__},
   2842 
   2843 #endif /* defined(HAVE_SETGROUPS) */
   2844 
   2845 #if defined(HAVE_WAIT3)
   2846 
   2847 PyDoc_STRVAR(os_wait3__doc__,
   2848 "wait3($module, /, options)\n"
   2849 "--\n"
   2850 "\n"
   2851 "Wait for completion of a child process.\n"
   2852 "\n"
   2853 "Returns a tuple of information about the child process:\n"
   2854 "  (pid, status, rusage)");
   2855 
   2856 #define OS_WAIT3_METHODDEF    \
   2857     {"wait3", (PyCFunction)os_wait3, METH_FASTCALL, os_wait3__doc__},
   2858 
   2859 static PyObject *
   2860 os_wait3_impl(PyObject *module, int options);
   2861 
   2862 static PyObject *
   2863 os_wait3(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   2864 {
   2865     PyObject *return_value = NULL;
   2866     static const char * const _keywords[] = {"options", NULL};
   2867     static _PyArg_Parser _parser = {"i:wait3", _keywords, 0};
   2868     int options;
   2869 
   2870     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   2871         &options)) {
   2872         goto exit;
   2873     }
   2874     return_value = os_wait3_impl(module, options);
   2875 
   2876 exit:
   2877     return return_value;
   2878 }
   2879 
   2880 #endif /* defined(HAVE_WAIT3) */
   2881 
   2882 #if defined(HAVE_WAIT4)
   2883 
   2884 PyDoc_STRVAR(os_wait4__doc__,
   2885 "wait4($module, /, pid, options)\n"
   2886 "--\n"
   2887 "\n"
   2888 "Wait for completion of a specific child process.\n"
   2889 "\n"
   2890 "Returns a tuple of information about the child process:\n"
   2891 "  (pid, status, rusage)");
   2892 
   2893 #define OS_WAIT4_METHODDEF    \
   2894     {"wait4", (PyCFunction)os_wait4, METH_FASTCALL, os_wait4__doc__},
   2895 
   2896 static PyObject *
   2897 os_wait4_impl(PyObject *module, pid_t pid, int options);
   2898 
   2899 static PyObject *
   2900 os_wait4(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   2901 {
   2902     PyObject *return_value = NULL;
   2903     static const char * const _keywords[] = {"pid", "options", NULL};
   2904     static _PyArg_Parser _parser = {"" _Py_PARSE_PID "i:wait4", _keywords, 0};
   2905     pid_t pid;
   2906     int options;
   2907 
   2908     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   2909         &pid, &options)) {
   2910         goto exit;
   2911     }
   2912     return_value = os_wait4_impl(module, pid, options);
   2913 
   2914 exit:
   2915     return return_value;
   2916 }
   2917 
   2918 #endif /* defined(HAVE_WAIT4) */
   2919 
   2920 #if (defined(HAVE_WAITID) && !defined(__APPLE__))
   2921 
   2922 PyDoc_STRVAR(os_waitid__doc__,
   2923 "waitid($module, idtype, id, options, /)\n"
   2924 "--\n"
   2925 "\n"
   2926 "Returns the result of waiting for a process or processes.\n"
   2927 "\n"
   2928 "  idtype\n"
   2929 "    Must be one of be P_PID, P_PGID or P_ALL.\n"
   2930 "  id\n"
   2931 "    The id to wait on.\n"
   2932 "  options\n"
   2933 "    Constructed from the ORing of one or more of WEXITED, WSTOPPED\n"
   2934 "    or WCONTINUED and additionally may be ORed with WNOHANG or WNOWAIT.\n"
   2935 "\n"
   2936 "Returns either waitid_result or None if WNOHANG is specified and there are\n"
   2937 "no children in a waitable state.");
   2938 
   2939 #define OS_WAITID_METHODDEF    \
   2940     {"waitid", (PyCFunction)os_waitid, METH_VARARGS, os_waitid__doc__},
   2941 
   2942 static PyObject *
   2943 os_waitid_impl(PyObject *module, idtype_t idtype, id_t id, int options);
   2944 
   2945 static PyObject *
   2946 os_waitid(PyObject *module, PyObject *args)
   2947 {
   2948     PyObject *return_value = NULL;
   2949     idtype_t idtype;
   2950     id_t id;
   2951     int options;
   2952 
   2953     if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID "i:waitid",
   2954         &idtype, &id, &options)) {
   2955         goto exit;
   2956     }
   2957     return_value = os_waitid_impl(module, idtype, id, options);
   2958 
   2959 exit:
   2960     return return_value;
   2961 }
   2962 
   2963 #endif /* (defined(HAVE_WAITID) && !defined(__APPLE__)) */
   2964 
   2965 #if defined(HAVE_WAITPID)
   2966 
   2967 PyDoc_STRVAR(os_waitpid__doc__,
   2968 "waitpid($module, pid, options, /)\n"
   2969 "--\n"
   2970 "\n"
   2971 "Wait for completion of a given child process.\n"
   2972 "\n"
   2973 "Returns a tuple of information regarding the child process:\n"
   2974 "    (pid, status)\n"
   2975 "\n"
   2976 "The options argument is ignored on Windows.");
   2977 
   2978 #define OS_WAITPID_METHODDEF    \
   2979     {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__},
   2980 
   2981 static PyObject *
   2982 os_waitpid_impl(PyObject *module, pid_t pid, int options);
   2983 
   2984 static PyObject *
   2985 os_waitpid(PyObject *module, PyObject *args)
   2986 {
   2987     PyObject *return_value = NULL;
   2988     pid_t pid;
   2989     int options;
   2990 
   2991     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "i:waitpid",
   2992         &pid, &options)) {
   2993         goto exit;
   2994     }
   2995     return_value = os_waitpid_impl(module, pid, options);
   2996 
   2997 exit:
   2998     return return_value;
   2999 }
   3000 
   3001 #endif /* defined(HAVE_WAITPID) */
   3002 
   3003 #if defined(HAVE_CWAIT)
   3004 
   3005 PyDoc_STRVAR(os_waitpid__doc__,
   3006 "waitpid($module, pid, options, /)\n"
   3007 "--\n"
   3008 "\n"
   3009 "Wait for completion of a given process.\n"
   3010 "\n"
   3011 "Returns a tuple of information regarding the process:\n"
   3012 "    (pid, status << 8)\n"
   3013 "\n"
   3014 "The options argument is ignored on Windows.");
   3015 
   3016 #define OS_WAITPID_METHODDEF    \
   3017     {"waitpid", (PyCFunction)os_waitpid, METH_VARARGS, os_waitpid__doc__},
   3018 
   3019 static PyObject *
   3020 os_waitpid_impl(PyObject *module, intptr_t pid, int options);
   3021 
   3022 static PyObject *
   3023 os_waitpid(PyObject *module, PyObject *args)
   3024 {
   3025     PyObject *return_value = NULL;
   3026     intptr_t pid;
   3027     int options;
   3028 
   3029     if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "i:waitpid",
   3030         &pid, &options)) {
   3031         goto exit;
   3032     }
   3033     return_value = os_waitpid_impl(module, pid, options);
   3034 
   3035 exit:
   3036     return return_value;
   3037 }
   3038 
   3039 #endif /* defined(HAVE_CWAIT) */
   3040 
   3041 #if defined(HAVE_WAIT)
   3042 
   3043 PyDoc_STRVAR(os_wait__doc__,
   3044 "wait($module, /)\n"
   3045 "--\n"
   3046 "\n"
   3047 "Wait for completion of a child process.\n"
   3048 "\n"
   3049 "Returns a tuple of information about the child process:\n"
   3050 "    (pid, status)");
   3051 
   3052 #define OS_WAIT_METHODDEF    \
   3053     {"wait", (PyCFunction)os_wait, METH_NOARGS, os_wait__doc__},
   3054 
   3055 static PyObject *
   3056 os_wait_impl(PyObject *module);
   3057 
   3058 static PyObject *
   3059 os_wait(PyObject *module, PyObject *Py_UNUSED(ignored))
   3060 {
   3061     return os_wait_impl(module);
   3062 }
   3063 
   3064 #endif /* defined(HAVE_WAIT) */
   3065 
   3066 #if defined(HAVE_SYMLINK)
   3067 
   3068 PyDoc_STRVAR(os_symlink__doc__,
   3069 "symlink($module, /, src, dst, target_is_directory=False, *, dir_fd=None)\n"
   3070 "--\n"
   3071 "\n"
   3072 "Create a symbolic link pointing to src named dst.\n"
   3073 "\n"
   3074 "target_is_directory is required on Windows if the target is to be\n"
   3075 "  interpreted as a directory.  (On Windows, symlink requires\n"
   3076 "  Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n"
   3077 "  target_is_directory is ignored on non-Windows platforms.\n"
   3078 "\n"
   3079 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   3080 "  and path should be relative; path will then be relative to that directory.\n"
   3081 "dir_fd may not be implemented on your platform.\n"
   3082 "  If it is unavailable, using it will raise a NotImplementedError.");
   3083 
   3084 #define OS_SYMLINK_METHODDEF    \
   3085     {"symlink", (PyCFunction)os_symlink, METH_FASTCALL, os_symlink__doc__},
   3086 
   3087 static PyObject *
   3088 os_symlink_impl(PyObject *module, path_t *src, path_t *dst,
   3089                 int target_is_directory, int dir_fd);
   3090 
   3091 static PyObject *
   3092 os_symlink(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3093 {
   3094     PyObject *return_value = NULL;
   3095     static const char * const _keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL};
   3096     static _PyArg_Parser _parser = {"O&O&|p$O&:symlink", _keywords, 0};
   3097     path_t src = PATH_T_INITIALIZE("symlink", "src", 0, 0);
   3098     path_t dst = PATH_T_INITIALIZE("symlink", "dst", 0, 0);
   3099     int target_is_directory = 0;
   3100     int dir_fd = DEFAULT_DIR_FD;
   3101 
   3102     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3103         path_converter, &src, path_converter, &dst, &target_is_directory, SYMLINKAT_DIR_FD_CONVERTER, &dir_fd)) {
   3104         goto exit;
   3105     }
   3106     return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd);
   3107 
   3108 exit:
   3109     /* Cleanup for src */
   3110     path_cleanup(&src);
   3111     /* Cleanup for dst */
   3112     path_cleanup(&dst);
   3113 
   3114     return return_value;
   3115 }
   3116 
   3117 #endif /* defined(HAVE_SYMLINK) */
   3118 
   3119 #if defined(HAVE_TIMES)
   3120 
   3121 PyDoc_STRVAR(os_times__doc__,
   3122 "times($module, /)\n"
   3123 "--\n"
   3124 "\n"
   3125 "Return a collection containing process timing information.\n"
   3126 "\n"
   3127 "The object returned behaves like a named tuple with these fields:\n"
   3128 "  (utime, stime, cutime, cstime, elapsed_time)\n"
   3129 "All fields are floating point numbers.");
   3130 
   3131 #define OS_TIMES_METHODDEF    \
   3132     {"times", (PyCFunction)os_times, METH_NOARGS, os_times__doc__},
   3133 
   3134 static PyObject *
   3135 os_times_impl(PyObject *module);
   3136 
   3137 static PyObject *
   3138 os_times(PyObject *module, PyObject *Py_UNUSED(ignored))
   3139 {
   3140     return os_times_impl(module);
   3141 }
   3142 
   3143 #endif /* defined(HAVE_TIMES) */
   3144 
   3145 #if defined(HAVE_GETSID)
   3146 
   3147 PyDoc_STRVAR(os_getsid__doc__,
   3148 "getsid($module, pid, /)\n"
   3149 "--\n"
   3150 "\n"
   3151 "Call the system call getsid(pid) and return the result.");
   3152 
   3153 #define OS_GETSID_METHODDEF    \
   3154     {"getsid", (PyCFunction)os_getsid, METH_O, os_getsid__doc__},
   3155 
   3156 static PyObject *
   3157 os_getsid_impl(PyObject *module, pid_t pid);
   3158 
   3159 static PyObject *
   3160 os_getsid(PyObject *module, PyObject *arg)
   3161 {
   3162     PyObject *return_value = NULL;
   3163     pid_t pid;
   3164 
   3165     if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":getsid", &pid)) {
   3166         goto exit;
   3167     }
   3168     return_value = os_getsid_impl(module, pid);
   3169 
   3170 exit:
   3171     return return_value;
   3172 }
   3173 
   3174 #endif /* defined(HAVE_GETSID) */
   3175 
   3176 #if defined(HAVE_SETSID)
   3177 
   3178 PyDoc_STRVAR(os_setsid__doc__,
   3179 "setsid($module, /)\n"
   3180 "--\n"
   3181 "\n"
   3182 "Call the system call setsid().");
   3183 
   3184 #define OS_SETSID_METHODDEF    \
   3185     {"setsid", (PyCFunction)os_setsid, METH_NOARGS, os_setsid__doc__},
   3186 
   3187 static PyObject *
   3188 os_setsid_impl(PyObject *module);
   3189 
   3190 static PyObject *
   3191 os_setsid(PyObject *module, PyObject *Py_UNUSED(ignored))
   3192 {
   3193     return os_setsid_impl(module);
   3194 }
   3195 
   3196 #endif /* defined(HAVE_SETSID) */
   3197 
   3198 #if defined(HAVE_SETPGID)
   3199 
   3200 PyDoc_STRVAR(os_setpgid__doc__,
   3201 "setpgid($module, pid, pgrp, /)\n"
   3202 "--\n"
   3203 "\n"
   3204 "Call the system call setpgid(pid, pgrp).");
   3205 
   3206 #define OS_SETPGID_METHODDEF    \
   3207     {"setpgid", (PyCFunction)os_setpgid, METH_VARARGS, os_setpgid__doc__},
   3208 
   3209 static PyObject *
   3210 os_setpgid_impl(PyObject *module, pid_t pid, pid_t pgrp);
   3211 
   3212 static PyObject *
   3213 os_setpgid(PyObject *module, PyObject *args)
   3214 {
   3215     PyObject *return_value = NULL;
   3216     pid_t pid;
   3217     pid_t pgrp;
   3218 
   3219     if (!PyArg_ParseTuple(args, "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid",
   3220         &pid, &pgrp)) {
   3221         goto exit;
   3222     }
   3223     return_value = os_setpgid_impl(module, pid, pgrp);
   3224 
   3225 exit:
   3226     return return_value;
   3227 }
   3228 
   3229 #endif /* defined(HAVE_SETPGID) */
   3230 
   3231 #if defined(HAVE_TCGETPGRP)
   3232 
   3233 PyDoc_STRVAR(os_tcgetpgrp__doc__,
   3234 "tcgetpgrp($module, fd, /)\n"
   3235 "--\n"
   3236 "\n"
   3237 "Return the process group associated with the terminal specified by fd.");
   3238 
   3239 #define OS_TCGETPGRP_METHODDEF    \
   3240     {"tcgetpgrp", (PyCFunction)os_tcgetpgrp, METH_O, os_tcgetpgrp__doc__},
   3241 
   3242 static PyObject *
   3243 os_tcgetpgrp_impl(PyObject *module, int fd);
   3244 
   3245 static PyObject *
   3246 os_tcgetpgrp(PyObject *module, PyObject *arg)
   3247 {
   3248     PyObject *return_value = NULL;
   3249     int fd;
   3250 
   3251     if (!PyArg_Parse(arg, "i:tcgetpgrp", &fd)) {
   3252         goto exit;
   3253     }
   3254     return_value = os_tcgetpgrp_impl(module, fd);
   3255 
   3256 exit:
   3257     return return_value;
   3258 }
   3259 
   3260 #endif /* defined(HAVE_TCGETPGRP) */
   3261 
   3262 #if defined(HAVE_TCSETPGRP)
   3263 
   3264 PyDoc_STRVAR(os_tcsetpgrp__doc__,
   3265 "tcsetpgrp($module, fd, pgid, /)\n"
   3266 "--\n"
   3267 "\n"
   3268 "Set the process group associated with the terminal specified by fd.");
   3269 
   3270 #define OS_TCSETPGRP_METHODDEF    \
   3271     {"tcsetpgrp", (PyCFunction)os_tcsetpgrp, METH_VARARGS, os_tcsetpgrp__doc__},
   3272 
   3273 static PyObject *
   3274 os_tcsetpgrp_impl(PyObject *module, int fd, pid_t pgid);
   3275 
   3276 static PyObject *
   3277 os_tcsetpgrp(PyObject *module, PyObject *args)
   3278 {
   3279     PyObject *return_value = NULL;
   3280     int fd;
   3281     pid_t pgid;
   3282 
   3283     if (!PyArg_ParseTuple(args, "i" _Py_PARSE_PID ":tcsetpgrp",
   3284         &fd, &pgid)) {
   3285         goto exit;
   3286     }
   3287     return_value = os_tcsetpgrp_impl(module, fd, pgid);
   3288 
   3289 exit:
   3290     return return_value;
   3291 }
   3292 
   3293 #endif /* defined(HAVE_TCSETPGRP) */
   3294 
   3295 PyDoc_STRVAR(os_open__doc__,
   3296 "open($module, /, path, flags, mode=511, *, dir_fd=None)\n"
   3297 "--\n"
   3298 "\n"
   3299 "Open a file for low level IO.  Returns a file descriptor (integer).\n"
   3300 "\n"
   3301 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   3302 "  and path should be relative; path will then be relative to that directory.\n"
   3303 "dir_fd may not be implemented on your platform.\n"
   3304 "  If it is unavailable, using it will raise a NotImplementedError.");
   3305 
   3306 #define OS_OPEN_METHODDEF    \
   3307     {"open", (PyCFunction)os_open, METH_FASTCALL, os_open__doc__},
   3308 
   3309 static int
   3310 os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd);
   3311 
   3312 static PyObject *
   3313 os_open(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3314 {
   3315     PyObject *return_value = NULL;
   3316     static const char * const _keywords[] = {"path", "flags", "mode", "dir_fd", NULL};
   3317     static _PyArg_Parser _parser = {"O&i|i$O&:open", _keywords, 0};
   3318     path_t path = PATH_T_INITIALIZE("open", "path", 0, 0);
   3319     int flags;
   3320     int mode = 511;
   3321     int dir_fd = DEFAULT_DIR_FD;
   3322     int _return_value;
   3323 
   3324     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3325         path_converter, &path, &flags, &mode, OPENAT_DIR_FD_CONVERTER, &dir_fd)) {
   3326         goto exit;
   3327     }
   3328     _return_value = os_open_impl(module, &path, flags, mode, dir_fd);
   3329     if ((_return_value == -1) && PyErr_Occurred()) {
   3330         goto exit;
   3331     }
   3332     return_value = PyLong_FromLong((long)_return_value);
   3333 
   3334 exit:
   3335     /* Cleanup for path */
   3336     path_cleanup(&path);
   3337 
   3338     return return_value;
   3339 }
   3340 
   3341 PyDoc_STRVAR(os_close__doc__,
   3342 "close($module, /, fd)\n"
   3343 "--\n"
   3344 "\n"
   3345 "Close a file descriptor.");
   3346 
   3347 #define OS_CLOSE_METHODDEF    \
   3348     {"close", (PyCFunction)os_close, METH_FASTCALL, os_close__doc__},
   3349 
   3350 static PyObject *
   3351 os_close_impl(PyObject *module, int fd);
   3352 
   3353 static PyObject *
   3354 os_close(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3355 {
   3356     PyObject *return_value = NULL;
   3357     static const char * const _keywords[] = {"fd", NULL};
   3358     static _PyArg_Parser _parser = {"i:close", _keywords, 0};
   3359     int fd;
   3360 
   3361     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3362         &fd)) {
   3363         goto exit;
   3364     }
   3365     return_value = os_close_impl(module, fd);
   3366 
   3367 exit:
   3368     return return_value;
   3369 }
   3370 
   3371 PyDoc_STRVAR(os_closerange__doc__,
   3372 "closerange($module, fd_low, fd_high, /)\n"
   3373 "--\n"
   3374 "\n"
   3375 "Closes all file descriptors in [fd_low, fd_high), ignoring errors.");
   3376 
   3377 #define OS_CLOSERANGE_METHODDEF    \
   3378     {"closerange", (PyCFunction)os_closerange, METH_VARARGS, os_closerange__doc__},
   3379 
   3380 static PyObject *
   3381 os_closerange_impl(PyObject *module, int fd_low, int fd_high);
   3382 
   3383 static PyObject *
   3384 os_closerange(PyObject *module, PyObject *args)
   3385 {
   3386     PyObject *return_value = NULL;
   3387     int fd_low;
   3388     int fd_high;
   3389 
   3390     if (!PyArg_ParseTuple(args, "ii:closerange",
   3391         &fd_low, &fd_high)) {
   3392         goto exit;
   3393     }
   3394     return_value = os_closerange_impl(module, fd_low, fd_high);
   3395 
   3396 exit:
   3397     return return_value;
   3398 }
   3399 
   3400 PyDoc_STRVAR(os_dup__doc__,
   3401 "dup($module, fd, /)\n"
   3402 "--\n"
   3403 "\n"
   3404 "Return a duplicate of a file descriptor.");
   3405 
   3406 #define OS_DUP_METHODDEF    \
   3407     {"dup", (PyCFunction)os_dup, METH_O, os_dup__doc__},
   3408 
   3409 static int
   3410 os_dup_impl(PyObject *module, int fd);
   3411 
   3412 static PyObject *
   3413 os_dup(PyObject *module, PyObject *arg)
   3414 {
   3415     PyObject *return_value = NULL;
   3416     int fd;
   3417     int _return_value;
   3418 
   3419     if (!PyArg_Parse(arg, "i:dup", &fd)) {
   3420         goto exit;
   3421     }
   3422     _return_value = os_dup_impl(module, fd);
   3423     if ((_return_value == -1) && PyErr_Occurred()) {
   3424         goto exit;
   3425     }
   3426     return_value = PyLong_FromLong((long)_return_value);
   3427 
   3428 exit:
   3429     return return_value;
   3430 }
   3431 
   3432 PyDoc_STRVAR(os_dup2__doc__,
   3433 "dup2($module, /, fd, fd2, inheritable=True)\n"
   3434 "--\n"
   3435 "\n"
   3436 "Duplicate file descriptor.");
   3437 
   3438 #define OS_DUP2_METHODDEF    \
   3439     {"dup2", (PyCFunction)os_dup2, METH_FASTCALL, os_dup2__doc__},
   3440 
   3441 static PyObject *
   3442 os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable);
   3443 
   3444 static PyObject *
   3445 os_dup2(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3446 {
   3447     PyObject *return_value = NULL;
   3448     static const char * const _keywords[] = {"fd", "fd2", "inheritable", NULL};
   3449     static _PyArg_Parser _parser = {"ii|p:dup2", _keywords, 0};
   3450     int fd;
   3451     int fd2;
   3452     int inheritable = 1;
   3453 
   3454     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3455         &fd, &fd2, &inheritable)) {
   3456         goto exit;
   3457     }
   3458     return_value = os_dup2_impl(module, fd, fd2, inheritable);
   3459 
   3460 exit:
   3461     return return_value;
   3462 }
   3463 
   3464 #if defined(HAVE_LOCKF)
   3465 
   3466 PyDoc_STRVAR(os_lockf__doc__,
   3467 "lockf($module, fd, command, length, /)\n"
   3468 "--\n"
   3469 "\n"
   3470 "Apply, test or remove a POSIX lock on an open file descriptor.\n"
   3471 "\n"
   3472 "  fd\n"
   3473 "    An open file descriptor.\n"
   3474 "  command\n"
   3475 "    One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.\n"
   3476 "  length\n"
   3477 "    The number of bytes to lock, starting at the current position.");
   3478 
   3479 #define OS_LOCKF_METHODDEF    \
   3480     {"lockf", (PyCFunction)os_lockf, METH_VARARGS, os_lockf__doc__},
   3481 
   3482 static PyObject *
   3483 os_lockf_impl(PyObject *module, int fd, int command, Py_off_t length);
   3484 
   3485 static PyObject *
   3486 os_lockf(PyObject *module, PyObject *args)
   3487 {
   3488     PyObject *return_value = NULL;
   3489     int fd;
   3490     int command;
   3491     Py_off_t length;
   3492 
   3493     if (!PyArg_ParseTuple(args, "iiO&:lockf",
   3494         &fd, &command, Py_off_t_converter, &length)) {
   3495         goto exit;
   3496     }
   3497     return_value = os_lockf_impl(module, fd, command, length);
   3498 
   3499 exit:
   3500     return return_value;
   3501 }
   3502 
   3503 #endif /* defined(HAVE_LOCKF) */
   3504 
   3505 PyDoc_STRVAR(os_lseek__doc__,
   3506 "lseek($module, fd, position, how, /)\n"
   3507 "--\n"
   3508 "\n"
   3509 "Set the position of a file descriptor.  Return the new position.\n"
   3510 "\n"
   3511 "Return the new cursor position in number of bytes\n"
   3512 "relative to the beginning of the file.");
   3513 
   3514 #define OS_LSEEK_METHODDEF    \
   3515     {"lseek", (PyCFunction)os_lseek, METH_VARARGS, os_lseek__doc__},
   3516 
   3517 static Py_off_t
   3518 os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how);
   3519 
   3520 static PyObject *
   3521 os_lseek(PyObject *module, PyObject *args)
   3522 {
   3523     PyObject *return_value = NULL;
   3524     int fd;
   3525     Py_off_t position;
   3526     int how;
   3527     Py_off_t _return_value;
   3528 
   3529     if (!PyArg_ParseTuple(args, "iO&i:lseek",
   3530         &fd, Py_off_t_converter, &position, &how)) {
   3531         goto exit;
   3532     }
   3533     _return_value = os_lseek_impl(module, fd, position, how);
   3534     if ((_return_value == -1) && PyErr_Occurred()) {
   3535         goto exit;
   3536     }
   3537     return_value = PyLong_FromPy_off_t(_return_value);
   3538 
   3539 exit:
   3540     return return_value;
   3541 }
   3542 
   3543 PyDoc_STRVAR(os_read__doc__,
   3544 "read($module, fd, length, /)\n"
   3545 "--\n"
   3546 "\n"
   3547 "Read from a file descriptor.  Returns a bytes object.");
   3548 
   3549 #define OS_READ_METHODDEF    \
   3550     {"read", (PyCFunction)os_read, METH_VARARGS, os_read__doc__},
   3551 
   3552 static PyObject *
   3553 os_read_impl(PyObject *module, int fd, Py_ssize_t length);
   3554 
   3555 static PyObject *
   3556 os_read(PyObject *module, PyObject *args)
   3557 {
   3558     PyObject *return_value = NULL;
   3559     int fd;
   3560     Py_ssize_t length;
   3561 
   3562     if (!PyArg_ParseTuple(args, "in:read",
   3563         &fd, &length)) {
   3564         goto exit;
   3565     }
   3566     return_value = os_read_impl(module, fd, length);
   3567 
   3568 exit:
   3569     return return_value;
   3570 }
   3571 
   3572 #if defined(HAVE_READV)
   3573 
   3574 PyDoc_STRVAR(os_readv__doc__,
   3575 "readv($module, fd, buffers, /)\n"
   3576 "--\n"
   3577 "\n"
   3578 "Read from a file descriptor fd into an iterable of buffers.\n"
   3579 "\n"
   3580 "The buffers should be mutable buffers accepting bytes.\n"
   3581 "readv will transfer data into each buffer until it is full\n"
   3582 "and then move on to the next buffer in the sequence to hold\n"
   3583 "the rest of the data.\n"
   3584 "\n"
   3585 "readv returns the total number of bytes read,\n"
   3586 "which may be less than the total capacity of all the buffers.");
   3587 
   3588 #define OS_READV_METHODDEF    \
   3589     {"readv", (PyCFunction)os_readv, METH_VARARGS, os_readv__doc__},
   3590 
   3591 static Py_ssize_t
   3592 os_readv_impl(PyObject *module, int fd, PyObject *buffers);
   3593 
   3594 static PyObject *
   3595 os_readv(PyObject *module, PyObject *args)
   3596 {
   3597     PyObject *return_value = NULL;
   3598     int fd;
   3599     PyObject *buffers;
   3600     Py_ssize_t _return_value;
   3601 
   3602     if (!PyArg_ParseTuple(args, "iO:readv",
   3603         &fd, &buffers)) {
   3604         goto exit;
   3605     }
   3606     _return_value = os_readv_impl(module, fd, buffers);
   3607     if ((_return_value == -1) && PyErr_Occurred()) {
   3608         goto exit;
   3609     }
   3610     return_value = PyLong_FromSsize_t(_return_value);
   3611 
   3612 exit:
   3613     return return_value;
   3614 }
   3615 
   3616 #endif /* defined(HAVE_READV) */
   3617 
   3618 #if defined(HAVE_PREAD)
   3619 
   3620 PyDoc_STRVAR(os_pread__doc__,
   3621 "pread($module, fd, length, offset, /)\n"
   3622 "--\n"
   3623 "\n"
   3624 "Read a number of bytes from a file descriptor starting at a particular offset.\n"
   3625 "\n"
   3626 "Read length bytes from file descriptor fd, starting at offset bytes from\n"
   3627 "the beginning of the file.  The file offset remains unchanged.");
   3628 
   3629 #define OS_PREAD_METHODDEF    \
   3630     {"pread", (PyCFunction)os_pread, METH_VARARGS, os_pread__doc__},
   3631 
   3632 static PyObject *
   3633 os_pread_impl(PyObject *module, int fd, int length, Py_off_t offset);
   3634 
   3635 static PyObject *
   3636 os_pread(PyObject *module, PyObject *args)
   3637 {
   3638     PyObject *return_value = NULL;
   3639     int fd;
   3640     int length;
   3641     Py_off_t offset;
   3642 
   3643     if (!PyArg_ParseTuple(args, "iiO&:pread",
   3644         &fd, &length, Py_off_t_converter, &offset)) {
   3645         goto exit;
   3646     }
   3647     return_value = os_pread_impl(module, fd, length, offset);
   3648 
   3649 exit:
   3650     return return_value;
   3651 }
   3652 
   3653 #endif /* defined(HAVE_PREAD) */
   3654 
   3655 PyDoc_STRVAR(os_write__doc__,
   3656 "write($module, fd, data, /)\n"
   3657 "--\n"
   3658 "\n"
   3659 "Write a bytes object to a file descriptor.");
   3660 
   3661 #define OS_WRITE_METHODDEF    \
   3662     {"write", (PyCFunction)os_write, METH_VARARGS, os_write__doc__},
   3663 
   3664 static Py_ssize_t
   3665 os_write_impl(PyObject *module, int fd, Py_buffer *data);
   3666 
   3667 static PyObject *
   3668 os_write(PyObject *module, PyObject *args)
   3669 {
   3670     PyObject *return_value = NULL;
   3671     int fd;
   3672     Py_buffer data = {NULL, NULL};
   3673     Py_ssize_t _return_value;
   3674 
   3675     if (!PyArg_ParseTuple(args, "iy*:write",
   3676         &fd, &data)) {
   3677         goto exit;
   3678     }
   3679     _return_value = os_write_impl(module, fd, &data);
   3680     if ((_return_value == -1) && PyErr_Occurred()) {
   3681         goto exit;
   3682     }
   3683     return_value = PyLong_FromSsize_t(_return_value);
   3684 
   3685 exit:
   3686     /* Cleanup for data */
   3687     if (data.obj) {
   3688        PyBuffer_Release(&data);
   3689     }
   3690 
   3691     return return_value;
   3692 }
   3693 
   3694 PyDoc_STRVAR(os_fstat__doc__,
   3695 "fstat($module, /, fd)\n"
   3696 "--\n"
   3697 "\n"
   3698 "Perform a stat system call on the given file descriptor.\n"
   3699 "\n"
   3700 "Like stat(), but for an open file descriptor.\n"
   3701 "Equivalent to os.stat(fd).");
   3702 
   3703 #define OS_FSTAT_METHODDEF    \
   3704     {"fstat", (PyCFunction)os_fstat, METH_FASTCALL, os_fstat__doc__},
   3705 
   3706 static PyObject *
   3707 os_fstat_impl(PyObject *module, int fd);
   3708 
   3709 static PyObject *
   3710 os_fstat(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3711 {
   3712     PyObject *return_value = NULL;
   3713     static const char * const _keywords[] = {"fd", NULL};
   3714     static _PyArg_Parser _parser = {"i:fstat", _keywords, 0};
   3715     int fd;
   3716 
   3717     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3718         &fd)) {
   3719         goto exit;
   3720     }
   3721     return_value = os_fstat_impl(module, fd);
   3722 
   3723 exit:
   3724     return return_value;
   3725 }
   3726 
   3727 PyDoc_STRVAR(os_isatty__doc__,
   3728 "isatty($module, fd, /)\n"
   3729 "--\n"
   3730 "\n"
   3731 "Return True if the fd is connected to a terminal.\n"
   3732 "\n"
   3733 "Return True if the file descriptor is an open file descriptor\n"
   3734 "connected to the slave end of a terminal.");
   3735 
   3736 #define OS_ISATTY_METHODDEF    \
   3737     {"isatty", (PyCFunction)os_isatty, METH_O, os_isatty__doc__},
   3738 
   3739 static int
   3740 os_isatty_impl(PyObject *module, int fd);
   3741 
   3742 static PyObject *
   3743 os_isatty(PyObject *module, PyObject *arg)
   3744 {
   3745     PyObject *return_value = NULL;
   3746     int fd;
   3747     int _return_value;
   3748 
   3749     if (!PyArg_Parse(arg, "i:isatty", &fd)) {
   3750         goto exit;
   3751     }
   3752     _return_value = os_isatty_impl(module, fd);
   3753     if ((_return_value == -1) && PyErr_Occurred()) {
   3754         goto exit;
   3755     }
   3756     return_value = PyBool_FromLong((long)_return_value);
   3757 
   3758 exit:
   3759     return return_value;
   3760 }
   3761 
   3762 #if defined(HAVE_PIPE)
   3763 
   3764 PyDoc_STRVAR(os_pipe__doc__,
   3765 "pipe($module, /)\n"
   3766 "--\n"
   3767 "\n"
   3768 "Create a pipe.\n"
   3769 "\n"
   3770 "Returns a tuple of two file descriptors:\n"
   3771 "  (read_fd, write_fd)");
   3772 
   3773 #define OS_PIPE_METHODDEF    \
   3774     {"pipe", (PyCFunction)os_pipe, METH_NOARGS, os_pipe__doc__},
   3775 
   3776 static PyObject *
   3777 os_pipe_impl(PyObject *module);
   3778 
   3779 static PyObject *
   3780 os_pipe(PyObject *module, PyObject *Py_UNUSED(ignored))
   3781 {
   3782     return os_pipe_impl(module);
   3783 }
   3784 
   3785 #endif /* defined(HAVE_PIPE) */
   3786 
   3787 #if defined(HAVE_PIPE2)
   3788 
   3789 PyDoc_STRVAR(os_pipe2__doc__,
   3790 "pipe2($module, flags, /)\n"
   3791 "--\n"
   3792 "\n"
   3793 "Create a pipe with flags set atomically.\n"
   3794 "\n"
   3795 "Returns a tuple of two file descriptors:\n"
   3796 "  (read_fd, write_fd)\n"
   3797 "\n"
   3798 "flags can be constructed by ORing together one or more of these values:\n"
   3799 "O_NONBLOCK, O_CLOEXEC.");
   3800 
   3801 #define OS_PIPE2_METHODDEF    \
   3802     {"pipe2", (PyCFunction)os_pipe2, METH_O, os_pipe2__doc__},
   3803 
   3804 static PyObject *
   3805 os_pipe2_impl(PyObject *module, int flags);
   3806 
   3807 static PyObject *
   3808 os_pipe2(PyObject *module, PyObject *arg)
   3809 {
   3810     PyObject *return_value = NULL;
   3811     int flags;
   3812 
   3813     if (!PyArg_Parse(arg, "i:pipe2", &flags)) {
   3814         goto exit;
   3815     }
   3816     return_value = os_pipe2_impl(module, flags);
   3817 
   3818 exit:
   3819     return return_value;
   3820 }
   3821 
   3822 #endif /* defined(HAVE_PIPE2) */
   3823 
   3824 #if defined(HAVE_WRITEV)
   3825 
   3826 PyDoc_STRVAR(os_writev__doc__,
   3827 "writev($module, fd, buffers, /)\n"
   3828 "--\n"
   3829 "\n"
   3830 "Iterate over buffers, and write the contents of each to a file descriptor.\n"
   3831 "\n"
   3832 "Returns the total number of bytes written.\n"
   3833 "buffers must be a sequence of bytes-like objects.");
   3834 
   3835 #define OS_WRITEV_METHODDEF    \
   3836     {"writev", (PyCFunction)os_writev, METH_VARARGS, os_writev__doc__},
   3837 
   3838 static Py_ssize_t
   3839 os_writev_impl(PyObject *module, int fd, PyObject *buffers);
   3840 
   3841 static PyObject *
   3842 os_writev(PyObject *module, PyObject *args)
   3843 {
   3844     PyObject *return_value = NULL;
   3845     int fd;
   3846     PyObject *buffers;
   3847     Py_ssize_t _return_value;
   3848 
   3849     if (!PyArg_ParseTuple(args, "iO:writev",
   3850         &fd, &buffers)) {
   3851         goto exit;
   3852     }
   3853     _return_value = os_writev_impl(module, fd, buffers);
   3854     if ((_return_value == -1) && PyErr_Occurred()) {
   3855         goto exit;
   3856     }
   3857     return_value = PyLong_FromSsize_t(_return_value);
   3858 
   3859 exit:
   3860     return return_value;
   3861 }
   3862 
   3863 #endif /* defined(HAVE_WRITEV) */
   3864 
   3865 #if defined(HAVE_PWRITE)
   3866 
   3867 PyDoc_STRVAR(os_pwrite__doc__,
   3868 "pwrite($module, fd, buffer, offset, /)\n"
   3869 "--\n"
   3870 "\n"
   3871 "Write bytes to a file descriptor starting at a particular offset.\n"
   3872 "\n"
   3873 "Write buffer to fd, starting at offset bytes from the beginning of\n"
   3874 "the file.  Returns the number of bytes writte.  Does not change the\n"
   3875 "current file offset.");
   3876 
   3877 #define OS_PWRITE_METHODDEF    \
   3878     {"pwrite", (PyCFunction)os_pwrite, METH_VARARGS, os_pwrite__doc__},
   3879 
   3880 static Py_ssize_t
   3881 os_pwrite_impl(PyObject *module, int fd, Py_buffer *buffer, Py_off_t offset);
   3882 
   3883 static PyObject *
   3884 os_pwrite(PyObject *module, PyObject *args)
   3885 {
   3886     PyObject *return_value = NULL;
   3887     int fd;
   3888     Py_buffer buffer = {NULL, NULL};
   3889     Py_off_t offset;
   3890     Py_ssize_t _return_value;
   3891 
   3892     if (!PyArg_ParseTuple(args, "iy*O&:pwrite",
   3893         &fd, &buffer, Py_off_t_converter, &offset)) {
   3894         goto exit;
   3895     }
   3896     _return_value = os_pwrite_impl(module, fd, &buffer, offset);
   3897     if ((_return_value == -1) && PyErr_Occurred()) {
   3898         goto exit;
   3899     }
   3900     return_value = PyLong_FromSsize_t(_return_value);
   3901 
   3902 exit:
   3903     /* Cleanup for buffer */
   3904     if (buffer.obj) {
   3905        PyBuffer_Release(&buffer);
   3906     }
   3907 
   3908     return return_value;
   3909 }
   3910 
   3911 #endif /* defined(HAVE_PWRITE) */
   3912 
   3913 #if defined(HAVE_MKFIFO)
   3914 
   3915 PyDoc_STRVAR(os_mkfifo__doc__,
   3916 "mkfifo($module, /, path, mode=438, *, dir_fd=None)\n"
   3917 "--\n"
   3918 "\n"
   3919 "Create a \"fifo\" (a POSIX named pipe).\n"
   3920 "\n"
   3921 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   3922 "  and path should be relative; path will then be relative to that directory.\n"
   3923 "dir_fd may not be implemented on your platform.\n"
   3924 "  If it is unavailable, using it will raise a NotImplementedError.");
   3925 
   3926 #define OS_MKFIFO_METHODDEF    \
   3927     {"mkfifo", (PyCFunction)os_mkfifo, METH_FASTCALL, os_mkfifo__doc__},
   3928 
   3929 static PyObject *
   3930 os_mkfifo_impl(PyObject *module, path_t *path, int mode, int dir_fd);
   3931 
   3932 static PyObject *
   3933 os_mkfifo(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3934 {
   3935     PyObject *return_value = NULL;
   3936     static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL};
   3937     static _PyArg_Parser _parser = {"O&|i$O&:mkfifo", _keywords, 0};
   3938     path_t path = PATH_T_INITIALIZE("mkfifo", "path", 0, 0);
   3939     int mode = 438;
   3940     int dir_fd = DEFAULT_DIR_FD;
   3941 
   3942     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3943         path_converter, &path, &mode, MKFIFOAT_DIR_FD_CONVERTER, &dir_fd)) {
   3944         goto exit;
   3945     }
   3946     return_value = os_mkfifo_impl(module, &path, mode, dir_fd);
   3947 
   3948 exit:
   3949     /* Cleanup for path */
   3950     path_cleanup(&path);
   3951 
   3952     return return_value;
   3953 }
   3954 
   3955 #endif /* defined(HAVE_MKFIFO) */
   3956 
   3957 #if (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV))
   3958 
   3959 PyDoc_STRVAR(os_mknod__doc__,
   3960 "mknod($module, /, path, mode=384, device=0, *, dir_fd=None)\n"
   3961 "--\n"
   3962 "\n"
   3963 "Create a node in the file system.\n"
   3964 "\n"
   3965 "Create a node in the file system (file, device special file or named pipe)\n"
   3966 "at path.  mode specifies both the permissions to use and the\n"
   3967 "type of node to be created, being combined (bitwise OR) with one of\n"
   3968 "S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO.  If S_IFCHR or S_IFBLK is set on mode,\n"
   3969 "device defines the newly created device special file (probably using\n"
   3970 "os.makedev()).  Otherwise device is ignored.\n"
   3971 "\n"
   3972 "If dir_fd is not None, it should be a file descriptor open to a directory,\n"
   3973 "  and path should be relative; path will then be relative to that directory.\n"
   3974 "dir_fd may not be implemented on your platform.\n"
   3975 "  If it is unavailable, using it will raise a NotImplementedError.");
   3976 
   3977 #define OS_MKNOD_METHODDEF    \
   3978     {"mknod", (PyCFunction)os_mknod, METH_FASTCALL, os_mknod__doc__},
   3979 
   3980 static PyObject *
   3981 os_mknod_impl(PyObject *module, path_t *path, int mode, dev_t device,
   3982               int dir_fd);
   3983 
   3984 static PyObject *
   3985 os_mknod(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   3986 {
   3987     PyObject *return_value = NULL;
   3988     static const char * const _keywords[] = {"path", "mode", "device", "dir_fd", NULL};
   3989     static _PyArg_Parser _parser = {"O&|iO&$O&:mknod", _keywords, 0};
   3990     path_t path = PATH_T_INITIALIZE("mknod", "path", 0, 0);
   3991     int mode = 384;
   3992     dev_t device = 0;
   3993     int dir_fd = DEFAULT_DIR_FD;
   3994 
   3995     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   3996         path_converter, &path, &mode, _Py_Dev_Converter, &device, MKNODAT_DIR_FD_CONVERTER, &dir_fd)) {
   3997         goto exit;
   3998     }
   3999     return_value = os_mknod_impl(module, &path, mode, device, dir_fd);
   4000 
   4001 exit:
   4002     /* Cleanup for path */
   4003     path_cleanup(&path);
   4004 
   4005     return return_value;
   4006 }
   4007 
   4008 #endif /* (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) */
   4009 
   4010 #if defined(HAVE_DEVICE_MACROS)
   4011 
   4012 PyDoc_STRVAR(os_major__doc__,
   4013 "major($module, device, /)\n"
   4014 "--\n"
   4015 "\n"
   4016 "Extracts a device major number from a raw device number.");
   4017 
   4018 #define OS_MAJOR_METHODDEF    \
   4019     {"major", (PyCFunction)os_major, METH_O, os_major__doc__},
   4020 
   4021 static unsigned int
   4022 os_major_impl(PyObject *module, dev_t device);
   4023 
   4024 static PyObject *
   4025 os_major(PyObject *module, PyObject *arg)
   4026 {
   4027     PyObject *return_value = NULL;
   4028     dev_t device;
   4029     unsigned int _return_value;
   4030 
   4031     if (!PyArg_Parse(arg, "O&:major", _Py_Dev_Converter, &device)) {
   4032         goto exit;
   4033     }
   4034     _return_value = os_major_impl(module, device);
   4035     if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
   4036         goto exit;
   4037     }
   4038     return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
   4039 
   4040 exit:
   4041     return return_value;
   4042 }
   4043 
   4044 #endif /* defined(HAVE_DEVICE_MACROS) */
   4045 
   4046 #if defined(HAVE_DEVICE_MACROS)
   4047 
   4048 PyDoc_STRVAR(os_minor__doc__,
   4049 "minor($module, device, /)\n"
   4050 "--\n"
   4051 "\n"
   4052 "Extracts a device minor number from a raw device number.");
   4053 
   4054 #define OS_MINOR_METHODDEF    \
   4055     {"minor", (PyCFunction)os_minor, METH_O, os_minor__doc__},
   4056 
   4057 static unsigned int
   4058 os_minor_impl(PyObject *module, dev_t device);
   4059 
   4060 static PyObject *
   4061 os_minor(PyObject *module, PyObject *arg)
   4062 {
   4063     PyObject *return_value = NULL;
   4064     dev_t device;
   4065     unsigned int _return_value;
   4066 
   4067     if (!PyArg_Parse(arg, "O&:minor", _Py_Dev_Converter, &device)) {
   4068         goto exit;
   4069     }
   4070     _return_value = os_minor_impl(module, device);
   4071     if ((_return_value == (unsigned int)-1) && PyErr_Occurred()) {
   4072         goto exit;
   4073     }
   4074     return_value = PyLong_FromUnsignedLong((unsigned long)_return_value);
   4075 
   4076 exit:
   4077     return return_value;
   4078 }
   4079 
   4080 #endif /* defined(HAVE_DEVICE_MACROS) */
   4081 
   4082 #if defined(HAVE_DEVICE_MACROS)
   4083 
   4084 PyDoc_STRVAR(os_makedev__doc__,
   4085 "makedev($module, major, minor, /)\n"
   4086 "--\n"
   4087 "\n"
   4088 "Composes a raw device number from the major and minor device numbers.");
   4089 
   4090 #define OS_MAKEDEV_METHODDEF    \
   4091     {"makedev", (PyCFunction)os_makedev, METH_VARARGS, os_makedev__doc__},
   4092 
   4093 static dev_t
   4094 os_makedev_impl(PyObject *module, int major, int minor);
   4095 
   4096 static PyObject *
   4097 os_makedev(PyObject *module, PyObject *args)
   4098 {
   4099     PyObject *return_value = NULL;
   4100     int major;
   4101     int minor;
   4102     dev_t _return_value;
   4103 
   4104     if (!PyArg_ParseTuple(args, "ii:makedev",
   4105         &major, &minor)) {
   4106         goto exit;
   4107     }
   4108     _return_value = os_makedev_impl(module, major, minor);
   4109     if ((_return_value == (dev_t)-1) && PyErr_Occurred()) {
   4110         goto exit;
   4111     }
   4112     return_value = _PyLong_FromDev(_return_value);
   4113 
   4114 exit:
   4115     return return_value;
   4116 }
   4117 
   4118 #endif /* defined(HAVE_DEVICE_MACROS) */
   4119 
   4120 #if (defined HAVE_FTRUNCATE || defined MS_WINDOWS)
   4121 
   4122 PyDoc_STRVAR(os_ftruncate__doc__,
   4123 "ftruncate($module, fd, length, /)\n"
   4124 "--\n"
   4125 "\n"
   4126 "Truncate a file, specified by file descriptor, to a specific length.");
   4127 
   4128 #define OS_FTRUNCATE_METHODDEF    \
   4129     {"ftruncate", (PyCFunction)os_ftruncate, METH_VARARGS, os_ftruncate__doc__},
   4130 
   4131 static PyObject *
   4132 os_ftruncate_impl(PyObject *module, int fd, Py_off_t length);
   4133 
   4134 static PyObject *
   4135 os_ftruncate(PyObject *module, PyObject *args)
   4136 {
   4137     PyObject *return_value = NULL;
   4138     int fd;
   4139     Py_off_t length;
   4140 
   4141     if (!PyArg_ParseTuple(args, "iO&:ftruncate",
   4142         &fd, Py_off_t_converter, &length)) {
   4143         goto exit;
   4144     }
   4145     return_value = os_ftruncate_impl(module, fd, length);
   4146 
   4147 exit:
   4148     return return_value;
   4149 }
   4150 
   4151 #endif /* (defined HAVE_FTRUNCATE || defined MS_WINDOWS) */
   4152 
   4153 #if (defined HAVE_TRUNCATE || defined MS_WINDOWS)
   4154 
   4155 PyDoc_STRVAR(os_truncate__doc__,
   4156 "truncate($module, /, path, length)\n"
   4157 "--\n"
   4158 "\n"
   4159 "Truncate a file, specified by path, to a specific length.\n"
   4160 "\n"
   4161 "On some platforms, path may also be specified as an open file descriptor.\n"
   4162 "  If this functionality is unavailable, using it raises an exception.");
   4163 
   4164 #define OS_TRUNCATE_METHODDEF    \
   4165     {"truncate", (PyCFunction)os_truncate, METH_FASTCALL, os_truncate__doc__},
   4166 
   4167 static PyObject *
   4168 os_truncate_impl(PyObject *module, path_t *path, Py_off_t length);
   4169 
   4170 static PyObject *
   4171 os_truncate(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4172 {
   4173     PyObject *return_value = NULL;
   4174     static const char * const _keywords[] = {"path", "length", NULL};
   4175     static _PyArg_Parser _parser = {"O&O&:truncate", _keywords, 0};
   4176     path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE);
   4177     Py_off_t length;
   4178 
   4179     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4180         path_converter, &path, Py_off_t_converter, &length)) {
   4181         goto exit;
   4182     }
   4183     return_value = os_truncate_impl(module, &path, length);
   4184 
   4185 exit:
   4186     /* Cleanup for path */
   4187     path_cleanup(&path);
   4188 
   4189     return return_value;
   4190 }
   4191 
   4192 #endif /* (defined HAVE_TRUNCATE || defined MS_WINDOWS) */
   4193 
   4194 #if (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG))
   4195 
   4196 PyDoc_STRVAR(os_posix_fallocate__doc__,
   4197 "posix_fallocate($module, fd, offset, length, /)\n"
   4198 "--\n"
   4199 "\n"
   4200 "Ensure a file has allocated at least a particular number of bytes on disk.\n"
   4201 "\n"
   4202 "Ensure that the file specified by fd encompasses a range of bytes\n"
   4203 "starting at offset bytes from the beginning and continuing for length bytes.");
   4204 
   4205 #define OS_POSIX_FALLOCATE_METHODDEF    \
   4206     {"posix_fallocate", (PyCFunction)os_posix_fallocate, METH_VARARGS, os_posix_fallocate__doc__},
   4207 
   4208 static PyObject *
   4209 os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset,
   4210                         Py_off_t length);
   4211 
   4212 static PyObject *
   4213 os_posix_fallocate(PyObject *module, PyObject *args)
   4214 {
   4215     PyObject *return_value = NULL;
   4216     int fd;
   4217     Py_off_t offset;
   4218     Py_off_t length;
   4219 
   4220     if (!PyArg_ParseTuple(args, "iO&O&:posix_fallocate",
   4221         &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length)) {
   4222         goto exit;
   4223     }
   4224     return_value = os_posix_fallocate_impl(module, fd, offset, length);
   4225 
   4226 exit:
   4227     return return_value;
   4228 }
   4229 
   4230 #endif /* (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG)) */
   4231 
   4232 #if (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG))
   4233 
   4234 PyDoc_STRVAR(os_posix_fadvise__doc__,
   4235 "posix_fadvise($module, fd, offset, length, advice, /)\n"
   4236 "--\n"
   4237 "\n"
   4238 "Announce an intention to access data in a specific pattern.\n"
   4239 "\n"
   4240 "Announce an intention to access data in a specific pattern, thus allowing\n"
   4241 "the kernel to make optimizations.\n"
   4242 "The advice applies to the region of the file specified by fd starting at\n"
   4243 "offset and continuing for length bytes.\n"
   4244 "advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,\n"
   4245 "POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or\n"
   4246 "POSIX_FADV_DONTNEED.");
   4247 
   4248 #define OS_POSIX_FADVISE_METHODDEF    \
   4249     {"posix_fadvise", (PyCFunction)os_posix_fadvise, METH_VARARGS, os_posix_fadvise__doc__},
   4250 
   4251 static PyObject *
   4252 os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset,
   4253                       Py_off_t length, int advice);
   4254 
   4255 static PyObject *
   4256 os_posix_fadvise(PyObject *module, PyObject *args)
   4257 {
   4258     PyObject *return_value = NULL;
   4259     int fd;
   4260     Py_off_t offset;
   4261     Py_off_t length;
   4262     int advice;
   4263 
   4264     if (!PyArg_ParseTuple(args, "iO&O&i:posix_fadvise",
   4265         &fd, Py_off_t_converter, &offset, Py_off_t_converter, &length, &advice)) {
   4266         goto exit;
   4267     }
   4268     return_value = os_posix_fadvise_impl(module, fd, offset, length, advice);
   4269 
   4270 exit:
   4271     return return_value;
   4272 }
   4273 
   4274 #endif /* (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) */
   4275 
   4276 #if defined(HAVE_PUTENV) && defined(MS_WINDOWS)
   4277 
   4278 PyDoc_STRVAR(os_putenv__doc__,
   4279 "putenv($module, name, value, /)\n"
   4280 "--\n"
   4281 "\n"
   4282 "Change or add an environment variable.");
   4283 
   4284 #define OS_PUTENV_METHODDEF    \
   4285     {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__},
   4286 
   4287 static PyObject *
   4288 os_putenv_impl(PyObject *module, PyObject *name, PyObject *value);
   4289 
   4290 static PyObject *
   4291 os_putenv(PyObject *module, PyObject *args)
   4292 {
   4293     PyObject *return_value = NULL;
   4294     PyObject *name;
   4295     PyObject *value;
   4296 
   4297     if (!PyArg_ParseTuple(args, "UU:putenv",
   4298         &name, &value)) {
   4299         goto exit;
   4300     }
   4301     return_value = os_putenv_impl(module, name, value);
   4302 
   4303 exit:
   4304     return return_value;
   4305 }
   4306 
   4307 #endif /* defined(HAVE_PUTENV) && defined(MS_WINDOWS) */
   4308 
   4309 #if defined(HAVE_PUTENV) && !defined(MS_WINDOWS)
   4310 
   4311 PyDoc_STRVAR(os_putenv__doc__,
   4312 "putenv($module, name, value, /)\n"
   4313 "--\n"
   4314 "\n"
   4315 "Change or add an environment variable.");
   4316 
   4317 #define OS_PUTENV_METHODDEF    \
   4318     {"putenv", (PyCFunction)os_putenv, METH_VARARGS, os_putenv__doc__},
   4319 
   4320 static PyObject *
   4321 os_putenv_impl(PyObject *module, PyObject *name, PyObject *value);
   4322 
   4323 static PyObject *
   4324 os_putenv(PyObject *module, PyObject *args)
   4325 {
   4326     PyObject *return_value = NULL;
   4327     PyObject *name = NULL;
   4328     PyObject *value = NULL;
   4329 
   4330     if (!PyArg_ParseTuple(args, "O&O&:putenv",
   4331         PyUnicode_FSConverter, &name, PyUnicode_FSConverter, &value)) {
   4332         goto exit;
   4333     }
   4334     return_value = os_putenv_impl(module, name, value);
   4335 
   4336 exit:
   4337     /* Cleanup for name */
   4338     Py_XDECREF(name);
   4339     /* Cleanup for value */
   4340     Py_XDECREF(value);
   4341 
   4342     return return_value;
   4343 }
   4344 
   4345 #endif /* defined(HAVE_PUTENV) && !defined(MS_WINDOWS) */
   4346 
   4347 #if defined(HAVE_UNSETENV)
   4348 
   4349 PyDoc_STRVAR(os_unsetenv__doc__,
   4350 "unsetenv($module, name, /)\n"
   4351 "--\n"
   4352 "\n"
   4353 "Delete an environment variable.");
   4354 
   4355 #define OS_UNSETENV_METHODDEF    \
   4356     {"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__},
   4357 
   4358 static PyObject *
   4359 os_unsetenv_impl(PyObject *module, PyObject *name);
   4360 
   4361 static PyObject *
   4362 os_unsetenv(PyObject *module, PyObject *arg)
   4363 {
   4364     PyObject *return_value = NULL;
   4365     PyObject *name = NULL;
   4366 
   4367     if (!PyArg_Parse(arg, "O&:unsetenv", PyUnicode_FSConverter, &name)) {
   4368         goto exit;
   4369     }
   4370     return_value = os_unsetenv_impl(module, name);
   4371 
   4372 exit:
   4373     /* Cleanup for name */
   4374     Py_XDECREF(name);
   4375 
   4376     return return_value;
   4377 }
   4378 
   4379 #endif /* defined(HAVE_UNSETENV) */
   4380 
   4381 PyDoc_STRVAR(os_strerror__doc__,
   4382 "strerror($module, code, /)\n"
   4383 "--\n"
   4384 "\n"
   4385 "Translate an error code to a message string.");
   4386 
   4387 #define OS_STRERROR_METHODDEF    \
   4388     {"strerror", (PyCFunction)os_strerror, METH_O, os_strerror__doc__},
   4389 
   4390 static PyObject *
   4391 os_strerror_impl(PyObject *module, int code);
   4392 
   4393 static PyObject *
   4394 os_strerror(PyObject *module, PyObject *arg)
   4395 {
   4396     PyObject *return_value = NULL;
   4397     int code;
   4398 
   4399     if (!PyArg_Parse(arg, "i:strerror", &code)) {
   4400         goto exit;
   4401     }
   4402     return_value = os_strerror_impl(module, code);
   4403 
   4404 exit:
   4405     return return_value;
   4406 }
   4407 
   4408 #if defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP)
   4409 
   4410 PyDoc_STRVAR(os_WCOREDUMP__doc__,
   4411 "WCOREDUMP($module, status, /)\n"
   4412 "--\n"
   4413 "\n"
   4414 "Return True if the process returning status was dumped to a core file.");
   4415 
   4416 #define OS_WCOREDUMP_METHODDEF    \
   4417     {"WCOREDUMP", (PyCFunction)os_WCOREDUMP, METH_O, os_WCOREDUMP__doc__},
   4418 
   4419 static int
   4420 os_WCOREDUMP_impl(PyObject *module, int status);
   4421 
   4422 static PyObject *
   4423 os_WCOREDUMP(PyObject *module, PyObject *arg)
   4424 {
   4425     PyObject *return_value = NULL;
   4426     int status;
   4427     int _return_value;
   4428 
   4429     if (!PyArg_Parse(arg, "i:WCOREDUMP", &status)) {
   4430         goto exit;
   4431     }
   4432     _return_value = os_WCOREDUMP_impl(module, status);
   4433     if ((_return_value == -1) && PyErr_Occurred()) {
   4434         goto exit;
   4435     }
   4436     return_value = PyBool_FromLong((long)_return_value);
   4437 
   4438 exit:
   4439     return return_value;
   4440 }
   4441 
   4442 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) */
   4443 
   4444 #if defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED)
   4445 
   4446 PyDoc_STRVAR(os_WIFCONTINUED__doc__,
   4447 "WIFCONTINUED($module, /, status)\n"
   4448 "--\n"
   4449 "\n"
   4450 "Return True if a particular process was continued from a job control stop.\n"
   4451 "\n"
   4452 "Return True if the process returning status was continued from a\n"
   4453 "job control stop.");
   4454 
   4455 #define OS_WIFCONTINUED_METHODDEF    \
   4456     {"WIFCONTINUED", (PyCFunction)os_WIFCONTINUED, METH_FASTCALL, os_WIFCONTINUED__doc__},
   4457 
   4458 static int
   4459 os_WIFCONTINUED_impl(PyObject *module, int status);
   4460 
   4461 static PyObject *
   4462 os_WIFCONTINUED(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4463 {
   4464     PyObject *return_value = NULL;
   4465     static const char * const _keywords[] = {"status", NULL};
   4466     static _PyArg_Parser _parser = {"i:WIFCONTINUED", _keywords, 0};
   4467     int status;
   4468     int _return_value;
   4469 
   4470     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4471         &status)) {
   4472         goto exit;
   4473     }
   4474     _return_value = os_WIFCONTINUED_impl(module, status);
   4475     if ((_return_value == -1) && PyErr_Occurred()) {
   4476         goto exit;
   4477     }
   4478     return_value = PyBool_FromLong((long)_return_value);
   4479 
   4480 exit:
   4481     return return_value;
   4482 }
   4483 
   4484 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) */
   4485 
   4486 #if defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED)
   4487 
   4488 PyDoc_STRVAR(os_WIFSTOPPED__doc__,
   4489 "WIFSTOPPED($module, /, status)\n"
   4490 "--\n"
   4491 "\n"
   4492 "Return True if the process returning status was stopped.");
   4493 
   4494 #define OS_WIFSTOPPED_METHODDEF    \
   4495     {"WIFSTOPPED", (PyCFunction)os_WIFSTOPPED, METH_FASTCALL, os_WIFSTOPPED__doc__},
   4496 
   4497 static int
   4498 os_WIFSTOPPED_impl(PyObject *module, int status);
   4499 
   4500 static PyObject *
   4501 os_WIFSTOPPED(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4502 {
   4503     PyObject *return_value = NULL;
   4504     static const char * const _keywords[] = {"status", NULL};
   4505     static _PyArg_Parser _parser = {"i:WIFSTOPPED", _keywords, 0};
   4506     int status;
   4507     int _return_value;
   4508 
   4509     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4510         &status)) {
   4511         goto exit;
   4512     }
   4513     _return_value = os_WIFSTOPPED_impl(module, status);
   4514     if ((_return_value == -1) && PyErr_Occurred()) {
   4515         goto exit;
   4516     }
   4517     return_value = PyBool_FromLong((long)_return_value);
   4518 
   4519 exit:
   4520     return return_value;
   4521 }
   4522 
   4523 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) */
   4524 
   4525 #if defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED)
   4526 
   4527 PyDoc_STRVAR(os_WIFSIGNALED__doc__,
   4528 "WIFSIGNALED($module, /, status)\n"
   4529 "--\n"
   4530 "\n"
   4531 "Return True if the process returning status was terminated by a signal.");
   4532 
   4533 #define OS_WIFSIGNALED_METHODDEF    \
   4534     {"WIFSIGNALED", (PyCFunction)os_WIFSIGNALED, METH_FASTCALL, os_WIFSIGNALED__doc__},
   4535 
   4536 static int
   4537 os_WIFSIGNALED_impl(PyObject *module, int status);
   4538 
   4539 static PyObject *
   4540 os_WIFSIGNALED(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4541 {
   4542     PyObject *return_value = NULL;
   4543     static const char * const _keywords[] = {"status", NULL};
   4544     static _PyArg_Parser _parser = {"i:WIFSIGNALED", _keywords, 0};
   4545     int status;
   4546     int _return_value;
   4547 
   4548     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4549         &status)) {
   4550         goto exit;
   4551     }
   4552     _return_value = os_WIFSIGNALED_impl(module, status);
   4553     if ((_return_value == -1) && PyErr_Occurred()) {
   4554         goto exit;
   4555     }
   4556     return_value = PyBool_FromLong((long)_return_value);
   4557 
   4558 exit:
   4559     return return_value;
   4560 }
   4561 
   4562 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) */
   4563 
   4564 #if defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED)
   4565 
   4566 PyDoc_STRVAR(os_WIFEXITED__doc__,
   4567 "WIFEXITED($module, /, status)\n"
   4568 "--\n"
   4569 "\n"
   4570 "Return True if the process returning status exited via the exit() system call.");
   4571 
   4572 #define OS_WIFEXITED_METHODDEF    \
   4573     {"WIFEXITED", (PyCFunction)os_WIFEXITED, METH_FASTCALL, os_WIFEXITED__doc__},
   4574 
   4575 static int
   4576 os_WIFEXITED_impl(PyObject *module, int status);
   4577 
   4578 static PyObject *
   4579 os_WIFEXITED(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4580 {
   4581     PyObject *return_value = NULL;
   4582     static const char * const _keywords[] = {"status", NULL};
   4583     static _PyArg_Parser _parser = {"i:WIFEXITED", _keywords, 0};
   4584     int status;
   4585     int _return_value;
   4586 
   4587     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4588         &status)) {
   4589         goto exit;
   4590     }
   4591     _return_value = os_WIFEXITED_impl(module, status);
   4592     if ((_return_value == -1) && PyErr_Occurred()) {
   4593         goto exit;
   4594     }
   4595     return_value = PyBool_FromLong((long)_return_value);
   4596 
   4597 exit:
   4598     return return_value;
   4599 }
   4600 
   4601 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) */
   4602 
   4603 #if defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS)
   4604 
   4605 PyDoc_STRVAR(os_WEXITSTATUS__doc__,
   4606 "WEXITSTATUS($module, /, status)\n"
   4607 "--\n"
   4608 "\n"
   4609 "Return the process return code from status.");
   4610 
   4611 #define OS_WEXITSTATUS_METHODDEF    \
   4612     {"WEXITSTATUS", (PyCFunction)os_WEXITSTATUS, METH_FASTCALL, os_WEXITSTATUS__doc__},
   4613 
   4614 static int
   4615 os_WEXITSTATUS_impl(PyObject *module, int status);
   4616 
   4617 static PyObject *
   4618 os_WEXITSTATUS(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4619 {
   4620     PyObject *return_value = NULL;
   4621     static const char * const _keywords[] = {"status", NULL};
   4622     static _PyArg_Parser _parser = {"i:WEXITSTATUS", _keywords, 0};
   4623     int status;
   4624     int _return_value;
   4625 
   4626     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4627         &status)) {
   4628         goto exit;
   4629     }
   4630     _return_value = os_WEXITSTATUS_impl(module, status);
   4631     if ((_return_value == -1) && PyErr_Occurred()) {
   4632         goto exit;
   4633     }
   4634     return_value = PyLong_FromLong((long)_return_value);
   4635 
   4636 exit:
   4637     return return_value;
   4638 }
   4639 
   4640 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) */
   4641 
   4642 #if defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG)
   4643 
   4644 PyDoc_STRVAR(os_WTERMSIG__doc__,
   4645 "WTERMSIG($module, /, status)\n"
   4646 "--\n"
   4647 "\n"
   4648 "Return the signal that terminated the process that provided the status value.");
   4649 
   4650 #define OS_WTERMSIG_METHODDEF    \
   4651     {"WTERMSIG", (PyCFunction)os_WTERMSIG, METH_FASTCALL, os_WTERMSIG__doc__},
   4652 
   4653 static int
   4654 os_WTERMSIG_impl(PyObject *module, int status);
   4655 
   4656 static PyObject *
   4657 os_WTERMSIG(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4658 {
   4659     PyObject *return_value = NULL;
   4660     static const char * const _keywords[] = {"status", NULL};
   4661     static _PyArg_Parser _parser = {"i:WTERMSIG", _keywords, 0};
   4662     int status;
   4663     int _return_value;
   4664 
   4665     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4666         &status)) {
   4667         goto exit;
   4668     }
   4669     _return_value = os_WTERMSIG_impl(module, status);
   4670     if ((_return_value == -1) && PyErr_Occurred()) {
   4671         goto exit;
   4672     }
   4673     return_value = PyLong_FromLong((long)_return_value);
   4674 
   4675 exit:
   4676     return return_value;
   4677 }
   4678 
   4679 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) */
   4680 
   4681 #if defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG)
   4682 
   4683 PyDoc_STRVAR(os_WSTOPSIG__doc__,
   4684 "WSTOPSIG($module, /, status)\n"
   4685 "--\n"
   4686 "\n"
   4687 "Return the signal that stopped the process that provided the status value.");
   4688 
   4689 #define OS_WSTOPSIG_METHODDEF    \
   4690     {"WSTOPSIG", (PyCFunction)os_WSTOPSIG, METH_FASTCALL, os_WSTOPSIG__doc__},
   4691 
   4692 static int
   4693 os_WSTOPSIG_impl(PyObject *module, int status);
   4694 
   4695 static PyObject *
   4696 os_WSTOPSIG(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4697 {
   4698     PyObject *return_value = NULL;
   4699     static const char * const _keywords[] = {"status", NULL};
   4700     static _PyArg_Parser _parser = {"i:WSTOPSIG", _keywords, 0};
   4701     int status;
   4702     int _return_value;
   4703 
   4704     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4705         &status)) {
   4706         goto exit;
   4707     }
   4708     _return_value = os_WSTOPSIG_impl(module, status);
   4709     if ((_return_value == -1) && PyErr_Occurred()) {
   4710         goto exit;
   4711     }
   4712     return_value = PyLong_FromLong((long)_return_value);
   4713 
   4714 exit:
   4715     return return_value;
   4716 }
   4717 
   4718 #endif /* defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) */
   4719 
   4720 #if (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H))
   4721 
   4722 PyDoc_STRVAR(os_fstatvfs__doc__,
   4723 "fstatvfs($module, fd, /)\n"
   4724 "--\n"
   4725 "\n"
   4726 "Perform an fstatvfs system call on the given fd.\n"
   4727 "\n"
   4728 "Equivalent to statvfs(fd).");
   4729 
   4730 #define OS_FSTATVFS_METHODDEF    \
   4731     {"fstatvfs", (PyCFunction)os_fstatvfs, METH_O, os_fstatvfs__doc__},
   4732 
   4733 static PyObject *
   4734 os_fstatvfs_impl(PyObject *module, int fd);
   4735 
   4736 static PyObject *
   4737 os_fstatvfs(PyObject *module, PyObject *arg)
   4738 {
   4739     PyObject *return_value = NULL;
   4740     int fd;
   4741 
   4742     if (!PyArg_Parse(arg, "i:fstatvfs", &fd)) {
   4743         goto exit;
   4744     }
   4745     return_value = os_fstatvfs_impl(module, fd);
   4746 
   4747 exit:
   4748     return return_value;
   4749 }
   4750 
   4751 #endif /* (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) */
   4752 
   4753 #if (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H))
   4754 
   4755 PyDoc_STRVAR(os_statvfs__doc__,
   4756 "statvfs($module, /, path)\n"
   4757 "--\n"
   4758 "\n"
   4759 "Perform a statvfs system call on the given path.\n"
   4760 "\n"
   4761 "path may always be specified as a string.\n"
   4762 "On some platforms, path may also be specified as an open file descriptor.\n"
   4763 "  If this functionality is unavailable, using it raises an exception.");
   4764 
   4765 #define OS_STATVFS_METHODDEF    \
   4766     {"statvfs", (PyCFunction)os_statvfs, METH_FASTCALL, os_statvfs__doc__},
   4767 
   4768 static PyObject *
   4769 os_statvfs_impl(PyObject *module, path_t *path);
   4770 
   4771 static PyObject *
   4772 os_statvfs(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4773 {
   4774     PyObject *return_value = NULL;
   4775     static const char * const _keywords[] = {"path", NULL};
   4776     static _PyArg_Parser _parser = {"O&:statvfs", _keywords, 0};
   4777     path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS);
   4778 
   4779     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4780         path_converter, &path)) {
   4781         goto exit;
   4782     }
   4783     return_value = os_statvfs_impl(module, &path);
   4784 
   4785 exit:
   4786     /* Cleanup for path */
   4787     path_cleanup(&path);
   4788 
   4789     return return_value;
   4790 }
   4791 
   4792 #endif /* (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) */
   4793 
   4794 #if defined(MS_WINDOWS)
   4795 
   4796 PyDoc_STRVAR(os__getdiskusage__doc__,
   4797 "_getdiskusage($module, /, path)\n"
   4798 "--\n"
   4799 "\n"
   4800 "Return disk usage statistics about the given path as a (total, free) tuple.");
   4801 
   4802 #define OS__GETDISKUSAGE_METHODDEF    \
   4803     {"_getdiskusage", (PyCFunction)os__getdiskusage, METH_FASTCALL, os__getdiskusage__doc__},
   4804 
   4805 static PyObject *
   4806 os__getdiskusage_impl(PyObject *module, Py_UNICODE *path);
   4807 
   4808 static PyObject *
   4809 os__getdiskusage(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4810 {
   4811     PyObject *return_value = NULL;
   4812     static const char * const _keywords[] = {"path", NULL};
   4813     static _PyArg_Parser _parser = {"u:_getdiskusage", _keywords, 0};
   4814     Py_UNICODE *path;
   4815 
   4816     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4817         &path)) {
   4818         goto exit;
   4819     }
   4820     return_value = os__getdiskusage_impl(module, path);
   4821 
   4822 exit:
   4823     return return_value;
   4824 }
   4825 
   4826 #endif /* defined(MS_WINDOWS) */
   4827 
   4828 #if defined(HAVE_FPATHCONF)
   4829 
   4830 PyDoc_STRVAR(os_fpathconf__doc__,
   4831 "fpathconf($module, fd, name, /)\n"
   4832 "--\n"
   4833 "\n"
   4834 "Return the configuration limit name for the file descriptor fd.\n"
   4835 "\n"
   4836 "If there is no limit, return -1.");
   4837 
   4838 #define OS_FPATHCONF_METHODDEF    \
   4839     {"fpathconf", (PyCFunction)os_fpathconf, METH_VARARGS, os_fpathconf__doc__},
   4840 
   4841 static long
   4842 os_fpathconf_impl(PyObject *module, int fd, int name);
   4843 
   4844 static PyObject *
   4845 os_fpathconf(PyObject *module, PyObject *args)
   4846 {
   4847     PyObject *return_value = NULL;
   4848     int fd;
   4849     int name;
   4850     long _return_value;
   4851 
   4852     if (!PyArg_ParseTuple(args, "iO&:fpathconf",
   4853         &fd, conv_path_confname, &name)) {
   4854         goto exit;
   4855     }
   4856     _return_value = os_fpathconf_impl(module, fd, name);
   4857     if ((_return_value == -1) && PyErr_Occurred()) {
   4858         goto exit;
   4859     }
   4860     return_value = PyLong_FromLong(_return_value);
   4861 
   4862 exit:
   4863     return return_value;
   4864 }
   4865 
   4866 #endif /* defined(HAVE_FPATHCONF) */
   4867 
   4868 #if defined(HAVE_PATHCONF)
   4869 
   4870 PyDoc_STRVAR(os_pathconf__doc__,
   4871 "pathconf($module, /, path, name)\n"
   4872 "--\n"
   4873 "\n"
   4874 "Return the configuration limit name for the file or directory path.\n"
   4875 "\n"
   4876 "If there is no limit, return -1.\n"
   4877 "On some platforms, path may also be specified as an open file descriptor.\n"
   4878 "  If this functionality is unavailable, using it raises an exception.");
   4879 
   4880 #define OS_PATHCONF_METHODDEF    \
   4881     {"pathconf", (PyCFunction)os_pathconf, METH_FASTCALL, os_pathconf__doc__},
   4882 
   4883 static long
   4884 os_pathconf_impl(PyObject *module, path_t *path, int name);
   4885 
   4886 static PyObject *
   4887 os_pathconf(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   4888 {
   4889     PyObject *return_value = NULL;
   4890     static const char * const _keywords[] = {"path", "name", NULL};
   4891     static _PyArg_Parser _parser = {"O&O&:pathconf", _keywords, 0};
   4892     path_t path = PATH_T_INITIALIZE("pathconf", "path", 0, PATH_HAVE_FPATHCONF);
   4893     int name;
   4894     long _return_value;
   4895 
   4896     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   4897         path_converter, &path, conv_path_confname, &name)) {
   4898         goto exit;
   4899     }
   4900     _return_value = os_pathconf_impl(module, &path, name);
   4901     if ((_return_value == -1) && PyErr_Occurred()) {
   4902         goto exit;
   4903     }
   4904     return_value = PyLong_FromLong(_return_value);
   4905 
   4906 exit:
   4907     /* Cleanup for path */
   4908     path_cleanup(&path);
   4909 
   4910     return return_value;
   4911 }
   4912 
   4913 #endif /* defined(HAVE_PATHCONF) */
   4914 
   4915 #if defined(HAVE_CONFSTR)
   4916 
   4917 PyDoc_STRVAR(os_confstr__doc__,
   4918 "confstr($module, name, /)\n"
   4919 "--\n"
   4920 "\n"
   4921 "Return a string-valued system configuration variable.");
   4922 
   4923 #define OS_CONFSTR_METHODDEF    \
   4924     {"confstr", (PyCFunction)os_confstr, METH_O, os_confstr__doc__},
   4925 
   4926 static PyObject *
   4927 os_confstr_impl(PyObject *module, int name);
   4928 
   4929 static PyObject *
   4930 os_confstr(PyObject *module, PyObject *arg)
   4931 {
   4932     PyObject *return_value = NULL;
   4933     int name;
   4934 
   4935     if (!PyArg_Parse(arg, "O&:confstr", conv_confstr_confname, &name)) {
   4936         goto exit;
   4937     }
   4938     return_value = os_confstr_impl(module, name);
   4939 
   4940 exit:
   4941     return return_value;
   4942 }
   4943 
   4944 #endif /* defined(HAVE_CONFSTR) */
   4945 
   4946 #if defined(HAVE_SYSCONF)
   4947 
   4948 PyDoc_STRVAR(os_sysconf__doc__,
   4949 "sysconf($module, name, /)\n"
   4950 "--\n"
   4951 "\n"
   4952 "Return an integer-valued system configuration variable.");
   4953 
   4954 #define OS_SYSCONF_METHODDEF    \
   4955     {"sysconf", (PyCFunction)os_sysconf, METH_O, os_sysconf__doc__},
   4956 
   4957 static long
   4958 os_sysconf_impl(PyObject *module, int name);
   4959 
   4960 static PyObject *
   4961 os_sysconf(PyObject *module, PyObject *arg)
   4962 {
   4963     PyObject *return_value = NULL;
   4964     int name;
   4965     long _return_value;
   4966 
   4967     if (!PyArg_Parse(arg, "O&:sysconf", conv_sysconf_confname, &name)) {
   4968         goto exit;
   4969     }
   4970     _return_value = os_sysconf_impl(module, name);
   4971     if ((_return_value == -1) && PyErr_Occurred()) {
   4972         goto exit;
   4973     }
   4974     return_value = PyLong_FromLong(_return_value);
   4975 
   4976 exit:
   4977     return return_value;
   4978 }
   4979 
   4980 #endif /* defined(HAVE_SYSCONF) */
   4981 
   4982 PyDoc_STRVAR(os_abort__doc__,
   4983 "abort($module, /)\n"
   4984 "--\n"
   4985 "\n"
   4986 "Abort the interpreter immediately.\n"
   4987 "\n"
   4988 "This function \'dumps core\' or otherwise fails in the hardest way possible\n"
   4989 "on the hosting operating system.  This function never returns.");
   4990 
   4991 #define OS_ABORT_METHODDEF    \
   4992     {"abort", (PyCFunction)os_abort, METH_NOARGS, os_abort__doc__},
   4993 
   4994 static PyObject *
   4995 os_abort_impl(PyObject *module);
   4996 
   4997 static PyObject *
   4998 os_abort(PyObject *module, PyObject *Py_UNUSED(ignored))
   4999 {
   5000     return os_abort_impl(module);
   5001 }
   5002 
   5003 #if defined(MS_WINDOWS)
   5004 
   5005 PyDoc_STRVAR(os_startfile__doc__,
   5006 "startfile($module, /, filepath, operation=None)\n"
   5007 "--\n"
   5008 "\n"
   5009 "startfile(filepath [, operation])\n"
   5010 "\n"
   5011 "Start a file with its associated application.\n"
   5012 "\n"
   5013 "When \"operation\" is not specified or \"open\", this acts like\n"
   5014 "double-clicking the file in Explorer, or giving the file name as an\n"
   5015 "argument to the DOS \"start\" command: the file is opened with whatever\n"
   5016 "application (if any) its extension is associated.\n"
   5017 "When another \"operation\" is given, it specifies what should be done with\n"
   5018 "the file.  A typical operation is \"print\".\n"
   5019 "\n"
   5020 "startfile returns as soon as the associated application is launched.\n"
   5021 "There is no option to wait for the application to close, and no way\n"
   5022 "to retrieve the application\'s exit status.\n"
   5023 "\n"
   5024 "The filepath is relative to the current directory.  If you want to use\n"
   5025 "an absolute path, make sure the first character is not a slash (\"/\");\n"
   5026 "the underlying Win32 ShellExecute function doesn\'t work if it is.");
   5027 
   5028 #define OS_STARTFILE_METHODDEF    \
   5029     {"startfile", (PyCFunction)os_startfile, METH_FASTCALL, os_startfile__doc__},
   5030 
   5031 static PyObject *
   5032 os_startfile_impl(PyObject *module, path_t *filepath, Py_UNICODE *operation);
   5033 
   5034 static PyObject *
   5035 os_startfile(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5036 {
   5037     PyObject *return_value = NULL;
   5038     static const char * const _keywords[] = {"filepath", "operation", NULL};
   5039     static _PyArg_Parser _parser = {"O&|u:startfile", _keywords, 0};
   5040     path_t filepath = PATH_T_INITIALIZE("startfile", "filepath", 0, 0);
   5041     Py_UNICODE *operation = NULL;
   5042 
   5043     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5044         path_converter, &filepath, &operation)) {
   5045         goto exit;
   5046     }
   5047     return_value = os_startfile_impl(module, &filepath, operation);
   5048 
   5049 exit:
   5050     /* Cleanup for filepath */
   5051     path_cleanup(&filepath);
   5052 
   5053     return return_value;
   5054 }
   5055 
   5056 #endif /* defined(MS_WINDOWS) */
   5057 
   5058 #if defined(HAVE_GETLOADAVG)
   5059 
   5060 PyDoc_STRVAR(os_getloadavg__doc__,
   5061 "getloadavg($module, /)\n"
   5062 "--\n"
   5063 "\n"
   5064 "Return average recent system load information.\n"
   5065 "\n"
   5066 "Return the number of processes in the system run queue averaged over\n"
   5067 "the last 1, 5, and 15 minutes as a tuple of three floats.\n"
   5068 "Raises OSError if the load average was unobtainable.");
   5069 
   5070 #define OS_GETLOADAVG_METHODDEF    \
   5071     {"getloadavg", (PyCFunction)os_getloadavg, METH_NOARGS, os_getloadavg__doc__},
   5072 
   5073 static PyObject *
   5074 os_getloadavg_impl(PyObject *module);
   5075 
   5076 static PyObject *
   5077 os_getloadavg(PyObject *module, PyObject *Py_UNUSED(ignored))
   5078 {
   5079     return os_getloadavg_impl(module);
   5080 }
   5081 
   5082 #endif /* defined(HAVE_GETLOADAVG) */
   5083 
   5084 PyDoc_STRVAR(os_device_encoding__doc__,
   5085 "device_encoding($module, /, fd)\n"
   5086 "--\n"
   5087 "\n"
   5088 "Return a string describing the encoding of a terminal\'s file descriptor.\n"
   5089 "\n"
   5090 "The file descriptor must be attached to a terminal.\n"
   5091 "If the device is not a terminal, return None.");
   5092 
   5093 #define OS_DEVICE_ENCODING_METHODDEF    \
   5094     {"device_encoding", (PyCFunction)os_device_encoding, METH_FASTCALL, os_device_encoding__doc__},
   5095 
   5096 static PyObject *
   5097 os_device_encoding_impl(PyObject *module, int fd);
   5098 
   5099 static PyObject *
   5100 os_device_encoding(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5101 {
   5102     PyObject *return_value = NULL;
   5103     static const char * const _keywords[] = {"fd", NULL};
   5104     static _PyArg_Parser _parser = {"i:device_encoding", _keywords, 0};
   5105     int fd;
   5106 
   5107     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5108         &fd)) {
   5109         goto exit;
   5110     }
   5111     return_value = os_device_encoding_impl(module, fd);
   5112 
   5113 exit:
   5114     return return_value;
   5115 }
   5116 
   5117 #if defined(HAVE_SETRESUID)
   5118 
   5119 PyDoc_STRVAR(os_setresuid__doc__,
   5120 "setresuid($module, ruid, euid, suid, /)\n"
   5121 "--\n"
   5122 "\n"
   5123 "Set the current process\'s real, effective, and saved user ids.");
   5124 
   5125 #define OS_SETRESUID_METHODDEF    \
   5126     {"setresuid", (PyCFunction)os_setresuid, METH_VARARGS, os_setresuid__doc__},
   5127 
   5128 static PyObject *
   5129 os_setresuid_impl(PyObject *module, uid_t ruid, uid_t euid, uid_t suid);
   5130 
   5131 static PyObject *
   5132 os_setresuid(PyObject *module, PyObject *args)
   5133 {
   5134     PyObject *return_value = NULL;
   5135     uid_t ruid;
   5136     uid_t euid;
   5137     uid_t suid;
   5138 
   5139     if (!PyArg_ParseTuple(args, "O&O&O&:setresuid",
   5140         _Py_Uid_Converter, &ruid, _Py_Uid_Converter, &euid, _Py_Uid_Converter, &suid)) {
   5141         goto exit;
   5142     }
   5143     return_value = os_setresuid_impl(module, ruid, euid, suid);
   5144 
   5145 exit:
   5146     return return_value;
   5147 }
   5148 
   5149 #endif /* defined(HAVE_SETRESUID) */
   5150 
   5151 #if defined(HAVE_SETRESGID)
   5152 
   5153 PyDoc_STRVAR(os_setresgid__doc__,
   5154 "setresgid($module, rgid, egid, sgid, /)\n"
   5155 "--\n"
   5156 "\n"
   5157 "Set the current process\'s real, effective, and saved group ids.");
   5158 
   5159 #define OS_SETRESGID_METHODDEF    \
   5160     {"setresgid", (PyCFunction)os_setresgid, METH_VARARGS, os_setresgid__doc__},
   5161 
   5162 static PyObject *
   5163 os_setresgid_impl(PyObject *module, gid_t rgid, gid_t egid, gid_t sgid);
   5164 
   5165 static PyObject *
   5166 os_setresgid(PyObject *module, PyObject *args)
   5167 {
   5168     PyObject *return_value = NULL;
   5169     gid_t rgid;
   5170     gid_t egid;
   5171     gid_t sgid;
   5172 
   5173     if (!PyArg_ParseTuple(args, "O&O&O&:setresgid",
   5174         _Py_Gid_Converter, &rgid, _Py_Gid_Converter, &egid, _Py_Gid_Converter, &sgid)) {
   5175         goto exit;
   5176     }
   5177     return_value = os_setresgid_impl(module, rgid, egid, sgid);
   5178 
   5179 exit:
   5180     return return_value;
   5181 }
   5182 
   5183 #endif /* defined(HAVE_SETRESGID) */
   5184 
   5185 #if defined(HAVE_GETRESUID)
   5186 
   5187 PyDoc_STRVAR(os_getresuid__doc__,
   5188 "getresuid($module, /)\n"
   5189 "--\n"
   5190 "\n"
   5191 "Return a tuple of the current process\'s real, effective, and saved user ids.");
   5192 
   5193 #define OS_GETRESUID_METHODDEF    \
   5194     {"getresuid", (PyCFunction)os_getresuid, METH_NOARGS, os_getresuid__doc__},
   5195 
   5196 static PyObject *
   5197 os_getresuid_impl(PyObject *module);
   5198 
   5199 static PyObject *
   5200 os_getresuid(PyObject *module, PyObject *Py_UNUSED(ignored))
   5201 {
   5202     return os_getresuid_impl(module);
   5203 }
   5204 
   5205 #endif /* defined(HAVE_GETRESUID) */
   5206 
   5207 #if defined(HAVE_GETRESGID)
   5208 
   5209 PyDoc_STRVAR(os_getresgid__doc__,
   5210 "getresgid($module, /)\n"
   5211 "--\n"
   5212 "\n"
   5213 "Return a tuple of the current process\'s real, effective, and saved group ids.");
   5214 
   5215 #define OS_GETRESGID_METHODDEF    \
   5216     {"getresgid", (PyCFunction)os_getresgid, METH_NOARGS, os_getresgid__doc__},
   5217 
   5218 static PyObject *
   5219 os_getresgid_impl(PyObject *module);
   5220 
   5221 static PyObject *
   5222 os_getresgid(PyObject *module, PyObject *Py_UNUSED(ignored))
   5223 {
   5224     return os_getresgid_impl(module);
   5225 }
   5226 
   5227 #endif /* defined(HAVE_GETRESGID) */
   5228 
   5229 #if defined(USE_XATTRS)
   5230 
   5231 PyDoc_STRVAR(os_getxattr__doc__,
   5232 "getxattr($module, /, path, attribute, *, follow_symlinks=True)\n"
   5233 "--\n"
   5234 "\n"
   5235 "Return the value of extended attribute attribute on path.\n"
   5236 "\n"
   5237 "path may be either a string or an open file descriptor.\n"
   5238 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
   5239 "  link, getxattr will examine the symbolic link itself instead of the file\n"
   5240 "  the link points to.");
   5241 
   5242 #define OS_GETXATTR_METHODDEF    \
   5243     {"getxattr", (PyCFunction)os_getxattr, METH_FASTCALL, os_getxattr__doc__},
   5244 
   5245 static PyObject *
   5246 os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute,
   5247                  int follow_symlinks);
   5248 
   5249 static PyObject *
   5250 os_getxattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5251 {
   5252     PyObject *return_value = NULL;
   5253     static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL};
   5254     static _PyArg_Parser _parser = {"O&O&|$p:getxattr", _keywords, 0};
   5255     path_t path = PATH_T_INITIALIZE("getxattr", "path", 0, 1);
   5256     path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0);
   5257     int follow_symlinks = 1;
   5258 
   5259     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5260         path_converter, &path, path_converter, &attribute, &follow_symlinks)) {
   5261         goto exit;
   5262     }
   5263     return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks);
   5264 
   5265 exit:
   5266     /* Cleanup for path */
   5267     path_cleanup(&path);
   5268     /* Cleanup for attribute */
   5269     path_cleanup(&attribute);
   5270 
   5271     return return_value;
   5272 }
   5273 
   5274 #endif /* defined(USE_XATTRS) */
   5275 
   5276 #if defined(USE_XATTRS)
   5277 
   5278 PyDoc_STRVAR(os_setxattr__doc__,
   5279 "setxattr($module, /, path, attribute, value, flags=0, *,\n"
   5280 "         follow_symlinks=True)\n"
   5281 "--\n"
   5282 "\n"
   5283 "Set extended attribute attribute on path to value.\n"
   5284 "\n"
   5285 "path may be either a string or an open file descriptor.\n"
   5286 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
   5287 "  link, setxattr will modify the symbolic link itself instead of the file\n"
   5288 "  the link points to.");
   5289 
   5290 #define OS_SETXATTR_METHODDEF    \
   5291     {"setxattr", (PyCFunction)os_setxattr, METH_FASTCALL, os_setxattr__doc__},
   5292 
   5293 static PyObject *
   5294 os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute,
   5295                  Py_buffer *value, int flags, int follow_symlinks);
   5296 
   5297 static PyObject *
   5298 os_setxattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5299 {
   5300     PyObject *return_value = NULL;
   5301     static const char * const _keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL};
   5302     static _PyArg_Parser _parser = {"O&O&y*|i$p:setxattr", _keywords, 0};
   5303     path_t path = PATH_T_INITIALIZE("setxattr", "path", 0, 1);
   5304     path_t attribute = PATH_T_INITIALIZE("setxattr", "attribute", 0, 0);
   5305     Py_buffer value = {NULL, NULL};
   5306     int flags = 0;
   5307     int follow_symlinks = 1;
   5308 
   5309     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5310         path_converter, &path, path_converter, &attribute, &value, &flags, &follow_symlinks)) {
   5311         goto exit;
   5312     }
   5313     return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks);
   5314 
   5315 exit:
   5316     /* Cleanup for path */
   5317     path_cleanup(&path);
   5318     /* Cleanup for attribute */
   5319     path_cleanup(&attribute);
   5320     /* Cleanup for value */
   5321     if (value.obj) {
   5322        PyBuffer_Release(&value);
   5323     }
   5324 
   5325     return return_value;
   5326 }
   5327 
   5328 #endif /* defined(USE_XATTRS) */
   5329 
   5330 #if defined(USE_XATTRS)
   5331 
   5332 PyDoc_STRVAR(os_removexattr__doc__,
   5333 "removexattr($module, /, path, attribute, *, follow_symlinks=True)\n"
   5334 "--\n"
   5335 "\n"
   5336 "Remove extended attribute attribute on path.\n"
   5337 "\n"
   5338 "path may be either a string or an open file descriptor.\n"
   5339 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
   5340 "  link, removexattr will modify the symbolic link itself instead of the file\n"
   5341 "  the link points to.");
   5342 
   5343 #define OS_REMOVEXATTR_METHODDEF    \
   5344     {"removexattr", (PyCFunction)os_removexattr, METH_FASTCALL, os_removexattr__doc__},
   5345 
   5346 static PyObject *
   5347 os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute,
   5348                     int follow_symlinks);
   5349 
   5350 static PyObject *
   5351 os_removexattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5352 {
   5353     PyObject *return_value = NULL;
   5354     static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL};
   5355     static _PyArg_Parser _parser = {"O&O&|$p:removexattr", _keywords, 0};
   5356     path_t path = PATH_T_INITIALIZE("removexattr", "path", 0, 1);
   5357     path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0);
   5358     int follow_symlinks = 1;
   5359 
   5360     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5361         path_converter, &path, path_converter, &attribute, &follow_symlinks)) {
   5362         goto exit;
   5363     }
   5364     return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks);
   5365 
   5366 exit:
   5367     /* Cleanup for path */
   5368     path_cleanup(&path);
   5369     /* Cleanup for attribute */
   5370     path_cleanup(&attribute);
   5371 
   5372     return return_value;
   5373 }
   5374 
   5375 #endif /* defined(USE_XATTRS) */
   5376 
   5377 #if defined(USE_XATTRS)
   5378 
   5379 PyDoc_STRVAR(os_listxattr__doc__,
   5380 "listxattr($module, /, path=None, *, follow_symlinks=True)\n"
   5381 "--\n"
   5382 "\n"
   5383 "Return a list of extended attributes on path.\n"
   5384 "\n"
   5385 "path may be either None, a string, or an open file descriptor.\n"
   5386 "if path is None, listxattr will examine the current directory.\n"
   5387 "If follow_symlinks is False, and the last element of the path is a symbolic\n"
   5388 "  link, listxattr will examine the symbolic link itself instead of the file\n"
   5389 "  the link points to.");
   5390 
   5391 #define OS_LISTXATTR_METHODDEF    \
   5392     {"listxattr", (PyCFunction)os_listxattr, METH_FASTCALL, os_listxattr__doc__},
   5393 
   5394 static PyObject *
   5395 os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks);
   5396 
   5397 static PyObject *
   5398 os_listxattr(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5399 {
   5400     PyObject *return_value = NULL;
   5401     static const char * const _keywords[] = {"path", "follow_symlinks", NULL};
   5402     static _PyArg_Parser _parser = {"|O&$p:listxattr", _keywords, 0};
   5403     path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1);
   5404     int follow_symlinks = 1;
   5405 
   5406     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5407         path_converter, &path, &follow_symlinks)) {
   5408         goto exit;
   5409     }
   5410     return_value = os_listxattr_impl(module, &path, follow_symlinks);
   5411 
   5412 exit:
   5413     /* Cleanup for path */
   5414     path_cleanup(&path);
   5415 
   5416     return return_value;
   5417 }
   5418 
   5419 #endif /* defined(USE_XATTRS) */
   5420 
   5421 PyDoc_STRVAR(os_urandom__doc__,
   5422 "urandom($module, size, /)\n"
   5423 "--\n"
   5424 "\n"
   5425 "Return a bytes object containing random bytes suitable for cryptographic use.");
   5426 
   5427 #define OS_URANDOM_METHODDEF    \
   5428     {"urandom", (PyCFunction)os_urandom, METH_O, os_urandom__doc__},
   5429 
   5430 static PyObject *
   5431 os_urandom_impl(PyObject *module, Py_ssize_t size);
   5432 
   5433 static PyObject *
   5434 os_urandom(PyObject *module, PyObject *arg)
   5435 {
   5436     PyObject *return_value = NULL;
   5437     Py_ssize_t size;
   5438 
   5439     if (!PyArg_Parse(arg, "n:urandom", &size)) {
   5440         goto exit;
   5441     }
   5442     return_value = os_urandom_impl(module, size);
   5443 
   5444 exit:
   5445     return return_value;
   5446 }
   5447 
   5448 PyDoc_STRVAR(os_cpu_count__doc__,
   5449 "cpu_count($module, /)\n"
   5450 "--\n"
   5451 "\n"
   5452 "Return the number of CPUs in the system; return None if indeterminable.\n"
   5453 "\n"
   5454 "This number is not equivalent to the number of CPUs the current process can\n"
   5455 "use.  The number of usable CPUs can be obtained with\n"
   5456 "``len(os.sched_getaffinity(0))``");
   5457 
   5458 #define OS_CPU_COUNT_METHODDEF    \
   5459     {"cpu_count", (PyCFunction)os_cpu_count, METH_NOARGS, os_cpu_count__doc__},
   5460 
   5461 static PyObject *
   5462 os_cpu_count_impl(PyObject *module);
   5463 
   5464 static PyObject *
   5465 os_cpu_count(PyObject *module, PyObject *Py_UNUSED(ignored))
   5466 {
   5467     return os_cpu_count_impl(module);
   5468 }
   5469 
   5470 PyDoc_STRVAR(os_get_inheritable__doc__,
   5471 "get_inheritable($module, fd, /)\n"
   5472 "--\n"
   5473 "\n"
   5474 "Get the close-on-exe flag of the specified file descriptor.");
   5475 
   5476 #define OS_GET_INHERITABLE_METHODDEF    \
   5477     {"get_inheritable", (PyCFunction)os_get_inheritable, METH_O, os_get_inheritable__doc__},
   5478 
   5479 static int
   5480 os_get_inheritable_impl(PyObject *module, int fd);
   5481 
   5482 static PyObject *
   5483 os_get_inheritable(PyObject *module, PyObject *arg)
   5484 {
   5485     PyObject *return_value = NULL;
   5486     int fd;
   5487     int _return_value;
   5488 
   5489     if (!PyArg_Parse(arg, "i:get_inheritable", &fd)) {
   5490         goto exit;
   5491     }
   5492     _return_value = os_get_inheritable_impl(module, fd);
   5493     if ((_return_value == -1) && PyErr_Occurred()) {
   5494         goto exit;
   5495     }
   5496     return_value = PyBool_FromLong((long)_return_value);
   5497 
   5498 exit:
   5499     return return_value;
   5500 }
   5501 
   5502 PyDoc_STRVAR(os_set_inheritable__doc__,
   5503 "set_inheritable($module, fd, inheritable, /)\n"
   5504 "--\n"
   5505 "\n"
   5506 "Set the inheritable flag of the specified file descriptor.");
   5507 
   5508 #define OS_SET_INHERITABLE_METHODDEF    \
   5509     {"set_inheritable", (PyCFunction)os_set_inheritable, METH_VARARGS, os_set_inheritable__doc__},
   5510 
   5511 static PyObject *
   5512 os_set_inheritable_impl(PyObject *module, int fd, int inheritable);
   5513 
   5514 static PyObject *
   5515 os_set_inheritable(PyObject *module, PyObject *args)
   5516 {
   5517     PyObject *return_value = NULL;
   5518     int fd;
   5519     int inheritable;
   5520 
   5521     if (!PyArg_ParseTuple(args, "ii:set_inheritable",
   5522         &fd, &inheritable)) {
   5523         goto exit;
   5524     }
   5525     return_value = os_set_inheritable_impl(module, fd, inheritable);
   5526 
   5527 exit:
   5528     return return_value;
   5529 }
   5530 
   5531 #if defined(MS_WINDOWS)
   5532 
   5533 PyDoc_STRVAR(os_get_handle_inheritable__doc__,
   5534 "get_handle_inheritable($module, handle, /)\n"
   5535 "--\n"
   5536 "\n"
   5537 "Get the close-on-exe flag of the specified file descriptor.");
   5538 
   5539 #define OS_GET_HANDLE_INHERITABLE_METHODDEF    \
   5540     {"get_handle_inheritable", (PyCFunction)os_get_handle_inheritable, METH_O, os_get_handle_inheritable__doc__},
   5541 
   5542 static int
   5543 os_get_handle_inheritable_impl(PyObject *module, intptr_t handle);
   5544 
   5545 static PyObject *
   5546 os_get_handle_inheritable(PyObject *module, PyObject *arg)
   5547 {
   5548     PyObject *return_value = NULL;
   5549     intptr_t handle;
   5550     int _return_value;
   5551 
   5552     if (!PyArg_Parse(arg, "" _Py_PARSE_INTPTR ":get_handle_inheritable", &handle)) {
   5553         goto exit;
   5554     }
   5555     _return_value = os_get_handle_inheritable_impl(module, handle);
   5556     if ((_return_value == -1) && PyErr_Occurred()) {
   5557         goto exit;
   5558     }
   5559     return_value = PyBool_FromLong((long)_return_value);
   5560 
   5561 exit:
   5562     return return_value;
   5563 }
   5564 
   5565 #endif /* defined(MS_WINDOWS) */
   5566 
   5567 #if defined(MS_WINDOWS)
   5568 
   5569 PyDoc_STRVAR(os_set_handle_inheritable__doc__,
   5570 "set_handle_inheritable($module, handle, inheritable, /)\n"
   5571 "--\n"
   5572 "\n"
   5573 "Set the inheritable flag of the specified handle.");
   5574 
   5575 #define OS_SET_HANDLE_INHERITABLE_METHODDEF    \
   5576     {"set_handle_inheritable", (PyCFunction)os_set_handle_inheritable, METH_VARARGS, os_set_handle_inheritable__doc__},
   5577 
   5578 static PyObject *
   5579 os_set_handle_inheritable_impl(PyObject *module, intptr_t handle,
   5580                                int inheritable);
   5581 
   5582 static PyObject *
   5583 os_set_handle_inheritable(PyObject *module, PyObject *args)
   5584 {
   5585     PyObject *return_value = NULL;
   5586     intptr_t handle;
   5587     int inheritable;
   5588 
   5589     if (!PyArg_ParseTuple(args, "" _Py_PARSE_INTPTR "p:set_handle_inheritable",
   5590         &handle, &inheritable)) {
   5591         goto exit;
   5592     }
   5593     return_value = os_set_handle_inheritable_impl(module, handle, inheritable);
   5594 
   5595 exit:
   5596     return return_value;
   5597 }
   5598 
   5599 #endif /* defined(MS_WINDOWS) */
   5600 
   5601 PyDoc_STRVAR(os_fspath__doc__,
   5602 "fspath($module, /, path)\n"
   5603 "--\n"
   5604 "\n"
   5605 "Return the file system path representation of the object.\n"
   5606 "\n"
   5607 "If the object is str or bytes, then allow it to pass through as-is. If the\n"
   5608 "object defines __fspath__(), then return the result of that method. All other\n"
   5609 "types raise a TypeError.");
   5610 
   5611 #define OS_FSPATH_METHODDEF    \
   5612     {"fspath", (PyCFunction)os_fspath, METH_FASTCALL, os_fspath__doc__},
   5613 
   5614 static PyObject *
   5615 os_fspath_impl(PyObject *module, PyObject *path);
   5616 
   5617 static PyObject *
   5618 os_fspath(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5619 {
   5620     PyObject *return_value = NULL;
   5621     static const char * const _keywords[] = {"path", NULL};
   5622     static _PyArg_Parser _parser = {"O:fspath", _keywords, 0};
   5623     PyObject *path;
   5624 
   5625     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5626         &path)) {
   5627         goto exit;
   5628     }
   5629     return_value = os_fspath_impl(module, path);
   5630 
   5631 exit:
   5632     return return_value;
   5633 }
   5634 
   5635 #if defined(HAVE_GETRANDOM_SYSCALL)
   5636 
   5637 PyDoc_STRVAR(os_getrandom__doc__,
   5638 "getrandom($module, /, size, flags=0)\n"
   5639 "--\n"
   5640 "\n"
   5641 "Obtain a series of random bytes.");
   5642 
   5643 #define OS_GETRANDOM_METHODDEF    \
   5644     {"getrandom", (PyCFunction)os_getrandom, METH_FASTCALL, os_getrandom__doc__},
   5645 
   5646 static PyObject *
   5647 os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags);
   5648 
   5649 static PyObject *
   5650 os_getrandom(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
   5651 {
   5652     PyObject *return_value = NULL;
   5653     static const char * const _keywords[] = {"size", "flags", NULL};
   5654     static _PyArg_Parser _parser = {"n|i:getrandom", _keywords, 0};
   5655     Py_ssize_t size;
   5656     int flags = 0;
   5657 
   5658     if (!_PyArg_ParseStack(args, nargs, kwnames, &_parser,
   5659         &size, &flags)) {
   5660         goto exit;
   5661     }
   5662     return_value = os_getrandom_impl(module, size, flags);
   5663 
   5664 exit:
   5665     return return_value;
   5666 }
   5667 
   5668 #endif /* defined(HAVE_GETRANDOM_SYSCALL) */
   5669 
   5670 #ifndef OS_TTYNAME_METHODDEF
   5671     #define OS_TTYNAME_METHODDEF
   5672 #endif /* !defined(OS_TTYNAME_METHODDEF) */
   5673 
   5674 #ifndef OS_CTERMID_METHODDEF
   5675     #define OS_CTERMID_METHODDEF
   5676 #endif /* !defined(OS_CTERMID_METHODDEF) */
   5677 
   5678 #ifndef OS_FCHDIR_METHODDEF
   5679     #define OS_FCHDIR_METHODDEF
   5680 #endif /* !defined(OS_FCHDIR_METHODDEF) */
   5681 
   5682 #ifndef OS_FCHMOD_METHODDEF
   5683     #define OS_FCHMOD_METHODDEF
   5684 #endif /* !defined(OS_FCHMOD_METHODDEF) */
   5685 
   5686 #ifndef OS_LCHMOD_METHODDEF
   5687     #define OS_LCHMOD_METHODDEF
   5688 #endif /* !defined(OS_LCHMOD_METHODDEF) */
   5689 
   5690 #ifndef OS_CHFLAGS_METHODDEF
   5691     #define OS_CHFLAGS_METHODDEF
   5692 #endif /* !defined(OS_CHFLAGS_METHODDEF) */
   5693 
   5694 #ifndef OS_LCHFLAGS_METHODDEF
   5695     #define OS_LCHFLAGS_METHODDEF
   5696 #endif /* !defined(OS_LCHFLAGS_METHODDEF) */
   5697 
   5698 #ifndef OS_CHROOT_METHODDEF
   5699     #define OS_CHROOT_METHODDEF
   5700 #endif /* !defined(OS_CHROOT_METHODDEF) */
   5701 
   5702 #ifndef OS_FSYNC_METHODDEF
   5703     #define OS_FSYNC_METHODDEF
   5704 #endif /* !defined(OS_FSYNC_METHODDEF) */
   5705 
   5706 #ifndef OS_SYNC_METHODDEF
   5707     #define OS_SYNC_METHODDEF
   5708 #endif /* !defined(OS_SYNC_METHODDEF) */
   5709 
   5710 #ifndef OS_FDATASYNC_METHODDEF
   5711     #define OS_FDATASYNC_METHODDEF
   5712 #endif /* !defined(OS_FDATASYNC_METHODDEF) */
   5713 
   5714 #ifndef OS_CHOWN_METHODDEF
   5715     #define OS_CHOWN_METHODDEF
   5716 #endif /* !defined(OS_CHOWN_METHODDEF) */
   5717 
   5718 #ifndef OS_FCHOWN_METHODDEF
   5719     #define OS_FCHOWN_METHODDEF
   5720 #endif /* !defined(OS_FCHOWN_METHODDEF) */
   5721 
   5722 #ifndef OS_LCHOWN_METHODDEF
   5723     #define OS_LCHOWN_METHODDEF
   5724 #endif /* !defined(OS_LCHOWN_METHODDEF) */
   5725 
   5726 #ifndef OS_LINK_METHODDEF
   5727     #define OS_LINK_METHODDEF
   5728 #endif /* !defined(OS_LINK_METHODDEF) */
   5729 
   5730 #ifndef OS__GETFULLPATHNAME_METHODDEF
   5731     #define OS__GETFULLPATHNAME_METHODDEF
   5732 #endif /* !defined(OS__GETFULLPATHNAME_METHODDEF) */
   5733 
   5734 #ifndef OS__GETFINALPATHNAME_METHODDEF
   5735     #define OS__GETFINALPATHNAME_METHODDEF
   5736 #endif /* !defined(OS__GETFINALPATHNAME_METHODDEF) */
   5737 
   5738 #ifndef OS__ISDIR_METHODDEF
   5739     #define OS__ISDIR_METHODDEF
   5740 #endif /* !defined(OS__ISDIR_METHODDEF) */
   5741 
   5742 #ifndef OS__GETVOLUMEPATHNAME_METHODDEF
   5743     #define OS__GETVOLUMEPATHNAME_METHODDEF
   5744 #endif /* !defined(OS__GETVOLUMEPATHNAME_METHODDEF) */
   5745 
   5746 #ifndef OS_NICE_METHODDEF
   5747     #define OS_NICE_METHODDEF
   5748 #endif /* !defined(OS_NICE_METHODDEF) */
   5749 
   5750 #ifndef OS_GETPRIORITY_METHODDEF
   5751     #define OS_GETPRIORITY_METHODDEF
   5752 #endif /* !defined(OS_GETPRIORITY_METHODDEF) */
   5753 
   5754 #ifndef OS_SETPRIORITY_METHODDEF
   5755     #define OS_SETPRIORITY_METHODDEF
   5756 #endif /* !defined(OS_SETPRIORITY_METHODDEF) */
   5757 
   5758 #ifndef OS_SYSTEM_METHODDEF
   5759     #define OS_SYSTEM_METHODDEF
   5760 #endif /* !defined(OS_SYSTEM_METHODDEF) */
   5761 
   5762 #ifndef OS_UNAME_METHODDEF
   5763     #define OS_UNAME_METHODDEF
   5764 #endif /* !defined(OS_UNAME_METHODDEF) */
   5765 
   5766 #ifndef OS_EXECV_METHODDEF
   5767     #define OS_EXECV_METHODDEF
   5768 #endif /* !defined(OS_EXECV_METHODDEF) */
   5769 
   5770 #ifndef OS_EXECVE_METHODDEF
   5771     #define OS_EXECVE_METHODDEF
   5772 #endif /* !defined(OS_EXECVE_METHODDEF) */
   5773 
   5774 #ifndef OS_SPAWNV_METHODDEF
   5775     #define OS_SPAWNV_METHODDEF
   5776 #endif /* !defined(OS_SPAWNV_METHODDEF) */
   5777 
   5778 #ifndef OS_SPAWNVE_METHODDEF
   5779     #define OS_SPAWNVE_METHODDEF
   5780 #endif /* !defined(OS_SPAWNVE_METHODDEF) */
   5781 
   5782 #ifndef OS_FORK1_METHODDEF
   5783     #define OS_FORK1_METHODDEF
   5784 #endif /* !defined(OS_FORK1_METHODDEF) */
   5785 
   5786 #ifndef OS_FORK_METHODDEF
   5787     #define OS_FORK_METHODDEF
   5788 #endif /* !defined(OS_FORK_METHODDEF) */
   5789 
   5790 #ifndef OS_SCHED_GET_PRIORITY_MAX_METHODDEF
   5791     #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF
   5792 #endif /* !defined(OS_SCHED_GET_PRIORITY_MAX_METHODDEF) */
   5793 
   5794 #ifndef OS_SCHED_GET_PRIORITY_MIN_METHODDEF
   5795     #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF
   5796 #endif /* !defined(OS_SCHED_GET_PRIORITY_MIN_METHODDEF) */
   5797 
   5798 #ifndef OS_SCHED_GETSCHEDULER_METHODDEF
   5799     #define OS_SCHED_GETSCHEDULER_METHODDEF
   5800 #endif /* !defined(OS_SCHED_GETSCHEDULER_METHODDEF) */
   5801 
   5802 #ifndef OS_SCHED_SETSCHEDULER_METHODDEF
   5803     #define OS_SCHED_SETSCHEDULER_METHODDEF
   5804 #endif /* !defined(OS_SCHED_SETSCHEDULER_METHODDEF) */
   5805 
   5806 #ifndef OS_SCHED_GETPARAM_METHODDEF
   5807     #define OS_SCHED_GETPARAM_METHODDEF
   5808 #endif /* !defined(OS_SCHED_GETPARAM_METHODDEF) */
   5809 
   5810 #ifndef OS_SCHED_SETPARAM_METHODDEF
   5811     #define OS_SCHED_SETPARAM_METHODDEF
   5812 #endif /* !defined(OS_SCHED_SETPARAM_METHODDEF) */
   5813 
   5814 #ifndef OS_SCHED_RR_GET_INTERVAL_METHODDEF
   5815     #define OS_SCHED_RR_GET_INTERVAL_METHODDEF
   5816 #endif /* !defined(OS_SCHED_RR_GET_INTERVAL_METHODDEF) */
   5817 
   5818 #ifndef OS_SCHED_YIELD_METHODDEF
   5819     #define OS_SCHED_YIELD_METHODDEF
   5820 #endif /* !defined(OS_SCHED_YIELD_METHODDEF) */
   5821 
   5822 #ifndef OS_SCHED_SETAFFINITY_METHODDEF
   5823     #define OS_SCHED_SETAFFINITY_METHODDEF
   5824 #endif /* !defined(OS_SCHED_SETAFFINITY_METHODDEF) */
   5825 
   5826 #ifndef OS_SCHED_GETAFFINITY_METHODDEF
   5827     #define OS_SCHED_GETAFFINITY_METHODDEF
   5828 #endif /* !defined(OS_SCHED_GETAFFINITY_METHODDEF) */
   5829 
   5830 #ifndef OS_OPENPTY_METHODDEF
   5831     #define OS_OPENPTY_METHODDEF
   5832 #endif /* !defined(OS_OPENPTY_METHODDEF) */
   5833 
   5834 #ifndef OS_FORKPTY_METHODDEF
   5835     #define OS_FORKPTY_METHODDEF
   5836 #endif /* !defined(OS_FORKPTY_METHODDEF) */
   5837 
   5838 #ifndef OS_GETEGID_METHODDEF
   5839     #define OS_GETEGID_METHODDEF
   5840 #endif /* !defined(OS_GETEGID_METHODDEF) */
   5841 
   5842 #ifndef OS_GETEUID_METHODDEF
   5843     #define OS_GETEUID_METHODDEF
   5844 #endif /* !defined(OS_GETEUID_METHODDEF) */
   5845 
   5846 #ifndef OS_GETGID_METHODDEF
   5847     #define OS_GETGID_METHODDEF
   5848 #endif /* !defined(OS_GETGID_METHODDEF) */
   5849 
   5850 #ifndef OS_GETPID_METHODDEF
   5851     #define OS_GETPID_METHODDEF
   5852 #endif /* !defined(OS_GETPID_METHODDEF) */
   5853 
   5854 #ifndef OS_GETGROUPS_METHODDEF
   5855     #define OS_GETGROUPS_METHODDEF
   5856 #endif /* !defined(OS_GETGROUPS_METHODDEF) */
   5857 
   5858 #ifndef OS_GETPGID_METHODDEF
   5859     #define OS_GETPGID_METHODDEF
   5860 #endif /* !defined(OS_GETPGID_METHODDEF) */
   5861 
   5862 #ifndef OS_GETPGRP_METHODDEF
   5863     #define OS_GETPGRP_METHODDEF
   5864 #endif /* !defined(OS_GETPGRP_METHODDEF) */
   5865 
   5866 #ifndef OS_SETPGRP_METHODDEF
   5867     #define OS_SETPGRP_METHODDEF
   5868 #endif /* !defined(OS_SETPGRP_METHODDEF) */
   5869 
   5870 #ifndef OS_GETPPID_METHODDEF
   5871     #define OS_GETPPID_METHODDEF
   5872 #endif /* !defined(OS_GETPPID_METHODDEF) */
   5873 
   5874 #ifndef OS_GETLOGIN_METHODDEF
   5875     #define OS_GETLOGIN_METHODDEF
   5876 #endif /* !defined(OS_GETLOGIN_METHODDEF) */
   5877 
   5878 #ifndef OS_GETUID_METHODDEF
   5879     #define OS_GETUID_METHODDEF
   5880 #endif /* !defined(OS_GETUID_METHODDEF) */
   5881 
   5882 #ifndef OS_KILL_METHODDEF
   5883     #define OS_KILL_METHODDEF
   5884 #endif /* !defined(OS_KILL_METHODDEF) */
   5885 
   5886 #ifndef OS_KILLPG_METHODDEF
   5887     #define OS_KILLPG_METHODDEF
   5888 #endif /* !defined(OS_KILLPG_METHODDEF) */
   5889 
   5890 #ifndef OS_PLOCK_METHODDEF
   5891     #define OS_PLOCK_METHODDEF
   5892 #endif /* !defined(OS_PLOCK_METHODDEF) */
   5893 
   5894 #ifndef OS_SETUID_METHODDEF
   5895     #define OS_SETUID_METHODDEF
   5896 #endif /* !defined(OS_SETUID_METHODDEF) */
   5897 
   5898 #ifndef OS_SETEUID_METHODDEF
   5899     #define OS_SETEUID_METHODDEF
   5900 #endif /* !defined(OS_SETEUID_METHODDEF) */
   5901 
   5902 #ifndef OS_SETEGID_METHODDEF
   5903     #define OS_SETEGID_METHODDEF
   5904 #endif /* !defined(OS_SETEGID_METHODDEF) */
   5905 
   5906 #ifndef OS_SETREUID_METHODDEF
   5907     #define OS_SETREUID_METHODDEF
   5908 #endif /* !defined(OS_SETREUID_METHODDEF) */
   5909 
   5910 #ifndef OS_SETREGID_METHODDEF
   5911     #define OS_SETREGID_METHODDEF
   5912 #endif /* !defined(OS_SETREGID_METHODDEF) */
   5913 
   5914 #ifndef OS_SETGID_METHODDEF
   5915     #define OS_SETGID_METHODDEF
   5916 #endif /* !defined(OS_SETGID_METHODDEF) */
   5917 
   5918 #ifndef OS_SETGROUPS_METHODDEF
   5919     #define OS_SETGROUPS_METHODDEF
   5920 #endif /* !defined(OS_SETGROUPS_METHODDEF) */
   5921 
   5922 #ifndef OS_WAIT3_METHODDEF
   5923     #define OS_WAIT3_METHODDEF
   5924 #endif /* !defined(OS_WAIT3_METHODDEF) */
   5925 
   5926 #ifndef OS_WAIT4_METHODDEF
   5927     #define OS_WAIT4_METHODDEF
   5928 #endif /* !defined(OS_WAIT4_METHODDEF) */
   5929 
   5930 #ifndef OS_WAITID_METHODDEF
   5931     #define OS_WAITID_METHODDEF
   5932 #endif /* !defined(OS_WAITID_METHODDEF) */
   5933 
   5934 #ifndef OS_WAITPID_METHODDEF
   5935     #define OS_WAITPID_METHODDEF
   5936 #endif /* !defined(OS_WAITPID_METHODDEF) */
   5937 
   5938 #ifndef OS_WAIT_METHODDEF
   5939     #define OS_WAIT_METHODDEF
   5940 #endif /* !defined(OS_WAIT_METHODDEF) */
   5941 
   5942 #ifndef OS_SYMLINK_METHODDEF
   5943     #define OS_SYMLINK_METHODDEF
   5944 #endif /* !defined(OS_SYMLINK_METHODDEF) */
   5945 
   5946 #ifndef OS_TIMES_METHODDEF
   5947     #define OS_TIMES_METHODDEF
   5948 #endif /* !defined(OS_TIMES_METHODDEF) */
   5949 
   5950 #ifndef OS_GETSID_METHODDEF
   5951     #define OS_GETSID_METHODDEF
   5952 #endif /* !defined(OS_GETSID_METHODDEF) */
   5953 
   5954 #ifndef OS_SETSID_METHODDEF
   5955     #define OS_SETSID_METHODDEF
   5956 #endif /* !defined(OS_SETSID_METHODDEF) */
   5957 
   5958 #ifndef OS_SETPGID_METHODDEF
   5959     #define OS_SETPGID_METHODDEF
   5960 #endif /* !defined(OS_SETPGID_METHODDEF) */
   5961 
   5962 #ifndef OS_TCGETPGRP_METHODDEF
   5963     #define OS_TCGETPGRP_METHODDEF
   5964 #endif /* !defined(OS_TCGETPGRP_METHODDEF) */
   5965 
   5966 #ifndef OS_TCSETPGRP_METHODDEF
   5967     #define OS_TCSETPGRP_METHODDEF
   5968 #endif /* !defined(OS_TCSETPGRP_METHODDEF) */
   5969 
   5970 #ifndef OS_LOCKF_METHODDEF
   5971     #define OS_LOCKF_METHODDEF
   5972 #endif /* !defined(OS_LOCKF_METHODDEF) */
   5973 
   5974 #ifndef OS_READV_METHODDEF
   5975     #define OS_READV_METHODDEF
   5976 #endif /* !defined(OS_READV_METHODDEF) */
   5977 
   5978 #ifndef OS_PREAD_METHODDEF
   5979     #define OS_PREAD_METHODDEF
   5980 #endif /* !defined(OS_PREAD_METHODDEF) */
   5981 
   5982 #ifndef OS_PIPE_METHODDEF
   5983     #define OS_PIPE_METHODDEF
   5984 #endif /* !defined(OS_PIPE_METHODDEF) */
   5985 
   5986 #ifndef OS_PIPE2_METHODDEF
   5987     #define OS_PIPE2_METHODDEF
   5988 #endif /* !defined(OS_PIPE2_METHODDEF) */
   5989 
   5990 #ifndef OS_WRITEV_METHODDEF
   5991     #define OS_WRITEV_METHODDEF
   5992 #endif /* !defined(OS_WRITEV_METHODDEF) */
   5993 
   5994 #ifndef OS_PWRITE_METHODDEF
   5995     #define OS_PWRITE_METHODDEF
   5996 #endif /* !defined(OS_PWRITE_METHODDEF) */
   5997 
   5998 #ifndef OS_MKFIFO_METHODDEF
   5999     #define OS_MKFIFO_METHODDEF
   6000 #endif /* !defined(OS_MKFIFO_METHODDEF) */
   6001 
   6002 #ifndef OS_MKNOD_METHODDEF
   6003     #define OS_MKNOD_METHODDEF
   6004 #endif /* !defined(OS_MKNOD_METHODDEF) */
   6005 
   6006 #ifndef OS_MAJOR_METHODDEF
   6007     #define OS_MAJOR_METHODDEF
   6008 #endif /* !defined(OS_MAJOR_METHODDEF) */
   6009 
   6010 #ifndef OS_MINOR_METHODDEF
   6011     #define OS_MINOR_METHODDEF
   6012 #endif /* !defined(OS_MINOR_METHODDEF) */
   6013 
   6014 #ifndef OS_MAKEDEV_METHODDEF
   6015     #define OS_MAKEDEV_METHODDEF
   6016 #endif /* !defined(OS_MAKEDEV_METHODDEF) */
   6017 
   6018 #ifndef OS_FTRUNCATE_METHODDEF
   6019     #define OS_FTRUNCATE_METHODDEF
   6020 #endif /* !defined(OS_FTRUNCATE_METHODDEF) */
   6021 
   6022 #ifndef OS_TRUNCATE_METHODDEF
   6023     #define OS_TRUNCATE_METHODDEF
   6024 #endif /* !defined(OS_TRUNCATE_METHODDEF) */
   6025 
   6026 #ifndef OS_POSIX_FALLOCATE_METHODDEF
   6027     #define OS_POSIX_FALLOCATE_METHODDEF
   6028 #endif /* !defined(OS_POSIX_FALLOCATE_METHODDEF) */
   6029 
   6030 #ifndef OS_POSIX_FADVISE_METHODDEF
   6031     #define OS_POSIX_FADVISE_METHODDEF
   6032 #endif /* !defined(OS_POSIX_FADVISE_METHODDEF) */
   6033 
   6034 #ifndef OS_PUTENV_METHODDEF
   6035     #define OS_PUTENV_METHODDEF
   6036 #endif /* !defined(OS_PUTENV_METHODDEF) */
   6037 
   6038 #ifndef OS_UNSETENV_METHODDEF
   6039     #define OS_UNSETENV_METHODDEF
   6040 #endif /* !defined(OS_UNSETENV_METHODDEF) */
   6041 
   6042 #ifndef OS_WCOREDUMP_METHODDEF
   6043     #define OS_WCOREDUMP_METHODDEF
   6044 #endif /* !defined(OS_WCOREDUMP_METHODDEF) */
   6045 
   6046 #ifndef OS_WIFCONTINUED_METHODDEF
   6047     #define OS_WIFCONTINUED_METHODDEF
   6048 #endif /* !defined(OS_WIFCONTINUED_METHODDEF) */
   6049 
   6050 #ifndef OS_WIFSTOPPED_METHODDEF
   6051     #define OS_WIFSTOPPED_METHODDEF
   6052 #endif /* !defined(OS_WIFSTOPPED_METHODDEF) */
   6053 
   6054 #ifndef OS_WIFSIGNALED_METHODDEF
   6055     #define OS_WIFSIGNALED_METHODDEF
   6056 #endif /* !defined(OS_WIFSIGNALED_METHODDEF) */
   6057 
   6058 #ifndef OS_WIFEXITED_METHODDEF
   6059     #define OS_WIFEXITED_METHODDEF
   6060 #endif /* !defined(OS_WIFEXITED_METHODDEF) */
   6061 
   6062 #ifndef OS_WEXITSTATUS_METHODDEF
   6063     #define OS_WEXITSTATUS_METHODDEF
   6064 #endif /* !defined(OS_WEXITSTATUS_METHODDEF) */
   6065 
   6066 #ifndef OS_WTERMSIG_METHODDEF
   6067     #define OS_WTERMSIG_METHODDEF
   6068 #endif /* !defined(OS_WTERMSIG_METHODDEF) */
   6069 
   6070 #ifndef OS_WSTOPSIG_METHODDEF
   6071     #define OS_WSTOPSIG_METHODDEF
   6072 #endif /* !defined(OS_WSTOPSIG_METHODDEF) */
   6073 
   6074 #ifndef OS_FSTATVFS_METHODDEF
   6075     #define OS_FSTATVFS_METHODDEF
   6076 #endif /* !defined(OS_FSTATVFS_METHODDEF) */
   6077 
   6078 #ifndef OS_STATVFS_METHODDEF
   6079     #define OS_STATVFS_METHODDEF
   6080 #endif /* !defined(OS_STATVFS_METHODDEF) */
   6081 
   6082 #ifndef OS__GETDISKUSAGE_METHODDEF
   6083     #define OS__GETDISKUSAGE_METHODDEF
   6084 #endif /* !defined(OS__GETDISKUSAGE_METHODDEF) */
   6085 
   6086 #ifndef OS_FPATHCONF_METHODDEF
   6087     #define OS_FPATHCONF_METHODDEF
   6088 #endif /* !defined(OS_FPATHCONF_METHODDEF) */
   6089 
   6090 #ifndef OS_PATHCONF_METHODDEF
   6091     #define OS_PATHCONF_METHODDEF
   6092 #endif /* !defined(OS_PATHCONF_METHODDEF) */
   6093 
   6094 #ifndef OS_CONFSTR_METHODDEF
   6095     #define OS_CONFSTR_METHODDEF
   6096 #endif /* !defined(OS_CONFSTR_METHODDEF) */
   6097 
   6098 #ifndef OS_SYSCONF_METHODDEF
   6099     #define OS_SYSCONF_METHODDEF
   6100 #endif /* !defined(OS_SYSCONF_METHODDEF) */
   6101 
   6102 #ifndef OS_STARTFILE_METHODDEF
   6103     #define OS_STARTFILE_METHODDEF
   6104 #endif /* !defined(OS_STARTFILE_METHODDEF) */
   6105 
   6106 #ifndef OS_GETLOADAVG_METHODDEF
   6107     #define OS_GETLOADAVG_METHODDEF
   6108 #endif /* !defined(OS_GETLOADAVG_METHODDEF) */
   6109 
   6110 #ifndef OS_SETRESUID_METHODDEF
   6111     #define OS_SETRESUID_METHODDEF
   6112 #endif /* !defined(OS_SETRESUID_METHODDEF) */
   6113 
   6114 #ifndef OS_SETRESGID_METHODDEF
   6115     #define OS_SETRESGID_METHODDEF
   6116 #endif /* !defined(OS_SETRESGID_METHODDEF) */
   6117 
   6118 #ifndef OS_GETRESUID_METHODDEF
   6119     #define OS_GETRESUID_METHODDEF
   6120 #endif /* !defined(OS_GETRESUID_METHODDEF) */
   6121 
   6122 #ifndef OS_GETRESGID_METHODDEF
   6123     #define OS_GETRESGID_METHODDEF
   6124 #endif /* !defined(OS_GETRESGID_METHODDEF) */
   6125 
   6126 #ifndef OS_GETXATTR_METHODDEF
   6127     #define OS_GETXATTR_METHODDEF
   6128 #endif /* !defined(OS_GETXATTR_METHODDEF) */
   6129 
   6130 #ifndef OS_SETXATTR_METHODDEF
   6131     #define OS_SETXATTR_METHODDEF
   6132 #endif /* !defined(OS_SETXATTR_METHODDEF) */
   6133 
   6134 #ifndef OS_REMOVEXATTR_METHODDEF
   6135     #define OS_REMOVEXATTR_METHODDEF
   6136 #endif /* !defined(OS_REMOVEXATTR_METHODDEF) */
   6137 
   6138 #ifndef OS_LISTXATTR_METHODDEF
   6139     #define OS_LISTXATTR_METHODDEF
   6140 #endif /* !defined(OS_LISTXATTR_METHODDEF) */
   6141 
   6142 #ifndef OS_GET_HANDLE_INHERITABLE_METHODDEF
   6143     #define OS_GET_HANDLE_INHERITABLE_METHODDEF
   6144 #endif /* !defined(OS_GET_HANDLE_INHERITABLE_METHODDEF) */
   6145 
   6146 #ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF
   6147     #define OS_SET_HANDLE_INHERITABLE_METHODDEF
   6148 #endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */
   6149 
   6150 #ifndef OS_GETRANDOM_METHODDEF
   6151     #define OS_GETRANDOM_METHODDEF
   6152 #endif /* !defined(OS_GETRANDOM_METHODDEF) */
   6153 /*[clinic end generated code: output=455def991740915a input=a9049054013a1b77]*/
   6154