| 1 |
//! Hermit C type definitions |
| 2 |
|
| 3 |
use crate::prelude::*; |
| 4 |
|
| 5 |
pub type intmax_t = i64; |
| 6 |
pub type uintmax_t = u64; |
| 7 |
pub type intptr_t = isize; |
| 8 |
pub type uintptr_t = usize; |
| 9 |
|
| 10 |
pub type size_t = usize; |
| 11 |
pub type ssize_t = isize; |
| 12 |
pub type ptrdiff_t = isize; |
| 13 |
|
| 14 |
pub type clockid_t = i32; |
| 15 |
pub type in_addr_t = u32; |
| 16 |
pub type in_port_t = u16; |
| 17 |
pub type mode_t = u32; |
| 18 |
pub type nfds_t = usize; |
| 19 |
pub type pid_t = i32; |
| 20 |
pub type sa_family_t = u8; |
| 21 |
pub type socklen_t = u32; |
| 22 |
pub type time_t = i64; |
| 23 |
|
| 24 |
s! { |
| 25 |
pub struct addrinfo { |
| 26 |
pub ai_flags: i32, |
| 27 |
pub ai_family: i32, |
| 28 |
pub ai_socktype: i32, |
| 29 |
pub ai_protocol: i32, |
| 30 |
pub ai_addrlen: socklen_t, |
| 31 |
pub ai_canonname: *mut c_char, |
| 32 |
pub ai_addr: *mut sockaddr, |
| 33 |
pub ai_next: *mut addrinfo, |
| 34 |
} |
| 35 |
|
| 36 |
pub struct dirent64 { |
| 37 |
pub d_ino: u64, |
| 38 |
pub d_off: i64, |
| 39 |
pub d_reclen: u16, |
| 40 |
pub d_type: u8, |
| 41 |
pub d_name: [c_char; 256], |
| 42 |
} |
| 43 |
|
| 44 |
#[repr(align(4))] |
| 45 |
pub struct in6_addr { |
| 46 |
pub s6_addr: [u8; 16], |
| 47 |
} |
| 48 |
|
| 49 |
pub struct in_addr { |
| 50 |
pub s_addr: in_addr_t, |
| 51 |
} |
| 52 |
|
| 53 |
pub struct iovec { |
| 54 |
iov_base: *mut c_void, |
| 55 |
iov_len: usize, |
| 56 |
} |
| 57 |
|
| 58 |
pub struct pollfd { |
| 59 |
pub fd: i32, |
| 60 |
pub events: i16, |
| 61 |
pub revents: i16, |
| 62 |
} |
| 63 |
|
| 64 |
pub struct sockaddr { |
| 65 |
pub sa_len: u8, |
| 66 |
pub sa_family: sa_family_t, |
| 67 |
pub sa_data: [c_char; 14], |
| 68 |
} |
| 69 |
|
| 70 |
pub struct sockaddr_in { |
| 71 |
pub sin_len: u8, |
| 72 |
pub sin_family: sa_family_t, |
| 73 |
pub sin_port: in_port_t, |
| 74 |
pub sin_addr: in_addr, |
| 75 |
pub sin_zero: [c_char; 8], |
| 76 |
} |
| 77 |
|
| 78 |
pub struct sockaddr_in6 { |
| 79 |
pub sin6_len: u8, |
| 80 |
pub sin6_family: sa_family_t, |
| 81 |
pub sin6_port: in_port_t, |
| 82 |
pub sin6_flowinfo: u32, |
| 83 |
pub sin6_addr: in6_addr, |
| 84 |
pub sin6_scope_id: u32, |
| 85 |
} |
| 86 |
|
| 87 |
pub struct sockaddr_storage { |
| 88 |
pub ss_len: u8, |
| 89 |
pub ss_family: sa_family_t, |
| 90 |
__ss_pad1: Padding<[u8; 6]>, |
| 91 |
__ss_align: i64, |
| 92 |
__ss_pad2: Padding<[u8; 112]>, |
| 93 |
} |
| 94 |
|
| 95 |
pub struct stat { |
| 96 |
pub st_dev: u64, |
| 97 |
pub st_ino: u64, |
| 98 |
pub st_nlink: u64, |
| 99 |
pub st_mode: mode_t, |
| 100 |
pub st_uid: u32, |
| 101 |
pub st_gid: u32, |
| 102 |
pub st_rdev: u64, |
| 103 |
pub st_size: i64, |
| 104 |
pub st_blksize: i64, |
| 105 |
pub st_blocks: i64, |
| 106 |
pub st_atim: timespec, |
| 107 |
pub st_mtim: timespec, |
| 108 |
pub st_ctim: timespec, |
| 109 |
} |
| 110 |
|
| 111 |
pub struct timespec { |
| 112 |
pub tv_sec: time_t, |
| 113 |
pub tv_nsec: i32, |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
pub const AF_UNSPEC: i32 = 0; |
| 118 |
pub const AF_INET: i32 = 3; |
| 119 |
pub const AF_INET6: i32 = 1; |
| 120 |
pub const AF_VSOCK: i32 = 2; |
| 121 |
|
| 122 |
pub const CLOCK_REALTIME: clockid_t = 1; |
| 123 |
pub const CLOCK_MONOTONIC: clockid_t = 4; |
| 124 |
|
| 125 |
pub const DT_UNKNOWN: u8 = 0; |
| 126 |
pub const DT_FIFO: u8 = 1; |
| 127 |
pub const DT_CHR: u8 = 2; |
| 128 |
pub const DT_DIR: u8 = 4; |
| 129 |
pub const DT_BLK: u8 = 6; |
| 130 |
pub const DT_REG: u8 = 8; |
| 131 |
pub const DT_LNK: u8 = 10; |
| 132 |
pub const DT_SOCK: u8 = 12; |
| 133 |
pub const DT_WHT: u8 = 14; |
| 134 |
|
| 135 |
pub const EAI_AGAIN: i32 = 2; |
| 136 |
pub const EAI_BADFLAGS: i32 = 3; |
| 137 |
pub const EAI_FAIL: i32 = 4; |
| 138 |
pub const EAI_FAMILY: i32 = 5; |
| 139 |
pub const EAI_MEMORY: i32 = 6; |
| 140 |
pub const EAI_NODATA: i32 = 7; |
| 141 |
pub const EAI_NONAME: i32 = 8; |
| 142 |
pub const EAI_SERVICE: i32 = 9; |
| 143 |
pub const EAI_SOCKTYPE: i32 = 10; |
| 144 |
pub const EAI_SYSTEM: i32 = 11; |
| 145 |
pub const EAI_OVERFLOW: i32 = 14; |
| 146 |
|
| 147 |
pub const EFD_SEMAPHORE: i16 = 0o1; |
| 148 |
pub const EFD_NONBLOCK: i16 = 0o4000; |
| 149 |
pub const EFD_CLOEXEC: i16 = 0o40000; |
| 150 |
|
| 151 |
pub const F_DUPFD: i32 = 0; |
| 152 |
pub const F_GETFD: i32 = 1; |
| 153 |
pub const F_SETFD: i32 = 2; |
| 154 |
pub const F_GETFL: i32 = 3; |
| 155 |
pub const F_SETFL: i32 = 4; |
| 156 |
|
| 157 |
pub const FD_CLOEXEC: i32 = 1; |
| 158 |
|
| 159 |
pub const FIONBIO: i32 = 0x8008667e; |
| 160 |
|
| 161 |
pub const FUTEX_RELATIVE_TIMEOUT: u32 = 1; |
| 162 |
|
| 163 |
pub const IP_TOS: i32 = 1; |
| 164 |
pub const IP_TTL: i32 = 2; |
| 165 |
pub const IP_ADD_MEMBERSHIP: i32 = 3; |
| 166 |
pub const IP_DROP_MEMBERSHIP: i32 = 4; |
| 167 |
pub const IP_MULTICAST_TTL: i32 = 5; |
| 168 |
pub const IP_MULTICAST_LOOP: i32 = 7; |
| 169 |
|
| 170 |
pub const IPPROTO_IP: i32 = 0; |
| 171 |
pub const IPPROTO_TCP: i32 = 6; |
| 172 |
pub const IPPROTO_UDP: i32 = 17; |
| 173 |
pub const IPPROTO_IPV6: i32 = 41; |
| 174 |
|
| 175 |
pub const IPV6_ADD_MEMBERSHIP: i32 = 12; |
| 176 |
pub const IPV6_DROP_MEMBERSHIP: i32 = 13; |
| 177 |
pub const IPV6_MULTICAST_LOOP: i32 = 19; |
| 178 |
pub const IPV6_V6ONLY: i32 = 27; |
| 179 |
|
| 180 |
pub const MSG_PEEK: i32 = 1; |
| 181 |
|
| 182 |
pub const O_RDONLY: i32 = 0o0; |
| 183 |
pub const O_WRONLY: i32 = 0o1; |
| 184 |
pub const O_RDWR: i32 = 0o2; |
| 185 |
pub const O_CREAT: i32 = 0o100; |
| 186 |
pub const O_EXCL: i32 = 0o200; |
| 187 |
pub const O_TRUNC: i32 = 0o1000; |
| 188 |
pub const O_APPEND: i32 = 0o2000; |
| 189 |
pub const O_NONBLOCK: i32 = 0o4000; |
| 190 |
pub const O_DIRECTORY: i32 = 0o200000; |
| 191 |
|
| 192 |
pub const POLLIN: i16 = 0x1; |
| 193 |
pub const POLLPRI: i16 = 0x2; |
| 194 |
pub const POLLOUT: i16 = 0x4; |
| 195 |
pub const POLLERR: i16 = 0x8; |
| 196 |
pub const POLLHUP: i16 = 0x10; |
| 197 |
pub const POLLNVAL: i16 = 0x20; |
| 198 |
pub const POLLRDNORM: i16 = 0x040; |
| 199 |
pub const POLLRDBAND: i16 = 0x080; |
| 200 |
pub const POLLWRNORM: i16 = 0x0100; |
| 201 |
pub const POLLWRBAND: i16 = 0x0200; |
| 202 |
pub const POLLRDHUP: i16 = 0x2000; |
| 203 |
|
| 204 |
pub const S_IRWXU: mode_t = 0o0700; |
| 205 |
pub const S_IRUSR: mode_t = 0o0400; |
| 206 |
pub const S_IWUSR: mode_t = 0o0200; |
| 207 |
pub const S_IXUSR: mode_t = 0o0100; |
| 208 |
pub const S_IRWXG: mode_t = 0o0070; |
| 209 |
pub const S_IRGRP: mode_t = 0o0040; |
| 210 |
pub const S_IWGRP: mode_t = 0o0020; |
| 211 |
pub const S_IXGRP: mode_t = 0o0010; |
| 212 |
pub const S_IRWXO: mode_t = 0o0007; |
| 213 |
pub const S_IROTH: mode_t = 0o0004; |
| 214 |
pub const S_IWOTH: mode_t = 0o0002; |
| 215 |
pub const S_IXOTH: mode_t = 0o0001; |
| 216 |
|
| 217 |
pub const S_IFMT: mode_t = 0o17_0000; |
| 218 |
pub const S_IFSOCK: mode_t = 0o14_0000; |
| 219 |
pub const S_IFLNK: mode_t = 0o12_0000; |
| 220 |
pub const S_IFREG: mode_t = 0o10_0000; |
| 221 |
pub const S_IFBLK: mode_t = 0o6_0000; |
| 222 |
pub const S_IFDIR: mode_t = 0o4_0000; |
| 223 |
pub const S_IFCHR: mode_t = 0o2_0000; |
| 224 |
pub const S_IFIFO: mode_t = 0o1_0000; |
| 225 |
|
| 226 |
pub const SHUT_RD: i32 = 0; |
| 227 |
pub const SHUT_WR: i32 = 1; |
| 228 |
pub const SHUT_RDWR: i32 = 2; |
| 229 |
|
| 230 |
pub const SO_REUSEADDR: i32 = 0x0004; |
| 231 |
pub const SO_KEEPALIVE: i32 = 0x0008; |
| 232 |
pub const SO_BROADCAST: i32 = 0x0020; |
| 233 |
pub const SO_LINGER: i32 = 0x0080; |
| 234 |
pub const SO_SNDBUF: i32 = 0x1001; |
| 235 |
pub const SO_RCVBUF: i32 = 0x1002; |
| 236 |
pub const SO_SNDTIMEO: i32 = 0x1005; |
| 237 |
pub const SO_RCVTIMEO: i32 = 0x1006; |
| 238 |
pub const SO_ERROR: i32 = 0x1007; |
| 239 |
|
| 240 |
pub const SOCK_STREAM: i32 = 1; |
| 241 |
pub const SOCK_DGRAM: i32 = 2; |
| 242 |
pub const SOCK_NONBLOCK: i32 = 0o4000; |
| 243 |
pub const SOCK_CLOEXEC: i32 = 0o40000; |
| 244 |
|
| 245 |
pub const SOL_SOCKET: i32 = 4095; |
| 246 |
|
| 247 |
pub const STDIN_FILENO: c_int = 0; |
| 248 |
pub const STDOUT_FILENO: c_int = 1; |
| 249 |
pub const STDERR_FILENO: c_int = 2; |
| 250 |
|
| 251 |
pub const TCP_NODELAY: i32 = 1; |
| 252 |
|
| 253 |
pub const EPERM: i32 = 1; |
| 254 |
pub const ENOENT: i32 = 2; |
| 255 |
pub const ESRCH: i32 = 3; |
| 256 |
pub const EINTR: i32 = 4; |
| 257 |
pub const EIO: i32 = 5; |
| 258 |
pub const ENXIO: i32 = 6; |
| 259 |
pub const E2BIG: i32 = 7; |
| 260 |
pub const ENOEXEC: i32 = 8; |
| 261 |
pub const EBADF: i32 = 9; |
| 262 |
pub const ECHILD: i32 = 10; |
| 263 |
pub const EAGAIN: i32 = 11; |
| 264 |
pub const ENOMEM: i32 = 12; |
| 265 |
pub const EACCES: i32 = 13; |
| 266 |
pub const EFAULT: i32 = 14; |
| 267 |
pub const ENOTBLK: i32 = 15; |
| 268 |
pub const EBUSY: i32 = 16; |
| 269 |
pub const EEXIST: i32 = 17; |
| 270 |
pub const EXDEV: i32 = 18; |
| 271 |
pub const ENODEV: i32 = 19; |
| 272 |
pub const ENOTDIR: i32 = 20; |
| 273 |
pub const EISDIR: i32 = 21; |
| 274 |
pub const EINVAL: i32 = 22; |
| 275 |
pub const ENFILE: i32 = 23; |
| 276 |
pub const EMFILE: i32 = 24; |
| 277 |
pub const ENOTTY: i32 = 25; |
| 278 |
pub const ETXTBSY: i32 = 26; |
| 279 |
pub const EFBIG: i32 = 27; |
| 280 |
pub const ENOSPC: i32 = 28; |
| 281 |
pub const ESPIPE: i32 = 29; |
| 282 |
pub const EROFS: i32 = 30; |
| 283 |
pub const EMLINK: i32 = 31; |
| 284 |
pub const EPIPE: i32 = 32; |
| 285 |
pub const EDOM: i32 = 33; |
| 286 |
pub const ERANGE: i32 = 34; |
| 287 |
pub const EDEADLK: i32 = 35; |
| 288 |
pub const ENAMETOOLONG: i32 = 36; |
| 289 |
pub const ENOLCK: i32 = 37; |
| 290 |
pub const ENOSYS: i32 = 38; |
| 291 |
pub const ENOTEMPTY: i32 = 39; |
| 292 |
pub const ELOOP: i32 = 40; |
| 293 |
pub const EWOULDBLOCK: i32 = EAGAIN; |
| 294 |
pub const ENOMSG: i32 = 42; |
| 295 |
pub const EIDRM: i32 = 43; |
| 296 |
pub const ECHRNG: i32 = 44; |
| 297 |
pub const EL2NSYNC: i32 = 45; |
| 298 |
pub const EL3HLT: i32 = 46; |
| 299 |
pub const EL3RST: i32 = 47; |
| 300 |
pub const ELNRNG: i32 = 48; |
| 301 |
pub const EUNATCH: i32 = 49; |
| 302 |
pub const ENOCSI: i32 = 50; |
| 303 |
pub const EL2HLT: i32 = 51; |
| 304 |
pub const EBADE: i32 = 52; |
| 305 |
pub const EBADR: i32 = 53; |
| 306 |
pub const EXFULL: i32 = 54; |
| 307 |
pub const ENOANO: i32 = 55; |
| 308 |
pub const EBADRQC: i32 = 56; |
| 309 |
pub const EBADSLT: i32 = 57; |
| 310 |
pub const EDEADLOCK: i32 = EDEADLK; |
| 311 |
pub const EBFONT: i32 = 59; |
| 312 |
pub const ENOSTR: i32 = 60; |
| 313 |
pub const ENODATA: i32 = 61; |
| 314 |
pub const ETIME: i32 = 62; |
| 315 |
pub const ENOSR: i32 = 63; |
| 316 |
pub const ENONET: i32 = 64; |
| 317 |
pub const ENOPKG: i32 = 65; |
| 318 |
pub const EREMOTE: i32 = 66; |
| 319 |
pub const ENOLINK: i32 = 67; |
| 320 |
pub const EADV: i32 = 68; |
| 321 |
pub const ESRMNT: i32 = 69; |
| 322 |
pub const ECOMM: i32 = 70; |
| 323 |
pub const EPROTO: i32 = 71; |
| 324 |
pub const EMULTIHOP: i32 = 72; |
| 325 |
pub const EDOTDOT: i32 = 73; |
| 326 |
pub const EBADMSG: i32 = 74; |
| 327 |
pub const EOVERFLOW: i32 = 75; |
| 328 |
pub const ENOTUNIQ: i32 = 76; |
| 329 |
pub const EBADFD: i32 = 77; |
| 330 |
pub const EREMCHG: i32 = 78; |
| 331 |
pub const ELIBACC: i32 = 79; |
| 332 |
pub const ELIBBAD: i32 = 80; |
| 333 |
pub const ELIBSCN: i32 = 81; |
| 334 |
pub const ELIBMAX: i32 = 82; |
| 335 |
pub const ELIBEXEC: i32 = 83; |
| 336 |
pub const EILSEQ: i32 = 84; |
| 337 |
pub const ERESTART: i32 = 85; |
| 338 |
pub const ESTRPIPE: i32 = 86; |
| 339 |
pub const EUSERS: i32 = 87; |
| 340 |
pub const ENOTSOCK: i32 = 88; |
| 341 |
pub const EDESTADDRREQ: i32 = 89; |
| 342 |
pub const EMSGSIZE: i32 = 90; |
| 343 |
pub const EPROTOTYPE: i32 = 91; |
| 344 |
pub const ENOPROTOOPT: i32 = 92; |
| 345 |
pub const EPROTONOSUPPORT: i32 = 93; |
| 346 |
pub const ESOCKTNOSUPPORT: i32 = 94; |
| 347 |
pub const EOPNOTSUPP: i32 = 95; |
| 348 |
pub const EPFNOSUPPORT: i32 = 96; |
| 349 |
pub const EAFNOSUPPORT: i32 = 97; |
| 350 |
pub const EADDRINUSE: i32 = 98; |
| 351 |
pub const EADDRNOTAVAIL: i32 = 99; |
| 352 |
pub const ENETDOWN: i32 = 100; |
| 353 |
pub const ENETUNREACH: i32 = 101; |
| 354 |
pub const ENETRESET: i32 = 102; |
| 355 |
pub const ECONNABORTED: i32 = 103; |
| 356 |
pub const ECONNRESET: i32 = 104; |
| 357 |
pub const ENOBUFS: i32 = 105; |
| 358 |
pub const EISCONN: i32 = 106; |
| 359 |
pub const ENOTCONN: i32 = 107; |
| 360 |
pub const ESHUTDOWN: i32 = 108; |
| 361 |
pub const ETOOMANYREFS: i32 = 109; |
| 362 |
pub const ETIMEDOUT: i32 = 110; |
| 363 |
pub const ECONNREFUSED: i32 = 111; |
| 364 |
pub const EHOSTDOWN: i32 = 112; |
| 365 |
pub const EHOSTUNREACH: i32 = 113; |
| 366 |
pub const EALREADY: i32 = 114; |
| 367 |
pub const EINPROGRESS: i32 = 115; |
| 368 |
pub const ESTALE: i32 = 116; |
| 369 |
pub const EUCLEAN: i32 = 117; |
| 370 |
pub const ENOTNAM: i32 = 118; |
| 371 |
pub const ENAVAIL: i32 = 119; |
| 372 |
pub const EISNAM: i32 = 120; |
| 373 |
pub const EREMOTEIO: i32 = 121; |
| 374 |
pub const EDQUOT: i32 = 122; |
| 375 |
pub const ENOMEDIUM: i32 = 123; |
| 376 |
pub const EMEDIUMTYPE: i32 = 124; |
| 377 |
pub const ECANCELED: i32 = 125; |
| 378 |
pub const ENOKEY: i32 = 126; |
| 379 |
pub const EKEYEXPIRED: i32 = 127; |
| 380 |
pub const EKEYREVOKED: i32 = 128; |
| 381 |
pub const EKEYREJECTED: i32 = 129; |
| 382 |
pub const EOWNERDEAD: i32 = 130; |
| 383 |
pub const ENOTRECOVERABLE: i32 = 131; |
| 384 |
pub const ERFKILL: i32 = 132; |
| 385 |
pub const EHWPOISON: i32 = 133; |
| 386 |
|
| 387 |
extern "C" { |
| 388 |
#[link_name = "sys_alloc"] |
| 389 |
pub fn alloc(size: usize, align: usize) -> *mut u8; |
| 390 |
|
| 391 |
#[link_name = "sys_alloc_zeroed"] |
| 392 |
pub fn alloc_zeroed(size: usize, align: usize) -> *mut u8; |
| 393 |
|
| 394 |
#[link_name = "sys_realloc"] |
| 395 |
pub fn realloc(ptr: *mut u8, size: usize, align: usize, new_size: usize) -> *mut u8; |
| 396 |
|
| 397 |
#[link_name = "sys_dealloc"] |
| 398 |
pub fn dealloc(ptr: *mut u8, size: usize, align: usize); |
| 399 |
|
| 400 |
#[link_name = "sys_exit"] |
| 401 |
pub fn exit(status: i32) -> !; |
| 402 |
|
| 403 |
#[link_name = "sys_abort"] |
| 404 |
pub fn abort() -> !; |
| 405 |
|
| 406 |
#[link_name = "sys_errno"] |
| 407 |
pub fn errno() -> i32; |
| 408 |
|
| 409 |
#[link_name = "sys_clock_gettime"] |
| 410 |
pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; |
| 411 |
|
| 412 |
#[link_name = "sys_nanosleep"] |
| 413 |
pub fn nanosleep(req: *const timespec) -> i32; |
| 414 |
|
| 415 |
#[link_name = "sys_available_parallelism"] |
| 416 |
pub fn available_parallelism() -> usize; |
| 417 |
|
| 418 |
#[link_name = "sys_futex_wait"] |
| 419 |
pub fn futex_wait( |
| 420 |
address: *mut u32, |
| 421 |
expected: u32, |
| 422 |
timeout: *const timespec, |
| 423 |
flags: u32, |
| 424 |
) -> i32; |
| 425 |
|
| 426 |
#[link_name = "sys_futex_wake"] |
| 427 |
pub fn futex_wake(address: *mut u32, count: i32) -> i32; |
| 428 |
|
| 429 |
#[link_name = "sys_stat"] |
| 430 |
pub fn stat(path: *const c_char, stat: *mut stat) -> i32; |
| 431 |
|
| 432 |
#[link_name = "sys_fstat"] |
| 433 |
pub fn fstat(fd: i32, stat: *mut stat) -> i32; |
| 434 |
|
| 435 |
#[link_name = "sys_lstat"] |
| 436 |
pub fn lstat(path: *const c_char, stat: *mut stat) -> i32; |
| 437 |
|
| 438 |
#[link_name = "sys_open"] |
| 439 |
pub fn open(path: *const c_char, flags: i32, mode: mode_t) -> i32; |
| 440 |
|
| 441 |
#[link_name = "sys_unlink"] |
| 442 |
pub fn unlink(path: *const c_char) -> i32; |
| 443 |
|
| 444 |
#[link_name = "sys_mkdir"] |
| 445 |
pub fn mkdir(path: *const c_char, mode: mode_t) -> i32; |
| 446 |
|
| 447 |
#[link_name = "sys_rmdir"] |
| 448 |
pub fn rmdir(path: *const c_char) -> i32; |
| 449 |
|
| 450 |
#[link_name = "sys_read"] |
| 451 |
pub fn read(fd: i32, buf: *mut u8, len: usize) -> isize; |
| 452 |
|
| 453 |
#[link_name = "sys_write"] |
| 454 |
pub fn write(fd: i32, buf: *const u8, len: usize) -> isize; |
| 455 |
|
| 456 |
#[link_name = "sys_readv"] |
| 457 |
pub fn readv(fd: i32, iov: *const iovec, iovcnt: usize) -> isize; |
| 458 |
|
| 459 |
#[link_name = "sys_writev"] |
| 460 |
pub fn writev(fd: i32, iov: *const iovec, iovcnt: usize) -> isize; |
| 461 |
|
| 462 |
#[link_name = "sys_close"] |
| 463 |
pub fn close(fd: i32) -> i32; |
| 464 |
|
| 465 |
#[link_name = "sys_dup"] |
| 466 |
pub fn dup(fd: i32) -> i32; |
| 467 |
|
| 468 |
#[link_name = "sys_fcntl"] |
| 469 |
pub fn fcntl(fd: i32, cmd: i32, arg: i32) -> i32; |
| 470 |
|
| 471 |
#[link_name = "sys_getdents64"] |
| 472 |
pub fn getdents64(fd: i32, dirp: *mut dirent64, count: usize) -> isize; |
| 473 |
|
| 474 |
#[link_name = "sys_getaddrinfo"] |
| 475 |
pub fn getaddrinfo( |
| 476 |
nodename: *const c_char, |
| 477 |
servname: *const c_char, |
| 478 |
hints: *const addrinfo, |
| 479 |
res: *mut *mut addrinfo, |
| 480 |
) -> i32; |
| 481 |
|
| 482 |
#[link_name = "sys_freeaddrinfo"] |
| 483 |
pub fn freeaddrinfo(ai: *mut addrinfo); |
| 484 |
|
| 485 |
#[link_name = "sys_socket"] |
| 486 |
pub fn socket(domain: i32, ty: i32, protocol: i32) -> i32; |
| 487 |
|
| 488 |
#[link_name = "sys_bind"] |
| 489 |
pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; |
| 490 |
|
| 491 |
#[link_name = "sys_listen"] |
| 492 |
pub fn listen(sockfd: i32, backlog: i32) -> i32; |
| 493 |
|
| 494 |
#[link_name = "sys_accept"] |
| 495 |
pub fn accept(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; |
| 496 |
|
| 497 |
#[link_name = "sys_connect"] |
| 498 |
pub fn connect(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; |
| 499 |
|
| 500 |
#[link_name = "sys_recv"] |
| 501 |
pub fn recv(sockfd: i32, buf: *mut u8, len: usize, flags: i32) -> isize; |
| 502 |
|
| 503 |
#[link_name = "sys_recvfrom"] |
| 504 |
pub fn recvfrom( |
| 505 |
sockfd: i32, |
| 506 |
buf: *mut c_void, |
| 507 |
len: usize, |
| 508 |
flags: i32, |
| 509 |
addr: *mut sockaddr, |
| 510 |
addrlen: *mut socklen_t, |
| 511 |
) -> isize; |
| 512 |
|
| 513 |
#[link_name = "sys_send"] |
| 514 |
pub fn send(sockfd: i32, buf: *const c_void, len: usize, flags: i32) -> isize; |
| 515 |
|
| 516 |
#[link_name = "sys_sendto"] |
| 517 |
pub fn sendto( |
| 518 |
sockfd: i32, |
| 519 |
buf: *const c_void, |
| 520 |
len: usize, |
| 521 |
flags: i32, |
| 522 |
to: *const sockaddr, |
| 523 |
tolen: socklen_t, |
| 524 |
) -> isize; |
| 525 |
|
| 526 |
#[link_name = "sys_getpeername"] |
| 527 |
pub fn getpeername(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; |
| 528 |
|
| 529 |
#[link_name = "sys_getsockname"] |
| 530 |
pub fn getsockname(sockfd: i32, addr: *mut sockaddr, addrlen: *mut socklen_t) -> i32; |
| 531 |
|
| 532 |
#[link_name = "sys_getsockopt"] |
| 533 |
pub fn getsockopt( |
| 534 |
sockfd: i32, |
| 535 |
level: i32, |
| 536 |
optname: i32, |
| 537 |
optval: *mut c_void, |
| 538 |
optlen: *mut socklen_t, |
| 539 |
) -> i32; |
| 540 |
|
| 541 |
#[link_name = "sys_setsockopt"] |
| 542 |
pub fn setsockopt( |
| 543 |
sockfd: i32, |
| 544 |
level: i32, |
| 545 |
optname: i32, |
| 546 |
optval: *const c_void, |
| 547 |
optlen: socklen_t, |
| 548 |
) -> i32; |
| 549 |
|
| 550 |
#[link_name = "sys_ioctl"] |
| 551 |
pub fn ioctl(sockfd: i32, cmd: i32, argp: *mut c_void) -> i32; |
| 552 |
|
| 553 |
#[link_name = "sys_shutdown"] |
| 554 |
pub fn shutdown(sockfd: i32, how: i32) -> i32; |
| 555 |
|
| 556 |
#[link_name = "sys_eventfd"] |
| 557 |
pub fn eventfd(initval: u64, flags: i16) -> i32; |
| 558 |
|
| 559 |
#[link_name = "sys_poll"] |
| 560 |
pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: i32) -> i32; |
| 561 |
} |