@@ -43,6 +43,16 @@ pub type uid_t = usize;
43
43
pub type suseconds_t = i64 ;
44
44
45
45
s ! {
46
+ pub struct fd_set {
47
+ fds_bits: [ :: c_ulong; FD_SETSIZE / ULONG_SIZE ] ,
48
+ }
49
+
50
+ pub struct pollfd {
51
+ pub fd: :: c_int,
52
+ pub events: :: c_short,
53
+ pub revents: :: c_short,
54
+ }
55
+
46
56
pub struct timeval {
47
57
pub tv_sec: time_t,
48
58
pub tv_usec: suseconds_t,
@@ -64,6 +74,27 @@ pub const STDERR_FILENO: ::c_int = 2;
64
74
pub const EXIT_FAILURE : :: c_int = 1 ;
65
75
pub const EXIT_SUCCESS : :: c_int = 0 ;
66
76
77
+ pub const FD_SETSIZE : usize = 1024 ;
78
+
79
+ pub const MAP_SHARED : :: c_int = 1 ;
80
+ pub const MAP_PRIVATE : :: c_int = 2 ;
81
+ pub const MAP_ANONYMOUS : :: c_int = 4 ;
82
+ pub const MAP_ANON : :: c_int = MAP_ANONYMOUS ;
83
+
84
+ pub const MAP_FAILED : * mut :: c_void = !0 as * mut :: c_void ;
85
+
86
+ pub const POLLIN : :: c_short = 0x001 ;
87
+ pub const POLLPRI : :: c_short = 0x002 ;
88
+ pub const POLLOUT : :: c_short = 0x004 ;
89
+ pub const POLLERR : :: c_short = 0x008 ;
90
+ pub const POLLHUP : :: c_short = 0x010 ;
91
+ pub const POLLNVAL : :: c_short = 0x020 ;
92
+
93
+ pub const PROT_NONE : :: c_int = 0 ;
94
+ pub const PROT_EXEC : :: c_int = 1 ;
95
+ pub const PROT_WRITE : :: c_int = 2 ;
96
+ pub const PROT_READ : :: c_int = 4 ;
97
+
67
98
pub const S_ISUID : :: c_int = 0x800 ;
68
99
pub const S_ISGID : :: c_int = 0x400 ;
69
100
pub const S_ISVTX : :: c_int = 0x200 ;
@@ -152,6 +183,18 @@ pub const SIGSYS: ::c_int = 31;
152
183
pub enum FILE { }
153
184
pub enum fpos_t { } // TODO: fill this out with a struct
154
185
186
+
187
+ // intentionally not public, only used for fd_set
188
+ cfg_if ! {
189
+ if #[ cfg( target_pointer_width = "32" ) ] {
190
+ const ULONG_SIZE : usize = 32 ;
191
+ } else if #[ cfg( target_pointer_width = "64" ) ] {
192
+ const ULONG_SIZE : usize = 64 ;
193
+ } else {
194
+ // Unknown target_pointer_width
195
+ }
196
+ }
197
+
155
198
extern {
156
199
pub fn isalnum ( c : c_int ) -> c_int ;
157
200
pub fn isalpha ( c : c_int ) -> c_int ;
@@ -262,9 +305,20 @@ extern {
262
305
pub fn close ( fd : :: c_int ) -> :: c_int ;
263
306
pub fn fchown ( fd : :: c_int , uid : :: uid_t , gid : :: gid_t ) -> :: c_int ;
264
307
pub fn fcntl ( fd : :: c_int , cmd : :: c_int , ...) -> :: c_int ;
308
+ pub fn fsync ( fd : :: c_int ) -> :: c_int ;
265
309
pub fn gethostname ( name : * mut :: c_char , len : :: size_t ) -> :: c_int ;
266
310
pub fn getpid ( ) -> pid_t ;
267
311
pub fn memalign ( align : :: size_t , size : :: size_t ) -> * mut :: c_void ;
312
+ pub fn mmap ( addr : * mut :: c_void ,
313
+ len : :: size_t ,
314
+ prot : :: c_int ,
315
+ flags : :: c_int ,
316
+ fd : :: c_int ,
317
+ offset : off_t )
318
+ -> * mut :: c_void ;
319
+ pub fn mprotect ( addr : * mut :: c_void , len : :: size_t , prot : :: c_int )
320
+ -> :: c_int ;
321
+ pub fn munmap ( addr : * mut :: c_void , len : :: size_t ) -> :: c_int ;
268
322
pub fn read ( fd : :: c_int , buf : * mut :: c_void , count : :: size_t ) -> :: ssize_t ;
269
323
pub fn setenv ( name : * const c_char , val : * const c_char , overwrite : :: c_int )
270
324
-> :: c_int ;
0 commit comments