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_ulong = std::os::raw::c_ulong;
26type c_void = std::os::raw::c_void;
27type c_char = std::os::raw::c_char;
28type size_t = usize;
29
30pub const FD_SETSIZE: usize = 1024;
31pub const EPIPE: c_int = 32;
32pub const O_RDWR: c_int = 2;
33
34#[repr(C)]
35pub struct fd_set {
36 fds_bits: [c_ulong; FD_SETSIZE / ULONG_SIZE],
37}
38
39pub const RTLD_LAZY: c_int = 1;
40pub const RTLD_LOCAL: c_int = 0;
41
42extern "C"{
43 pub fn dlopen(filename: *const c_char, flag: c_int) -> *mut c_void;
44 pub fn dlclose(handle: *mut c_void) -> c_int;
45 pub fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void;
46 pub fn open(path: *const c_char, oflag: c_int, ...) -> c_int;
47 pub fn close(fd: c_int) -> c_int;
48 pub fn free(arg1: *mut c_void);
49 pub fn pipe(fds: *mut c_int) -> c_int;
50 pub fn select(
51 nfds: c_int,
52 readfds: *mut fd_set,
53 writefds: *mut fd_set,
54 errorfds: *mut fd_set,
55 timeout: *mut timeval,
56 ) -> c_int;
57 pub fn read(fd: c_int, buf: *mut c_void, count: size_t) -> c_int;
58}
59
60pub unsafe fn FD_SET(fd: c_int, set: *mut fd_set) -> () {
61 let fd = fd as usize;
62 let size =mem::size_of_val(&(*set).fds_bits[0]) * 8;
63 (*set).fds_bits[fd / size] |= 1 << (fd % size);
64 return
65}
66
67pub unsafe fn FD_ZERO(set: *mut fd_set) -> () {
68 for slot in (*set).fds_bits.iter_mut() {
69 *slot = 0;
70 }
71}
72
73#[derive(Default, Clone, Copy, Debug)]
74#[repr(C)]
75pub struct timeval {
76 pub tv_sec: time_t,
77 pub tv_usec: suseconds_t,
78}
79