@@ -175,6 +175,11 @@ s! {
175
175
pub st_ctim: timespec,
176
176
__reserved: [ c_longlong; 3 ] ,
177
177
}
178
+
179
+ pub struct fd_set {
180
+ __nfds: usize ,
181
+ __fds: [ c_int; FD_SETSIZE as usize ] ,
182
+ }
178
183
}
179
184
180
185
// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
@@ -442,6 +447,28 @@ pub const NOEXPR: ::nl_item = 0x50001;
442
447
pub const YESSTR : :: nl_item = 0x50002 ;
443
448
pub const NOSTR : :: nl_item = 0x50003 ;
444
449
450
+ f ! {
451
+ pub fn FD_ISSET ( fd: :: c_int, set: * const fd_set) -> bool {
452
+ let set = & * set;
453
+ let n = set. __nfds;
454
+ return set. __fds[ ..n] . iter( ) . any( |p| * p == fd)
455
+ }
456
+
457
+ pub fn FD_SET ( fd: :: c_int, set: * mut fd_set) -> ( ) {
458
+ let set = & mut * set;
459
+ let n = set. __nfds;
460
+ if !set. __fds[ ..n] . iter( ) . any( |p| * p == fd) {
461
+ set. __nfds = n + 1 ;
462
+ set. __fds[ n] = fd;
463
+ }
464
+ }
465
+
466
+ pub fn FD_ZERO ( set: * mut fd_set) -> ( ) {
467
+ ( * set) . __nfds = 0 ;
468
+ return
469
+ }
470
+ }
471
+
445
472
#[ cfg_attr(
446
473
feature = "rustc-dep-of-std" ,
447
474
link(
@@ -737,6 +764,14 @@ extern "C" {
737
764
pub fn nl_langinfo ( item : :: nl_item ) -> * mut :: c_char ;
738
765
pub fn nl_langinfo_l ( item : :: nl_item , loc : :: locale_t ) -> * mut :: c_char ;
739
766
767
+ pub fn select (
768
+ nfds : c_int ,
769
+ readfds : * mut fd_set ,
770
+ writefds : * mut fd_set ,
771
+ errorfds : * mut fd_set ,
772
+ timeout : * const timeval ,
773
+ ) -> c_int ;
774
+
740
775
pub fn __wasilibc_register_preopened_fd ( fd : c_int , path : * const c_char ) -> c_int ;
741
776
pub fn __wasilibc_fd_renumber ( fd : c_int , newfd : c_int ) -> c_int ;
742
777
pub fn __wasilibc_unlinkat ( fd : c_int , path : * const c_char ) -> c_int ;
0 commit comments