1
1
use super :: { Send , Sync } ;
2
- use core:: iter:: Iterator ;
3
2
4
3
pub use ffi:: c_void;
5
4
@@ -10,8 +9,15 @@ pub type c_int = i32;
10
9
pub type c_uint = u32 ;
11
10
pub type c_short = i16 ;
12
11
pub type c_ushort = u16 ;
13
- pub type c_long = i32 ;
14
- pub type c_ulong = u32 ;
12
+ cfg_if ! {
13
+ if #[ cfg( target_arch = "wasm64" ) ] {
14
+ pub type c_long = i64 ;
15
+ pub type c_ulong = u64 ;
16
+ } else {
17
+ pub type c_long = i32 ;
18
+ pub type c_ulong = u32 ;
19
+ }
20
+ }
15
21
pub type c_longlong = i64 ;
16
22
pub type c_ulonglong = u64 ;
17
23
pub type intmax_t = i64 ;
@@ -28,7 +34,6 @@ pub type time_t = c_longlong;
28
34
pub type c_double = f64 ;
29
35
pub type c_float = f32 ;
30
36
pub type ino_t = u64 ;
31
- pub type sigset_t = c_uchar ;
32
37
pub type suseconds_t = c_longlong ;
33
38
pub type mode_t = u32 ;
34
39
pub type dev_t = u64 ;
@@ -176,11 +181,6 @@ s! {
176
181
pub st_ctim: timespec,
177
182
__reserved: [ c_longlong; 3 ] ,
178
183
}
179
-
180
- pub struct fd_set {
181
- __nfds: usize ,
182
- __fds: [ c_int; FD_SETSIZE as usize ] ,
183
- }
184
184
}
185
185
186
186
// Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
@@ -197,6 +197,9 @@ pub struct dirent {
197
197
pub d_name : [ c_char ; 0 ] ,
198
198
}
199
199
200
+ pub const INT_MIN : c_int = -2147483648 ;
201
+ pub const INT_MAX : c_int = 2147483647 ;
202
+
200
203
pub const EXIT_SUCCESS : c_int = 0 ;
201
204
pub const EXIT_FAILURE : c_int = 1 ;
202
205
pub const STDIN_FILENO : c_int = 0 ;
@@ -212,6 +215,8 @@ pub const F_GETFD: c_int = 1;
212
215
pub const F_SETFD : c_int = 2 ;
213
216
pub const F_GETFL : c_int = 3 ;
214
217
pub const F_SETFL : c_int = 4 ;
218
+ pub const F_DUPFD : c_int = 5 ;
219
+ pub const F_DUPFD_CLOEXEC : c_int = 6 ;
215
220
pub const FD_CLOEXEC : c_int = 1 ;
216
221
pub const FD_SETSIZE : size_t = 1024 ;
217
222
pub const O_APPEND : c_int = 0x0001 ;
@@ -245,14 +250,14 @@ pub const AT_SYMLINK_FOLLOW: c_int = 0x2;
245
250
pub const AT_REMOVEDIR : c_int = 0x4 ;
246
251
pub const UTIME_OMIT : c_long = 0xfffffffe ;
247
252
pub const UTIME_NOW : c_long = 0xffffffff ;
248
- pub const S_IFIFO : mode_t = 0o1_0000 ;
253
+ pub const S_IFIFO : mode_t = 49152 ;
249
254
pub const S_IFCHR : mode_t = 8192 ;
250
255
pub const S_IFBLK : mode_t = 24576 ;
251
256
pub const S_IFDIR : mode_t = 16384 ;
252
257
pub const S_IFREG : mode_t = 32768 ;
253
258
pub const S_IFLNK : mode_t = 40960 ;
254
259
pub const S_IFSOCK : mode_t = 49152 ;
255
- pub const S_IFMT : mode_t = 0o17_0000 ;
260
+ pub const S_IFMT : mode_t = 57344 ;
256
261
pub const S_IRWXO : mode_t = 0x7 ;
257
262
pub const S_IXOTH : mode_t = 0x1 ;
258
263
pub const S_IWOTH : mode_t = 0x2 ;
@@ -370,28 +375,15 @@ pub const EWOULDBLOCK: c_int = EAGAIN;
370
375
pub const _SC_PAGESIZE: c_int = 30 ;
371
376
pub const _SC_PAGE_SIZE: :: c_int = _SC_PAGESIZE;
372
377
pub const _SC_IOV_MAX: c_int = 60 ;
378
+ pub const _SC_NPROCESSORS_ONLN: :: c_int = 84 ;
373
379
pub const _SC_SYMLOOP_MAX: c_int = 173 ;
374
380
375
- cfg_if ! {
376
- if #[ cfg( libc_ctest) ] {
377
- // skip these constants when this is active because `ctest` currently
378
- // panics on parsing the constants below
379
- } else {
380
- // `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82
381
- #[ allow( unused_unsafe) ]
382
- pub static CLOCK_MONOTONIC : clockid_t =
383
- unsafe { clockid_t( ptr_addr_of!( _CLOCK_MONOTONIC) ) } ;
384
- #[ allow( unused_unsafe) ]
385
- pub static CLOCK_PROCESS_CPUTIME_ID : clockid_t =
386
- unsafe { clockid_t( ptr_addr_of!( _CLOCK_PROCESS_CPUTIME_ID) ) } ;
387
- #[ allow( unused_unsafe) ]
388
- pub static CLOCK_REALTIME : clockid_t =
389
- unsafe { clockid_t( ptr_addr_of!( _CLOCK_REALTIME) ) } ;
390
- #[ allow( unused_unsafe) ]
391
- pub static CLOCK_THREAD_CPUTIME_ID : clockid_t =
392
- unsafe { clockid_t( ptr_addr_of!( _CLOCK_THREAD_CPUTIME_ID) ) } ;
393
- }
394
- }
381
+ pub static CLOCK_MONOTONIC : clockid_t = unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_MONOTONIC) ) } ;
382
+ pub static CLOCK_PROCESS_CPUTIME_ID : clockid_t =
383
+ unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_PROCESS_CPUTIME_ID) ) } ;
384
+ pub static CLOCK_REALTIME : clockid_t = unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_REALTIME) ) } ;
385
+ pub static CLOCK_THREAD_CPUTIME_ID : clockid_t =
386
+ unsafe { clockid_t ( ptr_addr_of ! ( _CLOCK_THREAD_CPUTIME_ID) ) } ;
395
387
396
388
pub const ABDAY_1 : :: nl_item = 0x20000 ;
397
389
pub const ABDAY_2 : :: nl_item = 0x20001 ;
@@ -458,28 +450,6 @@ pub const NOEXPR: ::nl_item = 0x50001;
458
450
pub const YESSTR : :: nl_item = 0x50002 ;
459
451
pub const NOSTR : :: nl_item = 0x50003 ;
460
452
461
- f ! {
462
- pub fn FD_ISSET ( fd: :: c_int, set: * const fd_set) -> bool {
463
- let set = & * set;
464
- let n = set. __nfds;
465
- return set. __fds[ ..n] . iter( ) . any( |p| * p == fd)
466
- }
467
-
468
- pub fn FD_SET ( fd: :: c_int, set: * mut fd_set) -> ( ) {
469
- let set = & mut * set;
470
- let n = set. __nfds;
471
- if !set. __fds[ ..n] . iter( ) . any( |p| * p == fd) {
472
- set. __nfds = n + 1 ;
473
- set. __fds[ n] = fd;
474
- }
475
- }
476
-
477
- pub fn FD_ZERO ( set: * mut fd_set) -> ( ) {
478
- ( * set) . __nfds = 0 ;
479
- return
480
- }
481
- }
482
-
483
453
#[ cfg_attr(
484
454
feature = "rustc-dep-of-std" ,
485
455
link(
@@ -775,14 +745,6 @@ extern "C" {
775
745
pub fn nl_langinfo ( item : :: nl_item ) -> * mut :: c_char ;
776
746
pub fn nl_langinfo_l ( item : :: nl_item , loc : :: locale_t ) -> * mut :: c_char ;
777
747
778
- pub fn select (
779
- nfds : c_int ,
780
- readfds : * mut fd_set ,
781
- writefds : * mut fd_set ,
782
- errorfds : * mut fd_set ,
783
- timeout : * const timeval ,
784
- ) -> c_int ;
785
-
786
748
pub fn __wasilibc_register_preopened_fd ( fd : c_int , path : * const c_char ) -> c_int ;
787
749
pub fn __wasilibc_fd_renumber ( fd : c_int , newfd : c_int ) -> c_int ;
788
750
pub fn __wasilibc_unlinkat ( fd : c_int , path : * const c_char ) -> c_int ;
@@ -880,9 +842,5 @@ extern "C" {
880
842
pub fn __errno_location ( ) -> * mut :: c_int ;
881
843
}
882
844
883
- cfg_if ! {
884
- if #[ cfg( target_env = "p2" ) ] {
885
- mod p2;
886
- pub use self :: p2:: * ;
887
- }
888
- }
845
+ mod wasix;
846
+ pub use self :: wasix:: * ;
0 commit comments