-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Attempt to automate posix consts #6117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| #!/usr/bin/env python | ||
| import collections | ||
| import re | ||
| import urllib.request | ||
| from typing import TYPE_CHECKING | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Iterator | ||
|
|
||
| CONSTS_PAT = re.compile(r"\b_*[A-Z]+(?:_+[A-Z]+)*_*\b") | ||
| OS_CONSTS_PAT = re.compile( | ||
| r"\bos\.(_*[A-Z]+(?:_+[A-Z]+)*_*)" | ||
| ) # TODO: Exclude matches if they have `(` after (those are functions) | ||
|
|
||
|
|
||
| LIBC_VERSION = "0.2.175" | ||
|
|
||
| EXCLUDE = frozenset( | ||
| { | ||
| # Defined at `vm/src/stdlib/os.rs` | ||
| "O_APPEND", | ||
| "O_CREAT", | ||
| "O_EXCL", | ||
| "O_RDONLY", | ||
| "O_RDWR", | ||
| "O_TRUNC", | ||
| "O_WRONLY", | ||
| "SEEK_CUR", | ||
| "SEEK_END", | ||
| "SEEK_SET", | ||
| # Functions, not consts | ||
| "WCOREDUMP", | ||
| "WIFCONTINUED", | ||
| "WIFSTOPPED", | ||
| "WIFSIGNALED", | ||
| "WIFEXITED", | ||
| "WEXITSTATUS", | ||
| "WSTOPSIG", | ||
| "WTERMSIG", | ||
| # False positive | ||
| # "EOF", | ||
| } | ||
| ) | ||
|
|
||
| EXTRAS = { | ||
| frozenset({"macos"}): {"COPYFILE_DATA"}, | ||
| } | ||
| RENAMES = {"COPYFILE_DATA": "_COPYFILE_DATA"} | ||
|
|
||
|
|
||
| def build_url(fname: str) -> str: | ||
| return f"https://raw.githubusercontent.com/rust-lang/libc/refs/tags/{LIBC_VERSION}/libc-test/semver/{fname}.txt" | ||
|
|
||
|
|
||
| TARGET_OS = { | ||
| "android": "android", | ||
| "dragonfly": "dragonfly", | ||
| "freebsd": "freebsd", | ||
| "linux": "linux", | ||
| "macos": "apple", | ||
| "netbsd": "netbsd", | ||
| "openbsd": "openbsd", | ||
| "redox": "redox", | ||
| # solaris? | ||
| "unix": "unix", | ||
| } | ||
|
|
||
|
|
||
| def get_consts(url: str, pattern: re.Pattern = CONSTS_PAT) -> frozenset[str]: | ||
| with urllib.request.urlopen(url) as f: | ||
| resp = f.read().decode() | ||
|
|
||
| return frozenset(pattern.findall(resp)) - EXCLUDE | ||
|
|
||
|
|
||
| def format_groups(groups: dict) -> "Iterator[tuple[str, str]]": | ||
| # sort by length, then alphabet. so we will have a consistent output | ||
| for targets, consts in sorted( | ||
| groups.items(), key=lambda t: (len(t[0]), sorted(t[0])) | ||
| ): | ||
| cond = ", ".join( | ||
| f'target_os = "{target_os}"' if target_os != "unix" else target_os | ||
| for target_os in sorted(targets) | ||
| ) | ||
| if len(targets) > 1: | ||
| cond = f"any({cond})" | ||
| cfg = f"#[cfg({cond})]" | ||
|
|
||
| imports = ", ".join( | ||
| const if const not in RENAMES else f"{const} as {RENAMES[const]}" | ||
| for const in sorted(consts) | ||
| ) | ||
| use = f"use libc::{{{imports}}};" | ||
| yield cfg, use | ||
|
|
||
|
|
||
| def main(): | ||
| wanted_consts = get_consts( | ||
| "https://docs.python.org/3.13/library/os.html", # Should we read from https://github.com/python/cpython/blob/bcee1c322115c581da27600f2ae55e5439c027eb/Modules/posixmodule.c#L17023 instead? | ||
| pattern=OS_CONSTS_PAT, | ||
| ) | ||
| available = { | ||
| target_os: get_consts(build_url(fname)) | ||
| for target_os, fname in TARGET_OS.items() | ||
| } | ||
|
|
||
| group_consts = collections.defaultdict(set) | ||
| for const in wanted_consts: | ||
| target_oses = frozenset( | ||
| target_os for target_os, consts in available.items() if const in consts | ||
| ) | ||
| if not target_oses: | ||
| continue | ||
|
|
||
| group_consts[target_oses].add(const) | ||
| group_consts = {grp: v | EXTRAS.get(grp, set()) for grp, v in group_consts.items()} | ||
|
|
||
| code = "\n\n".join( | ||
| f""" | ||
| {cfg} | ||
| #[pyattr] | ||
| {use} | ||
| """.strip() | ||
| for cfg, use in format_groups(group_consts) | ||
| ) | ||
|
|
||
| print(code) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,40 +47,177 @@ pub mod module { | |||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
| use strum_macros::{EnumIter, EnumString}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(target_os = "freebsd")] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{PRIO_PGRP, PRIO_PROCESS, PRIO_USER}; | ||||||||||||||||||||||||
| use libc::{MFD_HUGE_MASK, SF_MNOWAIT, SF_NOCACHE, SF_NODISKIO, SF_SYNC}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(target_os = "linux")] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::PIDFD_NONBLOCK; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(target_os = "macos")] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{ | ||||||||||||||||||||||||
| COPYFILE_DATA as _COPYFILE_DATA, O_EVTONLY, O_NOFOLLOW_ANY, PRIO_DARWIN_BG, | ||||||||||||||||||||||||
| PRIO_DARWIN_NONUI, PRIO_DARWIN_PROCESS, PRIO_DARWIN_THREAD, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any(target_os = "android", target_os = "linux"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{ | ||||||||||||||||||||||||
| CLONE_FILES, CLONE_FS, CLONE_NEWCGROUP, CLONE_NEWIPC, CLONE_NEWNET, CLONE_NEWNS, | ||||||||||||||||||||||||
| CLONE_NEWPID, CLONE_NEWUSER, CLONE_NEWUTS, CLONE_SIGHAND, CLONE_SYSVSEM, CLONE_THREAD, | ||||||||||||||||||||||||
| CLONE_VM, EFD_CLOEXEC, EFD_NONBLOCK, EFD_SEMAPHORE, O_NOATIME, O_TMPFILE, P_PIDFD, | ||||||||||||||||||||||||
| SCHED_BATCH, SCHED_IDLE, SCHED_RESET_ON_FORK, SPLICE_F_MORE, SPLICE_F_MOVE, | ||||||||||||||||||||||||
| SPLICE_F_NONBLOCK, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+65
to
+74
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainSplit Linux-only flags from Android-safe ones; likely Android build break Several items here are Linux-only or not guaranteed in bionic (e.g., P_PIDFD, O_TMPFILE, O_NOATIME, CLONE_NEW*). Keep eventfd on Android; move the rest to Linux-only. -#[cfg(any(target_os = "android", target_os = "linux"))]
-#[pyattr]
-use libc::{
- CLONE_FILES, CLONE_FS, CLONE_NEWCGROUP, CLONE_NEWIPC, CLONE_NEWNET, CLONE_NEWNS,
- CLONE_NEWPID, CLONE_NEWUSER, CLONE_NEWUTS, CLONE_SIGHAND, CLONE_SYSVSEM, CLONE_THREAD,
- CLONE_VM, EFD_CLOEXEC, EFD_NONBLOCK, EFD_SEMAPHORE, O_NOATIME, O_TMPFILE, P_PIDFD,
- SCHED_BATCH, SCHED_IDLE, SCHED_RESET_ON_FORK, SPLICE_F_MORE, SPLICE_F_MOVE,
- SPLICE_F_NONBLOCK,
-};
+# // Android + Linux: eventfd
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[pyattr]
+use libc::{EFD_CLOEXEC, EFD_NONBLOCK, EFD_SEMAPHORE};
+
+# // Linux-only: clone namespaces, pidfd, tmpfile, noatime, splice, sched_*
+#[cfg(target_os = "linux")]
+#[pyattr]
+use libc::{
+ CLONE_FILES, CLONE_FS, CLONE_NEWCGROUP, CLONE_NEWIPC, CLONE_NEWNET, CLONE_NEWNS, CLONE_NEWPID,
+ CLONE_NEWUSER, CLONE_NEWUTS, CLONE_SIGHAND, CLONE_SYSVSEM, CLONE_THREAD, CLONE_VM, O_NOATIME,
+ O_TMPFILE, P_PIDFD, SCHED_BATCH, SCHED_IDLE, SCHED_RESET_ON_FORK, SPLICE_F_MORE, SPLICE_F_MOVE,
+ SPLICE_F_NONBLOCK,
+};To confirm bionic coverage, please verify: 🌐 Web query: 💡 Result: O_TMPFILE — yes. [1] Sources:
Only exclude P_PIDFD on Android; keep O_TMPFILE, O_NOATIME, CLONE_NEWCGROUP under Android+Linux O_TMPFILE, O_NOATIME and CLONE_NEWCGROUP are defined in bionic’s asm-generic fcntl.h and linux/sched.h and safe on Android (android.googlesource.com). P_PIDFD is not defined in bionic’s public headers (sys/pidfd.h provides APIs but no P_PIDFD) (android.googlesource.com); move only P_PIDFD into the 🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| #[cfg(any(target_os = "android", unix))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{ | ||||||||||||||||||||||||
| F_OK, O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW, O_NONBLOCK, PRIO_PGRP, PRIO_PROCESS, PRIO_USER, | ||||||||||||||||||||||||
| R_OK, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL, RTLD_NOW, W_OK, WCONTINUED, WNOHANG, WUNTRACED, | ||||||||||||||||||||||||
| X_OK, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any(target_os = "macos", target_os = "redox"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::O_SYMLINK; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{ | ||||||||||||||||||||||||
| MFD_ALLOW_SEALING, MFD_CLOEXEC, MFD_HUGETLB, POSIX_FADV_DONTNEED, POSIX_FADV_NOREUSE, | ||||||||||||||||||||||||
| POSIX_FADV_NORMAL, POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+87
to
+93
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Split memfd flags from POSIX_FADV_*; avoid FreeBSD/Android build breaks
Apply: -#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
-#[pyattr]
-use libc::{
- MFD_ALLOW_SEALING, MFD_CLOEXEC, MFD_HUGETLB, POSIX_FADV_DONTNEED, POSIX_FADV_NOREUSE,
- POSIX_FADV_NORMAL, POSIX_FADV_RANDOM, POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED,
-};
+// memfd_* flags: Linux/Android only
+#[cfg(any(target_os = "android", target_os = "linux"))]
+#[pyattr]
+use libc::{MFD_ALLOW_SEALING, MFD_CLOEXEC, MFD_HUGETLB};
+
+// posix_fadvise advice values
+#[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux"))]
+#[pyattr]
+use libc::{
+ POSIX_FADV_DONTNEED, POSIX_FADV_NOREUSE, POSIX_FADV_NORMAL, POSIX_FADV_RANDOM,
+ POSIX_FADV_SEQUENTIAL, POSIX_FADV_WILLNEED,
+};🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| #[cfg(any(target_os = "android", target_os = "linux", target_os = "netbsd"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{TFD_CLOEXEC, TFD_NONBLOCK, TFD_TIMER_ABSTIME, TFD_TIMER_CANCEL_ON_SET}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+94
to
+97
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restrict timerfd constants to Linux/Android TFD_* are Linux-only (and present on Android); NetBSD doesn’t provide timerfd. Apply: -#[cfg(any(target_os = "android", target_os = "linux", target_os = "netbsd"))]
+#[cfg(any(target_os = "android", target_os = "linux"))]
#[pyattr]
use libc::{TFD_CLOEXEC, TFD_NONBLOCK, TFD_TIMER_ABSTIME, TFD_TIMER_CANCEL_ON_SET};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| #[cfg(any(target_os = "linux", target_os = "macos", target_os = "netbsd"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{XATTR_CREATE, XATTR_REPLACE}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "netbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{GRND_NONBLOCK, GRND_RANDOM}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "redox" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::O_PATH; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+111
to
+119
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O_PATH is Linux-specific FreeBSD/Redox don’t expose O_PATH like Linux; this will likely fail to compile on those targets. Apply: -#[cfg(any(
- target_os = "android",
- target_os = "freebsd",
- target_os = "linux",
- target_os = "redox"
-))]
+#[cfg(any(target_os = "android", target_os = "linux"))]
#[pyattr]
use libc::O_PATH;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "openbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::O_RSYNC; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Comment on lines
+120
to
+128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent ❓ Verification inconclusiveTighten O_RSYNC gating O_RSYNC is a Linux-ism (alias of O_SYNC). It’s not generally available on *BSDs and may not be exposed by libc there. Tentative change: -#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "netbsd",
- target_os = "openbsd"
-))]
-#[pyattr]
-use libc::O_RSYNC;
+#[cfg(target_os = "linux")]
+#[pyattr]
+use libc::O_RSYNC;If Android’s bionic exposes O_RSYNC in your minimum API level, we can include it after verification. Restrict O_RSYNC import to Linux O_RSYNC is only defined in libc for Linux (added under “Solarish” in libc 0.2.160) and isn’t exposed on NetBSD or OpenBSD (github.com). Change the cfg to target Linux only; if Android’s bionic proves to define O_RSYNC on your minimum API level, you can re-add it then. -#[cfg(any(
- target_os = "android",
- target_os = "linux",
- target_os = "netbsd",
- target_os = "openbsd"
-))]
-#[pyattr]
-use libc::O_RSYNC;
+#[cfg(target_os = "linux")]
+#[pyattr]
+use libc::O_RSYNC;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "macos" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{SEEK_DATA, SEEK_HOLE}; | ||||||||||||||||||||||||
| use libc::{RTLD_NODELETE, SEEK_DATA, SEEK_HOLE}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(not(any(target_os = "redox", target_os = "freebsd")))] | ||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "netbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::O_DSYNC; | ||||||||||||||||||||||||
| use libc::O_DIRECT; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "netbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{O_CLOEXEC, O_NONBLOCK, WNOHANG}; | ||||||||||||||||||||||||
| use libc::RTLD_NOLOAD; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(target_os = "macos")] | ||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "openbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{O_EVTONLY, O_FSYNC, O_NOFOLLOW_ANY, O_SYMLINK}; | ||||||||||||||||||||||||
| use libc::O_DSYNC; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(not(target_os = "redox"))] | ||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "openbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{O_NDELAY, O_NOCTTY}; | ||||||||||||||||||||||||
| use libc::SCHED_OTHER; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "openbsd", | ||||||||||||||||||||||||
| target_os = "redox" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL, RTLD_NOW}; | ||||||||||||||||||||||||
| use libc::{O_EXLOCK, O_FSYNC, O_SHLOCK}; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(target_os = "linux")] | ||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "openbsd" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{GRND_NONBLOCK, GRND_RANDOM}; | ||||||||||||||||||||||||
| use libc::{ | ||||||||||||||||||||||||
| CLD_CONTINUED, CLD_DUMPED, CLD_EXITED, CLD_KILLED, CLD_STOPPED, CLD_TRAPPED, F_LOCK, | ||||||||||||||||||||||||
| F_TEST, F_TLOCK, F_ULOCK, O_NDELAY, O_NOCTTY, O_SYNC, P_ALL, P_PGID, P_PID, SCHED_FIFO, | ||||||||||||||||||||||||
| SCHED_RR, | ||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "openbsd", | ||||||||||||||||||||||||
| target_os = "redox" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| use libc::{O_ASYNC, WEXITED, WNOWAIT, WSTOPPED}; | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const EX_OK: i8 = exitcode::OK as i8; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -129,49 +266,6 @@ pub mod module { | |||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const EX_CONFIG: i8 = exitcode::CONFIG as i8; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "macos" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const SCHED_RR: i32 = libc::SCHED_RR; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "android", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "macos" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const SCHED_FIFO: i32 = libc::SCHED_FIFO; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any( | ||||||||||||||||||||||||
| target_os = "macos", | ||||||||||||||||||||||||
| target_os = "linux", | ||||||||||||||||||||||||
| target_os = "freebsd", | ||||||||||||||||||||||||
| target_os = "dragonfly", | ||||||||||||||||||||||||
| target_os = "netbsd", | ||||||||||||||||||||||||
| target_os = "macos" | ||||||||||||||||||||||||
| ))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const SCHED_OTHER: i32 = libc::SCHED_OTHER; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const SCHED_IDLE: i32 = libc::SCHED_IDLE; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any(target_os = "linux", target_os = "android"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const SCHED_BATCH: i32 = libc::SCHED_BATCH; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "macos"))] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const POSIX_SPAWN_OPEN: i32 = PosixSpawnFileActionIdentifier::Open as i32; | ||||||||||||||||||||||||
|
|
@@ -184,10 +278,6 @@ pub mod module { | |||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const POSIX_SPAWN_DUP2: i32 = PosixSpawnFileActionIdentifier::Dup2 as i32; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| #[cfg(target_os = "macos")] | ||||||||||||||||||||||||
| #[pyattr] | ||||||||||||||||||||||||
| const _COPYFILE_DATA: u32 = 1 << 3; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| impl TryFromObject for BorrowedFd<'_> { | ||||||||||||||||||||||||
| fn try_from_object(vm: &VirtualMachine, obj: PyObjectRef) -> PyResult<Self> { | ||||||||||||||||||||||||
| let fd = i32::try_from_object(vm, obj)?; | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXTRAS may be silently dropped when their group doesn’t already exist
EXTRASare only merged into already-existing groups. If a group like {"macos"} has no other members, its extras (e.g., COPYFILE_DATA) won’t be emitted. Ensure extras create their group.Apply this diff:
🤖 Prompt for AI Agents