/home/mdboom/Work/builds/cpython/Modules/clinic/posixmodule.c.h
Line | Count | Source (jump to first uncovered line) |
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, a 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_CAST(os_stat), METH_FASTCALL|METH_KEYWORDS, 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 *const *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 = {NULL, _keywords, "stat", 0}; |
42 | PyObject *argsbuf[3]; |
43 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE12.4k (kwnames) : 0341k ) - 1; Branch (43:36): [True: 12.4k, False: 341k]
|
44 | path_t path = PATH_T_INITIALIZE("stat", "path", 0, 1); |
45 | int dir_fd = DEFAULT_DIR_FD; |
46 | int follow_symlinks = 1; |
47 | |
48 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
49 | if (!args) { Branch (49:9): [True: 0, False: 354k]
|
50 | goto exit; |
51 | } |
52 | if (!path_converter(args[0], &path)) { Branch (52:9): [True: 119, False: 354k]
|
53 | goto exit; |
54 | } |
55 | if (!noptargs) { Branch (55:9): [True: 341k, False: 12.3k]
|
56 | goto skip_optional_kwonly; |
57 | } |
58 | if (args[1]) { Branch (58:9): [True: 4.23k, False: 8.14k]
|
59 | if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { Branch (59:13): [True: 3, False: 4.23k]
|
60 | goto exit; |
61 | } |
62 | if (!--noptargs) { Branch (62:13): [True: 42, False: 4.19k]
|
63 | goto skip_optional_kwonly; |
64 | } |
65 | } |
66 | follow_symlinks = PyObject_IsTrue(args[2]); |
67 | if (follow_symlinks < 0) { Branch (67:9): [True: 0, False: 12.3k]
|
68 | goto exit; |
69 | } |
70 | skip_optional_kwonly: |
71 | return_value = os_stat_impl(module, &path, dir_fd, follow_symlinks); |
72 | |
73 | exit: |
74 | /* Cleanup for path */ |
75 | path_cleanup(&path); |
76 | |
77 | return return_value; |
78 | } |
79 | |
80 | PyDoc_STRVAR(os_lstat__doc__, |
81 | "lstat($module, /, path, *, dir_fd=None)\n" |
82 | "--\n" |
83 | "\n" |
84 | "Perform a stat system call on the given path, without following symbolic links.\n" |
85 | "\n" |
86 | "Like stat(), but do not follow symbolic links.\n" |
87 | "Equivalent to stat(path, follow_symlinks=False)."); |
88 | |
89 | #define OS_LSTAT_METHODDEF \ |
90 | {"lstat", _PyCFunction_CAST(os_lstat), METH_FASTCALL|METH_KEYWORDS, os_lstat__doc__}, |
91 | |
92 | static PyObject * |
93 | os_lstat_impl(PyObject *module, path_t *path, int dir_fd); |
94 | |
95 | static PyObject * |
96 | os_lstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
97 | { |
98 | PyObject *return_value = NULL; |
99 | static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
100 | static _PyArg_Parser _parser = {NULL, _keywords, "lstat", 0}; |
101 | PyObject *argsbuf[2]; |
102 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE2.97k (kwnames) : 040.7k ) - 1; Branch (102:36): [True: 2.97k, False: 40.7k]
|
103 | path_t path = PATH_T_INITIALIZE("lstat", "path", 0, 0); |
104 | int dir_fd = DEFAULT_DIR_FD; |
105 | |
106 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
107 | if (!args) { Branch (107:9): [True: 0, False: 43.7k]
|
108 | goto exit; |
109 | } |
110 | if (!path_converter(args[0], &path)) { Branch (110:9): [True: 14, False: 43.7k]
|
111 | goto exit; |
112 | } |
113 | if (!noptargs) { Branch (113:9): [True: 40.7k, False: 2.97k]
|
114 | goto skip_optional_kwonly; |
115 | } |
116 | if (!FSTATAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { Branch (116:9): [True: 0, False: 2.97k]
|
117 | goto exit; |
118 | } |
119 | skip_optional_kwonly: |
120 | return_value = os_lstat_impl(module, &path, dir_fd); |
121 | |
122 | exit: |
123 | /* Cleanup for path */ |
124 | path_cleanup(&path); |
125 | |
126 | return return_value; |
127 | } |
128 | |
129 | PyDoc_STRVAR(os_access__doc__, |
130 | "access($module, /, path, mode, *, dir_fd=None, effective_ids=False,\n" |
131 | " follow_symlinks=True)\n" |
132 | "--\n" |
133 | "\n" |
134 | "Use the real uid/gid to test for access to a path.\n" |
135 | "\n" |
136 | " path\n" |
137 | " Path to be tested; can be string, bytes, or a path-like object.\n" |
138 | " mode\n" |
139 | " Operating-system mode bitfield. Can be F_OK to test existence,\n" |
140 | " or the inclusive-OR of R_OK, W_OK, and X_OK.\n" |
141 | " dir_fd\n" |
142 | " If not None, it should be a file descriptor open to a directory,\n" |
143 | " and path should be relative; path will then be relative to that\n" |
144 | " directory.\n" |
145 | " effective_ids\n" |
146 | " If True, access will use the effective uid/gid instead of\n" |
147 | " the real uid/gid.\n" |
148 | " follow_symlinks\n" |
149 | " If False, and the last element of the path is a symbolic link,\n" |
150 | " access will examine the symbolic link itself instead of the file\n" |
151 | " the link points to.\n" |
152 | "\n" |
153 | "dir_fd, effective_ids, and follow_symlinks may not be implemented\n" |
154 | " on your platform. If they are unavailable, using them will raise a\n" |
155 | " NotImplementedError.\n" |
156 | "\n" |
157 | "Note that most operations will use the effective uid/gid, therefore this\n" |
158 | " routine can be used in a suid/sgid environment to test if the invoking user\n" |
159 | " has the specified access to the path."); |
160 | |
161 | #define OS_ACCESS_METHODDEF \ |
162 | {"access", _PyCFunction_CAST(os_access), METH_FASTCALL|METH_KEYWORDS, os_access__doc__}, |
163 | |
164 | static int |
165 | os_access_impl(PyObject *module, path_t *path, int mode, int dir_fd, |
166 | int effective_ids, int follow_symlinks); |
167 | |
168 | static PyObject * |
169 | os_access(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
170 | { |
171 | PyObject *return_value = NULL; |
172 | static const char * const _keywords[] = {"path", "mode", "dir_fd", "effective_ids", "follow_symlinks", NULL}; |
173 | static _PyArg_Parser _parser = {NULL, _keywords, "access", 0}; |
174 | PyObject *argsbuf[5]; |
175 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE5 (kwnames) : 0137 ) - 2; Branch (175:36): [True: 5, False: 137]
|
176 | path_t path = PATH_T_INITIALIZE("access", "path", 0, 0); |
177 | int mode; |
178 | int dir_fd = DEFAULT_DIR_FD; |
179 | int effective_ids = 0; |
180 | int follow_symlinks = 1; |
181 | int _return_value; |
182 | |
183 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
184 | if (!args) { Branch (184:9): [True: 0, False: 142]
|
185 | goto exit; |
186 | } |
187 | if (!path_converter(args[0], &path)) { Branch (187:9): [True: 2, False: 140]
|
188 | goto exit; |
189 | } |
190 | mode = _PyLong_AsInt(args[1]); |
191 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (191:9): [True: 0, False: 140]
Branch (191:23): [True: 0, False: 0]
|
192 | goto exit; |
193 | } |
194 | if (!noptargs) { Branch (194:9): [True: 135, False: 5]
|
195 | goto skip_optional_kwonly; |
196 | } |
197 | if (args[2]) { Branch (197:9): [True: 1, False: 4]
|
198 | if (!FACCESSAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { Branch (198:13): [True: 0, False: 1]
|
199 | goto exit; |
200 | } |
201 | if (!--noptargs) { Branch (201:13): [True: 1, False: 0]
|
202 | goto skip_optional_kwonly; |
203 | } |
204 | } |
205 | if (args[3]) { Branch (205:9): [True: 4, False: 0]
|
206 | effective_ids = PyObject_IsTrue(args[3]); |
207 | if (effective_ids < 0) { Branch (207:13): [True: 0, False: 4]
|
208 | goto exit; |
209 | } |
210 | if (!--noptargs) { Branch (210:13): [True: 4, False: 0]
|
211 | goto skip_optional_kwonly; |
212 | } |
213 | } |
214 | follow_symlinks = PyObject_IsTrue(args[4]); |
215 | if (follow_symlinks < 0) { Branch (215:9): [True: 0, False: 0]
|
216 | goto exit; |
217 | } |
218 | skip_optional_kwonly: |
219 | _return_value = os_access_impl(module, &path, mode, dir_fd, effective_ids, follow_symlinks); |
220 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (220:9): [True: 0, False: 140]
Branch (220:34): [True: 0, False: 0]
|
221 | goto exit; |
222 | } |
223 | return_value = PyBool_FromLong((long)_return_value); |
224 | |
225 | exit: |
226 | /* Cleanup for path */ |
227 | path_cleanup(&path); |
228 | |
229 | return return_value; |
230 | } |
231 | |
232 | #if defined(HAVE_TTYNAME) |
233 | |
234 | PyDoc_STRVAR(os_ttyname__doc__, |
235 | "ttyname($module, fd, /)\n" |
236 | "--\n" |
237 | "\n" |
238 | "Return the name of the terminal device connected to \'fd\'.\n" |
239 | "\n" |
240 | " fd\n" |
241 | " Integer file descriptor handle."); |
242 | |
243 | #define OS_TTYNAME_METHODDEF \ |
244 | {"ttyname", (PyCFunction)os_ttyname, METH_O, os_ttyname__doc__}, |
245 | |
246 | static PyObject * |
247 | os_ttyname_impl(PyObject *module, int fd); |
248 | |
249 | static PyObject * |
250 | os_ttyname(PyObject *module, PyObject *arg) |
251 | { |
252 | PyObject *return_value = NULL; |
253 | int fd; |
254 | |
255 | fd = _PyLong_AsInt(arg); |
256 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (256:9): [True: 0, False: 1]
Branch (256:21): [True: 0, False: 0]
|
257 | goto exit; |
258 | } |
259 | return_value = os_ttyname_impl(module, fd); |
260 | |
261 | exit: |
262 | return return_value; |
263 | } |
264 | |
265 | #endif /* defined(HAVE_TTYNAME) */ |
266 | |
267 | #if defined(HAVE_CTERMID) |
268 | |
269 | PyDoc_STRVAR(os_ctermid__doc__, |
270 | "ctermid($module, /)\n" |
271 | "--\n" |
272 | "\n" |
273 | "Return the name of the controlling terminal for this process."); |
274 | |
275 | #define OS_CTERMID_METHODDEF \ |
276 | {"ctermid", (PyCFunction)os_ctermid, METH_NOARGS, os_ctermid__doc__}, |
277 | |
278 | static PyObject * |
279 | os_ctermid_impl(PyObject *module); |
280 | |
281 | static PyObject * |
282 | os_ctermid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
283 | { |
284 | return os_ctermid_impl(module); |
285 | } |
286 | |
287 | #endif /* defined(HAVE_CTERMID) */ |
288 | |
289 | PyDoc_STRVAR(os_chdir__doc__, |
290 | "chdir($module, /, path)\n" |
291 | "--\n" |
292 | "\n" |
293 | "Change the current working directory to the specified path.\n" |
294 | "\n" |
295 | "path may always be specified as a string.\n" |
296 | "On some platforms, path may also be specified as an open file descriptor.\n" |
297 | " If this functionality is unavailable, using it raises an exception."); |
298 | |
299 | #define OS_CHDIR_METHODDEF \ |
300 | {"chdir", _PyCFunction_CAST(os_chdir), METH_FASTCALL|METH_KEYWORDS, os_chdir__doc__}, |
301 | |
302 | static PyObject * |
303 | os_chdir_impl(PyObject *module, path_t *path); |
304 | |
305 | static PyObject * |
306 | os_chdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
307 | { |
308 | PyObject *return_value = NULL; |
309 | static const char * const _keywords[] = {"path", NULL}; |
310 | static _PyArg_Parser _parser = {NULL, _keywords, "chdir", 0}; |
311 | PyObject *argsbuf[1]; |
312 | path_t path = PATH_T_INITIALIZE("chdir", "path", 0, PATH_HAVE_FCHDIR); |
313 | |
314 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
315 | if (!args) { Branch (315:9): [True: 0, False: 1.53k]
|
316 | goto exit; |
317 | } |
318 | if (!path_converter(args[0], &path)) { Branch (318:9): [True: 0, False: 1.53k]
|
319 | goto exit; |
320 | } |
321 | return_value = os_chdir_impl(module, &path); |
322 | |
323 | exit: |
324 | /* Cleanup for path */ |
325 | path_cleanup(&path); |
326 | |
327 | return return_value; |
328 | } |
329 | |
330 | #if defined(HAVE_FCHDIR) |
331 | |
332 | PyDoc_STRVAR(os_fchdir__doc__, |
333 | "fchdir($module, /, fd)\n" |
334 | "--\n" |
335 | "\n" |
336 | "Change to the directory of the given file descriptor.\n" |
337 | "\n" |
338 | "fd must be opened on a directory, not a file.\n" |
339 | "Equivalent to os.chdir(fd)."); |
340 | |
341 | #define OS_FCHDIR_METHODDEF \ |
342 | {"fchdir", _PyCFunction_CAST(os_fchdir), METH_FASTCALL|METH_KEYWORDS, os_fchdir__doc__}, |
343 | |
344 | static PyObject * |
345 | os_fchdir_impl(PyObject *module, int fd); |
346 | |
347 | static PyObject * |
348 | os_fchdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
349 | { |
350 | PyObject *return_value = NULL; |
351 | static const char * const _keywords[] = {"fd", NULL}; |
352 | static _PyArg_Parser _parser = {NULL, _keywords, "fchdir", 0}; |
353 | PyObject *argsbuf[1]; |
354 | int fd; |
355 | |
356 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
357 | if (!args) { Branch (357:9): [True: 0, False: 1]
|
358 | goto exit; |
359 | } |
360 | if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { Branch (360:9): [True: 0, False: 1]
|
361 | goto exit; |
362 | } |
363 | return_value = os_fchdir_impl(module, fd); |
364 | |
365 | exit: |
366 | return return_value; |
367 | } |
368 | |
369 | #endif /* defined(HAVE_FCHDIR) */ |
370 | |
371 | PyDoc_STRVAR(os_chmod__doc__, |
372 | "chmod($module, /, path, mode, *, dir_fd=None, follow_symlinks=True)\n" |
373 | "--\n" |
374 | "\n" |
375 | "Change the access permissions of a file.\n" |
376 | "\n" |
377 | " path\n" |
378 | " Path to be modified. May always be specified as a str, bytes, or a path-like object.\n" |
379 | " On some platforms, path may also be specified as an open file descriptor.\n" |
380 | " If this functionality is unavailable, using it raises an exception.\n" |
381 | " mode\n" |
382 | " Operating-system mode bitfield.\n" |
383 | " dir_fd\n" |
384 | " If not None, it should be a file descriptor open to a directory,\n" |
385 | " and path should be relative; path will then be relative to that\n" |
386 | " directory.\n" |
387 | " follow_symlinks\n" |
388 | " If False, and the last element of the path is a symbolic link,\n" |
389 | " chmod will modify the symbolic link itself instead of the file\n" |
390 | " the link points to.\n" |
391 | "\n" |
392 | "It is an error to use dir_fd or follow_symlinks when specifying path as\n" |
393 | " an open file descriptor.\n" |
394 | "dir_fd and follow_symlinks may not be implemented on your platform.\n" |
395 | " If they are unavailable, using them will raise a NotImplementedError."); |
396 | |
397 | #define OS_CHMOD_METHODDEF \ |
398 | {"chmod", _PyCFunction_CAST(os_chmod), METH_FASTCALL|METH_KEYWORDS, os_chmod__doc__}, |
399 | |
400 | static PyObject * |
401 | os_chmod_impl(PyObject *module, path_t *path, int mode, int dir_fd, |
402 | int follow_symlinks); |
403 | |
404 | static PyObject * |
405 | os_chmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
406 | { |
407 | PyObject *return_value = NULL; |
408 | static const char * const _keywords[] = {"path", "mode", "dir_fd", "follow_symlinks", NULL}; |
409 | static _PyArg_Parser _parser = {NULL, _keywords, "chmod", 0}; |
410 | PyObject *argsbuf[4]; |
411 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE8.64k (kwnames) : 02.92k ) - 2; Branch (411:36): [True: 8.64k, False: 2.92k]
|
412 | path_t path = PATH_T_INITIALIZE("chmod", "path", 0, PATH_HAVE_FCHMOD); |
413 | int mode; |
414 | int dir_fd = DEFAULT_DIR_FD; |
415 | int follow_symlinks = 1; |
416 | |
417 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
418 | if (!args) { Branch (418:9): [True: 0, False: 11.5k]
|
419 | goto exit; |
420 | } |
421 | if (!path_converter(args[0], &path)) { Branch (421:9): [True: 0, False: 11.5k]
|
422 | goto exit; |
423 | } |
424 | mode = _PyLong_AsInt(args[1]); |
425 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (425:9): [True: 0, False: 11.5k]
Branch (425:23): [True: 0, False: 0]
|
426 | goto exit; |
427 | } |
428 | if (!noptargs) { Branch (428:9): [True: 2.92k, False: 8.64k]
|
429 | goto skip_optional_kwonly; |
430 | } |
431 | if (args[2]) { Branch (431:9): [True: 1, False: 8.64k]
|
432 | if (!FCHMODAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { Branch (432:13): [True: 0, False: 1]
|
433 | goto exit; |
434 | } |
435 | if (!--noptargs) { Branch (435:13): [True: 1, False: 0]
|
436 | goto skip_optional_kwonly; |
437 | } |
438 | } |
439 | follow_symlinks = PyObject_IsTrue(args[3]); |
440 | if (follow_symlinks < 0) { Branch (440:9): [True: 0, False: 8.64k]
|
441 | goto exit; |
442 | } |
443 | skip_optional_kwonly: |
444 | return_value = os_chmod_impl(module, &path, mode, dir_fd, follow_symlinks); |
445 | |
446 | exit: |
447 | /* Cleanup for path */ |
448 | path_cleanup(&path); |
449 | |
450 | return return_value; |
451 | } |
452 | |
453 | #if defined(HAVE_FCHMOD) |
454 | |
455 | PyDoc_STRVAR(os_fchmod__doc__, |
456 | "fchmod($module, /, fd, mode)\n" |
457 | "--\n" |
458 | "\n" |
459 | "Change the access permissions of the file given by file descriptor fd.\n" |
460 | "\n" |
461 | "Equivalent to os.chmod(fd, mode)."); |
462 | |
463 | #define OS_FCHMOD_METHODDEF \ |
464 | {"fchmod", _PyCFunction_CAST(os_fchmod), METH_FASTCALL|METH_KEYWORDS, os_fchmod__doc__}, |
465 | |
466 | static PyObject * |
467 | os_fchmod_impl(PyObject *module, int fd, int mode); |
468 | |
469 | static PyObject * |
470 | os_fchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
471 | { |
472 | PyObject *return_value = NULL; |
473 | static const char * const _keywords[] = {"fd", "mode", NULL}; |
474 | static _PyArg_Parser _parser = {NULL, _keywords, "fchmod", 0}; |
475 | PyObject *argsbuf[2]; |
476 | int fd; |
477 | int mode; |
478 | |
479 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
480 | if (!args) { Branch (480:9): [True: 0, False: 1]
|
481 | goto exit; |
482 | } |
483 | fd = _PyLong_AsInt(args[0]); |
484 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (484:9): [True: 0, False: 1]
Branch (484:21): [True: 0, False: 0]
|
485 | goto exit; |
486 | } |
487 | mode = _PyLong_AsInt(args[1]); |
488 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (488:9): [True: 0, False: 1]
Branch (488:23): [True: 0, False: 0]
|
489 | goto exit; |
490 | } |
491 | return_value = os_fchmod_impl(module, fd, mode); |
492 | |
493 | exit: |
494 | return return_value; |
495 | } |
496 | |
497 | #endif /* defined(HAVE_FCHMOD) */ |
498 | |
499 | #if defined(HAVE_LCHMOD) |
500 | |
501 | PyDoc_STRVAR(os_lchmod__doc__, |
502 | "lchmod($module, /, path, mode)\n" |
503 | "--\n" |
504 | "\n" |
505 | "Change the access permissions of a file, without following symbolic links.\n" |
506 | "\n" |
507 | "If path is a symlink, this affects the link itself rather than the target.\n" |
508 | "Equivalent to chmod(path, mode, follow_symlinks=False).\""); |
509 | |
510 | #define OS_LCHMOD_METHODDEF \ |
511 | {"lchmod", _PyCFunction_CAST(os_lchmod), METH_FASTCALL|METH_KEYWORDS, os_lchmod__doc__}, |
512 | |
513 | static PyObject * |
514 | os_lchmod_impl(PyObject *module, path_t *path, int mode); |
515 | |
516 | static PyObject * |
517 | os_lchmod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
518 | { |
519 | PyObject *return_value = NULL; |
520 | static const char * const _keywords[] = {"path", "mode", NULL}; |
521 | static _PyArg_Parser _parser = {NULL, _keywords, "lchmod", 0}; |
522 | PyObject *argsbuf[2]; |
523 | path_t path = PATH_T_INITIALIZE("lchmod", "path", 0, 0); |
524 | int mode; |
525 | |
526 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
527 | if (!args) { |
528 | goto exit; |
529 | } |
530 | if (!path_converter(args[0], &path)) { |
531 | goto exit; |
532 | } |
533 | mode = _PyLong_AsInt(args[1]); |
534 | if (mode == -1 && PyErr_Occurred()) { |
535 | goto exit; |
536 | } |
537 | return_value = os_lchmod_impl(module, &path, mode); |
538 | |
539 | exit: |
540 | /* Cleanup for path */ |
541 | path_cleanup(&path); |
542 | |
543 | return return_value; |
544 | } |
545 | |
546 | #endif /* defined(HAVE_LCHMOD) */ |
547 | |
548 | #if defined(HAVE_CHFLAGS) |
549 | |
550 | PyDoc_STRVAR(os_chflags__doc__, |
551 | "chflags($module, /, path, flags, follow_symlinks=True)\n" |
552 | "--\n" |
553 | "\n" |
554 | "Set file flags.\n" |
555 | "\n" |
556 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
557 | " link, chflags will change flags on the symbolic link itself instead of the\n" |
558 | " file the link points to.\n" |
559 | "follow_symlinks may not be implemented on your platform. If it is\n" |
560 | "unavailable, using it will raise a NotImplementedError."); |
561 | |
562 | #define OS_CHFLAGS_METHODDEF \ |
563 | {"chflags", _PyCFunction_CAST(os_chflags), METH_FASTCALL|METH_KEYWORDS, os_chflags__doc__}, |
564 | |
565 | static PyObject * |
566 | os_chflags_impl(PyObject *module, path_t *path, unsigned long flags, |
567 | int follow_symlinks); |
568 | |
569 | static PyObject * |
570 | os_chflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
571 | { |
572 | PyObject *return_value = NULL; |
573 | static const char * const _keywords[] = {"path", "flags", "follow_symlinks", NULL}; |
574 | static _PyArg_Parser _parser = {NULL, _keywords, "chflags", 0}; |
575 | PyObject *argsbuf[3]; |
576 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 2; |
577 | path_t path = PATH_T_INITIALIZE("chflags", "path", 0, 0); |
578 | unsigned long flags; |
579 | int follow_symlinks = 1; |
580 | |
581 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); |
582 | if (!args) { |
583 | goto exit; |
584 | } |
585 | if (!path_converter(args[0], &path)) { |
586 | goto exit; |
587 | } |
588 | if (!PyLong_Check(args[1])) { |
589 | _PyArg_BadArgument("chflags", "argument 'flags'", "int", args[1]); |
590 | goto exit; |
591 | } |
592 | flags = PyLong_AsUnsignedLongMask(args[1]); |
593 | if (!noptargs) { |
594 | goto skip_optional_pos; |
595 | } |
596 | follow_symlinks = PyObject_IsTrue(args[2]); |
597 | if (follow_symlinks < 0) { |
598 | goto exit; |
599 | } |
600 | skip_optional_pos: |
601 | return_value = os_chflags_impl(module, &path, flags, follow_symlinks); |
602 | |
603 | exit: |
604 | /* Cleanup for path */ |
605 | path_cleanup(&path); |
606 | |
607 | return return_value; |
608 | } |
609 | |
610 | #endif /* defined(HAVE_CHFLAGS) */ |
611 | |
612 | #if defined(HAVE_LCHFLAGS) |
613 | |
614 | PyDoc_STRVAR(os_lchflags__doc__, |
615 | "lchflags($module, /, path, flags)\n" |
616 | "--\n" |
617 | "\n" |
618 | "Set file flags.\n" |
619 | "\n" |
620 | "This function will not follow symbolic links.\n" |
621 | "Equivalent to chflags(path, flags, follow_symlinks=False)."); |
622 | |
623 | #define OS_LCHFLAGS_METHODDEF \ |
624 | {"lchflags", _PyCFunction_CAST(os_lchflags), METH_FASTCALL|METH_KEYWORDS, os_lchflags__doc__}, |
625 | |
626 | static PyObject * |
627 | os_lchflags_impl(PyObject *module, path_t *path, unsigned long flags); |
628 | |
629 | static PyObject * |
630 | os_lchflags(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
631 | { |
632 | PyObject *return_value = NULL; |
633 | static const char * const _keywords[] = {"path", "flags", NULL}; |
634 | static _PyArg_Parser _parser = {NULL, _keywords, "lchflags", 0}; |
635 | PyObject *argsbuf[2]; |
636 | path_t path = PATH_T_INITIALIZE("lchflags", "path", 0, 0); |
637 | unsigned long flags; |
638 | |
639 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
640 | if (!args) { |
641 | goto exit; |
642 | } |
643 | if (!path_converter(args[0], &path)) { |
644 | goto exit; |
645 | } |
646 | if (!PyLong_Check(args[1])) { |
647 | _PyArg_BadArgument("lchflags", "argument 'flags'", "int", args[1]); |
648 | goto exit; |
649 | } |
650 | flags = PyLong_AsUnsignedLongMask(args[1]); |
651 | return_value = os_lchflags_impl(module, &path, flags); |
652 | |
653 | exit: |
654 | /* Cleanup for path */ |
655 | path_cleanup(&path); |
656 | |
657 | return return_value; |
658 | } |
659 | |
660 | #endif /* defined(HAVE_LCHFLAGS) */ |
661 | |
662 | #if defined(HAVE_CHROOT) |
663 | |
664 | PyDoc_STRVAR(os_chroot__doc__, |
665 | "chroot($module, /, path)\n" |
666 | "--\n" |
667 | "\n" |
668 | "Change root directory to path."); |
669 | |
670 | #define OS_CHROOT_METHODDEF \ |
671 | {"chroot", _PyCFunction_CAST(os_chroot), METH_FASTCALL|METH_KEYWORDS, os_chroot__doc__}, |
672 | |
673 | static PyObject * |
674 | os_chroot_impl(PyObject *module, path_t *path); |
675 | |
676 | static PyObject * |
677 | os_chroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
678 | { |
679 | PyObject *return_value = NULL; |
680 | static const char * const _keywords[] = {"path", NULL}; |
681 | static _PyArg_Parser _parser = {NULL, _keywords, "chroot", 0}; |
682 | PyObject *argsbuf[1]; |
683 | path_t path = PATH_T_INITIALIZE("chroot", "path", 0, 0); |
684 | |
685 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
686 | if (!args) { Branch (686:9): [True: 0, False: 5]
|
687 | goto exit; |
688 | } |
689 | if (!path_converter(args[0], &path)) { Branch (689:9): [True: 0, False: 5]
|
690 | goto exit; |
691 | } |
692 | return_value = os_chroot_impl(module, &path); |
693 | |
694 | exit: |
695 | /* Cleanup for path */ |
696 | path_cleanup(&path); |
697 | |
698 | return return_value; |
699 | } |
700 | |
701 | #endif /* defined(HAVE_CHROOT) */ |
702 | |
703 | #if defined(HAVE_FSYNC) |
704 | |
705 | PyDoc_STRVAR(os_fsync__doc__, |
706 | "fsync($module, /, fd)\n" |
707 | "--\n" |
708 | "\n" |
709 | "Force write of fd to disk."); |
710 | |
711 | #define OS_FSYNC_METHODDEF \ |
712 | {"fsync", _PyCFunction_CAST(os_fsync), METH_FASTCALL|METH_KEYWORDS, os_fsync__doc__}, |
713 | |
714 | static PyObject * |
715 | os_fsync_impl(PyObject *module, int fd); |
716 | |
717 | static PyObject * |
718 | os_fsync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
719 | { |
720 | PyObject *return_value = NULL; |
721 | static const char * const _keywords[] = {"fd", NULL}; |
722 | static _PyArg_Parser _parser = {NULL, _keywords, "fsync", 0}; |
723 | PyObject *argsbuf[1]; |
724 | int fd; |
725 | |
726 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
727 | if (!args) { Branch (727:9): [True: 0, False: 543]
|
728 | goto exit; |
729 | } |
730 | if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { Branch (730:9): [True: 0, False: 543]
|
731 | goto exit; |
732 | } |
733 | return_value = os_fsync_impl(module, fd); |
734 | |
735 | exit: |
736 | return return_value; |
737 | } |
738 | |
739 | #endif /* defined(HAVE_FSYNC) */ |
740 | |
741 | #if defined(HAVE_SYNC) |
742 | |
743 | PyDoc_STRVAR(os_sync__doc__, |
744 | "sync($module, /)\n" |
745 | "--\n" |
746 | "\n" |
747 | "Force write of everything to disk."); |
748 | |
749 | #define OS_SYNC_METHODDEF \ |
750 | {"sync", (PyCFunction)os_sync, METH_NOARGS, os_sync__doc__}, |
751 | |
752 | static PyObject * |
753 | os_sync_impl(PyObject *module); |
754 | |
755 | static PyObject * |
756 | os_sync(PyObject *module, PyObject *Py_UNUSED(ignored)) |
757 | { |
758 | return os_sync_impl(module); |
759 | } |
760 | |
761 | #endif /* defined(HAVE_SYNC) */ |
762 | |
763 | #if defined(HAVE_FDATASYNC) |
764 | |
765 | PyDoc_STRVAR(os_fdatasync__doc__, |
766 | "fdatasync($module, /, fd)\n" |
767 | "--\n" |
768 | "\n" |
769 | "Force write of fd to disk without forcing update of metadata."); |
770 | |
771 | #define OS_FDATASYNC_METHODDEF \ |
772 | {"fdatasync", _PyCFunction_CAST(os_fdatasync), METH_FASTCALL|METH_KEYWORDS, os_fdatasync__doc__}, |
773 | |
774 | static PyObject * |
775 | os_fdatasync_impl(PyObject *module, int fd); |
776 | |
777 | static PyObject * |
778 | os_fdatasync(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
779 | { |
780 | PyObject *return_value = NULL; |
781 | static const char * const _keywords[] = {"fd", NULL}; |
782 | static _PyArg_Parser _parser = {NULL, _keywords, "fdatasync", 0}; |
783 | PyObject *argsbuf[1]; |
784 | int fd; |
785 | |
786 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
787 | if (!args) { Branch (787:9): [True: 0, False: 1]
|
788 | goto exit; |
789 | } |
790 | if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { Branch (790:9): [True: 0, False: 1]
|
791 | goto exit; |
792 | } |
793 | return_value = os_fdatasync_impl(module, fd); |
794 | |
795 | exit: |
796 | return return_value; |
797 | } |
798 | |
799 | #endif /* defined(HAVE_FDATASYNC) */ |
800 | |
801 | #if defined(HAVE_CHOWN) |
802 | |
803 | PyDoc_STRVAR(os_chown__doc__, |
804 | "chown($module, /, path, uid, gid, *, dir_fd=None, follow_symlinks=True)\n" |
805 | "--\n" |
806 | "\n" |
807 | "Change the owner and group id of path to the numeric uid and gid.\\\n" |
808 | "\n" |
809 | " path\n" |
810 | " Path to be examined; can be string, bytes, a path-like object, or open-file-descriptor int.\n" |
811 | " dir_fd\n" |
812 | " If not None, it should be a file descriptor open to a directory,\n" |
813 | " and path should be relative; path will then be relative to that\n" |
814 | " directory.\n" |
815 | " follow_symlinks\n" |
816 | " If False, and the last element of the path is a symbolic link,\n" |
817 | " stat will examine the symbolic link itself instead of the file\n" |
818 | " the link points to.\n" |
819 | "\n" |
820 | "path may always be specified as a string.\n" |
821 | "On some platforms, path may also be specified as an open file descriptor.\n" |
822 | " If this functionality is unavailable, using it raises an exception.\n" |
823 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
824 | " and path should be relative; path will then be relative to that directory.\n" |
825 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
826 | " link, chown will modify the symbolic link itself instead of the file the\n" |
827 | " link points to.\n" |
828 | "It is an error to use dir_fd or follow_symlinks when specifying path as\n" |
829 | " an open file descriptor.\n" |
830 | "dir_fd and follow_symlinks may not be implemented on your platform.\n" |
831 | " If they are unavailable, using them will raise a NotImplementedError."); |
832 | |
833 | #define OS_CHOWN_METHODDEF \ |
834 | {"chown", _PyCFunction_CAST(os_chown), METH_FASTCALL|METH_KEYWORDS, os_chown__doc__}, |
835 | |
836 | static PyObject * |
837 | os_chown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid, |
838 | int dir_fd, int follow_symlinks); |
839 | |
840 | static PyObject * |
841 | os_chown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
842 | { |
843 | PyObject *return_value = NULL; |
844 | static const char * const _keywords[] = {"path", "uid", "gid", "dir_fd", "follow_symlinks", NULL}; |
845 | static _PyArg_Parser _parser = {NULL, _keywords, "chown", 0}; |
846 | PyObject *argsbuf[5]; |
847 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 041 ) - 3; Branch (847:36): [True: 1, False: 41]
|
848 | path_t path = PATH_T_INITIALIZE("chown", "path", 0, PATH_HAVE_FCHOWN); |
849 | uid_t uid; |
850 | gid_t gid; |
851 | int dir_fd = DEFAULT_DIR_FD; |
852 | int follow_symlinks = 1; |
853 | |
854 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
855 | if (!args) { Branch (855:9): [True: 0, False: 42]
|
856 | goto exit; |
857 | } |
858 | if (!path_converter(args[0], &path)) { Branch (858:9): [True: 0, False: 42]
|
859 | goto exit; |
860 | } |
861 | if (!_Py_Uid_Converter(args[1], &uid)) { Branch (861:9): [True: 8, False: 34]
|
862 | goto exit; |
863 | } |
864 | if (!_Py_Gid_Converter(args[2], &gid)) { Branch (864:9): [True: 6, False: 28]
|
865 | goto exit; |
866 | } |
867 | if (!noptargs) { Branch (867:9): [True: 27, False: 1]
|
868 | goto skip_optional_kwonly; |
869 | } |
870 | if (args[3]) { Branch (870:9): [True: 1, False: 0]
|
871 | if (!FCHOWNAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { Branch (871:13): [True: 0, False: 1]
|
872 | goto exit; |
873 | } |
874 | if (!--noptargs) { Branch (874:13): [True: 1, False: 0]
|
875 | goto skip_optional_kwonly; |
876 | } |
877 | } |
878 | follow_symlinks = PyObject_IsTrue(args[4]); |
879 | if (follow_symlinks < 0) { Branch (879:9): [True: 0, False: 0]
|
880 | goto exit; |
881 | } |
882 | skip_optional_kwonly: |
883 | return_value = os_chown_impl(module, &path, uid, gid, dir_fd, follow_symlinks); |
884 | |
885 | exit: |
886 | /* Cleanup for path */ |
887 | path_cleanup(&path); |
888 | |
889 | return return_value; |
890 | } |
891 | |
892 | #endif /* defined(HAVE_CHOWN) */ |
893 | |
894 | #if defined(HAVE_FCHOWN) |
895 | |
896 | PyDoc_STRVAR(os_fchown__doc__, |
897 | "fchown($module, /, fd, uid, gid)\n" |
898 | "--\n" |
899 | "\n" |
900 | "Change the owner and group id of the file specified by file descriptor.\n" |
901 | "\n" |
902 | "Equivalent to os.chown(fd, uid, gid)."); |
903 | |
904 | #define OS_FCHOWN_METHODDEF \ |
905 | {"fchown", _PyCFunction_CAST(os_fchown), METH_FASTCALL|METH_KEYWORDS, os_fchown__doc__}, |
906 | |
907 | static PyObject * |
908 | os_fchown_impl(PyObject *module, int fd, uid_t uid, gid_t gid); |
909 | |
910 | static PyObject * |
911 | os_fchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
912 | { |
913 | PyObject *return_value = NULL; |
914 | static const char * const _keywords[] = {"fd", "uid", "gid", NULL}; |
915 | static _PyArg_Parser _parser = {NULL, _keywords, "fchown", 0}; |
916 | PyObject *argsbuf[3]; |
917 | int fd; |
918 | uid_t uid; |
919 | gid_t gid; |
920 | |
921 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
922 | if (!args) { Branch (922:9): [True: 0, False: 11]
|
923 | goto exit; |
924 | } |
925 | fd = _PyLong_AsInt(args[0]); |
926 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (926:9): [True: 0, False: 11]
Branch (926:21): [True: 0, False: 0]
|
927 | goto exit; |
928 | } |
929 | if (!_Py_Uid_Converter(args[1], &uid)) { Branch (929:9): [True: 2, False: 9]
|
930 | goto exit; |
931 | } |
932 | if (!_Py_Gid_Converter(args[2], &gid)) { Branch (932:9): [True: 2, False: 7]
|
933 | goto exit; |
934 | } |
935 | return_value = os_fchown_impl(module, fd, uid, gid); |
936 | |
937 | exit: |
938 | return return_value; |
939 | } |
940 | |
941 | #endif /* defined(HAVE_FCHOWN) */ |
942 | |
943 | #if defined(HAVE_LCHOWN) |
944 | |
945 | PyDoc_STRVAR(os_lchown__doc__, |
946 | "lchown($module, /, path, uid, gid)\n" |
947 | "--\n" |
948 | "\n" |
949 | "Change the owner and group id of path to the numeric uid and gid.\n" |
950 | "\n" |
951 | "This function will not follow symbolic links.\n" |
952 | "Equivalent to os.chown(path, uid, gid, follow_symlinks=False)."); |
953 | |
954 | #define OS_LCHOWN_METHODDEF \ |
955 | {"lchown", _PyCFunction_CAST(os_lchown), METH_FASTCALL|METH_KEYWORDS, os_lchown__doc__}, |
956 | |
957 | static PyObject * |
958 | os_lchown_impl(PyObject *module, path_t *path, uid_t uid, gid_t gid); |
959 | |
960 | static PyObject * |
961 | os_lchown(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
962 | { |
963 | PyObject *return_value = NULL; |
964 | static const char * const _keywords[] = {"path", "uid", "gid", NULL}; |
965 | static _PyArg_Parser _parser = {NULL, _keywords, "lchown", 0}; |
966 | PyObject *argsbuf[3]; |
967 | path_t path = PATH_T_INITIALIZE("lchown", "path", 0, 0); |
968 | uid_t uid; |
969 | gid_t gid; |
970 | |
971 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
972 | if (!args) { Branch (972:9): [True: 0, False: 15]
|
973 | goto exit; |
974 | } |
975 | if (!path_converter(args[0], &path)) { Branch (975:9): [True: 0, False: 15]
|
976 | goto exit; |
977 | } |
978 | if (!_Py_Uid_Converter(args[1], &uid)) { Branch (978:9): [True: 2, False: 13]
|
979 | goto exit; |
980 | } |
981 | if (!_Py_Gid_Converter(args[2], &gid)) { Branch (981:9): [True: 2, False: 11]
|
982 | goto exit; |
983 | } |
984 | return_value = os_lchown_impl(module, &path, uid, gid); |
985 | |
986 | exit: |
987 | /* Cleanup for path */ |
988 | path_cleanup(&path); |
989 | |
990 | return return_value; |
991 | } |
992 | |
993 | #endif /* defined(HAVE_LCHOWN) */ |
994 | |
995 | PyDoc_STRVAR(os_getcwd__doc__, |
996 | "getcwd($module, /)\n" |
997 | "--\n" |
998 | "\n" |
999 | "Return a unicode string representing the current working directory."); |
1000 | |
1001 | #define OS_GETCWD_METHODDEF \ |
1002 | {"getcwd", (PyCFunction)os_getcwd, METH_NOARGS, os_getcwd__doc__}, |
1003 | |
1004 | static PyObject * |
1005 | os_getcwd_impl(PyObject *module); |
1006 | |
1007 | static PyObject * |
1008 | os_getcwd(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1009 | { |
1010 | return os_getcwd_impl(module); |
1011 | } |
1012 | |
1013 | PyDoc_STRVAR(os_getcwdb__doc__, |
1014 | "getcwdb($module, /)\n" |
1015 | "--\n" |
1016 | "\n" |
1017 | "Return a bytes string representing the current working directory."); |
1018 | |
1019 | #define OS_GETCWDB_METHODDEF \ |
1020 | {"getcwdb", (PyCFunction)os_getcwdb, METH_NOARGS, os_getcwdb__doc__}, |
1021 | |
1022 | static PyObject * |
1023 | os_getcwdb_impl(PyObject *module); |
1024 | |
1025 | static PyObject * |
1026 | os_getcwdb(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1027 | { |
1028 | return os_getcwdb_impl(module); |
1029 | } |
1030 | |
1031 | #if defined(HAVE_LINK) |
1032 | |
1033 | PyDoc_STRVAR(os_link__doc__, |
1034 | "link($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None,\n" |
1035 | " follow_symlinks=True)\n" |
1036 | "--\n" |
1037 | "\n" |
1038 | "Create a hard link to a file.\n" |
1039 | "\n" |
1040 | "If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" |
1041 | " descriptor open to a directory, and the respective path string (src or dst)\n" |
1042 | " should be relative; the path will then be relative to that directory.\n" |
1043 | "If follow_symlinks is False, and the last element of src is a symbolic\n" |
1044 | " link, link will create a link to the symbolic link itself instead of the\n" |
1045 | " file the link points to.\n" |
1046 | "src_dir_fd, dst_dir_fd, and follow_symlinks may not be implemented on your\n" |
1047 | " platform. If they are unavailable, using them will raise a\n" |
1048 | " NotImplementedError."); |
1049 | |
1050 | #define OS_LINK_METHODDEF \ |
1051 | {"link", _PyCFunction_CAST(os_link), METH_FASTCALL|METH_KEYWORDS, os_link__doc__}, |
1052 | |
1053 | static PyObject * |
1054 | os_link_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, |
1055 | int dst_dir_fd, int follow_symlinks); |
1056 | |
1057 | static PyObject * |
1058 | os_link(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1059 | { |
1060 | PyObject *return_value = NULL; |
1061 | static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", "follow_symlinks", NULL}; |
1062 | static _PyArg_Parser _parser = {NULL, _keywords, "link", 0}; |
1063 | PyObject *argsbuf[5]; |
1064 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 0311 ) - 2; Branch (1064:36): [True: 1, False: 311]
|
1065 | path_t src = PATH_T_INITIALIZE("link", "src", 0, 0); |
1066 | path_t dst = PATH_T_INITIALIZE("link", "dst", 0, 0); |
1067 | int src_dir_fd = DEFAULT_DIR_FD; |
1068 | int dst_dir_fd = DEFAULT_DIR_FD; |
1069 | int follow_symlinks = 1; |
1070 | |
1071 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
1072 | if (!args) { Branch (1072:9): [True: 0, False: 312]
|
1073 | goto exit; |
1074 | } |
1075 | if (!path_converter(args[0], &src)) { Branch (1075:9): [True: 0, False: 312]
|
1076 | goto exit; |
1077 | } |
1078 | if (!path_converter(args[1], &dst)) { Branch (1078:9): [True: 0, False: 312]
|
1079 | goto exit; |
1080 | } |
1081 | if (!noptargs) { Branch (1081:9): [True: 311, False: 1]
|
1082 | goto skip_optional_kwonly; |
1083 | } |
1084 | if (args[2]) { Branch (1084:9): [True: 1, False: 0]
|
1085 | if (!dir_fd_converter(args[2], &src_dir_fd)) { Branch (1085:13): [True: 0, False: 1]
|
1086 | goto exit; |
1087 | } |
1088 | if (!--noptargs) { Branch (1088:13): [True: 0, False: 1]
|
1089 | goto skip_optional_kwonly; |
1090 | } |
1091 | } |
1092 | if (args[3]) { Branch (1092:9): [True: 1, False: 0]
|
1093 | if (!dir_fd_converter(args[3], &dst_dir_fd)) { Branch (1093:13): [True: 0, False: 1]
|
1094 | goto exit; |
1095 | } |
1096 | if (!--noptargs) { Branch (1096:13): [True: 1, False: 0]
|
1097 | goto skip_optional_kwonly; |
1098 | } |
1099 | } |
1100 | follow_symlinks = PyObject_IsTrue(args[4]); |
1101 | if (follow_symlinks < 0) { Branch (1101:9): [True: 0, False: 0]
|
1102 | goto exit; |
1103 | } |
1104 | skip_optional_kwonly: |
1105 | return_value = os_link_impl(module, &src, &dst, src_dir_fd, dst_dir_fd, follow_symlinks); |
1106 | |
1107 | exit: |
1108 | /* Cleanup for src */ |
1109 | path_cleanup(&src); |
1110 | /* Cleanup for dst */ |
1111 | path_cleanup(&dst); |
1112 | |
1113 | return return_value; |
1114 | } |
1115 | |
1116 | #endif /* defined(HAVE_LINK) */ |
1117 | |
1118 | PyDoc_STRVAR(os_listdir__doc__, |
1119 | "listdir($module, /, path=None)\n" |
1120 | "--\n" |
1121 | "\n" |
1122 | "Return a list containing the names of the files in the directory.\n" |
1123 | "\n" |
1124 | "path can be specified as either str, bytes, or a path-like object. If path is bytes,\n" |
1125 | " the filenames returned will also be bytes; in all other circumstances\n" |
1126 | " the filenames returned will be str.\n" |
1127 | "If path is None, uses the path=\'.\'.\n" |
1128 | "On some platforms, path may also be specified as an open file descriptor;\\\n" |
1129 | " the file descriptor must refer to a directory.\n" |
1130 | " If this functionality is unavailable, using it raises NotImplementedError.\n" |
1131 | "\n" |
1132 | "The list is in arbitrary order. It does not include the special\n" |
1133 | "entries \'.\' and \'..\' even if they are present in the directory."); |
1134 | |
1135 | #define OS_LISTDIR_METHODDEF \ |
1136 | {"listdir", _PyCFunction_CAST(os_listdir), METH_FASTCALL|METH_KEYWORDS, os_listdir__doc__}, |
1137 | |
1138 | static PyObject * |
1139 | os_listdir_impl(PyObject *module, path_t *path); |
1140 | |
1141 | static PyObject * |
1142 | os_listdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1143 | { |
1144 | PyObject *return_value = NULL; |
1145 | static const char * const _keywords[] = {"path", NULL}; |
1146 | static _PyArg_Parser _parser = {NULL, _keywords, "listdir", 0}; |
1147 | PyObject *argsbuf[1]; |
1148 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 0; Branch (1148:36): [True: 0, False: 7.17k]
|
1149 | path_t path = PATH_T_INITIALIZE("listdir", "path", 1, PATH_HAVE_FDOPENDIR); |
1150 | |
1151 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
1152 | if (!args) { Branch (1152:9): [True: 0, False: 7.17k]
|
1153 | goto exit; |
1154 | } |
1155 | if (!noptargs) { Branch (1155:9): [True: 1.70k, False: 5.46k]
|
1156 | goto skip_optional_pos; |
1157 | } |
1158 | if (!path_converter(args[0], &path)) { Branch (1158:9): [True: 0, False: 5.46k]
|
1159 | goto exit; |
1160 | } |
1161 | skip_optional_pos: |
1162 | return_value = os_listdir_impl(module, &path); |
1163 | |
1164 | exit: |
1165 | /* Cleanup for path */ |
1166 | path_cleanup(&path); |
1167 | |
1168 | return return_value; |
1169 | } |
1170 | |
1171 | #if defined(MS_WINDOWS) |
1172 | |
1173 | PyDoc_STRVAR(os__getfullpathname__doc__, |
1174 | "_getfullpathname($module, path, /)\n" |
1175 | "--\n" |
1176 | "\n"); |
1177 | |
1178 | #define OS__GETFULLPATHNAME_METHODDEF \ |
1179 | {"_getfullpathname", (PyCFunction)os__getfullpathname, METH_O, os__getfullpathname__doc__}, |
1180 | |
1181 | static PyObject * |
1182 | os__getfullpathname_impl(PyObject *module, path_t *path); |
1183 | |
1184 | static PyObject * |
1185 | os__getfullpathname(PyObject *module, PyObject *arg) |
1186 | { |
1187 | PyObject *return_value = NULL; |
1188 | path_t path = PATH_T_INITIALIZE("_getfullpathname", "path", 0, 0); |
1189 | |
1190 | if (!path_converter(arg, &path)) { |
1191 | goto exit; |
1192 | } |
1193 | return_value = os__getfullpathname_impl(module, &path); |
1194 | |
1195 | exit: |
1196 | /* Cleanup for path */ |
1197 | path_cleanup(&path); |
1198 | |
1199 | return return_value; |
1200 | } |
1201 | |
1202 | #endif /* defined(MS_WINDOWS) */ |
1203 | |
1204 | #if defined(MS_WINDOWS) |
1205 | |
1206 | PyDoc_STRVAR(os__getfinalpathname__doc__, |
1207 | "_getfinalpathname($module, path, /)\n" |
1208 | "--\n" |
1209 | "\n" |
1210 | "A helper function for samepath on windows."); |
1211 | |
1212 | #define OS__GETFINALPATHNAME_METHODDEF \ |
1213 | {"_getfinalpathname", (PyCFunction)os__getfinalpathname, METH_O, os__getfinalpathname__doc__}, |
1214 | |
1215 | static PyObject * |
1216 | os__getfinalpathname_impl(PyObject *module, path_t *path); |
1217 | |
1218 | static PyObject * |
1219 | os__getfinalpathname(PyObject *module, PyObject *arg) |
1220 | { |
1221 | PyObject *return_value = NULL; |
1222 | path_t path = PATH_T_INITIALIZE("_getfinalpathname", "path", 0, 0); |
1223 | |
1224 | if (!path_converter(arg, &path)) { |
1225 | goto exit; |
1226 | } |
1227 | return_value = os__getfinalpathname_impl(module, &path); |
1228 | |
1229 | exit: |
1230 | /* Cleanup for path */ |
1231 | path_cleanup(&path); |
1232 | |
1233 | return return_value; |
1234 | } |
1235 | |
1236 | #endif /* defined(MS_WINDOWS) */ |
1237 | |
1238 | #if defined(MS_WINDOWS) |
1239 | |
1240 | PyDoc_STRVAR(os__getvolumepathname__doc__, |
1241 | "_getvolumepathname($module, /, path)\n" |
1242 | "--\n" |
1243 | "\n" |
1244 | "A helper function for ismount on Win32."); |
1245 | |
1246 | #define OS__GETVOLUMEPATHNAME_METHODDEF \ |
1247 | {"_getvolumepathname", _PyCFunction_CAST(os__getvolumepathname), METH_FASTCALL|METH_KEYWORDS, os__getvolumepathname__doc__}, |
1248 | |
1249 | static PyObject * |
1250 | os__getvolumepathname_impl(PyObject *module, path_t *path); |
1251 | |
1252 | static PyObject * |
1253 | os__getvolumepathname(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1254 | { |
1255 | PyObject *return_value = NULL; |
1256 | static const char * const _keywords[] = {"path", NULL}; |
1257 | static _PyArg_Parser _parser = {NULL, _keywords, "_getvolumepathname", 0}; |
1258 | PyObject *argsbuf[1]; |
1259 | path_t path = PATH_T_INITIALIZE("_getvolumepathname", "path", 0, 0); |
1260 | |
1261 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1262 | if (!args) { |
1263 | goto exit; |
1264 | } |
1265 | if (!path_converter(args[0], &path)) { |
1266 | goto exit; |
1267 | } |
1268 | return_value = os__getvolumepathname_impl(module, &path); |
1269 | |
1270 | exit: |
1271 | /* Cleanup for path */ |
1272 | path_cleanup(&path); |
1273 | |
1274 | return return_value; |
1275 | } |
1276 | |
1277 | #endif /* defined(MS_WINDOWS) */ |
1278 | |
1279 | #if defined(MS_WINDOWS) |
1280 | |
1281 | PyDoc_STRVAR(os__path_splitroot__doc__, |
1282 | "_path_splitroot($module, /, path)\n" |
1283 | "--\n" |
1284 | "\n" |
1285 | "Removes everything after the root on Win32."); |
1286 | |
1287 | #define OS__PATH_SPLITROOT_METHODDEF \ |
1288 | {"_path_splitroot", _PyCFunction_CAST(os__path_splitroot), METH_FASTCALL|METH_KEYWORDS, os__path_splitroot__doc__}, |
1289 | |
1290 | static PyObject * |
1291 | os__path_splitroot_impl(PyObject *module, path_t *path); |
1292 | |
1293 | static PyObject * |
1294 | os__path_splitroot(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1295 | { |
1296 | PyObject *return_value = NULL; |
1297 | static const char * const _keywords[] = {"path", NULL}; |
1298 | static _PyArg_Parser _parser = {NULL, _keywords, "_path_splitroot", 0}; |
1299 | PyObject *argsbuf[1]; |
1300 | path_t path = PATH_T_INITIALIZE("_path_splitroot", "path", 0, 0); |
1301 | |
1302 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1303 | if (!args) { |
1304 | goto exit; |
1305 | } |
1306 | if (!path_converter(args[0], &path)) { |
1307 | goto exit; |
1308 | } |
1309 | return_value = os__path_splitroot_impl(module, &path); |
1310 | |
1311 | exit: |
1312 | /* Cleanup for path */ |
1313 | path_cleanup(&path); |
1314 | |
1315 | return return_value; |
1316 | } |
1317 | |
1318 | #endif /* defined(MS_WINDOWS) */ |
1319 | |
1320 | PyDoc_STRVAR(os__path_normpath__doc__, |
1321 | "_path_normpath($module, /, path)\n" |
1322 | "--\n" |
1323 | "\n" |
1324 | "Basic path normalization."); |
1325 | |
1326 | #define OS__PATH_NORMPATH_METHODDEF \ |
1327 | {"_path_normpath", _PyCFunction_CAST(os__path_normpath), METH_FASTCALL|METH_KEYWORDS, os__path_normpath__doc__}, |
1328 | |
1329 | static PyObject * |
1330 | os__path_normpath_impl(PyObject *module, PyObject *path); |
1331 | |
1332 | static PyObject * |
1333 | os__path_normpath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1334 | { |
1335 | PyObject *return_value = NULL; |
1336 | static const char * const _keywords[] = {"path", NULL}; |
1337 | static _PyArg_Parser _parser = {NULL, _keywords, "_path_normpath", 0}; |
1338 | PyObject *argsbuf[1]; |
1339 | PyObject *path; |
1340 | |
1341 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1342 | if (!args) { Branch (1342:9): [True: 0, False: 25.3k]
|
1343 | goto exit; |
1344 | } |
1345 | path = args[0]; |
1346 | return_value = os__path_normpath_impl(module, path); |
1347 | |
1348 | exit: |
1349 | return return_value; |
1350 | } |
1351 | |
1352 | PyDoc_STRVAR(os_mkdir__doc__, |
1353 | "mkdir($module, /, path, mode=511, *, dir_fd=None)\n" |
1354 | "--\n" |
1355 | "\n" |
1356 | "Create a directory.\n" |
1357 | "\n" |
1358 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
1359 | " and path should be relative; path will then be relative to that directory.\n" |
1360 | "dir_fd may not be implemented on your platform.\n" |
1361 | " If it is unavailable, using it will raise a NotImplementedError.\n" |
1362 | "\n" |
1363 | "The mode argument is ignored on Windows."); |
1364 | |
1365 | #define OS_MKDIR_METHODDEF \ |
1366 | {"mkdir", _PyCFunction_CAST(os_mkdir), METH_FASTCALL|METH_KEYWORDS, os_mkdir__doc__}, |
1367 | |
1368 | static PyObject * |
1369 | os_mkdir_impl(PyObject *module, path_t *path, int mode, int dir_fd); |
1370 | |
1371 | static PyObject * |
1372 | os_mkdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1373 | { |
1374 | PyObject *return_value = NULL; |
1375 | static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; |
1376 | static _PyArg_Parser _parser = {NULL, _keywords, "mkdir", 0}; |
1377 | PyObject *argsbuf[3]; |
1378 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 08.20k ) - 1; Branch (1378:36): [True: 1, False: 8.20k]
|
1379 | path_t path = PATH_T_INITIALIZE("mkdir", "path", 0, 0); |
1380 | int mode = 511; |
1381 | int dir_fd = DEFAULT_DIR_FD; |
1382 | |
1383 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
1384 | if (!args) { Branch (1384:9): [True: 0, False: 8.20k]
|
1385 | goto exit; |
1386 | } |
1387 | if (!path_converter(args[0], &path)) { Branch (1387:9): [True: 2, False: 8.20k]
|
1388 | goto exit; |
1389 | } |
1390 | if (!noptargs) { Branch (1390:9): [True: 2.71k, False: 5.49k]
|
1391 | goto skip_optional_pos; |
1392 | } |
1393 | if (args[1]) { Branch (1393:9): [True: 5.49k, False: 1]
|
1394 | mode = _PyLong_AsInt(args[1]); |
1395 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (1395:13): [True: 0, False: 5.49k]
Branch (1395:27): [True: 0, False: 0]
|
1396 | goto exit; |
1397 | } |
1398 | if (!--noptargs) { Branch (1398:13): [True: 5.49k, False: 0]
|
1399 | goto skip_optional_pos; |
1400 | } |
1401 | } |
1402 | skip_optional_pos: |
1403 | if (!noptargs) { Branch (1403:9): [True: 8.20k, False: 1]
|
1404 | goto skip_optional_kwonly; |
1405 | } |
1406 | if (!MKDIRAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { Branch (1406:9): [True: 0, False: 1]
|
1407 | goto exit; |
1408 | } |
1409 | skip_optional_kwonly: |
1410 | return_value = os_mkdir_impl(module, &path, mode, dir_fd); |
1411 | |
1412 | exit: |
1413 | /* Cleanup for path */ |
1414 | path_cleanup(&path); |
1415 | |
1416 | return return_value; |
1417 | } |
1418 | |
1419 | #if defined(HAVE_NICE) |
1420 | |
1421 | PyDoc_STRVAR(os_nice__doc__, |
1422 | "nice($module, increment, /)\n" |
1423 | "--\n" |
1424 | "\n" |
1425 | "Add increment to the priority of process and return the new priority."); |
1426 | |
1427 | #define OS_NICE_METHODDEF \ |
1428 | {"nice", (PyCFunction)os_nice, METH_O, os_nice__doc__}, |
1429 | |
1430 | static PyObject * |
1431 | os_nice_impl(PyObject *module, int increment); |
1432 | |
1433 | static PyObject * |
1434 | os_nice(PyObject *module, PyObject *arg) |
1435 | { |
1436 | PyObject *return_value = NULL; |
1437 | int increment; |
1438 |
|
1439 | increment = _PyLong_AsInt(arg); |
1440 | if (increment == -1 && PyErr_Occurred()) { Branch (1440:9): [True: 0, False: 0]
Branch (1440:28): [True: 0, False: 0]
|
1441 | goto exit; |
1442 | } |
1443 | return_value = os_nice_impl(module, increment); |
1444 |
|
1445 | exit: |
1446 | return return_value; |
1447 | } |
1448 | |
1449 | #endif /* defined(HAVE_NICE) */ |
1450 | |
1451 | #if defined(HAVE_GETPRIORITY) |
1452 | |
1453 | PyDoc_STRVAR(os_getpriority__doc__, |
1454 | "getpriority($module, /, which, who)\n" |
1455 | "--\n" |
1456 | "\n" |
1457 | "Return program scheduling priority."); |
1458 | |
1459 | #define OS_GETPRIORITY_METHODDEF \ |
1460 | {"getpriority", _PyCFunction_CAST(os_getpriority), METH_FASTCALL|METH_KEYWORDS, os_getpriority__doc__}, |
1461 | |
1462 | static PyObject * |
1463 | os_getpriority_impl(PyObject *module, int which, int who); |
1464 | |
1465 | static PyObject * |
1466 | os_getpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1467 | { |
1468 | PyObject *return_value = NULL; |
1469 | static const char * const _keywords[] = {"which", "who", NULL}; |
1470 | static _PyArg_Parser _parser = {NULL, _keywords, "getpriority", 0}; |
1471 | PyObject *argsbuf[2]; |
1472 | int which; |
1473 | int who; |
1474 | |
1475 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
1476 | if (!args) { Branch (1476:9): [True: 0, False: 2]
|
1477 | goto exit; |
1478 | } |
1479 | which = _PyLong_AsInt(args[0]); |
1480 | if (which == -1 && PyErr_Occurred()0 ) { Branch (1480:9): [True: 0, False: 2]
Branch (1480:24): [True: 0, False: 0]
|
1481 | goto exit; |
1482 | } |
1483 | who = _PyLong_AsInt(args[1]); |
1484 | if (who == -1 && PyErr_Occurred()0 ) { Branch (1484:9): [True: 0, False: 2]
Branch (1484:22): [True: 0, False: 0]
|
1485 | goto exit; |
1486 | } |
1487 | return_value = os_getpriority_impl(module, which, who); |
1488 | |
1489 | exit: |
1490 | return return_value; |
1491 | } |
1492 | |
1493 | #endif /* defined(HAVE_GETPRIORITY) */ |
1494 | |
1495 | #if defined(HAVE_SETPRIORITY) |
1496 | |
1497 | PyDoc_STRVAR(os_setpriority__doc__, |
1498 | "setpriority($module, /, which, who, priority)\n" |
1499 | "--\n" |
1500 | "\n" |
1501 | "Set program scheduling priority."); |
1502 | |
1503 | #define OS_SETPRIORITY_METHODDEF \ |
1504 | {"setpriority", _PyCFunction_CAST(os_setpriority), METH_FASTCALL|METH_KEYWORDS, os_setpriority__doc__}, |
1505 | |
1506 | static PyObject * |
1507 | os_setpriority_impl(PyObject *module, int which, int who, int priority); |
1508 | |
1509 | static PyObject * |
1510 | os_setpriority(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1511 | { |
1512 | PyObject *return_value = NULL; |
1513 | static const char * const _keywords[] = {"which", "who", "priority", NULL}; |
1514 | static _PyArg_Parser _parser = {NULL, _keywords, "setpriority", 0}; |
1515 | PyObject *argsbuf[3]; |
1516 | int which; |
1517 | int who; |
1518 | int priority; |
1519 | |
1520 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
1521 | if (!args) { Branch (1521:9): [True: 0, False: 2]
|
1522 | goto exit; |
1523 | } |
1524 | which = _PyLong_AsInt(args[0]); |
1525 | if (which == -1 && PyErr_Occurred()0 ) { Branch (1525:9): [True: 0, False: 2]
Branch (1525:24): [True: 0, False: 0]
|
1526 | goto exit; |
1527 | } |
1528 | who = _PyLong_AsInt(args[1]); |
1529 | if (who == -1 && PyErr_Occurred()0 ) { Branch (1529:9): [True: 0, False: 2]
Branch (1529:22): [True: 0, False: 0]
|
1530 | goto exit; |
1531 | } |
1532 | priority = _PyLong_AsInt(args[2]); |
1533 | if (priority == -1 && PyErr_Occurred()0 ) { Branch (1533:9): [True: 0, False: 2]
Branch (1533:27): [True: 0, False: 0]
|
1534 | goto exit; |
1535 | } |
1536 | return_value = os_setpriority_impl(module, which, who, priority); |
1537 | |
1538 | exit: |
1539 | return return_value; |
1540 | } |
1541 | |
1542 | #endif /* defined(HAVE_SETPRIORITY) */ |
1543 | |
1544 | PyDoc_STRVAR(os_rename__doc__, |
1545 | "rename($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" |
1546 | "--\n" |
1547 | "\n" |
1548 | "Rename a file or directory.\n" |
1549 | "\n" |
1550 | "If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" |
1551 | " descriptor open to a directory, and the respective path string (src or dst)\n" |
1552 | " should be relative; the path will then be relative to that directory.\n" |
1553 | "src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" |
1554 | " If they are unavailable, using them will raise a NotImplementedError."); |
1555 | |
1556 | #define OS_RENAME_METHODDEF \ |
1557 | {"rename", _PyCFunction_CAST(os_rename), METH_FASTCALL|METH_KEYWORDS, os_rename__doc__}, |
1558 | |
1559 | static PyObject * |
1560 | os_rename_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, |
1561 | int dst_dir_fd); |
1562 | |
1563 | static PyObject * |
1564 | os_rename(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1565 | { |
1566 | PyObject *return_value = NULL; |
1567 | static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; |
1568 | static _PyArg_Parser _parser = {NULL, _keywords, "rename", 0}; |
1569 | PyObject *argsbuf[4]; |
1570 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 0900 ) - 2; Branch (1570:36): [True: 1, False: 900]
|
1571 | path_t src = PATH_T_INITIALIZE("rename", "src", 0, 0); |
1572 | path_t dst = PATH_T_INITIALIZE("rename", "dst", 0, 0); |
1573 | int src_dir_fd = DEFAULT_DIR_FD; |
1574 | int dst_dir_fd = DEFAULT_DIR_FD; |
1575 | |
1576 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
1577 | if (!args) { Branch (1577:9): [True: 0, False: 901]
|
1578 | goto exit; |
1579 | } |
1580 | if (!path_converter(args[0], &src)) { Branch (1580:9): [True: 0, False: 901]
|
1581 | goto exit; |
1582 | } |
1583 | if (!path_converter(args[1], &dst)) { Branch (1583:9): [True: 1, False: 900]
|
1584 | goto exit; |
1585 | } |
1586 | if (!noptargs) { Branch (1586:9): [True: 899, False: 1]
|
1587 | goto skip_optional_kwonly; |
1588 | } |
1589 | if (args[2]) { Branch (1589:9): [True: 1, False: 0]
|
1590 | if (!dir_fd_converter(args[2], &src_dir_fd)) { Branch (1590:13): [True: 0, False: 1]
|
1591 | goto exit; |
1592 | } |
1593 | if (!--noptargs) { Branch (1593:13): [True: 0, False: 1]
|
1594 | goto skip_optional_kwonly; |
1595 | } |
1596 | } |
1597 | if (!dir_fd_converter(args[3], &dst_dir_fd)) { Branch (1597:9): [True: 0, False: 1]
|
1598 | goto exit; |
1599 | } |
1600 | skip_optional_kwonly: |
1601 | return_value = os_rename_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); |
1602 | |
1603 | exit: |
1604 | /* Cleanup for src */ |
1605 | path_cleanup(&src); |
1606 | /* Cleanup for dst */ |
1607 | path_cleanup(&dst); |
1608 | |
1609 | return return_value; |
1610 | } |
1611 | |
1612 | PyDoc_STRVAR(os_replace__doc__, |
1613 | "replace($module, /, src, dst, *, src_dir_fd=None, dst_dir_fd=None)\n" |
1614 | "--\n" |
1615 | "\n" |
1616 | "Rename a file or directory, overwriting the destination.\n" |
1617 | "\n" |
1618 | "If either src_dir_fd or dst_dir_fd is not None, it should be a file\n" |
1619 | " descriptor open to a directory, and the respective path string (src or dst)\n" |
1620 | " should be relative; the path will then be relative to that directory.\n" |
1621 | "src_dir_fd and dst_dir_fd, may not be implemented on your platform.\n" |
1622 | " If they are unavailable, using them will raise a NotImplementedError."); |
1623 | |
1624 | #define OS_REPLACE_METHODDEF \ |
1625 | {"replace", _PyCFunction_CAST(os_replace), METH_FASTCALL|METH_KEYWORDS, os_replace__doc__}, |
1626 | |
1627 | static PyObject * |
1628 | os_replace_impl(PyObject *module, path_t *src, path_t *dst, int src_dir_fd, |
1629 | int dst_dir_fd); |
1630 | |
1631 | static PyObject * |
1632 | os_replace(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1633 | { |
1634 | PyObject *return_value = NULL; |
1635 | static const char * const _keywords[] = {"src", "dst", "src_dir_fd", "dst_dir_fd", NULL}; |
1636 | static _PyArg_Parser _parser = {NULL, _keywords, "replace", 0}; |
1637 | PyObject *argsbuf[4]; |
1638 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 2; Branch (1638:36): [True: 0, False: 795]
|
1639 | path_t src = PATH_T_INITIALIZE("replace", "src", 0, 0); |
1640 | path_t dst = PATH_T_INITIALIZE("replace", "dst", 0, 0); |
1641 | int src_dir_fd = DEFAULT_DIR_FD; |
1642 | int dst_dir_fd = DEFAULT_DIR_FD; |
1643 | |
1644 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
1645 | if (!args) { Branch (1645:9): [True: 0, False: 795]
|
1646 | goto exit; |
1647 | } |
1648 | if (!path_converter(args[0], &src)) { Branch (1648:9): [True: 0, False: 795]
|
1649 | goto exit; |
1650 | } |
1651 | if (!path_converter(args[1], &dst)) { Branch (1651:9): [True: 0, False: 795]
|
1652 | goto exit; |
1653 | } |
1654 | if (!noptargs) { Branch (1654:9): [True: 795, False: 0]
|
1655 | goto skip_optional_kwonly; |
1656 | } |
1657 | if (args[2]) { Branch (1657:9): [True: 0, False: 0]
|
1658 | if (!dir_fd_converter(args[2], &src_dir_fd)) { Branch (1658:13): [True: 0, False: 0]
|
1659 | goto exit; |
1660 | } |
1661 | if (!--noptargs) { Branch (1661:13): [True: 0, False: 0]
|
1662 | goto skip_optional_kwonly; |
1663 | } |
1664 | } |
1665 | if (!dir_fd_converter(args[3], &dst_dir_fd)) { Branch (1665:9): [True: 0, False: 0]
|
1666 | goto exit; |
1667 | } |
1668 | skip_optional_kwonly: |
1669 | return_value = os_replace_impl(module, &src, &dst, src_dir_fd, dst_dir_fd); |
1670 | |
1671 | exit: |
1672 | /* Cleanup for src */ |
1673 | path_cleanup(&src); |
1674 | /* Cleanup for dst */ |
1675 | path_cleanup(&dst); |
1676 | |
1677 | return return_value; |
1678 | } |
1679 | |
1680 | PyDoc_STRVAR(os_rmdir__doc__, |
1681 | "rmdir($module, /, path, *, dir_fd=None)\n" |
1682 | "--\n" |
1683 | "\n" |
1684 | "Remove a directory.\n" |
1685 | "\n" |
1686 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
1687 | " and path should be relative; path will then be relative to that directory.\n" |
1688 | "dir_fd may not be implemented on your platform.\n" |
1689 | " If it is unavailable, using it will raise a NotImplementedError."); |
1690 | |
1691 | #define OS_RMDIR_METHODDEF \ |
1692 | {"rmdir", _PyCFunction_CAST(os_rmdir), METH_FASTCALL|METH_KEYWORDS, os_rmdir__doc__}, |
1693 | |
1694 | static PyObject * |
1695 | os_rmdir_impl(PyObject *module, path_t *path, int dir_fd); |
1696 | |
1697 | static PyObject * |
1698 | os_rmdir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1699 | { |
1700 | PyObject *return_value = NULL; |
1701 | static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
1702 | static _PyArg_Parser _parser = {NULL, _keywords, "rmdir", 0}; |
1703 | PyObject *argsbuf[2]; |
1704 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE7.95k (kwnames) : 01.07k ) - 1; Branch (1704:36): [True: 7.95k, False: 1.07k]
|
1705 | path_t path = PATH_T_INITIALIZE("rmdir", "path", 0, 0); |
1706 | int dir_fd = DEFAULT_DIR_FD; |
1707 | |
1708 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1709 | if (!args) { Branch (1709:9): [True: 0, False: 9.03k]
|
1710 | goto exit; |
1711 | } |
1712 | if (!path_converter(args[0], &path)) { Branch (1712:9): [True: 0, False: 9.03k]
|
1713 | goto exit; |
1714 | } |
1715 | if (!noptargs) { Branch (1715:9): [True: 1.07k, False: 7.95k]
|
1716 | goto skip_optional_kwonly; |
1717 | } |
1718 | if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { Branch (1718:9): [True: 0, False: 7.95k]
|
1719 | goto exit; |
1720 | } |
1721 | skip_optional_kwonly: |
1722 | return_value = os_rmdir_impl(module, &path, dir_fd); |
1723 | |
1724 | exit: |
1725 | /* Cleanup for path */ |
1726 | path_cleanup(&path); |
1727 | |
1728 | return return_value; |
1729 | } |
1730 | |
1731 | #if defined(HAVE_SYSTEM) && defined(MS_WINDOWS) |
1732 | |
1733 | PyDoc_STRVAR(os_system__doc__, |
1734 | "system($module, /, command)\n" |
1735 | "--\n" |
1736 | "\n" |
1737 | "Execute the command in a subshell."); |
1738 | |
1739 | #define OS_SYSTEM_METHODDEF \ |
1740 | {"system", _PyCFunction_CAST(os_system), METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, |
1741 | |
1742 | static long |
1743 | os_system_impl(PyObject *module, const Py_UNICODE *command); |
1744 | |
1745 | static PyObject * |
1746 | os_system(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1747 | { |
1748 | PyObject *return_value = NULL; |
1749 | static const char * const _keywords[] = {"command", NULL}; |
1750 | static _PyArg_Parser _parser = {NULL, _keywords, "system", 0}; |
1751 | PyObject *argsbuf[1]; |
1752 | const Py_UNICODE *command; |
1753 | long _return_value; |
1754 | |
1755 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1756 | if (!args) { |
1757 | goto exit; |
1758 | } |
1759 | if (!PyUnicode_Check(args[0])) { |
1760 | _PyArg_BadArgument("system", "argument 'command'", "str", args[0]); |
1761 | goto exit; |
1762 | } |
1763 | command = PyUnicode_AsWideCharString(args[0], NULL); |
1764 | if (command == NULL) { |
1765 | goto exit; |
1766 | } |
1767 | _return_value = os_system_impl(module, command); |
1768 | if ((_return_value == -1) && PyErr_Occurred()) { |
1769 | goto exit; |
1770 | } |
1771 | return_value = PyLong_FromLong(_return_value); |
1772 | |
1773 | exit: |
1774 | /* Cleanup for command */ |
1775 | PyMem_Free((void *)command); |
1776 | |
1777 | return return_value; |
1778 | } |
1779 | |
1780 | #endif /* defined(HAVE_SYSTEM) && defined(MS_WINDOWS) */ |
1781 | |
1782 | #if defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) |
1783 | |
1784 | PyDoc_STRVAR(os_system__doc__, |
1785 | "system($module, /, command)\n" |
1786 | "--\n" |
1787 | "\n" |
1788 | "Execute the command in a subshell."); |
1789 | |
1790 | #define OS_SYSTEM_METHODDEF \ |
1791 | {"system", _PyCFunction_CAST(os_system), METH_FASTCALL|METH_KEYWORDS, os_system__doc__}, |
1792 | |
1793 | static long |
1794 | os_system_impl(PyObject *module, PyObject *command); |
1795 | |
1796 | static PyObject * |
1797 | os_system(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1798 | { |
1799 | PyObject *return_value = NULL; |
1800 | static const char * const _keywords[] = {"command", NULL}; |
1801 | static _PyArg_Parser _parser = {NULL, _keywords, "system", 0}; |
1802 | PyObject *argsbuf[1]; |
1803 | PyObject *command = NULL; |
1804 | long _return_value; |
1805 | |
1806 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1807 | if (!args) { Branch (1807:9): [True: 0, False: 4]
|
1808 | goto exit; |
1809 | } |
1810 | if (!PyUnicode_FSConverter(args[0], &command)) { Branch (1810:9): [True: 0, False: 4]
|
1811 | goto exit; |
1812 | } |
1813 | _return_value = os_system_impl(module, command); |
1814 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (1814:9): [True: 0, False: 4]
Branch (1814:34): [True: 0, False: 0]
|
1815 | goto exit; |
1816 | } |
1817 | return_value = PyLong_FromLong(_return_value); |
1818 | |
1819 | exit: |
1820 | /* Cleanup for command */ |
1821 | Py_XDECREF(command); |
1822 | |
1823 | return return_value; |
1824 | } |
1825 | |
1826 | #endif /* defined(HAVE_SYSTEM) && !defined(MS_WINDOWS) */ |
1827 | |
1828 | #if defined(HAVE_UMASK) |
1829 | |
1830 | PyDoc_STRVAR(os_umask__doc__, |
1831 | "umask($module, mask, /)\n" |
1832 | "--\n" |
1833 | "\n" |
1834 | "Set the current numeric umask and return the previous umask."); |
1835 | |
1836 | #define OS_UMASK_METHODDEF \ |
1837 | {"umask", (PyCFunction)os_umask, METH_O, os_umask__doc__}, |
1838 | |
1839 | static PyObject * |
1840 | os_umask_impl(PyObject *module, int mask); |
1841 | |
1842 | static PyObject * |
1843 | os_umask(PyObject *module, PyObject *arg) |
1844 | { |
1845 | PyObject *return_value = NULL; |
1846 | int mask; |
1847 | |
1848 | mask = _PyLong_AsInt(arg); |
1849 | if (mask == -1 && PyErr_Occurred()0 ) { Branch (1849:9): [True: 0, False: 486]
Branch (1849:23): [True: 0, False: 0]
|
1850 | goto exit; |
1851 | } |
1852 | return_value = os_umask_impl(module, mask); |
1853 | |
1854 | exit: |
1855 | return return_value; |
1856 | } |
1857 | |
1858 | #endif /* defined(HAVE_UMASK) */ |
1859 | |
1860 | PyDoc_STRVAR(os_unlink__doc__, |
1861 | "unlink($module, /, path, *, dir_fd=None)\n" |
1862 | "--\n" |
1863 | "\n" |
1864 | "Remove a file (same as remove()).\n" |
1865 | "\n" |
1866 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
1867 | " and path should be relative; path will then be relative to that directory.\n" |
1868 | "dir_fd may not be implemented on your platform.\n" |
1869 | " If it is unavailable, using it will raise a NotImplementedError."); |
1870 | |
1871 | #define OS_UNLINK_METHODDEF \ |
1872 | {"unlink", _PyCFunction_CAST(os_unlink), METH_FASTCALL|METH_KEYWORDS, os_unlink__doc__}, |
1873 | |
1874 | static PyObject * |
1875 | os_unlink_impl(PyObject *module, path_t *path, int dir_fd); |
1876 | |
1877 | static PyObject * |
1878 | os_unlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1879 | { |
1880 | PyObject *return_value = NULL; |
1881 | static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
1882 | static _PyArg_Parser _parser = {NULL, _keywords, "unlink", 0}; |
1883 | PyObject *argsbuf[2]; |
1884 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE29.0k (kwnames) : 015.4k ) - 1; Branch (1884:36): [True: 29.0k, False: 15.4k]
|
1885 | path_t path = PATH_T_INITIALIZE("unlink", "path", 0, 0); |
1886 | int dir_fd = DEFAULT_DIR_FD; |
1887 | |
1888 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1889 | if (!args) { Branch (1889:9): [True: 0, False: 44.4k]
|
1890 | goto exit; |
1891 | } |
1892 | if (!path_converter(args[0], &path)) { Branch (1892:9): [True: 0, False: 44.4k]
|
1893 | goto exit; |
1894 | } |
1895 | if (!noptargs) { Branch (1895:9): [True: 15.4k, False: 29.0k]
|
1896 | goto skip_optional_kwonly; |
1897 | } |
1898 | if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { Branch (1898:9): [True: 0, False: 29.0k]
|
1899 | goto exit; |
1900 | } |
1901 | skip_optional_kwonly: |
1902 | return_value = os_unlink_impl(module, &path, dir_fd); |
1903 | |
1904 | exit: |
1905 | /* Cleanup for path */ |
1906 | path_cleanup(&path); |
1907 | |
1908 | return return_value; |
1909 | } |
1910 | |
1911 | PyDoc_STRVAR(os_remove__doc__, |
1912 | "remove($module, /, path, *, dir_fd=None)\n" |
1913 | "--\n" |
1914 | "\n" |
1915 | "Remove a file (same as unlink()).\n" |
1916 | "\n" |
1917 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
1918 | " and path should be relative; path will then be relative to that directory.\n" |
1919 | "dir_fd may not be implemented on your platform.\n" |
1920 | " If it is unavailable, using it will raise a NotImplementedError."); |
1921 | |
1922 | #define OS_REMOVE_METHODDEF \ |
1923 | {"remove", _PyCFunction_CAST(os_remove), METH_FASTCALL|METH_KEYWORDS, os_remove__doc__}, |
1924 | |
1925 | static PyObject * |
1926 | os_remove_impl(PyObject *module, path_t *path, int dir_fd); |
1927 | |
1928 | static PyObject * |
1929 | os_remove(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
1930 | { |
1931 | PyObject *return_value = NULL; |
1932 | static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
1933 | static _PyArg_Parser _parser = {NULL, _keywords, "remove", 0}; |
1934 | PyObject *argsbuf[2]; |
1935 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 1; Branch (1935:36): [True: 0, False: 1.36k]
|
1936 | path_t path = PATH_T_INITIALIZE("remove", "path", 0, 0); |
1937 | int dir_fd = DEFAULT_DIR_FD; |
1938 | |
1939 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
1940 | if (!args) { Branch (1940:9): [True: 0, False: 1.36k]
|
1941 | goto exit; |
1942 | } |
1943 | if (!path_converter(args[0], &path)) { Branch (1943:9): [True: 0, False: 1.36k]
|
1944 | goto exit; |
1945 | } |
1946 | if (!noptargs) { Branch (1946:9): [True: 1.36k, False: 0]
|
1947 | goto skip_optional_kwonly; |
1948 | } |
1949 | if (!UNLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { Branch (1949:9): [True: 0, False: 0]
|
1950 | goto exit; |
1951 | } |
1952 | skip_optional_kwonly: |
1953 | return_value = os_remove_impl(module, &path, dir_fd); |
1954 | |
1955 | exit: |
1956 | /* Cleanup for path */ |
1957 | path_cleanup(&path); |
1958 | |
1959 | return return_value; |
1960 | } |
1961 | |
1962 | #if defined(HAVE_UNAME) |
1963 | |
1964 | PyDoc_STRVAR(os_uname__doc__, |
1965 | "uname($module, /)\n" |
1966 | "--\n" |
1967 | "\n" |
1968 | "Return an object identifying the current operating system.\n" |
1969 | "\n" |
1970 | "The object behaves like a named tuple with the following fields:\n" |
1971 | " (sysname, nodename, release, version, machine)"); |
1972 | |
1973 | #define OS_UNAME_METHODDEF \ |
1974 | {"uname", (PyCFunction)os_uname, METH_NOARGS, os_uname__doc__}, |
1975 | |
1976 | static PyObject * |
1977 | os_uname_impl(PyObject *module); |
1978 | |
1979 | static PyObject * |
1980 | os_uname(PyObject *module, PyObject *Py_UNUSED(ignored)) |
1981 | { |
1982 | return os_uname_impl(module); |
1983 | } |
1984 | |
1985 | #endif /* defined(HAVE_UNAME) */ |
1986 | |
1987 | PyDoc_STRVAR(os_utime__doc__, |
1988 | "utime($module, /, path, times=None, *, ns=<unrepresentable>,\n" |
1989 | " dir_fd=None, follow_symlinks=True)\n" |
1990 | "--\n" |
1991 | "\n" |
1992 | "Set the access and modified time of path.\n" |
1993 | "\n" |
1994 | "path may always be specified as a string.\n" |
1995 | "On some platforms, path may also be specified as an open file descriptor.\n" |
1996 | " If this functionality is unavailable, using it raises an exception.\n" |
1997 | "\n" |
1998 | "If times is not None, it must be a tuple (atime, mtime);\n" |
1999 | " atime and mtime should be expressed as float seconds since the epoch.\n" |
2000 | "If ns is specified, it must be a tuple (atime_ns, mtime_ns);\n" |
2001 | " atime_ns and mtime_ns should be expressed as integer nanoseconds\n" |
2002 | " since the epoch.\n" |
2003 | "If times is None and ns is unspecified, utime uses the current time.\n" |
2004 | "Specifying tuples for both times and ns is an error.\n" |
2005 | "\n" |
2006 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
2007 | " and path should be relative; path will then be relative to that directory.\n" |
2008 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
2009 | " link, utime will modify the symbolic link itself instead of the file the\n" |
2010 | " link points to.\n" |
2011 | "It is an error to use dir_fd or follow_symlinks when specifying path\n" |
2012 | " as an open file descriptor.\n" |
2013 | "dir_fd and follow_symlinks may not be available on your platform.\n" |
2014 | " If they are unavailable, using them will raise a NotImplementedError."); |
2015 | |
2016 | #define OS_UTIME_METHODDEF \ |
2017 | {"utime", _PyCFunction_CAST(os_utime), METH_FASTCALL|METH_KEYWORDS, os_utime__doc__}, |
2018 | |
2019 | static PyObject * |
2020 | os_utime_impl(PyObject *module, path_t *path, PyObject *times, PyObject *ns, |
2021 | int dir_fd, int follow_symlinks); |
2022 | |
2023 | static PyObject * |
2024 | os_utime(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2025 | { |
2026 | PyObject *return_value = NULL; |
2027 | static const char * const _keywords[] = {"path", "times", "ns", "dir_fd", "follow_symlinks", NULL}; |
2028 | static _PyArg_Parser _parser = {NULL, _keywords, "utime", 0}; |
2029 | PyObject *argsbuf[5]; |
2030 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE8.66k (kwnames) : 0375 ) - 1; Branch (2030:36): [True: 8.66k, False: 375]
|
2031 | path_t path = PATH_T_INITIALIZE("utime", "path", 0, PATH_UTIME_HAVE_FD); |
2032 | PyObject *times = Py_None; |
2033 | PyObject *ns = NULL; |
2034 | int dir_fd = DEFAULT_DIR_FD; |
2035 | int follow_symlinks = 1; |
2036 | |
2037 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
2038 | if (!args) { Branch (2038:9): [True: 0, False: 9.04k]
|
2039 | goto exit; |
2040 | } |
2041 | if (!path_converter(args[0], &path)) { Branch (2041:9): [True: 0, False: 9.04k]
|
2042 | goto exit; |
2043 | } |
2044 | if (!noptargs) { Branch (2044:9): [True: 2, False: 9.03k]
|
2045 | goto skip_optional_pos; |
2046 | } |
2047 | if (args[1]) { Branch (2047:9): [True: 394, False: 8.64k]
|
2048 | times = args[1]; |
2049 | if (!--noptargs) { Branch (2049:13): [True: 374, False: 20]
|
2050 | goto skip_optional_pos; |
2051 | } |
2052 | } |
2053 | skip_optional_pos: |
2054 | if (!noptargs) { Branch (2054:9): [True: 376, False: 8.66k]
|
2055 | goto skip_optional_kwonly; |
2056 | } |
2057 | if (args[2]) { Branch (2057:9): [True: 8.64k, False: 19]
|
2058 | ns = args[2]; |
2059 | if (!--noptargs) { Branch (2059:13): [True: 14, False: 8.63k]
|
2060 | goto skip_optional_kwonly; |
2061 | } |
2062 | } |
2063 | if (args[3]) { Branch (2063:9): [True: 13, False: 8.63k]
|
2064 | if (!FUTIMENSAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { Branch (2064:13): [True: 0, False: 13]
|
2065 | goto exit; |
2066 | } |
2067 | if (!--noptargs) { Branch (2067:13): [True: 12, False: 1]
|
2068 | goto skip_optional_kwonly; |
2069 | } |
2070 | } |
2071 | follow_symlinks = PyObject_IsTrue(args[4]); |
2072 | if (follow_symlinks < 0) { Branch (2072:9): [True: 0, False: 8.63k]
|
2073 | goto exit; |
2074 | } |
2075 | skip_optional_kwonly: |
2076 | return_value = os_utime_impl(module, &path, times, ns, dir_fd, follow_symlinks); |
2077 | |
2078 | exit: |
2079 | /* Cleanup for path */ |
2080 | path_cleanup(&path); |
2081 | |
2082 | return return_value; |
2083 | } |
2084 | |
2085 | PyDoc_STRVAR(os__exit__doc__, |
2086 | "_exit($module, /, status)\n" |
2087 | "--\n" |
2088 | "\n" |
2089 | "Exit to the system with specified status, without normal exit processing."); |
2090 | |
2091 | #define OS__EXIT_METHODDEF \ |
2092 | {"_exit", _PyCFunction_CAST(os__exit), METH_FASTCALL|METH_KEYWORDS, os__exit__doc__}, |
2093 | |
2094 | static PyObject * |
2095 | os__exit_impl(PyObject *module, int status); |
2096 | |
2097 | static PyObject * |
2098 | os__exit(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2099 | { |
2100 | PyObject *return_value = NULL; |
2101 | static const char * const _keywords[] = {"status", NULL}; |
2102 | static _PyArg_Parser _parser = {NULL, _keywords, "_exit", 0}; |
2103 | PyObject *argsbuf[1]; |
2104 | int status; |
2105 |
|
2106 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
2107 | if (!args) { Branch (2107:9): [True: 0, False: 0]
|
2108 | goto exit; |
2109 | } |
2110 | status = _PyLong_AsInt(args[0]); |
2111 | if (status == -1 && PyErr_Occurred()) { Branch (2111:9): [True: 0, False: 0]
Branch (2111:25): [True: 0, False: 0]
|
2112 | goto exit; |
2113 | } |
2114 | return_value = os__exit_impl(module, status); |
2115 |
|
2116 | exit: |
2117 | return return_value; |
2118 | } |
2119 | |
2120 | #if defined(HAVE_EXECV) |
2121 | |
2122 | PyDoc_STRVAR(os_execv__doc__, |
2123 | "execv($module, path, argv, /)\n" |
2124 | "--\n" |
2125 | "\n" |
2126 | "Execute an executable path with arguments, replacing current process.\n" |
2127 | "\n" |
2128 | " path\n" |
2129 | " Path of executable file.\n" |
2130 | " argv\n" |
2131 | " Tuple or list of strings."); |
2132 | |
2133 | #define OS_EXECV_METHODDEF \ |
2134 | {"execv", _PyCFunction_CAST(os_execv), METH_FASTCALL, os_execv__doc__}, |
2135 | |
2136 | static PyObject * |
2137 | os_execv_impl(PyObject *module, path_t *path, PyObject *argv); |
2138 | |
2139 | static PyObject * |
2140 | os_execv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
2141 | { |
2142 | PyObject *return_value = NULL; |
2143 | path_t path = PATH_T_INITIALIZE("execv", "path", 0, 0); |
2144 | PyObject *argv; |
2145 | |
2146 | if (!_PyArg_CheckPositional("execv", nargs, 2, 2)) { |
2147 | goto exit; |
2148 | } |
2149 | if (!path_converter(args[0], &path)) { Branch (2149:9): [True: 0, False: 43]
|
2150 | goto exit; |
2151 | } |
2152 | argv = args[1]; |
2153 | return_value = os_execv_impl(module, &path, argv); |
2154 | |
2155 | exit: |
2156 | /* Cleanup for path */ |
2157 | path_cleanup(&path); |
2158 | |
2159 | return return_value; |
2160 | } |
2161 | |
2162 | #endif /* defined(HAVE_EXECV) */ |
2163 | |
2164 | #if defined(HAVE_EXECV) |
2165 | |
2166 | PyDoc_STRVAR(os_execve__doc__, |
2167 | "execve($module, /, path, argv, env)\n" |
2168 | "--\n" |
2169 | "\n" |
2170 | "Execute an executable path with arguments, replacing current process.\n" |
2171 | "\n" |
2172 | " path\n" |
2173 | " Path of executable file.\n" |
2174 | " argv\n" |
2175 | " Tuple or list of strings.\n" |
2176 | " env\n" |
2177 | " Dictionary of strings mapping to strings."); |
2178 | |
2179 | #define OS_EXECVE_METHODDEF \ |
2180 | {"execve", _PyCFunction_CAST(os_execve), METH_FASTCALL|METH_KEYWORDS, os_execve__doc__}, |
2181 | |
2182 | static PyObject * |
2183 | os_execve_impl(PyObject *module, path_t *path, PyObject *argv, PyObject *env); |
2184 | |
2185 | static PyObject * |
2186 | os_execve(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2187 | { |
2188 | PyObject *return_value = NULL; |
2189 | static const char * const _keywords[] = {"path", "argv", "env", NULL}; |
2190 | static _PyArg_Parser _parser = {NULL, _keywords, "execve", 0}; |
2191 | PyObject *argsbuf[3]; |
2192 | path_t path = PATH_T_INITIALIZE("execve", "path", 0, PATH_HAVE_FEXECVE); |
2193 | PyObject *argv; |
2194 | PyObject *env; |
2195 | |
2196 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
2197 | if (!args) { Branch (2197:9): [True: 0, False: 5]
|
2198 | goto exit; |
2199 | } |
2200 | if (!path_converter(args[0], &path)) { Branch (2200:9): [True: 0, False: 5]
|
2201 | goto exit; |
2202 | } |
2203 | argv = args[1]; |
2204 | env = args[2]; |
2205 | return_value = os_execve_impl(module, &path, argv, env); |
2206 | |
2207 | exit: |
2208 | /* Cleanup for path */ |
2209 | path_cleanup(&path); |
2210 | |
2211 | return return_value; |
2212 | } |
2213 | |
2214 | #endif /* defined(HAVE_EXECV) */ |
2215 | |
2216 | #if defined(HAVE_POSIX_SPAWN) |
2217 | |
2218 | PyDoc_STRVAR(os_posix_spawn__doc__, |
2219 | "posix_spawn($module, path, argv, env, /, *, file_actions=(),\n" |
2220 | " setpgroup=<unrepresentable>, resetids=False, setsid=False,\n" |
2221 | " setsigmask=(), setsigdef=(), scheduler=<unrepresentable>)\n" |
2222 | "--\n" |
2223 | "\n" |
2224 | "Execute the program specified by path in a new process.\n" |
2225 | "\n" |
2226 | " path\n" |
2227 | " Path of executable file.\n" |
2228 | " argv\n" |
2229 | " Tuple or list of strings.\n" |
2230 | " env\n" |
2231 | " Dictionary of strings mapping to strings.\n" |
2232 | " file_actions\n" |
2233 | " A sequence of file action tuples.\n" |
2234 | " setpgroup\n" |
2235 | " The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" |
2236 | " resetids\n" |
2237 | " If the value is `true` the POSIX_SPAWN_RESETIDS will be activated.\n" |
2238 | " setsid\n" |
2239 | " If the value is `true` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" |
2240 | " setsigmask\n" |
2241 | " The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" |
2242 | " setsigdef\n" |
2243 | " The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" |
2244 | " scheduler\n" |
2245 | " A tuple with the scheduler policy (optional) and parameters."); |
2246 | |
2247 | #define OS_POSIX_SPAWN_METHODDEF \ |
2248 | {"posix_spawn", _PyCFunction_CAST(os_posix_spawn), METH_FASTCALL|METH_KEYWORDS, os_posix_spawn__doc__}, |
2249 | |
2250 | static PyObject * |
2251 | os_posix_spawn_impl(PyObject *module, path_t *path, PyObject *argv, |
2252 | PyObject *env, PyObject *file_actions, |
2253 | PyObject *setpgroup, int resetids, int setsid, |
2254 | PyObject *setsigmask, PyObject *setsigdef, |
2255 | PyObject *scheduler); |
2256 | |
2257 | static PyObject * |
2258 | os_posix_spawn(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2259 | { |
2260 | PyObject *return_value = NULL; |
2261 | static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; |
2262 | static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawn", 0}; |
2263 | PyObject *argsbuf[10]; |
2264 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE55 (kwnames) : 03 ) - 3; Branch (2264:36): [True: 55, False: 3]
|
2265 | path_t path = PATH_T_INITIALIZE("posix_spawn", "path", 0, 0); |
2266 | PyObject *argv; |
2267 | PyObject *env; |
2268 | PyObject *file_actions = NULL; |
2269 | PyObject *setpgroup = NULL; |
2270 | int resetids = 0; |
2271 | int setsid = 0; |
2272 | PyObject *setsigmask = NULL; |
2273 | PyObject *setsigdef = NULL; |
2274 | PyObject *scheduler = NULL; |
2275 | |
2276 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
2277 | if (!args) { Branch (2277:9): [True: 0, False: 58]
|
2278 | goto exit; |
2279 | } |
2280 | if (!path_converter(args[0], &path)) { Branch (2280:9): [True: 0, False: 58]
|
2281 | goto exit; |
2282 | } |
2283 | argv = args[1]; |
2284 | env = args[2]; |
2285 | if (!noptargs) { Branch (2285:9): [True: 3, False: 55]
|
2286 | goto skip_optional_kwonly; |
2287 | } |
2288 | if (args[3]) { Branch (2288:9): [True: 39, False: 16]
|
2289 | file_actions = args[3]; |
2290 | if (!--noptargs) { Branch (2290:13): [True: 14, False: 25]
|
2291 | goto skip_optional_kwonly; |
2292 | } |
2293 | } |
2294 | if (args[4]) { Branch (2294:9): [True: 2, False: 39]
|
2295 | setpgroup = args[4]; |
2296 | if (!--noptargs) { Branch (2296:13): [True: 2, False: 0]
|
2297 | goto skip_optional_kwonly; |
2298 | } |
2299 | } |
2300 | if (args[5]) { Branch (2300:9): [True: 3, False: 36]
|
2301 | resetids = _PyLong_AsInt(args[5]); |
2302 | if (resetids == -1 && PyErr_Occurred()1 ) { Branch (2302:13): [True: 1, False: 2]
Branch (2302:31): [True: 1, False: 0]
|
2303 | goto exit; |
2304 | } |
2305 | if (!--noptargs) { Branch (2305:13): [True: 2, False: 0]
|
2306 | goto skip_optional_kwonly; |
2307 | } |
2308 | } |
2309 | if (args[6]) { Branch (2309:9): [True: 1, False: 35]
|
2310 | setsid = _PyLong_AsInt(args[6]); |
2311 | if (setsid == -1 && PyErr_Occurred()0 ) { Branch (2311:13): [True: 0, False: 1]
Branch (2311:29): [True: 0, False: 0]
|
2312 | goto exit; |
2313 | } |
2314 | if (!--noptargs) { Branch (2314:13): [True: 1, False: 0]
|
2315 | goto skip_optional_kwonly; |
2316 | } |
2317 | } |
2318 | if (args[7]) { Branch (2318:9): [True: 4, False: 31]
|
2319 | setsigmask = args[7]; |
2320 | if (!--noptargs) { Branch (2320:13): [True: 4, False: 0]
|
2321 | goto skip_optional_kwonly; |
2322 | } |
2323 | } |
2324 | if (args[8]) { Branch (2324:9): [True: 29, False: 2]
|
2325 | setsigdef = args[8]; |
2326 | if (!--noptargs) { Branch (2326:13): [True: 29, False: 0]
|
2327 | goto skip_optional_kwonly; |
2328 | } |
2329 | } |
2330 | scheduler = args[9]; |
2331 | skip_optional_kwonly: |
2332 | return_value = os_posix_spawn_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); |
2333 | |
2334 | exit: |
2335 | /* Cleanup for path */ |
2336 | path_cleanup(&path); |
2337 | |
2338 | return return_value; |
2339 | } |
2340 | |
2341 | #endif /* defined(HAVE_POSIX_SPAWN) */ |
2342 | |
2343 | #if defined(HAVE_POSIX_SPAWNP) |
2344 | |
2345 | PyDoc_STRVAR(os_posix_spawnp__doc__, |
2346 | "posix_spawnp($module, path, argv, env, /, *, file_actions=(),\n" |
2347 | " setpgroup=<unrepresentable>, resetids=False, setsid=False,\n" |
2348 | " setsigmask=(), setsigdef=(), scheduler=<unrepresentable>)\n" |
2349 | "--\n" |
2350 | "\n" |
2351 | "Execute the program specified by path in a new process.\n" |
2352 | "\n" |
2353 | " path\n" |
2354 | " Path of executable file.\n" |
2355 | " argv\n" |
2356 | " Tuple or list of strings.\n" |
2357 | " env\n" |
2358 | " Dictionary of strings mapping to strings.\n" |
2359 | " file_actions\n" |
2360 | " A sequence of file action tuples.\n" |
2361 | " setpgroup\n" |
2362 | " The pgroup to use with the POSIX_SPAWN_SETPGROUP flag.\n" |
2363 | " resetids\n" |
2364 | " If the value is `True` the POSIX_SPAWN_RESETIDS will be activated.\n" |
2365 | " setsid\n" |
2366 | " If the value is `True` the POSIX_SPAWN_SETSID or POSIX_SPAWN_SETSID_NP will be activated.\n" |
2367 | " setsigmask\n" |
2368 | " The sigmask to use with the POSIX_SPAWN_SETSIGMASK flag.\n" |
2369 | " setsigdef\n" |
2370 | " The sigmask to use with the POSIX_SPAWN_SETSIGDEF flag.\n" |
2371 | " scheduler\n" |
2372 | " A tuple with the scheduler policy (optional) and parameters."); |
2373 | |
2374 | #define OS_POSIX_SPAWNP_METHODDEF \ |
2375 | {"posix_spawnp", _PyCFunction_CAST(os_posix_spawnp), METH_FASTCALL|METH_KEYWORDS, os_posix_spawnp__doc__}, |
2376 | |
2377 | static PyObject * |
2378 | os_posix_spawnp_impl(PyObject *module, path_t *path, PyObject *argv, |
2379 | PyObject *env, PyObject *file_actions, |
2380 | PyObject *setpgroup, int resetids, int setsid, |
2381 | PyObject *setsigmask, PyObject *setsigdef, |
2382 | PyObject *scheduler); |
2383 | |
2384 | static PyObject * |
2385 | os_posix_spawnp(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2386 | { |
2387 | PyObject *return_value = NULL; |
2388 | static const char * const _keywords[] = {"", "", "", "file_actions", "setpgroup", "resetids", "setsid", "setsigmask", "setsigdef", "scheduler", NULL}; |
2389 | static _PyArg_Parser _parser = {NULL, _keywords, "posix_spawnp", 0}; |
2390 | PyObject *argsbuf[10]; |
2391 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE30 (kwnames) : 03 ) - 3; Branch (2391:36): [True: 30, False: 3]
|
2392 | path_t path = PATH_T_INITIALIZE("posix_spawnp", "path", 0, 0); |
2393 | PyObject *argv; |
2394 | PyObject *env; |
2395 | PyObject *file_actions = NULL; |
2396 | PyObject *setpgroup = NULL; |
2397 | int resetids = 0; |
2398 | int setsid = 0; |
2399 | PyObject *setsigmask = NULL; |
2400 | PyObject *setsigdef = NULL; |
2401 | PyObject *scheduler = NULL; |
2402 | |
2403 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf); |
2404 | if (!args) { Branch (2404:9): [True: 0, False: 33]
|
2405 | goto exit; |
2406 | } |
2407 | if (!path_converter(args[0], &path)) { Branch (2407:9): [True: 0, False: 33]
|
2408 | goto exit; |
2409 | } |
2410 | argv = args[1]; |
2411 | env = args[2]; |
2412 | if (!noptargs) { Branch (2412:9): [True: 3, False: 30]
|
2413 | goto skip_optional_kwonly; |
2414 | } |
2415 | if (args[3]) { Branch (2415:9): [True: 14, False: 16]
|
2416 | file_actions = args[3]; |
2417 | if (!--noptargs) { Branch (2417:13): [True: 14, False: 0]
|
2418 | goto skip_optional_kwonly; |
2419 | } |
2420 | } |
2421 | if (args[4]) { Branch (2421:9): [True: 2, False: 14]
|
2422 | setpgroup = args[4]; |
2423 | if (!--noptargs) { Branch (2423:13): [True: 2, False: 0]
|
2424 | goto skip_optional_kwonly; |
2425 | } |
2426 | } |
2427 | if (args[5]) { Branch (2427:9): [True: 3, False: 11]
|
2428 | resetids = _PyLong_AsInt(args[5]); |
2429 | if (resetids == -1 && PyErr_Occurred()1 ) { Branch (2429:13): [True: 1, False: 2]
Branch (2429:31): [True: 1, False: 0]
|
2430 | goto exit; |
2431 | } |
2432 | if (!--noptargs) { Branch (2432:13): [True: 2, False: 0]
|
2433 | goto skip_optional_kwonly; |
2434 | } |
2435 | } |
2436 | if (args[6]) { Branch (2436:9): [True: 1, False: 10]
|
2437 | setsid = _PyLong_AsInt(args[6]); |
2438 | if (setsid == -1 && PyErr_Occurred()0 ) { Branch (2438:13): [True: 0, False: 1]
Branch (2438:29): [True: 0, False: 0]
|
2439 | goto exit; |
2440 | } |
2441 | if (!--noptargs) { Branch (2441:13): [True: 1, False: 0]
|
2442 | goto skip_optional_kwonly; |
2443 | } |
2444 | } |
2445 | if (args[7]) { Branch (2445:9): [True: 4, False: 6]
|
2446 | setsigmask = args[7]; |
2447 | if (!--noptargs) { Branch (2447:13): [True: 4, False: 0]
|
2448 | goto skip_optional_kwonly; |
2449 | } |
2450 | } |
2451 | if (args[8]) { Branch (2451:9): [True: 4, False: 2]
|
2452 | setsigdef = args[8]; |
2453 | if (!--noptargs) { Branch (2453:13): [True: 4, False: 0]
|
2454 | goto skip_optional_kwonly; |
2455 | } |
2456 | } |
2457 | scheduler = args[9]; |
2458 | skip_optional_kwonly: |
2459 | return_value = os_posix_spawnp_impl(module, &path, argv, env, file_actions, setpgroup, resetids, setsid, setsigmask, setsigdef, scheduler); |
2460 | |
2461 | exit: |
2462 | /* Cleanup for path */ |
2463 | path_cleanup(&path); |
2464 | |
2465 | return return_value; |
2466 | } |
2467 | |
2468 | #endif /* defined(HAVE_POSIX_SPAWNP) */ |
2469 | |
2470 | #if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) |
2471 | |
2472 | PyDoc_STRVAR(os_spawnv__doc__, |
2473 | "spawnv($module, mode, path, argv, /)\n" |
2474 | "--\n" |
2475 | "\n" |
2476 | "Execute the program specified by path in a new process.\n" |
2477 | "\n" |
2478 | " mode\n" |
2479 | " Mode of process creation.\n" |
2480 | " path\n" |
2481 | " Path of executable file.\n" |
2482 | " argv\n" |
2483 | " Tuple or list of strings."); |
2484 | |
2485 | #define OS_SPAWNV_METHODDEF \ |
2486 | {"spawnv", _PyCFunction_CAST(os_spawnv), METH_FASTCALL, os_spawnv__doc__}, |
2487 | |
2488 | static PyObject * |
2489 | os_spawnv_impl(PyObject *module, int mode, path_t *path, PyObject *argv); |
2490 | |
2491 | static PyObject * |
2492 | os_spawnv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
2493 | { |
2494 | PyObject *return_value = NULL; |
2495 | int mode; |
2496 | path_t path = PATH_T_INITIALIZE("spawnv", "path", 0, 0); |
2497 | PyObject *argv; |
2498 | |
2499 | if (!_PyArg_CheckPositional("spawnv", nargs, 3, 3)) { |
2500 | goto exit; |
2501 | } |
2502 | mode = _PyLong_AsInt(args[0]); |
2503 | if (mode == -1 && PyErr_Occurred()) { |
2504 | goto exit; |
2505 | } |
2506 | if (!path_converter(args[1], &path)) { |
2507 | goto exit; |
2508 | } |
2509 | argv = args[2]; |
2510 | return_value = os_spawnv_impl(module, mode, &path, argv); |
2511 | |
2512 | exit: |
2513 | /* Cleanup for path */ |
2514 | path_cleanup(&path); |
2515 | |
2516 | return return_value; |
2517 | } |
2518 | |
2519 | #endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ |
2520 | |
2521 | #if (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) |
2522 | |
2523 | PyDoc_STRVAR(os_spawnve__doc__, |
2524 | "spawnve($module, mode, path, argv, env, /)\n" |
2525 | "--\n" |
2526 | "\n" |
2527 | "Execute the program specified by path in a new process.\n" |
2528 | "\n" |
2529 | " mode\n" |
2530 | " Mode of process creation.\n" |
2531 | " path\n" |
2532 | " Path of executable file.\n" |
2533 | " argv\n" |
2534 | " Tuple or list of strings.\n" |
2535 | " env\n" |
2536 | " Dictionary of strings mapping to strings."); |
2537 | |
2538 | #define OS_SPAWNVE_METHODDEF \ |
2539 | {"spawnve", _PyCFunction_CAST(os_spawnve), METH_FASTCALL, os_spawnve__doc__}, |
2540 | |
2541 | static PyObject * |
2542 | os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv, |
2543 | PyObject *env); |
2544 | |
2545 | static PyObject * |
2546 | os_spawnve(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
2547 | { |
2548 | PyObject *return_value = NULL; |
2549 | int mode; |
2550 | path_t path = PATH_T_INITIALIZE("spawnve", "path", 0, 0); |
2551 | PyObject *argv; |
2552 | PyObject *env; |
2553 | |
2554 | if (!_PyArg_CheckPositional("spawnve", nargs, 4, 4)) { |
2555 | goto exit; |
2556 | } |
2557 | mode = _PyLong_AsInt(args[0]); |
2558 | if (mode == -1 && PyErr_Occurred()) { |
2559 | goto exit; |
2560 | } |
2561 | if (!path_converter(args[1], &path)) { |
2562 | goto exit; |
2563 | } |
2564 | argv = args[2]; |
2565 | env = args[3]; |
2566 | return_value = os_spawnve_impl(module, mode, &path, argv, env); |
2567 | |
2568 | exit: |
2569 | /* Cleanup for path */ |
2570 | path_cleanup(&path); |
2571 | |
2572 | return return_value; |
2573 | } |
2574 | |
2575 | #endif /* (defined(HAVE_SPAWNV) || defined(HAVE_WSPAWNV) || defined(HAVE_RTPSPAWN)) */ |
2576 | |
2577 | #if defined(HAVE_FORK) |
2578 | |
2579 | PyDoc_STRVAR(os_register_at_fork__doc__, |
2580 | "register_at_fork($module, /, *, before=<unrepresentable>,\n" |
2581 | " after_in_child=<unrepresentable>,\n" |
2582 | " after_in_parent=<unrepresentable>)\n" |
2583 | "--\n" |
2584 | "\n" |
2585 | "Register callables to be called when forking a new process.\n" |
2586 | "\n" |
2587 | " before\n" |
2588 | " A callable to be called in the parent before the fork() syscall.\n" |
2589 | " after_in_child\n" |
2590 | " A callable to be called in the child after fork().\n" |
2591 | " after_in_parent\n" |
2592 | " A callable to be called in the parent after fork().\n" |
2593 | "\n" |
2594 | "\'before\' callbacks are called in reverse order.\n" |
2595 | "\'after_in_child\' and \'after_in_parent\' callbacks are called in order."); |
2596 | |
2597 | #define OS_REGISTER_AT_FORK_METHODDEF \ |
2598 | {"register_at_fork", _PyCFunction_CAST(os_register_at_fork), METH_FASTCALL|METH_KEYWORDS, os_register_at_fork__doc__}, |
2599 | |
2600 | static PyObject * |
2601 | os_register_at_fork_impl(PyObject *module, PyObject *before, |
2602 | PyObject *after_in_child, PyObject *after_in_parent); |
2603 | |
2604 | static PyObject * |
2605 | os_register_at_fork(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2606 | { |
2607 | PyObject *return_value = NULL; |
2608 | static const char * const _keywords[] = {"before", "after_in_child", "after_in_parent", NULL}; |
2609 | static _PyArg_Parser _parser = {NULL, _keywords, "register_at_fork", 0}; |
2610 | PyObject *argsbuf[3]; |
2611 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE17 (kwnames) : 01 ) - 0; Branch (2611:36): [True: 17, False: 1]
|
2612 | PyObject *before = NULL; |
2613 | PyObject *after_in_child = NULL; |
2614 | PyObject *after_in_parent = NULL; |
2615 | |
2616 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); |
2617 | if (!args) { Branch (2617:9): [True: 1, False: 17]
|
2618 | goto exit; |
2619 | } |
2620 | if (!noptargs) { Branch (2620:9): [True: 0, False: 17]
|
2621 | goto skip_optional_kwonly; |
2622 | } |
2623 | if (args[0]) { Branch (2623:9): [True: 6, False: 11]
|
2624 | before = args[0]; |
2625 | if (!--noptargs) { Branch (2625:13): [True: 2, False: 4]
|
2626 | goto skip_optional_kwonly; |
2627 | } |
2628 | } |
2629 | if (args[1]) { Branch (2629:9): [True: 12, False: 3]
|
2630 | after_in_child = args[1]; |
2631 | if (!--noptargs) { Branch (2631:13): [True: 10, False: 2]
|
2632 | goto skip_optional_kwonly; |
2633 | } |
2634 | } |
2635 | after_in_parent = args[2]; |
2636 | skip_optional_kwonly: |
2637 | return_value = os_register_at_fork_impl(module, before, after_in_child, after_in_parent); |
2638 | |
2639 | exit: |
2640 | return return_value; |
2641 | } |
2642 | |
2643 | #endif /* defined(HAVE_FORK) */ |
2644 | |
2645 | #if defined(HAVE_FORK1) |
2646 | |
2647 | PyDoc_STRVAR(os_fork1__doc__, |
2648 | "fork1($module, /)\n" |
2649 | "--\n" |
2650 | "\n" |
2651 | "Fork a child process with a single multiplexed (i.e., not bound) thread.\n" |
2652 | "\n" |
2653 | "Return 0 to child process and PID of child to parent process."); |
2654 | |
2655 | #define OS_FORK1_METHODDEF \ |
2656 | {"fork1", (PyCFunction)os_fork1, METH_NOARGS, os_fork1__doc__}, |
2657 | |
2658 | static PyObject * |
2659 | os_fork1_impl(PyObject *module); |
2660 | |
2661 | static PyObject * |
2662 | os_fork1(PyObject *module, PyObject *Py_UNUSED(ignored)) |
2663 | { |
2664 | return os_fork1_impl(module); |
2665 | } |
2666 | |
2667 | #endif /* defined(HAVE_FORK1) */ |
2668 | |
2669 | #if defined(HAVE_FORK) |
2670 | |
2671 | PyDoc_STRVAR(os_fork__doc__, |
2672 | "fork($module, /)\n" |
2673 | "--\n" |
2674 | "\n" |
2675 | "Fork a child process.\n" |
2676 | "\n" |
2677 | "Return 0 to child process and PID of child to parent process."); |
2678 | |
2679 | #define OS_FORK_METHODDEF \ |
2680 | {"fork", (PyCFunction)os_fork, METH_NOARGS, os_fork__doc__}, |
2681 | |
2682 | static PyObject * |
2683 | os_fork_impl(PyObject *module); |
2684 | |
2685 | static PyObject * |
2686 | os_fork(PyObject *module, PyObject *Py_UNUSED(ignored)) |
2687 | { |
2688 | return os_fork_impl(module); |
2689 | } |
2690 | |
2691 | #endif /* defined(HAVE_FORK) */ |
2692 | |
2693 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) |
2694 | |
2695 | PyDoc_STRVAR(os_sched_get_priority_max__doc__, |
2696 | "sched_get_priority_max($module, /, policy)\n" |
2697 | "--\n" |
2698 | "\n" |
2699 | "Get the maximum scheduling priority for policy."); |
2700 | |
2701 | #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF \ |
2702 | {"sched_get_priority_max", _PyCFunction_CAST(os_sched_get_priority_max), METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_max__doc__}, |
2703 | |
2704 | static PyObject * |
2705 | os_sched_get_priority_max_impl(PyObject *module, int policy); |
2706 | |
2707 | static PyObject * |
2708 | os_sched_get_priority_max(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2709 | { |
2710 | PyObject *return_value = NULL; |
2711 | static const char * const _keywords[] = {"policy", NULL}; |
2712 | static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_max", 0}; |
2713 | PyObject *argsbuf[1]; |
2714 | int policy; |
2715 | |
2716 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
2717 | if (!args) { Branch (2717:9): [True: 0, False: 2]
|
2718 | goto exit; |
2719 | } |
2720 | policy = _PyLong_AsInt(args[0]); |
2721 | if (policy == -1 && PyErr_Occurred()0 ) { Branch (2721:9): [True: 0, False: 2]
Branch (2721:25): [True: 0, False: 0]
|
2722 | goto exit; |
2723 | } |
2724 | return_value = os_sched_get_priority_max_impl(module, policy); |
2725 | |
2726 | exit: |
2727 | return return_value; |
2728 | } |
2729 | |
2730 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */ |
2731 | |
2732 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) |
2733 | |
2734 | PyDoc_STRVAR(os_sched_get_priority_min__doc__, |
2735 | "sched_get_priority_min($module, /, policy)\n" |
2736 | "--\n" |
2737 | "\n" |
2738 | "Get the minimum scheduling priority for policy."); |
2739 | |
2740 | #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF \ |
2741 | {"sched_get_priority_min", _PyCFunction_CAST(os_sched_get_priority_min), METH_FASTCALL|METH_KEYWORDS, os_sched_get_priority_min__doc__}, |
2742 | |
2743 | static PyObject * |
2744 | os_sched_get_priority_min_impl(PyObject *module, int policy); |
2745 | |
2746 | static PyObject * |
2747 | os_sched_get_priority_min(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
2748 | { |
2749 | PyObject *return_value = NULL; |
2750 | static const char * const _keywords[] = {"policy", NULL}; |
2751 | static _PyArg_Parser _parser = {NULL, _keywords, "sched_get_priority_min", 0}; |
2752 | PyObject *argsbuf[1]; |
2753 | int policy; |
2754 | |
2755 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
2756 | if (!args) { Branch (2756:9): [True: 0, False: 6]
|
2757 | goto exit; |
2758 | } |
2759 | policy = _PyLong_AsInt(args[0]); |
2760 | if (policy == -1 && PyErr_Occurred()0 ) { Branch (2760:9): [True: 0, False: 6]
Branch (2760:25): [True: 0, False: 0]
|
2761 | goto exit; |
2762 | } |
2763 | return_value = os_sched_get_priority_min_impl(module, policy); |
2764 | |
2765 | exit: |
2766 | return return_value; |
2767 | } |
2768 | |
2769 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_GET_PRIORITY_MAX) */ |
2770 | |
2771 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) |
2772 | |
2773 | PyDoc_STRVAR(os_sched_getscheduler__doc__, |
2774 | "sched_getscheduler($module, pid, /)\n" |
2775 | "--\n" |
2776 | "\n" |
2777 | "Get the scheduling policy for the process identified by pid.\n" |
2778 | "\n" |
2779 | "Passing 0 for pid returns the scheduling policy for the calling process."); |
2780 | |
2781 | #define OS_SCHED_GETSCHEDULER_METHODDEF \ |
2782 | {"sched_getscheduler", (PyCFunction)os_sched_getscheduler, METH_O, os_sched_getscheduler__doc__}, |
2783 | |
2784 | static PyObject * |
2785 | os_sched_getscheduler_impl(PyObject *module, pid_t pid); |
2786 | |
2787 | static PyObject * |
2788 | os_sched_getscheduler(PyObject *module, PyObject *arg) |
2789 | { |
2790 | PyObject *return_value = NULL; |
2791 | pid_t pid; |
2792 | |
2793 | if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getscheduler", &pid)) { Branch (2793:9): [True: 0, False: 8]
|
2794 | goto exit; |
2795 | } |
2796 | return_value = os_sched_getscheduler_impl(module, pid); |
2797 | |
2798 | exit: |
2799 | return return_value; |
2800 | } |
2801 | |
2802 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ |
2803 | |
2804 | #if defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) |
2805 | |
2806 | PyDoc_STRVAR(os_sched_param__doc__, |
2807 | "sched_param(sched_priority)\n" |
2808 | "--\n" |
2809 | "\n" |
2810 | "Currently has only one field: sched_priority\n" |
2811 | "\n" |
2812 | " sched_priority\n" |
2813 | " A scheduling parameter."); |
2814 | |
2815 | static PyObject * |
2816 | os_sched_param_impl(PyTypeObject *type, PyObject *sched_priority); |
2817 | |
2818 | static PyObject * |
2819 | os_sched_param(PyTypeObject *type, PyObject *args, PyObject *kwargs) |
2820 | { |
2821 | PyObject *return_value = NULL; |
2822 | static const char * const _keywords[] = {"sched_priority", NULL}; |
2823 | static _PyArg_Parser _parser = {NULL, _keywords, "sched_param", 0}; |
2824 | PyObject *argsbuf[1]; |
2825 | PyObject * const *fastargs; |
2826 | Py_ssize_t nargs = PyTuple_GET_SIZE(args); |
2827 | PyObject *sched_priority; |
2828 | |
2829 | fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 1, 0, argsbuf); |
2830 | if (!fastargs) { Branch (2830:9): [True: 0, False: 7]
|
2831 | goto exit; |
2832 | } |
2833 | sched_priority = fastargs[0]; |
2834 | return_value = os_sched_param_impl(type, sched_priority); |
2835 | |
2836 | exit: |
2837 | return return_value; |
2838 | } |
2839 | |
2840 | #endif /* defined(HAVE_SCHED_H) && (defined(HAVE_SCHED_SETPARAM) || defined(HAVE_SCHED_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDULER) || defined(POSIX_SPAWN_SETSCHEDPARAM)) */ |
2841 | |
2842 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) |
2843 | |
2844 | PyDoc_STRVAR(os_sched_setscheduler__doc__, |
2845 | "sched_setscheduler($module, pid, policy, param, /)\n" |
2846 | "--\n" |
2847 | "\n" |
2848 | "Set the scheduling policy for the process identified by pid.\n" |
2849 | "\n" |
2850 | "If pid is 0, the calling process is changed.\n" |
2851 | "param is an instance of sched_param."); |
2852 | |
2853 | #define OS_SCHED_SETSCHEDULER_METHODDEF \ |
2854 | {"sched_setscheduler", _PyCFunction_CAST(os_sched_setscheduler), METH_FASTCALL, os_sched_setscheduler__doc__}, |
2855 | |
2856 | static PyObject * |
2857 | os_sched_setscheduler_impl(PyObject *module, pid_t pid, int policy, |
2858 | PyObject *param_obj); |
2859 | |
2860 | static PyObject * |
2861 | os_sched_setscheduler(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
2862 | { |
2863 | PyObject *return_value = NULL; |
2864 | pid_t pid; |
2865 | int policy; |
2866 | PyObject *param_obj; |
2867 | |
2868 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "iO:sched_setscheduler", Branch (2868:9): [True: 0, False: 3]
|
2869 | &pid, &policy, ¶m_obj)) { |
2870 | goto exit; |
2871 | } |
2872 | return_value = os_sched_setscheduler_impl(module, pid, policy, param_obj); |
2873 | |
2874 | exit: |
2875 | return return_value; |
2876 | } |
2877 | |
2878 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETSCHEDULER) */ |
2879 | |
2880 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) |
2881 | |
2882 | PyDoc_STRVAR(os_sched_getparam__doc__, |
2883 | "sched_getparam($module, pid, /)\n" |
2884 | "--\n" |
2885 | "\n" |
2886 | "Returns scheduling parameters for the process identified by pid.\n" |
2887 | "\n" |
2888 | "If pid is 0, returns parameters for the calling process.\n" |
2889 | "Return value is an instance of sched_param."); |
2890 | |
2891 | #define OS_SCHED_GETPARAM_METHODDEF \ |
2892 | {"sched_getparam", (PyCFunction)os_sched_getparam, METH_O, os_sched_getparam__doc__}, |
2893 | |
2894 | static PyObject * |
2895 | os_sched_getparam_impl(PyObject *module, pid_t pid); |
2896 | |
2897 | static PyObject * |
2898 | os_sched_getparam(PyObject *module, PyObject *arg) |
2899 | { |
2900 | PyObject *return_value = NULL; |
2901 | pid_t pid; |
2902 | |
2903 | if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getparam", &pid)) { Branch (2903:9): [True: 0, False: 2]
|
2904 | goto exit; |
2905 | } |
2906 | return_value = os_sched_getparam_impl(module, pid); |
2907 | |
2908 | exit: |
2909 | return return_value; |
2910 | } |
2911 | |
2912 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */ |
2913 | |
2914 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) |
2915 | |
2916 | PyDoc_STRVAR(os_sched_setparam__doc__, |
2917 | "sched_setparam($module, pid, param, /)\n" |
2918 | "--\n" |
2919 | "\n" |
2920 | "Set scheduling parameters for the process identified by pid.\n" |
2921 | "\n" |
2922 | "If pid is 0, sets parameters for the calling process.\n" |
2923 | "param should be an instance of sched_param."); |
2924 | |
2925 | #define OS_SCHED_SETPARAM_METHODDEF \ |
2926 | {"sched_setparam", _PyCFunction_CAST(os_sched_setparam), METH_FASTCALL, os_sched_setparam__doc__}, |
2927 | |
2928 | static PyObject * |
2929 | os_sched_setparam_impl(PyObject *module, pid_t pid, PyObject *param_obj); |
2930 | |
2931 | static PyObject * |
2932 | os_sched_setparam(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
2933 | { |
2934 | PyObject *return_value = NULL; |
2935 | pid_t pid; |
2936 | PyObject *param_obj; |
2937 | |
2938 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "O:sched_setparam", Branch (2938:9): [True: 0, False: 6]
|
2939 | &pid, ¶m_obj)) { |
2940 | goto exit; |
2941 | } |
2942 | return_value = os_sched_setparam_impl(module, pid, param_obj); |
2943 | |
2944 | exit: |
2945 | return return_value; |
2946 | } |
2947 | |
2948 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETPARAM) */ |
2949 | |
2950 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) |
2951 | |
2952 | PyDoc_STRVAR(os_sched_rr_get_interval__doc__, |
2953 | "sched_rr_get_interval($module, pid, /)\n" |
2954 | "--\n" |
2955 | "\n" |
2956 | "Return the round-robin quantum for the process identified by pid, in seconds.\n" |
2957 | "\n" |
2958 | "Value returned is a float."); |
2959 | |
2960 | #define OS_SCHED_RR_GET_INTERVAL_METHODDEF \ |
2961 | {"sched_rr_get_interval", (PyCFunction)os_sched_rr_get_interval, METH_O, os_sched_rr_get_interval__doc__}, |
2962 | |
2963 | static double |
2964 | os_sched_rr_get_interval_impl(PyObject *module, pid_t pid); |
2965 | |
2966 | static PyObject * |
2967 | os_sched_rr_get_interval(PyObject *module, PyObject *arg) |
2968 | { |
2969 | PyObject *return_value = NULL; |
2970 | pid_t pid; |
2971 | double _return_value; |
2972 | |
2973 | if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_rr_get_interval", &pid)) { Branch (2973:9): [True: 0, False: 1]
|
2974 | goto exit; |
2975 | } |
2976 | _return_value = os_sched_rr_get_interval_impl(module, pid); |
2977 | if ((_return_value == -1.0) && PyErr_Occurred()0 ) { Branch (2977:9): [True: 0, False: 1]
Branch (2977:36): [True: 0, False: 0]
|
2978 | goto exit; |
2979 | } |
2980 | return_value = PyFloat_FromDouble(_return_value); |
2981 | |
2982 | exit: |
2983 | return return_value; |
2984 | } |
2985 | |
2986 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_RR_GET_INTERVAL) */ |
2987 | |
2988 | #if defined(HAVE_SCHED_H) |
2989 | |
2990 | PyDoc_STRVAR(os_sched_yield__doc__, |
2991 | "sched_yield($module, /)\n" |
2992 | "--\n" |
2993 | "\n" |
2994 | "Voluntarily relinquish the CPU."); |
2995 | |
2996 | #define OS_SCHED_YIELD_METHODDEF \ |
2997 | {"sched_yield", (PyCFunction)os_sched_yield, METH_NOARGS, os_sched_yield__doc__}, |
2998 | |
2999 | static PyObject * |
3000 | os_sched_yield_impl(PyObject *module); |
3001 | |
3002 | static PyObject * |
3003 | os_sched_yield(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3004 | { |
3005 | return os_sched_yield_impl(module); |
3006 | } |
3007 | |
3008 | #endif /* defined(HAVE_SCHED_H) */ |
3009 | |
3010 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) |
3011 | |
3012 | PyDoc_STRVAR(os_sched_setaffinity__doc__, |
3013 | "sched_setaffinity($module, pid, mask, /)\n" |
3014 | "--\n" |
3015 | "\n" |
3016 | "Set the CPU affinity of the process identified by pid to mask.\n" |
3017 | "\n" |
3018 | "mask should be an iterable of integers identifying CPUs."); |
3019 | |
3020 | #define OS_SCHED_SETAFFINITY_METHODDEF \ |
3021 | {"sched_setaffinity", _PyCFunction_CAST(os_sched_setaffinity), METH_FASTCALL, os_sched_setaffinity__doc__}, |
3022 | |
3023 | static PyObject * |
3024 | os_sched_setaffinity_impl(PyObject *module, pid_t pid, PyObject *mask); |
3025 | |
3026 | static PyObject * |
3027 | os_sched_setaffinity(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3028 | { |
3029 | PyObject *return_value = NULL; |
3030 | pid_t pid; |
3031 | PyObject *mask; |
3032 | |
3033 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "O:sched_setaffinity", Branch (3033:9): [True: 0, False: 6]
|
3034 | &pid, &mask)) { |
3035 | goto exit; |
3036 | } |
3037 | return_value = os_sched_setaffinity_impl(module, pid, mask); |
3038 | |
3039 | exit: |
3040 | return return_value; |
3041 | } |
3042 | |
3043 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */ |
3044 | |
3045 | #if defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) |
3046 | |
3047 | PyDoc_STRVAR(os_sched_getaffinity__doc__, |
3048 | "sched_getaffinity($module, pid, /)\n" |
3049 | "--\n" |
3050 | "\n" |
3051 | "Return the affinity of the process identified by pid (or the current process if zero).\n" |
3052 | "\n" |
3053 | "The affinity is returned as a set of CPU identifiers."); |
3054 | |
3055 | #define OS_SCHED_GETAFFINITY_METHODDEF \ |
3056 | {"sched_getaffinity", (PyCFunction)os_sched_getaffinity, METH_O, os_sched_getaffinity__doc__}, |
3057 | |
3058 | static PyObject * |
3059 | os_sched_getaffinity_impl(PyObject *module, pid_t pid); |
3060 | |
3061 | static PyObject * |
3062 | os_sched_getaffinity(PyObject *module, PyObject *arg) |
3063 | { |
3064 | PyObject *return_value = NULL; |
3065 | pid_t pid; |
3066 | |
3067 | if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":sched_getaffinity", &pid)) { Branch (3067:9): [True: 0, False: 4]
|
3068 | goto exit; |
3069 | } |
3070 | return_value = os_sched_getaffinity_impl(module, pid); |
3071 | |
3072 | exit: |
3073 | return return_value; |
3074 | } |
3075 | |
3076 | #endif /* defined(HAVE_SCHED_H) && defined(HAVE_SCHED_SETAFFINITY) */ |
3077 | |
3078 | #if (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) |
3079 | |
3080 | PyDoc_STRVAR(os_openpty__doc__, |
3081 | "openpty($module, /)\n" |
3082 | "--\n" |
3083 | "\n" |
3084 | "Open a pseudo-terminal.\n" |
3085 | "\n" |
3086 | "Return a tuple of (master_fd, slave_fd) containing open file descriptors\n" |
3087 | "for both the master and slave ends."); |
3088 | |
3089 | #define OS_OPENPTY_METHODDEF \ |
3090 | {"openpty", (PyCFunction)os_openpty, METH_NOARGS, os_openpty__doc__}, |
3091 | |
3092 | static PyObject * |
3093 | os_openpty_impl(PyObject *module); |
3094 | |
3095 | static PyObject * |
3096 | os_openpty(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3097 | { |
3098 | return os_openpty_impl(module); |
3099 | } |
3100 | |
3101 | #endif /* (defined(HAVE_OPENPTY) || defined(HAVE__GETPTY) || defined(HAVE_DEV_PTMX)) */ |
3102 | |
3103 | #if (defined(HAVE_LOGIN_TTY) || defined(HAVE_FALLBACK_LOGIN_TTY)) |
3104 | |
3105 | PyDoc_STRVAR(os_login_tty__doc__, |
3106 | "login_tty($module, fd, /)\n" |
3107 | "--\n" |
3108 | "\n" |
3109 | "Prepare the tty of which fd is a file descriptor for a new login session.\n" |
3110 | "\n" |
3111 | "Make the calling process a session leader; make the tty the\n" |
3112 | "controlling tty, the stdin, the stdout, and the stderr of the\n" |
3113 | "calling process; close fd."); |
3114 | |
3115 | #define OS_LOGIN_TTY_METHODDEF \ |
3116 | {"login_tty", (PyCFunction)os_login_tty, METH_O, os_login_tty__doc__}, |
3117 | |
3118 | static PyObject * |
3119 | os_login_tty_impl(PyObject *module, int fd); |
3120 | |
3121 | static PyObject * |
3122 | os_login_tty(PyObject *module, PyObject *arg) |
3123 | { |
3124 | PyObject *return_value = NULL; |
3125 | int fd; |
3126 |
|
3127 | if (!_PyLong_FileDescriptor_Converter(arg, &fd)) { Branch (3127:9): [True: 0, False: 0]
|
3128 | goto exit; |
3129 | } |
3130 | return_value = os_login_tty_impl(module, fd); |
3131 |
|
3132 | exit: |
3133 | return return_value; |
3134 | } |
3135 | |
3136 | #endif /* (defined(HAVE_LOGIN_TTY) || defined(HAVE_FALLBACK_LOGIN_TTY)) */ |
3137 | |
3138 | #if defined(HAVE_FORKPTY) |
3139 | |
3140 | PyDoc_STRVAR(os_forkpty__doc__, |
3141 | "forkpty($module, /)\n" |
3142 | "--\n" |
3143 | "\n" |
3144 | "Fork a new process with a new pseudo-terminal as controlling tty.\n" |
3145 | "\n" |
3146 | "Returns a tuple of (pid, master_fd).\n" |
3147 | "Like fork(), return pid of 0 to the child process,\n" |
3148 | "and pid of child to the parent process.\n" |
3149 | "To both, return fd of newly opened pseudo-terminal."); |
3150 | |
3151 | #define OS_FORKPTY_METHODDEF \ |
3152 | {"forkpty", (PyCFunction)os_forkpty, METH_NOARGS, os_forkpty__doc__}, |
3153 | |
3154 | static PyObject * |
3155 | os_forkpty_impl(PyObject *module); |
3156 | |
3157 | static PyObject * |
3158 | os_forkpty(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3159 | { |
3160 | return os_forkpty_impl(module); |
3161 | } |
3162 | |
3163 | #endif /* defined(HAVE_FORKPTY) */ |
3164 | |
3165 | #if defined(HAVE_GETEGID) |
3166 | |
3167 | PyDoc_STRVAR(os_getegid__doc__, |
3168 | "getegid($module, /)\n" |
3169 | "--\n" |
3170 | "\n" |
3171 | "Return the current process\'s effective group id."); |
3172 | |
3173 | #define OS_GETEGID_METHODDEF \ |
3174 | {"getegid", (PyCFunction)os_getegid, METH_NOARGS, os_getegid__doc__}, |
3175 | |
3176 | static PyObject * |
3177 | os_getegid_impl(PyObject *module); |
3178 | |
3179 | static PyObject * |
3180 | os_getegid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3181 | { |
3182 | return os_getegid_impl(module); |
3183 | } |
3184 | |
3185 | #endif /* defined(HAVE_GETEGID) */ |
3186 | |
3187 | #if defined(HAVE_GETEUID) |
3188 | |
3189 | PyDoc_STRVAR(os_geteuid__doc__, |
3190 | "geteuid($module, /)\n" |
3191 | "--\n" |
3192 | "\n" |
3193 | "Return the current process\'s effective user id."); |
3194 | |
3195 | #define OS_GETEUID_METHODDEF \ |
3196 | {"geteuid", (PyCFunction)os_geteuid, METH_NOARGS, os_geteuid__doc__}, |
3197 | |
3198 | static PyObject * |
3199 | os_geteuid_impl(PyObject *module); |
3200 | |
3201 | static PyObject * |
3202 | os_geteuid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3203 | { |
3204 | return os_geteuid_impl(module); |
3205 | } |
3206 | |
3207 | #endif /* defined(HAVE_GETEUID) */ |
3208 | |
3209 | #if defined(HAVE_GETGID) |
3210 | |
3211 | PyDoc_STRVAR(os_getgid__doc__, |
3212 | "getgid($module, /)\n" |
3213 | "--\n" |
3214 | "\n" |
3215 | "Return the current process\'s group id."); |
3216 | |
3217 | #define OS_GETGID_METHODDEF \ |
3218 | {"getgid", (PyCFunction)os_getgid, METH_NOARGS, os_getgid__doc__}, |
3219 | |
3220 | static PyObject * |
3221 | os_getgid_impl(PyObject *module); |
3222 | |
3223 | static PyObject * |
3224 | os_getgid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3225 | { |
3226 | return os_getgid_impl(module); |
3227 | } |
3228 | |
3229 | #endif /* defined(HAVE_GETGID) */ |
3230 | |
3231 | #if defined(HAVE_GETPID) |
3232 | |
3233 | PyDoc_STRVAR(os_getpid__doc__, |
3234 | "getpid($module, /)\n" |
3235 | "--\n" |
3236 | "\n" |
3237 | "Return the current process id."); |
3238 | |
3239 | #define OS_GETPID_METHODDEF \ |
3240 | {"getpid", (PyCFunction)os_getpid, METH_NOARGS, os_getpid__doc__}, |
3241 | |
3242 | static PyObject * |
3243 | os_getpid_impl(PyObject *module); |
3244 | |
3245 | static PyObject * |
3246 | os_getpid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3247 | { |
3248 | return os_getpid_impl(module); |
3249 | } |
3250 | |
3251 | #endif /* defined(HAVE_GETPID) */ |
3252 | |
3253 | #if defined(HAVE_GETGROUPLIST) && defined(__APPLE__) |
3254 | |
3255 | PyDoc_STRVAR(os_getgrouplist__doc__, |
3256 | "getgrouplist($module, user, group, /)\n" |
3257 | "--\n" |
3258 | "\n" |
3259 | "Returns a list of groups to which a user belongs.\n" |
3260 | "\n" |
3261 | " user\n" |
3262 | " username to lookup\n" |
3263 | " group\n" |
3264 | " base group id of the user"); |
3265 | |
3266 | #define OS_GETGROUPLIST_METHODDEF \ |
3267 | {"getgrouplist", _PyCFunction_CAST(os_getgrouplist), METH_FASTCALL, os_getgrouplist__doc__}, |
3268 | |
3269 | static PyObject * |
3270 | os_getgrouplist_impl(PyObject *module, const char *user, int basegid); |
3271 | |
3272 | static PyObject * |
3273 | os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3274 | { |
3275 | PyObject *return_value = NULL; |
3276 | const char *user; |
3277 | int basegid; |
3278 | |
3279 | if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { |
3280 | goto exit; |
3281 | } |
3282 | if (!PyUnicode_Check(args[0])) { |
3283 | _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); |
3284 | goto exit; |
3285 | } |
3286 | Py_ssize_t user_length; |
3287 | user = PyUnicode_AsUTF8AndSize(args[0], &user_length); |
3288 | if (user == NULL) { |
3289 | goto exit; |
3290 | } |
3291 | if (strlen(user) != (size_t)user_length) { |
3292 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
3293 | goto exit; |
3294 | } |
3295 | basegid = _PyLong_AsInt(args[1]); |
3296 | if (basegid == -1 && PyErr_Occurred()) { |
3297 | goto exit; |
3298 | } |
3299 | return_value = os_getgrouplist_impl(module, user, basegid); |
3300 | |
3301 | exit: |
3302 | return return_value; |
3303 | } |
3304 | |
3305 | #endif /* defined(HAVE_GETGROUPLIST) && defined(__APPLE__) */ |
3306 | |
3307 | #if defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) |
3308 | |
3309 | PyDoc_STRVAR(os_getgrouplist__doc__, |
3310 | "getgrouplist($module, user, group, /)\n" |
3311 | "--\n" |
3312 | "\n" |
3313 | "Returns a list of groups to which a user belongs.\n" |
3314 | "\n" |
3315 | " user\n" |
3316 | " username to lookup\n" |
3317 | " group\n" |
3318 | " base group id of the user"); |
3319 | |
3320 | #define OS_GETGROUPLIST_METHODDEF \ |
3321 | {"getgrouplist", _PyCFunction_CAST(os_getgrouplist), METH_FASTCALL, os_getgrouplist__doc__}, |
3322 | |
3323 | static PyObject * |
3324 | os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid); |
3325 | |
3326 | static PyObject * |
3327 | os_getgrouplist(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3328 | { |
3329 | PyObject *return_value = NULL; |
3330 | const char *user; |
3331 | gid_t basegid; |
3332 | |
3333 | if (!_PyArg_CheckPositional("getgrouplist", nargs, 2, 2)) { |
3334 | goto exit; |
3335 | } |
3336 | if (!PyUnicode_Check(args[0])) { Branch (3336:9): [True: 0, False: 1]
|
3337 | _PyArg_BadArgument("getgrouplist", "argument 1", "str", args[0]); |
3338 | goto exit; |
3339 | } |
3340 | Py_ssize_t user_length; |
3341 | user = PyUnicode_AsUTF8AndSize(args[0], &user_length); |
3342 | if (user == NULL) { Branch (3342:9): [True: 0, False: 1]
|
3343 | goto exit; |
3344 | } |
3345 | if (strlen(user) != (size_t)user_length) { Branch (3345:9): [True: 0, False: 1]
|
3346 | PyErr_SetString(PyExc_ValueError, "embedded null character"); |
3347 | goto exit; |
3348 | } |
3349 | if (!_Py_Gid_Converter(args[1], &basegid)) { Branch (3349:9): [True: 0, False: 1]
|
3350 | goto exit; |
3351 | } |
3352 | return_value = os_getgrouplist_impl(module, user, basegid); |
3353 | |
3354 | exit: |
3355 | return return_value; |
3356 | } |
3357 | |
3358 | #endif /* defined(HAVE_GETGROUPLIST) && !defined(__APPLE__) */ |
3359 | |
3360 | #if defined(HAVE_GETGROUPS) |
3361 | |
3362 | PyDoc_STRVAR(os_getgroups__doc__, |
3363 | "getgroups($module, /)\n" |
3364 | "--\n" |
3365 | "\n" |
3366 | "Return list of supplemental group IDs for the process."); |
3367 | |
3368 | #define OS_GETGROUPS_METHODDEF \ |
3369 | {"getgroups", (PyCFunction)os_getgroups, METH_NOARGS, os_getgroups__doc__}, |
3370 | |
3371 | static PyObject * |
3372 | os_getgroups_impl(PyObject *module); |
3373 | |
3374 | static PyObject * |
3375 | os_getgroups(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3376 | { |
3377 | return os_getgroups_impl(module); |
3378 | } |
3379 | |
3380 | #endif /* defined(HAVE_GETGROUPS) */ |
3381 | |
3382 | #if defined(HAVE_INITGROUPS) && defined(__APPLE__) |
3383 | |
3384 | PyDoc_STRVAR(os_initgroups__doc__, |
3385 | "initgroups($module, username, gid, /)\n" |
3386 | "--\n" |
3387 | "\n" |
3388 | "Initialize the group access list.\n" |
3389 | "\n" |
3390 | "Call the system initgroups() to initialize the group access list with all of\n" |
3391 | "the groups of which the specified username is a member, plus the specified\n" |
3392 | "group id."); |
3393 | |
3394 | #define OS_INITGROUPS_METHODDEF \ |
3395 | {"initgroups", _PyCFunction_CAST(os_initgroups), METH_FASTCALL, os_initgroups__doc__}, |
3396 | |
3397 | static PyObject * |
3398 | os_initgroups_impl(PyObject *module, PyObject *oname, int gid); |
3399 | |
3400 | static PyObject * |
3401 | os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3402 | { |
3403 | PyObject *return_value = NULL; |
3404 | PyObject *oname = NULL; |
3405 | int gid; |
3406 | |
3407 | if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { |
3408 | goto exit; |
3409 | } |
3410 | if (!PyUnicode_FSConverter(args[0], &oname)) { |
3411 | goto exit; |
3412 | } |
3413 | gid = _PyLong_AsInt(args[1]); |
3414 | if (gid == -1 && PyErr_Occurred()) { |
3415 | goto exit; |
3416 | } |
3417 | return_value = os_initgroups_impl(module, oname, gid); |
3418 | |
3419 | exit: |
3420 | /* Cleanup for oname */ |
3421 | Py_XDECREF(oname); |
3422 | |
3423 | return return_value; |
3424 | } |
3425 | |
3426 | #endif /* defined(HAVE_INITGROUPS) && defined(__APPLE__) */ |
3427 | |
3428 | #if defined(HAVE_INITGROUPS) && !defined(__APPLE__) |
3429 | |
3430 | PyDoc_STRVAR(os_initgroups__doc__, |
3431 | "initgroups($module, username, gid, /)\n" |
3432 | "--\n" |
3433 | "\n" |
3434 | "Initialize the group access list.\n" |
3435 | "\n" |
3436 | "Call the system initgroups() to initialize the group access list with all of\n" |
3437 | "the groups of which the specified username is a member, plus the specified\n" |
3438 | "group id."); |
3439 | |
3440 | #define OS_INITGROUPS_METHODDEF \ |
3441 | {"initgroups", _PyCFunction_CAST(os_initgroups), METH_FASTCALL, os_initgroups__doc__}, |
3442 | |
3443 | static PyObject * |
3444 | os_initgroups_impl(PyObject *module, PyObject *oname, gid_t gid); |
3445 | |
3446 | static PyObject * |
3447 | os_initgroups(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3448 | { |
3449 | PyObject *return_value = NULL; |
3450 | PyObject *oname = NULL; |
3451 | gid_t gid; |
3452 | |
3453 | if (!_PyArg_CheckPositional("initgroups", nargs, 2, 2)) { |
3454 | goto exit; |
3455 | } |
3456 | if (!PyUnicode_FSConverter(args[0], &oname)) { Branch (3456:9): [True: 1, False: 1]
|
3457 | goto exit; |
3458 | } |
3459 | if (!_Py_Gid_Converter(args[1], &gid)) { Branch (3459:9): [True: 0, False: 1]
|
3460 | goto exit; |
3461 | } |
3462 | return_value = os_initgroups_impl(module, oname, gid); |
3463 | |
3464 | exit: |
3465 | /* Cleanup for oname */ |
3466 | Py_XDECREF(oname); |
3467 | |
3468 | return return_value; |
3469 | } |
3470 | |
3471 | #endif /* defined(HAVE_INITGROUPS) && !defined(__APPLE__) */ |
3472 | |
3473 | #if defined(HAVE_GETPGID) |
3474 | |
3475 | PyDoc_STRVAR(os_getpgid__doc__, |
3476 | "getpgid($module, /, pid)\n" |
3477 | "--\n" |
3478 | "\n" |
3479 | "Call the system call getpgid(), and return the result."); |
3480 | |
3481 | #define OS_GETPGID_METHODDEF \ |
3482 | {"getpgid", _PyCFunction_CAST(os_getpgid), METH_FASTCALL|METH_KEYWORDS, os_getpgid__doc__}, |
3483 | |
3484 | static PyObject * |
3485 | os_getpgid_impl(PyObject *module, pid_t pid); |
3486 | |
3487 | static PyObject * |
3488 | os_getpgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
3489 | { |
3490 | PyObject *return_value = NULL; |
3491 | static const char * const _keywords[] = {"pid", NULL}; |
3492 | static _PyArg_Parser _parser = {"" _Py_PARSE_PID ":getpgid", _keywords, 0}; |
3493 | pid_t pid; |
3494 | |
3495 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, Branch (3495:9): [True: 0, False: 1]
|
3496 | &pid)) { |
3497 | goto exit; |
3498 | } |
3499 | return_value = os_getpgid_impl(module, pid); |
3500 | |
3501 | exit: |
3502 | return return_value; |
3503 | } |
3504 | |
3505 | #endif /* defined(HAVE_GETPGID) */ |
3506 | |
3507 | #if defined(HAVE_GETPGRP) |
3508 | |
3509 | PyDoc_STRVAR(os_getpgrp__doc__, |
3510 | "getpgrp($module, /)\n" |
3511 | "--\n" |
3512 | "\n" |
3513 | "Return the current process group id."); |
3514 | |
3515 | #define OS_GETPGRP_METHODDEF \ |
3516 | {"getpgrp", (PyCFunction)os_getpgrp, METH_NOARGS, os_getpgrp__doc__}, |
3517 | |
3518 | static PyObject * |
3519 | os_getpgrp_impl(PyObject *module); |
3520 | |
3521 | static PyObject * |
3522 | os_getpgrp(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3523 | { |
3524 | return os_getpgrp_impl(module); |
3525 | } |
3526 | |
3527 | #endif /* defined(HAVE_GETPGRP) */ |
3528 | |
3529 | #if defined(HAVE_SETPGRP) |
3530 | |
3531 | PyDoc_STRVAR(os_setpgrp__doc__, |
3532 | "setpgrp($module, /)\n" |
3533 | "--\n" |
3534 | "\n" |
3535 | "Make the current process the leader of its process group."); |
3536 | |
3537 | #define OS_SETPGRP_METHODDEF \ |
3538 | {"setpgrp", (PyCFunction)os_setpgrp, METH_NOARGS, os_setpgrp__doc__}, |
3539 | |
3540 | static PyObject * |
3541 | os_setpgrp_impl(PyObject *module); |
3542 | |
3543 | static PyObject * |
3544 | os_setpgrp(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3545 | { |
3546 | return os_setpgrp_impl(module); |
3547 | } |
3548 | |
3549 | #endif /* defined(HAVE_SETPGRP) */ |
3550 | |
3551 | #if defined(HAVE_GETPPID) |
3552 | |
3553 | PyDoc_STRVAR(os_getppid__doc__, |
3554 | "getppid($module, /)\n" |
3555 | "--\n" |
3556 | "\n" |
3557 | "Return the parent\'s process id.\n" |
3558 | "\n" |
3559 | "If the parent process has already exited, Windows machines will still\n" |
3560 | "return its id; others systems will return the id of the \'init\' process (1)."); |
3561 | |
3562 | #define OS_GETPPID_METHODDEF \ |
3563 | {"getppid", (PyCFunction)os_getppid, METH_NOARGS, os_getppid__doc__}, |
3564 | |
3565 | static PyObject * |
3566 | os_getppid_impl(PyObject *module); |
3567 | |
3568 | static PyObject * |
3569 | os_getppid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3570 | { |
3571 | return os_getppid_impl(module); |
3572 | } |
3573 | |
3574 | #endif /* defined(HAVE_GETPPID) */ |
3575 | |
3576 | #if defined(HAVE_GETLOGIN) |
3577 | |
3578 | PyDoc_STRVAR(os_getlogin__doc__, |
3579 | "getlogin($module, /)\n" |
3580 | "--\n" |
3581 | "\n" |
3582 | "Return the actual login name."); |
3583 | |
3584 | #define OS_GETLOGIN_METHODDEF \ |
3585 | {"getlogin", (PyCFunction)os_getlogin, METH_NOARGS, os_getlogin__doc__}, |
3586 | |
3587 | static PyObject * |
3588 | os_getlogin_impl(PyObject *module); |
3589 | |
3590 | static PyObject * |
3591 | os_getlogin(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3592 | { |
3593 | return os_getlogin_impl(module); |
3594 | } |
3595 | |
3596 | #endif /* defined(HAVE_GETLOGIN) */ |
3597 | |
3598 | #if defined(HAVE_GETUID) |
3599 | |
3600 | PyDoc_STRVAR(os_getuid__doc__, |
3601 | "getuid($module, /)\n" |
3602 | "--\n" |
3603 | "\n" |
3604 | "Return the current process\'s user id."); |
3605 | |
3606 | #define OS_GETUID_METHODDEF \ |
3607 | {"getuid", (PyCFunction)os_getuid, METH_NOARGS, os_getuid__doc__}, |
3608 | |
3609 | static PyObject * |
3610 | os_getuid_impl(PyObject *module); |
3611 | |
3612 | static PyObject * |
3613 | os_getuid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
3614 | { |
3615 | return os_getuid_impl(module); |
3616 | } |
3617 | |
3618 | #endif /* defined(HAVE_GETUID) */ |
3619 | |
3620 | #if defined(HAVE_KILL) |
3621 | |
3622 | PyDoc_STRVAR(os_kill__doc__, |
3623 | "kill($module, pid, signal, /)\n" |
3624 | "--\n" |
3625 | "\n" |
3626 | "Kill a process with a signal."); |
3627 | |
3628 | #define OS_KILL_METHODDEF \ |
3629 | {"kill", _PyCFunction_CAST(os_kill), METH_FASTCALL, os_kill__doc__}, |
3630 | |
3631 | static PyObject * |
3632 | os_kill_impl(PyObject *module, pid_t pid, Py_ssize_t signal); |
3633 | |
3634 | static PyObject * |
3635 | os_kill(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3636 | { |
3637 | PyObject *return_value = NULL; |
3638 | pid_t pid; |
3639 | Py_ssize_t signal; |
3640 | |
3641 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "n:kill", Branch (3641:9): [True: 0, False: 15.7k]
|
3642 | &pid, &signal)) { |
3643 | goto exit; |
3644 | } |
3645 | return_value = os_kill_impl(module, pid, signal); |
3646 | |
3647 | exit: |
3648 | return return_value; |
3649 | } |
3650 | |
3651 | #endif /* defined(HAVE_KILL) */ |
3652 | |
3653 | #if defined(HAVE_KILLPG) |
3654 | |
3655 | PyDoc_STRVAR(os_killpg__doc__, |
3656 | "killpg($module, pgid, signal, /)\n" |
3657 | "--\n" |
3658 | "\n" |
3659 | "Kill a process group with a signal."); |
3660 | |
3661 | #define OS_KILLPG_METHODDEF \ |
3662 | {"killpg", _PyCFunction_CAST(os_killpg), METH_FASTCALL, os_killpg__doc__}, |
3663 | |
3664 | static PyObject * |
3665 | os_killpg_impl(PyObject *module, pid_t pgid, int signal); |
3666 | |
3667 | static PyObject * |
3668 | os_killpg(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3669 | { |
3670 | PyObject *return_value = NULL; |
3671 | pid_t pgid; |
3672 | int signal; |
3673 |
|
3674 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "i:killpg", Branch (3674:9): [True: 0, False: 0]
|
3675 | &pgid, &signal)) { |
3676 | goto exit; |
3677 | } |
3678 | return_value = os_killpg_impl(module, pgid, signal); |
3679 |
|
3680 | exit: |
3681 | return return_value; |
3682 | } |
3683 | |
3684 | #endif /* defined(HAVE_KILLPG) */ |
3685 | |
3686 | #if defined(HAVE_PLOCK) |
3687 | |
3688 | PyDoc_STRVAR(os_plock__doc__, |
3689 | "plock($module, op, /)\n" |
3690 | "--\n" |
3691 | "\n" |
3692 | "Lock program segments into memory.\");"); |
3693 | |
3694 | #define OS_PLOCK_METHODDEF \ |
3695 | {"plock", (PyCFunction)os_plock, METH_O, os_plock__doc__}, |
3696 | |
3697 | static PyObject * |
3698 | os_plock_impl(PyObject *module, int op); |
3699 | |
3700 | static PyObject * |
3701 | os_plock(PyObject *module, PyObject *arg) |
3702 | { |
3703 | PyObject *return_value = NULL; |
3704 | int op; |
3705 | |
3706 | op = _PyLong_AsInt(arg); |
3707 | if (op == -1 && PyErr_Occurred()) { |
3708 | goto exit; |
3709 | } |
3710 | return_value = os_plock_impl(module, op); |
3711 | |
3712 | exit: |
3713 | return return_value; |
3714 | } |
3715 | |
3716 | #endif /* defined(HAVE_PLOCK) */ |
3717 | |
3718 | #if defined(HAVE_SETUID) |
3719 | |
3720 | PyDoc_STRVAR(os_setuid__doc__, |
3721 | "setuid($module, uid, /)\n" |
3722 | "--\n" |
3723 | "\n" |
3724 | "Set the current process\'s user id."); |
3725 | |
3726 | #define OS_SETUID_METHODDEF \ |
3727 | {"setuid", (PyCFunction)os_setuid, METH_O, os_setuid__doc__}, |
3728 | |
3729 | static PyObject * |
3730 | os_setuid_impl(PyObject *module, uid_t uid); |
3731 | |
3732 | static PyObject * |
3733 | os_setuid(PyObject *module, PyObject *arg) |
3734 | { |
3735 | PyObject *return_value = NULL; |
3736 | uid_t uid; |
3737 | |
3738 | if (!_Py_Uid_Converter(arg, &uid)) { Branch (3738:9): [True: 2, False: 1]
|
3739 | goto exit; |
3740 | } |
3741 | return_value = os_setuid_impl(module, uid); |
3742 | |
3743 | exit: |
3744 | return return_value; |
3745 | } |
3746 | |
3747 | #endif /* defined(HAVE_SETUID) */ |
3748 | |
3749 | #if defined(HAVE_SETEUID) |
3750 | |
3751 | PyDoc_STRVAR(os_seteuid__doc__, |
3752 | "seteuid($module, euid, /)\n" |
3753 | "--\n" |
3754 | "\n" |
3755 | "Set the current process\'s effective user id."); |
3756 | |
3757 | #define OS_SETEUID_METHODDEF \ |
3758 | {"seteuid", (PyCFunction)os_seteuid, METH_O, os_seteuid__doc__}, |
3759 | |
3760 | static PyObject * |
3761 | os_seteuid_impl(PyObject *module, uid_t euid); |
3762 | |
3763 | static PyObject * |
3764 | os_seteuid(PyObject *module, PyObject *arg) |
3765 | { |
3766 | PyObject *return_value = NULL; |
3767 | uid_t euid; |
3768 | |
3769 | if (!_Py_Uid_Converter(arg, &euid)) { Branch (3769:9): [True: 1, False: 1]
|
3770 | goto exit; |
3771 | } |
3772 | return_value = os_seteuid_impl(module, euid); |
3773 | |
3774 | exit: |
3775 | return return_value; |
3776 | } |
3777 | |
3778 | #endif /* defined(HAVE_SETEUID) */ |
3779 | |
3780 | #if defined(HAVE_SETEGID) |
3781 | |
3782 | PyDoc_STRVAR(os_setegid__doc__, |
3783 | "setegid($module, egid, /)\n" |
3784 | "--\n" |
3785 | "\n" |
3786 | "Set the current process\'s effective group id."); |
3787 | |
3788 | #define OS_SETEGID_METHODDEF \ |
3789 | {"setegid", (PyCFunction)os_setegid, METH_O, os_setegid__doc__}, |
3790 | |
3791 | static PyObject * |
3792 | os_setegid_impl(PyObject *module, gid_t egid); |
3793 | |
3794 | static PyObject * |
3795 | os_setegid(PyObject *module, PyObject *arg) |
3796 | { |
3797 | PyObject *return_value = NULL; |
3798 | gid_t egid; |
3799 | |
3800 | if (!_Py_Gid_Converter(arg, &egid)) { Branch (3800:9): [True: 3, False: 1]
|
3801 | goto exit; |
3802 | } |
3803 | return_value = os_setegid_impl(module, egid); |
3804 | |
3805 | exit: |
3806 | return return_value; |
3807 | } |
3808 | |
3809 | #endif /* defined(HAVE_SETEGID) */ |
3810 | |
3811 | #if defined(HAVE_SETREUID) |
3812 | |
3813 | PyDoc_STRVAR(os_setreuid__doc__, |
3814 | "setreuid($module, ruid, euid, /)\n" |
3815 | "--\n" |
3816 | "\n" |
3817 | "Set the current process\'s real and effective user ids."); |
3818 | |
3819 | #define OS_SETREUID_METHODDEF \ |
3820 | {"setreuid", _PyCFunction_CAST(os_setreuid), METH_FASTCALL, os_setreuid__doc__}, |
3821 | |
3822 | static PyObject * |
3823 | os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid); |
3824 | |
3825 | static PyObject * |
3826 | os_setreuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3827 | { |
3828 | PyObject *return_value = NULL; |
3829 | uid_t ruid; |
3830 | uid_t euid; |
3831 | |
3832 | if (!_PyArg_CheckPositional("setreuid", nargs, 2, 2)) { |
3833 | goto exit; |
3834 | } |
3835 | if (!_Py_Uid_Converter(args[0], &ruid)) { Branch (3835:9): [True: 2, False: 3]
|
3836 | goto exit; |
3837 | } |
3838 | if (!_Py_Uid_Converter(args[1], &euid)) { Branch (3838:9): [True: 2, False: 1]
|
3839 | goto exit; |
3840 | } |
3841 | return_value = os_setreuid_impl(module, ruid, euid); |
3842 | |
3843 | exit: |
3844 | return return_value; |
3845 | } |
3846 | |
3847 | #endif /* defined(HAVE_SETREUID) */ |
3848 | |
3849 | #if defined(HAVE_SETREGID) |
3850 | |
3851 | PyDoc_STRVAR(os_setregid__doc__, |
3852 | "setregid($module, rgid, egid, /)\n" |
3853 | "--\n" |
3854 | "\n" |
3855 | "Set the current process\'s real and effective group ids."); |
3856 | |
3857 | #define OS_SETREGID_METHODDEF \ |
3858 | {"setregid", _PyCFunction_CAST(os_setregid), METH_FASTCALL, os_setregid__doc__}, |
3859 | |
3860 | static PyObject * |
3861 | os_setregid_impl(PyObject *module, gid_t rgid, gid_t egid); |
3862 | |
3863 | static PyObject * |
3864 | os_setregid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
3865 | { |
3866 | PyObject *return_value = NULL; |
3867 | gid_t rgid; |
3868 | gid_t egid; |
3869 | |
3870 | if (!_PyArg_CheckPositional("setregid", nargs, 2, 2)) { |
3871 | goto exit; |
3872 | } |
3873 | if (!_Py_Gid_Converter(args[0], &rgid)) { Branch (3873:9): [True: 2, False: 3]
|
3874 | goto exit; |
3875 | } |
3876 | if (!_Py_Gid_Converter(args[1], &egid)) { Branch (3876:9): [True: 2, False: 1]
|
3877 | goto exit; |
3878 | } |
3879 | return_value = os_setregid_impl(module, rgid, egid); |
3880 | |
3881 | exit: |
3882 | return return_value; |
3883 | } |
3884 | |
3885 | #endif /* defined(HAVE_SETREGID) */ |
3886 | |
3887 | #if defined(HAVE_SETGID) |
3888 | |
3889 | PyDoc_STRVAR(os_setgid__doc__, |
3890 | "setgid($module, gid, /)\n" |
3891 | "--\n" |
3892 | "\n" |
3893 | "Set the current process\'s group id."); |
3894 | |
3895 | #define OS_SETGID_METHODDEF \ |
3896 | {"setgid", (PyCFunction)os_setgid, METH_O, os_setgid__doc__}, |
3897 | |
3898 | static PyObject * |
3899 | os_setgid_impl(PyObject *module, gid_t gid); |
3900 | |
3901 | static PyObject * |
3902 | os_setgid(PyObject *module, PyObject *arg) |
3903 | { |
3904 | PyObject *return_value = NULL; |
3905 | gid_t gid; |
3906 | |
3907 | if (!_Py_Gid_Converter(arg, &gid)) { Branch (3907:9): [True: 2, False: 1]
|
3908 | goto exit; |
3909 | } |
3910 | return_value = os_setgid_impl(module, gid); |
3911 | |
3912 | exit: |
3913 | return return_value; |
3914 | } |
3915 | |
3916 | #endif /* defined(HAVE_SETGID) */ |
3917 | |
3918 | #if defined(HAVE_SETGROUPS) |
3919 | |
3920 | PyDoc_STRVAR(os_setgroups__doc__, |
3921 | "setgroups($module, groups, /)\n" |
3922 | "--\n" |
3923 | "\n" |
3924 | "Set the groups of the current process to list."); |
3925 | |
3926 | #define OS_SETGROUPS_METHODDEF \ |
3927 | {"setgroups", (PyCFunction)os_setgroups, METH_O, os_setgroups__doc__}, |
3928 | |
3929 | #endif /* defined(HAVE_SETGROUPS) */ |
3930 | |
3931 | #if defined(HAVE_WAIT3) |
3932 | |
3933 | PyDoc_STRVAR(os_wait3__doc__, |
3934 | "wait3($module, /, options)\n" |
3935 | "--\n" |
3936 | "\n" |
3937 | "Wait for completion of a child process.\n" |
3938 | "\n" |
3939 | "Returns a tuple of information about the child process:\n" |
3940 | " (pid, status, rusage)"); |
3941 | |
3942 | #define OS_WAIT3_METHODDEF \ |
3943 | {"wait3", _PyCFunction_CAST(os_wait3), METH_FASTCALL|METH_KEYWORDS, os_wait3__doc__}, |
3944 | |
3945 | static PyObject * |
3946 | os_wait3_impl(PyObject *module, int options); |
3947 | |
3948 | static PyObject * |
3949 | os_wait3(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
3950 | { |
3951 | PyObject *return_value = NULL; |
3952 | static const char * const _keywords[] = {"options", NULL}; |
3953 | static _PyArg_Parser _parser = {NULL, _keywords, "wait3", 0}; |
3954 | PyObject *argsbuf[1]; |
3955 | int options; |
3956 | |
3957 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
3958 | if (!args) { Branch (3958:9): [True: 0, False: 10]
|
3959 | goto exit; |
3960 | } |
3961 | options = _PyLong_AsInt(args[0]); |
3962 | if (options == -1 && PyErr_Occurred()0 ) { Branch (3962:9): [True: 0, False: 10]
Branch (3962:26): [True: 0, False: 0]
|
3963 | goto exit; |
3964 | } |
3965 | return_value = os_wait3_impl(module, options); |
3966 | |
3967 | exit: |
3968 | return return_value; |
3969 | } |
3970 | |
3971 | #endif /* defined(HAVE_WAIT3) */ |
3972 | |
3973 | #if defined(HAVE_WAIT4) |
3974 | |
3975 | PyDoc_STRVAR(os_wait4__doc__, |
3976 | "wait4($module, /, pid, options)\n" |
3977 | "--\n" |
3978 | "\n" |
3979 | "Wait for completion of a specific child process.\n" |
3980 | "\n" |
3981 | "Returns a tuple of information about the child process:\n" |
3982 | " (pid, status, rusage)"); |
3983 | |
3984 | #define OS_WAIT4_METHODDEF \ |
3985 | {"wait4", _PyCFunction_CAST(os_wait4), METH_FASTCALL|METH_KEYWORDS, os_wait4__doc__}, |
3986 | |
3987 | static PyObject * |
3988 | os_wait4_impl(PyObject *module, pid_t pid, int options); |
3989 | |
3990 | static PyObject * |
3991 | os_wait4(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
3992 | { |
3993 | PyObject *return_value = NULL; |
3994 | static const char * const _keywords[] = {"pid", "options", NULL}; |
3995 | static _PyArg_Parser _parser = {"" _Py_PARSE_PID "i:wait4", _keywords, 0}; |
3996 | pid_t pid; |
3997 | int options; |
3998 | |
3999 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, Branch (3999:9): [True: 0, False: 9]
|
4000 | &pid, &options)) { |
4001 | goto exit; |
4002 | } |
4003 | return_value = os_wait4_impl(module, pid, options); |
4004 | |
4005 | exit: |
4006 | return return_value; |
4007 | } |
4008 | |
4009 | #endif /* defined(HAVE_WAIT4) */ |
4010 | |
4011 | #if (defined(HAVE_WAITID) && !defined(__APPLE__)) |
4012 | |
4013 | PyDoc_STRVAR(os_waitid__doc__, |
4014 | "waitid($module, idtype, id, options, /)\n" |
4015 | "--\n" |
4016 | "\n" |
4017 | "Returns the result of waiting for a process or processes.\n" |
4018 | "\n" |
4019 | " idtype\n" |
4020 | " Must be one of be P_PID, P_PGID or P_ALL.\n" |
4021 | " id\n" |
4022 | " The id to wait on.\n" |
4023 | " options\n" |
4024 | " Constructed from the ORing of one or more of WEXITED, WSTOPPED\n" |
4025 | " or WCONTINUED and additionally may be ORed with WNOHANG or WNOWAIT.\n" |
4026 | "\n" |
4027 | "Returns either waitid_result or None if WNOHANG is specified and there are\n" |
4028 | "no children in a waitable state."); |
4029 | |
4030 | #define OS_WAITID_METHODDEF \ |
4031 | {"waitid", _PyCFunction_CAST(os_waitid), METH_FASTCALL, os_waitid__doc__}, |
4032 | |
4033 | static PyObject * |
4034 | os_waitid_impl(PyObject *module, idtype_t idtype, id_t id, int options); |
4035 | |
4036 | static PyObject * |
4037 | os_waitid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4038 | { |
4039 | PyObject *return_value = NULL; |
4040 | idtype_t idtype; |
4041 | id_t id; |
4042 | int options; |
4043 | |
4044 | if (!_PyArg_ParseStack(args, nargs, "i" _Py_PARSE_PID "i:waitid", Branch (4044:9): [True: 0, False: 1]
|
4045 | &idtype, &id, &options)) { |
4046 | goto exit; |
4047 | } |
4048 | return_value = os_waitid_impl(module, idtype, id, options); |
4049 | |
4050 | exit: |
4051 | return return_value; |
4052 | } |
4053 | |
4054 | #endif /* (defined(HAVE_WAITID) && !defined(__APPLE__)) */ |
4055 | |
4056 | #if defined(HAVE_WAITPID) |
4057 | |
4058 | PyDoc_STRVAR(os_waitpid__doc__, |
4059 | "waitpid($module, pid, options, /)\n" |
4060 | "--\n" |
4061 | "\n" |
4062 | "Wait for completion of a given child process.\n" |
4063 | "\n" |
4064 | "Returns a tuple of information regarding the child process:\n" |
4065 | " (pid, status)\n" |
4066 | "\n" |
4067 | "The options argument is ignored on Windows."); |
4068 | |
4069 | #define OS_WAITPID_METHODDEF \ |
4070 | {"waitpid", _PyCFunction_CAST(os_waitpid), METH_FASTCALL, os_waitpid__doc__}, |
4071 | |
4072 | static PyObject * |
4073 | os_waitpid_impl(PyObject *module, pid_t pid, int options); |
4074 | |
4075 | static PyObject * |
4076 | os_waitpid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4077 | { |
4078 | PyObject *return_value = NULL; |
4079 | pid_t pid; |
4080 | int options; |
4081 | |
4082 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "i:waitpid", Branch (4082:9): [True: 0, False: 35.8k]
|
4083 | &pid, &options)) { |
4084 | goto exit; |
4085 | } |
4086 | return_value = os_waitpid_impl(module, pid, options); |
4087 | |
4088 | exit: |
4089 | return return_value; |
4090 | } |
4091 | |
4092 | #endif /* defined(HAVE_WAITPID) */ |
4093 | |
4094 | #if !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) |
4095 | |
4096 | PyDoc_STRVAR(os_waitpid__doc__, |
4097 | "waitpid($module, pid, options, /)\n" |
4098 | "--\n" |
4099 | "\n" |
4100 | "Wait for completion of a given process.\n" |
4101 | "\n" |
4102 | "Returns a tuple of information regarding the process:\n" |
4103 | " (pid, status << 8)\n" |
4104 | "\n" |
4105 | "The options argument is ignored on Windows."); |
4106 | |
4107 | #define OS_WAITPID_METHODDEF \ |
4108 | {"waitpid", _PyCFunction_CAST(os_waitpid), METH_FASTCALL, os_waitpid__doc__}, |
4109 | |
4110 | static PyObject * |
4111 | os_waitpid_impl(PyObject *module, intptr_t pid, int options); |
4112 | |
4113 | static PyObject * |
4114 | os_waitpid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4115 | { |
4116 | PyObject *return_value = NULL; |
4117 | intptr_t pid; |
4118 | int options; |
4119 | |
4120 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_INTPTR "i:waitpid", |
4121 | &pid, &options)) { |
4122 | goto exit; |
4123 | } |
4124 | return_value = os_waitpid_impl(module, pid, options); |
4125 | |
4126 | exit: |
4127 | return return_value; |
4128 | } |
4129 | |
4130 | #endif /* !defined(HAVE_WAITPID) && defined(HAVE_CWAIT) */ |
4131 | |
4132 | #if defined(HAVE_WAIT) |
4133 | |
4134 | PyDoc_STRVAR(os_wait__doc__, |
4135 | "wait($module, /)\n" |
4136 | "--\n" |
4137 | "\n" |
4138 | "Wait for completion of a child process.\n" |
4139 | "\n" |
4140 | "Returns a tuple of information about the child process:\n" |
4141 | " (pid, status)"); |
4142 | |
4143 | #define OS_WAIT_METHODDEF \ |
4144 | {"wait", (PyCFunction)os_wait, METH_NOARGS, os_wait__doc__}, |
4145 | |
4146 | static PyObject * |
4147 | os_wait_impl(PyObject *module); |
4148 | |
4149 | static PyObject * |
4150 | os_wait(PyObject *module, PyObject *Py_UNUSED(ignored)) |
4151 | { |
4152 | return os_wait_impl(module); |
4153 | } |
4154 | |
4155 | #endif /* defined(HAVE_WAIT) */ |
4156 | |
4157 | #if (defined(__linux__) && defined(__NR_pidfd_open)) |
4158 | |
4159 | PyDoc_STRVAR(os_pidfd_open__doc__, |
4160 | "pidfd_open($module, /, pid, flags=0)\n" |
4161 | "--\n" |
4162 | "\n" |
4163 | "Return a file descriptor referring to the process *pid*.\n" |
4164 | "\n" |
4165 | "The descriptor can be used to perform process management without races and\n" |
4166 | "signals."); |
4167 | |
4168 | #define OS_PIDFD_OPEN_METHODDEF \ |
4169 | {"pidfd_open", _PyCFunction_CAST(os_pidfd_open), METH_FASTCALL|METH_KEYWORDS, os_pidfd_open__doc__}, |
4170 | |
4171 | static PyObject * |
4172 | os_pidfd_open_impl(PyObject *module, pid_t pid, unsigned int flags); |
4173 | |
4174 | static PyObject * |
4175 | os_pidfd_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
4176 | { |
4177 | PyObject *return_value = NULL; |
4178 | static const char * const _keywords[] = {"pid", "flags", NULL}; |
4179 | static _PyArg_Parser _parser = {"" _Py_PARSE_PID "|O&:pidfd_open", _keywords, 0}; |
4180 | pid_t pid; |
4181 | unsigned int flags = 0; |
4182 | |
4183 | if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser, Branch (4183:9): [True: 0, False: 26]
|
4184 | &pid, _PyLong_UnsignedInt_Converter, &flags)) { |
4185 | goto exit; |
4186 | } |
4187 | return_value = os_pidfd_open_impl(module, pid, flags); |
4188 | |
4189 | exit: |
4190 | return return_value; |
4191 | } |
4192 | |
4193 | #endif /* (defined(__linux__) && defined(__NR_pidfd_open)) */ |
4194 | |
4195 | #if (defined(HAVE_READLINK) || defined(MS_WINDOWS)) |
4196 | |
4197 | PyDoc_STRVAR(os_readlink__doc__, |
4198 | "readlink($module, /, path, *, dir_fd=None)\n" |
4199 | "--\n" |
4200 | "\n" |
4201 | "Return a string representing the path to which the symbolic link points.\n" |
4202 | "\n" |
4203 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
4204 | "and path should be relative; path will then be relative to that directory.\n" |
4205 | "\n" |
4206 | "dir_fd may not be implemented on your platform. If it is unavailable,\n" |
4207 | "using it will raise a NotImplementedError."); |
4208 | |
4209 | #define OS_READLINK_METHODDEF \ |
4210 | {"readlink", _PyCFunction_CAST(os_readlink), METH_FASTCALL|METH_KEYWORDS, os_readlink__doc__}, |
4211 | |
4212 | static PyObject * |
4213 | os_readlink_impl(PyObject *module, path_t *path, int dir_fd); |
4214 | |
4215 | static PyObject * |
4216 | os_readlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
4217 | { |
4218 | PyObject *return_value = NULL; |
4219 | static const char * const _keywords[] = {"path", "dir_fd", NULL}; |
4220 | static _PyArg_Parser _parser = {NULL, _keywords, "readlink", 0}; |
4221 | PyObject *argsbuf[2]; |
4222 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 0308 ) - 1; Branch (4222:36): [True: 1, False: 308]
|
4223 | path_t path = PATH_T_INITIALIZE("readlink", "path", 0, 0); |
4224 | int dir_fd = DEFAULT_DIR_FD; |
4225 | |
4226 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
4227 | if (!args) { Branch (4227:9): [True: 0, False: 309]
|
4228 | goto exit; |
4229 | } |
4230 | if (!path_converter(args[0], &path)) { Branch (4230:9): [True: 0, False: 309]
|
4231 | goto exit; |
4232 | } |
4233 | if (!noptargs) { Branch (4233:9): [True: 308, False: 1]
|
4234 | goto skip_optional_kwonly; |
4235 | } |
4236 | if (!READLINKAT_DIR_FD_CONVERTER(args[1], &dir_fd)) { Branch (4236:9): [True: 0, False: 1]
|
4237 | goto exit; |
4238 | } |
4239 | skip_optional_kwonly: |
4240 | return_value = os_readlink_impl(module, &path, dir_fd); |
4241 | |
4242 | exit: |
4243 | /* Cleanup for path */ |
4244 | path_cleanup(&path); |
4245 | |
4246 | return return_value; |
4247 | } |
4248 | |
4249 | #endif /* (defined(HAVE_READLINK) || defined(MS_WINDOWS)) */ |
4250 | |
4251 | #if defined(HAVE_SYMLINK) |
4252 | |
4253 | PyDoc_STRVAR(os_symlink__doc__, |
4254 | "symlink($module, /, src, dst, target_is_directory=False, *, dir_fd=None)\n" |
4255 | "--\n" |
4256 | "\n" |
4257 | "Create a symbolic link pointing to src named dst.\n" |
4258 | "\n" |
4259 | "target_is_directory is required on Windows if the target is to be\n" |
4260 | " interpreted as a directory. (On Windows, symlink requires\n" |
4261 | " Windows 6.0 or greater, and raises a NotImplementedError otherwise.)\n" |
4262 | " target_is_directory is ignored on non-Windows platforms.\n" |
4263 | "\n" |
4264 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
4265 | " and path should be relative; path will then be relative to that directory.\n" |
4266 | "dir_fd may not be implemented on your platform.\n" |
4267 | " If it is unavailable, using it will raise a NotImplementedError."); |
4268 | |
4269 | #define OS_SYMLINK_METHODDEF \ |
4270 | {"symlink", _PyCFunction_CAST(os_symlink), METH_FASTCALL|METH_KEYWORDS, os_symlink__doc__}, |
4271 | |
4272 | static PyObject * |
4273 | os_symlink_impl(PyObject *module, path_t *src, path_t *dst, |
4274 | int target_is_directory, int dir_fd); |
4275 | |
4276 | static PyObject * |
4277 | os_symlink(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
4278 | { |
4279 | PyObject *return_value = NULL; |
4280 | static const char * const _keywords[] = {"src", "dst", "target_is_directory", "dir_fd", NULL}; |
4281 | static _PyArg_Parser _parser = {NULL, _keywords, "symlink", 0}; |
4282 | PyObject *argsbuf[4]; |
4283 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE5 (kwnames) : 01.27k ) - 2; Branch (4283:36): [True: 5, False: 1.27k]
|
4284 | path_t src = PATH_T_INITIALIZE("symlink", "src", 0, 0); |
4285 | path_t dst = PATH_T_INITIALIZE("symlink", "dst", 0, 0); |
4286 | int target_is_directory = 0; |
4287 | int dir_fd = DEFAULT_DIR_FD; |
4288 | |
4289 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); |
4290 | if (!args) { Branch (4290:9): [True: 0, False: 1.27k]
|
4291 | goto exit; |
4292 | } |
4293 | if (!path_converter(args[0], &src)) { Branch (4293:9): [True: 0, False: 1.27k]
|
4294 | goto exit; |
4295 | } |
4296 | if (!path_converter(args[1], &dst)) { Branch (4296:9): [True: 0, False: 1.27k]
|
4297 | goto exit; |
4298 | } |
4299 | if (!noptargs) { Branch (4299:9): [True: 1.16k, False: 115]
|
4300 | goto skip_optional_pos; |
4301 | } |
4302 | if (args[2]) { Branch (4302:9): [True: 114, False: 1]
|
4303 | target_is_directory = PyObject_IsTrue(args[2]); |
4304 | if (target_is_directory < 0) { Branch (4304:13): [True: 0, False: 114]
|
4305 | goto exit; |
4306 | } |
4307 | if (!--noptargs) { Branch (4307:13): [True: 113, False: 1]
|
4308 | goto skip_optional_pos; |
4309 | } |
4310 | } |
4311 | skip_optional_pos: |
4312 | if (!noptargs) { Branch (4312:9): [True: 1.27k, False: 2]
|
4313 | goto skip_optional_kwonly; |
4314 | } |
4315 | if (!SYMLINKAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { Branch (4315:9): [True: 0, False: 2]
|
4316 | goto exit; |
4317 | } |
4318 | skip_optional_kwonly: |
4319 | return_value = os_symlink_impl(module, &src, &dst, target_is_directory, dir_fd); |
4320 | |
4321 | exit: |
4322 | /* Cleanup for src */ |
4323 | path_cleanup(&src); |
4324 | /* Cleanup for dst */ |
4325 | path_cleanup(&dst); |
4326 | |
4327 | return return_value; |
4328 | } |
4329 | |
4330 | #endif /* defined(HAVE_SYMLINK) */ |
4331 | |
4332 | #if defined(HAVE_TIMES) |
4333 | |
4334 | PyDoc_STRVAR(os_times__doc__, |
4335 | "times($module, /)\n" |
4336 | "--\n" |
4337 | "\n" |
4338 | "Return a collection containing process timing information.\n" |
4339 | "\n" |
4340 | "The object returned behaves like a named tuple with these fields:\n" |
4341 | " (utime, stime, cutime, cstime, elapsed_time)\n" |
4342 | "All fields are floating point numbers."); |
4343 | |
4344 | #define OS_TIMES_METHODDEF \ |
4345 | {"times", (PyCFunction)os_times, METH_NOARGS, os_times__doc__}, |
4346 | |
4347 | static PyObject * |
4348 | os_times_impl(PyObject *module); |
4349 | |
4350 | static PyObject * |
4351 | os_times(PyObject *module, PyObject *Py_UNUSED(ignored)) |
4352 | { |
4353 | return os_times_impl(module); |
4354 | } |
4355 | |
4356 | #endif /* defined(HAVE_TIMES) */ |
4357 | |
4358 | #if defined(HAVE_GETSID) |
4359 | |
4360 | PyDoc_STRVAR(os_getsid__doc__, |
4361 | "getsid($module, pid, /)\n" |
4362 | "--\n" |
4363 | "\n" |
4364 | "Call the system call getsid(pid) and return the result."); |
4365 | |
4366 | #define OS_GETSID_METHODDEF \ |
4367 | {"getsid", (PyCFunction)os_getsid, METH_O, os_getsid__doc__}, |
4368 | |
4369 | static PyObject * |
4370 | os_getsid_impl(PyObject *module, pid_t pid); |
4371 | |
4372 | static PyObject * |
4373 | os_getsid(PyObject *module, PyObject *arg) |
4374 | { |
4375 | PyObject *return_value = NULL; |
4376 | pid_t pid; |
4377 | |
4378 | if (!PyArg_Parse(arg, "" _Py_PARSE_PID ":getsid", &pid)) { Branch (4378:9): [True: 0, False: 8]
|
4379 | goto exit; |
4380 | } |
4381 | return_value = os_getsid_impl(module, pid); |
4382 | |
4383 | exit: |
4384 | return return_value; |
4385 | } |
4386 | |
4387 | #endif /* defined(HAVE_GETSID) */ |
4388 | |
4389 | #if defined(HAVE_SETSID) |
4390 | |
4391 | PyDoc_STRVAR(os_setsid__doc__, |
4392 | "setsid($module, /)\n" |
4393 | "--\n" |
4394 | "\n" |
4395 | "Call the system call setsid()."); |
4396 | |
4397 | #define OS_SETSID_METHODDEF \ |
4398 | {"setsid", (PyCFunction)os_setsid, METH_NOARGS, os_setsid__doc__}, |
4399 | |
4400 | static PyObject * |
4401 | os_setsid_impl(PyObject *module); |
4402 | |
4403 | static PyObject * |
4404 | os_setsid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
4405 | { |
4406 | return os_setsid_impl(module); |
4407 | } |
4408 | |
4409 | #endif /* defined(HAVE_SETSID) */ |
4410 | |
4411 | #if defined(HAVE_SETPGID) |
4412 | |
4413 | PyDoc_STRVAR(os_setpgid__doc__, |
4414 | "setpgid($module, pid, pgrp, /)\n" |
4415 | "--\n" |
4416 | "\n" |
4417 | "Call the system call setpgid(pid, pgrp)."); |
4418 | |
4419 | #define OS_SETPGID_METHODDEF \ |
4420 | {"setpgid", _PyCFunction_CAST(os_setpgid), METH_FASTCALL, os_setpgid__doc__}, |
4421 | |
4422 | static PyObject * |
4423 | os_setpgid_impl(PyObject *module, pid_t pid, pid_t pgrp); |
4424 | |
4425 | static PyObject * |
4426 | os_setpgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4427 | { |
4428 | PyObject *return_value = NULL; |
4429 | pid_t pid; |
4430 | pid_t pgrp; |
4431 |
|
4432 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_PID "" _Py_PARSE_PID ":setpgid", Branch (4432:9): [True: 0, False: 0]
|
4433 | &pid, &pgrp)) { |
4434 | goto exit; |
4435 | } |
4436 | return_value = os_setpgid_impl(module, pid, pgrp); |
4437 |
|
4438 | exit: |
4439 | return return_value; |
4440 | } |
4441 | |
4442 | #endif /* defined(HAVE_SETPGID) */ |
4443 | |
4444 | #if defined(HAVE_TCGETPGRP) |
4445 | |
4446 | PyDoc_STRVAR(os_tcgetpgrp__doc__, |
4447 | "tcgetpgrp($module, fd, /)\n" |
4448 | "--\n" |
4449 | "\n" |
4450 | "Return the process group associated with the terminal specified by fd."); |
4451 | |
4452 | #define OS_TCGETPGRP_METHODDEF \ |
4453 | {"tcgetpgrp", (PyCFunction)os_tcgetpgrp, METH_O, os_tcgetpgrp__doc__}, |
4454 | |
4455 | static PyObject * |
4456 | os_tcgetpgrp_impl(PyObject *module, int fd); |
4457 | |
4458 | static PyObject * |
4459 | os_tcgetpgrp(PyObject *module, PyObject *arg) |
4460 | { |
4461 | PyObject *return_value = NULL; |
4462 | int fd; |
4463 | |
4464 | fd = _PyLong_AsInt(arg); |
4465 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4465:9): [True: 0, False: 1]
Branch (4465:21): [True: 0, False: 0]
|
4466 | goto exit; |
4467 | } |
4468 | return_value = os_tcgetpgrp_impl(module, fd); |
4469 | |
4470 | exit: |
4471 | return return_value; |
4472 | } |
4473 | |
4474 | #endif /* defined(HAVE_TCGETPGRP) */ |
4475 | |
4476 | #if defined(HAVE_TCSETPGRP) |
4477 | |
4478 | PyDoc_STRVAR(os_tcsetpgrp__doc__, |
4479 | "tcsetpgrp($module, fd, pgid, /)\n" |
4480 | "--\n" |
4481 | "\n" |
4482 | "Set the process group associated with the terminal specified by fd."); |
4483 | |
4484 | #define OS_TCSETPGRP_METHODDEF \ |
4485 | {"tcsetpgrp", _PyCFunction_CAST(os_tcsetpgrp), METH_FASTCALL, os_tcsetpgrp__doc__}, |
4486 | |
4487 | static PyObject * |
4488 | os_tcsetpgrp_impl(PyObject *module, int fd, pid_t pgid); |
4489 | |
4490 | static PyObject * |
4491 | os_tcsetpgrp(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4492 | { |
4493 | PyObject *return_value = NULL; |
4494 | int fd; |
4495 | pid_t pgid; |
4496 | |
4497 | if (!_PyArg_ParseStack(args, nargs, "i" _Py_PARSE_PID ":tcsetpgrp", Branch (4497:9): [True: 0, False: 1]
|
4498 | &fd, &pgid)) { |
4499 | goto exit; |
4500 | } |
4501 | return_value = os_tcsetpgrp_impl(module, fd, pgid); |
4502 | |
4503 | exit: |
4504 | return return_value; |
4505 | } |
4506 | |
4507 | #endif /* defined(HAVE_TCSETPGRP) */ |
4508 | |
4509 | PyDoc_STRVAR(os_open__doc__, |
4510 | "open($module, /, path, flags, mode=511, *, dir_fd=None)\n" |
4511 | "--\n" |
4512 | "\n" |
4513 | "Open a file for low level IO. Returns a file descriptor (integer).\n" |
4514 | "\n" |
4515 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
4516 | " and path should be relative; path will then be relative to that directory.\n" |
4517 | "dir_fd may not be implemented on your platform.\n" |
4518 | " If it is unavailable, using it will raise a NotImplementedError."); |
4519 | |
4520 | #define OS_OPEN_METHODDEF \ |
4521 | {"open", _PyCFunction_CAST(os_open), METH_FASTCALL|METH_KEYWORDS, os_open__doc__}, |
4522 | |
4523 | static int |
4524 | os_open_impl(PyObject *module, path_t *path, int flags, int mode, int dir_fd); |
4525 | |
4526 | static PyObject * |
4527 | os_open(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
4528 | { |
4529 | PyObject *return_value = NULL; |
4530 | static const char * const _keywords[] = {"path", "flags", "mode", "dir_fd", NULL}; |
4531 | static _PyArg_Parser _parser = {NULL, _keywords, "open", 0}; |
4532 | PyObject *argsbuf[4]; |
4533 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE12.8k (kwnames) : 09.92k ) - 2; Branch (4533:36): [True: 12.8k, False: 9.92k]
|
4534 | path_t path = PATH_T_INITIALIZE("open", "path", 0, 0); |
4535 | int flags; |
4536 | int mode = 511; |
4537 | int dir_fd = DEFAULT_DIR_FD; |
4538 | int _return_value; |
4539 | |
4540 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); |
4541 | if (!args) { Branch (4541:9): [True: 0, False: 22.7k]
|
4542 | goto exit; |
4543 | } |
4544 | if (!path_converter(args[0], &path)) { Branch (4544:9): [True: 9, False: 22.7k]
|
4545 | goto exit; |
4546 | } |
4547 | flags = _PyLong_AsInt(args[1]); |
4548 | if (flags == -1 && PyErr_Occurred()0 ) { Branch (4548:9): [True: 0, False: 22.7k]
Branch (4548:24): [True: 0, False: 0]
|
4549 | goto exit; |
4550 | } |
4551 | if (!noptargs) { Branch (4551:9): [True: 2.63k, False: 20.1k]
|
4552 | goto skip_optional_pos; |
4553 | } |
4554 | if (args[2]) { Branch (4554:9): [True: 7.28k, False: 12.8k]
|
4555 | mode = _PyLong_AsInt(args[2]); |
4556 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (4556:13): [True: 0, False: 7.28k]
Branch (4556:27): [True: 0, False: 0]
|
4557 | goto exit; |
4558 | } |
4559 | if (!--noptargs) { Branch (4559:13): [True: 7.28k, False: 1]
|
4560 | goto skip_optional_pos; |
4561 | } |
4562 | } |
4563 | skip_optional_pos: |
4564 | if (!noptargs) { Branch (4564:9): [True: 9.91k, False: 12.8k]
|
4565 | goto skip_optional_kwonly; |
4566 | } |
4567 | if (!OPENAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { Branch (4567:9): [True: 0, False: 12.8k]
|
4568 | goto exit; |
4569 | } |
4570 | skip_optional_kwonly: |
4571 | _return_value = os_open_impl(module, &path, flags, mode, dir_fd); |
4572 | if ((_return_value == -1) && PyErr_Occurred()733 ) { Branch (4572:9): [True: 733, False: 22.0k]
Branch (4572:34): [True: 733, False: 0]
|
4573 | goto exit; |
4574 | } |
4575 | return_value = PyLong_FromLong((long)_return_value); |
4576 | |
4577 | exit: |
4578 | /* Cleanup for path */ |
4579 | path_cleanup(&path); |
4580 | |
4581 | return return_value; |
4582 | } |
4583 | |
4584 | PyDoc_STRVAR(os_close__doc__, |
4585 | "close($module, /, fd)\n" |
4586 | "--\n" |
4587 | "\n" |
4588 | "Close a file descriptor."); |
4589 | |
4590 | #define OS_CLOSE_METHODDEF \ |
4591 | {"close", _PyCFunction_CAST(os_close), METH_FASTCALL|METH_KEYWORDS, os_close__doc__}, |
4592 | |
4593 | static PyObject * |
4594 | os_close_impl(PyObject *module, int fd); |
4595 | |
4596 | static PyObject * |
4597 | os_close(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
4598 | { |
4599 | PyObject *return_value = NULL; |
4600 | static const char * const _keywords[] = {"fd", NULL}; |
4601 | static _PyArg_Parser _parser = {NULL, _keywords, "close", 0}; |
4602 | PyObject *argsbuf[1]; |
4603 | int fd; |
4604 | |
4605 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
4606 | if (!args) { Branch (4606:9): [True: 0, False: 52.1k]
|
4607 | goto exit; |
4608 | } |
4609 | fd = _PyLong_AsInt(args[0]); |
4610 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4610:9): [True: 0, False: 52.1k]
Branch (4610:21): [True: 0, False: 0]
|
4611 | goto exit; |
4612 | } |
4613 | return_value = os_close_impl(module, fd); |
4614 | |
4615 | exit: |
4616 | return return_value; |
4617 | } |
4618 | |
4619 | PyDoc_STRVAR(os_closerange__doc__, |
4620 | "closerange($module, fd_low, fd_high, /)\n" |
4621 | "--\n" |
4622 | "\n" |
4623 | "Closes all file descriptors in [fd_low, fd_high), ignoring errors."); |
4624 | |
4625 | #define OS_CLOSERANGE_METHODDEF \ |
4626 | {"closerange", _PyCFunction_CAST(os_closerange), METH_FASTCALL, os_closerange__doc__}, |
4627 | |
4628 | static PyObject * |
4629 | os_closerange_impl(PyObject *module, int fd_low, int fd_high); |
4630 | |
4631 | static PyObject * |
4632 | os_closerange(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4633 | { |
4634 | PyObject *return_value = NULL; |
4635 | int fd_low; |
4636 | int fd_high; |
4637 |
|
4638 | if (!_PyArg_CheckPositional("closerange", nargs, 2, 2)) { |
4639 | goto exit; |
4640 | } |
4641 | fd_low = _PyLong_AsInt(args[0]); |
4642 | if (fd_low == -1 && PyErr_Occurred()) { Branch (4642:9): [True: 0, False: 0]
Branch (4642:25): [True: 0, False: 0]
|
4643 | goto exit; |
4644 | } |
4645 | fd_high = _PyLong_AsInt(args[1]); |
4646 | if (fd_high == -1 && PyErr_Occurred()) { Branch (4646:9): [True: 0, False: 0]
Branch (4646:26): [True: 0, False: 0]
|
4647 | goto exit; |
4648 | } |
4649 | return_value = os_closerange_impl(module, fd_low, fd_high); |
4650 |
|
4651 | exit: |
4652 | return return_value; |
4653 | } |
4654 | |
4655 | PyDoc_STRVAR(os_dup__doc__, |
4656 | "dup($module, fd, /)\n" |
4657 | "--\n" |
4658 | "\n" |
4659 | "Return a duplicate of a file descriptor."); |
4660 | |
4661 | #define OS_DUP_METHODDEF \ |
4662 | {"dup", (PyCFunction)os_dup, METH_O, os_dup__doc__}, |
4663 | |
4664 | static int |
4665 | os_dup_impl(PyObject *module, int fd); |
4666 | |
4667 | static PyObject * |
4668 | os_dup(PyObject *module, PyObject *arg) |
4669 | { |
4670 | PyObject *return_value = NULL; |
4671 | int fd; |
4672 | int _return_value; |
4673 | |
4674 | fd = _PyLong_AsInt(arg); |
4675 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4675:9): [True: 0, False: 898]
Branch (4675:21): [True: 0, False: 0]
|
4676 | goto exit; |
4677 | } |
4678 | _return_value = os_dup_impl(module, fd); |
4679 | if ((_return_value == -1) && PyErr_Occurred()1 ) { Branch (4679:9): [True: 1, False: 897]
Branch (4679:34): [True: 1, False: 0]
|
4680 | goto exit; |
4681 | } |
4682 | return_value = PyLong_FromLong((long)_return_value); |
4683 | |
4684 | exit: |
4685 | return return_value; |
4686 | } |
4687 | |
4688 | PyDoc_STRVAR(os_dup2__doc__, |
4689 | "dup2($module, /, fd, fd2, inheritable=True)\n" |
4690 | "--\n" |
4691 | "\n" |
4692 | "Duplicate file descriptor."); |
4693 | |
4694 | #define OS_DUP2_METHODDEF \ |
4695 | {"dup2", _PyCFunction_CAST(os_dup2), METH_FASTCALL|METH_KEYWORDS, os_dup2__doc__}, |
4696 | |
4697 | static int |
4698 | os_dup2_impl(PyObject *module, int fd, int fd2, int inheritable); |
4699 | |
4700 | static PyObject * |
4701 | os_dup2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
4702 | { |
4703 | PyObject *return_value = NULL; |
4704 | static const char * const _keywords[] = {"fd", "fd2", "inheritable", NULL}; |
4705 | static _PyArg_Parser _parser = {NULL, _keywords, "dup2", 0}; |
4706 | PyObject *argsbuf[3]; |
4707 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE88 (kwnames) : 075 ) - 2; Branch (4707:36): [True: 88, False: 75]
|
4708 | int fd; |
4709 | int fd2; |
4710 | int inheritable = 1; |
4711 | int _return_value; |
4712 | |
4713 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 3, 0, argsbuf); |
4714 | if (!args) { Branch (4714:9): [True: 0, False: 163]
|
4715 | goto exit; |
4716 | } |
4717 | fd = _PyLong_AsInt(args[0]); |
4718 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4718:9): [True: 0, False: 163]
Branch (4718:21): [True: 0, False: 0]
|
4719 | goto exit; |
4720 | } |
4721 | fd2 = _PyLong_AsInt(args[1]); |
4722 | if (fd2 == -1 && PyErr_Occurred()0 ) { Branch (4722:9): [True: 0, False: 163]
Branch (4722:22): [True: 0, False: 0]
|
4723 | goto exit; |
4724 | } |
4725 | if (!noptargs) { Branch (4725:9): [True: 75, False: 88]
|
4726 | goto skip_optional_pos; |
4727 | } |
4728 | inheritable = PyObject_IsTrue(args[2]); |
4729 | if (inheritable < 0) { Branch (4729:9): [True: 0, False: 88]
|
4730 | goto exit; |
4731 | } |
4732 | skip_optional_pos: |
4733 | _return_value = os_dup2_impl(module, fd, fd2, inheritable); |
4734 | if ((_return_value == -1) && PyErr_Occurred()1 ) { Branch (4734:9): [True: 1, False: 162]
Branch (4734:34): [True: 1, False: 0]
|
4735 | goto exit; |
4736 | } |
4737 | return_value = PyLong_FromLong((long)_return_value); |
4738 | |
4739 | exit: |
4740 | return return_value; |
4741 | } |
4742 | |
4743 | #if defined(HAVE_LOCKF) |
4744 | |
4745 | PyDoc_STRVAR(os_lockf__doc__, |
4746 | "lockf($module, fd, command, length, /)\n" |
4747 | "--\n" |
4748 | "\n" |
4749 | "Apply, test or remove a POSIX lock on an open file descriptor.\n" |
4750 | "\n" |
4751 | " fd\n" |
4752 | " An open file descriptor.\n" |
4753 | " command\n" |
4754 | " One of F_LOCK, F_TLOCK, F_ULOCK or F_TEST.\n" |
4755 | " length\n" |
4756 | " The number of bytes to lock, starting at the current position."); |
4757 | |
4758 | #define OS_LOCKF_METHODDEF \ |
4759 | {"lockf", _PyCFunction_CAST(os_lockf), METH_FASTCALL, os_lockf__doc__}, |
4760 | |
4761 | static PyObject * |
4762 | os_lockf_impl(PyObject *module, int fd, int command, Py_off_t length); |
4763 | |
4764 | static PyObject * |
4765 | os_lockf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4766 | { |
4767 | PyObject *return_value = NULL; |
4768 | int fd; |
4769 | int command; |
4770 | Py_off_t length; |
4771 | |
4772 | if (!_PyArg_CheckPositional("lockf", nargs, 3, 3)) { |
4773 | goto exit; |
4774 | } |
4775 | fd = _PyLong_AsInt(args[0]); |
4776 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4776:9): [True: 0, False: 2]
Branch (4776:21): [True: 0, False: 0]
|
4777 | goto exit; |
4778 | } |
4779 | command = _PyLong_AsInt(args[1]); |
4780 | if (command == -1 && PyErr_Occurred()0 ) { Branch (4780:9): [True: 0, False: 2]
Branch (4780:26): [True: 0, False: 0]
|
4781 | goto exit; |
4782 | } |
4783 | if (!Py_off_t_converter(args[2], &length)) { Branch (4783:9): [True: 0, False: 2]
|
4784 | goto exit; |
4785 | } |
4786 | return_value = os_lockf_impl(module, fd, command, length); |
4787 | |
4788 | exit: |
4789 | return return_value; |
4790 | } |
4791 | |
4792 | #endif /* defined(HAVE_LOCKF) */ |
4793 | |
4794 | PyDoc_STRVAR(os_lseek__doc__, |
4795 | "lseek($module, fd, position, how, /)\n" |
4796 | "--\n" |
4797 | "\n" |
4798 | "Set the position of a file descriptor. Return the new position.\n" |
4799 | "\n" |
4800 | "Return the new cursor position in number of bytes\n" |
4801 | "relative to the beginning of the file."); |
4802 | |
4803 | #define OS_LSEEK_METHODDEF \ |
4804 | {"lseek", _PyCFunction_CAST(os_lseek), METH_FASTCALL, os_lseek__doc__}, |
4805 | |
4806 | static Py_off_t |
4807 | os_lseek_impl(PyObject *module, int fd, Py_off_t position, int how); |
4808 | |
4809 | static PyObject * |
4810 | os_lseek(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4811 | { |
4812 | PyObject *return_value = NULL; |
4813 | int fd; |
4814 | Py_off_t position; |
4815 | int how; |
4816 | Py_off_t _return_value; |
4817 | |
4818 | if (!_PyArg_CheckPositional("lseek", nargs, 3, 3)) { |
4819 | goto exit; |
4820 | } |
4821 | fd = _PyLong_AsInt(args[0]); |
4822 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4822:9): [True: 0, False: 8.38k]
Branch (4822:21): [True: 0, False: 0]
|
4823 | goto exit; |
4824 | } |
4825 | if (!Py_off_t_converter(args[1], &position)) { Branch (4825:9): [True: 0, False: 8.38k]
|
4826 | goto exit; |
4827 | } |
4828 | how = _PyLong_AsInt(args[2]); |
4829 | if (how == -1 && PyErr_Occurred()0 ) { Branch (4829:9): [True: 0, False: 8.38k]
Branch (4829:22): [True: 0, False: 0]
|
4830 | goto exit; |
4831 | } |
4832 | _return_value = os_lseek_impl(module, fd, position, how); |
4833 | if ((_return_value == -1) && PyErr_Occurred()32 ) { Branch (4833:9): [True: 32, False: 8.35k]
Branch (4833:34): [True: 32, False: 0]
|
4834 | goto exit; |
4835 | } |
4836 | return_value = PyLong_FromPy_off_t(_return_value); |
4837 | |
4838 | exit: |
4839 | return return_value; |
4840 | } |
4841 | |
4842 | PyDoc_STRVAR(os_read__doc__, |
4843 | "read($module, fd, length, /)\n" |
4844 | "--\n" |
4845 | "\n" |
4846 | "Read from a file descriptor. Returns a bytes object."); |
4847 | |
4848 | #define OS_READ_METHODDEF \ |
4849 | {"read", _PyCFunction_CAST(os_read), METH_FASTCALL, os_read__doc__}, |
4850 | |
4851 | static PyObject * |
4852 | os_read_impl(PyObject *module, int fd, Py_ssize_t length); |
4853 | |
4854 | static PyObject * |
4855 | os_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4856 | { |
4857 | PyObject *return_value = NULL; |
4858 | int fd; |
4859 | Py_ssize_t length; |
4860 | |
4861 | if (!_PyArg_CheckPositional("read", nargs, 2, 2)) { |
4862 | goto exit; |
4863 | } |
4864 | fd = _PyLong_AsInt(args[0]); |
4865 | if (fd == -1 && PyErr_Occurred()1 ) { Branch (4865:9): [True: 1, False: 612k]
Branch (4865:21): [True: 0, False: 1]
|
4866 | goto exit; |
4867 | } |
4868 | { |
4869 | Py_ssize_t ival = -1; |
4870 | PyObject *iobj = _PyNumber_Index(args[1]); |
4871 | if (iobj != NULL) { Branch (4871:13): [True: 612k, False: 0]
|
4872 | ival = PyLong_AsSsize_t(iobj); |
4873 | Py_DECREF(iobj); |
4874 | } |
4875 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (4875:13): [True: 0, False: 612k]
Branch (4875:27): [True: 0, False: 0]
|
4876 | goto exit; |
4877 | } |
4878 | length = ival; |
4879 | } |
4880 | return_value = os_read_impl(module, fd, length); |
4881 | |
4882 | exit: |
4883 | return return_value; |
4884 | } |
4885 | |
4886 | #if defined(HAVE_READV) |
4887 | |
4888 | PyDoc_STRVAR(os_readv__doc__, |
4889 | "readv($module, fd, buffers, /)\n" |
4890 | "--\n" |
4891 | "\n" |
4892 | "Read from a file descriptor fd into an iterable of buffers.\n" |
4893 | "\n" |
4894 | "The buffers should be mutable buffers accepting bytes.\n" |
4895 | "readv will transfer data into each buffer until it is full\n" |
4896 | "and then move on to the next buffer in the sequence to hold\n" |
4897 | "the rest of the data.\n" |
4898 | "\n" |
4899 | "readv returns the total number of bytes read,\n" |
4900 | "which may be less than the total capacity of all the buffers."); |
4901 | |
4902 | #define OS_READV_METHODDEF \ |
4903 | {"readv", _PyCFunction_CAST(os_readv), METH_FASTCALL, os_readv__doc__}, |
4904 | |
4905 | static Py_ssize_t |
4906 | os_readv_impl(PyObject *module, int fd, PyObject *buffers); |
4907 | |
4908 | static PyObject * |
4909 | os_readv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4910 | { |
4911 | PyObject *return_value = NULL; |
4912 | int fd; |
4913 | PyObject *buffers; |
4914 | Py_ssize_t _return_value; |
4915 | |
4916 | if (!_PyArg_CheckPositional("readv", nargs, 2, 2)) { |
4917 | goto exit; |
4918 | } |
4919 | fd = _PyLong_AsInt(args[0]); |
4920 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4920:9): [True: 0, False: 3]
Branch (4920:21): [True: 0, False: 0]
|
4921 | goto exit; |
4922 | } |
4923 | buffers = args[1]; |
4924 | _return_value = os_readv_impl(module, fd, buffers); |
4925 | if ((_return_value == -1) && PyErr_Occurred()1 ) { Branch (4925:9): [True: 1, False: 2]
Branch (4925:34): [True: 1, False: 0]
|
4926 | goto exit; |
4927 | } |
4928 | return_value = PyLong_FromSsize_t(_return_value); |
4929 | |
4930 | exit: |
4931 | return return_value; |
4932 | } |
4933 | |
4934 | #endif /* defined(HAVE_READV) */ |
4935 | |
4936 | #if defined(HAVE_PREAD) |
4937 | |
4938 | PyDoc_STRVAR(os_pread__doc__, |
4939 | "pread($module, fd, length, offset, /)\n" |
4940 | "--\n" |
4941 | "\n" |
4942 | "Read a number of bytes from a file descriptor starting at a particular offset.\n" |
4943 | "\n" |
4944 | "Read length bytes from file descriptor fd, starting at offset bytes from\n" |
4945 | "the beginning of the file. The file offset remains unchanged."); |
4946 | |
4947 | #define OS_PREAD_METHODDEF \ |
4948 | {"pread", _PyCFunction_CAST(os_pread), METH_FASTCALL, os_pread__doc__}, |
4949 | |
4950 | static PyObject * |
4951 | os_pread_impl(PyObject *module, int fd, Py_ssize_t length, Py_off_t offset); |
4952 | |
4953 | static PyObject * |
4954 | os_pread(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
4955 | { |
4956 | PyObject *return_value = NULL; |
4957 | int fd; |
4958 | Py_ssize_t length; |
4959 | Py_off_t offset; |
4960 | |
4961 | if (!_PyArg_CheckPositional("pread", nargs, 3, 3)) { |
4962 | goto exit; |
4963 | } |
4964 | fd = _PyLong_AsInt(args[0]); |
4965 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (4965:9): [True: 0, False: 1]
Branch (4965:21): [True: 0, False: 0]
|
4966 | goto exit; |
4967 | } |
4968 | { |
4969 | Py_ssize_t ival = -1; |
4970 | PyObject *iobj = _PyNumber_Index(args[1]); |
4971 | if (iobj != NULL) { Branch (4971:13): [True: 1, False: 0]
|
4972 | ival = PyLong_AsSsize_t(iobj); |
4973 | Py_DECREF(iobj); |
4974 | } |
4975 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (4975:13): [True: 0, False: 1]
Branch (4975:27): [True: 0, False: 0]
|
4976 | goto exit; |
4977 | } |
4978 | length = ival; |
4979 | } |
4980 | if (!Py_off_t_converter(args[2], &offset)) { Branch (4980:9): [True: 0, False: 1]
|
4981 | goto exit; |
4982 | } |
4983 | return_value = os_pread_impl(module, fd, length, offset); |
4984 | |
4985 | exit: |
4986 | return return_value; |
4987 | } |
4988 | |
4989 | #endif /* defined(HAVE_PREAD) */ |
4990 | |
4991 | #if (defined(HAVE_PREADV) || defined (HAVE_PREADV2)) |
4992 | |
4993 | PyDoc_STRVAR(os_preadv__doc__, |
4994 | "preadv($module, fd, buffers, offset, flags=0, /)\n" |
4995 | "--\n" |
4996 | "\n" |
4997 | "Reads from a file descriptor into a number of mutable bytes-like objects.\n" |
4998 | "\n" |
4999 | "Combines the functionality of readv() and pread(). As readv(), it will\n" |
5000 | "transfer data into each buffer until it is full and then move on to the next\n" |
5001 | "buffer in the sequence to hold the rest of the data. Its fourth argument,\n" |
5002 | "specifies the file offset at which the input operation is to be performed. It\n" |
5003 | "will return the total number of bytes read (which can be less than the total\n" |
5004 | "capacity of all the objects).\n" |
5005 | "\n" |
5006 | "The flags argument contains a bitwise OR of zero or more of the following flags:\n" |
5007 | "\n" |
5008 | "- RWF_HIPRI\n" |
5009 | "- RWF_NOWAIT\n" |
5010 | "\n" |
5011 | "Using non-zero flags requires Linux 4.6 or newer."); |
5012 | |
5013 | #define OS_PREADV_METHODDEF \ |
5014 | {"preadv", _PyCFunction_CAST(os_preadv), METH_FASTCALL, os_preadv__doc__}, |
5015 | |
5016 | static Py_ssize_t |
5017 | os_preadv_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, |
5018 | int flags); |
5019 | |
5020 | static PyObject * |
5021 | os_preadv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
5022 | { |
5023 | PyObject *return_value = NULL; |
5024 | int fd; |
5025 | PyObject *buffers; |
5026 | Py_off_t offset; |
5027 | int flags = 0; |
5028 | Py_ssize_t _return_value; |
5029 | |
5030 | if (!_PyArg_CheckPositional("preadv", nargs, 3, 4)) { |
5031 | goto exit; |
5032 | } |
5033 | fd = _PyLong_AsInt(args[0]); |
5034 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (5034:9): [True: 0, False: 2]
Branch (5034:21): [True: 0, False: 0]
|
5035 | goto exit; |
5036 | } |
5037 | buffers = args[1]; |
5038 | if (!Py_off_t_converter(args[2], &offset)) { Branch (5038:9): [True: 0, False: 2]
|
5039 | goto exit; |
5040 | } |
5041 | if (nargs < 4) { Branch (5041:9): [True: 1, False: 1]
|
5042 | goto skip_optional; |
5043 | } |
5044 | flags = _PyLong_AsInt(args[3]); |
5045 | if (flags == -1 && PyErr_Occurred()0 ) { Branch (5045:9): [True: 0, False: 1]
Branch (5045:24): [True: 0, False: 0]
|
5046 | goto exit; |
5047 | } |
5048 | skip_optional: |
5049 | _return_value = os_preadv_impl(module, fd, buffers, offset, flags); |
5050 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (5050:9): [True: 0, False: 2]
Branch (5050:34): [True: 0, False: 0]
|
5051 | goto exit; |
5052 | } |
5053 | return_value = PyLong_FromSsize_t(_return_value); |
5054 | |
5055 | exit: |
5056 | return return_value; |
5057 | } |
5058 | |
5059 | #endif /* (defined(HAVE_PREADV) || defined (HAVE_PREADV2)) */ |
5060 | |
5061 | PyDoc_STRVAR(os_write__doc__, |
5062 | "write($module, fd, data, /)\n" |
5063 | "--\n" |
5064 | "\n" |
5065 | "Write a bytes object to a file descriptor."); |
5066 | |
5067 | #define OS_WRITE_METHODDEF \ |
5068 | {"write", _PyCFunction_CAST(os_write), METH_FASTCALL, os_write__doc__}, |
5069 | |
5070 | static Py_ssize_t |
5071 | os_write_impl(PyObject *module, int fd, Py_buffer *data); |
5072 | |
5073 | static PyObject * |
5074 | os_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
5075 | { |
5076 | PyObject *return_value = NULL; |
5077 | int fd; |
5078 | Py_buffer data = {NULL, NULL}; |
5079 | Py_ssize_t _return_value; |
5080 | |
5081 | if (!_PyArg_CheckPositional("write", nargs, 2, 2)) { |
5082 | goto exit; |
5083 | } |
5084 | fd = _PyLong_AsInt(args[0]); |
5085 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (5085:9): [True: 0, False: 38.5k]
Branch (5085:21): [True: 0, False: 0]
|
5086 | goto exit; |
5087 | } |
5088 | if (PyObject_GetBuffer(args[1], &data, PyBUF_SIMPLE) != 0) { Branch (5088:9): [True: 4, False: 38.5k]
|
5089 | goto exit; |
5090 | } |
5091 | if (!PyBuffer_IsContiguous(&data, 'C')) { Branch (5091:9): [True: 0, False: 38.5k]
|
5092 | _PyArg_BadArgument("write", "argument 2", "contiguous buffer", args[1]); |
5093 | goto exit; |
5094 | } |
5095 | _return_value = os_write_impl(module, fd, &data); |
5096 | if ((_return_value == -1) && PyErr_Occurred()29 ) { Branch (5096:9): [True: 29, False: 38.4k]
Branch (5096:34): [True: 29, False: 0]
|
5097 | goto exit; |
5098 | } |
5099 | return_value = PyLong_FromSsize_t(_return_value); |
5100 | |
5101 | exit: |
5102 | /* Cleanup for data */ |
5103 | if (data.obj) { Branch (5103:9): [True: 38.5k, False: 4]
|
5104 | PyBuffer_Release(&data); |
5105 | } |
5106 | |
5107 | return return_value; |
5108 | } |
5109 | |
5110 | #if defined(HAVE_SENDFILE) && defined(__APPLE__) |
5111 | |
5112 | PyDoc_STRVAR(os_sendfile__doc__, |
5113 | "sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" |
5114 | " trailers=(), flags=0)\n" |
5115 | "--\n" |
5116 | "\n" |
5117 | "Copy count bytes from file descriptor in_fd to file descriptor out_fd."); |
5118 | |
5119 | #define OS_SENDFILE_METHODDEF \ |
5120 | {"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, |
5121 | |
5122 | static PyObject * |
5123 | os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, |
5124 | Py_off_t sbytes, PyObject *headers, PyObject *trailers, |
5125 | int flags); |
5126 | |
5127 | static PyObject * |
5128 | os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5129 | { |
5130 | PyObject *return_value = NULL; |
5131 | static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; |
5132 | static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; |
5133 | PyObject *argsbuf[7]; |
5134 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; |
5135 | int out_fd; |
5136 | int in_fd; |
5137 | Py_off_t offset; |
5138 | Py_off_t sbytes; |
5139 | PyObject *headers = NULL; |
5140 | PyObject *trailers = NULL; |
5141 | int flags = 0; |
5142 | |
5143 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 7, 0, argsbuf); |
5144 | if (!args) { |
5145 | goto exit; |
5146 | } |
5147 | out_fd = _PyLong_AsInt(args[0]); |
5148 | if (out_fd == -1 && PyErr_Occurred()) { |
5149 | goto exit; |
5150 | } |
5151 | in_fd = _PyLong_AsInt(args[1]); |
5152 | if (in_fd == -1 && PyErr_Occurred()) { |
5153 | goto exit; |
5154 | } |
5155 | if (!Py_off_t_converter(args[2], &offset)) { |
5156 | goto exit; |
5157 | } |
5158 | if (!Py_off_t_converter(args[3], &sbytes)) { |
5159 | goto exit; |
5160 | } |
5161 | if (!noptargs) { |
5162 | goto skip_optional_pos; |
5163 | } |
5164 | if (args[4]) { |
5165 | headers = args[4]; |
5166 | if (!--noptargs) { |
5167 | goto skip_optional_pos; |
5168 | } |
5169 | } |
5170 | if (args[5]) { |
5171 | trailers = args[5]; |
5172 | if (!--noptargs) { |
5173 | goto skip_optional_pos; |
5174 | } |
5175 | } |
5176 | flags = _PyLong_AsInt(args[6]); |
5177 | if (flags == -1 && PyErr_Occurred()) { |
5178 | goto exit; |
5179 | } |
5180 | skip_optional_pos: |
5181 | return_value = os_sendfile_impl(module, out_fd, in_fd, offset, sbytes, headers, trailers, flags); |
5182 | |
5183 | exit: |
5184 | return return_value; |
5185 | } |
5186 | |
5187 | #endif /* defined(HAVE_SENDFILE) && defined(__APPLE__) */ |
5188 | |
5189 | #if defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) |
5190 | |
5191 | PyDoc_STRVAR(os_sendfile__doc__, |
5192 | "sendfile($module, /, out_fd, in_fd, offset, count, headers=(),\n" |
5193 | " trailers=(), flags=0)\n" |
5194 | "--\n" |
5195 | "\n" |
5196 | "Copy count bytes from file descriptor in_fd to file descriptor out_fd."); |
5197 | |
5198 | #define OS_SENDFILE_METHODDEF \ |
5199 | {"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, |
5200 | |
5201 | static PyObject * |
5202 | os_sendfile_impl(PyObject *module, int out_fd, int in_fd, Py_off_t offset, |
5203 | Py_ssize_t count, PyObject *headers, PyObject *trailers, |
5204 | int flags); |
5205 | |
5206 | static PyObject * |
5207 | os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5208 | { |
5209 | PyObject *return_value = NULL; |
5210 | static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", "headers", "trailers", "flags", NULL}; |
5211 | static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; |
5212 | PyObject *argsbuf[7]; |
5213 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 4; |
5214 | int out_fd; |
5215 | int in_fd; |
5216 | Py_off_t offset; |
5217 | Py_ssize_t count; |
5218 | PyObject *headers = NULL; |
5219 | PyObject *trailers = NULL; |
5220 | int flags = 0; |
5221 | |
5222 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 7, 0, argsbuf); |
5223 | if (!args) { |
5224 | goto exit; |
5225 | } |
5226 | out_fd = _PyLong_AsInt(args[0]); |
5227 | if (out_fd == -1 && PyErr_Occurred()) { |
5228 | goto exit; |
5229 | } |
5230 | in_fd = _PyLong_AsInt(args[1]); |
5231 | if (in_fd == -1 && PyErr_Occurred()) { |
5232 | goto exit; |
5233 | } |
5234 | if (!Py_off_t_converter(args[2], &offset)) { |
5235 | goto exit; |
5236 | } |
5237 | { |
5238 | Py_ssize_t ival = -1; |
5239 | PyObject *iobj = _PyNumber_Index(args[3]); |
5240 | if (iobj != NULL) { |
5241 | ival = PyLong_AsSsize_t(iobj); |
5242 | Py_DECREF(iobj); |
5243 | } |
5244 | if (ival == -1 && PyErr_Occurred()) { |
5245 | goto exit; |
5246 | } |
5247 | count = ival; |
5248 | } |
5249 | if (!noptargs) { |
5250 | goto skip_optional_pos; |
5251 | } |
5252 | if (args[4]) { |
5253 | headers = args[4]; |
5254 | if (!--noptargs) { |
5255 | goto skip_optional_pos; |
5256 | } |
5257 | } |
5258 | if (args[5]) { |
5259 | trailers = args[5]; |
5260 | if (!--noptargs) { |
5261 | goto skip_optional_pos; |
5262 | } |
5263 | } |
5264 | flags = _PyLong_AsInt(args[6]); |
5265 | if (flags == -1 && PyErr_Occurred()) { |
5266 | goto exit; |
5267 | } |
5268 | skip_optional_pos: |
5269 | return_value = os_sendfile_impl(module, out_fd, in_fd, offset, count, headers, trailers, flags); |
5270 | |
5271 | exit: |
5272 | return return_value; |
5273 | } |
5274 | |
5275 | #endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && (defined(__FreeBSD__) || defined(__DragonFly__)) */ |
5276 | |
5277 | #if defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) |
5278 | |
5279 | PyDoc_STRVAR(os_sendfile__doc__, |
5280 | "sendfile($module, /, out_fd, in_fd, offset, count)\n" |
5281 | "--\n" |
5282 | "\n" |
5283 | "Copy count bytes from file descriptor in_fd to file descriptor out_fd."); |
5284 | |
5285 | #define OS_SENDFILE_METHODDEF \ |
5286 | {"sendfile", _PyCFunction_CAST(os_sendfile), METH_FASTCALL|METH_KEYWORDS, os_sendfile__doc__}, |
5287 | |
5288 | static PyObject * |
5289 | os_sendfile_impl(PyObject *module, int out_fd, int in_fd, PyObject *offobj, |
5290 | Py_ssize_t count); |
5291 | |
5292 | static PyObject * |
5293 | os_sendfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5294 | { |
5295 | PyObject *return_value = NULL; |
5296 | static const char * const _keywords[] = {"out_fd", "in_fd", "offset", "count", NULL}; |
5297 | static _PyArg_Parser _parser = {NULL, _keywords, "sendfile", 0}; |
5298 | PyObject *argsbuf[4]; |
5299 | int out_fd; |
5300 | int in_fd; |
5301 | PyObject *offobj; |
5302 | Py_ssize_t count; |
5303 | |
5304 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 4, 4, 0, argsbuf); |
5305 | if (!args) { Branch (5305:9): [True: 0, False: 17.2k]
|
5306 | goto exit; |
5307 | } |
5308 | out_fd = _PyLong_AsInt(args[0]); |
5309 | if (out_fd == -1 && PyErr_Occurred()0 ) { Branch (5309:9): [True: 0, False: 17.2k]
Branch (5309:25): [True: 0, False: 0]
|
5310 | goto exit; |
5311 | } |
5312 | in_fd = _PyLong_AsInt(args[1]); |
5313 | if (in_fd == -1 && PyErr_Occurred()0 ) { Branch (5313:9): [True: 0, False: 17.2k]
Branch (5313:24): [True: 0, False: 0]
|
5314 | goto exit; |
5315 | } |
5316 | offobj = args[2]; |
5317 | { |
5318 | Py_ssize_t ival = -1; |
5319 | PyObject *iobj = _PyNumber_Index(args[3]); |
5320 | if (iobj != NULL) { Branch (5320:13): [True: 17.2k, False: 0]
|
5321 | ival = PyLong_AsSsize_t(iobj); |
5322 | Py_DECREF(iobj); |
5323 | } |
5324 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (5324:13): [True: 0, False: 17.2k]
Branch (5324:27): [True: 0, False: 0]
|
5325 | goto exit; |
5326 | } |
5327 | count = ival; |
5328 | } |
5329 | return_value = os_sendfile_impl(module, out_fd, in_fd, offobj, count); |
5330 | |
5331 | exit: |
5332 | return return_value; |
5333 | } |
5334 | |
5335 | #endif /* defined(HAVE_SENDFILE) && !defined(__APPLE__) && !(defined(__FreeBSD__) || defined(__DragonFly__)) */ |
5336 | |
5337 | #if defined(__APPLE__) |
5338 | |
5339 | PyDoc_STRVAR(os__fcopyfile__doc__, |
5340 | "_fcopyfile($module, in_fd, out_fd, flags, /)\n" |
5341 | "--\n" |
5342 | "\n" |
5343 | "Efficiently copy content or metadata of 2 regular file descriptors (macOS)."); |
5344 | |
5345 | #define OS__FCOPYFILE_METHODDEF \ |
5346 | {"_fcopyfile", _PyCFunction_CAST(os__fcopyfile), METH_FASTCALL, os__fcopyfile__doc__}, |
5347 | |
5348 | static PyObject * |
5349 | os__fcopyfile_impl(PyObject *module, int in_fd, int out_fd, int flags); |
5350 | |
5351 | static PyObject * |
5352 | os__fcopyfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
5353 | { |
5354 | PyObject *return_value = NULL; |
5355 | int in_fd; |
5356 | int out_fd; |
5357 | int flags; |
5358 | |
5359 | if (!_PyArg_CheckPositional("_fcopyfile", nargs, 3, 3)) { |
5360 | goto exit; |
5361 | } |
5362 | in_fd = _PyLong_AsInt(args[0]); |
5363 | if (in_fd == -1 && PyErr_Occurred()) { |
5364 | goto exit; |
5365 | } |
5366 | out_fd = _PyLong_AsInt(args[1]); |
5367 | if (out_fd == -1 && PyErr_Occurred()) { |
5368 | goto exit; |
5369 | } |
5370 | flags = _PyLong_AsInt(args[2]); |
5371 | if (flags == -1 && PyErr_Occurred()) { |
5372 | goto exit; |
5373 | } |
5374 | return_value = os__fcopyfile_impl(module, in_fd, out_fd, flags); |
5375 | |
5376 | exit: |
5377 | return return_value; |
5378 | } |
5379 | |
5380 | #endif /* defined(__APPLE__) */ |
5381 | |
5382 | PyDoc_STRVAR(os_fstat__doc__, |
5383 | "fstat($module, /, fd)\n" |
5384 | "--\n" |
5385 | "\n" |
5386 | "Perform a stat system call on the given file descriptor.\n" |
5387 | "\n" |
5388 | "Like stat(), but for an open file descriptor.\n" |
5389 | "Equivalent to os.stat(fd)."); |
5390 | |
5391 | #define OS_FSTAT_METHODDEF \ |
5392 | {"fstat", _PyCFunction_CAST(os_fstat), METH_FASTCALL|METH_KEYWORDS, os_fstat__doc__}, |
5393 | |
5394 | static PyObject * |
5395 | os_fstat_impl(PyObject *module, int fd); |
5396 | |
5397 | static PyObject * |
5398 | os_fstat(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5399 | { |
5400 | PyObject *return_value = NULL; |
5401 | static const char * const _keywords[] = {"fd", NULL}; |
5402 | static _PyArg_Parser _parser = {NULL, _keywords, "fstat", 0}; |
5403 | PyObject *argsbuf[1]; |
5404 | int fd; |
5405 | |
5406 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
5407 | if (!args) { Branch (5407:9): [True: 0, False: 26.4k]
|
5408 | goto exit; |
5409 | } |
5410 | fd = _PyLong_AsInt(args[0]); |
5411 | if (fd == -1 && PyErr_Occurred()3 ) { Branch (5411:9): [True: 3, False: 26.4k]
Branch (5411:21): [True: 2, False: 1]
|
5412 | goto exit; |
5413 | } |
5414 | return_value = os_fstat_impl(module, fd); |
5415 | |
5416 | exit: |
5417 | return return_value; |
5418 | } |
5419 | |
5420 | PyDoc_STRVAR(os_isatty__doc__, |
5421 | "isatty($module, fd, /)\n" |
5422 | "--\n" |
5423 | "\n" |
5424 | "Return True if the fd is connected to a terminal.\n" |
5425 | "\n" |
5426 | "Return True if the file descriptor is an open file descriptor\n" |
5427 | "connected to the slave end of a terminal."); |
5428 | |
5429 | #define OS_ISATTY_METHODDEF \ |
5430 | {"isatty", (PyCFunction)os_isatty, METH_O, os_isatty__doc__}, |
5431 | |
5432 | static int |
5433 | os_isatty_impl(PyObject *module, int fd); |
5434 | |
5435 | static PyObject * |
5436 | os_isatty(PyObject *module, PyObject *arg) |
5437 | { |
5438 | PyObject *return_value = NULL; |
5439 | int fd; |
5440 | int _return_value; |
5441 | |
5442 | fd = _PyLong_AsInt(arg); |
5443 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (5443:9): [True: 0, False: 3.58k]
Branch (5443:21): [True: 0, False: 0]
|
5444 | goto exit; |
5445 | } |
5446 | _return_value = os_isatty_impl(module, fd); |
5447 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (5447:9): [True: 0, False: 3.58k]
Branch (5447:34): [True: 0, False: 0]
|
5448 | goto exit; |
5449 | } |
5450 | return_value = PyBool_FromLong((long)_return_value); |
5451 | |
5452 | exit: |
5453 | return return_value; |
5454 | } |
5455 | |
5456 | #if defined(HAVE_PIPE) |
5457 | |
5458 | PyDoc_STRVAR(os_pipe__doc__, |
5459 | "pipe($module, /)\n" |
5460 | "--\n" |
5461 | "\n" |
5462 | "Create a pipe.\n" |
5463 | "\n" |
5464 | "Returns a tuple of two file descriptors:\n" |
5465 | " (read_fd, write_fd)"); |
5466 | |
5467 | #define OS_PIPE_METHODDEF \ |
5468 | {"pipe", (PyCFunction)os_pipe, METH_NOARGS, os_pipe__doc__}, |
5469 | |
5470 | static PyObject * |
5471 | os_pipe_impl(PyObject *module); |
5472 | |
5473 | static PyObject * |
5474 | os_pipe(PyObject *module, PyObject *Py_UNUSED(ignored)) |
5475 | { |
5476 | return os_pipe_impl(module); |
5477 | } |
5478 | |
5479 | #endif /* defined(HAVE_PIPE) */ |
5480 | |
5481 | #if defined(HAVE_PIPE2) |
5482 | |
5483 | PyDoc_STRVAR(os_pipe2__doc__, |
5484 | "pipe2($module, flags, /)\n" |
5485 | "--\n" |
5486 | "\n" |
5487 | "Create a pipe with flags set atomically.\n" |
5488 | "\n" |
5489 | "Returns a tuple of two file descriptors:\n" |
5490 | " (read_fd, write_fd)\n" |
5491 | "\n" |
5492 | "flags can be constructed by ORing together one or more of these values:\n" |
5493 | "O_NONBLOCK, O_CLOEXEC."); |
5494 | |
5495 | #define OS_PIPE2_METHODDEF \ |
5496 | {"pipe2", (PyCFunction)os_pipe2, METH_O, os_pipe2__doc__}, |
5497 | |
5498 | static PyObject * |
5499 | os_pipe2_impl(PyObject *module, int flags); |
5500 | |
5501 | static PyObject * |
5502 | os_pipe2(PyObject *module, PyObject *arg) |
5503 | { |
5504 | PyObject *return_value = NULL; |
5505 | int flags; |
5506 | |
5507 | flags = _PyLong_AsInt(arg); |
5508 | if (flags == -1 && PyErr_Occurred()3 ) { Branch (5508:9): [True: 3, False: 2]
Branch (5508:24): [True: 3, False: 0]
|
5509 | goto exit; |
5510 | } |
5511 | return_value = os_pipe2_impl(module, flags); |
5512 | |
5513 | exit: |
5514 | return return_value; |
5515 | } |
5516 | |
5517 | #endif /* defined(HAVE_PIPE2) */ |
5518 | |
5519 | #if defined(HAVE_WRITEV) |
5520 | |
5521 | PyDoc_STRVAR(os_writev__doc__, |
5522 | "writev($module, fd, buffers, /)\n" |
5523 | "--\n" |
5524 | "\n" |
5525 | "Iterate over buffers, and write the contents of each to a file descriptor.\n" |
5526 | "\n" |
5527 | "Returns the total number of bytes written.\n" |
5528 | "buffers must be a sequence of bytes-like objects."); |
5529 | |
5530 | #define OS_WRITEV_METHODDEF \ |
5531 | {"writev", _PyCFunction_CAST(os_writev), METH_FASTCALL, os_writev__doc__}, |
5532 | |
5533 | static Py_ssize_t |
5534 | os_writev_impl(PyObject *module, int fd, PyObject *buffers); |
5535 | |
5536 | static PyObject * |
5537 | os_writev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
5538 | { |
5539 | PyObject *return_value = NULL; |
5540 | int fd; |
5541 | PyObject *buffers; |
5542 | Py_ssize_t _return_value; |
5543 | |
5544 | if (!_PyArg_CheckPositional("writev", nargs, 2, 2)) { |
5545 | goto exit; |
5546 | } |
5547 | fd = _PyLong_AsInt(args[0]); |
5548 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (5548:9): [True: 0, False: 3]
Branch (5548:21): [True: 0, False: 0]
|
5549 | goto exit; |
5550 | } |
5551 | buffers = args[1]; |
5552 | _return_value = os_writev_impl(module, fd, buffers); |
5553 | if ((_return_value == -1) && PyErr_Occurred()1 ) { Branch (5553:9): [True: 1, False: 2]
Branch (5553:34): [True: 1, False: 0]
|
5554 | goto exit; |
5555 | } |
5556 | return_value = PyLong_FromSsize_t(_return_value); |
5557 | |
5558 | exit: |
5559 | return return_value; |
5560 | } |
5561 | |
5562 | #endif /* defined(HAVE_WRITEV) */ |
5563 | |
5564 | #if defined(HAVE_PWRITE) |
5565 | |
5566 | PyDoc_STRVAR(os_pwrite__doc__, |
5567 | "pwrite($module, fd, buffer, offset, /)\n" |
5568 | "--\n" |
5569 | "\n" |
5570 | "Write bytes to a file descriptor starting at a particular offset.\n" |
5571 | "\n" |
5572 | "Write buffer to fd, starting at offset bytes from the beginning of\n" |
5573 | "the file. Returns the number of bytes writte. Does not change the\n" |
5574 | "current file offset."); |
5575 | |
5576 | #define OS_PWRITE_METHODDEF \ |
5577 | {"pwrite", _PyCFunction_CAST(os_pwrite), METH_FASTCALL, os_pwrite__doc__}, |
5578 | |
5579 | static Py_ssize_t |
5580 | os_pwrite_impl(PyObject *module, int fd, Py_buffer *buffer, Py_off_t offset); |
5581 | |
5582 | static PyObject * |
5583 | os_pwrite(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
5584 | { |
5585 | PyObject *return_value = NULL; |
5586 | int fd; |
5587 | Py_buffer buffer = {NULL, NULL}; |
5588 | Py_off_t offset; |
5589 | Py_ssize_t _return_value; |
5590 | |
5591 | if (!_PyArg_CheckPositional("pwrite", nargs, 3, 3)) { |
5592 | goto exit; |
5593 | } |
5594 | fd = _PyLong_AsInt(args[0]); |
5595 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (5595:9): [True: 0, False: 1]
Branch (5595:21): [True: 0, False: 0]
|
5596 | goto exit; |
5597 | } |
5598 | if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) { Branch (5598:9): [True: 0, False: 1]
|
5599 | goto exit; |
5600 | } |
5601 | if (!PyBuffer_IsContiguous(&buffer, 'C')) { Branch (5601:9): [True: 0, False: 1]
|
5602 | _PyArg_BadArgument("pwrite", "argument 2", "contiguous buffer", args[1]); |
5603 | goto exit; |
5604 | } |
5605 | if (!Py_off_t_converter(args[2], &offset)) { Branch (5605:9): [True: 0, False: 1]
|
5606 | goto exit; |
5607 | } |
5608 | _return_value = os_pwrite_impl(module, fd, &buffer, offset); |
5609 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (5609:9): [True: 0, False: 1]
Branch (5609:34): [True: 0, False: 0]
|
5610 | goto exit; |
5611 | } |
5612 | return_value = PyLong_FromSsize_t(_return_value); |
5613 | |
5614 | exit: |
5615 | /* Cleanup for buffer */ |
5616 | if (buffer.obj) { Branch (5616:9): [True: 1, False: 0]
|
5617 | PyBuffer_Release(&buffer); |
5618 | } |
5619 | |
5620 | return return_value; |
5621 | } |
5622 | |
5623 | #endif /* defined(HAVE_PWRITE) */ |
5624 | |
5625 | #if (defined(HAVE_PWRITEV) || defined (HAVE_PWRITEV2)) |
5626 | |
5627 | PyDoc_STRVAR(os_pwritev__doc__, |
5628 | "pwritev($module, fd, buffers, offset, flags=0, /)\n" |
5629 | "--\n" |
5630 | "\n" |
5631 | "Writes the contents of bytes-like objects to a file descriptor at a given offset.\n" |
5632 | "\n" |
5633 | "Combines the functionality of writev() and pwrite(). All buffers must be a sequence\n" |
5634 | "of bytes-like objects. Buffers are processed in array order. Entire contents of first\n" |
5635 | "buffer is written before proceeding to second, and so on. The operating system may\n" |
5636 | "set a limit (sysconf() value SC_IOV_MAX) on the number of buffers that can be used.\n" |
5637 | "This function writes the contents of each object to the file descriptor and returns\n" |
5638 | "the total number of bytes written.\n" |
5639 | "\n" |
5640 | "The flags argument contains a bitwise OR of zero or more of the following flags:\n" |
5641 | "\n" |
5642 | "- RWF_DSYNC\n" |
5643 | "- RWF_SYNC\n" |
5644 | "- RWF_APPEND\n" |
5645 | "\n" |
5646 | "Using non-zero flags requires Linux 4.7 or newer."); |
5647 | |
5648 | #define OS_PWRITEV_METHODDEF \ |
5649 | {"pwritev", _PyCFunction_CAST(os_pwritev), METH_FASTCALL, os_pwritev__doc__}, |
5650 | |
5651 | static Py_ssize_t |
5652 | os_pwritev_impl(PyObject *module, int fd, PyObject *buffers, Py_off_t offset, |
5653 | int flags); |
5654 | |
5655 | static PyObject * |
5656 | os_pwritev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
5657 | { |
5658 | PyObject *return_value = NULL; |
5659 | int fd; |
5660 | PyObject *buffers; |
5661 | Py_off_t offset; |
5662 | int flags = 0; |
5663 | Py_ssize_t _return_value; |
5664 | |
5665 | if (!_PyArg_CheckPositional("pwritev", nargs, 3, 4)) { |
5666 | goto exit; |
5667 | } |
5668 | fd = _PyLong_AsInt(args[0]); |
5669 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (5669:9): [True: 0, False: 1]
Branch (5669:21): [True: 0, False: 0]
|
5670 | goto exit; |
5671 | } |
5672 | buffers = args[1]; |
5673 | if (!Py_off_t_converter(args[2], &offset)) { Branch (5673:9): [True: 0, False: 1]
|
5674 | goto exit; |
5675 | } |
5676 | if (nargs < 4) { Branch (5676:9): [True: 1, False: 0]
|
5677 | goto skip_optional; |
5678 | } |
5679 | flags = _PyLong_AsInt(args[3]); |
5680 | if (flags == -1 && PyErr_Occurred()) { Branch (5680:9): [True: 0, False: 0]
Branch (5680:24): [True: 0, False: 0]
|
5681 | goto exit; |
5682 | } |
5683 | skip_optional: |
5684 | _return_value = os_pwritev_impl(module, fd, buffers, offset, flags); |
5685 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (5685:9): [True: 0, False: 1]
Branch (5685:34): [True: 0, False: 0]
|
5686 | goto exit; |
5687 | } |
5688 | return_value = PyLong_FromSsize_t(_return_value); |
5689 | |
5690 | exit: |
5691 | return return_value; |
5692 | } |
5693 | |
5694 | #endif /* (defined(HAVE_PWRITEV) || defined (HAVE_PWRITEV2)) */ |
5695 | |
5696 | #if defined(HAVE_COPY_FILE_RANGE) |
5697 | |
5698 | PyDoc_STRVAR(os_copy_file_range__doc__, |
5699 | "copy_file_range($module, /, src, dst, count, offset_src=None,\n" |
5700 | " offset_dst=None)\n" |
5701 | "--\n" |
5702 | "\n" |
5703 | "Copy count bytes from one file descriptor to another.\n" |
5704 | "\n" |
5705 | " src\n" |
5706 | " Source file descriptor.\n" |
5707 | " dst\n" |
5708 | " Destination file descriptor.\n" |
5709 | " count\n" |
5710 | " Number of bytes to copy.\n" |
5711 | " offset_src\n" |
5712 | " Starting offset in src.\n" |
5713 | " offset_dst\n" |
5714 | " Starting offset in dst.\n" |
5715 | "\n" |
5716 | "If offset_src is None, then src is read from the current position;\n" |
5717 | "respectively for offset_dst."); |
5718 | |
5719 | #define OS_COPY_FILE_RANGE_METHODDEF \ |
5720 | {"copy_file_range", _PyCFunction_CAST(os_copy_file_range), METH_FASTCALL|METH_KEYWORDS, os_copy_file_range__doc__}, |
5721 | |
5722 | static PyObject * |
5723 | os_copy_file_range_impl(PyObject *module, int src, int dst, Py_ssize_t count, |
5724 | PyObject *offset_src, PyObject *offset_dst); |
5725 | |
5726 | static PyObject * |
5727 | os_copy_file_range(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5728 | { |
5729 | PyObject *return_value = NULL; |
5730 | static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", NULL}; |
5731 | static _PyArg_Parser _parser = {NULL, _keywords, "copy_file_range", 0}; |
5732 | PyObject *argsbuf[5]; |
5733 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 02 ) - 3; Branch (5733:36): [True: 1, False: 2]
|
5734 | int src; |
5735 | int dst; |
5736 | Py_ssize_t count; |
5737 | PyObject *offset_src = Py_None; |
5738 | PyObject *offset_dst = Py_None; |
5739 | |
5740 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 5, 0, argsbuf); |
5741 | if (!args) { Branch (5741:9): [True: 0, False: 3]
|
5742 | goto exit; |
5743 | } |
5744 | src = _PyLong_AsInt(args[0]); |
5745 | if (src == -1 && PyErr_Occurred()0 ) { Branch (5745:9): [True: 0, False: 3]
Branch (5745:22): [True: 0, False: 0]
|
5746 | goto exit; |
5747 | } |
5748 | dst = _PyLong_AsInt(args[1]); |
5749 | if (dst == -1 && PyErr_Occurred()0 ) { Branch (5749:9): [True: 0, False: 3]
Branch (5749:22): [True: 0, False: 0]
|
5750 | goto exit; |
5751 | } |
5752 | { |
5753 | Py_ssize_t ival = -1; |
5754 | PyObject *iobj = _PyNumber_Index(args[2]); |
5755 | if (iobj != NULL) { Branch (5755:13): [True: 3, False: 0]
|
5756 | ival = PyLong_AsSsize_t(iobj); |
5757 | Py_DECREF(iobj); |
5758 | } |
5759 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (5759:13): [True: 0, False: 3]
Branch (5759:27): [True: 0, False: 0]
|
5760 | goto exit; |
5761 | } |
5762 | count = ival; |
5763 | } |
5764 | if (!noptargs) { Branch (5764:9): [True: 2, False: 1]
|
5765 | goto skip_optional_pos; |
5766 | } |
5767 | if (args[3]) { Branch (5767:9): [True: 1, False: 0]
|
5768 | offset_src = args[3]; |
5769 | if (!--noptargs) { Branch (5769:13): [True: 0, False: 1]
|
5770 | goto skip_optional_pos; |
5771 | } |
5772 | } |
5773 | offset_dst = args[4]; |
5774 | skip_optional_pos: |
5775 | return_value = os_copy_file_range_impl(module, src, dst, count, offset_src, offset_dst); |
5776 | |
5777 | exit: |
5778 | return return_value; |
5779 | } |
5780 | |
5781 | #endif /* defined(HAVE_COPY_FILE_RANGE) */ |
5782 | |
5783 | #if ((defined(HAVE_SPLICE) && !defined(_AIX))) |
5784 | |
5785 | PyDoc_STRVAR(os_splice__doc__, |
5786 | "splice($module, /, src, dst, count, offset_src=None, offset_dst=None,\n" |
5787 | " flags=0)\n" |
5788 | "--\n" |
5789 | "\n" |
5790 | "Transfer count bytes from one pipe to a descriptor or vice versa.\n" |
5791 | "\n" |
5792 | " src\n" |
5793 | " Source file descriptor.\n" |
5794 | " dst\n" |
5795 | " Destination file descriptor.\n" |
5796 | " count\n" |
5797 | " Number of bytes to copy.\n" |
5798 | " offset_src\n" |
5799 | " Starting offset in src.\n" |
5800 | " offset_dst\n" |
5801 | " Starting offset in dst.\n" |
5802 | " flags\n" |
5803 | " Flags to modify the semantics of the call.\n" |
5804 | "\n" |
5805 | "If offset_src is None, then src is read from the current position;\n" |
5806 | "respectively for offset_dst. The offset associated to the file\n" |
5807 | "descriptor that refers to a pipe must be None."); |
5808 | |
5809 | #define OS_SPLICE_METHODDEF \ |
5810 | {"splice", _PyCFunction_CAST(os_splice), METH_FASTCALL|METH_KEYWORDS, os_splice__doc__}, |
5811 | |
5812 | static PyObject * |
5813 | os_splice_impl(PyObject *module, int src, int dst, Py_ssize_t count, |
5814 | PyObject *offset_src, PyObject *offset_dst, |
5815 | unsigned int flags); |
5816 | |
5817 | static PyObject * |
5818 | os_splice(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5819 | { |
5820 | PyObject *return_value = NULL; |
5821 | static const char * const _keywords[] = {"src", "dst", "count", "offset_src", "offset_dst", "flags", NULL}; |
5822 | static _PyArg_Parser _parser = {NULL, _keywords, "splice", 0}; |
5823 | PyObject *argsbuf[6]; |
5824 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE2 (kwnames) : 02 ) - 3; Branch (5824:36): [True: 2, False: 2]
|
5825 | int src; |
5826 | int dst; |
5827 | Py_ssize_t count; |
5828 | PyObject *offset_src = Py_None; |
5829 | PyObject *offset_dst = Py_None; |
5830 | unsigned int flags = 0; |
5831 | |
5832 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 6, 0, argsbuf); |
5833 | if (!args) { Branch (5833:9): [True: 0, False: 4]
|
5834 | goto exit; |
5835 | } |
5836 | src = _PyLong_AsInt(args[0]); |
5837 | if (src == -1 && PyErr_Occurred()0 ) { Branch (5837:9): [True: 0, False: 4]
Branch (5837:22): [True: 0, False: 0]
|
5838 | goto exit; |
5839 | } |
5840 | dst = _PyLong_AsInt(args[1]); |
5841 | if (dst == -1 && PyErr_Occurred()0 ) { Branch (5841:9): [True: 0, False: 4]
Branch (5841:22): [True: 0, False: 0]
|
5842 | goto exit; |
5843 | } |
5844 | { |
5845 | Py_ssize_t ival = -1; |
5846 | PyObject *iobj = _PyNumber_Index(args[2]); |
5847 | if (iobj != NULL) { Branch (5847:13): [True: 4, False: 0]
|
5848 | ival = PyLong_AsSsize_t(iobj); |
5849 | Py_DECREF(iobj); |
5850 | } |
5851 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (5851:13): [True: 0, False: 4]
Branch (5851:27): [True: 0, False: 0]
|
5852 | goto exit; |
5853 | } |
5854 | count = ival; |
5855 | } |
5856 | if (!noptargs) { Branch (5856:9): [True: 2, False: 2]
|
5857 | goto skip_optional_pos; |
5858 | } |
5859 | if (args[3]) { Branch (5859:9): [True: 1, False: 1]
|
5860 | offset_src = args[3]; |
5861 | if (!--noptargs) { Branch (5861:13): [True: 1, False: 0]
|
5862 | goto skip_optional_pos; |
5863 | } |
5864 | } |
5865 | if (args[4]) { Branch (5865:9): [True: 1, False: 0]
|
5866 | offset_dst = args[4]; |
5867 | if (!--noptargs) { Branch (5867:13): [True: 1, False: 0]
|
5868 | goto skip_optional_pos; |
5869 | } |
5870 | } |
5871 | if (!_PyLong_UnsignedInt_Converter(args[5], &flags)) { Branch (5871:9): [True: 0, False: 0]
|
5872 | goto exit; |
5873 | } |
5874 | skip_optional_pos: |
5875 | return_value = os_splice_impl(module, src, dst, count, offset_src, offset_dst, flags); |
5876 | |
5877 | exit: |
5878 | return return_value; |
5879 | } |
5880 | |
5881 | #endif /* ((defined(HAVE_SPLICE) && !defined(_AIX))) */ |
5882 | |
5883 | #if defined(HAVE_MKFIFO) |
5884 | |
5885 | PyDoc_STRVAR(os_mkfifo__doc__, |
5886 | "mkfifo($module, /, path, mode=438, *, dir_fd=None)\n" |
5887 | "--\n" |
5888 | "\n" |
5889 | "Create a \"fifo\" (a POSIX named pipe).\n" |
5890 | "\n" |
5891 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
5892 | " and path should be relative; path will then be relative to that directory.\n" |
5893 | "dir_fd may not be implemented on your platform.\n" |
5894 | " If it is unavailable, using it will raise a NotImplementedError."); |
5895 | |
5896 | #define OS_MKFIFO_METHODDEF \ |
5897 | {"mkfifo", _PyCFunction_CAST(os_mkfifo), METH_FASTCALL|METH_KEYWORDS, os_mkfifo__doc__}, |
5898 | |
5899 | static PyObject * |
5900 | os_mkfifo_impl(PyObject *module, path_t *path, int mode, int dir_fd); |
5901 | |
5902 | static PyObject * |
5903 | os_mkfifo(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5904 | { |
5905 | PyObject *return_value = NULL; |
5906 | static const char * const _keywords[] = {"path", "mode", "dir_fd", NULL}; |
5907 | static _PyArg_Parser _parser = {NULL, _keywords, "mkfifo", 0}; |
5908 | PyObject *argsbuf[3]; |
5909 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE1 (kwnames) : 07 ) - 1; Branch (5909:36): [True: 1, False: 7]
|
5910 | path_t path = PATH_T_INITIALIZE("mkfifo", "path", 0, 0); |
5911 | int mode = 438; |
5912 | int dir_fd = DEFAULT_DIR_FD; |
5913 | |
5914 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
5915 | if (!args) { Branch (5915:9): [True: 0, False: 8]
|
5916 | goto exit; |
5917 | } |
5918 | if (!path_converter(args[0], &path)) { Branch (5918:9): [True: 0, False: 8]
|
5919 | goto exit; |
5920 | } |
5921 | if (!noptargs) { Branch (5921:9): [True: 4, False: 4]
|
5922 | goto skip_optional_pos; |
5923 | } |
5924 | if (args[1]) { Branch (5924:9): [True: 4, False: 0]
|
5925 | mode = _PyLong_AsInt(args[1]); |
5926 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (5926:13): [True: 0, False: 4]
Branch (5926:27): [True: 0, False: 0]
|
5927 | goto exit; |
5928 | } |
5929 | if (!--noptargs) { Branch (5929:13): [True: 3, False: 1]
|
5930 | goto skip_optional_pos; |
5931 | } |
5932 | } |
5933 | skip_optional_pos: |
5934 | if (!noptargs) { Branch (5934:9): [True: 7, False: 1]
|
5935 | goto skip_optional_kwonly; |
5936 | } |
5937 | if (!MKFIFOAT_DIR_FD_CONVERTER(args[2], &dir_fd)) { Branch (5937:9): [True: 0, False: 1]
|
5938 | goto exit; |
5939 | } |
5940 | skip_optional_kwonly: |
5941 | return_value = os_mkfifo_impl(module, &path, mode, dir_fd); |
5942 | |
5943 | exit: |
5944 | /* Cleanup for path */ |
5945 | path_cleanup(&path); |
5946 | |
5947 | return return_value; |
5948 | } |
5949 | |
5950 | #endif /* defined(HAVE_MKFIFO) */ |
5951 | |
5952 | #if (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) |
5953 | |
5954 | PyDoc_STRVAR(os_mknod__doc__, |
5955 | "mknod($module, /, path, mode=384, device=0, *, dir_fd=None)\n" |
5956 | "--\n" |
5957 | "\n" |
5958 | "Create a node in the file system.\n" |
5959 | "\n" |
5960 | "Create a node in the file system (file, device special file or named pipe)\n" |
5961 | "at path. mode specifies both the permissions to use and the\n" |
5962 | "type of node to be created, being combined (bitwise OR) with one of\n" |
5963 | "S_IFREG, S_IFCHR, S_IFBLK, and S_IFIFO. If S_IFCHR or S_IFBLK is set on mode,\n" |
5964 | "device defines the newly created device special file (probably using\n" |
5965 | "os.makedev()). Otherwise device is ignored.\n" |
5966 | "\n" |
5967 | "If dir_fd is not None, it should be a file descriptor open to a directory,\n" |
5968 | " and path should be relative; path will then be relative to that directory.\n" |
5969 | "dir_fd may not be implemented on your platform.\n" |
5970 | " If it is unavailable, using it will raise a NotImplementedError."); |
5971 | |
5972 | #define OS_MKNOD_METHODDEF \ |
5973 | {"mknod", _PyCFunction_CAST(os_mknod), METH_FASTCALL|METH_KEYWORDS, os_mknod__doc__}, |
5974 | |
5975 | static PyObject * |
5976 | os_mknod_impl(PyObject *module, path_t *path, int mode, dev_t device, |
5977 | int dir_fd); |
5978 | |
5979 | static PyObject * |
5980 | os_mknod(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
5981 | { |
5982 | PyObject *return_value = NULL; |
5983 | static const char * const _keywords[] = {"path", "mode", "device", "dir_fd", NULL}; |
5984 | static _PyArg_Parser _parser = {NULL, _keywords, "mknod", 0}; |
5985 | PyObject *argsbuf[4]; |
5986 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE2 (kwnames) : 01 ) - 1; Branch (5986:36): [True: 2, False: 1]
|
5987 | path_t path = PATH_T_INITIALIZE("mknod", "path", 0, 0); |
5988 | int mode = 384; |
5989 | dev_t device = 0; |
5990 | int dir_fd = DEFAULT_DIR_FD; |
5991 | |
5992 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 3, 0, argsbuf); |
5993 | if (!args) { Branch (5993:9): [True: 0, False: 3]
|
5994 | goto exit; |
5995 | } |
5996 | if (!path_converter(args[0], &path)) { Branch (5996:9): [True: 0, False: 3]
|
5997 | goto exit; |
5998 | } |
5999 | if (!noptargs) { Branch (5999:9): [True: 0, False: 3]
|
6000 | goto skip_optional_pos; |
6001 | } |
6002 | if (args[1]) { Branch (6002:9): [True: 3, False: 0]
|
6003 | mode = _PyLong_AsInt(args[1]); |
6004 | if (mode == -1 && PyErr_Occurred()0 ) { Branch (6004:13): [True: 0, False: 3]
Branch (6004:27): [True: 0, False: 0]
|
6005 | goto exit; |
6006 | } |
6007 | if (!--noptargs) { Branch (6007:13): [True: 0, False: 3]
|
6008 | goto skip_optional_pos; |
6009 | } |
6010 | } |
6011 | if (args[2]) { Branch (6011:9): [True: 3, False: 0]
|
6012 | if (!_Py_Dev_Converter(args[2], &device)) { Branch (6012:13): [True: 0, False: 3]
|
6013 | goto exit; |
6014 | } |
6015 | if (!--noptargs) { Branch (6015:13): [True: 1, False: 2]
|
6016 | goto skip_optional_pos; |
6017 | } |
6018 | } |
6019 | skip_optional_pos: |
6020 | if (!noptargs) { Branch (6020:9): [True: 1, False: 2]
|
6021 | goto skip_optional_kwonly; |
6022 | } |
6023 | if (!MKNODAT_DIR_FD_CONVERTER(args[3], &dir_fd)) { Branch (6023:9): [True: 0, False: 2]
|
6024 | goto exit; |
6025 | } |
6026 | skip_optional_kwonly: |
6027 | return_value = os_mknod_impl(module, &path, mode, device, dir_fd); |
6028 | |
6029 | exit: |
6030 | /* Cleanup for path */ |
6031 | path_cleanup(&path); |
6032 | |
6033 | return return_value; |
6034 | } |
6035 | |
6036 | #endif /* (defined(HAVE_MKNOD) && defined(HAVE_MAKEDEV)) */ |
6037 | |
6038 | #if defined(HAVE_DEVICE_MACROS) |
6039 | |
6040 | PyDoc_STRVAR(os_major__doc__, |
6041 | "major($module, device, /)\n" |
6042 | "--\n" |
6043 | "\n" |
6044 | "Extracts a device major number from a raw device number."); |
6045 | |
6046 | #define OS_MAJOR_METHODDEF \ |
6047 | {"major", (PyCFunction)os_major, METH_O, os_major__doc__}, |
6048 | |
6049 | static unsigned int |
6050 | os_major_impl(PyObject *module, dev_t device); |
6051 | |
6052 | static PyObject * |
6053 | os_major(PyObject *module, PyObject *arg) |
6054 | { |
6055 | PyObject *return_value = NULL; |
6056 | dev_t device; |
6057 | unsigned int _return_value; |
6058 | |
6059 | if (!_Py_Dev_Converter(arg, &device)) { Branch (6059:9): [True: 2, False: 2]
|
6060 | goto exit; |
6061 | } |
6062 | _return_value = os_major_impl(module, device); |
6063 | if ((_return_value == (unsigned int)-1) && PyErr_Occurred()0 ) { Branch (6063:9): [True: 0, False: 2]
Branch (6063:48): [True: 0, False: 0]
|
6064 | goto exit; |
6065 | } |
6066 | return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); |
6067 | |
6068 | exit: |
6069 | return return_value; |
6070 | } |
6071 | |
6072 | #endif /* defined(HAVE_DEVICE_MACROS) */ |
6073 | |
6074 | #if defined(HAVE_DEVICE_MACROS) |
6075 | |
6076 | PyDoc_STRVAR(os_minor__doc__, |
6077 | "minor($module, device, /)\n" |
6078 | "--\n" |
6079 | "\n" |
6080 | "Extracts a device minor number from a raw device number."); |
6081 | |
6082 | #define OS_MINOR_METHODDEF \ |
6083 | {"minor", (PyCFunction)os_minor, METH_O, os_minor__doc__}, |
6084 | |
6085 | static unsigned int |
6086 | os_minor_impl(PyObject *module, dev_t device); |
6087 | |
6088 | static PyObject * |
6089 | os_minor(PyObject *module, PyObject *arg) |
6090 | { |
6091 | PyObject *return_value = NULL; |
6092 | dev_t device; |
6093 | unsigned int _return_value; |
6094 | |
6095 | if (!_Py_Dev_Converter(arg, &device)) { Branch (6095:9): [True: 2, False: 2]
|
6096 | goto exit; |
6097 | } |
6098 | _return_value = os_minor_impl(module, device); |
6099 | if ((_return_value == (unsigned int)-1) && PyErr_Occurred()0 ) { Branch (6099:9): [True: 0, False: 2]
Branch (6099:48): [True: 0, False: 0]
|
6100 | goto exit; |
6101 | } |
6102 | return_value = PyLong_FromUnsignedLong((unsigned long)_return_value); |
6103 | |
6104 | exit: |
6105 | return return_value; |
6106 | } |
6107 | |
6108 | #endif /* defined(HAVE_DEVICE_MACROS) */ |
6109 | |
6110 | #if defined(HAVE_DEVICE_MACROS) |
6111 | |
6112 | PyDoc_STRVAR(os_makedev__doc__, |
6113 | "makedev($module, major, minor, /)\n" |
6114 | "--\n" |
6115 | "\n" |
6116 | "Composes a raw device number from the major and minor device numbers."); |
6117 | |
6118 | #define OS_MAKEDEV_METHODDEF \ |
6119 | {"makedev", _PyCFunction_CAST(os_makedev), METH_FASTCALL, os_makedev__doc__}, |
6120 | |
6121 | static dev_t |
6122 | os_makedev_impl(PyObject *module, int major, int minor); |
6123 | |
6124 | static PyObject * |
6125 | os_makedev(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
6126 | { |
6127 | PyObject *return_value = NULL; |
6128 | int major; |
6129 | int minor; |
6130 | dev_t _return_value; |
6131 | |
6132 | if (!_PyArg_CheckPositional("makedev", nargs, 2, 2)) { |
6133 | goto exit; |
6134 | } |
6135 | major = _PyLong_AsInt(args[0]); |
6136 | if (major == -1 && PyErr_Occurred()1 ) { Branch (6136:9): [True: 1, False: 2]
Branch (6136:24): [True: 1, False: 0]
|
6137 | goto exit; |
6138 | } |
6139 | minor = _PyLong_AsInt(args[1]); |
6140 | if (minor == -1 && PyErr_Occurred()1 ) { Branch (6140:9): [True: 1, False: 1]
Branch (6140:24): [True: 1, False: 0]
|
6141 | goto exit; |
6142 | } |
6143 | _return_value = os_makedev_impl(module, major, minor); |
6144 | if ((_return_value == (dev_t)-1) && PyErr_Occurred()0 ) { Branch (6144:9): [True: 0, False: 1]
Branch (6144:41): [True: 0, False: 0]
|
6145 | goto exit; |
6146 | } |
6147 | return_value = _PyLong_FromDev(_return_value); |
6148 | |
6149 | exit: |
6150 | return return_value; |
6151 | } |
6152 | |
6153 | #endif /* defined(HAVE_DEVICE_MACROS) */ |
6154 | |
6155 | #if (defined HAVE_FTRUNCATE || defined MS_WINDOWS) |
6156 | |
6157 | PyDoc_STRVAR(os_ftruncate__doc__, |
6158 | "ftruncate($module, fd, length, /)\n" |
6159 | "--\n" |
6160 | "\n" |
6161 | "Truncate a file, specified by file descriptor, to a specific length."); |
6162 | |
6163 | #define OS_FTRUNCATE_METHODDEF \ |
6164 | {"ftruncate", _PyCFunction_CAST(os_ftruncate), METH_FASTCALL, os_ftruncate__doc__}, |
6165 | |
6166 | static PyObject * |
6167 | os_ftruncate_impl(PyObject *module, int fd, Py_off_t length); |
6168 | |
6169 | static PyObject * |
6170 | os_ftruncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
6171 | { |
6172 | PyObject *return_value = NULL; |
6173 | int fd; |
6174 | Py_off_t length; |
6175 | |
6176 | if (!_PyArg_CheckPositional("ftruncate", nargs, 2, 2)) { |
6177 | goto exit; |
6178 | } |
6179 | fd = _PyLong_AsInt(args[0]); |
6180 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (6180:9): [True: 0, False: 262]
Branch (6180:21): [True: 0, False: 0]
|
6181 | goto exit; |
6182 | } |
6183 | if (!Py_off_t_converter(args[1], &length)) { Branch (6183:9): [True: 0, False: 262]
|
6184 | goto exit; |
6185 | } |
6186 | return_value = os_ftruncate_impl(module, fd, length); |
6187 | |
6188 | exit: |
6189 | return return_value; |
6190 | } |
6191 | |
6192 | #endif /* (defined HAVE_FTRUNCATE || defined MS_WINDOWS) */ |
6193 | |
6194 | #if (defined HAVE_TRUNCATE || defined MS_WINDOWS) |
6195 | |
6196 | PyDoc_STRVAR(os_truncate__doc__, |
6197 | "truncate($module, /, path, length)\n" |
6198 | "--\n" |
6199 | "\n" |
6200 | "Truncate a file, specified by path, to a specific length.\n" |
6201 | "\n" |
6202 | "On some platforms, path may also be specified as an open file descriptor.\n" |
6203 | " If this functionality is unavailable, using it raises an exception."); |
6204 | |
6205 | #define OS_TRUNCATE_METHODDEF \ |
6206 | {"truncate", _PyCFunction_CAST(os_truncate), METH_FASTCALL|METH_KEYWORDS, os_truncate__doc__}, |
6207 | |
6208 | static PyObject * |
6209 | os_truncate_impl(PyObject *module, path_t *path, Py_off_t length); |
6210 | |
6211 | static PyObject * |
6212 | os_truncate(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6213 | { |
6214 | PyObject *return_value = NULL; |
6215 | static const char * const _keywords[] = {"path", "length", NULL}; |
6216 | static _PyArg_Parser _parser = {NULL, _keywords, "truncate", 0}; |
6217 | PyObject *argsbuf[2]; |
6218 | path_t path = PATH_T_INITIALIZE("truncate", "path", 0, PATH_HAVE_FTRUNCATE); |
6219 | Py_off_t length; |
6220 | |
6221 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
6222 | if (!args) { Branch (6222:9): [True: 0, False: 7]
|
6223 | goto exit; |
6224 | } |
6225 | if (!path_converter(args[0], &path)) { Branch (6225:9): [True: 0, False: 7]
|
6226 | goto exit; |
6227 | } |
6228 | if (!Py_off_t_converter(args[1], &length)) { Branch (6228:9): [True: 0, False: 7]
|
6229 | goto exit; |
6230 | } |
6231 | return_value = os_truncate_impl(module, &path, length); |
6232 | |
6233 | exit: |
6234 | /* Cleanup for path */ |
6235 | path_cleanup(&path); |
6236 | |
6237 | return return_value; |
6238 | } |
6239 | |
6240 | #endif /* (defined HAVE_TRUNCATE || defined MS_WINDOWS) */ |
6241 | |
6242 | #if (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG)) |
6243 | |
6244 | PyDoc_STRVAR(os_posix_fallocate__doc__, |
6245 | "posix_fallocate($module, fd, offset, length, /)\n" |
6246 | "--\n" |
6247 | "\n" |
6248 | "Ensure a file has allocated at least a particular number of bytes on disk.\n" |
6249 | "\n" |
6250 | "Ensure that the file specified by fd encompasses a range of bytes\n" |
6251 | "starting at offset bytes from the beginning and continuing for length bytes."); |
6252 | |
6253 | #define OS_POSIX_FALLOCATE_METHODDEF \ |
6254 | {"posix_fallocate", _PyCFunction_CAST(os_posix_fallocate), METH_FASTCALL, os_posix_fallocate__doc__}, |
6255 | |
6256 | static PyObject * |
6257 | os_posix_fallocate_impl(PyObject *module, int fd, Py_off_t offset, |
6258 | Py_off_t length); |
6259 | |
6260 | static PyObject * |
6261 | os_posix_fallocate(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
6262 | { |
6263 | PyObject *return_value = NULL; |
6264 | int fd; |
6265 | Py_off_t offset; |
6266 | Py_off_t length; |
6267 | |
6268 | if (!_PyArg_CheckPositional("posix_fallocate", nargs, 3, 3)) { |
6269 | goto exit; |
6270 | } |
6271 | fd = _PyLong_AsInt(args[0]); |
6272 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (6272:9): [True: 0, False: 2]
Branch (6272:21): [True: 0, False: 0]
|
6273 | goto exit; |
6274 | } |
6275 | if (!Py_off_t_converter(args[1], &offset)) { Branch (6275:9): [True: 0, False: 2]
|
6276 | goto exit; |
6277 | } |
6278 | if (!Py_off_t_converter(args[2], &length)) { Branch (6278:9): [True: 0, False: 2]
|
6279 | goto exit; |
6280 | } |
6281 | return_value = os_posix_fallocate_impl(module, fd, offset, length); |
6282 | |
6283 | exit: |
6284 | return return_value; |
6285 | } |
6286 | |
6287 | #endif /* (defined(HAVE_POSIX_FALLOCATE) && !defined(POSIX_FADVISE_AIX_BUG)) */ |
6288 | |
6289 | #if (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) |
6290 | |
6291 | PyDoc_STRVAR(os_posix_fadvise__doc__, |
6292 | "posix_fadvise($module, fd, offset, length, advice, /)\n" |
6293 | "--\n" |
6294 | "\n" |
6295 | "Announce an intention to access data in a specific pattern.\n" |
6296 | "\n" |
6297 | "Announce an intention to access data in a specific pattern, thus allowing\n" |
6298 | "the kernel to make optimizations.\n" |
6299 | "The advice applies to the region of the file specified by fd starting at\n" |
6300 | "offset and continuing for length bytes.\n" |
6301 | "advice is one of POSIX_FADV_NORMAL, POSIX_FADV_SEQUENTIAL,\n" |
6302 | "POSIX_FADV_RANDOM, POSIX_FADV_NOREUSE, POSIX_FADV_WILLNEED, or\n" |
6303 | "POSIX_FADV_DONTNEED."); |
6304 | |
6305 | #define OS_POSIX_FADVISE_METHODDEF \ |
6306 | {"posix_fadvise", _PyCFunction_CAST(os_posix_fadvise), METH_FASTCALL, os_posix_fadvise__doc__}, |
6307 | |
6308 | static PyObject * |
6309 | os_posix_fadvise_impl(PyObject *module, int fd, Py_off_t offset, |
6310 | Py_off_t length, int advice); |
6311 | |
6312 | static PyObject * |
6313 | os_posix_fadvise(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
6314 | { |
6315 | PyObject *return_value = NULL; |
6316 | int fd; |
6317 | Py_off_t offset; |
6318 | Py_off_t length; |
6319 | int advice; |
6320 | |
6321 | if (!_PyArg_CheckPositional("posix_fadvise", nargs, 4, 4)) { |
6322 | goto exit; |
6323 | } |
6324 | fd = _PyLong_AsInt(args[0]); |
6325 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (6325:9): [True: 0, False: 2]
Branch (6325:21): [True: 0, False: 0]
|
6326 | goto exit; |
6327 | } |
6328 | if (!Py_off_t_converter(args[1], &offset)) { Branch (6328:9): [True: 0, False: 2]
|
6329 | goto exit; |
6330 | } |
6331 | if (!Py_off_t_converter(args[2], &length)) { Branch (6331:9): [True: 0, False: 2]
|
6332 | goto exit; |
6333 | } |
6334 | advice = _PyLong_AsInt(args[3]); |
6335 | if (advice == -1 && PyErr_Occurred()0 ) { Branch (6335:9): [True: 0, False: 2]
Branch (6335:25): [True: 0, False: 0]
|
6336 | goto exit; |
6337 | } |
6338 | return_value = os_posix_fadvise_impl(module, fd, offset, length, advice); |
6339 | |
6340 | exit: |
6341 | return return_value; |
6342 | } |
6343 | |
6344 | #endif /* (defined(HAVE_POSIX_FADVISE) && !defined(POSIX_FADVISE_AIX_BUG)) */ |
6345 | |
6346 | #if defined(MS_WINDOWS) |
6347 | |
6348 | PyDoc_STRVAR(os_putenv__doc__, |
6349 | "putenv($module, name, value, /)\n" |
6350 | "--\n" |
6351 | "\n" |
6352 | "Change or add an environment variable."); |
6353 | |
6354 | #define OS_PUTENV_METHODDEF \ |
6355 | {"putenv", _PyCFunction_CAST(os_putenv), METH_FASTCALL, os_putenv__doc__}, |
6356 | |
6357 | static PyObject * |
6358 | os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); |
6359 | |
6360 | static PyObject * |
6361 | os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
6362 | { |
6363 | PyObject *return_value = NULL; |
6364 | PyObject *name; |
6365 | PyObject *value; |
6366 | |
6367 | if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { |
6368 | goto exit; |
6369 | } |
6370 | if (!PyUnicode_Check(args[0])) { |
6371 | _PyArg_BadArgument("putenv", "argument 1", "str", args[0]); |
6372 | goto exit; |
6373 | } |
6374 | if (PyUnicode_READY(args[0]) == -1) { |
6375 | goto exit; |
6376 | } |
6377 | name = args[0]; |
6378 | if (!PyUnicode_Check(args[1])) { |
6379 | _PyArg_BadArgument("putenv", "argument 2", "str", args[1]); |
6380 | goto exit; |
6381 | } |
6382 | if (PyUnicode_READY(args[1]) == -1) { |
6383 | goto exit; |
6384 | } |
6385 | value = args[1]; |
6386 | return_value = os_putenv_impl(module, name, value); |
6387 | |
6388 | exit: |
6389 | return return_value; |
6390 | } |
6391 | |
6392 | #endif /* defined(MS_WINDOWS) */ |
6393 | |
6394 | #if !defined(MS_WINDOWS) |
6395 | |
6396 | PyDoc_STRVAR(os_putenv__doc__, |
6397 | "putenv($module, name, value, /)\n" |
6398 | "--\n" |
6399 | "\n" |
6400 | "Change or add an environment variable."); |
6401 | |
6402 | #define OS_PUTENV_METHODDEF \ |
6403 | {"putenv", _PyCFunction_CAST(os_putenv), METH_FASTCALL, os_putenv__doc__}, |
6404 | |
6405 | static PyObject * |
6406 | os_putenv_impl(PyObject *module, PyObject *name, PyObject *value); |
6407 | |
6408 | static PyObject * |
6409 | os_putenv(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
6410 | { |
6411 | PyObject *return_value = NULL; |
6412 | PyObject *name = NULL; |
6413 | PyObject *value = NULL; |
6414 | |
6415 | if (!_PyArg_CheckPositional("putenv", nargs, 2, 2)) { |
6416 | goto exit; |
6417 | } |
6418 | if (!PyUnicode_FSConverter(args[0], &name)) { Branch (6418:9): [True: 4, False: 8.86k]
|
6419 | goto exit; |
6420 | } |
6421 | if (!PyUnicode_FSConverter(args[1], &value)) { Branch (6421:9): [True: 2, False: 8.86k]
|
6422 | goto exit; |
6423 | } |
6424 | return_value = os_putenv_impl(module, name, value); |
6425 | |
6426 | exit: |
6427 | /* Cleanup for name */ |
6428 | Py_XDECREF(name); |
6429 | /* Cleanup for value */ |
6430 | Py_XDECREF(value); |
6431 | |
6432 | return return_value; |
6433 | } |
6434 | |
6435 | #endif /* !defined(MS_WINDOWS) */ |
6436 | |
6437 | #if defined(MS_WINDOWS) |
6438 | |
6439 | PyDoc_STRVAR(os_unsetenv__doc__, |
6440 | "unsetenv($module, name, /)\n" |
6441 | "--\n" |
6442 | "\n" |
6443 | "Delete an environment variable."); |
6444 | |
6445 | #define OS_UNSETENV_METHODDEF \ |
6446 | {"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__}, |
6447 | |
6448 | static PyObject * |
6449 | os_unsetenv_impl(PyObject *module, PyObject *name); |
6450 | |
6451 | static PyObject * |
6452 | os_unsetenv(PyObject *module, PyObject *arg) |
6453 | { |
6454 | PyObject *return_value = NULL; |
6455 | PyObject *name; |
6456 | |
6457 | if (!PyUnicode_Check(arg)) { |
6458 | _PyArg_BadArgument("unsetenv", "argument", "str", arg); |
6459 | goto exit; |
6460 | } |
6461 | if (PyUnicode_READY(arg) == -1) { |
6462 | goto exit; |
6463 | } |
6464 | name = arg; |
6465 | return_value = os_unsetenv_impl(module, name); |
6466 | |
6467 | exit: |
6468 | return return_value; |
6469 | } |
6470 | |
6471 | #endif /* defined(MS_WINDOWS) */ |
6472 | |
6473 | #if !defined(MS_WINDOWS) |
6474 | |
6475 | PyDoc_STRVAR(os_unsetenv__doc__, |
6476 | "unsetenv($module, name, /)\n" |
6477 | "--\n" |
6478 | "\n" |
6479 | "Delete an environment variable."); |
6480 | |
6481 | #define OS_UNSETENV_METHODDEF \ |
6482 | {"unsetenv", (PyCFunction)os_unsetenv, METH_O, os_unsetenv__doc__}, |
6483 | |
6484 | static PyObject * |
6485 | os_unsetenv_impl(PyObject *module, PyObject *name); |
6486 | |
6487 | static PyObject * |
6488 | os_unsetenv(PyObject *module, PyObject *arg) |
6489 | { |
6490 | PyObject *return_value = NULL; |
6491 | PyObject *name = NULL; |
6492 | |
6493 | if (!PyUnicode_FSConverter(arg, &name)) { Branch (6493:9): [True: 2, False: 8.47k]
|
6494 | goto exit; |
6495 | } |
6496 | return_value = os_unsetenv_impl(module, name); |
6497 | |
6498 | exit: |
6499 | /* Cleanup for name */ |
6500 | Py_XDECREF(name); |
6501 | |
6502 | return return_value; |
6503 | } |
6504 | |
6505 | #endif /* !defined(MS_WINDOWS) */ |
6506 | |
6507 | PyDoc_STRVAR(os_strerror__doc__, |
6508 | "strerror($module, code, /)\n" |
6509 | "--\n" |
6510 | "\n" |
6511 | "Translate an error code to a message string."); |
6512 | |
6513 | #define OS_STRERROR_METHODDEF \ |
6514 | {"strerror", (PyCFunction)os_strerror, METH_O, os_strerror__doc__}, |
6515 | |
6516 | static PyObject * |
6517 | os_strerror_impl(PyObject *module, int code); |
6518 | |
6519 | static PyObject * |
6520 | os_strerror(PyObject *module, PyObject *arg) |
6521 | { |
6522 | PyObject *return_value = NULL; |
6523 | int code; |
6524 | |
6525 | code = _PyLong_AsInt(arg); |
6526 | if (code == -1 && PyErr_Occurred()1 ) { Branch (6526:9): [True: 1, False: 2.09k]
Branch (6526:23): [True: 0, False: 1]
|
6527 | goto exit; |
6528 | } |
6529 | return_value = os_strerror_impl(module, code); |
6530 | |
6531 | exit: |
6532 | return return_value; |
6533 | } |
6534 | |
6535 | #if defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) |
6536 | |
6537 | PyDoc_STRVAR(os_WCOREDUMP__doc__, |
6538 | "WCOREDUMP($module, status, /)\n" |
6539 | "--\n" |
6540 | "\n" |
6541 | "Return True if the process returning status was dumped to a core file."); |
6542 | |
6543 | #define OS_WCOREDUMP_METHODDEF \ |
6544 | {"WCOREDUMP", (PyCFunction)os_WCOREDUMP, METH_O, os_WCOREDUMP__doc__}, |
6545 | |
6546 | static int |
6547 | os_WCOREDUMP_impl(PyObject *module, int status); |
6548 | |
6549 | static PyObject * |
6550 | os_WCOREDUMP(PyObject *module, PyObject *arg) |
6551 | { |
6552 | PyObject *return_value = NULL; |
6553 | int status; |
6554 | int _return_value; |
6555 |
|
6556 | status = _PyLong_AsInt(arg); |
6557 | if (status == -1 && PyErr_Occurred()) { Branch (6557:9): [True: 0, False: 0]
Branch (6557:25): [True: 0, False: 0]
|
6558 | goto exit; |
6559 | } |
6560 | _return_value = os_WCOREDUMP_impl(module, status); |
6561 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (6561:9): [True: 0, False: 0]
Branch (6561:34): [True: 0, False: 0]
|
6562 | goto exit; |
6563 | } |
6564 | return_value = PyBool_FromLong((long)_return_value); |
6565 |
|
6566 | exit: |
6567 | return return_value; |
6568 | } |
6569 | |
6570 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WCOREDUMP) */ |
6571 | |
6572 | #if defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) |
6573 | |
6574 | PyDoc_STRVAR(os_WIFCONTINUED__doc__, |
6575 | "WIFCONTINUED($module, /, status)\n" |
6576 | "--\n" |
6577 | "\n" |
6578 | "Return True if a particular process was continued from a job control stop.\n" |
6579 | "\n" |
6580 | "Return True if the process returning status was continued from a\n" |
6581 | "job control stop."); |
6582 | |
6583 | #define OS_WIFCONTINUED_METHODDEF \ |
6584 | {"WIFCONTINUED", _PyCFunction_CAST(os_WIFCONTINUED), METH_FASTCALL|METH_KEYWORDS, os_WIFCONTINUED__doc__}, |
6585 | |
6586 | static int |
6587 | os_WIFCONTINUED_impl(PyObject *module, int status); |
6588 | |
6589 | static PyObject * |
6590 | os_WIFCONTINUED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6591 | { |
6592 | PyObject *return_value = NULL; |
6593 | static const char * const _keywords[] = {"status", NULL}; |
6594 | static _PyArg_Parser _parser = {NULL, _keywords, "WIFCONTINUED", 0}; |
6595 | PyObject *argsbuf[1]; |
6596 | int status; |
6597 | int _return_value; |
6598 |
|
6599 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6600 | if (!args) { Branch (6600:9): [True: 0, False: 0]
|
6601 | goto exit; |
6602 | } |
6603 | status = _PyLong_AsInt(args[0]); |
6604 | if (status == -1 && PyErr_Occurred()) { Branch (6604:9): [True: 0, False: 0]
Branch (6604:25): [True: 0, False: 0]
|
6605 | goto exit; |
6606 | } |
6607 | _return_value = os_WIFCONTINUED_impl(module, status); |
6608 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (6608:9): [True: 0, False: 0]
Branch (6608:34): [True: 0, False: 0]
|
6609 | goto exit; |
6610 | } |
6611 | return_value = PyBool_FromLong((long)_return_value); |
6612 |
|
6613 | exit: |
6614 | return return_value; |
6615 | } |
6616 | |
6617 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFCONTINUED) */ |
6618 | |
6619 | #if defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) |
6620 | |
6621 | PyDoc_STRVAR(os_WIFSTOPPED__doc__, |
6622 | "WIFSTOPPED($module, /, status)\n" |
6623 | "--\n" |
6624 | "\n" |
6625 | "Return True if the process returning status was stopped."); |
6626 | |
6627 | #define OS_WIFSTOPPED_METHODDEF \ |
6628 | {"WIFSTOPPED", _PyCFunction_CAST(os_WIFSTOPPED), METH_FASTCALL|METH_KEYWORDS, os_WIFSTOPPED__doc__}, |
6629 | |
6630 | static int |
6631 | os_WIFSTOPPED_impl(PyObject *module, int status); |
6632 | |
6633 | static PyObject * |
6634 | os_WIFSTOPPED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6635 | { |
6636 | PyObject *return_value = NULL; |
6637 | static const char * const _keywords[] = {"status", NULL}; |
6638 | static _PyArg_Parser _parser = {NULL, _keywords, "WIFSTOPPED", 0}; |
6639 | PyObject *argsbuf[1]; |
6640 | int status; |
6641 | int _return_value; |
6642 | |
6643 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6644 | if (!args) { Branch (6644:9): [True: 0, False: 4.17k]
|
6645 | goto exit; |
6646 | } |
6647 | status = _PyLong_AsInt(args[0]); |
6648 | if (status == -1 && PyErr_Occurred()0 ) { Branch (6648:9): [True: 0, False: 4.17k]
Branch (6648:25): [True: 0, False: 0]
|
6649 | goto exit; |
6650 | } |
6651 | _return_value = os_WIFSTOPPED_impl(module, status); |
6652 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (6652:9): [True: 0, False: 4.17k]
Branch (6652:34): [True: 0, False: 0]
|
6653 | goto exit; |
6654 | } |
6655 | return_value = PyBool_FromLong((long)_return_value); |
6656 | |
6657 | exit: |
6658 | return return_value; |
6659 | } |
6660 | |
6661 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSTOPPED) */ |
6662 | |
6663 | #if defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) |
6664 | |
6665 | PyDoc_STRVAR(os_WIFSIGNALED__doc__, |
6666 | "WIFSIGNALED($module, /, status)\n" |
6667 | "--\n" |
6668 | "\n" |
6669 | "Return True if the process returning status was terminated by a signal."); |
6670 | |
6671 | #define OS_WIFSIGNALED_METHODDEF \ |
6672 | {"WIFSIGNALED", _PyCFunction_CAST(os_WIFSIGNALED), METH_FASTCALL|METH_KEYWORDS, os_WIFSIGNALED__doc__}, |
6673 | |
6674 | static int |
6675 | os_WIFSIGNALED_impl(PyObject *module, int status); |
6676 | |
6677 | static PyObject * |
6678 | os_WIFSIGNALED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6679 | { |
6680 | PyObject *return_value = NULL; |
6681 | static const char * const _keywords[] = {"status", NULL}; |
6682 | static _PyArg_Parser _parser = {NULL, _keywords, "WIFSIGNALED", 0}; |
6683 | PyObject *argsbuf[1]; |
6684 | int status; |
6685 | int _return_value; |
6686 |
|
6687 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6688 | if (!args) { Branch (6688:9): [True: 0, False: 0]
|
6689 | goto exit; |
6690 | } |
6691 | status = _PyLong_AsInt(args[0]); |
6692 | if (status == -1 && PyErr_Occurred()) { Branch (6692:9): [True: 0, False: 0]
Branch (6692:25): [True: 0, False: 0]
|
6693 | goto exit; |
6694 | } |
6695 | _return_value = os_WIFSIGNALED_impl(module, status); |
6696 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (6696:9): [True: 0, False: 0]
Branch (6696:34): [True: 0, False: 0]
|
6697 | goto exit; |
6698 | } |
6699 | return_value = PyBool_FromLong((long)_return_value); |
6700 |
|
6701 | exit: |
6702 | return return_value; |
6703 | } |
6704 | |
6705 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFSIGNALED) */ |
6706 | |
6707 | #if defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) |
6708 | |
6709 | PyDoc_STRVAR(os_WIFEXITED__doc__, |
6710 | "WIFEXITED($module, /, status)\n" |
6711 | "--\n" |
6712 | "\n" |
6713 | "Return True if the process returning status exited via the exit() system call."); |
6714 | |
6715 | #define OS_WIFEXITED_METHODDEF \ |
6716 | {"WIFEXITED", _PyCFunction_CAST(os_WIFEXITED), METH_FASTCALL|METH_KEYWORDS, os_WIFEXITED__doc__}, |
6717 | |
6718 | static int |
6719 | os_WIFEXITED_impl(PyObject *module, int status); |
6720 | |
6721 | static PyObject * |
6722 | os_WIFEXITED(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6723 | { |
6724 | PyObject *return_value = NULL; |
6725 | static const char * const _keywords[] = {"status", NULL}; |
6726 | static _PyArg_Parser _parser = {NULL, _keywords, "WIFEXITED", 0}; |
6727 | PyObject *argsbuf[1]; |
6728 | int status; |
6729 | int _return_value; |
6730 |
|
6731 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6732 | if (!args) { Branch (6732:9): [True: 0, False: 0]
|
6733 | goto exit; |
6734 | } |
6735 | status = _PyLong_AsInt(args[0]); |
6736 | if (status == -1 && PyErr_Occurred()) { Branch (6736:9): [True: 0, False: 0]
Branch (6736:25): [True: 0, False: 0]
|
6737 | goto exit; |
6738 | } |
6739 | _return_value = os_WIFEXITED_impl(module, status); |
6740 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (6740:9): [True: 0, False: 0]
Branch (6740:34): [True: 0, False: 0]
|
6741 | goto exit; |
6742 | } |
6743 | return_value = PyBool_FromLong((long)_return_value); |
6744 |
|
6745 | exit: |
6746 | return return_value; |
6747 | } |
6748 | |
6749 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WIFEXITED) */ |
6750 | |
6751 | #if defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) |
6752 | |
6753 | PyDoc_STRVAR(os_WEXITSTATUS__doc__, |
6754 | "WEXITSTATUS($module, /, status)\n" |
6755 | "--\n" |
6756 | "\n" |
6757 | "Return the process return code from status."); |
6758 | |
6759 | #define OS_WEXITSTATUS_METHODDEF \ |
6760 | {"WEXITSTATUS", _PyCFunction_CAST(os_WEXITSTATUS), METH_FASTCALL|METH_KEYWORDS, os_WEXITSTATUS__doc__}, |
6761 | |
6762 | static int |
6763 | os_WEXITSTATUS_impl(PyObject *module, int status); |
6764 | |
6765 | static PyObject * |
6766 | os_WEXITSTATUS(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6767 | { |
6768 | PyObject *return_value = NULL; |
6769 | static const char * const _keywords[] = {"status", NULL}; |
6770 | static _PyArg_Parser _parser = {NULL, _keywords, "WEXITSTATUS", 0}; |
6771 | PyObject *argsbuf[1]; |
6772 | int status; |
6773 | int _return_value; |
6774 |
|
6775 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6776 | if (!args) { Branch (6776:9): [True: 0, False: 0]
|
6777 | goto exit; |
6778 | } |
6779 | status = _PyLong_AsInt(args[0]); |
6780 | if (status == -1 && PyErr_Occurred()) { Branch (6780:9): [True: 0, False: 0]
Branch (6780:25): [True: 0, False: 0]
|
6781 | goto exit; |
6782 | } |
6783 | _return_value = os_WEXITSTATUS_impl(module, status); |
6784 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (6784:9): [True: 0, False: 0]
Branch (6784:34): [True: 0, False: 0]
|
6785 | goto exit; |
6786 | } |
6787 | return_value = PyLong_FromLong((long)_return_value); |
6788 |
|
6789 | exit: |
6790 | return return_value; |
6791 | } |
6792 | |
6793 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WEXITSTATUS) */ |
6794 | |
6795 | #if defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) |
6796 | |
6797 | PyDoc_STRVAR(os_WTERMSIG__doc__, |
6798 | "WTERMSIG($module, /, status)\n" |
6799 | "--\n" |
6800 | "\n" |
6801 | "Return the signal that terminated the process that provided the status value."); |
6802 | |
6803 | #define OS_WTERMSIG_METHODDEF \ |
6804 | {"WTERMSIG", _PyCFunction_CAST(os_WTERMSIG), METH_FASTCALL|METH_KEYWORDS, os_WTERMSIG__doc__}, |
6805 | |
6806 | static int |
6807 | os_WTERMSIG_impl(PyObject *module, int status); |
6808 | |
6809 | static PyObject * |
6810 | os_WTERMSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6811 | { |
6812 | PyObject *return_value = NULL; |
6813 | static const char * const _keywords[] = {"status", NULL}; |
6814 | static _PyArg_Parser _parser = {NULL, _keywords, "WTERMSIG", 0}; |
6815 | PyObject *argsbuf[1]; |
6816 | int status; |
6817 | int _return_value; |
6818 |
|
6819 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6820 | if (!args) { Branch (6820:9): [True: 0, False: 0]
|
6821 | goto exit; |
6822 | } |
6823 | status = _PyLong_AsInt(args[0]); |
6824 | if (status == -1 && PyErr_Occurred()) { Branch (6824:9): [True: 0, False: 0]
Branch (6824:25): [True: 0, False: 0]
|
6825 | goto exit; |
6826 | } |
6827 | _return_value = os_WTERMSIG_impl(module, status); |
6828 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (6828:9): [True: 0, False: 0]
Branch (6828:34): [True: 0, False: 0]
|
6829 | goto exit; |
6830 | } |
6831 | return_value = PyLong_FromLong((long)_return_value); |
6832 |
|
6833 | exit: |
6834 | return return_value; |
6835 | } |
6836 | |
6837 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WTERMSIG) */ |
6838 | |
6839 | #if defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) |
6840 | |
6841 | PyDoc_STRVAR(os_WSTOPSIG__doc__, |
6842 | "WSTOPSIG($module, /, status)\n" |
6843 | "--\n" |
6844 | "\n" |
6845 | "Return the signal that stopped the process that provided the status value."); |
6846 | |
6847 | #define OS_WSTOPSIG_METHODDEF \ |
6848 | {"WSTOPSIG", _PyCFunction_CAST(os_WSTOPSIG), METH_FASTCALL|METH_KEYWORDS, os_WSTOPSIG__doc__}, |
6849 | |
6850 | static int |
6851 | os_WSTOPSIG_impl(PyObject *module, int status); |
6852 | |
6853 | static PyObject * |
6854 | os_WSTOPSIG(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6855 | { |
6856 | PyObject *return_value = NULL; |
6857 | static const char * const _keywords[] = {"status", NULL}; |
6858 | static _PyArg_Parser _parser = {NULL, _keywords, "WSTOPSIG", 0}; |
6859 | PyObject *argsbuf[1]; |
6860 | int status; |
6861 | int _return_value; |
6862 | |
6863 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6864 | if (!args) { Branch (6864:9): [True: 0, False: 1]
|
6865 | goto exit; |
6866 | } |
6867 | status = _PyLong_AsInt(args[0]); |
6868 | if (status == -1 && PyErr_Occurred()0 ) { Branch (6868:9): [True: 0, False: 1]
Branch (6868:25): [True: 0, False: 0]
|
6869 | goto exit; |
6870 | } |
6871 | _return_value = os_WSTOPSIG_impl(module, status); |
6872 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (6872:9): [True: 0, False: 1]
Branch (6872:34): [True: 0, False: 0]
|
6873 | goto exit; |
6874 | } |
6875 | return_value = PyLong_FromLong((long)_return_value); |
6876 | |
6877 | exit: |
6878 | return return_value; |
6879 | } |
6880 | |
6881 | #endif /* defined(HAVE_SYS_WAIT_H) && defined(WSTOPSIG) */ |
6882 | |
6883 | #if (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) |
6884 | |
6885 | PyDoc_STRVAR(os_fstatvfs__doc__, |
6886 | "fstatvfs($module, fd, /)\n" |
6887 | "--\n" |
6888 | "\n" |
6889 | "Perform an fstatvfs system call on the given fd.\n" |
6890 | "\n" |
6891 | "Equivalent to statvfs(fd)."); |
6892 | |
6893 | #define OS_FSTATVFS_METHODDEF \ |
6894 | {"fstatvfs", (PyCFunction)os_fstatvfs, METH_O, os_fstatvfs__doc__}, |
6895 | |
6896 | static PyObject * |
6897 | os_fstatvfs_impl(PyObject *module, int fd); |
6898 | |
6899 | static PyObject * |
6900 | os_fstatvfs(PyObject *module, PyObject *arg) |
6901 | { |
6902 | PyObject *return_value = NULL; |
6903 | int fd; |
6904 | |
6905 | fd = _PyLong_AsInt(arg); |
6906 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (6906:9): [True: 0, False: 2]
Branch (6906:21): [True: 0, False: 0]
|
6907 | goto exit; |
6908 | } |
6909 | return_value = os_fstatvfs_impl(module, fd); |
6910 | |
6911 | exit: |
6912 | return return_value; |
6913 | } |
6914 | |
6915 | #endif /* (defined(HAVE_FSTATVFS) && defined(HAVE_SYS_STATVFS_H)) */ |
6916 | |
6917 | #if (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) |
6918 | |
6919 | PyDoc_STRVAR(os_statvfs__doc__, |
6920 | "statvfs($module, /, path)\n" |
6921 | "--\n" |
6922 | "\n" |
6923 | "Perform a statvfs system call on the given path.\n" |
6924 | "\n" |
6925 | "path may always be specified as a string.\n" |
6926 | "On some platforms, path may also be specified as an open file descriptor.\n" |
6927 | " If this functionality is unavailable, using it raises an exception."); |
6928 | |
6929 | #define OS_STATVFS_METHODDEF \ |
6930 | {"statvfs", _PyCFunction_CAST(os_statvfs), METH_FASTCALL|METH_KEYWORDS, os_statvfs__doc__}, |
6931 | |
6932 | static PyObject * |
6933 | os_statvfs_impl(PyObject *module, path_t *path); |
6934 | |
6935 | static PyObject * |
6936 | os_statvfs(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6937 | { |
6938 | PyObject *return_value = NULL; |
6939 | static const char * const _keywords[] = {"path", NULL}; |
6940 | static _PyArg_Parser _parser = {NULL, _keywords, "statvfs", 0}; |
6941 | PyObject *argsbuf[1]; |
6942 | path_t path = PATH_T_INITIALIZE("statvfs", "path", 0, PATH_HAVE_FSTATVFS); |
6943 | |
6944 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6945 | if (!args) { Branch (6945:9): [True: 0, False: 103]
|
6946 | goto exit; |
6947 | } |
6948 | if (!path_converter(args[0], &path)) { Branch (6948:9): [True: 0, False: 103]
|
6949 | goto exit; |
6950 | } |
6951 | return_value = os_statvfs_impl(module, &path); |
6952 | |
6953 | exit: |
6954 | /* Cleanup for path */ |
6955 | path_cleanup(&path); |
6956 | |
6957 | return return_value; |
6958 | } |
6959 | |
6960 | #endif /* (defined(HAVE_STATVFS) && defined(HAVE_SYS_STATVFS_H)) */ |
6961 | |
6962 | #if defined(MS_WINDOWS) |
6963 | |
6964 | PyDoc_STRVAR(os__getdiskusage__doc__, |
6965 | "_getdiskusage($module, /, path)\n" |
6966 | "--\n" |
6967 | "\n" |
6968 | "Return disk usage statistics about the given path as a (total, free) tuple."); |
6969 | |
6970 | #define OS__GETDISKUSAGE_METHODDEF \ |
6971 | {"_getdiskusage", _PyCFunction_CAST(os__getdiskusage), METH_FASTCALL|METH_KEYWORDS, os__getdiskusage__doc__}, |
6972 | |
6973 | static PyObject * |
6974 | os__getdiskusage_impl(PyObject *module, path_t *path); |
6975 | |
6976 | static PyObject * |
6977 | os__getdiskusage(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
6978 | { |
6979 | PyObject *return_value = NULL; |
6980 | static const char * const _keywords[] = {"path", NULL}; |
6981 | static _PyArg_Parser _parser = {NULL, _keywords, "_getdiskusage", 0}; |
6982 | PyObject *argsbuf[1]; |
6983 | path_t path = PATH_T_INITIALIZE("_getdiskusage", "path", 0, 0); |
6984 | |
6985 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
6986 | if (!args) { |
6987 | goto exit; |
6988 | } |
6989 | if (!path_converter(args[0], &path)) { |
6990 | goto exit; |
6991 | } |
6992 | return_value = os__getdiskusage_impl(module, &path); |
6993 | |
6994 | exit: |
6995 | /* Cleanup for path */ |
6996 | path_cleanup(&path); |
6997 | |
6998 | return return_value; |
6999 | } |
7000 | |
7001 | #endif /* defined(MS_WINDOWS) */ |
7002 | |
7003 | #if defined(HAVE_FPATHCONF) |
7004 | |
7005 | PyDoc_STRVAR(os_fpathconf__doc__, |
7006 | "fpathconf($module, fd, name, /)\n" |
7007 | "--\n" |
7008 | "\n" |
7009 | "Return the configuration limit name for the file descriptor fd.\n" |
7010 | "\n" |
7011 | "If there is no limit, return -1."); |
7012 | |
7013 | #define OS_FPATHCONF_METHODDEF \ |
7014 | {"fpathconf", _PyCFunction_CAST(os_fpathconf), METH_FASTCALL, os_fpathconf__doc__}, |
7015 | |
7016 | static long |
7017 | os_fpathconf_impl(PyObject *module, int fd, int name); |
7018 | |
7019 | static PyObject * |
7020 | os_fpathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
7021 | { |
7022 | PyObject *return_value = NULL; |
7023 | int fd; |
7024 | int name; |
7025 | long _return_value; |
7026 | |
7027 | if (!_PyArg_CheckPositional("fpathconf", nargs, 2, 2)) { |
7028 | goto exit; |
7029 | } |
7030 | if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { Branch (7030:9): [True: 0, False: 1]
|
7031 | goto exit; |
7032 | } |
7033 | if (!conv_path_confname(args[1], &name)) { Branch (7033:9): [True: 0, False: 1]
|
7034 | goto exit; |
7035 | } |
7036 | _return_value = os_fpathconf_impl(module, fd, name); |
7037 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (7037:9): [True: 1, False: 0]
Branch (7037:34): [True: 1, False: 0]
|
7038 | goto exit; |
7039 | } |
7040 | return_value = PyLong_FromLong(_return_value); |
7041 |
|
7042 | exit: |
7043 | return return_value; |
7044 | } |
7045 | |
7046 | #endif /* defined(HAVE_FPATHCONF) */ |
7047 | |
7048 | #if defined(HAVE_PATHCONF) |
7049 | |
7050 | PyDoc_STRVAR(os_pathconf__doc__, |
7051 | "pathconf($module, /, path, name)\n" |
7052 | "--\n" |
7053 | "\n" |
7054 | "Return the configuration limit name for the file or directory path.\n" |
7055 | "\n" |
7056 | "If there is no limit, return -1.\n" |
7057 | "On some platforms, path may also be specified as an open file descriptor.\n" |
7058 | " If this functionality is unavailable, using it raises an exception."); |
7059 | |
7060 | #define OS_PATHCONF_METHODDEF \ |
7061 | {"pathconf", _PyCFunction_CAST(os_pathconf), METH_FASTCALL|METH_KEYWORDS, os_pathconf__doc__}, |
7062 | |
7063 | static long |
7064 | os_pathconf_impl(PyObject *module, path_t *path, int name); |
7065 | |
7066 | static PyObject * |
7067 | os_pathconf(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7068 | { |
7069 | PyObject *return_value = NULL; |
7070 | static const char * const _keywords[] = {"path", "name", NULL}; |
7071 | static _PyArg_Parser _parser = {NULL, _keywords, "pathconf", 0}; |
7072 | PyObject *argsbuf[2]; |
7073 | path_t path = PATH_T_INITIALIZE("pathconf", "path", 0, PATH_HAVE_FPATHCONF); |
7074 | int name; |
7075 | long _return_value; |
7076 | |
7077 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
7078 | if (!args) { Branch (7078:9): [True: 0, False: 1]
|
7079 | goto exit; |
7080 | } |
7081 | if (!path_converter(args[0], &path)) { Branch (7081:9): [True: 0, False: 1]
|
7082 | goto exit; |
7083 | } |
7084 | if (!conv_path_confname(args[1], &name)) { Branch (7084:9): [True: 0, False: 1]
|
7085 | goto exit; |
7086 | } |
7087 | _return_value = os_pathconf_impl(module, &path, name); |
7088 | if ((_return_value == -1) && PyErr_Occurred()) { Branch (7088:9): [True: 1, False: 0]
Branch (7088:34): [True: 1, False: 0]
|
7089 | goto exit; |
7090 | } |
7091 | return_value = PyLong_FromLong(_return_value); |
7092 |
|
7093 | exit: |
7094 | /* Cleanup for path */ |
7095 | path_cleanup(&path); |
7096 | |
7097 | return return_value; |
7098 | } |
7099 | |
7100 | #endif /* defined(HAVE_PATHCONF) */ |
7101 | |
7102 | #if defined(HAVE_CONFSTR) |
7103 | |
7104 | PyDoc_STRVAR(os_confstr__doc__, |
7105 | "confstr($module, name, /)\n" |
7106 | "--\n" |
7107 | "\n" |
7108 | "Return a string-valued system configuration variable."); |
7109 | |
7110 | #define OS_CONFSTR_METHODDEF \ |
7111 | {"confstr", (PyCFunction)os_confstr, METH_O, os_confstr__doc__}, |
7112 | |
7113 | static PyObject * |
7114 | os_confstr_impl(PyObject *module, int name); |
7115 | |
7116 | static PyObject * |
7117 | os_confstr(PyObject *module, PyObject *arg) |
7118 | { |
7119 | PyObject *return_value = NULL; |
7120 | int name; |
7121 | |
7122 | if (!conv_confstr_confname(arg, &name)) { Branch (7122:9): [True: 1, False: 10]
|
7123 | goto exit; |
7124 | } |
7125 | return_value = os_confstr_impl(module, name); |
7126 | |
7127 | exit: |
7128 | return return_value; |
7129 | } |
7130 | |
7131 | #endif /* defined(HAVE_CONFSTR) */ |
7132 | |
7133 | #if defined(HAVE_SYSCONF) |
7134 | |
7135 | PyDoc_STRVAR(os_sysconf__doc__, |
7136 | "sysconf($module, name, /)\n" |
7137 | "--\n" |
7138 | "\n" |
7139 | "Return an integer-valued system configuration variable."); |
7140 | |
7141 | #define OS_SYSCONF_METHODDEF \ |
7142 | {"sysconf", (PyCFunction)os_sysconf, METH_O, os_sysconf__doc__}, |
7143 | |
7144 | static long |
7145 | os_sysconf_impl(PyObject *module, int name); |
7146 | |
7147 | static PyObject * |
7148 | os_sysconf(PyObject *module, PyObject *arg) |
7149 | { |
7150 | PyObject *return_value = NULL; |
7151 | int name; |
7152 | long _return_value; |
7153 | |
7154 | if (!conv_sysconf_confname(arg, &name)) { Branch (7154:9): [True: 0, False: 560]
|
7155 | goto exit; |
7156 | } |
7157 | _return_value = os_sysconf_impl(module, name); |
7158 | if ((_return_value == -1) && PyErr_Occurred()558 ) { Branch (7158:9): [True: 558, False: 2]
Branch (7158:34): [True: 0, False: 558]
|
7159 | goto exit; |
7160 | } |
7161 | return_value = PyLong_FromLong(_return_value); |
7162 | |
7163 | exit: |
7164 | return return_value; |
7165 | } |
7166 | |
7167 | #endif /* defined(HAVE_SYSCONF) */ |
7168 | |
7169 | PyDoc_STRVAR(os_abort__doc__, |
7170 | "abort($module, /)\n" |
7171 | "--\n" |
7172 | "\n" |
7173 | "Abort the interpreter immediately.\n" |
7174 | "\n" |
7175 | "This function \'dumps core\' or otherwise fails in the hardest way possible\n" |
7176 | "on the hosting operating system. This function never returns."); |
7177 | |
7178 | #define OS_ABORT_METHODDEF \ |
7179 | {"abort", (PyCFunction)os_abort, METH_NOARGS, os_abort__doc__}, |
7180 | |
7181 | static PyObject * |
7182 | os_abort_impl(PyObject *module); |
7183 | |
7184 | static PyObject * |
7185 | os_abort(PyObject *module, PyObject *Py_UNUSED(ignored)) |
7186 | { |
7187 | return os_abort_impl(module); |
7188 | } |
7189 | |
7190 | #if defined(MS_WINDOWS) |
7191 | |
7192 | PyDoc_STRVAR(os_startfile__doc__, |
7193 | "startfile($module, /, filepath, operation=<unrepresentable>,\n" |
7194 | " arguments=<unrepresentable>, cwd=None, show_cmd=1)\n" |
7195 | "--\n" |
7196 | "\n" |
7197 | "Start a file with its associated application.\n" |
7198 | "\n" |
7199 | "When \"operation\" is not specified or \"open\", this acts like\n" |
7200 | "double-clicking the file in Explorer, or giving the file name as an\n" |
7201 | "argument to the DOS \"start\" command: the file is opened with whatever\n" |
7202 | "application (if any) its extension is associated.\n" |
7203 | "When another \"operation\" is given, it specifies what should be done with\n" |
7204 | "the file. A typical operation is \"print\".\n" |
7205 | "\n" |
7206 | "\"arguments\" is passed to the application, but should be omitted if the\n" |
7207 | "file is a document.\n" |
7208 | "\n" |
7209 | "\"cwd\" is the working directory for the operation. If \"filepath\" is\n" |
7210 | "relative, it will be resolved against this directory. This argument\n" |
7211 | "should usually be an absolute path.\n" |
7212 | "\n" |
7213 | "\"show_cmd\" can be used to override the recommended visibility option.\n" |
7214 | "See the Windows ShellExecute documentation for values.\n" |
7215 | "\n" |
7216 | "startfile returns as soon as the associated application is launched.\n" |
7217 | "There is no option to wait for the application to close, and no way\n" |
7218 | "to retrieve the application\'s exit status.\n" |
7219 | "\n" |
7220 | "The filepath is relative to the current directory. If you want to use\n" |
7221 | "an absolute path, make sure the first character is not a slash (\"/\");\n" |
7222 | "the underlying Win32 ShellExecute function doesn\'t work if it is."); |
7223 | |
7224 | #define OS_STARTFILE_METHODDEF \ |
7225 | {"startfile", _PyCFunction_CAST(os_startfile), METH_FASTCALL|METH_KEYWORDS, os_startfile__doc__}, |
7226 | |
7227 | static PyObject * |
7228 | os_startfile_impl(PyObject *module, path_t *filepath, |
7229 | const Py_UNICODE *operation, const Py_UNICODE *arguments, |
7230 | path_t *cwd, int show_cmd); |
7231 | |
7232 | static PyObject * |
7233 | os_startfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7234 | { |
7235 | PyObject *return_value = NULL; |
7236 | static const char * const _keywords[] = {"filepath", "operation", "arguments", "cwd", "show_cmd", NULL}; |
7237 | static _PyArg_Parser _parser = {NULL, _keywords, "startfile", 0}; |
7238 | PyObject *argsbuf[5]; |
7239 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1; |
7240 | path_t filepath = PATH_T_INITIALIZE("startfile", "filepath", 0, 0); |
7241 | const Py_UNICODE *operation = NULL; |
7242 | const Py_UNICODE *arguments = NULL; |
7243 | path_t cwd = PATH_T_INITIALIZE("startfile", "cwd", 1, 0); |
7244 | int show_cmd = 1; |
7245 | |
7246 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 5, 0, argsbuf); |
7247 | if (!args) { |
7248 | goto exit; |
7249 | } |
7250 | if (!path_converter(args[0], &filepath)) { |
7251 | goto exit; |
7252 | } |
7253 | if (!noptargs) { |
7254 | goto skip_optional_pos; |
7255 | } |
7256 | if (args[1]) { |
7257 | if (!PyUnicode_Check(args[1])) { |
7258 | _PyArg_BadArgument("startfile", "argument 'operation'", "str", args[1]); |
7259 | goto exit; |
7260 | } |
7261 | operation = PyUnicode_AsWideCharString(args[1], NULL); |
7262 | if (operation == NULL) { |
7263 | goto exit; |
7264 | } |
7265 | if (!--noptargs) { |
7266 | goto skip_optional_pos; |
7267 | } |
7268 | } |
7269 | if (args[2]) { |
7270 | if (!PyUnicode_Check(args[2])) { |
7271 | _PyArg_BadArgument("startfile", "argument 'arguments'", "str", args[2]); |
7272 | goto exit; |
7273 | } |
7274 | arguments = PyUnicode_AsWideCharString(args[2], NULL); |
7275 | if (arguments == NULL) { |
7276 | goto exit; |
7277 | } |
7278 | if (!--noptargs) { |
7279 | goto skip_optional_pos; |
7280 | } |
7281 | } |
7282 | if (args[3]) { |
7283 | if (!path_converter(args[3], &cwd)) { |
7284 | goto exit; |
7285 | } |
7286 | if (!--noptargs) { |
7287 | goto skip_optional_pos; |
7288 | } |
7289 | } |
7290 | show_cmd = _PyLong_AsInt(args[4]); |
7291 | if (show_cmd == -1 && PyErr_Occurred()) { |
7292 | goto exit; |
7293 | } |
7294 | skip_optional_pos: |
7295 | return_value = os_startfile_impl(module, &filepath, operation, arguments, &cwd, show_cmd); |
7296 | |
7297 | exit: |
7298 | /* Cleanup for filepath */ |
7299 | path_cleanup(&filepath); |
7300 | /* Cleanup for operation */ |
7301 | PyMem_Free((void *)operation); |
7302 | /* Cleanup for arguments */ |
7303 | PyMem_Free((void *)arguments); |
7304 | /* Cleanup for cwd */ |
7305 | path_cleanup(&cwd); |
7306 | |
7307 | return return_value; |
7308 | } |
7309 | |
7310 | #endif /* defined(MS_WINDOWS) */ |
7311 | |
7312 | #if defined(HAVE_GETLOADAVG) |
7313 | |
7314 | PyDoc_STRVAR(os_getloadavg__doc__, |
7315 | "getloadavg($module, /)\n" |
7316 | "--\n" |
7317 | "\n" |
7318 | "Return average recent system load information.\n" |
7319 | "\n" |
7320 | "Return the number of processes in the system run queue averaged over\n" |
7321 | "the last 1, 5, and 15 minutes as a tuple of three floats.\n" |
7322 | "Raises OSError if the load average was unobtainable."); |
7323 | |
7324 | #define OS_GETLOADAVG_METHODDEF \ |
7325 | {"getloadavg", (PyCFunction)os_getloadavg, METH_NOARGS, os_getloadavg__doc__}, |
7326 | |
7327 | static PyObject * |
7328 | os_getloadavg_impl(PyObject *module); |
7329 | |
7330 | static PyObject * |
7331 | os_getloadavg(PyObject *module, PyObject *Py_UNUSED(ignored)) |
7332 | { |
7333 | return os_getloadavg_impl(module); |
7334 | } |
7335 | |
7336 | #endif /* defined(HAVE_GETLOADAVG) */ |
7337 | |
7338 | PyDoc_STRVAR(os_device_encoding__doc__, |
7339 | "device_encoding($module, /, fd)\n" |
7340 | "--\n" |
7341 | "\n" |
7342 | "Return a string describing the encoding of a terminal\'s file descriptor.\n" |
7343 | "\n" |
7344 | "The file descriptor must be attached to a terminal.\n" |
7345 | "If the device is not a terminal, return None."); |
7346 | |
7347 | #define OS_DEVICE_ENCODING_METHODDEF \ |
7348 | {"device_encoding", _PyCFunction_CAST(os_device_encoding), METH_FASTCALL|METH_KEYWORDS, os_device_encoding__doc__}, |
7349 | |
7350 | static PyObject * |
7351 | os_device_encoding_impl(PyObject *module, int fd); |
7352 | |
7353 | static PyObject * |
7354 | os_device_encoding(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7355 | { |
7356 | PyObject *return_value = NULL; |
7357 | static const char * const _keywords[] = {"fd", NULL}; |
7358 | static _PyArg_Parser _parser = {NULL, _keywords, "device_encoding", 0}; |
7359 | PyObject *argsbuf[1]; |
7360 | int fd; |
7361 | |
7362 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
7363 | if (!args) { Branch (7363:9): [True: 0, False: 2]
|
7364 | goto exit; |
7365 | } |
7366 | fd = _PyLong_AsInt(args[0]); |
7367 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (7367:9): [True: 0, False: 2]
Branch (7367:21): [True: 0, False: 0]
|
7368 | goto exit; |
7369 | } |
7370 | return_value = os_device_encoding_impl(module, fd); |
7371 | |
7372 | exit: |
7373 | return return_value; |
7374 | } |
7375 | |
7376 | #if defined(HAVE_SETRESUID) |
7377 | |
7378 | PyDoc_STRVAR(os_setresuid__doc__, |
7379 | "setresuid($module, ruid, euid, suid, /)\n" |
7380 | "--\n" |
7381 | "\n" |
7382 | "Set the current process\'s real, effective, and saved user ids."); |
7383 | |
7384 | #define OS_SETRESUID_METHODDEF \ |
7385 | {"setresuid", _PyCFunction_CAST(os_setresuid), METH_FASTCALL, os_setresuid__doc__}, |
7386 | |
7387 | static PyObject * |
7388 | os_setresuid_impl(PyObject *module, uid_t ruid, uid_t euid, uid_t suid); |
7389 | |
7390 | static PyObject * |
7391 | os_setresuid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
7392 | { |
7393 | PyObject *return_value = NULL; |
7394 | uid_t ruid; |
7395 | uid_t euid; |
7396 | uid_t suid; |
7397 | |
7398 | if (!_PyArg_CheckPositional("setresuid", nargs, 3, 3)) { |
7399 | goto exit; |
7400 | } |
7401 | if (!_Py_Uid_Converter(args[0], &ruid)) { Branch (7401:9): [True: 0, False: 3]
|
7402 | goto exit; |
7403 | } |
7404 | if (!_Py_Uid_Converter(args[1], &euid)) { Branch (7404:9): [True: 0, False: 3]
|
7405 | goto exit; |
7406 | } |
7407 | if (!_Py_Uid_Converter(args[2], &suid)) { Branch (7407:9): [True: 0, False: 3]
|
7408 | goto exit; |
7409 | } |
7410 | return_value = os_setresuid_impl(module, ruid, euid, suid); |
7411 | |
7412 | exit: |
7413 | return return_value; |
7414 | } |
7415 | |
7416 | #endif /* defined(HAVE_SETRESUID) */ |
7417 | |
7418 | #if defined(HAVE_SETRESGID) |
7419 | |
7420 | PyDoc_STRVAR(os_setresgid__doc__, |
7421 | "setresgid($module, rgid, egid, sgid, /)\n" |
7422 | "--\n" |
7423 | "\n" |
7424 | "Set the current process\'s real, effective, and saved group ids."); |
7425 | |
7426 | #define OS_SETRESGID_METHODDEF \ |
7427 | {"setresgid", _PyCFunction_CAST(os_setresgid), METH_FASTCALL, os_setresgid__doc__}, |
7428 | |
7429 | static PyObject * |
7430 | os_setresgid_impl(PyObject *module, gid_t rgid, gid_t egid, gid_t sgid); |
7431 | |
7432 | static PyObject * |
7433 | os_setresgid(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
7434 | { |
7435 | PyObject *return_value = NULL; |
7436 | gid_t rgid; |
7437 | gid_t egid; |
7438 | gid_t sgid; |
7439 | |
7440 | if (!_PyArg_CheckPositional("setresgid", nargs, 3, 3)) { |
7441 | goto exit; |
7442 | } |
7443 | if (!_Py_Gid_Converter(args[0], &rgid)) { Branch (7443:9): [True: 0, False: 3]
|
7444 | goto exit; |
7445 | } |
7446 | if (!_Py_Gid_Converter(args[1], &egid)) { Branch (7446:9): [True: 0, False: 3]
|
7447 | goto exit; |
7448 | } |
7449 | if (!_Py_Gid_Converter(args[2], &sgid)) { Branch (7449:9): [True: 0, False: 3]
|
7450 | goto exit; |
7451 | } |
7452 | return_value = os_setresgid_impl(module, rgid, egid, sgid); |
7453 | |
7454 | exit: |
7455 | return return_value; |
7456 | } |
7457 | |
7458 | #endif /* defined(HAVE_SETRESGID) */ |
7459 | |
7460 | #if defined(HAVE_GETRESUID) |
7461 | |
7462 | PyDoc_STRVAR(os_getresuid__doc__, |
7463 | "getresuid($module, /)\n" |
7464 | "--\n" |
7465 | "\n" |
7466 | "Return a tuple of the current process\'s real, effective, and saved user ids."); |
7467 | |
7468 | #define OS_GETRESUID_METHODDEF \ |
7469 | {"getresuid", (PyCFunction)os_getresuid, METH_NOARGS, os_getresuid__doc__}, |
7470 | |
7471 | static PyObject * |
7472 | os_getresuid_impl(PyObject *module); |
7473 | |
7474 | static PyObject * |
7475 | os_getresuid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
7476 | { |
7477 | return os_getresuid_impl(module); |
7478 | } |
7479 | |
7480 | #endif /* defined(HAVE_GETRESUID) */ |
7481 | |
7482 | #if defined(HAVE_GETRESGID) |
7483 | |
7484 | PyDoc_STRVAR(os_getresgid__doc__, |
7485 | "getresgid($module, /)\n" |
7486 | "--\n" |
7487 | "\n" |
7488 | "Return a tuple of the current process\'s real, effective, and saved group ids."); |
7489 | |
7490 | #define OS_GETRESGID_METHODDEF \ |
7491 | {"getresgid", (PyCFunction)os_getresgid, METH_NOARGS, os_getresgid__doc__}, |
7492 | |
7493 | static PyObject * |
7494 | os_getresgid_impl(PyObject *module); |
7495 | |
7496 | static PyObject * |
7497 | os_getresgid(PyObject *module, PyObject *Py_UNUSED(ignored)) |
7498 | { |
7499 | return os_getresgid_impl(module); |
7500 | } |
7501 | |
7502 | #endif /* defined(HAVE_GETRESGID) */ |
7503 | |
7504 | #if defined(USE_XATTRS) |
7505 | |
7506 | PyDoc_STRVAR(os_getxattr__doc__, |
7507 | "getxattr($module, /, path, attribute, *, follow_symlinks=True)\n" |
7508 | "--\n" |
7509 | "\n" |
7510 | "Return the value of extended attribute attribute on path.\n" |
7511 | "\n" |
7512 | "path may be either a string, a path-like object, or an open file descriptor.\n" |
7513 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
7514 | " link, getxattr will examine the symbolic link itself instead of the file\n" |
7515 | " the link points to."); |
7516 | |
7517 | #define OS_GETXATTR_METHODDEF \ |
7518 | {"getxattr", _PyCFunction_CAST(os_getxattr), METH_FASTCALL|METH_KEYWORDS, os_getxattr__doc__}, |
7519 | |
7520 | static PyObject * |
7521 | os_getxattr_impl(PyObject *module, path_t *path, path_t *attribute, |
7522 | int follow_symlinks); |
7523 | |
7524 | static PyObject * |
7525 | os_getxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7526 | { |
7527 | PyObject *return_value = NULL; |
7528 | static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; |
7529 | static _PyArg_Parser _parser = {NULL, _keywords, "getxattr", 0}; |
7530 | PyObject *argsbuf[3]; |
7531 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE12 (kwnames) : 029 ) - 2; Branch (7531:36): [True: 12, False: 29]
|
7532 | path_t path = PATH_T_INITIALIZE("getxattr", "path", 0, 1); |
7533 | path_t attribute = PATH_T_INITIALIZE("getxattr", "attribute", 0, 0); |
7534 | int follow_symlinks = 1; |
7535 | |
7536 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
7537 | if (!args) { Branch (7537:9): [True: 0, False: 41]
|
7538 | goto exit; |
7539 | } |
7540 | if (!path_converter(args[0], &path)) { Branch (7540:9): [True: 0, False: 41]
|
7541 | goto exit; |
7542 | } |
7543 | if (!path_converter(args[1], &attribute)) { Branch (7543:9): [True: 0, False: 41]
|
7544 | goto exit; |
7545 | } |
7546 | if (!noptargs) { Branch (7546:9): [True: 29, False: 12]
|
7547 | goto skip_optional_kwonly; |
7548 | } |
7549 | follow_symlinks = PyObject_IsTrue(args[2]); |
7550 | if (follow_symlinks < 0) { Branch (7550:9): [True: 0, False: 12]
|
7551 | goto exit; |
7552 | } |
7553 | skip_optional_kwonly: |
7554 | return_value = os_getxattr_impl(module, &path, &attribute, follow_symlinks); |
7555 | |
7556 | exit: |
7557 | /* Cleanup for path */ |
7558 | path_cleanup(&path); |
7559 | /* Cleanup for attribute */ |
7560 | path_cleanup(&attribute); |
7561 | |
7562 | return return_value; |
7563 | } |
7564 | |
7565 | #endif /* defined(USE_XATTRS) */ |
7566 | |
7567 | #if defined(USE_XATTRS) |
7568 | |
7569 | PyDoc_STRVAR(os_setxattr__doc__, |
7570 | "setxattr($module, /, path, attribute, value, flags=0, *,\n" |
7571 | " follow_symlinks=True)\n" |
7572 | "--\n" |
7573 | "\n" |
7574 | "Set extended attribute attribute on path to value.\n" |
7575 | "\n" |
7576 | "path may be either a string, a path-like object, or an open file descriptor.\n" |
7577 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
7578 | " link, setxattr will modify the symbolic link itself instead of the file\n" |
7579 | " the link points to."); |
7580 | |
7581 | #define OS_SETXATTR_METHODDEF \ |
7582 | {"setxattr", _PyCFunction_CAST(os_setxattr), METH_FASTCALL|METH_KEYWORDS, os_setxattr__doc__}, |
7583 | |
7584 | static PyObject * |
7585 | os_setxattr_impl(PyObject *module, path_t *path, path_t *attribute, |
7586 | Py_buffer *value, int flags, int follow_symlinks); |
7587 | |
7588 | static PyObject * |
7589 | os_setxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7590 | { |
7591 | PyObject *return_value = NULL; |
7592 | static const char * const _keywords[] = {"path", "attribute", "value", "flags", "follow_symlinks", NULL}; |
7593 | static _PyArg_Parser _parser = {NULL, _keywords, "setxattr", 0}; |
7594 | PyObject *argsbuf[5]; |
7595 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE212 (kwnames) : 0433 ) - 3; Branch (7595:36): [True: 212, False: 433]
|
7596 | path_t path = PATH_T_INITIALIZE("setxattr", "path", 0, 1); |
7597 | path_t attribute = PATH_T_INITIALIZE("setxattr", "attribute", 0, 0); |
7598 | Py_buffer value = {NULL, NULL}; |
7599 | int flags = 0; |
7600 | int follow_symlinks = 1; |
7601 | |
7602 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 4, 0, argsbuf); |
7603 | if (!args) { Branch (7603:9): [True: 0, False: 645]
|
7604 | goto exit; |
7605 | } |
7606 | if (!path_converter(args[0], &path)) { Branch (7606:9): [True: 0, False: 645]
|
7607 | goto exit; |
7608 | } |
7609 | if (!path_converter(args[1], &attribute)) { Branch (7609:9): [True: 0, False: 645]
|
7610 | goto exit; |
7611 | } |
7612 | if (PyObject_GetBuffer(args[2], &value, PyBUF_SIMPLE) != 0) { Branch (7612:9): [True: 0, False: 645]
|
7613 | goto exit; |
7614 | } |
7615 | if (!PyBuffer_IsContiguous(&value, 'C')) { Branch (7615:9): [True: 0, False: 645]
|
7616 | _PyArg_BadArgument("setxattr", "argument 'value'", "contiguous buffer", args[2]); |
7617 | goto exit; |
7618 | } |
7619 | if (!noptargs) { Branch (7619:9): [True: 417, False: 228]
|
7620 | goto skip_optional_pos; |
7621 | } |
7622 | if (args[3]) { Branch (7622:9): [True: 24, False: 204]
|
7623 | flags = _PyLong_AsInt(args[3]); |
7624 | if (flags == -1 && PyErr_Occurred()0 ) { Branch (7624:13): [True: 0, False: 24]
Branch (7624:28): [True: 0, False: 0]
|
7625 | goto exit; |
7626 | } |
7627 | if (!--noptargs) { Branch (7627:13): [True: 16, False: 8]
|
7628 | goto skip_optional_pos; |
7629 | } |
7630 | } |
7631 | skip_optional_pos: |
7632 | if (!noptargs) { Branch (7632:9): [True: 433, False: 212]
|
7633 | goto skip_optional_kwonly; |
7634 | } |
7635 | follow_symlinks = PyObject_IsTrue(args[4]); |
7636 | if (follow_symlinks < 0) { Branch (7636:9): [True: 0, False: 212]
|
7637 | goto exit; |
7638 | } |
7639 | skip_optional_kwonly: |
7640 | return_value = os_setxattr_impl(module, &path, &attribute, &value, flags, follow_symlinks); |
7641 | |
7642 | exit: |
7643 | /* Cleanup for path */ |
7644 | path_cleanup(&path); |
7645 | /* Cleanup for attribute */ |
7646 | path_cleanup(&attribute); |
7647 | /* Cleanup for value */ |
7648 | if (value.obj) { Branch (7648:9): [True: 645, False: 0]
|
7649 | PyBuffer_Release(&value); |
7650 | } |
7651 | |
7652 | return return_value; |
7653 | } |
7654 | |
7655 | #endif /* defined(USE_XATTRS) */ |
7656 | |
7657 | #if defined(USE_XATTRS) |
7658 | |
7659 | PyDoc_STRVAR(os_removexattr__doc__, |
7660 | "removexattr($module, /, path, attribute, *, follow_symlinks=True)\n" |
7661 | "--\n" |
7662 | "\n" |
7663 | "Remove extended attribute attribute on path.\n" |
7664 | "\n" |
7665 | "path may be either a string, a path-like object, or an open file descriptor.\n" |
7666 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
7667 | " link, removexattr will modify the symbolic link itself instead of the file\n" |
7668 | " the link points to."); |
7669 | |
7670 | #define OS_REMOVEXATTR_METHODDEF \ |
7671 | {"removexattr", _PyCFunction_CAST(os_removexattr), METH_FASTCALL|METH_KEYWORDS, os_removexattr__doc__}, |
7672 | |
7673 | static PyObject * |
7674 | os_removexattr_impl(PyObject *module, path_t *path, path_t *attribute, |
7675 | int follow_symlinks); |
7676 | |
7677 | static PyObject * |
7678 | os_removexattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7679 | { |
7680 | PyObject *return_value = NULL; |
7681 | static const char * const _keywords[] = {"path", "attribute", "follow_symlinks", NULL}; |
7682 | static _PyArg_Parser _parser = {NULL, _keywords, "removexattr", 0}; |
7683 | PyObject *argsbuf[3]; |
7684 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE4 (kwnames) : 013 ) - 2; Branch (7684:36): [True: 4, False: 13]
|
7685 | path_t path = PATH_T_INITIALIZE("removexattr", "path", 0, 1); |
7686 | path_t attribute = PATH_T_INITIALIZE("removexattr", "attribute", 0, 0); |
7687 | int follow_symlinks = 1; |
7688 | |
7689 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
7690 | if (!args) { Branch (7690:9): [True: 0, False: 17]
|
7691 | goto exit; |
7692 | } |
7693 | if (!path_converter(args[0], &path)) { Branch (7693:9): [True: 0, False: 17]
|
7694 | goto exit; |
7695 | } |
7696 | if (!path_converter(args[1], &attribute)) { Branch (7696:9): [True: 0, False: 17]
|
7697 | goto exit; |
7698 | } |
7699 | if (!noptargs) { Branch (7699:9): [True: 13, False: 4]
|
7700 | goto skip_optional_kwonly; |
7701 | } |
7702 | follow_symlinks = PyObject_IsTrue(args[2]); |
7703 | if (follow_symlinks < 0) { Branch (7703:9): [True: 0, False: 4]
|
7704 | goto exit; |
7705 | } |
7706 | skip_optional_kwonly: |
7707 | return_value = os_removexattr_impl(module, &path, &attribute, follow_symlinks); |
7708 | |
7709 | exit: |
7710 | /* Cleanup for path */ |
7711 | path_cleanup(&path); |
7712 | /* Cleanup for attribute */ |
7713 | path_cleanup(&attribute); |
7714 | |
7715 | return return_value; |
7716 | } |
7717 | |
7718 | #endif /* defined(USE_XATTRS) */ |
7719 | |
7720 | #if defined(USE_XATTRS) |
7721 | |
7722 | PyDoc_STRVAR(os_listxattr__doc__, |
7723 | "listxattr($module, /, path=None, *, follow_symlinks=True)\n" |
7724 | "--\n" |
7725 | "\n" |
7726 | "Return a list of extended attributes on path.\n" |
7727 | "\n" |
7728 | "path may be either None, a string, a path-like object, or an open file descriptor.\n" |
7729 | "if path is None, listxattr will examine the current directory.\n" |
7730 | "If follow_symlinks is False, and the last element of the path is a symbolic\n" |
7731 | " link, listxattr will examine the symbolic link itself instead of the file\n" |
7732 | " the link points to."); |
7733 | |
7734 | #define OS_LISTXATTR_METHODDEF \ |
7735 | {"listxattr", _PyCFunction_CAST(os_listxattr), METH_FASTCALL|METH_KEYWORDS, os_listxattr__doc__}, |
7736 | |
7737 | static PyObject * |
7738 | os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks); |
7739 | |
7740 | static PyObject * |
7741 | os_listxattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7742 | { |
7743 | PyObject *return_value = NULL; |
7744 | static const char * const _keywords[] = {"path", "follow_symlinks", NULL}; |
7745 | static _PyArg_Parser _parser = {NULL, _keywords, "listxattr", 0}; |
7746 | PyObject *argsbuf[2]; |
7747 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE8.62k (kwnames) : 035 ) - 0; Branch (7747:36): [True: 8.62k, False: 35]
|
7748 | path_t path = PATH_T_INITIALIZE("listxattr", "path", 1, 1); |
7749 | int follow_symlinks = 1; |
7750 | |
7751 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
7752 | if (!args) { Branch (7752:9): [True: 0, False: 8.66k]
|
7753 | goto exit; |
7754 | } |
7755 | if (!noptargs) { Branch (7755:9): [True: 0, False: 8.66k]
|
7756 | goto skip_optional_pos; |
7757 | } |
7758 | if (args[0]) { Branch (7758:9): [True: 8.66k, False: 0]
|
7759 | if (!path_converter(args[0], &path)) { Branch (7759:13): [True: 0, False: 8.66k]
|
7760 | goto exit; |
7761 | } |
7762 | if (!--noptargs) { Branch (7762:13): [True: 35, False: 8.62k]
|
7763 | goto skip_optional_pos; |
7764 | } |
7765 | } |
7766 | skip_optional_pos: |
7767 | if (!noptargs) { Branch (7767:9): [True: 35, False: 8.62k]
|
7768 | goto skip_optional_kwonly; |
7769 | } |
7770 | follow_symlinks = PyObject_IsTrue(args[1]); |
7771 | if (follow_symlinks < 0) { Branch (7771:9): [True: 0, False: 8.62k]
|
7772 | goto exit; |
7773 | } |
7774 | skip_optional_kwonly: |
7775 | return_value = os_listxattr_impl(module, &path, follow_symlinks); |
7776 | |
7777 | exit: |
7778 | /* Cleanup for path */ |
7779 | path_cleanup(&path); |
7780 | |
7781 | return return_value; |
7782 | } |
7783 | |
7784 | #endif /* defined(USE_XATTRS) */ |
7785 | |
7786 | PyDoc_STRVAR(os_urandom__doc__, |
7787 | "urandom($module, size, /)\n" |
7788 | "--\n" |
7789 | "\n" |
7790 | "Return a bytes object containing random bytes suitable for cryptographic use."); |
7791 | |
7792 | #define OS_URANDOM_METHODDEF \ |
7793 | {"urandom", (PyCFunction)os_urandom, METH_O, os_urandom__doc__}, |
7794 | |
7795 | static PyObject * |
7796 | os_urandom_impl(PyObject *module, Py_ssize_t size); |
7797 | |
7798 | static PyObject * |
7799 | os_urandom(PyObject *module, PyObject *arg) |
7800 | { |
7801 | PyObject *return_value = NULL; |
7802 | Py_ssize_t size; |
7803 | |
7804 | { |
7805 | Py_ssize_t ival = -1; |
7806 | PyObject *iobj = _PyNumber_Index(arg); |
7807 | if (iobj != NULL) { Branch (7807:13): [True: 166k, False: 2]
|
7808 | ival = PyLong_AsSsize_t(iobj); |
7809 | Py_DECREF(iobj); |
7810 | } |
7811 | if (ival == -1 && PyErr_Occurred()3 ) { Branch (7811:13): [True: 3, False: 166k]
Branch (7811:27): [True: 2, False: 1]
|
7812 | goto exit; |
7813 | } |
7814 | size = ival; |
7815 | } |
7816 | return_value = os_urandom_impl(module, size); |
7817 | |
7818 | exit: |
7819 | return return_value; |
7820 | } |
7821 | |
7822 | #if defined(HAVE_MEMFD_CREATE) |
7823 | |
7824 | PyDoc_STRVAR(os_memfd_create__doc__, |
7825 | "memfd_create($module, /, name, flags=MFD_CLOEXEC)\n" |
7826 | "--\n" |
7827 | "\n"); |
7828 | |
7829 | #define OS_MEMFD_CREATE_METHODDEF \ |
7830 | {"memfd_create", _PyCFunction_CAST(os_memfd_create), METH_FASTCALL|METH_KEYWORDS, os_memfd_create__doc__}, |
7831 | |
7832 | static PyObject * |
7833 | os_memfd_create_impl(PyObject *module, PyObject *name, unsigned int flags); |
7834 | |
7835 | static PyObject * |
7836 | os_memfd_create(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7837 | { |
7838 | PyObject *return_value = NULL; |
7839 | static const char * const _keywords[] = {"name", "flags", NULL}; |
7840 | static _PyArg_Parser _parser = {NULL, _keywords, "memfd_create", 0}; |
7841 | PyObject *argsbuf[2]; |
7842 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 1; Branch (7842:36): [True: 0, False: 2]
|
7843 | PyObject *name = NULL; |
7844 | unsigned int flags = MFD_CLOEXEC; |
7845 | |
7846 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
7847 | if (!args) { Branch (7847:9): [True: 0, False: 2]
|
7848 | goto exit; |
7849 | } |
7850 | if (!PyUnicode_FSConverter(args[0], &name)) { Branch (7850:9): [True: 0, False: 2]
|
7851 | goto exit; |
7852 | } |
7853 | if (!noptargs) { Branch (7853:9): [True: 1, False: 1]
|
7854 | goto skip_optional_pos; |
7855 | } |
7856 | flags = (unsigned int)PyLong_AsUnsignedLongMask(args[1]); |
7857 | if (flags == (unsigned int)-1 && PyErr_Occurred()0 ) { Branch (7857:9): [True: 0, False: 1]
Branch (7857:38): [True: 0, False: 0]
|
7858 | goto exit; |
7859 | } |
7860 | skip_optional_pos: |
7861 | return_value = os_memfd_create_impl(module, name, flags); |
7862 | |
7863 | exit: |
7864 | /* Cleanup for name */ |
7865 | Py_XDECREF(name); |
7866 | |
7867 | return return_value; |
7868 | } |
7869 | |
7870 | #endif /* defined(HAVE_MEMFD_CREATE) */ |
7871 | |
7872 | #if defined(HAVE_EVENTFD) |
7873 | |
7874 | PyDoc_STRVAR(os_eventfd__doc__, |
7875 | "eventfd($module, /, initval, flags=EFD_CLOEXEC)\n" |
7876 | "--\n" |
7877 | "\n" |
7878 | "Creates and returns an event notification file descriptor."); |
7879 | |
7880 | #define OS_EVENTFD_METHODDEF \ |
7881 | {"eventfd", _PyCFunction_CAST(os_eventfd), METH_FASTCALL|METH_KEYWORDS, os_eventfd__doc__}, |
7882 | |
7883 | static PyObject * |
7884 | os_eventfd_impl(PyObject *module, unsigned int initval, int flags); |
7885 | |
7886 | static PyObject * |
7887 | os_eventfd(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7888 | { |
7889 | PyObject *return_value = NULL; |
7890 | static const char * const _keywords[] = {"initval", "flags", NULL}; |
7891 | static _PyArg_Parser _parser = {NULL, _keywords, "eventfd", 0}; |
7892 | PyObject *argsbuf[2]; |
7893 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 1; Branch (7893:36): [True: 0, False: 3]
|
7894 | unsigned int initval; |
7895 | int flags = EFD_CLOEXEC; |
7896 | |
7897 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
7898 | if (!args) { Branch (7898:9): [True: 0, False: 3]
|
7899 | goto exit; |
7900 | } |
7901 | if (!_PyLong_UnsignedInt_Converter(args[0], &initval)) { Branch (7901:9): [True: 0, False: 3]
|
7902 | goto exit; |
7903 | } |
7904 | if (!noptargs) { Branch (7904:9): [True: 1, False: 2]
|
7905 | goto skip_optional_pos; |
7906 | } |
7907 | flags = _PyLong_AsInt(args[1]); |
7908 | if (flags == -1 && PyErr_Occurred()0 ) { Branch (7908:9): [True: 0, False: 2]
Branch (7908:24): [True: 0, False: 0]
|
7909 | goto exit; |
7910 | } |
7911 | skip_optional_pos: |
7912 | return_value = os_eventfd_impl(module, initval, flags); |
7913 | |
7914 | exit: |
7915 | return return_value; |
7916 | } |
7917 | |
7918 | #endif /* defined(HAVE_EVENTFD) */ |
7919 | |
7920 | #if defined(HAVE_EVENTFD) |
7921 | |
7922 | PyDoc_STRVAR(os_eventfd_read__doc__, |
7923 | "eventfd_read($module, /, fd)\n" |
7924 | "--\n" |
7925 | "\n" |
7926 | "Read eventfd value"); |
7927 | |
7928 | #define OS_EVENTFD_READ_METHODDEF \ |
7929 | {"eventfd_read", _PyCFunction_CAST(os_eventfd_read), METH_FASTCALL|METH_KEYWORDS, os_eventfd_read__doc__}, |
7930 | |
7931 | static PyObject * |
7932 | os_eventfd_read_impl(PyObject *module, int fd); |
7933 | |
7934 | static PyObject * |
7935 | os_eventfd_read(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7936 | { |
7937 | PyObject *return_value = NULL; |
7938 | static const char * const _keywords[] = {"fd", NULL}; |
7939 | static _PyArg_Parser _parser = {NULL, _keywords, "eventfd_read", 0}; |
7940 | PyObject *argsbuf[1]; |
7941 | int fd; |
7942 | |
7943 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
7944 | if (!args) { Branch (7944:9): [True: 0, False: 8]
|
7945 | goto exit; |
7946 | } |
7947 | if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { Branch (7947:9): [True: 0, False: 8]
|
7948 | goto exit; |
7949 | } |
7950 | return_value = os_eventfd_read_impl(module, fd); |
7951 | |
7952 | exit: |
7953 | return return_value; |
7954 | } |
7955 | |
7956 | #endif /* defined(HAVE_EVENTFD) */ |
7957 | |
7958 | #if defined(HAVE_EVENTFD) |
7959 | |
7960 | PyDoc_STRVAR(os_eventfd_write__doc__, |
7961 | "eventfd_write($module, /, fd, value)\n" |
7962 | "--\n" |
7963 | "\n" |
7964 | "Write eventfd value."); |
7965 | |
7966 | #define OS_EVENTFD_WRITE_METHODDEF \ |
7967 | {"eventfd_write", _PyCFunction_CAST(os_eventfd_write), METH_FASTCALL|METH_KEYWORDS, os_eventfd_write__doc__}, |
7968 | |
7969 | static PyObject * |
7970 | os_eventfd_write_impl(PyObject *module, int fd, unsigned long long value); |
7971 | |
7972 | static PyObject * |
7973 | os_eventfd_write(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
7974 | { |
7975 | PyObject *return_value = NULL; |
7976 | static const char * const _keywords[] = {"fd", "value", NULL}; |
7977 | static _PyArg_Parser _parser = {NULL, _keywords, "eventfd_write", 0}; |
7978 | PyObject *argsbuf[2]; |
7979 | int fd; |
7980 | unsigned long long value; |
7981 | |
7982 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
7983 | if (!args) { Branch (7983:9): [True: 0, False: 5]
|
7984 | goto exit; |
7985 | } |
7986 | if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) { Branch (7986:9): [True: 0, False: 5]
|
7987 | goto exit; |
7988 | } |
7989 | if (!_PyLong_UnsignedLongLong_Converter(args[1], &value)) { Branch (7989:9): [True: 0, False: 5]
|
7990 | goto exit; |
7991 | } |
7992 | return_value = os_eventfd_write_impl(module, fd, value); |
7993 | |
7994 | exit: |
7995 | return return_value; |
7996 | } |
7997 | |
7998 | #endif /* defined(HAVE_EVENTFD) */ |
7999 | |
8000 | #if (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) |
8001 | |
8002 | PyDoc_STRVAR(os_get_terminal_size__doc__, |
8003 | "get_terminal_size($module, fd=<unrepresentable>, /)\n" |
8004 | "--\n" |
8005 | "\n" |
8006 | "Return the size of the terminal window as (columns, lines).\n" |
8007 | "\n" |
8008 | "The optional argument fd (default standard output) specifies\n" |
8009 | "which file descriptor should be queried.\n" |
8010 | "\n" |
8011 | "If the file descriptor is not connected to a terminal, an OSError\n" |
8012 | "is thrown.\n" |
8013 | "\n" |
8014 | "This function will only be defined if an implementation is\n" |
8015 | "available for this system.\n" |
8016 | "\n" |
8017 | "shutil.get_terminal_size is the high-level function which should\n" |
8018 | "normally be used, os.get_terminal_size is the low-level implementation."); |
8019 | |
8020 | #define OS_GET_TERMINAL_SIZE_METHODDEF \ |
8021 | {"get_terminal_size", _PyCFunction_CAST(os_get_terminal_size), METH_FASTCALL, os_get_terminal_size__doc__}, |
8022 | |
8023 | static PyObject * |
8024 | os_get_terminal_size_impl(PyObject *module, int fd); |
8025 | |
8026 | static PyObject * |
8027 | os_get_terminal_size(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
8028 | { |
8029 | PyObject *return_value = NULL; |
8030 | int fd = fileno(stdout); |
8031 | |
8032 | if (!_PyArg_CheckPositional("get_terminal_size", nargs, 0, 1)) { |
8033 | goto exit; |
8034 | } |
8035 | if (nargs < 1) { Branch (8035:9): [True: 1, False: 7.71k]
|
8036 | goto skip_optional; |
8037 | } |
8038 | fd = _PyLong_AsInt(args[0]); |
8039 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (8039:9): [True: 0, False: 7.71k]
Branch (8039:21): [True: 0, False: 0]
|
8040 | goto exit; |
8041 | } |
8042 | skip_optional: |
8043 | return_value = os_get_terminal_size_impl(module, fd); |
8044 | |
8045 | exit: |
8046 | return return_value; |
8047 | } |
8048 | |
8049 | #endif /* (defined(TERMSIZE_USE_CONIO) || defined(TERMSIZE_USE_IOCTL)) */ |
8050 | |
8051 | PyDoc_STRVAR(os_cpu_count__doc__, |
8052 | "cpu_count($module, /)\n" |
8053 | "--\n" |
8054 | "\n" |
8055 | "Return the number of CPUs in the system; return None if indeterminable.\n" |
8056 | "\n" |
8057 | "This number is not equivalent to the number of CPUs the current process can\n" |
8058 | "use. The number of usable CPUs can be obtained with\n" |
8059 | "``len(os.sched_getaffinity(0))``"); |
8060 | |
8061 | #define OS_CPU_COUNT_METHODDEF \ |
8062 | {"cpu_count", (PyCFunction)os_cpu_count, METH_NOARGS, os_cpu_count__doc__}, |
8063 | |
8064 | static PyObject * |
8065 | os_cpu_count_impl(PyObject *module); |
8066 | |
8067 | static PyObject * |
8068 | os_cpu_count(PyObject *module, PyObject *Py_UNUSED(ignored)) |
8069 | { |
8070 | return os_cpu_count_impl(module); |
8071 | } |
8072 | |
8073 | PyDoc_STRVAR(os_get_inheritable__doc__, |
8074 | "get_inheritable($module, fd, /)\n" |
8075 | "--\n" |
8076 | "\n" |
8077 | "Get the close-on-exe flag of the specified file descriptor."); |
8078 | |
8079 | #define OS_GET_INHERITABLE_METHODDEF \ |
8080 | {"get_inheritable", (PyCFunction)os_get_inheritable, METH_O, os_get_inheritable__doc__}, |
8081 | |
8082 | static int |
8083 | os_get_inheritable_impl(PyObject *module, int fd); |
8084 | |
8085 | static PyObject * |
8086 | os_get_inheritable(PyObject *module, PyObject *arg) |
8087 | { |
8088 | PyObject *return_value = NULL; |
8089 | int fd; |
8090 | int _return_value; |
8091 | |
8092 | fd = _PyLong_AsInt(arg); |
8093 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (8093:9): [True: 0, False: 130]
Branch (8093:21): [True: 0, False: 0]
|
8094 | goto exit; |
8095 | } |
8096 | _return_value = os_get_inheritable_impl(module, fd); |
8097 | if ((_return_value == -1) && PyErr_Occurred()2 ) { Branch (8097:9): [True: 2, False: 128]
Branch (8097:34): [True: 2, False: 0]
|
8098 | goto exit; |
8099 | } |
8100 | return_value = PyBool_FromLong((long)_return_value); |
8101 | |
8102 | exit: |
8103 | return return_value; |
8104 | } |
8105 | |
8106 | PyDoc_STRVAR(os_set_inheritable__doc__, |
8107 | "set_inheritable($module, fd, inheritable, /)\n" |
8108 | "--\n" |
8109 | "\n" |
8110 | "Set the inheritable flag of the specified file descriptor."); |
8111 | |
8112 | #define OS_SET_INHERITABLE_METHODDEF \ |
8113 | {"set_inheritable", _PyCFunction_CAST(os_set_inheritable), METH_FASTCALL, os_set_inheritable__doc__}, |
8114 | |
8115 | static PyObject * |
8116 | os_set_inheritable_impl(PyObject *module, int fd, int inheritable); |
8117 | |
8118 | static PyObject * |
8119 | os_set_inheritable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
8120 | { |
8121 | PyObject *return_value = NULL; |
8122 | int fd; |
8123 | int inheritable; |
8124 | |
8125 | if (!_PyArg_CheckPositional("set_inheritable", nargs, 2, 2)) { |
8126 | goto exit; |
8127 | } |
8128 | fd = _PyLong_AsInt(args[0]); |
8129 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (8129:9): [True: 0, False: 35]
Branch (8129:21): [True: 0, False: 0]
|
8130 | goto exit; |
8131 | } |
8132 | inheritable = _PyLong_AsInt(args[1]); |
8133 | if (inheritable == -1 && PyErr_Occurred()0 ) { Branch (8133:9): [True: 0, False: 35]
Branch (8133:30): [True: 0, False: 0]
|
8134 | goto exit; |
8135 | } |
8136 | return_value = os_set_inheritable_impl(module, fd, inheritable); |
8137 | |
8138 | exit: |
8139 | return return_value; |
8140 | } |
8141 | |
8142 | #if defined(MS_WINDOWS) |
8143 | |
8144 | PyDoc_STRVAR(os_get_handle_inheritable__doc__, |
8145 | "get_handle_inheritable($module, handle, /)\n" |
8146 | "--\n" |
8147 | "\n" |
8148 | "Get the close-on-exe flag of the specified file descriptor."); |
8149 | |
8150 | #define OS_GET_HANDLE_INHERITABLE_METHODDEF \ |
8151 | {"get_handle_inheritable", (PyCFunction)os_get_handle_inheritable, METH_O, os_get_handle_inheritable__doc__}, |
8152 | |
8153 | static int |
8154 | os_get_handle_inheritable_impl(PyObject *module, intptr_t handle); |
8155 | |
8156 | static PyObject * |
8157 | os_get_handle_inheritable(PyObject *module, PyObject *arg) |
8158 | { |
8159 | PyObject *return_value = NULL; |
8160 | intptr_t handle; |
8161 | int _return_value; |
8162 | |
8163 | if (!PyArg_Parse(arg, "" _Py_PARSE_INTPTR ":get_handle_inheritable", &handle)) { |
8164 | goto exit; |
8165 | } |
8166 | _return_value = os_get_handle_inheritable_impl(module, handle); |
8167 | if ((_return_value == -1) && PyErr_Occurred()) { |
8168 | goto exit; |
8169 | } |
8170 | return_value = PyBool_FromLong((long)_return_value); |
8171 | |
8172 | exit: |
8173 | return return_value; |
8174 | } |
8175 | |
8176 | #endif /* defined(MS_WINDOWS) */ |
8177 | |
8178 | #if defined(MS_WINDOWS) |
8179 | |
8180 | PyDoc_STRVAR(os_set_handle_inheritable__doc__, |
8181 | "set_handle_inheritable($module, handle, inheritable, /)\n" |
8182 | "--\n" |
8183 | "\n" |
8184 | "Set the inheritable flag of the specified handle."); |
8185 | |
8186 | #define OS_SET_HANDLE_INHERITABLE_METHODDEF \ |
8187 | {"set_handle_inheritable", _PyCFunction_CAST(os_set_handle_inheritable), METH_FASTCALL, os_set_handle_inheritable__doc__}, |
8188 | |
8189 | static PyObject * |
8190 | os_set_handle_inheritable_impl(PyObject *module, intptr_t handle, |
8191 | int inheritable); |
8192 | |
8193 | static PyObject * |
8194 | os_set_handle_inheritable(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
8195 | { |
8196 | PyObject *return_value = NULL; |
8197 | intptr_t handle; |
8198 | int inheritable; |
8199 | |
8200 | if (!_PyArg_ParseStack(args, nargs, "" _Py_PARSE_INTPTR "p:set_handle_inheritable", |
8201 | &handle, &inheritable)) { |
8202 | goto exit; |
8203 | } |
8204 | return_value = os_set_handle_inheritable_impl(module, handle, inheritable); |
8205 | |
8206 | exit: |
8207 | return return_value; |
8208 | } |
8209 | |
8210 | #endif /* defined(MS_WINDOWS) */ |
8211 | |
8212 | #if !defined(MS_WINDOWS) |
8213 | |
8214 | PyDoc_STRVAR(os_get_blocking__doc__, |
8215 | "get_blocking($module, fd, /)\n" |
8216 | "--\n" |
8217 | "\n" |
8218 | "Get the blocking mode of the file descriptor.\n" |
8219 | "\n" |
8220 | "Return False if the O_NONBLOCK flag is set, True if the flag is cleared."); |
8221 | |
8222 | #define OS_GET_BLOCKING_METHODDEF \ |
8223 | {"get_blocking", (PyCFunction)os_get_blocking, METH_O, os_get_blocking__doc__}, |
8224 | |
8225 | static int |
8226 | os_get_blocking_impl(PyObject *module, int fd); |
8227 | |
8228 | static PyObject * |
8229 | os_get_blocking(PyObject *module, PyObject *arg) |
8230 | { |
8231 | PyObject *return_value = NULL; |
8232 | int fd; |
8233 | int _return_value; |
8234 | |
8235 | fd = _PyLong_AsInt(arg); |
8236 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (8236:9): [True: 0, False: 6]
Branch (8236:21): [True: 0, False: 0]
|
8237 | goto exit; |
8238 | } |
8239 | _return_value = os_get_blocking_impl(module, fd); |
8240 | if ((_return_value == -1) && PyErr_Occurred()1 ) { Branch (8240:9): [True: 1, False: 5]
Branch (8240:34): [True: 1, False: 0]
|
8241 | goto exit; |
8242 | } |
8243 | return_value = PyBool_FromLong((long)_return_value); |
8244 | |
8245 | exit: |
8246 | return return_value; |
8247 | } |
8248 | |
8249 | #endif /* !defined(MS_WINDOWS) */ |
8250 | |
8251 | #if !defined(MS_WINDOWS) |
8252 | |
8253 | PyDoc_STRVAR(os_set_blocking__doc__, |
8254 | "set_blocking($module, fd, blocking, /)\n" |
8255 | "--\n" |
8256 | "\n" |
8257 | "Set the blocking mode of the specified file descriptor.\n" |
8258 | "\n" |
8259 | "Set the O_NONBLOCK flag if blocking is False,\n" |
8260 | "clear the O_NONBLOCK flag otherwise."); |
8261 | |
8262 | #define OS_SET_BLOCKING_METHODDEF \ |
8263 | {"set_blocking", _PyCFunction_CAST(os_set_blocking), METH_FASTCALL, os_set_blocking__doc__}, |
8264 | |
8265 | static PyObject * |
8266 | os_set_blocking_impl(PyObject *module, int fd, int blocking); |
8267 | |
8268 | static PyObject * |
8269 | os_set_blocking(PyObject *module, PyObject *const *args, Py_ssize_t nargs) |
8270 | { |
8271 | PyObject *return_value = NULL; |
8272 | int fd; |
8273 | int blocking; |
8274 | |
8275 | if (!_PyArg_CheckPositional("set_blocking", nargs, 2, 2)) { |
8276 | goto exit; |
8277 | } |
8278 | fd = _PyLong_AsInt(args[0]); |
8279 | if (fd == -1 && PyErr_Occurred()0 ) { Branch (8279:9): [True: 0, False: 252]
Branch (8279:21): [True: 0, False: 0]
|
8280 | goto exit; |
8281 | } |
8282 | blocking = _PyLong_AsInt(args[1]); |
8283 | if (blocking == -1 && PyErr_Occurred()0 ) { Branch (8283:9): [True: 0, False: 252]
Branch (8283:27): [True: 0, False: 0]
|
8284 | goto exit; |
8285 | } |
8286 | return_value = os_set_blocking_impl(module, fd, blocking); |
8287 | |
8288 | exit: |
8289 | return return_value; |
8290 | } |
8291 | |
8292 | #endif /* !defined(MS_WINDOWS) */ |
8293 | |
8294 | PyDoc_STRVAR(os_DirEntry_is_symlink__doc__, |
8295 | "is_symlink($self, /)\n" |
8296 | "--\n" |
8297 | "\n" |
8298 | "Return True if the entry is a symbolic link; cached per entry."); |
8299 | |
8300 | #define OS_DIRENTRY_IS_SYMLINK_METHODDEF \ |
8301 | {"is_symlink", _PyCFunction_CAST(os_DirEntry_is_symlink), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_symlink__doc__}, |
8302 | |
8303 | static int |
8304 | os_DirEntry_is_symlink_impl(DirEntry *self, PyTypeObject *defining_class); |
8305 | |
8306 | static PyObject * |
8307 | os_DirEntry_is_symlink(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8308 | { |
8309 | PyObject *return_value = NULL; |
8310 | int _return_value; |
8311 | |
8312 | if (nargs) { Branch (8312:9): [True: 0, False: 22.0k]
|
8313 | PyErr_SetString(PyExc_TypeError, "is_symlink() takes no arguments"); |
8314 | goto exit; |
8315 | } |
8316 | _return_value = os_DirEntry_is_symlink_impl(self, defining_class); |
8317 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (8317:9): [True: 0, False: 22.0k]
Branch (8317:34): [True: 0, False: 0]
|
8318 | goto exit; |
8319 | } |
8320 | return_value = PyBool_FromLong((long)_return_value); |
8321 | |
8322 | exit: |
8323 | return return_value; |
8324 | } |
8325 | |
8326 | PyDoc_STRVAR(os_DirEntry_stat__doc__, |
8327 | "stat($self, /, *, follow_symlinks=True)\n" |
8328 | "--\n" |
8329 | "\n" |
8330 | "Return stat_result object for the entry; cached per entry."); |
8331 | |
8332 | #define OS_DIRENTRY_STAT_METHODDEF \ |
8333 | {"stat", _PyCFunction_CAST(os_DirEntry_stat), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_stat__doc__}, |
8334 | |
8335 | static PyObject * |
8336 | os_DirEntry_stat_impl(DirEntry *self, PyTypeObject *defining_class, |
8337 | int follow_symlinks); |
8338 | |
8339 | static PyObject * |
8340 | os_DirEntry_stat(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8341 | { |
8342 | PyObject *return_value = NULL; |
8343 | static const char * const _keywords[] = {"follow_symlinks", NULL}; |
8344 | static _PyArg_Parser _parser = {NULL, _keywords, "stat", 0}; |
8345 | PyObject *argsbuf[1]; |
8346 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE14.0k (kwnames) : 015.8k ) - 0; Branch (8346:36): [True: 14.0k, False: 15.8k]
|
8347 | int follow_symlinks = 1; |
8348 | |
8349 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); |
8350 | if (!args) { Branch (8350:9): [True: 0, False: 29.8k]
|
8351 | goto exit; |
8352 | } |
8353 | if (!noptargs) { Branch (8353:9): [True: 15.8k, False: 14.0k]
|
8354 | goto skip_optional_kwonly; |
8355 | } |
8356 | follow_symlinks = PyObject_IsTrue(args[0]); |
8357 | if (follow_symlinks < 0) { Branch (8357:9): [True: 0, False: 14.0k]
|
8358 | goto exit; |
8359 | } |
8360 | skip_optional_kwonly: |
8361 | return_value = os_DirEntry_stat_impl(self, defining_class, follow_symlinks); |
8362 | |
8363 | exit: |
8364 | return return_value; |
8365 | } |
8366 | |
8367 | PyDoc_STRVAR(os_DirEntry_is_dir__doc__, |
8368 | "is_dir($self, /, *, follow_symlinks=True)\n" |
8369 | "--\n" |
8370 | "\n" |
8371 | "Return True if the entry is a directory; cached per entry."); |
8372 | |
8373 | #define OS_DIRENTRY_IS_DIR_METHODDEF \ |
8374 | {"is_dir", _PyCFunction_CAST(os_DirEntry_is_dir), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_dir__doc__}, |
8375 | |
8376 | static int |
8377 | os_DirEntry_is_dir_impl(DirEntry *self, PyTypeObject *defining_class, |
8378 | int follow_symlinks); |
8379 | |
8380 | static PyObject * |
8381 | os_DirEntry_is_dir(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8382 | { |
8383 | PyObject *return_value = NULL; |
8384 | static const char * const _keywords[] = {"follow_symlinks", NULL}; |
8385 | static _PyArg_Parser _parser = {NULL, _keywords, "is_dir", 0}; |
8386 | PyObject *argsbuf[1]; |
8387 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE34.3k (kwnames) : 057.9k ) - 0; Branch (8387:36): [True: 34.3k, False: 57.9k]
|
8388 | int follow_symlinks = 1; |
8389 | int _return_value; |
8390 | |
8391 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); |
8392 | if (!args) { Branch (8392:9): [True: 0, False: 92.3k]
|
8393 | goto exit; |
8394 | } |
8395 | if (!noptargs) { Branch (8395:9): [True: 57.9k, False: 34.3k]
|
8396 | goto skip_optional_kwonly; |
8397 | } |
8398 | follow_symlinks = PyObject_IsTrue(args[0]); |
8399 | if (follow_symlinks < 0) { Branch (8399:9): [True: 0, False: 34.3k]
|
8400 | goto exit; |
8401 | } |
8402 | skip_optional_kwonly: |
8403 | _return_value = os_DirEntry_is_dir_impl(self, defining_class, follow_symlinks); |
8404 | if ((_return_value == -1) && PyErr_Occurred()1.18k ) { Branch (8404:9): [True: 1.18k, False: 91.1k]
Branch (8404:34): [True: 1.18k, False: 0]
|
8405 | goto exit; |
8406 | } |
8407 | return_value = PyBool_FromLong((long)_return_value); |
8408 | |
8409 | exit: |
8410 | return return_value; |
8411 | } |
8412 | |
8413 | PyDoc_STRVAR(os_DirEntry_is_file__doc__, |
8414 | "is_file($self, /, *, follow_symlinks=True)\n" |
8415 | "--\n" |
8416 | "\n" |
8417 | "Return True if the entry is a file; cached per entry."); |
8418 | |
8419 | #define OS_DIRENTRY_IS_FILE_METHODDEF \ |
8420 | {"is_file", _PyCFunction_CAST(os_DirEntry_is_file), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, os_DirEntry_is_file__doc__}, |
8421 | |
8422 | static int |
8423 | os_DirEntry_is_file_impl(DirEntry *self, PyTypeObject *defining_class, |
8424 | int follow_symlinks); |
8425 | |
8426 | static PyObject * |
8427 | os_DirEntry_is_file(DirEntry *self, PyTypeObject *defining_class, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8428 | { |
8429 | PyObject *return_value = NULL; |
8430 | static const char * const _keywords[] = {"follow_symlinks", NULL}; |
8431 | static _PyArg_Parser _parser = {NULL, _keywords, "is_file", 0}; |
8432 | PyObject *argsbuf[1]; |
8433 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE6 (kwnames) : 07 ) - 0; Branch (8433:36): [True: 6, False: 7]
|
8434 | int follow_symlinks = 1; |
8435 | int _return_value; |
8436 | |
8437 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf); |
8438 | if (!args) { Branch (8438:9): [True: 0, False: 13]
|
8439 | goto exit; |
8440 | } |
8441 | if (!noptargs) { Branch (8441:9): [True: 7, False: 6]
|
8442 | goto skip_optional_kwonly; |
8443 | } |
8444 | follow_symlinks = PyObject_IsTrue(args[0]); |
8445 | if (follow_symlinks < 0) { Branch (8445:9): [True: 0, False: 6]
|
8446 | goto exit; |
8447 | } |
8448 | skip_optional_kwonly: |
8449 | _return_value = os_DirEntry_is_file_impl(self, defining_class, follow_symlinks); |
8450 | if ((_return_value == -1) && PyErr_Occurred()0 ) { Branch (8450:9): [True: 0, False: 13]
Branch (8450:34): [True: 0, False: 0]
|
8451 | goto exit; |
8452 | } |
8453 | return_value = PyBool_FromLong((long)_return_value); |
8454 | |
8455 | exit: |
8456 | return return_value; |
8457 | } |
8458 | |
8459 | PyDoc_STRVAR(os_DirEntry_inode__doc__, |
8460 | "inode($self, /)\n" |
8461 | "--\n" |
8462 | "\n" |
8463 | "Return inode of the entry; cached per entry."); |
8464 | |
8465 | #define OS_DIRENTRY_INODE_METHODDEF \ |
8466 | {"inode", (PyCFunction)os_DirEntry_inode, METH_NOARGS, os_DirEntry_inode__doc__}, |
8467 | |
8468 | static PyObject * |
8469 | os_DirEntry_inode_impl(DirEntry *self); |
8470 | |
8471 | static PyObject * |
8472 | os_DirEntry_inode(DirEntry *self, PyObject *Py_UNUSED(ignored)) |
8473 | { |
8474 | return os_DirEntry_inode_impl(self); |
8475 | } |
8476 | |
8477 | PyDoc_STRVAR(os_DirEntry___fspath____doc__, |
8478 | "__fspath__($self, /)\n" |
8479 | "--\n" |
8480 | "\n" |
8481 | "Returns the path for the entry."); |
8482 | |
8483 | #define OS_DIRENTRY___FSPATH___METHODDEF \ |
8484 | {"__fspath__", (PyCFunction)os_DirEntry___fspath__, METH_NOARGS, os_DirEntry___fspath____doc__}, |
8485 | |
8486 | static PyObject * |
8487 | os_DirEntry___fspath___impl(DirEntry *self); |
8488 | |
8489 | static PyObject * |
8490 | os_DirEntry___fspath__(DirEntry *self, PyObject *Py_UNUSED(ignored)) |
8491 | { |
8492 | return os_DirEntry___fspath___impl(self); |
8493 | } |
8494 | |
8495 | PyDoc_STRVAR(os_scandir__doc__, |
8496 | "scandir($module, /, path=None)\n" |
8497 | "--\n" |
8498 | "\n" |
8499 | "Return an iterator of DirEntry objects for given path.\n" |
8500 | "\n" |
8501 | "path can be specified as either str, bytes, or a path-like object. If path\n" |
8502 | "is bytes, the names of yielded DirEntry objects will also be bytes; in\n" |
8503 | "all other circumstances they will be str.\n" |
8504 | "\n" |
8505 | "If path is None, uses the path=\'.\'."); |
8506 | |
8507 | #define OS_SCANDIR_METHODDEF \ |
8508 | {"scandir", _PyCFunction_CAST(os_scandir), METH_FASTCALL|METH_KEYWORDS, os_scandir__doc__}, |
8509 | |
8510 | static PyObject * |
8511 | os_scandir_impl(PyObject *module, path_t *path); |
8512 | |
8513 | static PyObject * |
8514 | os_scandir(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8515 | { |
8516 | PyObject *return_value = NULL; |
8517 | static const char * const _keywords[] = {"path", NULL}; |
8518 | static _PyArg_Parser _parser = {NULL, _keywords, "scandir", 0}; |
8519 | PyObject *argsbuf[1]; |
8520 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 0; Branch (8520:36): [True: 0, False: 46.2k]
|
8521 | path_t path = PATH_T_INITIALIZE("scandir", "path", 1, PATH_HAVE_FDOPENDIR); |
8522 | |
8523 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf); |
8524 | if (!args) { Branch (8524:9): [True: 0, False: 46.2k]
|
8525 | goto exit; |
8526 | } |
8527 | if (!noptargs) { Branch (8527:9): [True: 1, False: 46.2k]
|
8528 | goto skip_optional_pos; |
8529 | } |
8530 | if (!path_converter(args[0], &path)) { Branch (8530:9): [True: 3, False: 46.2k]
|
8531 | goto exit; |
8532 | } |
8533 | skip_optional_pos: |
8534 | return_value = os_scandir_impl(module, &path); |
8535 | |
8536 | exit: |
8537 | /* Cleanup for path */ |
8538 | path_cleanup(&path); |
8539 | |
8540 | return return_value; |
8541 | } |
8542 | |
8543 | PyDoc_STRVAR(os_fspath__doc__, |
8544 | "fspath($module, /, path)\n" |
8545 | "--\n" |
8546 | "\n" |
8547 | "Return the file system path representation of the object.\n" |
8548 | "\n" |
8549 | "If the object is str or bytes, then allow it to pass through as-is. If the\n" |
8550 | "object defines __fspath__(), then return the result of that method. All other\n" |
8551 | "types raise a TypeError."); |
8552 | |
8553 | #define OS_FSPATH_METHODDEF \ |
8554 | {"fspath", _PyCFunction_CAST(os_fspath), METH_FASTCALL|METH_KEYWORDS, os_fspath__doc__}, |
8555 | |
8556 | static PyObject * |
8557 | os_fspath_impl(PyObject *module, PyObject *path); |
8558 | |
8559 | static PyObject * |
8560 | os_fspath(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8561 | { |
8562 | PyObject *return_value = NULL; |
8563 | static const char * const _keywords[] = {"path", NULL}; |
8564 | static _PyArg_Parser _parser = {NULL, _keywords, "fspath", 0}; |
8565 | PyObject *argsbuf[1]; |
8566 | PyObject *path; |
8567 | |
8568 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
8569 | if (!args) { Branch (8569:9): [True: 1, False: 1.88M]
|
8570 | goto exit; |
8571 | } |
8572 | path = args[0]; |
8573 | return_value = os_fspath_impl(module, path); |
8574 | |
8575 | exit: |
8576 | return return_value; |
8577 | } |
8578 | |
8579 | #if defined(HAVE_GETRANDOM_SYSCALL) |
8580 | |
8581 | PyDoc_STRVAR(os_getrandom__doc__, |
8582 | "getrandom($module, /, size, flags=0)\n" |
8583 | "--\n" |
8584 | "\n" |
8585 | "Obtain a series of random bytes."); |
8586 | |
8587 | #define OS_GETRANDOM_METHODDEF \ |
8588 | {"getrandom", _PyCFunction_CAST(os_getrandom), METH_FASTCALL|METH_KEYWORDS, os_getrandom__doc__}, |
8589 | |
8590 | static PyObject * |
8591 | os_getrandom_impl(PyObject *module, Py_ssize_t size, int flags); |
8592 | |
8593 | static PyObject * |
8594 | os_getrandom(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8595 | { |
8596 | PyObject *return_value = NULL; |
8597 | static const char * const _keywords[] = {"size", "flags", NULL}; |
8598 | static _PyArg_Parser _parser = {NULL, _keywords, "getrandom", 0}; |
8599 | PyObject *argsbuf[2]; |
8600 | Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE0 (kwnames) : 0) - 1; Branch (8600:36): [True: 0, False: 6]
|
8601 | Py_ssize_t size; |
8602 | int flags = 0; |
8603 | |
8604 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf); |
8605 | if (!args) { Branch (8605:9): [True: 0, False: 6]
|
8606 | goto exit; |
8607 | } |
8608 | { |
8609 | Py_ssize_t ival = -1; |
8610 | PyObject *iobj = _PyNumber_Index(args[0]); |
8611 | if (iobj != NULL) { Branch (8611:13): [True: 6, False: 0]
|
8612 | ival = PyLong_AsSsize_t(iobj); |
8613 | Py_DECREF(iobj); |
8614 | } |
8615 | if (ival == -1 && PyErr_Occurred()0 ) { Branch (8615:13): [True: 0, False: 6]
Branch (8615:27): [True: 0, False: 0]
|
8616 | goto exit; |
8617 | } |
8618 | size = ival; |
8619 | } |
8620 | if (!noptargs) { Branch (8620:9): [True: 5, False: 1]
|
8621 | goto skip_optional_pos; |
8622 | } |
8623 | flags = _PyLong_AsInt(args[1]); |
8624 | if (flags == -1 && PyErr_Occurred()0 ) { Branch (8624:9): [True: 0, False: 1]
Branch (8624:24): [True: 0, False: 0]
|
8625 | goto exit; |
8626 | } |
8627 | skip_optional_pos: |
8628 | return_value = os_getrandom_impl(module, size, flags); |
8629 | |
8630 | exit: |
8631 | return return_value; |
8632 | } |
8633 | |
8634 | #endif /* defined(HAVE_GETRANDOM_SYSCALL) */ |
8635 | |
8636 | #if defined(MS_WINDOWS) |
8637 | |
8638 | PyDoc_STRVAR(os__add_dll_directory__doc__, |
8639 | "_add_dll_directory($module, /, path)\n" |
8640 | "--\n" |
8641 | "\n" |
8642 | "Add a path to the DLL search path.\n" |
8643 | "\n" |
8644 | "This search path is used when resolving dependencies for imported\n" |
8645 | "extension modules (the module itself is resolved through sys.path),\n" |
8646 | "and also by ctypes.\n" |
8647 | "\n" |
8648 | "Returns an opaque value that may be passed to os.remove_dll_directory\n" |
8649 | "to remove this directory from the search path."); |
8650 | |
8651 | #define OS__ADD_DLL_DIRECTORY_METHODDEF \ |
8652 | {"_add_dll_directory", _PyCFunction_CAST(os__add_dll_directory), METH_FASTCALL|METH_KEYWORDS, os__add_dll_directory__doc__}, |
8653 | |
8654 | static PyObject * |
8655 | os__add_dll_directory_impl(PyObject *module, path_t *path); |
8656 | |
8657 | static PyObject * |
8658 | os__add_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8659 | { |
8660 | PyObject *return_value = NULL; |
8661 | static const char * const _keywords[] = {"path", NULL}; |
8662 | static _PyArg_Parser _parser = {NULL, _keywords, "_add_dll_directory", 0}; |
8663 | PyObject *argsbuf[1]; |
8664 | path_t path = PATH_T_INITIALIZE("_add_dll_directory", "path", 0, 0); |
8665 | |
8666 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
8667 | if (!args) { |
8668 | goto exit; |
8669 | } |
8670 | if (!path_converter(args[0], &path)) { |
8671 | goto exit; |
8672 | } |
8673 | return_value = os__add_dll_directory_impl(module, &path); |
8674 | |
8675 | exit: |
8676 | /* Cleanup for path */ |
8677 | path_cleanup(&path); |
8678 | |
8679 | return return_value; |
8680 | } |
8681 | |
8682 | #endif /* defined(MS_WINDOWS) */ |
8683 | |
8684 | #if defined(MS_WINDOWS) |
8685 | |
8686 | PyDoc_STRVAR(os__remove_dll_directory__doc__, |
8687 | "_remove_dll_directory($module, /, cookie)\n" |
8688 | "--\n" |
8689 | "\n" |
8690 | "Removes a path from the DLL search path.\n" |
8691 | "\n" |
8692 | "The parameter is an opaque value that was returned from\n" |
8693 | "os.add_dll_directory. You can only remove directories that you added\n" |
8694 | "yourself."); |
8695 | |
8696 | #define OS__REMOVE_DLL_DIRECTORY_METHODDEF \ |
8697 | {"_remove_dll_directory", _PyCFunction_CAST(os__remove_dll_directory), METH_FASTCALL|METH_KEYWORDS, os__remove_dll_directory__doc__}, |
8698 | |
8699 | static PyObject * |
8700 | os__remove_dll_directory_impl(PyObject *module, PyObject *cookie); |
8701 | |
8702 | static PyObject * |
8703 | os__remove_dll_directory(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8704 | { |
8705 | PyObject *return_value = NULL; |
8706 | static const char * const _keywords[] = {"cookie", NULL}; |
8707 | static _PyArg_Parser _parser = {NULL, _keywords, "_remove_dll_directory", 0}; |
8708 | PyObject *argsbuf[1]; |
8709 | PyObject *cookie; |
8710 | |
8711 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
8712 | if (!args) { |
8713 | goto exit; |
8714 | } |
8715 | cookie = args[0]; |
8716 | return_value = os__remove_dll_directory_impl(module, cookie); |
8717 | |
8718 | exit: |
8719 | return return_value; |
8720 | } |
8721 | |
8722 | #endif /* defined(MS_WINDOWS) */ |
8723 | |
8724 | #if (defined(WIFEXITED) || defined(MS_WINDOWS)) |
8725 | |
8726 | PyDoc_STRVAR(os_waitstatus_to_exitcode__doc__, |
8727 | "waitstatus_to_exitcode($module, /, status)\n" |
8728 | "--\n" |
8729 | "\n" |
8730 | "Convert a wait status to an exit code.\n" |
8731 | "\n" |
8732 | "On Unix:\n" |
8733 | "\n" |
8734 | "* If WIFEXITED(status) is true, return WEXITSTATUS(status).\n" |
8735 | "* If WIFSIGNALED(status) is true, return -WTERMSIG(status).\n" |
8736 | "* Otherwise, raise a ValueError.\n" |
8737 | "\n" |
8738 | "On Windows, return status shifted right by 8 bits.\n" |
8739 | "\n" |
8740 | "On Unix, if the process is being traced or if waitpid() was called with\n" |
8741 | "WUNTRACED option, the caller must first check if WIFSTOPPED(status) is true.\n" |
8742 | "This function must not be called if WIFSTOPPED(status) is true."); |
8743 | |
8744 | #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF \ |
8745 | {"waitstatus_to_exitcode", _PyCFunction_CAST(os_waitstatus_to_exitcode), METH_FASTCALL|METH_KEYWORDS, os_waitstatus_to_exitcode__doc__}, |
8746 | |
8747 | static PyObject * |
8748 | os_waitstatus_to_exitcode_impl(PyObject *module, PyObject *status_obj); |
8749 | |
8750 | static PyObject * |
8751 | os_waitstatus_to_exitcode(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
8752 | { |
8753 | PyObject *return_value = NULL; |
8754 | static const char * const _keywords[] = {"status", NULL}; |
8755 | static _PyArg_Parser _parser = {NULL, _keywords, "waitstatus_to_exitcode", 0}; |
8756 | PyObject *argsbuf[1]; |
8757 | PyObject *status_obj; |
8758 | |
8759 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
8760 | if (!args) { Branch (8760:9): [True: 0, False: 5.66k]
|
8761 | goto exit; |
8762 | } |
8763 | status_obj = args[0]; |
8764 | return_value = os_waitstatus_to_exitcode_impl(module, status_obj); |
8765 | |
8766 | exit: |
8767 | return return_value; |
8768 | } |
8769 | |
8770 | #endif /* (defined(WIFEXITED) || defined(MS_WINDOWS)) */ |
8771 | |
8772 | #ifndef OS_TTYNAME_METHODDEF |
8773 | #define OS_TTYNAME_METHODDEF |
8774 | #endif /* !defined(OS_TTYNAME_METHODDEF) */ |
8775 | |
8776 | #ifndef OS_CTERMID_METHODDEF |
8777 | #define OS_CTERMID_METHODDEF |
8778 | #endif /* !defined(OS_CTERMID_METHODDEF) */ |
8779 | |
8780 | #ifndef OS_FCHDIR_METHODDEF |
8781 | #define OS_FCHDIR_METHODDEF |
8782 | #endif /* !defined(OS_FCHDIR_METHODDEF) */ |
8783 | |
8784 | #ifndef OS_FCHMOD_METHODDEF |
8785 | #define OS_FCHMOD_METHODDEF |
8786 | #endif /* !defined(OS_FCHMOD_METHODDEF) */ |
8787 | |
8788 | #ifndef OS_LCHMOD_METHODDEF |
8789 | #define OS_LCHMOD_METHODDEF |
8790 | #endif /* !defined(OS_LCHMOD_METHODDEF) */ |
8791 | |
8792 | #ifndef OS_CHFLAGS_METHODDEF |
8793 | #define OS_CHFLAGS_METHODDEF |
8794 | #endif /* !defined(OS_CHFLAGS_METHODDEF) */ |
8795 | |
8796 | #ifndef OS_LCHFLAGS_METHODDEF |
8797 | #define OS_LCHFLAGS_METHODDEF |
8798 | #endif /* !defined(OS_LCHFLAGS_METHODDEF) */ |
8799 | |
8800 | #ifndef OS_CHROOT_METHODDEF |
8801 | #define OS_CHROOT_METHODDEF |
8802 | #endif /* !defined(OS_CHROOT_METHODDEF) */ |
8803 | |
8804 | #ifndef OS_FSYNC_METHODDEF |
8805 | #define OS_FSYNC_METHODDEF |
8806 | #endif /* !defined(OS_FSYNC_METHODDEF) */ |
8807 | |
8808 | #ifndef OS_SYNC_METHODDEF |
8809 | #define OS_SYNC_METHODDEF |
8810 | #endif /* !defined(OS_SYNC_METHODDEF) */ |
8811 | |
8812 | #ifndef OS_FDATASYNC_METHODDEF |
8813 | #define OS_FDATASYNC_METHODDEF |
8814 | #endif /* !defined(OS_FDATASYNC_METHODDEF) */ |
8815 | |
8816 | #ifndef OS_CHOWN_METHODDEF |
8817 | #define OS_CHOWN_METHODDEF |
8818 | #endif /* !defined(OS_CHOWN_METHODDEF) */ |
8819 | |
8820 | #ifndef OS_FCHOWN_METHODDEF |
8821 | #define OS_FCHOWN_METHODDEF |
8822 | #endif /* !defined(OS_FCHOWN_METHODDEF) */ |
8823 | |
8824 | #ifndef OS_LCHOWN_METHODDEF |
8825 | #define OS_LCHOWN_METHODDEF |
8826 | #endif /* !defined(OS_LCHOWN_METHODDEF) */ |
8827 | |
8828 | #ifndef OS_LINK_METHODDEF |
8829 | #define OS_LINK_METHODDEF |
8830 | #endif /* !defined(OS_LINK_METHODDEF) */ |
8831 | |
8832 | #ifndef OS__GETFULLPATHNAME_METHODDEF |
8833 | #define OS__GETFULLPATHNAME_METHODDEF |
8834 | #endif /* !defined(OS__GETFULLPATHNAME_METHODDEF) */ |
8835 | |
8836 | #ifndef OS__GETFINALPATHNAME_METHODDEF |
8837 | #define OS__GETFINALPATHNAME_METHODDEF |
8838 | #endif /* !defined(OS__GETFINALPATHNAME_METHODDEF) */ |
8839 | |
8840 | #ifndef OS__GETVOLUMEPATHNAME_METHODDEF |
8841 | #define OS__GETVOLUMEPATHNAME_METHODDEF |
8842 | #endif /* !defined(OS__GETVOLUMEPATHNAME_METHODDEF) */ |
8843 | |
8844 | #ifndef OS__PATH_SPLITROOT_METHODDEF |
8845 | #define OS__PATH_SPLITROOT_METHODDEF |
8846 | #endif /* !defined(OS__PATH_SPLITROOT_METHODDEF) */ |
8847 | |
8848 | #ifndef OS_NICE_METHODDEF |
8849 | #define OS_NICE_METHODDEF |
8850 | #endif /* !defined(OS_NICE_METHODDEF) */ |
8851 | |
8852 | #ifndef OS_GETPRIORITY_METHODDEF |
8853 | #define OS_GETPRIORITY_METHODDEF |
8854 | #endif /* !defined(OS_GETPRIORITY_METHODDEF) */ |
8855 | |
8856 | #ifndef OS_SETPRIORITY_METHODDEF |
8857 | #define OS_SETPRIORITY_METHODDEF |
8858 | #endif /* !defined(OS_SETPRIORITY_METHODDEF) */ |
8859 | |
8860 | #ifndef OS_SYSTEM_METHODDEF |
8861 | #define OS_SYSTEM_METHODDEF |
8862 | #endif /* !defined(OS_SYSTEM_METHODDEF) */ |
8863 | |
8864 | #ifndef OS_UMASK_METHODDEF |
8865 | #define OS_UMASK_METHODDEF |
8866 | #endif /* !defined(OS_UMASK_METHODDEF) */ |
8867 | |
8868 | #ifndef OS_UNAME_METHODDEF |
8869 | #define OS_UNAME_METHODDEF |
8870 | #endif /* !defined(OS_UNAME_METHODDEF) */ |
8871 | |
8872 | #ifndef OS_EXECV_METHODDEF |
8873 | #define OS_EXECV_METHODDEF |
8874 | #endif /* !defined(OS_EXECV_METHODDEF) */ |
8875 | |
8876 | #ifndef OS_EXECVE_METHODDEF |
8877 | #define OS_EXECVE_METHODDEF |
8878 | #endif /* !defined(OS_EXECVE_METHODDEF) */ |
8879 | |
8880 | #ifndef OS_POSIX_SPAWN_METHODDEF |
8881 | #define OS_POSIX_SPAWN_METHODDEF |
8882 | #endif /* !defined(OS_POSIX_SPAWN_METHODDEF) */ |
8883 | |
8884 | #ifndef OS_POSIX_SPAWNP_METHODDEF |
8885 | #define OS_POSIX_SPAWNP_METHODDEF |
8886 | #endif /* !defined(OS_POSIX_SPAWNP_METHODDEF) */ |
8887 | |
8888 | #ifndef OS_SPAWNV_METHODDEF |
8889 | #define OS_SPAWNV_METHODDEF |
8890 | #endif /* !defined(OS_SPAWNV_METHODDEF) */ |
8891 | |
8892 | #ifndef OS_SPAWNVE_METHODDEF |
8893 | #define OS_SPAWNVE_METHODDEF |
8894 | #endif /* !defined(OS_SPAWNVE_METHODDEF) */ |
8895 | |
8896 | #ifndef OS_REGISTER_AT_FORK_METHODDEF |
8897 | #define OS_REGISTER_AT_FORK_METHODDEF |
8898 | #endif /* !defined(OS_REGISTER_AT_FORK_METHODDEF) */ |
8899 | |
8900 | #ifndef OS_FORK1_METHODDEF |
8901 | #define OS_FORK1_METHODDEF |
8902 | #endif /* !defined(OS_FORK1_METHODDEF) */ |
8903 | |
8904 | #ifndef OS_FORK_METHODDEF |
8905 | #define OS_FORK_METHODDEF |
8906 | #endif /* !defined(OS_FORK_METHODDEF) */ |
8907 | |
8908 | #ifndef OS_SCHED_GET_PRIORITY_MAX_METHODDEF |
8909 | #define OS_SCHED_GET_PRIORITY_MAX_METHODDEF |
8910 | #endif /* !defined(OS_SCHED_GET_PRIORITY_MAX_METHODDEF) */ |
8911 | |
8912 | #ifndef OS_SCHED_GET_PRIORITY_MIN_METHODDEF |
8913 | #define OS_SCHED_GET_PRIORITY_MIN_METHODDEF |
8914 | #endif /* !defined(OS_SCHED_GET_PRIORITY_MIN_METHODDEF) */ |
8915 | |
8916 | #ifndef OS_SCHED_GETSCHEDULER_METHODDEF |
8917 | #define OS_SCHED_GETSCHEDULER_METHODDEF |
8918 | #endif /* !defined(OS_SCHED_GETSCHEDULER_METHODDEF) */ |
8919 | |
8920 | #ifndef OS_SCHED_SETSCHEDULER_METHODDEF |
8921 | #define OS_SCHED_SETSCHEDULER_METHODDEF |
8922 | #endif /* !defined(OS_SCHED_SETSCHEDULER_METHODDEF) */ |
8923 | |
8924 | #ifndef OS_SCHED_GETPARAM_METHODDEF |
8925 | #define OS_SCHED_GETPARAM_METHODDEF |
8926 | #endif /* !defined(OS_SCHED_GETPARAM_METHODDEF) */ |
8927 | |
8928 | #ifndef OS_SCHED_SETPARAM_METHODDEF |
8929 | #define OS_SCHED_SETPARAM_METHODDEF |
8930 | #endif /* !defined(OS_SCHED_SETPARAM_METHODDEF) */ |
8931 | |
8932 | #ifndef OS_SCHED_RR_GET_INTERVAL_METHODDEF |
8933 | #define OS_SCHED_RR_GET_INTERVAL_METHODDEF |
8934 | #endif /* !defined(OS_SCHED_RR_GET_INTERVAL_METHODDEF) */ |
8935 | |
8936 | #ifndef OS_SCHED_YIELD_METHODDEF |
8937 | #define OS_SCHED_YIELD_METHODDEF |
8938 | #endif /* !defined(OS_SCHED_YIELD_METHODDEF) */ |
8939 | |
8940 | #ifndef OS_SCHED_SETAFFINITY_METHODDEF |
8941 | #define OS_SCHED_SETAFFINITY_METHODDEF |
8942 | #endif /* !defined(OS_SCHED_SETAFFINITY_METHODDEF) */ |
8943 | |
8944 | #ifndef OS_SCHED_GETAFFINITY_METHODDEF |
8945 | #define OS_SCHED_GETAFFINITY_METHODDEF |
8946 | #endif /* !defined(OS_SCHED_GETAFFINITY_METHODDEF) */ |
8947 | |
8948 | #ifndef OS_OPENPTY_METHODDEF |
8949 | #define OS_OPENPTY_METHODDEF |
8950 | #endif /* !defined(OS_OPENPTY_METHODDEF) */ |
8951 | |
8952 | #ifndef OS_LOGIN_TTY_METHODDEF |
8953 | #define OS_LOGIN_TTY_METHODDEF |
8954 | #endif /* !defined(OS_LOGIN_TTY_METHODDEF) */ |
8955 | |
8956 | #ifndef OS_FORKPTY_METHODDEF |
8957 | #define OS_FORKPTY_METHODDEF |
8958 | #endif /* !defined(OS_FORKPTY_METHODDEF) */ |
8959 | |
8960 | #ifndef OS_GETEGID_METHODDEF |
8961 | #define OS_GETEGID_METHODDEF |
8962 | #endif /* !defined(OS_GETEGID_METHODDEF) */ |
8963 | |
8964 | #ifndef OS_GETEUID_METHODDEF |
8965 | #define OS_GETEUID_METHODDEF |
8966 | #endif /* !defined(OS_GETEUID_METHODDEF) */ |
8967 | |
8968 | #ifndef OS_GETGID_METHODDEF |
8969 | #define OS_GETGID_METHODDEF |
8970 | #endif /* !defined(OS_GETGID_METHODDEF) */ |
8971 | |
8972 | #ifndef OS_GETPID_METHODDEF |
8973 | #define OS_GETPID_METHODDEF |
8974 | #endif /* !defined(OS_GETPID_METHODDEF) */ |
8975 | |
8976 | #ifndef OS_GETGROUPLIST_METHODDEF |
8977 | #define OS_GETGROUPLIST_METHODDEF |
8978 | #endif /* !defined(OS_GETGROUPLIST_METHODDEF) */ |
8979 | |
8980 | #ifndef OS_GETGROUPS_METHODDEF |
8981 | #define OS_GETGROUPS_METHODDEF |
8982 | #endif /* !defined(OS_GETGROUPS_METHODDEF) */ |
8983 | |
8984 | #ifndef OS_INITGROUPS_METHODDEF |
8985 | #define OS_INITGROUPS_METHODDEF |
8986 | #endif /* !defined(OS_INITGROUPS_METHODDEF) */ |
8987 | |
8988 | #ifndef OS_GETPGID_METHODDEF |
8989 | #define OS_GETPGID_METHODDEF |
8990 | #endif /* !defined(OS_GETPGID_METHODDEF) */ |
8991 | |
8992 | #ifndef OS_GETPGRP_METHODDEF |
8993 | #define OS_GETPGRP_METHODDEF |
8994 | #endif /* !defined(OS_GETPGRP_METHODDEF) */ |
8995 | |
8996 | #ifndef OS_SETPGRP_METHODDEF |
8997 | #define OS_SETPGRP_METHODDEF |
8998 | #endif /* !defined(OS_SETPGRP_METHODDEF) */ |
8999 | |
9000 | #ifndef OS_GETPPID_METHODDEF |
9001 | #define OS_GETPPID_METHODDEF |
9002 | #endif /* !defined(OS_GETPPID_METHODDEF) */ |
9003 | |
9004 | #ifndef OS_GETLOGIN_METHODDEF |
9005 | #define OS_GETLOGIN_METHODDEF |
9006 | #endif /* !defined(OS_GETLOGIN_METHODDEF) */ |
9007 | |
9008 | #ifndef OS_GETUID_METHODDEF |
9009 | #define OS_GETUID_METHODDEF |
9010 | #endif /* !defined(OS_GETUID_METHODDEF) */ |
9011 | |
9012 | #ifndef OS_KILL_METHODDEF |
9013 | #define OS_KILL_METHODDEF |
9014 | #endif /* !defined(OS_KILL_METHODDEF) */ |
9015 | |
9016 | #ifndef OS_KILLPG_METHODDEF |
9017 | #define OS_KILLPG_METHODDEF |
9018 | #endif /* !defined(OS_KILLPG_METHODDEF) */ |
9019 | |
9020 | #ifndef OS_PLOCK_METHODDEF |
9021 | #define OS_PLOCK_METHODDEF |
9022 | #endif /* !defined(OS_PLOCK_METHODDEF) */ |
9023 | |
9024 | #ifndef OS_SETUID_METHODDEF |
9025 | #define OS_SETUID_METHODDEF |
9026 | #endif /* !defined(OS_SETUID_METHODDEF) */ |
9027 | |
9028 | #ifndef OS_SETEUID_METHODDEF |
9029 | #define OS_SETEUID_METHODDEF |
9030 | #endif /* !defined(OS_SETEUID_METHODDEF) */ |
9031 | |
9032 | #ifndef OS_SETEGID_METHODDEF |
9033 | #define OS_SETEGID_METHODDEF |
9034 | #endif /* !defined(OS_SETEGID_METHODDEF) */ |
9035 | |
9036 | #ifndef OS_SETREUID_METHODDEF |
9037 | #define OS_SETREUID_METHODDEF |
9038 | #endif /* !defined(OS_SETREUID_METHODDEF) */ |
9039 | |
9040 | #ifndef OS_SETREGID_METHODDEF |
9041 | #define OS_SETREGID_METHODDEF |
9042 | #endif /* !defined(OS_SETREGID_METHODDEF) */ |
9043 | |
9044 | #ifndef OS_SETGID_METHODDEF |
9045 | #define OS_SETGID_METHODDEF |
9046 | #endif /* !defined(OS_SETGID_METHODDEF) */ |
9047 | |
9048 | #ifndef OS_SETGROUPS_METHODDEF |
9049 | #define OS_SETGROUPS_METHODDEF |
9050 | #endif /* !defined(OS_SETGROUPS_METHODDEF) */ |
9051 | |
9052 | #ifndef OS_WAIT3_METHODDEF |
9053 | #define OS_WAIT3_METHODDEF |
9054 | #endif /* !defined(OS_WAIT3_METHODDEF) */ |
9055 | |
9056 | #ifndef OS_WAIT4_METHODDEF |
9057 | #define OS_WAIT4_METHODDEF |
9058 | #endif /* !defined(OS_WAIT4_METHODDEF) */ |
9059 | |
9060 | #ifndef OS_WAITID_METHODDEF |
9061 | #define OS_WAITID_METHODDEF |
9062 | #endif /* !defined(OS_WAITID_METHODDEF) */ |
9063 | |
9064 | #ifndef OS_WAITPID_METHODDEF |
9065 | #define OS_WAITPID_METHODDEF |
9066 | #endif /* !defined(OS_WAITPID_METHODDEF) */ |
9067 | |
9068 | #ifndef OS_WAIT_METHODDEF |
9069 | #define OS_WAIT_METHODDEF |
9070 | #endif /* !defined(OS_WAIT_METHODDEF) */ |
9071 | |
9072 | #ifndef OS_PIDFD_OPEN_METHODDEF |
9073 | #define OS_PIDFD_OPEN_METHODDEF |
9074 | #endif /* !defined(OS_PIDFD_OPEN_METHODDEF) */ |
9075 | |
9076 | #ifndef OS_READLINK_METHODDEF |
9077 | #define OS_READLINK_METHODDEF |
9078 | #endif /* !defined(OS_READLINK_METHODDEF) */ |
9079 | |
9080 | #ifndef OS_SYMLINK_METHODDEF |
9081 | #define OS_SYMLINK_METHODDEF |
9082 | #endif /* !defined(OS_SYMLINK_METHODDEF) */ |
9083 | |
9084 | #ifndef OS_TIMES_METHODDEF |
9085 | #define OS_TIMES_METHODDEF |
9086 | #endif /* !defined(OS_TIMES_METHODDEF) */ |
9087 | |
9088 | #ifndef OS_GETSID_METHODDEF |
9089 | #define OS_GETSID_METHODDEF |
9090 | #endif /* !defined(OS_GETSID_METHODDEF) */ |
9091 | |
9092 | #ifndef OS_SETSID_METHODDEF |
9093 | #define OS_SETSID_METHODDEF |
9094 | #endif /* !defined(OS_SETSID_METHODDEF) */ |
9095 | |
9096 | #ifndef OS_SETPGID_METHODDEF |
9097 | #define OS_SETPGID_METHODDEF |
9098 | #endif /* !defined(OS_SETPGID_METHODDEF) */ |
9099 | |
9100 | #ifndef OS_TCGETPGRP_METHODDEF |
9101 | #define OS_TCGETPGRP_METHODDEF |
9102 | #endif /* !defined(OS_TCGETPGRP_METHODDEF) */ |
9103 | |
9104 | #ifndef OS_TCSETPGRP_METHODDEF |
9105 | #define OS_TCSETPGRP_METHODDEF |
9106 | #endif /* !defined(OS_TCSETPGRP_METHODDEF) */ |
9107 | |
9108 | #ifndef OS_LOCKF_METHODDEF |
9109 | #define OS_LOCKF_METHODDEF |
9110 | #endif /* !defined(OS_LOCKF_METHODDEF) */ |
9111 | |
9112 | #ifndef OS_READV_METHODDEF |
9113 | #define OS_READV_METHODDEF |
9114 | #endif /* !defined(OS_READV_METHODDEF) */ |
9115 | |
9116 | #ifndef OS_PREAD_METHODDEF |
9117 | #define OS_PREAD_METHODDEF |
9118 | #endif /* !defined(OS_PREAD_METHODDEF) */ |
9119 | |
9120 | #ifndef OS_PREADV_METHODDEF |
9121 | #define OS_PREADV_METHODDEF |
9122 | #endif /* !defined(OS_PREADV_METHODDEF) */ |
9123 | |
9124 | #ifndef OS_SENDFILE_METHODDEF |
9125 | #define OS_SENDFILE_METHODDEF |
9126 | #endif /* !defined(OS_SENDFILE_METHODDEF) */ |
9127 | |
9128 | #ifndef OS__FCOPYFILE_METHODDEF |
9129 | #define OS__FCOPYFILE_METHODDEF |
9130 | #endif /* !defined(OS__FCOPYFILE_METHODDEF) */ |
9131 | |
9132 | #ifndef OS_PIPE_METHODDEF |
9133 | #define OS_PIPE_METHODDEF |
9134 | #endif /* !defined(OS_PIPE_METHODDEF) */ |
9135 | |
9136 | #ifndef OS_PIPE2_METHODDEF |
9137 | #define OS_PIPE2_METHODDEF |
9138 | #endif /* !defined(OS_PIPE2_METHODDEF) */ |
9139 | |
9140 | #ifndef OS_WRITEV_METHODDEF |
9141 | #define OS_WRITEV_METHODDEF |
9142 | #endif /* !defined(OS_WRITEV_METHODDEF) */ |
9143 | |
9144 | #ifndef OS_PWRITE_METHODDEF |
9145 | #define OS_PWRITE_METHODDEF |
9146 | #endif /* !defined(OS_PWRITE_METHODDEF) */ |
9147 | |
9148 | #ifndef OS_PWRITEV_METHODDEF |
9149 | #define OS_PWRITEV_METHODDEF |
9150 | #endif /* !defined(OS_PWRITEV_METHODDEF) */ |
9151 | |
9152 | #ifndef OS_COPY_FILE_RANGE_METHODDEF |
9153 | #define OS_COPY_FILE_RANGE_METHODDEF |
9154 | #endif /* !defined(OS_COPY_FILE_RANGE_METHODDEF) */ |
9155 | |
9156 | #ifndef OS_SPLICE_METHODDEF |
9157 | #define OS_SPLICE_METHODDEF |
9158 | #endif /* !defined(OS_SPLICE_METHODDEF) */ |
9159 | |
9160 | #ifndef OS_MKFIFO_METHODDEF |
9161 | #define OS_MKFIFO_METHODDEF |
9162 | #endif /* !defined(OS_MKFIFO_METHODDEF) */ |
9163 | |
9164 | #ifndef OS_MKNOD_METHODDEF |
9165 | #define OS_MKNOD_METHODDEF |
9166 | #endif /* !defined(OS_MKNOD_METHODDEF) */ |
9167 | |
9168 | #ifndef OS_MAJOR_METHODDEF |
9169 | #define OS_MAJOR_METHODDEF |
9170 | #endif /* !defined(OS_MAJOR_METHODDEF) */ |
9171 | |
9172 | #ifndef OS_MINOR_METHODDEF |
9173 | #define OS_MINOR_METHODDEF |
9174 | #endif /* !defined(OS_MINOR_METHODDEF) */ |
9175 | |
9176 | #ifndef OS_MAKEDEV_METHODDEF |
9177 | #define OS_MAKEDEV_METHODDEF |
9178 | #endif /* !defined(OS_MAKEDEV_METHODDEF) */ |
9179 | |
9180 | #ifndef OS_FTRUNCATE_METHODDEF |
9181 | #define OS_FTRUNCATE_METHODDEF |
9182 | #endif /* !defined(OS_FTRUNCATE_METHODDEF) */ |
9183 | |
9184 | #ifndef OS_TRUNCATE_METHODDEF |
9185 | #define OS_TRUNCATE_METHODDEF |
9186 | #endif /* !defined(OS_TRUNCATE_METHODDEF) */ |
9187 | |
9188 | #ifndef OS_POSIX_FALLOCATE_METHODDEF |
9189 | #define OS_POSIX_FALLOCATE_METHODDEF |
9190 | #endif /* !defined(OS_POSIX_FALLOCATE_METHODDEF) */ |
9191 | |
9192 | #ifndef OS_POSIX_FADVISE_METHODDEF |
9193 | #define OS_POSIX_FADVISE_METHODDEF |
9194 | #endif /* !defined(OS_POSIX_FADVISE_METHODDEF) */ |
9195 | |
9196 | #ifndef OS_PUTENV_METHODDEF |
9197 | #define OS_PUTENV_METHODDEF |
9198 | #endif /* !defined(OS_PUTENV_METHODDEF) */ |
9199 | |
9200 | #ifndef OS_UNSETENV_METHODDEF |
9201 | #define OS_UNSETENV_METHODDEF |
9202 | #endif /* !defined(OS_UNSETENV_METHODDEF) */ |
9203 | |
9204 | #ifndef OS_WCOREDUMP_METHODDEF |
9205 | #define OS_WCOREDUMP_METHODDEF |
9206 | #endif /* !defined(OS_WCOREDUMP_METHODDEF) */ |
9207 | |
9208 | #ifndef OS_WIFCONTINUED_METHODDEF |
9209 | #define OS_WIFCONTINUED_METHODDEF |
9210 | #endif /* !defined(OS_WIFCONTINUED_METHODDEF) */ |
9211 | |
9212 | #ifndef OS_WIFSTOPPED_METHODDEF |
9213 | #define OS_WIFSTOPPED_METHODDEF |
9214 | #endif /* !defined(OS_WIFSTOPPED_METHODDEF) */ |
9215 | |
9216 | #ifndef OS_WIFSIGNALED_METHODDEF |
9217 | #define OS_WIFSIGNALED_METHODDEF |
9218 | #endif /* !defined(OS_WIFSIGNALED_METHODDEF) */ |
9219 | |
9220 | #ifndef OS_WIFEXITED_METHODDEF |
9221 | #define OS_WIFEXITED_METHODDEF |
9222 | #endif /* !defined(OS_WIFEXITED_METHODDEF) */ |
9223 | |
9224 | #ifndef OS_WEXITSTATUS_METHODDEF |
9225 | #define OS_WEXITSTATUS_METHODDEF |
9226 | #endif /* !defined(OS_WEXITSTATUS_METHODDEF) */ |
9227 | |
9228 | #ifndef OS_WTERMSIG_METHODDEF |
9229 | #define OS_WTERMSIG_METHODDEF |
9230 | #endif /* !defined(OS_WTERMSIG_METHODDEF) */ |
9231 | |
9232 | #ifndef OS_WSTOPSIG_METHODDEF |
9233 | #define OS_WSTOPSIG_METHODDEF |
9234 | #endif /* !defined(OS_WSTOPSIG_METHODDEF) */ |
9235 | |
9236 | #ifndef OS_FSTATVFS_METHODDEF |
9237 | #define OS_FSTATVFS_METHODDEF |
9238 | #endif /* !defined(OS_FSTATVFS_METHODDEF) */ |
9239 | |
9240 | #ifndef OS_STATVFS_METHODDEF |
9241 | #define OS_STATVFS_METHODDEF |
9242 | #endif /* !defined(OS_STATVFS_METHODDEF) */ |
9243 | |
9244 | #ifndef OS__GETDISKUSAGE_METHODDEF |
9245 | #define OS__GETDISKUSAGE_METHODDEF |
9246 | #endif /* !defined(OS__GETDISKUSAGE_METHODDEF) */ |
9247 | |
9248 | #ifndef OS_FPATHCONF_METHODDEF |
9249 | #define OS_FPATHCONF_METHODDEF |
9250 | #endif /* !defined(OS_FPATHCONF_METHODDEF) */ |
9251 | |
9252 | #ifndef OS_PATHCONF_METHODDEF |
9253 | #define OS_PATHCONF_METHODDEF |
9254 | #endif /* !defined(OS_PATHCONF_METHODDEF) */ |
9255 | |
9256 | #ifndef OS_CONFSTR_METHODDEF |
9257 | #define OS_CONFSTR_METHODDEF |
9258 | #endif /* !defined(OS_CONFSTR_METHODDEF) */ |
9259 | |
9260 | #ifndef OS_SYSCONF_METHODDEF |
9261 | #define OS_SYSCONF_METHODDEF |
9262 | #endif /* !defined(OS_SYSCONF_METHODDEF) */ |
9263 | |
9264 | #ifndef OS_STARTFILE_METHODDEF |
9265 | #define OS_STARTFILE_METHODDEF |
9266 | #endif /* !defined(OS_STARTFILE_METHODDEF) */ |
9267 | |
9268 | #ifndef OS_GETLOADAVG_METHODDEF |
9269 | #define OS_GETLOADAVG_METHODDEF |
9270 | #endif /* !defined(OS_GETLOADAVG_METHODDEF) */ |
9271 | |
9272 | #ifndef OS_SETRESUID_METHODDEF |
9273 | #define OS_SETRESUID_METHODDEF |
9274 | #endif /* !defined(OS_SETRESUID_METHODDEF) */ |
9275 | |
9276 | #ifndef OS_SETRESGID_METHODDEF |
9277 | #define OS_SETRESGID_METHODDEF |
9278 | #endif /* !defined(OS_SETRESGID_METHODDEF) */ |
9279 | |
9280 | #ifndef OS_GETRESUID_METHODDEF |
9281 | #define OS_GETRESUID_METHODDEF |
9282 | #endif /* !defined(OS_GETRESUID_METHODDEF) */ |
9283 | |
9284 | #ifndef OS_GETRESGID_METHODDEF |
9285 | #define OS_GETRESGID_METHODDEF |
9286 | #endif /* !defined(OS_GETRESGID_METHODDEF) */ |
9287 | |
9288 | #ifndef OS_GETXATTR_METHODDEF |
9289 | #define OS_GETXATTR_METHODDEF |
9290 | #endif /* !defined(OS_GETXATTR_METHODDEF) */ |
9291 | |
9292 | #ifndef OS_SETXATTR_METHODDEF |
9293 | #define OS_SETXATTR_METHODDEF |
9294 | #endif /* !defined(OS_SETXATTR_METHODDEF) */ |
9295 | |
9296 | #ifndef OS_REMOVEXATTR_METHODDEF |
9297 | #define OS_REMOVEXATTR_METHODDEF |
9298 | #endif /* !defined(OS_REMOVEXATTR_METHODDEF) */ |
9299 | |
9300 | #ifndef OS_LISTXATTR_METHODDEF |
9301 | #define OS_LISTXATTR_METHODDEF |
9302 | #endif /* !defined(OS_LISTXATTR_METHODDEF) */ |
9303 | |
9304 | #ifndef OS_MEMFD_CREATE_METHODDEF |
9305 | #define OS_MEMFD_CREATE_METHODDEF |
9306 | #endif /* !defined(OS_MEMFD_CREATE_METHODDEF) */ |
9307 | |
9308 | #ifndef OS_EVENTFD_METHODDEF |
9309 | #define OS_EVENTFD_METHODDEF |
9310 | #endif /* !defined(OS_EVENTFD_METHODDEF) */ |
9311 | |
9312 | #ifndef OS_EVENTFD_READ_METHODDEF |
9313 | #define OS_EVENTFD_READ_METHODDEF |
9314 | #endif /* !defined(OS_EVENTFD_READ_METHODDEF) */ |
9315 | |
9316 | #ifndef OS_EVENTFD_WRITE_METHODDEF |
9317 | #define OS_EVENTFD_WRITE_METHODDEF |
9318 | #endif /* !defined(OS_EVENTFD_WRITE_METHODDEF) */ |
9319 | |
9320 | #ifndef OS_GET_TERMINAL_SIZE_METHODDEF |
9321 | #define OS_GET_TERMINAL_SIZE_METHODDEF |
9322 | #endif /* !defined(OS_GET_TERMINAL_SIZE_METHODDEF) */ |
9323 | |
9324 | #ifndef OS_GET_HANDLE_INHERITABLE_METHODDEF |
9325 | #define OS_GET_HANDLE_INHERITABLE_METHODDEF |
9326 | #endif /* !defined(OS_GET_HANDLE_INHERITABLE_METHODDEF) */ |
9327 | |
9328 | #ifndef OS_SET_HANDLE_INHERITABLE_METHODDEF |
9329 | #define OS_SET_HANDLE_INHERITABLE_METHODDEF |
9330 | #endif /* !defined(OS_SET_HANDLE_INHERITABLE_METHODDEF) */ |
9331 | |
9332 | #ifndef OS_GET_BLOCKING_METHODDEF |
9333 | #define OS_GET_BLOCKING_METHODDEF |
9334 | #endif /* !defined(OS_GET_BLOCKING_METHODDEF) */ |
9335 | |
9336 | #ifndef OS_SET_BLOCKING_METHODDEF |
9337 | #define OS_SET_BLOCKING_METHODDEF |
9338 | #endif /* !defined(OS_SET_BLOCKING_METHODDEF) */ |
9339 | |
9340 | #ifndef OS_GETRANDOM_METHODDEF |
9341 | #define OS_GETRANDOM_METHODDEF |
9342 | #endif /* !defined(OS_GETRANDOM_METHODDEF) */ |
9343 | |
9344 | #ifndef OS__ADD_DLL_DIRECTORY_METHODDEF |
9345 | #define OS__ADD_DLL_DIRECTORY_METHODDEF |
9346 | #endif /* !defined(OS__ADD_DLL_DIRECTORY_METHODDEF) */ |
9347 | |
9348 | #ifndef OS__REMOVE_DLL_DIRECTORY_METHODDEF |
9349 | #define OS__REMOVE_DLL_DIRECTORY_METHODDEF |
9350 | #endif /* !defined(OS__REMOVE_DLL_DIRECTORY_METHODDEF) */ |
9351 | |
9352 | #ifndef OS_WAITSTATUS_TO_EXITCODE_METHODDEF |
9353 | #define OS_WAITSTATUS_TO_EXITCODE_METHODDEF |
9354 | #endif /* !defined(OS_WAITSTATUS_TO_EXITCODE_METHODDEF) */ |
9355 | /*[clinic end generated code: output=bae15f09a1b3d2e7 input=a9049054013a1b77]*/ |