11use crate :: prelude:: * ;
22
3- pub type c_long = i32 ;
4- pub type c_ulong = u32 ;
5- pub type nlink_t = u32 ;
6- pub type blksize_t = c_long ;
7- pub type __u64 = c_ulonglong ;
8- pub type __s64 = c_longlong ;
9- pub type regoff_t = c_int ;
10-
11- s ! {
12- pub struct pthread_attr_t {
13- __size: [ u32 ; 9 ] ,
14- }
3+ cfg_if ! {
4+ if #[ cfg( not( target_arch = "wasm32" ) ) ] {
5+ pub type c_long = i32 ;
6+ pub type c_ulong = u32 ;
7+ pub type nlink_t = u32 ;
8+ pub type blksize_t = c_long;
9+ pub type __u64 = c_ulonglong;
10+ pub type __s64 = c_longlong;
11+ pub type regoff_t = c_int;
1512
16- pub struct sigset_t {
17- __val: [ c_ulong; 32 ] ,
18- }
13+ s! {
14+ pub struct pthread_attr_t {
15+ __size: [ u32 ; 9 ] ,
16+ }
1917
20- pub struct msghdr {
21- pub msg_name: * mut c_void,
22- pub msg_namelen: crate :: socklen_t,
23- pub msg_iov: * mut crate :: iovec,
24- pub msg_iovlen: c_int,
25- pub msg_control: * mut c_void,
26- pub msg_controllen: crate :: socklen_t,
27- pub msg_flags: c_int,
28- }
18+ pub struct sigset_t {
19+ __val: [ c_ulong; 32 ] ,
20+ }
2921
30- pub struct cmsghdr {
31- pub cmsg_len: crate :: socklen_t,
32- pub cmsg_level: c_int,
33- pub cmsg_type: c_int,
22+ pub struct msghdr {
23+ pub msg_name: * mut c_void,
24+ pub msg_namelen: crate :: socklen_t,
25+ pub msg_iov: * mut crate :: iovec,
26+ pub msg_iovlen: c_int,
27+ pub msg_control: * mut c_void,
28+ pub msg_controllen: crate :: socklen_t,
29+ pub msg_flags: c_int,
30+ }
31+
32+ pub struct cmsghdr {
33+ pub cmsg_len: crate :: socklen_t,
34+ pub cmsg_level: c_int,
35+ pub cmsg_type: c_int,
36+ }
37+
38+ pub struct sem_t {
39+ __val: [ c_int; 4 ] ,
40+ }
41+ }
42+
43+ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 ;
44+ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24 ;
45+ pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20 ;
3446 }
47+ else {
48+ pub type c_long = i64 ;
49+ pub type c_ulong = u64 ;
50+ pub type regoff_t = c_long;
51+
52+ s! {
53+ pub struct stack_t {
54+ pub ss_sp: * mut c_void,
55+ pub ss_flags: c_int,
56+ pub ss_size: size_t,
57+ }
3558
36- pub struct sem_t {
37- __val: [ c_int; 4 ] ,
59+ pub struct pthread_attr_t {
60+ __size: [ u64 ; 7 ] ,
61+ }
62+
63+ pub struct sigset_t {
64+ __val: [ c_ulong; 16 ] ,
65+ }
66+
67+ pub struct shmid_ds {
68+ pub shm_perm: crate :: ipc_perm,
69+ pub shm_segsz: size_t,
70+ pub shm_atime: crate :: time_t,
71+ pub shm_dtime: crate :: time_t,
72+ pub shm_ctime: crate :: time_t,
73+ pub shm_cpid: crate :: pid_t,
74+ pub shm_lpid: crate :: pid_t,
75+ pub shm_nattch: c_ulong,
76+ __pad1: c_ulong,
77+ __pad2: c_ulong,
78+ }
79+
80+ pub struct msqid_ds {
81+ pub msg_perm: crate :: ipc_perm,
82+ pub msg_stime: crate :: time_t,
83+ pub msg_rtime: crate :: time_t,
84+ pub msg_ctime: crate :: time_t,
85+ __msg_cbytes: c_ulong,
86+ pub msg_qnum: crate :: msgqnum_t,
87+ pub msg_qbytes: crate :: msglen_t,
88+ pub msg_lspid: crate :: pid_t,
89+ pub msg_lrpid: crate :: pid_t,
90+ __pad1: c_ulong,
91+ __pad2: c_ulong,
92+ }
93+
94+ pub struct msghdr {
95+ pub msg_name: * mut c_void,
96+ pub msg_namelen: crate :: socklen_t,
97+ pub msg_iov: * mut crate :: iovec,
98+ #[ cfg( target_endian = "big" ) ]
99+ __pad1: c_int,
100+ pub msg_iovlen: c_int,
101+ #[ cfg( target_endian = "little" ) ]
102+ __pad1: c_int,
103+ pub msg_control: * mut c_void,
104+ #[ cfg( target_endian = "big" ) ]
105+ __pad2: c_int,
106+ pub msg_controllen: crate :: socklen_t,
107+ #[ cfg( target_endian = "little" ) ]
108+ __pad2: c_int,
109+ pub msg_flags: c_int,
110+ }
111+
112+ pub struct cmsghdr {
113+ #[ cfg( target_endian = "big" ) ]
114+ pub __pad1: c_int,
115+ pub cmsg_len: crate :: socklen_t,
116+ #[ cfg( target_endian = "little" ) ]
117+ pub __pad1: c_int,
118+ pub cmsg_level: c_int,
119+ pub cmsg_type: c_int,
120+ }
121+
122+ pub struct sem_t {
123+ __val: [ c_int; 8 ] ,
124+ }
125+ }
126+ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56 ;
127+ pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40 ;
128+ pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32 ;
129+
130+ extern "C" {
131+ pub fn getrandom( buf: * mut c_void, buflen: size_t, flags: c_uint) -> ssize_t;
132+ }
38133 }
39134}
40135
41- pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 ;
42- pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24 ;
43- pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 20 ;
44-
45136cfg_if ! {
46137 if #[ cfg( any( target_arch = "x86" ) ) ] {
47138 mod x86;
@@ -61,6 +152,9 @@ cfg_if! {
61152 } else if #[ cfg( any( target_arch = "riscv32" ) ) ] {
62153 mod riscv32;
63154 pub use self :: riscv32:: * ;
155+ } else if #[ cfg( any( target_arch = "wasm32" ) ) ] {
156+ mod wasm32;
157+ pub use self :: wasm32:: * ;
64158 } else {
65159 // Unknown target_arch
66160 }
0 commit comments