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