1 // The following definitions are correct for aarch64 and x86_64,
2 // but may be wrong for mips64
5 pub type c_ulong
= u64;
7 pub type off64_t
= i64;
8 pub type socklen_t
= u32;
12 __val
: [::c_ulong
; 1],
15 pub struct sigaction
{
16 pub sa_flags
: ::c_int
,
17 pub sa_sigaction
: ::sighandler_t
,
18 pub sa_mask
: ::sigset_t
,
19 pub sa_restorer
: ::Option
<extern fn()>,
23 pub rlim_cur
: ::c_ulonglong
,
24 pub rlim_max
: ::c_ulonglong
,
27 pub struct pthread_attr_t
{
29 pub stack_base
: *mut ::c_void
,
30 pub stack_size
: ::size_t
,
31 pub guard_size
: ::size_t
,
32 pub sched_policy
: i32,
33 pub sched_priority
: i32,
34 __reserved
: [::c_char
; 16],
38 pub pw_name
: *mut ::c_char
,
39 pub pw_passwd
: *mut ::c_char
,
42 pub pw_gecos
: *mut ::c_char
,
43 pub pw_dir
: *mut ::c_char
,
44 pub pw_shell
: *mut ::c_char
,
55 pub f_fsid
: ::__fsid_t
,
59 pub f_spare
: [u64; 4],
64 pub loads
: [::c_ulong
; 3],
65 pub totalram
: ::c_ulong
,
66 pub freeram
: ::c_ulong
,
67 pub sharedram
: ::c_ulong
,
68 pub bufferram
: ::c_ulong
,
69 pub totalswap
: ::c_ulong
,
70 pub freeswap
: ::c_ulong
,
71 pub procs
: ::c_ushort
,
73 pub totalhigh
: ::c_ulong
,
74 pub freehigh
: ::c_ulong
,
75 pub mem_unit
: ::c_uint
,
76 pub _f
: [::c_char
; 0],
87 pub f_fsid
: ::__fsid_t
,
91 pub f_spare
: [u64; 4],
94 pub struct statvfs64
{
95 pub f_bsize
: ::c_ulong
,
96 pub f_frsize
: ::c_ulong
,
103 pub f_fsid
: ::c_ulong
,
104 pub f_flag
: ::c_ulong
,
105 pub f_namemax
: ::c_ulong
,
106 __f_spare
: [::c_int
; 6],
109 pub struct pthread_barrier_t
{
113 pub struct pthread_spinlock_t
{
119 pub struct pthread_mutex_t
{
121 __reserved
: [::c_char
; 36],
124 pub struct pthread_cond_t
{
126 __reserved
: [::c_char
; 44],
129 pub struct pthread_rwlock_t
{
131 writerThreadId
: ::c_int
,
132 pendingReaders
: ::c_int
,
133 pendingWriters
: ::c_int
,
135 __reserved
: [::c_char
; 36],
138 pub struct sigset64_t
{
139 __bits
: [::c_ulong
; 1]
144 if #[cfg(feature = "extra_traits")] {
145 impl PartialEq
for pthread_mutex_t
{
146 fn eq(&self, other
: &pthread_mutex_t
) -> bool
{
147 self.value
== other
.value
151 .zip(other
.__reserved
.iter())
156 impl Eq
for pthread_mutex_t {}
158 impl ::fmt
::Debug
for pthread_mutex_t
{
159 fn fmt(&self, f
: &mut ::fmt
::Formatter
) -> ::fmt
::Result
{
160 f
.debug_struct("pthread_mutex_t")
161 .field("value", &self.value
)
162 // FIXME: .field("__reserved", &self.__reserved)
167 impl ::hash
::Hash
for pthread_mutex_t
{
168 fn hash
<H
: ::hash
::Hasher
>(&self, state
: &mut H
) {
169 self.value
.hash(state
);
170 self.__reserved
.hash(state
);
174 impl PartialEq
for pthread_cond_t
{
175 fn eq(&self, other
: &pthread_cond_t
) -> bool
{
176 self.value
== other
.value
180 .zip(other
.__reserved
.iter())
185 impl Eq
for pthread_cond_t {}
187 impl ::fmt
::Debug
for pthread_cond_t
{
188 fn fmt(&self, f
: &mut ::fmt
::Formatter
) -> ::fmt
::Result
{
189 f
.debug_struct("pthread_cond_t")
190 .field("value", &self.value
)
191 // FIXME: .field("__reserved", &self.__reserved)
196 impl ::hash
::Hash
for pthread_cond_t
{
197 fn hash
<H
: ::hash
::Hasher
>(&self, state
: &mut H
) {
198 self.value
.hash(state
);
199 self.__reserved
.hash(state
);
203 impl PartialEq
for pthread_rwlock_t
{
204 fn eq(&self, other
: &pthread_rwlock_t
) -> bool
{
205 self.numLocks
== other
.numLocks
206 && self.writerThreadId
== other
.writerThreadId
207 && self.pendingReaders
== other
.pendingReaders
208 && self.pendingWriters
== other
.pendingWriters
209 && self.attr
== other
.attr
213 .zip(other
.__reserved
.iter())
218 impl Eq
for pthread_rwlock_t {}
220 impl ::fmt
::Debug
for pthread_rwlock_t
{
221 fn fmt(&self, f
: &mut ::fmt
::Formatter
) -> ::fmt
::Result
{
222 f
.debug_struct("pthread_rwlock_t")
223 .field("numLocks", &self.numLocks
)
224 .field("writerThreadId", &self.writerThreadId
)
225 .field("pendingReaders", &self.pendingReaders
)
226 .field("pendingWriters", &self.pendingWriters
)
227 .field("attr", &self.attr
)
228 // FIXME: .field("__reserved", &self.__reserved)
233 impl ::hash
::Hash
for pthread_rwlock_t
{
234 fn hash
<H
: ::hash
::Hasher
>(&self, state
: &mut H
) {
235 self.numLocks
.hash(state
);
236 self.writerThreadId
.hash(state
);
237 self.pendingReaders
.hash(state
);
238 self.pendingWriters
.hash(state
);
239 self.attr
.hash(state
);
240 self.__reserved
.hash(state
);
244 impl ::fmt
::Debug
for sigset64_t
{
245 fn fmt(&self, f
: &mut ::fmt
::Formatter
) -> ::fmt
::Result
{
246 f
.debug_struct("sigset64_t")
247 .field("__bits", &self.__bits
)
254 // These constants must be of the same type of sigaction.sa_flags
255 pub const SA_NOCLDSTOP
: ::c_int
= 0x00000001;
256 pub const SA_NOCLDWAIT
: ::c_int
= 0x00000002;
257 pub const SA_NODEFER
: ::c_int
= 0x40000000;
258 pub const SA_ONSTACK
: ::c_int
= 0x08000000;
259 pub const SA_RESETHAND
: ::c_int
= 0x80000000;
260 pub const SA_RESTART
: ::c_int
= 0x10000000;
261 pub const SA_SIGINFO
: ::c_int
= 0x00000004;
263 pub const RTLD_GLOBAL
: ::c_int
= 0x00100;
264 pub const RTLD_NOW
: ::c_int
= 2;
265 pub const RTLD_DEFAULT
: *mut ::c_void
= 0i64 as *mut ::c_void
;
267 // From NDK's linux/auxvec.h
268 pub const AT_NULL
: ::c_ulong
= 0;
269 pub const AT_IGNORE
: ::c_ulong
= 1;
270 pub const AT_EXECFD
: ::c_ulong
= 2;
271 pub const AT_PHDR
: ::c_ulong
= 3;
272 pub const AT_PHENT
: ::c_ulong
= 4;
273 pub const AT_PHNUM
: ::c_ulong
= 5;
274 pub const AT_PAGESZ
: ::c_ulong
= 6;
275 pub const AT_BASE
: ::c_ulong
= 7;
276 pub const AT_FLAGS
: ::c_ulong
= 8;
277 pub const AT_ENTRY
: ::c_ulong
= 9;
278 pub const AT_NOTELF
: ::c_ulong
= 10;
279 pub const AT_UID
: ::c_ulong
= 11;
280 pub const AT_EUID
: ::c_ulong
= 12;
281 pub const AT_GID
: ::c_ulong
= 13;
282 pub const AT_EGID
: ::c_ulong
= 14;
283 pub const AT_PLATFORM
: ::c_ulong
= 15;
284 pub const AT_HWCAP
: ::c_ulong
= 16;
285 pub const AT_CLKTCK
: ::c_ulong
= 17;
286 pub const AT_SECURE
: ::c_ulong
= 23;
287 pub const AT_BASE_PLATFORM
: ::c_ulong
= 24;
288 pub const AT_RANDOM
: ::c_ulong
= 25;
289 pub const AT_HWCAP2
: ::c_ulong
= 26;
290 pub const AT_EXECFN
: ::c_ulong
= 31;
292 pub const PTHREAD_MUTEX_INITIALIZER
: pthread_mutex_t
= pthread_mutex_t
{
296 pub const PTHREAD_COND_INITIALIZER
: pthread_cond_t
= pthread_cond_t
{
300 pub const PTHREAD_RWLOCK_INITIALIZER
: pthread_rwlock_t
= pthread_rwlock_t
{
308 pub const PTHREAD_STACK_MIN
: ::size_t
= 4096 * 4;
309 pub const CPU_SETSIZE
: ::size_t
= 1024;
310 pub const __CPU_BITS
: ::size_t
= 64;
312 pub const UT_LINESIZE
: usize = 32;
313 pub const UT_NAMESIZE
: usize = 32;
314 pub const UT_HOSTSIZE
: usize = 256;
317 // Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
318 // exposed by the libc. As work-around, we implement it through `syscall`
319 // directly. This workaround can be removed if the minimum version of
320 // Android is bumped. When the workaround is removed, `accept4` can be
321 // moved back to `linux_like/mod.rs`
324 addr
: *mut ::sockaddr
,
325 len
: *mut ::socklen_t
,
328 ::syscall(SYS_accept4
, fd
, addr
, len
, flg
) as ::c_int
333 pub fn getauxval(type_
: ::c_ulong
) -> ::c_ulong
;
337 if #[cfg(target_arch = "x86_64")] {
339 pub use self::x86_64
::*;
340 } else if #[cfg(target_arch = "aarch64")] {
342 pub use self::aarch64
::*;
344 // Unknown target_arch