makepad_platform/os/linux/
libc_sys.rs1#![allow(non_camel_case_types)]
2#![allow(non_snake_case)]
3
4use std::mem;
5
6#[cfg(target_pointer_width = "32")]
7mod libc_32{
8 pub const ULONG_SIZE: usize = 32;
9}
10#[cfg(target_pointer_width = "32")]
11pub use libc_32::*;
12
13#[cfg(target_pointer_width = "64")]
14mod libc_64{
15pub const ULONG_SIZE: usize = 64;
16}
17#[cfg(target_pointer_width = "64")]
18pub use libc_64::*;
19
20pub type time_t = c_ulong;
21pub type suseconds_t = c_ulong;
22
23type c_int = std::os::raw::c_int;
24type c_long = std::os::raw::c_long;
26type c_ulong = std::os::raw::c_ulong;
27type c_void = std::os::raw::c_void;
28type c_char = std::os::raw::c_char;
29type size_t = usize;
30
31pub const FD_SETSIZE: usize = 1024;
32pub const EPIPE: c_int = 32;
33pub const O_RDWR: c_int = 2;
34
35#[repr(C)]
36pub struct fd_set {
37 fds_bits: [c_ulong; FD_SETSIZE / ULONG_SIZE],
38}
39
40pub const RTLD_LAZY: c_int = 1;
41pub const RTLD_LOCAL: c_int = 0;
42pub const SYS_GETTID: c_long = 178;
43
44extern "C"{
45 pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
46 pub fn dlclose(handle: *mut c_void) -> c_int;
47 pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
48 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
49 pub fn close(fd: c_int) -> c_int;
50 pub fn free(arg1: *mut c_void);
51 pub fn pipe(fds: *mut c_int) -> c_int;
52 pub fn select(
53 nfds: c_int,
54 readfds: *mut fd_set,
55 writefds: *mut fd_set,
56 errorfds: *mut fd_set,
57 timeout: *mut timeval,
58 ) -> c_int;
59 pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> c_int;
60 pub fn syscall(num: c_long, ...) -> c_long;
61}
62
63pub unsafe fn FD_SET(fd: c_int, set: *mut fd_set) -> () {
64 let fd = fd as usize;
65 let size =mem::size_of_val(&(*set).fds_bits[0]) * 8;
66 (*set).fds_bits[fd / size] |= 1 << (fd % size);
67 return
68}
69
70pub unsafe fn FD_ZERO(set: *mut fd_set) -> () {
71 for slot in (*set).fds_bits.iter_mut() {
72 *slot = 0;
73 }
74}
75
76#[derive(Default, Clone, Copy, Debug)]
77#[repr(C)]
78pub struct timeval {
79 pub tv_sec: time_t,
80 pub tv_usec: suseconds_t,
81}
82