libc/unix/linux_like/linux/gnu/b32/
mod.rs

1//! 32-bit specific definitions for linux-like values
2
3use pthread_mutex_t;
4
5pub type c_long = i32;
6pub type c_ulong = u32;
7pub type clock_t = i32;
8pub type time_t = i32;
9pub type suseconds_t = i32;
10pub type ino_t = u32;
11pub type off_t = i32;
12pub type blkcnt_t = i32;
13
14pub type fsblkcnt_t = ::c_ulong;
15pub type fsfilcnt_t = ::c_ulong;
16pub type rlim_t = c_ulong;
17pub type shmatt_t = ::c_ulong;
18pub type msgqnum_t = ::c_ulong;
19pub type msglen_t = ::c_ulong;
20pub type blksize_t = i32;
21pub type nlink_t = u32;
22pub type __u64 = ::c_ulonglong;
23pub type __fsword_t = i32;
24
25s! {
26    pub struct stat {
27        #[cfg(not(target_arch = "mips"))]
28        pub st_dev: ::dev_t,
29        #[cfg(target_arch = "mips")]
30        pub st_dev: ::c_ulong,
31
32        #[cfg(not(target_arch = "mips"))]
33        __pad1: ::c_short,
34        #[cfg(target_arch = "mips")]
35        st_pad1: [::c_long; 3],
36        pub st_ino: ::ino_t,
37        pub st_mode: ::mode_t,
38        pub st_nlink: ::nlink_t,
39        pub st_uid: ::uid_t,
40        pub st_gid: ::gid_t,
41        #[cfg(not(target_arch = "mips"))]
42        pub st_rdev: ::dev_t,
43        #[cfg(target_arch = "mips")]
44        pub st_rdev: ::c_ulong,
45        #[cfg(not(target_arch = "mips"))]
46        __pad2: ::c_short,
47        #[cfg(target_arch = "mips")]
48        st_pad2: [::c_long; 2],
49        pub st_size: ::off_t,
50        #[cfg(target_arch = "mips")]
51        st_pad3: ::c_long,
52        #[cfg(not(target_arch = "mips"))]
53        pub st_blksize: ::blksize_t,
54        #[cfg(not(target_arch = "mips"))]
55        pub st_blocks: ::blkcnt_t,
56        pub st_atime: ::time_t,
57        pub st_atime_nsec: ::c_long,
58        pub st_mtime: ::time_t,
59        pub st_mtime_nsec: ::c_long,
60        pub st_ctime: ::time_t,
61        pub st_ctime_nsec: ::c_long,
62        #[cfg(not(target_arch = "mips"))]
63        __unused4: ::c_long,
64        #[cfg(not(target_arch = "mips"))]
65        __unused5: ::c_long,
66        #[cfg(target_arch = "mips")]
67        pub st_blksize: ::blksize_t,
68        #[cfg(target_arch = "mips")]
69        pub st_blocks: ::blkcnt_t,
70        #[cfg(target_arch = "mips")]
71        st_pad5: [::c_long; 14],
72    }
73
74    pub struct statvfs {
75        pub f_bsize: ::c_ulong,
76        pub f_frsize: ::c_ulong,
77        pub f_blocks: ::fsblkcnt_t,
78        pub f_bfree: ::fsblkcnt_t,
79        pub f_bavail: ::fsblkcnt_t,
80        pub f_files: ::fsfilcnt_t,
81        pub f_ffree: ::fsfilcnt_t,
82        pub f_favail: ::fsfilcnt_t,
83        pub f_fsid: ::c_ulong,
84        __f_unused: ::c_int,
85        pub f_flag: ::c_ulong,
86        pub f_namemax: ::c_ulong,
87        __f_spare: [::c_int; 6],
88    }
89
90    pub struct pthread_attr_t {
91        __size: [u32; 9]
92    }
93
94    pub struct sigset_t {
95        __val: [::c_ulong; 32],
96    }
97
98    pub struct sysinfo {
99        pub uptime: ::c_long,
100        pub loads: [::c_ulong; 3],
101        pub totalram: ::c_ulong,
102        pub freeram: ::c_ulong,
103        pub sharedram: ::c_ulong,
104        pub bufferram: ::c_ulong,
105        pub totalswap: ::c_ulong,
106        pub freeswap: ::c_ulong,
107        pub procs: ::c_ushort,
108        #[deprecated(
109            since = "0.2.58",
110            note = "This padding field might become private in the future"
111        )]
112        pub pad: ::c_ushort,
113        pub totalhigh: ::c_ulong,
114        pub freehigh: ::c_ulong,
115        pub mem_unit: ::c_uint,
116        pub _f: [::c_char; 8],
117    }
118}
119
120pub const O_NOATIME: ::c_int = 0o1000000;
121pub const O_PATH: ::c_int = 0o10000000;
122pub const O_TMPFILE: ::c_int = 0o20000000 | O_DIRECTORY;
123
124pub const SO_PRIORITY: ::c_int = 12;
125pub const SO_BSDCOMPAT: ::c_int = 14;
126pub const SO_BINDTODEVICE: ::c_int = 25;
127pub const SO_TIMESTAMP: ::c_int = 29;
128pub const SO_MARK: ::c_int = 36;
129pub const SO_RXQ_OVFL: ::c_int = 40;
130pub const SO_PEEK_OFF: ::c_int = 42;
131pub const SO_BUSY_POLL: ::c_int = 46;
132
133pub const SA_ONSTACK: ::c_int = 0x08000000;
134
135pub const PTRACE_DETACH: ::c_uint = 17;
136pub const POSIX_FADV_DONTNEED: ::c_int = 4;
137pub const POSIX_FADV_NOREUSE: ::c_int = 5;
138
139pub const F_SETLK: ::c_int = 6;
140pub const F_SETLKW: ::c_int = 7;
141
142pub const F_RDLCK: ::c_int = 0;
143pub const F_WRLCK: ::c_int = 1;
144pub const F_UNLCK: ::c_int = 2;
145
146pub const SFD_CLOEXEC: ::c_int = 0x080000;
147
148pub const NCCS: usize = 32;
149
150pub const O_TRUNC: ::c_int = 512;
151
152pub const O_CLOEXEC: ::c_int = 0x80000;
153
154pub const EBFONT: ::c_int = 59;
155pub const ENOSTR: ::c_int = 60;
156pub const ENODATA: ::c_int = 61;
157pub const ETIME: ::c_int = 62;
158pub const ENOSR: ::c_int = 63;
159pub const ENONET: ::c_int = 64;
160pub const ENOPKG: ::c_int = 65;
161pub const EREMOTE: ::c_int = 66;
162pub const ENOLINK: ::c_int = 67;
163pub const EADV: ::c_int = 68;
164pub const ESRMNT: ::c_int = 69;
165pub const ECOMM: ::c_int = 70;
166pub const EPROTO: ::c_int = 71;
167pub const EDOTDOT: ::c_int = 73;
168
169pub const SA_NODEFER: ::c_int = 0x40000000;
170pub const SA_RESETHAND: ::c_int = 0x80000000;
171pub const SA_RESTART: ::c_int = 0x10000000;
172pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
173
174pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
175
176pub const EFD_CLOEXEC: ::c_int = 0x80000;
177
178pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
179pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
180pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
181pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
182pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
183
184align_const! {
185    #[cfg(target_endian = "little")]
186    pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t =
187        pthread_mutex_t {
188            size: [
189                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0,
190                0, 0, 0,
191            ],
192        };
193    #[cfg(target_endian = "little")]
194    pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t =
195        pthread_mutex_t {
196            size: [
197                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
198                0, 0, 0,
199            ],
200        };
201    #[cfg(target_endian = "little")]
202    pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t =
203        pthread_mutex_t {
204            size: [
205                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0,
206                0, 0, 0,
207            ],
208        };
209    #[cfg(target_endian = "big")]
210    pub const PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t =
211        pthread_mutex_t {
212            size: [
213                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
214                0, 0, 0,
215            ],
216        };
217    #[cfg(target_endian = "big")]
218    pub const PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP: ::pthread_mutex_t =
219        pthread_mutex_t {
220            size: [
221                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0,
222                0, 0, 0,
223            ],
224        };
225    #[cfg(target_endian = "big")]
226    pub const PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP: ::pthread_mutex_t =
227        pthread_mutex_t {
228            size: [
229                0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0,
230                0, 0, 0,
231            ],
232        };
233}
234
235pub const PTRACE_GETFPREGS: ::c_uint = 14;
236pub const PTRACE_SETFPREGS: ::c_uint = 15;
237pub const PTRACE_GETREGS: ::c_uint = 12;
238pub const PTRACE_SETREGS: ::c_uint = 13;
239
240#[link(name = "util")]
241extern "C" {
242    pub fn sysctl(
243        name: *mut ::c_int,
244        namelen: ::c_int,
245        oldp: *mut ::c_void,
246        oldlenp: *mut ::size_t,
247        newp: *mut ::c_void,
248        newlen: ::size_t,
249    ) -> ::c_int;
250}
251
252cfg_if! {
253    if #[cfg(target_arch = "x86")] {
254        mod x86;
255        pub use self::x86::*;
256    } else if #[cfg(target_arch = "arm")] {
257        mod arm;
258        pub use self::arm::*;
259    } else if #[cfg(target_arch = "mips")] {
260        mod mips;
261        pub use self::mips::*;
262    } else if #[cfg(target_arch = "powerpc")] {
263        mod powerpc;
264        pub use self::powerpc::*;
265    } else if #[cfg(target_arch = "sparc")] {
266        mod sparc;
267        pub use self::sparc::*;
268    } else {
269        // Unknown target_arch
270    }
271}