@@ -33,6 +33,10 @@ pub type wchar_t = i32;
3333pub type nl_item = c_int ;
3434pub type __wasi_rights_t = u64 ;
3535pub type locale_t = * mut __locale_struct ;
36+ pub type pthread_t = * mut c_void ;
37+ pub type pthread_once_t = c_int ;
38+ pub type pthread_key_t = c_uint ;
39+ pub type pthread_spinlock_t = c_int ;
3640
3741s_no_extra_traits ! {
3842 #[ repr( align( 16 ) ) ]
@@ -170,6 +174,47 @@ s! {
170174 __nfds: usize ,
171175 __fds: [ c_int; FD_SETSIZE as usize ] ,
172176 }
177+
178+ #[ repr( align( 4 ) ) ]
179+ pub struct pthread_attr_t {
180+ size: [ u8 ; 36 ] ,
181+ }
182+
183+ pub struct pthread_mutexattr_t {
184+ __attr: c_uint,
185+ }
186+
187+ pub struct pthread_condattr_t {
188+ __attr: c_uint,
189+ }
190+
191+ pub struct pthread_barrierattr_t {
192+ __attr: c_uint,
193+ }
194+
195+ pub struct pthread_rwlockattr_t {
196+ __attr: [ c_uint; 2 ] ,
197+ }
198+
199+ #[ repr( align( 4 ) ) ]
200+ pub struct pthread_cond_t {
201+ size: [ u8 ; 48 ] ,
202+ }
203+
204+ #[ repr( align( 4 ) ) ]
205+ pub struct pthread_mutex_t {
206+ size: [ u8 ; 24 ] ,
207+ }
208+
209+ #[ repr( align( 4 ) ) ]
210+ pub struct pthread_rwlock_t {
211+ size: [ u8 ; 32 ] ,
212+ }
213+
214+ #[ repr( align( 4 ) ) ]
215+ pub struct pthread_barrier_t {
216+ size: [ u8 ; 20 ] ,
217+ }
173218}
174219
175220// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
@@ -262,7 +307,9 @@ pub const DT_BLK: u8 = 1;
262307pub const DT_CHR : u8 = 2 ;
263308pub const DT_DIR : u8 = 3 ;
264309pub const DT_REG : u8 = 4 ;
310+ pub const DT_FIFO : u8 = 6 ;
265311pub const DT_LNK : u8 = 7 ;
312+ pub const DT_SOCK : u8 = 20 ;
266313pub const FIONREAD : c_int = 1 ;
267314pub const FIONBIO : c_int = 2 ;
268315pub const F_OK : c_int = 0 ;
@@ -438,6 +485,9 @@ pub const NOEXPR: crate::nl_item = 0x50001;
438485pub const YESSTR : crate :: nl_item = 0x50002 ;
439486pub const NOSTR : crate :: nl_item = 0x50003 ;
440487
488+ pub const PTHREAD_STACK_MIN : usize = 2048 ;
489+ pub const TIMER_ABSTIME : c_int = 1 ;
490+
441491f ! {
442492 pub fn FD_ISSET ( fd: c_int, set: * const fd_set) -> bool {
443493 let set = & * set;
@@ -843,6 +893,72 @@ extern "C" {
843893 pub fn arc4random_uniform ( a : u32 ) -> u32 ;
844894
845895 pub fn __errno_location ( ) -> * mut c_int ;
896+
897+ pub fn chmod ( path : * const c_char , mode : mode_t ) -> c_int ;
898+ pub fn fchmod ( fd : c_int , mode : mode_t ) -> c_int ;
899+ pub fn realpath ( pathname : * const c_char , resolved : * mut c_char ) -> * mut c_char ;
900+
901+ pub fn pthread_self ( ) -> pthread_t ;
902+ pub fn pthread_create (
903+ native : * mut pthread_t ,
904+ attr : * const pthread_attr_t ,
905+ f : extern "C" fn ( * mut c_void ) -> * mut c_void ,
906+ value : * mut c_void ,
907+ ) -> c_int ;
908+ pub fn pthread_equal ( t1 : pthread_t , t2 : pthread_t ) -> c_int ;
909+ pub fn pthread_join ( native : pthread_t , value : * mut * mut c_void ) -> c_int ;
910+ pub fn pthread_attr_init ( attr : * mut pthread_attr_t ) -> c_int ;
911+ pub fn pthread_attr_destroy ( attr : * mut pthread_attr_t ) -> c_int ;
912+ pub fn pthread_attr_getstacksize ( attr : * const pthread_attr_t , stacksize : * mut size_t ) -> c_int ;
913+ pub fn pthread_attr_setstacksize ( attr : * mut pthread_attr_t , stack_size : size_t ) -> c_int ;
914+ pub fn pthread_attr_setdetachstate ( attr : * mut pthread_attr_t , state : c_int ) -> c_int ;
915+ pub fn pthread_detach ( thread : pthread_t ) -> c_int ;
916+
917+ pub fn pthread_key_create (
918+ key : * mut pthread_key_t ,
919+ dtor : Option < unsafe extern "C" fn ( * mut c_void ) > ,
920+ ) -> c_int ;
921+ pub fn pthread_key_delete ( key : pthread_key_t ) -> c_int ;
922+ pub fn pthread_getspecific ( key : pthread_key_t ) -> * mut c_void ;
923+ pub fn pthread_setspecific ( key : pthread_key_t , value : * const c_void ) -> c_int ;
924+ pub fn pthread_mutex_init (
925+ lock : * mut pthread_mutex_t ,
926+ attr : * const pthread_mutexattr_t ,
927+ ) -> c_int ;
928+ pub fn pthread_mutex_destroy ( lock : * mut pthread_mutex_t ) -> c_int ;
929+ pub fn pthread_mutex_lock ( lock : * mut pthread_mutex_t ) -> c_int ;
930+ pub fn pthread_mutex_trylock ( lock : * mut pthread_mutex_t ) -> c_int ;
931+ pub fn pthread_mutex_unlock ( lock : * mut pthread_mutex_t ) -> c_int ;
932+
933+ pub fn pthread_mutexattr_init ( attr : * mut pthread_mutexattr_t ) -> c_int ;
934+ pub fn pthread_mutexattr_destroy ( attr : * mut pthread_mutexattr_t ) -> c_int ;
935+ pub fn pthread_mutexattr_settype ( attr : * mut pthread_mutexattr_t , _type : c_int ) -> c_int ;
936+
937+ pub fn pthread_cond_init ( cond : * mut pthread_cond_t , attr : * const pthread_condattr_t ) -> c_int ;
938+ pub fn pthread_cond_wait ( cond : * mut pthread_cond_t , lock : * mut pthread_mutex_t ) -> c_int ;
939+ pub fn pthread_cond_timedwait (
940+ cond : * mut pthread_cond_t ,
941+ lock : * mut pthread_mutex_t ,
942+ abstime : * const timespec ,
943+ ) -> c_int ;
944+ pub fn pthread_cond_signal ( cond : * mut pthread_cond_t ) -> c_int ;
945+ pub fn pthread_cond_broadcast ( cond : * mut pthread_cond_t ) -> c_int ;
946+ pub fn pthread_cond_destroy ( cond : * mut pthread_cond_t ) -> c_int ;
947+ pub fn pthread_condattr_init ( attr : * mut pthread_condattr_t ) -> c_int ;
948+ pub fn pthread_condattr_destroy ( attr : * mut pthread_condattr_t ) -> c_int ;
949+
950+ pub fn pthread_rwlock_init (
951+ lock : * mut pthread_rwlock_t ,
952+ attr : * const pthread_rwlockattr_t ,
953+ ) -> c_int ;
954+ pub fn pthread_rwlock_destroy ( lock : * mut pthread_rwlock_t ) -> c_int ;
955+ pub fn pthread_rwlock_rdlock ( lock : * mut pthread_rwlock_t ) -> c_int ;
956+ pub fn pthread_rwlock_tryrdlock ( lock : * mut pthread_rwlock_t ) -> c_int ;
957+ pub fn pthread_rwlock_wrlock ( lock : * mut pthread_rwlock_t ) -> c_int ;
958+ pub fn pthread_rwlock_trywrlock ( lock : * mut pthread_rwlock_t ) -> c_int ;
959+ pub fn pthread_rwlock_unlock ( lock : * mut pthread_rwlock_t ) -> c_int ;
960+ pub fn pthread_rwlockattr_init ( attr : * mut pthread_rwlockattr_t ) -> c_int ;
961+ pub fn pthread_rwlockattr_destroy ( attr : * mut pthread_rwlockattr_t ) -> c_int ;
846962}
847963
848964cfg_if ! {
0 commit comments