]> git.proxmox.com Git - rustc.git/blame - src/liblibc/src/unix/uclibc/x86_64/mod.rs
New upstream version 1.27.1+dfsg1
[rustc.git] / src / liblibc / src / unix / uclibc / x86_64 / mod.rs
CommitLineData
3b2f2976
XL
1//! Definitions for uclibc on 64bit systems
2//!
041b39d2
XL
3pub type blkcnt_t = i64;
4pub type blksize_t = i64;
3b2f2976 5pub type clock_t = i64;
041b39d2
XL
6pub type c_char = u8;
7pub type c_long = i64;
8pub type c_ulong = u64;
9pub type fsblkcnt_t = ::c_ulong;
10pub type fsfilcnt_t = ::c_ulong;
11pub type fsword_t = ::c_long;
12pub type ino_t = ::c_ulong;
13pub type nlink_t = ::c_uint;
14pub type off_t = ::c_long;
15pub type rlim_t = c_ulong;
16pub type rlim64_t = u64;
3b2f2976
XL
17// [uClibc docs] Note stat64 has the same shape as stat for x86-64.
18pub type stat64 = stat;
041b39d2
XL
19pub type suseconds_t = ::c_long;
20pub type time_t = ::c_int;
21pub type wchar_t = ::c_int;
22
041b39d2
XL
23pub type nfds_t = ::c_ulong;
24
25s! {
3b2f2976
XL
26 pub struct dirent {
27 pub d_ino: ::ino64_t,
28 pub d_off: ::off64_t,
29 pub d_reclen: u16,
30 pub d_type: u8,
31 pub d_name: [::c_char; 256],
32 }
33
34 pub struct dirent64 {
35 pub d_ino: ::ino64_t,
36 pub d_off: ::off64_t,
37 pub d_reclen: u16,
38 pub d_type: u8,
39 pub d_name: [::c_char; 256],
40 }
41
42 pub struct ipc_perm {
43 pub __key: ::key_t,
44 pub uid: ::uid_t,
45 pub gid: ::gid_t,
46 pub cuid: ::uid_t,
47 pub cgid: ::gid_t,
48 pub mode: ::c_ushort, // read / write
49 __pad1: ::c_ushort,
50 pub __seq: ::c_ushort,
51 __pad2: ::c_ushort,
52 __unused1: ::c_ulong,
53 __unused2: ::c_ulong
54 }
55
56 #[cfg(not(target_os = "l4re"))]
57 pub struct pthread_attr_t {
58 __detachstate: ::c_int,
59 __schedpolicy: ::c_int,
60 __schedparam: __sched_param,
61 __inheritsched: ::c_int,
62 __scope: ::c_int,
63 __guardsize: ::size_t,
64 __stackaddr_set: ::c_int,
65 __stackaddr: *mut ::c_void, // better don't use it
66 __stacksize: ::size_t,
67 }
68
69 pub struct __sched_param {
70 __sched_priority: ::c_int,
041b39d2
XL
71 }
72
3b2f2976
XL
73 pub struct siginfo_t {
74 si_signo: ::c_int, // signal number
75 si_errno: ::c_int, // if not zero: error value of signal, see errno.h
76 si_code: ::c_int, // signal code
77 pub _pad: [::c_int; 28], // unported union
78 _align: [usize; 0],
79 }
80
81 pub struct shmid_ds {
82 pub shm_perm: ::ipc_perm,
83 pub shm_segsz: ::size_t, // segment size in bytes
84 pub shm_atime: ::time_t, // time of last shmat()
85 pub shm_dtime: ::time_t,
86 pub shm_ctime: ::time_t,
87 pub shm_cpid: ::pid_t,
88 pub shm_lpid: ::pid_t,
89 pub shm_nattch: ::shmatt_t,
90 __unused1: ::c_ulong,
91 __unused2: ::c_ulong
92 }
93
94 pub struct msqid_ds {
95 pub msg_perm: ::ipc_perm,
96 pub msg_stime: ::time_t,
97 pub msg_rtime: ::time_t,
98 pub msg_ctime: ::time_t,
99 __msg_cbytes: ::c_ulong,
100 pub msg_qnum: ::msgqnum_t,
101 pub msg_qbytes: ::msglen_t,
102 pub msg_lspid: ::pid_t,
103 pub msg_lrpid: ::pid_t,
104 __ignored1: ::c_ulong,
105 __ignored2: ::c_ulong,
041b39d2
XL
106 }
107
108 pub struct sockaddr {
3b2f2976 109 pub sa_family: ::sa_family_t,
041b39d2
XL
110 pub sa_data: [::c_char; 14],
111 }
112
113 pub struct sockaddr_in {
3b2f2976 114 pub sin_family: ::sa_family_t,
041b39d2
XL
115 pub sin_port: ::in_port_t,
116 pub sin_addr: ::in_addr,
117 pub sin_zero: [u8; 8],
118 }
119
120 pub struct sockaddr_in6 {
3b2f2976
XL
121 pub sin6_family: ::sa_family_t,
122 pub sin6_port: ::in_port_t,
041b39d2
XL
123 pub sin6_flowinfo: u32,
124 pub sin6_addr: ::in6_addr,
125 pub sin6_scope_id: u32,
126 }
127
128 // ------------------------------------------------------------
129 // definitions below are *unverified* and might **break** the software
3b2f2976
XL
130// pub struct in_addr {
131// pub s_addr: in_addr_t,
132// }
133//
134// pub struct in6_addr {
135// pub s6_addr: [u8; 16],
136// __align: [u32; 0],
137// }
138
139 pub struct stat {
041b39d2 140 pub st_dev: ::c_ulong,
041b39d2 141 pub st_ino: ::ino_t,
3b2f2976
XL
142 // According to uclibc/libc/sysdeps/linux/x86_64/bits/stat.h, order of
143 // nlink and mode are swapped on 64 bit systems.
041b39d2 144 pub st_nlink: ::nlink_t,
3b2f2976 145 pub st_mode: ::mode_t,
041b39d2
XL
146 pub st_uid: ::uid_t,
147 pub st_gid: ::gid_t,
3b2f2976
XL
148 pub st_rdev: ::c_ulong, // dev_t
149 pub st_size: off_t, // file size
150 pub st_blksize: ::blksize_t,
151 pub st_blocks: ::blkcnt_t,
041b39d2 152 pub st_atime: ::time_t,
3b2f2976 153 pub st_atime_nsec: ::c_ulong,
041b39d2 154 pub st_mtime: ::time_t,
3b2f2976 155 pub st_mtime_nsec: ::c_ulong,
041b39d2 156 pub st_ctime: ::time_t,
3b2f2976
XL
157 pub st_ctime_nsec: ::c_ulong,
158 st_pad4: [::c_long; 3]
041b39d2
XL
159 }
160
3b2f2976
XL
161 pub struct sigaction {
162 pub sa_handler: ::sighandler_t,
163 pub sa_flags: ::c_ulong,
164 pub sa_restorer: *mut ::c_void,
041b39d2 165 pub sa_mask: ::sigset_t,
041b39d2
XL
166 }
167
168 pub struct stack_t { // ToDo
169 pub ss_sp: *mut ::c_void,
170 pub ss_flags: ::c_int,
171 pub ss_size: ::size_t
172 }
173
174 pub struct statfs { // ToDo
175 pub f_type: fsword_t,
176 pub f_bsize: fsword_t,
177 pub f_blocks: ::fsblkcnt_t,
178 pub f_bfree: ::fsblkcnt_t,
179 pub f_bavail: ::fsblkcnt_t,
180 pub f_files: ::fsfilcnt_t,
181 pub f_ffree: ::fsfilcnt_t,
182 pub f_fsid: ::fsid_t,
183 pub f_namelen: fsword_t,
184 pub f_frsize: fsword_t,
185 f_spare: [fsword_t; 5],
186 }
187
188 pub struct msghdr { // ToDo
189 pub msg_name: *mut ::c_void,
190 pub msg_namelen: ::socklen_t,
191 pub msg_iov: *mut ::iovec,
192 pub msg_iovlen: ::size_t,
193 pub msg_control: *mut ::c_void,
194 pub msg_controllen: ::size_t,
195 pub msg_flags: ::c_int,
196 }
197
198 pub struct termios { // ToDo
199 pub c_iflag: ::tcflag_t,
200 pub c_oflag: ::tcflag_t,
201 pub c_cflag: ::tcflag_t,
202 pub c_lflag: ::tcflag_t,
203 pub c_line: ::cc_t,
204 pub c_cc: [::cc_t; ::NCCS],
205 }
206
207 pub struct sem_t { // ToDo
208 #[cfg(target_pointer_width = "32")]
209 __size: [::c_char; 16],
210 #[cfg(target_pointer_width = "64")]
211 __size: [::c_char; 32],
212 __align: [::c_long; 0],
213 }
214
215 pub struct pthread_mutex_t { // ToDo
216 #[cfg(any(target_arch = "mips", target_arch = "arm",
217 target_arch = "powerpc"))]
218 __align: [::c_long; 0],
219 #[cfg(not(any(target_arch = "mips", target_arch = "arm",
220 target_arch = "powerpc")))]
221 __align: [::c_longlong; 0],
222 size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
223 }
224
225 pub struct pthread_mutexattr_t { // ToDo
226 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
227 target_arch = "mips64", target_arch = "s390x",
228 target_arch = "sparc64"))]
229 __align: [::c_int; 0],
230 #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
231 target_arch = "mips64", target_arch = "s390x",
232 target_arch = "sparc64")))]
233 __align: [::c_long; 0],
234 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
235 }
236
237 pub struct pthread_cond_t { // ToDo
238 __align: [::c_longlong; 0],
239 size: [u8; __SIZEOF_PTHREAD_COND_T],
240 }
241
242 pub struct pthread_condattr_t { // ToDo
243 __align: [::c_int; 0],
244 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
245 }
246
247 pub struct pthread_rwlock_t { // ToDo
248 #[cfg(any(target_arch = "mips", target_arch = "arm",
249 target_arch = "powerpc"))]
250 __align: [::c_long; 0],
251 #[cfg(not(any(target_arch = "mips", target_arch = "arm",
252 target_arch = "powerpc")))]
253 __align: [::c_longlong; 0],
254 size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
255 }
256
257 pub struct sigset_t { // ToDo
258 __val: [::c_ulong; 16],
259 }
260
261 pub struct sysinfo { // ToDo
262 pub uptime: ::c_long,
263 pub loads: [::c_ulong; 3],
264 pub totalram: ::c_ulong,
265 pub freeram: ::c_ulong,
266 pub sharedram: ::c_ulong,
267 pub bufferram: ::c_ulong,
268 pub totalswap: ::c_ulong,
269 pub freeswap: ::c_ulong,
270 pub procs: ::c_ushort,
271 pub pad: ::c_ushort,
272 pub totalhigh: ::c_ulong,
273 pub freehigh: ::c_ulong,
274 pub mem_unit: ::c_uint,
275 pub _f: [::c_char; 0],
276 }
277
278 pub struct glob_t { // ToDo
279 pub gl_pathc: ::size_t,
280 pub gl_pathv: *mut *mut c_char,
281 pub gl_offs: ::size_t,
282 pub gl_flags: ::c_int,
283 __unused1: *mut ::c_void,
284 __unused2: *mut ::c_void,
285 __unused3: *mut ::c_void,
286 __unused4: *mut ::c_void,
287 __unused5: *mut ::c_void,
288 }
289
041b39d2
XL
290 pub struct rlimit64 { // ToDo
291 pub rlim_cur: rlim64_t,
292 pub rlim_max: rlim64_t,
293 }
294
295 pub struct cpu_set_t { // ToDo
296 #[cfg(target_pointer_width = "32")]
297 bits: [u32; 32],
298 #[cfg(target_pointer_width = "64")]
299 bits: [u64; 16],
300 }
301
041b39d2
XL
302 pub struct fsid_t { // ToDo
303 __val: [::c_int; 2],
304 }
305}
306
307// constants
3b2f2976
XL
308pub const EADDRINUSE: ::c_int = 98; // Address already in use
309pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address
310pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort
311pub const ECONNREFUSED: ::c_int = 111; // Connection refused
312pub const ECONNRESET: ::c_int = 104; // Connection reset by peer
313pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur
314pub const ENOSYS: ::c_int = 38; // Function not implemented
315pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected
316pub const ETIMEDOUT: ::c_int = 110; // connection timed out
317pub const O_APPEND: ::c_int = 02000;
318pub const O_ACCMODE: ::c_int = 0003;
041b39d2 319pub const O_CLOEXEC: ::c_int = 0x80000;
3b2f2976 320pub const O_CREAT: ::c_int = 0100;
041b39d2 321pub const O_DIRECTORY: ::c_int = 0200000;
3b2f2976
XL
322pub const O_EXCL: ::c_int = 0200;
323pub const O_NONBLOCK: ::c_int = 04000;
324pub const O_TRUNC: ::c_int = 01000;
041b39d2 325pub const NCCS: usize = 32;
3b2f2976
XL
326pub const SIG_SETMASK: ::c_int = 2; // Set the set of blocked signals
327pub const PTHREAD_STACK_MIN: usize = 16384;
041b39d2
XL
328pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
329pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
3b2f2976
XL
330pub const SO_BROADCAST: ::c_int = 6;
331pub const SOCK_DGRAM: ::c_int = 2; // connectionless, unreliable datagrams
332pub const SOCK_STREAM: ::c_int = 1; // …/common/bits/socket_type.h
333pub const SO_ERROR: ::c_int = 4;
334pub const SOL_SOCKET: ::c_int = 1;
335pub const SO_RCVTIMEO: ::c_int = 20;
336pub const SO_REUSEADDR: ::c_int = 2;
337pub const SO_SNDTIMEO: ::c_int = 21;
041b39d2
XL
338pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
339pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
340pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
341pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
3b2f2976 342pub const RLIM_INFINITY: u64 = 0xffffffffffffffff;
041b39d2
XL
343pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
344pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
345pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
346
347extern {
348 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
349}
3b2f2976
XL
350
351cfg_if! {
352 if #[cfg(target_os = "l4re")] {
353 mod l4re;
354 pub use self::l4re::*;
83c7162d
XL
355 } else {
356 mod other;
357 pub use other::*;
358 }
3b2f2976
XL
359}
360