@@ -458,6 +458,37 @@ pub const NOEXPR: ::nl_item = 0x50001;
458
458
pub const YESSTR : :: nl_item = 0x50002 ;
459
459
pub const NOSTR : :: nl_item = 0x50003 ;
460
460
461
+ pub const SOCK_DGRAM : :: c_int = __WASI_SOCK_TYPE_SOCKET_DGRAM;
462
+ pub const SOCK_STREAM : :: c_int = __WASI_SOCK_TYPE_SOCKET_STREAM;
463
+ pub const SOCK_RAW : :: c_int = __WASI_SOCK_TYPE_SOCKET_RAW;
464
+ pub const SOCK_SEQPACKET : :: c_int = __WASI_SOCK_TYPE_SOCKET_SEQPACKET;
465
+
466
+ pub const MSG_PEEK : :: c_int = 0x0002 ;
467
+ pub const MSG_NOSIGNAL : :: c_int = 0x4000 ;
468
+ pub const MSG_CMSG_CLOEXEC : :: c_int = 0x40000000 ;
469
+
470
+ pub const AF_UNSPEC : :: c_int = 0 ;
471
+ pub const AF_INET : :: c_int = 1 ;
472
+ pub const AF_INET6 : :: c_int = 2 ;
473
+ pub const AF_UNIX : :: c_int = 3 ;
474
+
475
+ pub const SO_RCVTIMEO : :: c_int = __WASI_SOCK_OPTION_RECV_TIMEOUT;
476
+ pub const SO_SNDTIMEO : :: c_int = __WASI_SOCK_OPTION_SEND_TIMEOUT;
477
+
478
+ pub const PTHREAD_STACK_MIN : :: size_t = 2048 ;
479
+
480
+ pub fn WIFSIGNALED ( status : :: c_int ) -> bool {
481
+ ( ( status & 0x7f ) + 1 ) as i8 >= 2
482
+ }
483
+
484
+ pub fn WCOREDUMP ( status : :: c_int ) -> bool {
485
+ ( status & 0x80 ) != 0
486
+ }
487
+
488
+ pub fn WIFCONTINUED ( status : :: c_int ) -> bool {
489
+ status == 0xffff
490
+ }
491
+
461
492
f ! {
462
493
pub fn FD_ISSET ( fd: :: c_int, set: * const fd_set) -> bool {
463
494
let set = & * set;
@@ -494,6 +525,49 @@ f! {
494
525
link( name = "c" , cfg( not( target_feature = "crt-static" ) ) )
495
526
) ]
496
527
extern "C" {
528
+ pub fn bind ( socket : :: c_int , addr : * const :: sockaddr , addrlen : :: socklen_t ) -> :: c_int ;
529
+ pub fn connect ( socket : :: c_int , addr : * const sockaddr , addrlen : socklen_t ) -> :: c_int ;
530
+ pub fn getsockname ( socket : :: c_int , addr : * mut sockaddr , addrlen : * mut socklen_t ) -> :: c_int ;
531
+ pub fn getpeername ( socket : :: c_int , addr : * mut sockaddr , addrlen : * mut socklen_t ) -> :: c_int ;
532
+ pub fn recvfrom (
533
+ socket : :: c_int ,
534
+ buffer : * mut :: c_void ,
535
+ length : :: size_t ,
536
+ flags : :: c_int ,
537
+ addr : * mut :: sockaddr ,
538
+ addrlen : * mut :: socklen_t ,
539
+ ) -> :: ssize_t ;
540
+ pub fn sendto (
541
+ socket : :: c_int ,
542
+ buffer : * const :: c_void ,
543
+ length : :: size_t ,
544
+ flags : :: c_int ,
545
+ addr : * const sockaddr ,
546
+ addrlen : socklen_t ,
547
+ ) -> :: ssize_t ;
548
+ pub fn recvmsg ( socket : :: c_int , msg : * mut :: msghdr , flags : :: c_int ) -> :: ssize_t ;
549
+ pub fn sendmsg ( socket : :: c_int , msg : * const :: msghdr , flags : :: c_int ) -> :: ssize_t ;
550
+ pub fn dup ( fd : :: c_int ) -> :: c_int ;
551
+ pub fn dup2 ( src : :: c_int , dst : :: c_int ) -> :: c_int ;
552
+ pub fn execvp ( c : * const :: c_char , argv : * const * const :: c_char ) -> :: c_int ;
553
+
554
+ // Thread functions
555
+ pub fn pthread_create (
556
+ native : * mut :: pthread_t ,
557
+ attr : * const :: pthread_attr_t ,
558
+ f : extern "C" fn ( * mut :: c_void ) -> * mut :: c_void ,
559
+ value : * mut :: c_void ,
560
+ ) -> :: c_int ;
561
+ pub fn pthread_attr_init ( attr : * mut :: pthread_attr_t ) -> :: c_int ;
562
+ pub fn pthread_attr_destroy ( attr : * mut :: pthread_attr_t ) -> :: c_int ;
563
+ pub fn pthread_attr_setstacksize ( attr : * mut :: pthread_attr_t , stack_size : :: size_t ) -> :: c_int ;
564
+ pub fn pthread_join ( native : :: pthread_t , value : * mut * mut :: c_void ) -> :: c_int ;
565
+ pub fn pthread_detach ( thread : :: pthread_t ) -> :: c_int ;
566
+
567
+ // Signal handling
568
+ pub fn sigemptyset ( set : * mut sigset_t ) -> :: c_int ;
569
+ pub fn sigaddset ( set : * mut sigset_t , signum : :: c_int ) -> :: c_int ;
570
+
497
571
pub fn _Exit ( code : c_int ) -> !;
498
572
pub fn _exit ( code : c_int ) -> !;
499
573
pub fn abort ( ) -> !;
@@ -880,9 +954,6 @@ extern "C" {
880
954
pub fn __errno_location ( ) -> * mut :: c_int ;
881
955
}
882
956
883
- cfg_if ! {
884
- if #[ cfg( target_env = "p2" ) ] {
885
- mod p2;
886
- pub use self :: p2:: * ;
887
- }
888
- }
957
+ mod p2;
958
+ pub use self :: p2:: * ;
959
+
0 commit comments