From 8b916030bc4403705a0743f6697dcc91f52cc2c7 Mon Sep 17 00:00:00 2001 From: TheNotary Date: Wed, 8 Oct 2025 08:17:35 -0500 Subject: [PATCH 1/2] adds missing types, consts, and extern C refs for reading characters immediately from terminal --- src/wasi/wasix.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/wasi/wasix.rs b/src/wasi/wasix.rs index 5e03e0d7bad9f..2eb391bdf03b8 100644 --- a/src/wasi/wasix.rs +++ b/src/wasi/wasix.rs @@ -6,6 +6,9 @@ pub type in_addr_t = u32; pub type in_port_t = u16; pub type sa_family_t = u16; pub type sa_type_t = u16; +pub type cc_t = ::c_uint; +pub type speed_t = ::c_ulong; +pub type tcflag_t = ::c_uint; s! { #[repr(C)] @@ -263,6 +266,22 @@ s! { __policy: ::c_int, __pad: [::c_int; 16], } + + pub struct fd_set { + __nfds: usize, + __fds: [c_int; FD_SETSIZE as usize], + } + + pub struct termios { + pub c_iflag: ::tcflag_t, + pub c_oflag: ::tcflag_t, + pub c_cflag: ::tcflag_t, + pub c_lflag: ::tcflag_t, + pub c_line: ::cc_t, + pub c_cc: [::cc_t; ::NCCS], + pub c_ispeed: ::speed_t, + pub c_ospeed: ::speed_t, + } } pub const PTHREAD_STACK_MIN: ::size_t = 2048; @@ -739,6 +758,13 @@ pub const SA_NODEFER: ::c_int = 0x40000000; pub const SA_RESETHAND: ::c_int = 0x80000000; pub const SA_RESTORER: ::c_int = 0x04000000; +pub const ECHO: ::tcflag_t = 0x00000008; +pub const ICANON: ::tcflag_t = 0x00000002; +pub const TCSANOW: ::c_int = 0; +pub const NCCS: usize = 32; +pub const VTIME: usize = 5; +pub const VMIN: usize = 6; + #[cfg_attr( feature = "rustc-dep-of-std", link( @@ -931,6 +957,9 @@ extern "C" { pub fn sigprocmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int; pub fn sigpending(set: *mut sigset_t) -> ::c_int; + pub fn tcgetattr(fd: ::c_int, termios: *mut ::termios) -> ::c_int; + pub fn tcsetattr(fd: ::c_int, optional_actions: ::c_int, termios: *const ::termios) -> ::c_int; + pub fn pthread_self() -> ::pthread_t; pub fn pthread_join(native: ::pthread_t, value: *mut *mut ::c_void) -> ::c_int; pub fn pthread_exit(value: *mut ::c_void) -> !; From 917434b78d61345b6bb134e91902ae66aea976cb Mon Sep 17 00:00:00 2001 From: TheNotary Date: Wed, 15 Oct 2025 16:41:59 -0500 Subject: [PATCH 2/2] sets cc_t as c_uint and speed_t as c_uint --- src/wasi/wasix.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wasi/wasix.rs b/src/wasi/wasix.rs index 2eb391bdf03b8..755aa4d76b8e9 100644 --- a/src/wasi/wasix.rs +++ b/src/wasi/wasix.rs @@ -6,8 +6,8 @@ pub type in_addr_t = u32; pub type in_port_t = u16; pub type sa_family_t = u16; pub type sa_type_t = u16; -pub type cc_t = ::c_uint; -pub type speed_t = ::c_ulong; +pub type cc_t = ::c_uchar; +pub type speed_t = ::c_uint; pub type tcflag_t = ::c_uint; s! {