1 // The following definitions are correct for arm and i686,
2 // but may be wrong for mips
3 
4 pub type c_long = i32;
5 pub type c_ulong = u32;
6 pub type mode_t = u16;
7 pub type off64_t = ::c_longlong;
8 pub type sigset_t = ::c_ulong;
9 pub type socklen_t = i32;
10 pub type time64_t = i64;
11 
12 s! {
13     pub struct sigaction {
14         pub sa_sigaction: ::sighandler_t,
15         pub sa_mask: ::sigset_t,
16         pub sa_flags: ::c_int,
17         pub sa_restorer: ::Option<extern fn()>,
18     }
19 
20     pub struct rlimit64 {
21         pub rlim_cur: u64,
22         pub rlim_max: u64,
23     }
24 
25     pub struct stat {
26         pub st_dev: ::c_ulonglong,
27         __pad0: [::c_uchar; 4],
28         __st_ino: ::ino_t,
29         pub st_mode: ::c_uint,
30         pub st_nlink: ::nlink_t,
31         pub st_uid: ::uid_t,
32         pub st_gid: ::gid_t,
33         pub st_rdev: ::c_ulonglong,
34         __pad3: [::c_uchar; 4],
35         pub st_size: ::c_longlong,
36         pub st_blksize: ::blksize_t,
37         pub st_blocks: ::c_ulonglong,
38         pub st_atime: ::c_long,
39         pub st_atime_nsec: ::c_long,
40         pub st_mtime: ::c_long,
41         pub st_mtime_nsec: ::c_long,
42         pub st_ctime: ::c_long,
43         pub st_ctime_nsec: ::c_long,
44         pub st_ino: ::c_ulonglong,
45     }
46 
47     pub struct stat64 {
48         pub st_dev: ::c_ulonglong,
49         __pad0: [::c_uchar; 4],
50         __st_ino: ::ino_t,
51         pub st_mode: ::c_uint,
52         pub st_nlink: ::nlink_t,
53         pub st_uid: ::uid_t,
54         pub st_gid: ::gid_t,
55         pub st_rdev: ::c_ulonglong,
56         __pad3: [::c_uchar; 4],
57         pub st_size: ::c_longlong,
58         pub st_blksize: ::blksize_t,
59         pub st_blocks: ::c_ulonglong,
60         pub st_atime: ::c_long,
61         pub st_atime_nsec: ::c_long,
62         pub st_mtime: ::c_long,
63         pub st_mtime_nsec: ::c_long,
64         pub st_ctime: ::c_long,
65         pub st_ctime_nsec: ::c_long,
66         pub st_ino: ::c_ulonglong,
67     }
68 
69     pub struct statfs64 {
70         pub f_type: u32,
71         pub f_bsize: u32,
72         pub f_blocks: u64,
73         pub f_bfree: u64,
74         pub f_bavail: u64,
75         pub f_files: u64,
76         pub f_ffree: u64,
77         pub f_fsid: ::__fsid_t,
78         pub f_namelen: u32,
79         pub f_frsize: u32,
80         pub f_flags: u32,
81         pub f_spare: [u32; 4],
82     }
83 
84     pub struct statvfs64 {
85         pub f_bsize: ::c_ulong,
86         pub f_frsize: ::c_ulong,
87         pub f_blocks: ::c_ulong,
88         pub f_bfree: ::c_ulong,
89         pub f_bavail: ::c_ulong,
90         pub f_files: ::c_ulong,
91         pub f_ffree: ::c_ulong,
92         pub f_favail: ::c_ulong,
93         pub f_fsid: ::c_ulong,
94         pub f_flag: ::c_ulong,
95         pub f_namemax: ::c_ulong,
96     }
97 
98     pub struct pthread_attr_t {
99         pub flags: u32,
100         pub stack_base: *mut ::c_void,
101         pub stack_size: ::size_t,
102         pub guard_size: ::size_t,
103         pub sched_policy: i32,
104         pub sched_priority: i32,
105     }
106 
107     pub struct pthread_mutex_t { value: ::c_int }
108 
109     pub struct pthread_cond_t { value: ::c_int }
110 
111     pub struct pthread_rwlock_t {
112         lock: pthread_mutex_t,
113         cond: pthread_cond_t,
114         numLocks: ::c_int,
115         writerThreadId: ::c_int,
116         pendingReaders: ::c_int,
117         pendingWriters: ::c_int,
118         attr: i32,
119         __reserved: [::c_char; 12],
120     }
121 
122     pub struct passwd {
123         pub pw_name: *mut ::c_char,
124         pub pw_passwd: *mut ::c_char,
125         pub pw_uid: ::uid_t,
126         pub pw_gid: ::gid_t,
127         pub pw_dir: *mut ::c_char,
128         pub pw_shell: *mut ::c_char,
129     }
130 
131     pub struct statfs {
132         pub f_type: u32,
133         pub f_bsize: u32,
134         pub f_blocks: u64,
135         pub f_bfree: u64,
136         pub f_bavail: u64,
137         pub f_files: u64,
138         pub f_ffree: u64,
139         pub f_fsid: ::__fsid_t,
140         pub f_namelen: u32,
141         pub f_frsize: u32,
142         pub f_flags: u32,
143         pub f_spare: [u32; 4],
144     }
145 
146     pub struct sysinfo {
147         pub uptime: ::c_long,
148         pub loads: [::c_ulong; 3],
149         pub totalram: ::c_ulong,
150         pub freeram: ::c_ulong,
151         pub sharedram: ::c_ulong,
152         pub bufferram: ::c_ulong,
153         pub totalswap: ::c_ulong,
154         pub freeswap: ::c_ulong,
155         pub procs: ::c_ushort,
156         pub pad: ::c_ushort,
157         pub totalhigh: ::c_ulong,
158         pub freehigh: ::c_ulong,
159         pub mem_unit: ::c_uint,
160         pub _f: [::c_char; 8],
161     }
162 }
163 
164 s_no_extra_traits! {
165     pub struct sigset64_t {
166         __bits: [::c_ulong; 2]
167     }
168 }
169 
170 cfg_if! {
171     if #[cfg(feature = "extra_traits")] {
172         impl ::fmt::Debug for sigset64_t {
173             fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
174                 f.debug_struct("sigset64_t")
175                     .field("__bits", &self.__bits)
176                     .finish()
177             }
178         }
179     }
180 }
181 
182 // These constants must be of the same type of sigaction.sa_flags
183 pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
184 pub const SA_NOCLDWAIT: ::c_int = 0x00000002;
185 pub const SA_NODEFER: ::c_int = 0x40000000;
186 pub const SA_ONSTACK: ::c_int = 0x08000000;
187 pub const SA_RESETHAND: ::c_int = 0x80000000;
188 pub const SA_RESTART: ::c_int = 0x10000000;
189 pub const SA_SIGINFO: ::c_int = 0x00000004;
190 
191 pub const RTLD_GLOBAL: ::c_int = 2;
192 pub const RTLD_NOW: ::c_int = 0;
193 pub const RTLD_DEFAULT: *mut ::c_void = -1isize as *mut ::c_void;
194 
195 pub const PTRACE_GETFPREGS: ::c_int = 14;
196 pub const PTRACE_SETFPREGS: ::c_int = 15;
197 pub const PTRACE_GETREGS: ::c_int = 12;
198 pub const PTRACE_SETREGS: ::c_int = 13;
199 
200 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { value: 0 };
201 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { value: 0 };
202 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
203     lock: PTHREAD_MUTEX_INITIALIZER,
204     cond: PTHREAD_COND_INITIALIZER,
205     numLocks: 0,
206     writerThreadId: 0,
207     pendingReaders: 0,
208     pendingWriters: 0,
209     attr: 0,
210     __reserved: [0; 12],
211 };
212 pub const PTHREAD_STACK_MIN: ::size_t = 4096 * 2;
213 pub const CPU_SETSIZE: ::size_t = 32;
214 pub const __CPU_BITS: ::size_t = 32;
215 
216 pub const UT_LINESIZE: usize = 8;
217 pub const UT_NAMESIZE: usize = 8;
218 pub const UT_HOSTSIZE: usize = 16;
219 
220 pub const SIGSTKSZ: ::size_t = 8192;
221 pub const MINSIGSTKSZ: ::size_t = 2048;
222 
223 extern "C" {
timegm64(tm: *const ::tm) -> ::time64_t224     pub fn timegm64(tm: *const ::tm) -> ::time64_t;
225 }
226 
227 cfg_if! {
228     if #[cfg(target_arch = "x86")] {
229         mod x86;
230         pub use self::x86::*;
231     } else if #[cfg(target_arch = "arm")] {
232         mod arm;
233         pub use self::arm::*;
234     } else {
235         // Unknown target_arch
236     }
237 }
238