Skip to content

Commit 8e4f6d2

Browse files
authored
host_env: export SIG*, sysconf, CLOCK_*, unix socket names (#8790)
* host_env: export SIG*, sysconf, CLOCK_*, unix socket names Re-export signal numbers, pathconf/sysconf names, clock ids, and the unix socket integers the VM still took from libc. Assisted-by: Claude * stdlib: take SIG*, sysconf, CLOCK_*, socket names from host_env signal, posix pathconf/sysconf enums, time clock ids, and the shared socket pyattrs re-export host_env instead of libc. Assisted-by: Claude * host_env: export remaining socket integers and Windows SHUT_* Alias WinSock SD_* as SHUT_* so the shared pyattr names resolve. Re-export the rest of the libc socket integers the VM still took from `use libc as c`. Assisted-by: Claude * stdlib: take remaining socket pyattrs from host_env Module integer names come from host_env. Types and syscalls stay on libc / WinSock. Assisted-by: Claude * stdlib: drop unused Windows socket constant imports pyattrs now take those names from host_env. Keep only the syscall names the shared body still reads as c::. Assisted-by: Claude
1 parent e4984d5 commit 8e4f6d2

8 files changed

Lines changed: 794 additions & 217 deletions

File tree

‎crates/host_env/src/posix.rs‎

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,143 @@ pub use libc::{UTIME_NOW, UTIME_OMIT};
172172
#[cfg(target_os = "freebsd")]
173173
pub use libc::{SF_MNOWAIT, SF_NOCACHE, SF_NODISKIO, SF_SYNC};
174174

175+
/// `pathconf` / `sysconf` names. The VM enum discriminants still took these
176+
/// from `libc`.
177+
#[cfg(unix)]
178+
pub use libc::{
179+
_PC_CHOWN_RESTRICTED, _PC_LINK_MAX, _PC_MAX_CANON, _PC_MAX_INPUT, _PC_NAME_MAX, _PC_NO_TRUNC,
180+
_PC_PATH_MAX, _PC_PIPE_BUF, _PC_VDISABLE, _SC_ARG_MAX, _SC_CHILD_MAX, _SC_CLK_TCK,
181+
_SC_LOGIN_NAME_MAX, _SC_NGROUPS_MAX, _SC_OPEN_MAX, _SC_PAGE_SIZE, _SC_RE_DUP_MAX,
182+
_SC_STREAM_MAX, _SC_TTY_NAME_MAX, _SC_TZNAME_MAX, _SC_VERSION,
183+
};
184+
185+
#[cfg(any(
186+
target_os = "dragonfly",
187+
target_os = "freebsd",
188+
target_os = "linux",
189+
target_os = "netbsd",
190+
target_os = "openbsd",
191+
target_os = "redox"
192+
))]
193+
pub use libc::_PC_FILESIZEBITS;
194+
195+
#[cfg(any(
196+
target_os = "android",
197+
target_os = "dragonfly",
198+
target_os = "illumos",
199+
target_os = "linux",
200+
target_os = "netbsd",
201+
target_os = "openbsd",
202+
target_os = "redox",
203+
target_os = "solaris"
204+
))]
205+
pub use libc::_PC_2_SYMLINKS;
206+
207+
#[cfg(any(
208+
target_os = "android",
209+
target_os = "dragonfly",
210+
target_os = "freebsd",
211+
target_os = "linux",
212+
target_os = "openbsd",
213+
target_os = "redox"
214+
))]
215+
pub use libc::_PC_ALLOC_SIZE_MIN;
216+
217+
#[cfg(any(
218+
target_os = "android",
219+
target_os = "dragonfly",
220+
target_os = "freebsd",
221+
target_os = "linux",
222+
target_os = "openbsd"
223+
))]
224+
pub use libc::_PC_REC_INCR_XFER_SIZE;
225+
226+
#[cfg(any(
227+
target_os = "android",
228+
target_os = "dragonfly",
229+
target_os = "freebsd",
230+
target_os = "linux",
231+
target_os = "openbsd",
232+
target_os = "redox"
233+
))]
234+
pub use libc::{_PC_REC_MAX_XFER_SIZE, _PC_REC_MIN_XFER_SIZE, _PC_REC_XFER_ALIGN};
235+
236+
#[cfg(any(
237+
target_os = "android",
238+
target_os = "dragonfly",
239+
target_os = "freebsd",
240+
target_os = "illumos",
241+
target_os = "linux",
242+
target_os = "netbsd",
243+
target_os = "openbsd",
244+
target_os = "redox",
245+
target_os = "solaris"
246+
))]
247+
pub use libc::_PC_SYMLINK_MAX;
248+
249+
#[cfg(any(
250+
target_os = "android",
251+
target_os = "dragonfly",
252+
target_os = "freebsd",
253+
target_os = "illumos",
254+
target_os = "linux",
255+
target_os = "openbsd",
256+
target_os = "redox",
257+
target_os = "solaris"
258+
))]
259+
pub use libc::{_PC_ASYNC_IO, _PC_PRIO_IO};
260+
261+
#[cfg(any(
262+
target_os = "android",
263+
target_os = "dragonfly",
264+
target_os = "freebsd",
265+
target_os = "illumos",
266+
target_os = "linux",
267+
target_os = "netbsd",
268+
target_os = "openbsd",
269+
target_os = "redox",
270+
target_os = "solaris"
271+
))]
272+
pub use libc::_PC_SYNC_IO;
273+
274+
#[cfg(any(target_os = "dragonfly", target_os = "openbsd"))]
275+
pub use libc::_PC_TIMESTAMP_RESOLUTION;
276+
277+
#[cfg(all(unix, not(target_os = "redox")))]
278+
pub use libc::{
279+
_SC_2_C_BIND, _SC_2_C_DEV, _SC_2_CHAR_TERM, _SC_2_FORT_DEV, _SC_2_FORT_RUN, _SC_2_LOCALEDEF,
280+
_SC_2_SW_DEV, _SC_2_UPE, _SC_2_VERSION, _SC_AIO_LISTIO_MAX, _SC_AIO_MAX,
281+
_SC_AIO_PRIO_DELTA_MAX, _SC_ASYNCHRONOUS_IO, _SC_ATEXIT_MAX, _SC_BC_BASE_MAX, _SC_BC_DIM_MAX,
282+
_SC_BC_SCALE_MAX, _SC_BC_STRING_MAX, _SC_COLL_WEIGHTS_MAX, _SC_DELAYTIMER_MAX,
283+
_SC_EXPR_NEST_MAX, _SC_FSYNC, _SC_GETGR_R_SIZE_MAX, _SC_GETPW_R_SIZE_MAX, _SC_IOV_MAX,
284+
_SC_JOB_CONTROL, _SC_LINE_MAX, _SC_MAPPED_FILES, _SC_MEMLOCK, _SC_MEMLOCK_RANGE,
285+
_SC_MEMORY_PROTECTION, _SC_MESSAGE_PASSING, _SC_MQ_OPEN_MAX, _SC_MQ_PRIO_MAX,
286+
_SC_NPROCESSORS_CONF, _SC_NPROCESSORS_ONLN, _SC_PHYS_PAGES, _SC_PRIORITIZED_IO,
287+
_SC_PRIORITY_SCHEDULING, _SC_REALTIME_SIGNALS, _SC_RTSIG_MAX, _SC_SAVED_IDS, _SC_SEM_NSEMS_MAX,
288+
_SC_SEM_VALUE_MAX, _SC_SEMAPHORES, _SC_SHARED_MEMORY_OBJECTS, _SC_SIGQUEUE_MAX,
289+
_SC_SYNCHRONIZED_IO, _SC_THREAD_ATTR_STACKADDR, _SC_THREAD_ATTR_STACKSIZE,
290+
_SC_THREAD_DESTRUCTOR_ITERATIONS, _SC_THREAD_KEYS_MAX, _SC_THREAD_PRIO_INHERIT,
291+
_SC_THREAD_PRIO_PROTECT, _SC_THREAD_PRIORITY_SCHEDULING, _SC_THREAD_PROCESS_SHARED,
292+
_SC_THREAD_SAFE_FUNCTIONS, _SC_THREAD_STACK_MIN, _SC_THREAD_THREADS_MAX, _SC_THREADS,
293+
_SC_TIMER_MAX, _SC_TIMERS, _SC_XOPEN_CRYPT, _SC_XOPEN_ENH_I18N, _SC_XOPEN_LEGACY,
294+
_SC_XOPEN_REALTIME, _SC_XOPEN_REALTIME_THREADS, _SC_XOPEN_SHM, _SC_XOPEN_UNIX,
295+
_SC_XOPEN_VERSION, _SC_XOPEN_XCU_VERSION,
296+
};
297+
298+
#[cfg(any(
299+
target_os = "linux",
300+
target_vendor = "apple",
301+
target_os = "netbsd",
302+
target_os = "fuchsia"
303+
))]
304+
pub use libc::{
305+
_SC_PASS_MAX, _SC_XBS5_ILP32_OFF32, _SC_XBS5_ILP32_OFFBIG, _SC_XBS5_LP64_OFF64,
306+
_SC_XBS5_LPBIG_OFFBIG,
307+
};
308+
309+
#[cfg(target_os = "redox")]
310+
pub use libc::{_SC_HOST_NAME_MAX, _SC_SYMLOOP_MAX};
311+
175312
pub struct UnameInfo {
176313
pub sysname: String,
177314
pub nodename: String,

‎crates/host_env/src/signal.rs‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,30 @@ pub const SIG_IGN: libc::sighandler_t = 1;
2020
#[cfg(not(unix))]
2121
pub const SIG_ERR: libc::sighandler_t = -1 as _;
2222

23+
#[cfg(unix)]
24+
pub use libc::{SIG_BLOCK, SIG_SETMASK, SIG_UNBLOCK};
25+
26+
#[cfg(any(unix, windows))]
27+
pub use libc::{SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM};
28+
29+
#[cfg(unix)]
30+
pub use libc::{
31+
SIGALRM, SIGBUS, SIGCHLD, SIGCONT, SIGHUP, SIGIO, SIGKILL, SIGPIPE, SIGPROF, SIGQUIT, SIGSTOP,
32+
SIGSYS, SIGTRAP, SIGTSTP, SIGTTIN, SIGTTOU, SIGURG, SIGUSR1, SIGUSR2, SIGVTALRM, SIGWINCH,
33+
SIGXCPU, SIGXFSZ,
34+
};
35+
36+
#[cfg(all(
37+
unix,
38+
not(any(
39+
target_vendor = "apple",
40+
target_os = "openbsd",
41+
target_os = "freebsd",
42+
target_os = "netbsd"
43+
))
44+
))]
45+
pub use libc::{SIGPWR, SIGSTKFLT};
46+
2347
#[cfg(all(unix, not(target_os = "android")))]
2448
pub use libc::{ITIMER_PROF, ITIMER_REAL, ITIMER_VIRTUAL};
2549

0 commit comments

Comments
 (0)