Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Add consts from unix
  • Loading branch information
ShaharNaveh committed Aug 31, 2025
commit 29c40ae66b2d762fb89f939e35c369dda9518689
7 changes: 5 additions & 2 deletions scripts/libc_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"SEEK_CUR",
"SEEK_END",
"SEEK_SET",
"WNOHANG",
# Functions, not consts
"WCOREDUMP",
"WIFCONTINUED",
Expand Down Expand Up @@ -63,6 +62,7 @@ def build_url(fname: str) -> str:
"openbsd": "openbsd",
"redox": "redox",
# solaris?
"unix": "unix",
}


Expand All @@ -78,7 +78,10 @@ def format_groups(groups: dict) -> "Iterator[tuple[str, str]]":
for targets, consts in sorted(
groups.items(), key=lambda t: (len(t[0]), sorted(t[0]))
):
cond = ", ".join(f'target_os = "{target_os}"' for target_os in sorted(targets))
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})]"
Expand Down
19 changes: 8 additions & 11 deletions vm/src/stdlib/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ pub mod module {
};
use strum_macros::{EnumIter, EnumString};

#[cfg(target_os = "android")]
#[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, WUNTRACED, X_OK,
};

#[cfg(target_os = "freebsd")]
#[pyattr]
use libc::{MFD_HUGE_MASK, SF_MNOWAIT, SF_NOCACHE, SF_NODISKIO, SF_SYNC};
Expand All @@ -79,6 +72,14 @@ pub mod module {
SPLICE_F_NONBLOCK,
};

#[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;
Expand Down Expand Up @@ -217,10 +218,6 @@ pub mod module {
))]
#[pyattr]
use libc::{O_ASYNC, WEXITED, WNOWAIT, WSTOPPED};

#[pyattr]
use libc::WNOHANG;

#[pyattr]
const EX_OK: i8 = exitcode::OK as i8;

Expand Down
Loading