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