Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions scripts/libc_posix.py
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()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

EXTRAS may be silently dropped when their group doesn’t already exist

EXTRAS are 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:

-    group_consts = {grp: v | EXTRAS.get(grp, set()) for grp, v in group_consts.items()}
+    # Merge extras and ensure their groups exist even if empty
+    for grp, extras in EXTRAS.items():
+        group_consts.setdefault(grp, set()).update(extras)
🤖 Prompt for AI Agents
In scripts/libc_posix.py around line 112, EXTRAS are only merged into groups
that already exist so groups present only in EXTRAS will be dropped; modify the
merge to ensure every key in EXTRAS is present by taking the union of
group_consts.keys() and EXTRAS.keys() and then for each group produce the union
of existing values and EXTRAS[group] (or use group_consts.get(group, set()) |
EXTRAS.get(group, set())), so extras create their group instead of being
silently ignored.


code = "\n\n".join(
f"""
{cfg}
#[pyattr]
{use}
""".strip()
for cfg, use in format_groups(group_consts)
)

print(code)


if __name__ == "__main__":
main()
208 changes: 149 additions & 59 deletions vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Split 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:

Which of these constants are exposed by Android bionic's headers: P_PIDFD, O_TMPFILE, O_NOATIME, CLONE_NEWCGROUP?

💡 Result:

O_TMPFILE — yes. [1]
O_NOATIME — yes. [1]
CLONE_NEWCGROUP — yes. [2]
P_PIDFD — not exposed in bionic's public headers (bionic exposes pidfd APIs in <sys/pidfd.h>, but P_PIDFD itself is not defined there). [3][4]

Sources:

  • asm-generic fcntl.h (O_TMPFILE, O_NOATIME). [1]
  • linux sched.h (CLONE_NEWCGROUP). [2]
  • bionic <sys/pidfd.h> (pidfd APIs). [3]
  • linux/uapi pidfd header / userland references (shows pidfd flags but P_PIDFD is not in bionic headers). [4]

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 #[cfg(target_os = "linux")] block.

🤖 Prompt for AI Agents
In vm/src/stdlib/posix.rs around lines 65 to 74, the import currently excludes
the entire block on non-linux targets but the review notes P_PIDFD is the only
symbol missing on Android; update the cfg so O_TMPFILE, O_NOATIME and
CLONE_NEWCGROUP (and the other listed constants) remain under
#[cfg(any(target_os = "android", target_os = "linux"))] while moving P_PIDFD
into a separate #[cfg(target_os = "linux")] import line; adjust the use/libc
import(s) accordingly so all safe symbols are available on Android but P_PIDFD
is only imported for Linux.

#[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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Split memfd flags from POSIX_FADV_*; avoid FreeBSD/Android build breaks

  • memfd flags (MFD_*) are Linux/Android-only; FreeBSD doesn’t define MFD_HUGETLB/ALLOW_SEALING.
  • The POSIX_FADV_* advice values are fine on these Unixes.

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
In vm/src/stdlib/posix.rs around lines 86 to 92, the import groups mix
Linux/Android-only MFD_* constants with POSIX_FADV_* constants which exist on
FreeBSD too; split the imports so MFD_ALLOW_SEALING, MFD_CLOEXEC and MFD_HUGETLB
are imported only under #[cfg(any(target_os = "android", target_os = "linux"))]
(or target_os = "linux" if Android handled separately), while
POSIX_FADV_DONTNEED, POSIX_FADV_NOREUSE, POSIX_FADV_NORMAL, POSIX_FADV_RANDOM,
POSIX_FADV_SEQUENTIAL and POSIX_FADV_WILLNEED remain under #[cfg(any(target_os =
"android", target_os = "freebsd", target_os = "linux"))]; update the use libc::{
... } lines accordingly so FreeBSD builds do not reference undefined MFD_*
symbols.

#[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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[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};
#[cfg(any(target_os = "android", target_os = "linux"))]
#[pyattr]
use libc::{TFD_CLOEXEC, TFD_NONBLOCK, TFD_TIMER_ABSTIME, TFD_TIMER_CANCEL_ON_SET};
🤖 Prompt for AI Agents
In vm/src/stdlib/posix.rs around lines 93 to 96, the cfg currently includes
netbsd but the TFD_* timerfd constants are only available on Linux and Android;
remove target_os = "netbsd" from the cfg so it reads cfg(any(target_os =
"android", target_os = "linux")) and keep the #[pyattr] use libc::{TFD_CLOEXEC,
TFD_NONBLOCK, TFD_TIMER_ABSTIME, TFD_TIMER_CANCEL_ON_SET}; unchanged.

#[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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "redox"
))]
#[pyattr]
use libc::O_PATH;
#[cfg(any(target_os = "android", target_os = "linux"))]
#[pyattr]
use libc::O_PATH;
🤖 Prompt for AI Agents
In vm/src/stdlib/posix.rs around lines 110 to 118, the current cfg block exposes
libc::O_PATH for multiple OSes although O_PATH is Linux-specific; restrict the
import to Linux only by changing the cfg to target_os = "linux" (or add a cfg-if
that imports O_PATH only when target_os == "linux") and remove it from
freebsd/redox/android targets so the code compiles on those platforms without
referencing a non-existent symbol.

#[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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

❓ Verification inconclusive

Tighten 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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested 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;
🤖 Prompt for AI Agents
In vm/src/stdlib/posix.rs around lines 119 to 127, the cfg currently enables
importing libc::O_RSYNC for Android, Linux, NetBSD, and OpenBSD although O_RSYNC
is defined only on Linux; update the cfg to target_os = "linux" only (remove
Android, NetBSD and OpenBSD) so the use libc::O_RSYNC is compiled only on Linux,
and add a comment noting you can re-enable Android if/when bionic on your
minimum API level exposes O_RSYNC.

#[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;

Expand Down Expand Up @@ -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;
Expand All @@ -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)?;
Expand Down
Loading