@@ -42,7 +42,13 @@ cfg_if! {
4242pub type socklen_t = u32 ;
4343pub type speed_t = u32 ;
4444pub type suseconds_t = i32 ;
45- pub type tcflag_t = :: c_uint ;
45+ cfg_if ! {
46+ if #[ cfg( target_os = "espidf" ) ] {
47+ pub type tcflag_t = u16 ;
48+ } else {
49+ pub type tcflag_t = :: c_uint;
50+ }
51+ }
4652pub type useconds_t = u32 ;
4753
4854cfg_if ! {
@@ -197,6 +203,10 @@ s! {
197203 pub c_lflag: :: tcflag_t,
198204 pub c_line: :: cc_t,
199205 pub c_cc: [ :: cc_t; :: NCCS ] ,
206+ #[ cfg( target_os = "espidf" ) ]
207+ pub c_ispeed: u32 ,
208+ #[ cfg( target_os = "espidf" ) ]
209+ pub c_ospeed: u32 ,
200210 }
201211
202212 pub struct sem_t { // Unverified
@@ -224,7 +234,24 @@ s! {
224234 }
225235
226236 pub struct pthread_attr_t { // Unverified
227- __size: [ u8 ; __SIZEOF_PTHREAD_ATTR_T]
237+ #[ cfg( not( target_os = "espidf" ) ) ]
238+ __size: [ u8 ; __SIZEOF_PTHREAD_ATTR_T] ,
239+ #[ cfg( target_os = "espidf" ) ]
240+ pub is_initialized: i32 ,
241+ #[ cfg( target_os = "espidf" ) ]
242+ pub stackaddr: * mut crate :: c_void,
243+ #[ cfg( target_os = "espidf" ) ]
244+ pub stacksize: i32 ,
245+ #[ cfg( target_os = "espidf" ) ]
246+ pub contentionscope: i32 ,
247+ #[ cfg( target_os = "espidf" ) ]
248+ pub inheritsched: i32 ,
249+ #[ cfg( target_os = "espidf" ) ]
250+ pub schedpolicy: i32 ,
251+ #[ cfg( target_os = "espidf" ) ]
252+ pub schedparam: i32 ,
253+ #[ cfg( target_os = "espidf" ) ]
254+ pub detachstate: i32 ,
228255 }
229256
230257 pub struct pthread_rwlockattr_t { // Unverified
@@ -241,7 +268,14 @@ pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
241268pub const PTHREAD_RWLOCK_INITIALIZER : pthread_rwlock_t = pthread_rwlock_t {
242269 size : [ __PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T] ,
243270} ;
244- pub const NCCS : usize = 32 ;
271+
272+ cfg_if ! {
273+ if #[ cfg( target_os = "espidf" ) ] {
274+ pub const NCCS : usize = 11 ;
275+ } else {
276+ pub const NCCS : usize = 32 ;
277+ }
278+ }
245279
246280cfg_if ! {
247281 if #[ cfg( target_os = "espidf" ) ] {
@@ -420,7 +454,13 @@ pub const O_SYNC: ::c_int = 8192;
420454pub const O_NONBLOCK : :: c_int = 16384 ;
421455
422456pub const O_ACCMODE : :: c_int = 3 ;
423- pub const O_CLOEXEC : :: c_int = 0x80000 ;
457+ cfg_if ! {
458+ if #[ cfg( target_os = "espidf" ) ] {
459+ pub const O_CLOEXEC : :: c_int = 0x40000 ;
460+ } else {
461+ pub const O_CLOEXEC : :: c_int = 0x80000 ;
462+ }
463+ }
424464
425465pub const RTLD_LAZY : :: c_int = 0x1 ;
426466
@@ -462,7 +502,13 @@ pub const SOL_TCP: ::c_int = 6;
462502
463503pub const PF_UNSPEC : :: c_int = 0 ;
464504pub const PF_INET : :: c_int = 2 ;
465- pub const PF_INET6 : :: c_int = 23 ;
505+ cfg_if ! {
506+ if #[ cfg( target_os = "espidf" ) ] {
507+ pub const PF_INET6 : :: c_int = 10 ;
508+ } else {
509+ pub const PF_INET6 : :: c_int = 23 ;
510+ }
511+ }
466512
467513pub const AF_UNSPEC : :: c_int = 0 ;
468514pub const AF_INET : :: c_int = 2 ;
@@ -547,6 +593,9 @@ cfg_if! {
547593 if #[ cfg( target_os = "vita" ) ] {
548594 pub const TCP_NODELAY : :: c_int = 1 ;
549595 pub const TCP_MAXSEG : :: c_int = 2 ;
596+ } else if #[ cfg( target_os = "espidf" ) ] {
597+ pub const TCP_NODELAY : :: c_int = 1 ;
598+ pub const TCP_MAXSEG : :: c_int = 8194 ;
550599 } else {
551600 pub const TCP_NODELAY : :: c_int = 8193 ;
552601 pub const TCP_MAXSEG : :: c_int = 8194 ;
@@ -555,69 +604,131 @@ cfg_if! {
555604
556605pub const TCP_NOPUSH : :: c_int = 4 ;
557606pub const TCP_NOOPT : :: c_int = 8 ;
558- pub const TCP_KEEPIDLE : :: c_int = 256 ;
559- pub const TCP_KEEPINTVL : :: c_int = 512 ;
560- pub const TCP_KEEPCNT : :: c_int = 1024 ;
607+ cfg_if ! {
608+ if #[ cfg( target_os = "espidf" ) ] {
609+ pub const TCP_KEEPIDLE : :: c_int = 3 ;
610+ pub const TCP_KEEPINTVL : :: c_int = 4 ;
611+ pub const TCP_KEEPCNT : :: c_int = 5 ;
612+ } else {
613+ pub const TCP_KEEPIDLE : :: c_int = 256 ;
614+ pub const TCP_KEEPINTVL : :: c_int = 512 ;
615+ pub const TCP_KEEPCNT : :: c_int = 1024 ;
616+ }
617+ }
561618
562619cfg_if ! {
563620 if #[ cfg( target_os = "horizon" ) ] {
564621 pub const IP_TOS : :: c_int = 7 ;
622+ } else if #[ cfg( target_os = "espidf" ) ] {
623+ pub const IP_TOS : :: c_int = 1 ;
565624 } else {
566625 pub const IP_TOS : :: c_int = 3 ;
567626 }
568627}
569628cfg_if ! {
570629 if #[ cfg( target_os = "vita" ) ] {
571630 pub const IP_TTL : :: c_int = 4 ;
631+ } else if #[ cfg( target_os = "espidf" ) ] {
632+ pub const IP_TTL : :: c_int = 2 ;
572633 } else {
573634 pub const IP_TTL : :: c_int = 8 ;
574635 }
575636}
576- pub const IP_MULTICAST_IF : :: c_int = 9 ;
577- pub const IP_MULTICAST_TTL : :: c_int = 10 ;
578- pub const IP_MULTICAST_LOOP : :: c_int = 11 ;
637+
638+ cfg_if ! {
639+ if #[ cfg( target_os = "espidf" ) ] {
640+ pub const IP_MULTICAST_IF : :: c_int = 6 ;
641+ pub const IP_MULTICAST_TTL : :: c_int = 5 ;
642+ pub const IP_MULTICAST_LOOP : :: c_int = 7 ;
643+ } else {
644+ pub const IP_MULTICAST_IF : :: c_int = 9 ;
645+ pub const IP_MULTICAST_TTL : :: c_int = 10 ;
646+ pub const IP_MULTICAST_LOOP : :: c_int = 11 ;
647+ }
648+ }
649+
579650cfg_if ! {
580651 if #[ cfg( target_os = "vita" ) ] {
581652 pub const IP_ADD_MEMBERSHIP : :: c_int = 12 ;
582653 pub const IP_DROP_MEMBERSHIP : :: c_int = 13 ;
654+ } else if #[ cfg( target_os = "espidf" ) ] {
655+ pub const IP_ADD_MEMBERSHIP : :: c_int = 3 ;
656+ pub const IP_DROP_MEMBERSHIP : :: c_int = 4 ;
583657 } else {
584658 pub const IP_ADD_MEMBERSHIP : :: c_int = 11 ;
585659 pub const IP_DROP_MEMBERSHIP : :: c_int = 12 ;
586660 }
587661}
588662pub const IPV6_UNICAST_HOPS : :: c_int = 4 ;
589- pub const IPV6_MULTICAST_IF : :: c_int = 9 ;
590- pub const IPV6_MULTICAST_HOPS : :: c_int = 10 ;
591- pub const IPV6_MULTICAST_LOOP : :: c_int = 11 ;
663+ cfg_if ! {
664+ if #[ cfg( target_os = "espidf" ) ] {
665+ pub const IPV6_MULTICAST_IF : :: c_int = 768 ;
666+ pub const IPV6_MULTICAST_HOPS : :: c_int = 769 ;
667+ pub const IPV6_MULTICAST_LOOP : :: c_int = 770 ;
668+ } else {
669+ pub const IPV6_MULTICAST_IF : :: c_int = 9 ;
670+ pub const IPV6_MULTICAST_HOPS : :: c_int = 10 ;
671+ pub const IPV6_MULTICAST_LOOP : :: c_int = 11 ;
672+ }
673+ }
592674pub const IPV6_V6ONLY : :: c_int = 27 ;
593675pub const IPV6_JOIN_GROUP : :: c_int = 12 ;
594676pub const IPV6_LEAVE_GROUP : :: c_int = 13 ;
595677pub const IPV6_ADD_MEMBERSHIP : :: c_int = 12 ;
596678pub const IPV6_DROP_MEMBERSHIP : :: c_int = 13 ;
597679
598- pub const HOST_NOT_FOUND : :: c_int = 1 ;
599- pub const NO_DATA : :: c_int = 2 ;
680+ cfg_if ! {
681+ if #[ cfg( target_os = "espidf" ) ] {
682+ pub const HOST_NOT_FOUND : :: c_int = 210 ;
683+ pub const NO_DATA : :: c_int = 211 ;
684+ pub const NO_RECOVERY : :: c_int = 212 ;
685+ pub const TRY_AGAIN : :: c_int = 213 ;
686+
687+ } else {
688+ pub const HOST_NOT_FOUND : :: c_int = 1 ;
689+ pub const NO_DATA : :: c_int = 2 ;
690+ pub const NO_RECOVERY : :: c_int = 3 ;
691+ pub const TRY_AGAIN : :: c_int = 4 ;
692+ }
693+ }
600694pub const NO_ADDRESS : :: c_int = 2 ;
601- pub const NO_RECOVERY : :: c_int = 3 ;
602- pub const TRY_AGAIN : :: c_int = 4 ;
603695
604696pub const AI_PASSIVE : :: c_int = 1 ;
605697pub const AI_CANONNAME : :: c_int = 2 ;
606698pub const AI_NUMERICHOST : :: c_int = 4 ;
607- pub const AI_NUMERICSERV : :: c_int = 0 ;
608- pub const AI_ADDRCONFIG : :: c_int = 0 ;
699+ cfg_if ! {
700+ if #[ cfg( target_os = "espidf" ) ] {
701+ pub const AI_NUMERICSERV : :: c_int = 8 ;
702+ pub const AI_ADDRCONFIG : :: c_int = 64 ;
703+ } else {
704+ pub const AI_NUMERICSERV : :: c_int = 0 ;
705+ pub const AI_ADDRCONFIG : :: c_int = 0 ;
706+ }
707+ }
609708
610709pub const NI_MAXHOST : :: c_int = 1025 ;
611710pub const NI_MAXSERV : :: c_int = 32 ;
612711pub const NI_NOFQDN : :: c_int = 1 ;
613712pub const NI_NUMERICHOST : :: c_int = 2 ;
614713pub const NI_NAMEREQD : :: c_int = 4 ;
615- pub const NI_NUMERICSERV : :: c_int = 0 ;
616- pub const NI_DGRAM : :: c_int = 0 ;
714+ cfg_if ! {
715+ if #[ cfg( target_os = "espidf" ) ] {
716+ pub const NI_NUMERICSERV : :: c_int = 8 ;
717+ pub const NI_DGRAM : :: c_int = 16 ;
718+ } else {
719+ pub const NI_NUMERICSERV : :: c_int = 0 ;
720+ pub const NI_DGRAM : :: c_int = 0 ;
721+ }
722+ }
617723
618724cfg_if ! {
619725 // Defined in vita/mod.rs for "vita"
620- if #[ cfg( not( target_os = "vita" ) ) ] {
726+ if #[ cfg( target_os = "espidf" ) ] {
727+ pub const EAI_FAMILY : :: c_int = 204 ;
728+ pub const EAI_MEMORY : :: c_int = 203 ;
729+ pub const EAI_NONAME : :: c_int = 200 ;
730+ pub const EAI_SOCKTYPE : :: c_int = 10 ;
731+ } else if #[ cfg( not( target_os = "vita" ) ) ] {
621732 pub const EAI_FAMILY : :: c_int = -303 ;
622733 pub const EAI_MEMORY : :: c_int = -304 ;
623734 pub const EAI_NONAME : :: c_int = -305 ;
0 commit comments