Debian Codegraph @

debian/missing-sources/libc/src/unix/linux_like/android/b64/mod.rs

raw
1 use crate::prelude::*;
2
3 // The following definitions are correct for aarch64 and x86_64,
4 // but may be wrong for mips64
5
6 pub type mode_t = u32;
7 pub type off64_t = i64;
8 pub type socklen_t = u32;
9
10 s! {
11 pub struct sigset_t {
12 __val: [c_ulong; 1],
13 }
14
15 // FIXME(1.0): This should not implement `PartialEq`
16 #[allow(unpredictable_function_pointer_comparisons)]
17 pub struct sigaction {
18 pub sa_flags: c_int,
19 pub sa_sigaction: crate::sighandler_t,
20 pub sa_mask: crate::sigset_t,
21 pub sa_restorer: Option<extern "C" fn()>,
22 }
23
24 pub struct rlimit64 {
25 pub rlim_cur: c_ulonglong,
26 pub rlim_max: c_ulonglong,
27 }
28
29 pub struct pthread_attr_t {
30 pub flags: u32,
31 pub stack_base: *mut c_void,
32 pub stack_size: size_t,
33 pub guard_size: size_t,
34 pub sched_policy: i32,
35 pub sched_priority: i32,
36 __reserved: Padding<[c_char; 16]>,
37 }
38
39 pub struct passwd {
40 pub pw_name: *mut c_char,
41 pub pw_passwd: *mut c_char,
42 pub pw_uid: crate::uid_t,
43 pub pw_gid: crate::gid_t,
44 pub pw_gecos: *mut c_char,
45 pub pw_dir: *mut c_char,
46 pub pw_shell: *mut c_char,
47 }
48
49 pub struct statfs {
50 pub f_type: u64,
51 pub f_bsize: u64,
52 pub f_blocks: u64,
53 pub f_bfree: u64,
54 pub f_bavail: u64,
55 pub f_files: u64,
56 pub f_ffree: u64,
57 pub f_fsid: crate::__fsid_t,
58 pub f_namelen: u64,
59 pub f_frsize: u64,
60 pub f_flags: u64,
61 pub f_spare: [u64; 4],
62 }
63
64 pub struct sysinfo {
65 pub uptime: c_long,
66 pub loads: [c_ulong; 3],
67 pub totalram: c_ulong,
68 pub freeram: c_ulong,
69 pub sharedram: c_ulong,
70 pub bufferram: c_ulong,
71 pub totalswap: c_ulong,
72 pub freeswap: c_ulong,
73 pub procs: c_ushort,
74 pub pad: c_ushort,
75 pub totalhigh: c_ulong,
76 pub freehigh: c_ulong,
77 pub mem_unit: c_uint,
78 pub _f: [c_char; 0],
79 }
80
81 pub struct statfs64 {
82 pub f_type: u64,
83 pub f_bsize: u64,
84 pub f_blocks: u64,
85 pub f_bfree: u64,
86 pub f_bavail: u64,
87 pub f_files: u64,
88 pub f_ffree: u64,
89 pub f_fsid: crate::__fsid_t,
90 pub f_namelen: u64,
91 pub f_frsize: u64,
92 pub f_flags: u64,
93 pub f_spare: [u64; 4],
94 }
95
96 pub struct statvfs64 {
97 pub f_bsize: c_ulong,
98 pub f_frsize: c_ulong,
99 pub f_blocks: u64,
100 pub f_bfree: u64,
101 pub f_bavail: u64,
102 pub f_files: u64,
103 pub f_ffree: u64,
104 pub f_favail: u64,
105 pub f_fsid: c_ulong,
106 pub f_flag: c_ulong,
107 pub f_namemax: c_ulong,
108 __f_spare: [c_int; 6],
109 }
110
111 pub struct pthread_barrier_t {
112 __private: [i64; 4],
113 }
114
115 pub struct pthread_spinlock_t {
116 __private: i64,
117 }
118
119 pub struct pthread_mutex_t {
120 value: c_int,
121 __reserved: Padding<[c_char; 36]>,
122 }
123
124 pub struct pthread_cond_t {
125 value: c_int,
126 __reserved: Padding<[c_char; 44]>,
127 }
128
129 pub struct pthread_rwlock_t {
130 numLocks: c_int,
131 writerThreadId: c_int,
132 pendingReaders: c_int,
133 pendingWriters: c_int,
134 attr: i32,
135 __reserved: Padding<[c_char; 36]>,
136 }
137
138 pub struct sigset64_t {
139 __bits: [c_ulong; 1],
140 }
141 }
142
143 // These constants must be of the same type of sigaction.sa_flags
144 pub const SA_NOCLDSTOP: c_int = 0x00000001;
145 pub const SA_NOCLDWAIT: c_int = 0x00000002;
146 pub const SA_NODEFER: c_int = 0x40000000;
147 pub const SA_ONSTACK: c_int = 0x08000000;
148 pub const SA_RESETHAND: c_int = 0x80000000;
149 pub const SA_RESTART: c_int = 0x10000000;
150 pub const SA_SIGINFO: c_int = 0x00000004;
151
152 pub const RTLD_GLOBAL: c_int = 0x00100;
153 pub const RTLD_NOW: c_int = 2;
154 pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
155
156 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
157 value: 0,
158 __reserved: Padding::uninit(),
159 };
160 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
161 value: 0,
162 __reserved: Padding::uninit(),
163 };
164 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
165 numLocks: 0,
166 writerThreadId: 0,
167 pendingReaders: 0,
168 pendingWriters: 0,
169 attr: 0,
170 __reserved: Padding::uninit(),
171 };
172 pub const PTHREAD_STACK_MIN: size_t = 4096 * 4;
173 pub const CPU_SETSIZE: size_t = 1024;
174 pub const __CPU_BITS: size_t = 64;
175
176 pub const UT_LINESIZE: usize = 32;
177 pub const UT_NAMESIZE: usize = 32;
178 pub const UT_HOSTSIZE: usize = 256;
179
180 f! {
181 // Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
182 // exposed by the libc. As work-around, we implement it through `syscall`
183 // directly. This workaround can be removed if the minimum version of
184 // Android is bumped. When the workaround is removed, `accept4` can be
185 // moved back to `linux_like/mod.rs`
186 pub fn accept4(
187 fd: c_int,
188 addr: *mut crate::sockaddr,
189 len: *mut crate::socklen_t,
190 flg: c_int,
191 ) -> c_int {
192 crate::syscall(SYS_accept4, fd, addr, len, flg) as c_int
193 }
194 }
195
196 extern "C" {
197 pub fn __system_property_wait(
198 pi: *const crate::prop_info,
199 __old_serial: u32,
200 __new_serial_ptr: *mut u32,
201 __relative_timeout: *const crate::timespec,
202 ) -> bool;
203 }
204
205 cfg_if! {
206 if #[cfg(target_arch = "x86_64")] {
207 mod x86_64;
208 pub use self::x86_64::*;
209 } else if #[cfg(target_arch = "aarch64")] {
210 mod aarch64;
211 pub use self::aarch64::*;
212 } else if #[cfg(target_arch = "riscv64")] {
213 mod riscv64;
214 pub use self::riscv64::*;
215 } else {
216 // Unknown target_arch
217 }
218 }