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