@@ -12,9 +12,6 @@ impl ::Clone for DIR {
12
12
}
13
13
}
14
14
15
- // Throughout we use usize / isize for types that are
16
- // (unsigned) int in ILP32 and (unsigned) long in ILP64
17
-
18
15
pub type c_schar = i8 ;
19
16
pub type c_uchar = u8 ;
20
17
pub type c_short = i16 ;
@@ -28,11 +25,23 @@ pub type c_ulonglong = u64;
28
25
pub type intmax_t = i64 ;
29
26
pub type uintmax_t = u64 ;
30
27
31
- pub type size_t = usize ;
32
- pub type ptrdiff_t = isize ;
33
- pub type intptr_t = isize ;
34
- pub type uintptr_t = usize ;
35
- pub type ssize_t = isize ;
28
+ cfg_if ! {
29
+ if #[ cfg( target_pointer_width = "32" ) ] {
30
+ pub type size_t = c_uint;
31
+ pub type ssize_t = c_int;
32
+ pub type ptrdiff_t = c_int;
33
+ pub type intptr_t = c_int;
34
+ pub type uintptr_t = c_uint;
35
+ } else if #[ cfg( target_pointer_width = "64" ) ] {
36
+ pub type size_t = c_ulonglong;
37
+ pub type ssize_t = c_longlong;
38
+ pub type ptrdiff_t = c_longlong;
39
+ pub type intptr_t = c_longlong;
40
+ pub type uintptr_t = c_ulonglong;
41
+ } else {
42
+ // Unknown target_pointer_width
43
+ }
44
+ }
36
45
37
46
pub type pid_t = i32 ;
38
47
pub type in_addr_t = u32 ;
@@ -103,10 +112,17 @@ pub type _Vx_ticks64_t = ::c_ulonglong;
103
112
104
113
pub type sa_family_t = :: c_uchar ;
105
114
115
+ #[ cfg_attr( feature = "extra_traits" , derive( Debug ) ) ]
116
+ pub enum _Vx_semaphore { }
117
+ impl :: Copy for _Vx_semaphore { }
118
+ impl :: Clone for _Vx_semaphore {
119
+ fn clone ( & self ) -> _Vx_semaphore {
120
+ * self
121
+ }
122
+ }
123
+
106
124
// structs that only exist in userspace
107
125
s ! {
108
- pub struct _Vx_semaphore { }
109
-
110
126
// b_pthread_condattr_t.h
111
127
pub struct pthread_condattr_t {
112
128
pub condAttrStatus: :: c_int,
@@ -161,14 +177,6 @@ s! {
161
177
pub sa_data : [ :: c_char; 14 ] ,
162
178
}
163
179
164
- // socket.h
165
- pub struct sockaddr_storage {
166
- pub ss_len : :: c_uchar,
167
- pub ss_family : :: sa_family_t,
168
- pub __ss_pad1 : [ :: c_char; _SS_PAD1SIZE] ,
169
- pub __ss_align : i32 ,
170
- pub __ss_pad2 : [ :: c_char; _SS_PAD2SIZE] ,
171
- }
172
180
pub struct iovec {
173
181
pub iov_base: * mut :: c_void,
174
182
pub iov_len: :: size_t,
@@ -197,12 +205,6 @@ s! {
197
205
pub revents : :: c_short,
198
206
}
199
207
200
- // dirent.h
201
- pub struct dirent {
202
- pub d_ino : :: ino_t,
203
- pub d_name : [ :: c_char; _PARM_NAME_MAX + 1 ] ,
204
- }
205
-
206
208
// resource.h
207
209
pub struct rlimit { /* Is this really needed? Questionable ... */
208
210
pub rlim_cur : :: rlim_t,
@@ -391,12 +393,6 @@ s! {
391
393
pub sin6_scope_id: u32 ,
392
394
}
393
395
394
- pub struct sockaddr_un {
395
- pub sun_len: u8 ,
396
- pub sun_family: sa_family_t,
397
- pub sun_path: [ :: c_char; 104 ]
398
- }
399
-
400
396
pub struct passwd {
401
397
pub pw_name: * mut :: c_char,
402
398
pub pw_uid: :: uid_t,
@@ -405,10 +401,25 @@ s! {
405
401
pub pw_shell: * mut :: c_char,
406
402
}
407
403
408
- // epoll.h
409
- pub struct epoll_event {
410
- pub events: u32 ,
411
- pub u64 : u64 ,
404
+ pub struct Dl_info {
405
+ pub dli_fname: * const :: c_char,
406
+ pub dli_fbase: * mut :: c_void,
407
+ pub dli_sname: * const :: c_char,
408
+ pub dli_saddr: * mut :: c_void,
409
+ }
410
+ }
411
+
412
+ s_no_extra_traits ! {
413
+ // dirent.h
414
+ pub struct dirent {
415
+ pub d_ino : :: ino_t,
416
+ pub d_name : [ :: c_char; _PARM_NAME_MAX + 1 ] ,
417
+ }
418
+
419
+ pub struct sockaddr_un {
420
+ pub sun_len: u8 ,
421
+ pub sun_family: sa_family_t,
422
+ pub sun_path: [ :: c_char; 104 ]
412
423
}
413
424
414
425
// rtpLibCommon.h
@@ -423,12 +434,64 @@ s! {
423
434
pub textStart : * mut :: c_void,
424
435
pub textEnd : * mut :: c_void,
425
436
}
437
+ // socket.h
438
+ pub struct sockaddr_storage {
439
+ pub ss_len : :: c_uchar,
440
+ pub ss_family : :: sa_family_t,
441
+ pub __ss_pad1 : [ :: c_char; _SS_PAD1SIZE] ,
442
+ pub __ss_align : i32 ,
443
+ pub __ss_pad2 : [ :: c_char; _SS_PAD2SIZE] ,
444
+ }
426
445
427
- pub struct Dl_info {
428
- pub dli_fname: * const :: c_char,
429
- pub dli_fbase: * mut :: c_void,
430
- pub dli_sname: * const :: c_char,
431
- pub dli_saddr: * mut :: c_void,
446
+ }
447
+
448
+ cfg_if ! {
449
+ if #[ cfg( feature = "extra_traits" ) ] {
450
+ impl :: fmt:: Debug for dirent {
451
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
452
+ f. debug_struct( "dirent" )
453
+ . field( "d_ino" , & self . d_ino)
454
+ . field( "d_name" , &&self . d_name[ ..] )
455
+ . finish( )
456
+ }
457
+ }
458
+
459
+ impl :: fmt:: Debug for sockaddr_un {
460
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
461
+ f. debug_struct( "sockaddr_un" )
462
+ . field( "sun_len" , & self . sun_len)
463
+ . field( "sun_family" , & self . sun_family)
464
+ . field( "sun_path" , &&self . sun_path[ ..] )
465
+ . finish( )
466
+ }
467
+ }
468
+
469
+ impl :: fmt:: Debug for RTP_DESC {
470
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
471
+ f. debug_struct( "RTP_DESC" )
472
+ . field( "status" , & self . status)
473
+ . field( "options" , & self . options)
474
+ . field( "entrAddr" , & self . entrAddr)
475
+ . field( "initTaskId" , & self . initTaskId)
476
+ . field( "parentId" , & self . parentId)
477
+ . field( "pathName" , &&self . pathName[ ..] )
478
+ . field( "taskCnt" , & self . taskCnt)
479
+ . field( "textStart" , & self . textStart)
480
+ . field( "textEnd" , & self . textEnd)
481
+ . finish( )
482
+ }
483
+ }
484
+ impl :: fmt:: Debug for sockaddr_storage {
485
+ fn fmt( & self , f: & mut :: fmt:: Formatter ) -> :: fmt:: Result {
486
+ f. debug_struct( "sockaddr_storage" )
487
+ . field( "ss_len" , & self . ss_len)
488
+ . field( "ss_family" , & self . ss_family)
489
+ . field( "__ss_pad1" , &&self . __ss_pad1[ ..] )
490
+ . field( "__ss_align" , & self . __ss_align)
491
+ . field( "__ss_pad2" , &&self . __ss_pad2[ ..] )
492
+ . finish( )
493
+ }
494
+ }
432
495
}
433
496
}
434
497
@@ -754,20 +817,6 @@ pub const FIOSQUEEZE: ::c_int = 15;
754
817
pub const FIONBIO : :: c_int = 16 ;
755
818
pub const _POSIX_PATH_MAX: :: c_int = 256 ;
756
819
757
- // epoll.h
758
- pub const EPOLLIN : :: c_int = 0x1 ;
759
- pub const EPOLLPRI : :: c_int = 0x2 ;
760
- pub const EPOLLOUT : :: c_int = 0x4 ;
761
- pub const EPOLLERR : :: c_int = 0x8 ;
762
- pub const EPOLLHUP : :: c_int = 0x10 ;
763
- pub const EPOLLRDHUP : :: c_int = 0x2000 ;
764
- pub const EPOLLONESHOT : :: c_int = 1 << 30 ;
765
- pub const EPOLLET : :: c_int = 1 << 31 ;
766
-
767
- pub const EPOLL_CTL_ADD : :: c_int = 1 ;
768
- pub const EPOLL_CTL_DEL : :: c_int = 2 ;
769
- pub const EPOLL_CTL_MOD : :: c_int = 3 ;
770
-
771
820
// Some poll stuff
772
821
pub const POLLIN : :: c_short = 0x0001 ;
773
822
pub const POLLPRI : :: c_short = 0x0002 ;
@@ -2111,7 +2160,9 @@ pub fn posix_memalign(
2111
2160
) -> :: c_int {
2112
2161
// check to see if align is a power of 2 and if align is a multiple
2113
2162
// of sizeof(void *)
2114
- if ( align & align - 1 != 0 ) || ( align % size_of :: < :: size_t > ( ) != 0 ) {
2163
+ if ( align & align - 1 != 0 )
2164
+ || ( align as usize % size_of :: < :: size_t > ( ) != 0 )
2165
+ {
2115
2166
return :: EINVAL ;
2116
2167
}
2117
2168
@@ -2131,43 +2182,6 @@ pub fn posix_memalign(
2131
2182
}
2132
2183
}
2133
2184
2134
- // epoll.h
2135
- // Unfortunately epoll is currently only supported in the VxWorks kernel
2136
- #[ allow( unused_variables) ]
2137
- pub fn epoll_create ( size : :: c_int ) -> :: c_int {
2138
- -1
2139
- }
2140
- #[ allow( unused_variables) ]
2141
- pub fn epoll_create1 ( flags : :: c_int ) -> :: c_int {
2142
- -1
2143
- }
2144
- #[ allow( unused_variables) ]
2145
- pub fn epoll_ctl (
2146
- epfd : :: c_int ,
2147
- op : :: c_int ,
2148
- fd : :: c_int ,
2149
- event : * mut :: epoll_event ,
2150
- ) -> :: c_int {
2151
- -1
2152
- }
2153
- #[ allow( unused_variables) ]
2154
- pub fn epoll_create_and_ctl (
2155
- num : :: c_int ,
2156
- fds : * mut :: c_int ,
2157
- event : * mut :: epoll_event ,
2158
- ) -> :: c_int {
2159
- -1
2160
- }
2161
- #[ allow( unused_variables) ]
2162
- pub fn epoll_wait (
2163
- epfd : :: c_int ,
2164
- events : * mut :: epoll_event ,
2165
- maxevents : :: c_int ,
2166
- timeout : :: c_int ,
2167
- ) -> :: c_int {
2168
- -1
2169
- }
2170
-
2171
2185
// From sysconf.c -> doesn't seem to be supported?
2172
2186
pub fn getpwuid_r (
2173
2187
_uid : :: uid_t ,
0 commit comments