Skip to content

Commit 29c40ae

Browse files
committed
Add consts from unix
1 parent e9594c3 commit 29c40ae

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

scripts/libc_posix.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
"SEEK_CUR",
2929
"SEEK_END",
3030
"SEEK_SET",
31-
"WNOHANG",
3231
# Functions, not consts
3332
"WCOREDUMP",
3433
"WIFCONTINUED",
@@ -63,6 +62,7 @@ def build_url(fname: str) -> str:
6362
"openbsd": "openbsd",
6463
"redox": "redox",
6564
# solaris?
65+
"unix": "unix",
6666
}
6767

6868

@@ -78,7 +78,10 @@ def format_groups(groups: dict) -> "Iterator[tuple[str, str]]":
7878
for targets, consts in sorted(
7979
groups.items(), key=lambda t: (len(t[0]), sorted(t[0]))
8080
):
81-
cond = ", ".join(f'target_os = "{target_os}"' for target_os in sorted(targets))
81+
cond = ", ".join(
82+
f'target_os = "{target_os}"' if target_os != "unix" else target_os
83+
for target_os in sorted(targets)
84+
)
8285
if len(targets) > 1:
8386
cond = f"any({cond})"
8487
cfg = f"#[cfg({cond})]"

vm/src/stdlib/posix.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,6 @@ pub mod module {
4747
};
4848
use strum_macros::{EnumIter, EnumString};
4949

50-
#[cfg(target_os = "android")]
51-
#[pyattr]
52-
use libc::{
53-
F_OK, O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW, O_NONBLOCK, PRIO_PGRP, PRIO_PROCESS, PRIO_USER,
54-
R_OK, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL, RTLD_NOW, W_OK, WCONTINUED, WUNTRACED, X_OK,
55-
};
56-
5750
#[cfg(target_os = "freebsd")]
5851
#[pyattr]
5952
use libc::{MFD_HUGE_MASK, SF_MNOWAIT, SF_NOCACHE, SF_NODISKIO, SF_SYNC};
@@ -79,6 +72,14 @@ pub mod module {
7972
SPLICE_F_NONBLOCK,
8073
};
8174

75+
#[cfg(any(target_os = "android", unix))]
76+
#[pyattr]
77+
use libc::{
78+
F_OK, O_CLOEXEC, O_DIRECTORY, O_NOFOLLOW, O_NONBLOCK, PRIO_PGRP, PRIO_PROCESS, PRIO_USER,
79+
R_OK, RTLD_GLOBAL, RTLD_LAZY, RTLD_LOCAL, RTLD_NOW, W_OK, WCONTINUED, WNOHANG, WUNTRACED,
80+
X_OK,
81+
};
82+
8283
#[cfg(any(target_os = "macos", target_os = "redox"))]
8384
#[pyattr]
8485
use libc::O_SYMLINK;
@@ -217,10 +218,6 @@ pub mod module {
217218
))]
218219
#[pyattr]
219220
use libc::{O_ASYNC, WEXITED, WNOWAIT, WSTOPPED};
220-
221-
#[pyattr]
222-
use libc::WNOHANG;
223-
224221
#[pyattr]
225222
const EX_OK: i8 = exitcode::OK as i8;
226223

0 commit comments

Comments
 (0)