1#![allow(non_camel_case_types)]
2
3use core::ffi;
4
5pub type int = ffi::c_int;
7
8pub type uint = ffi::c_uint;
10
11pub type short = ffi::c_short;
13
14pub type ushort = ffi::c_ushort;
16
17pub type long = ffi::c_long;
19
20pub type ulong = ffi::c_ulong;
22
23pub type longlong = ffi::c_long;
25
26pub type ulonglong = ffi::c_ulong;
28
29pub type ssize_t = isize;
31
32pub type size_t = usize;
34
35pub type char = ffi::c_char;
37
38pub type uchar = ffi::c_uchar;
40
41pub type void = ffi::c_void;
43
44pub type mode_t = uint;
46
47pub type off_t = long;
49
50pub type loff_t = ffi::c_longlong;
52
53pub type pid_t = int;
55
56#[repr(C)]
68pub struct sockaddr {
69 pub family: sa_family_t,
70
71 data: [u8; 14],
75}
76
77#[repr(C, align(8))]
86pub struct sockaddr_storage {
87 pub family: sa_family_t,
88 pub data: [u8; 128 - core::mem::size_of::<sa_family_t>()],
89}
90
91pub type socklen_t = int;
93
94pub type uid_t = uint;
96
97pub type gid_t = uint;
99
100pub const SEEK_SET: int = 0;
102
103pub const SEEK_CUR: int = 1;
105
106pub const SEEK_END: int = 2;
108
109pub const SEEK_DATA: int = 3;
111
112pub const SEEK_HOLE: int = 4;
114
115pub const O_ACCMODE: int = 0o00000003;
116pub const O_RDONLY: int = 0o00000000;
117pub const O_WRONLY: int = 0o00000001;
118pub const O_RDWR: int = 0o00000002;
119pub const O_CREAT: int = 0o00000100;
120pub const O_EXCL: int = 0o00000200;
121pub const O_NOCTTY: int = 0o00000400;
122pub const O_TRUNC: int = 0o00001000;
123pub const O_APPEND: int = 0o00002000;
124pub const O_NONBLOCK: int = 0o00004000;
125pub const O_DSYNC: int = 0o00010000;
126pub const O_DIRECT: int = 0o00040000;
127pub const O_LARGEFILE: int = 0o00100000;
128pub const O_DIRECTORY: int = 0o00200000;
129pub const O_NOFOLLOW: int = 0o00400000;
130pub const O_NOATIME: int = 0o01000000;
131pub const O_CLOEXEC: int = 0o02000000;
132pub const O_SYNC: int = 0o04000000 | O_DSYNC;
133pub const O_PATH: int = 0o010000000;
134pub const O_TMPFILE: int = 0o020000000 | O_DIRECTORY;
135pub const O_TMPFILE_MASK: int = 0o020000000 | O_DIRECTORY | O_CREAT;
136pub const O_NDELAY: int = O_NONBLOCK;
137
138pub const AT_FDCWD: int = -100;
139pub const AT_EMPTY_PATH: int = 0x1000;
140pub const AT_SYMLINK_NOFOLLOW: int = 0x100;
141pub const AT_EACCESS: int = 0x200;
142pub const AT_REMOVEDIR: int = 0x200;
143pub const AT_SYMLINK_FOLLOW: int = 0x400;
144pub const AT_NO_AUTOMOUNT: int = 0x800;
145pub const AT_STATX_SYNC_TYPE: int = 0x6000;
146pub const AT_STATX_SYNC_AS_STAT: int = 0x0000;
147pub const AT_STATX_FORCE_SYNC: int = 0x2000;
148pub const AT_STATX_DONT_SYNC: int = 0x4000;
149pub const AT_RECURSIVE: int = 0x8000;
150pub const AT_HANDLE_FID: int = AT_REMOVEDIR;
151
152#[derive(Clone, Copy, Debug)]
154#[repr(C)]
155pub struct pollfd {
156 pub fd: int,
157 pub events: short,
158 pub revents: short,
159}
160
161pub type nfds_t = uint;
163
164pub const POLLIN: short = 0x0001;
165pub const POLLPRI: short = 0x0002;
166pub const POLLOUT: short = 0x0004;
167pub const POLLERR: short = 0x0008;
168pub const POLLHUP: short = 0x0010;
169pub const POLLNVAL: short = 0x0020;
170
171#[derive(Clone, Copy, Debug)]
173#[repr(C)]
174pub struct iovec {
175 pub iov_base: *mut void,
176 pub iov_len: size_t,
177}
178
179#[derive(Clone, Copy, Debug)]
181#[repr(C)]
182pub struct epoll_event {
183 pub events: u32,
184 pub data: epoll_data,
185}
186
187#[derive(Clone, Copy)]
189#[repr(C)]
190pub union epoll_data {
191 pub ptr: *mut void,
192 pub fd: int,
193 pub u32: u32,
194 pub u64: u64,
195}
196
197impl core::fmt::Debug for epoll_data {
198 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
199 f.debug_struct("epoll_data").finish_non_exhaustive()
200 }
201}
202
203#[derive(Clone, Copy, Debug)]
205#[repr(C)]
206pub struct flock {
207 pub l_type: short,
208 pub l_whence: short,
209 pub l_start: off_t,
210 pub l_len: off_t,
211 pub l_pid: pid_t,
212 }
217
218pub type sa_family_t = ushort;
220
221#[derive(Clone, Copy, Debug)]
223#[repr(C)]
224pub enum sock_type {
225 SOCK_STREAM = 1,
226 SOCK_DGRAM = 2,
227 SOCK_RAW = 3,
228 SOCK_RDM = 4,
229 SOCK_SEQPACKET = 5,
230 SOCK_DCCP = 6,
231 SOCK_PACKET = 10,
232}
233
234pub type time_t = long;
236
237pub type suseconds_t = long;
239
240#[derive(Clone, Copy, Debug)]
242#[repr(C)]
243pub struct timespec {
244 pub tv_sec: long,
245 pub tv_nsec: long,
246}
247
248#[derive(Clone, Copy, Debug)]
250#[repr(C)]
251pub struct timeval {
252 pub tv_sec: long,
253 pub tv_usec: suseconds_t,
254}
255
256#[derive(Debug)]
258#[repr(C)]
259pub struct linux_dirent {
260 pub d_ino: ulong,
261 pub d_off: ulong,
262 pub d_reclen: ushort,
263 pub d_name: [char],
264}
265
266pub type off64_t = longlong;
268
269pub type ino64_t = ulonglong;
271
272#[derive(Debug)]
274#[repr(C)]
275pub struct linux_dirent64 {
276 pub d_ino: ino64_t,
277 pub d_off: off64_t,
278 pub d_reclen: ushort,
279 pub d_type: uchar,
280 pub d_name: [char],
281}
282
283pub const DT_UNKNOWN: uchar = 0;
284pub const DT_FIFO: uchar = 1;
285pub const DT_CHR: uchar = 2;
286pub const DT_DIR: uchar = 4;
287pub const DT_BLK: uchar = 6;
288pub const DT_REG: uchar = 8;
289pub const DT_LNK: uchar = 10;
290pub const DT_SOCK: uchar = 12;
291pub const DT_WHT: uchar = 14;
292
293#[repr(C)]
294#[derive(Clone, Copy, Debug)]
295pub struct statx {
296 pub stx_mask: u32,
297 pub stx_blksize: u32,
298 pub stx_attributes: u64,
299 pub stx_nlink: u32,
300 pub stx_uid: u32,
301 pub stx_gid: u32,
302 pub stx_mode: u16,
303 pub stx_ino: u64,
304 pub stx_size: u64,
305 pub stx_blocks: u64,
306 pub stx_attributes_mask: u64,
307 pub stx_atime: statx_timestamp,
308 pub stx_btime: statx_timestamp,
309 pub stx_ctime: statx_timestamp,
310 pub stx_mtime: statx_timestamp,
311 pub stx_rdev_major: u32,
312 pub stx_rdev_minor: u32,
313 pub stx_dev_major: u32,
314 pub stx_dev_minor: u32,
315 pub stx_mnt_id: u64,
316 pub stx_dio_mem_align: u32,
317 pub stx_dio_offset_align: u32,
318}
319
320#[repr(C)]
321#[derive(Clone, Copy, Debug)]
322pub struct statx_timestamp {
323 pub tv_sec: i64,
324 pub tv_nsec: u32,
325}
326
327pub const STATX_TYPE: u32 = 1;
328pub const STATX_MODE: u32 = 2;
329pub const STATX_NLINK: u32 = 4;
330pub const STATX_UID: u32 = 8;
331pub const STATX_GID: u32 = 0x10;
332pub const STATX_ATIME: u32 = 0x20;
333pub const STATX_MTIME: u32 = 0x40;
334pub const STATX_CTIME: u32 = 0x80;
335pub const STATX_INO: u32 = 0x100;
336pub const STATX_SIZE: u32 = 0x200;
337pub const STATX_BLOCKS: u32 = 0x400;
338pub const STATX_BASIC_STATS: u32 = 0x7ff;
339pub const STATX_BTIME: u32 = 0x800;
340pub const STATX_ALL: u32 = 0xfff;
341pub const STATX_ATTR_COMPRESSED: u64 = 0x4;
342pub const STATX_ATTR_IMMUTABLE: u64 = 0x10;
343pub const STATX_ATTR_APPEND: u64 = 0x20;
344pub const STATX_ATTR_NODUMP: u64 = 0x40;
345pub const STATX_ATTR_ENCRYPTED: u64 = 0x800;
346pub const STATX_ATTR_AUTOMOUNT: u64 = 0x1000;
347pub const STATX_ATTR_MOUNT_ROOT: u64 = 0x2000;
348pub const STATX_ATTR_VERITY: u64 = 0x100000;
349pub const STATX_ATTR_DAX: u64 = 0x200000;
350
351#[derive(Clone, Copy, Debug)]
353#[repr(C)]
354pub struct io_uring_params {
355 pub sq_entries: u32,
356 pub cq_entries: u32,
357 pub flags: u32,
358 pub sq_thread_cpu: u32,
359 pub sq_thread_idle: u32,
360 pub features: u32,
361 pub wq_fd: u32,
362 pub resv: [u32; 3],
363 pub sq_off: io_sqring_offsets,
364 pub cq_off: io_cqring_offsets,
365}
366
367#[derive(Clone, Copy, Debug)]
369#[repr(C)]
370pub struct io_sqring_offsets {
371 pub head: u32,
372 pub tail: u32,
373 pub ring_mask: u32,
374 pub ring_entries: u32,
375 pub flags: u32,
376 pub dropped: u32,
377 pub array: u32,
378 pub resv: [u32; 3],
379}
380
381#[derive(Clone, Copy, Debug)]
383#[repr(C)]
384pub struct io_cqring_offsets {
385 pub head: u32,
386 pub tail: u32,
387 pub ring_mask: u32,
388 pub ring_entries: u32,
389 pub overflow: u32,
390 pub cqes: u32,
391 pub flags: u32,
392 pub resv: [u32; 3],
393}
394
395pub use crate::sigset::sigset_t;
396
397#[allow(unused_imports)]
399pub use crate::raw::types::*;
400
401pub const FUTEX_WAIT: int = 0;
402pub const FUTEX_WAKE: int = 1;
403pub const FUTEX_FD: int = 2;
404pub const FUTEX_REQUEUE: int = 3;
405pub const FUTEX_CMP_REQUEUE: int = 4;
406pub const FUTEX_WAKE_OP: int = 5;
407pub const FUTEX_LOCK_PI: int = 6;
408pub const FUTEX_UNLOCK_PI: int = 7;
409pub const FUTEX_TRYLOCK_PI: int = 8;
410pub const FUTEX_WAIT_BITSET: int = 9;
411pub const FUTEX_PRIVATE: int = 128;
412pub const FUTEX_CLOCK_REALTIME: int = 256;