1
-
2
1
pub type int8_t = i8 ;
3
2
pub type int16_t = i16 ;
4
3
pub type int32_t = i32 ;
@@ -31,18 +30,66 @@ pub type c_char = i8;
31
30
pub type c_long = i64 ;
32
31
pub type c_ulong = u64 ;
33
32
34
- pub type wchar_t = i16 ;
33
+ pub type wchar_t = i32 ;
34
+ pub type wint_t = u32 ;
35
+ pub type wctype_t = i64 ;
35
36
37
+ pub type regoff_t = size_t ;
36
38
pub type off_t = c_long ;
37
- pub type mode_t = u16 ;
38
- pub type time_t = i64 ;
39
- pub type pid_t = usize ;
40
- pub type gid_t = usize ;
41
- pub type uid_t = usize ;
39
+ pub type mode_t = c_int ;
40
+ pub type time_t = c_long ;
41
+ pub type pid_t = c_int ;
42
+ pub type id_t = c_uint ;
43
+ pub type gid_t = c_int ;
44
+ pub type uid_t = c_int ;
45
+ pub type dev_t = c_long ;
46
+ pub type ino_t = c_ulong ;
47
+ pub type nlink_t = c_ulong ;
48
+ pub type blksize_t = c_long ;
49
+ pub type blkcnt_t = c_ulong ;
50
+
51
+ pub type fsblkcnt_t = c_ulong ;
52
+ pub type fsfilcnt_t = c_ulong ;
53
+
54
+ pub type useconds_t = c_uint ;
55
+ pub type suseconds_t = c_int ;
42
56
43
- pub type suseconds_t = i64 ;
57
+ pub type clock_t = c_long ;
58
+ pub type clockid_t = c_int ;
59
+ pub type timer_t = * mut c_void ;
60
+
61
+ pub type nfds_t = c_ulong ;
44
62
45
63
s ! {
64
+ pub struct fd_set {
65
+ fds_bits: [ :: c_ulong; FD_SETSIZE / ULONG_SIZE ] ,
66
+ }
67
+
68
+ pub struct pollfd {
69
+ pub fd: :: c_int,
70
+ pub events: :: c_short,
71
+ pub revents: :: c_short,
72
+ }
73
+
74
+ pub struct stat {
75
+ pub st_dev: :: dev_t,
76
+ pub st_ino: :: ino_t,
77
+ pub st_nlink: :: nlink_t,
78
+ pub st_mode: :: mode_t,
79
+ pub st_uid: :: uid_t,
80
+ pub st_gid: :: gid_t,
81
+ pub st_rdev: :: dev_t,
82
+ pub st_size: :: off_t,
83
+ pub st_blksize: :: blksize_t,
84
+ pub st_blocks: :: blkcnt_t,
85
+
86
+ pub st_atime: :: timespec,
87
+ pub st_mtime: :: timespec,
88
+ pub st_ctime: :: timespec,
89
+
90
+ _pad: [ c_char; 24 ] ,
91
+ }
92
+
46
93
pub struct timeval {
47
94
pub tv_sec: time_t,
48
95
pub tv_usec: suseconds_t,
@@ -64,6 +111,27 @@ pub const STDERR_FILENO: ::c_int = 2;
64
111
pub const EXIT_FAILURE : :: c_int = 1 ;
65
112
pub const EXIT_SUCCESS : :: c_int = 0 ;
66
113
114
+ pub const FD_SETSIZE : usize = 1024 ;
115
+
116
+ pub const MAP_SHARED : :: c_int = 1 ;
117
+ pub const MAP_PRIVATE : :: c_int = 2 ;
118
+ pub const MAP_ANONYMOUS : :: c_int = 4 ;
119
+ pub const MAP_ANON : :: c_int = MAP_ANONYMOUS ;
120
+
121
+ pub const MAP_FAILED : * mut :: c_void = !0 as * mut :: c_void ;
122
+
123
+ pub const POLLIN : :: c_short = 0x001 ;
124
+ pub const POLLPRI : :: c_short = 0x002 ;
125
+ pub const POLLOUT : :: c_short = 0x004 ;
126
+ pub const POLLERR : :: c_short = 0x008 ;
127
+ pub const POLLHUP : :: c_short = 0x010 ;
128
+ pub const POLLNVAL : :: c_short = 0x020 ;
129
+
130
+ pub const PROT_NONE : :: c_int = 0 ;
131
+ pub const PROT_EXEC : :: c_int = 1 ;
132
+ pub const PROT_WRITE : :: c_int = 2 ;
133
+ pub const PROT_READ : :: c_int = 4 ;
134
+
67
135
pub const S_ISUID : :: c_int = 0x800 ;
68
136
pub const S_ISGID : :: c_int = 0x400 ;
69
137
pub const S_ISVTX : :: c_int = 0x200 ;
@@ -98,6 +166,8 @@ pub const F_SETFD: ::c_int = 2;
98
166
pub const F_GETFL : :: c_int = 3 ;
99
167
pub const F_SETFL : :: c_int = 4 ;
100
168
169
+ pub const FD_CLOEXEC : :: c_int = 0x0100_0000 ;
170
+
101
171
pub const O_RDONLY : :: c_int = 0x0001_0000 ;
102
172
pub const O_WRONLY : :: c_int = 0x0002_0000 ;
103
173
pub const O_RDWR : :: c_int = 0x0003_0000 ;
@@ -152,6 +222,17 @@ pub const SIGSYS: ::c_int = 31;
152
222
pub enum FILE { }
153
223
pub enum fpos_t { } // TODO: fill this out with a struct
154
224
225
+ // intentionally not public, only used for fd_set
226
+ cfg_if ! {
227
+ if #[ cfg( target_pointer_width = "32" ) ] {
228
+ const ULONG_SIZE : usize = 32 ;
229
+ } else if #[ cfg( target_pointer_width = "64" ) ] {
230
+ const ULONG_SIZE : usize = 64 ;
231
+ } else {
232
+ // Unknown target_pointer_width
233
+ }
234
+ }
235
+
155
236
extern {
156
237
pub fn isalnum ( c : c_int ) -> c_int ;
157
238
pub fn isalpha ( c : c_int ) -> c_int ;
@@ -262,9 +343,22 @@ extern {
262
343
pub fn close ( fd : :: c_int ) -> :: c_int ;
263
344
pub fn fchown ( fd : :: c_int , uid : :: uid_t , gid : :: gid_t ) -> :: c_int ;
264
345
pub fn fcntl ( fd : :: c_int , cmd : :: c_int , ...) -> :: c_int ;
346
+ pub fn fstat ( fd : :: c_int , buf : * mut stat ) -> :: c_int ;
347
+ pub fn fsync ( fd : :: c_int ) -> :: c_int ;
265
348
pub fn gethostname ( name : * mut :: c_char , len : :: size_t ) -> :: c_int ;
266
349
pub fn getpid ( ) -> pid_t ;
267
350
pub fn memalign ( align : :: size_t , size : :: size_t ) -> * mut :: c_void ;
351
+ pub fn mmap ( addr : * mut :: c_void ,
352
+ len : :: size_t ,
353
+ prot : :: c_int ,
354
+ flags : :: c_int ,
355
+ fd : :: c_int ,
356
+ offset : off_t )
357
+ -> * mut :: c_void ;
358
+ pub fn mprotect ( addr : * mut :: c_void , len : :: size_t , prot : :: c_int )
359
+ -> :: c_int ;
360
+ pub fn munmap ( addr : * mut :: c_void , len : :: size_t ) -> :: c_int ;
361
+ pub fn poll ( fds : * mut pollfd , nfds : nfds_t , timeout : :: c_int ) -> :: c_int ;
268
362
pub fn read ( fd : :: c_int , buf : * mut :: c_void , count : :: size_t ) -> :: ssize_t ;
269
363
pub fn setenv ( name : * const c_char , val : * const c_char , overwrite : :: c_int )
270
364
-> :: c_int ;
0 commit comments