| 1 |
use crate::prelude::*; |
| 2 |
use crate::{ |
| 3 |
in6_addr, |
| 4 |
in_addr_t, |
| 5 |
timespec, |
| 6 |
DIR, |
| 7 |
}; |
| 8 |
|
| 9 |
pub type nlink_t = u16; |
| 10 |
pub type ino_t = u16; |
| 11 |
pub type blkcnt_t = u64; |
| 12 |
pub type blksize_t = i16; |
| 13 |
pub type cc_t = u8; |
| 14 |
pub type clock_t = i64; |
| 15 |
pub type dev_t = i32; |
| 16 |
pub type fsblkcnt_t = u64; |
| 17 |
pub type locale_t = *mut i8; |
| 18 |
pub type mode_t = u32; |
| 19 |
pub type nfds_t = u32; |
| 20 |
pub type off_t = i64; |
| 21 |
pub type pthread_key_t = i32; |
| 22 |
pub type pthread_mutexattr_t = u8; |
| 23 |
pub type pthread_rwlockattr_t = i32; |
| 24 |
pub type pthread_t = i32; |
| 25 |
pub type rlim_t = i64; |
| 26 |
pub type sa_family_t = u16; |
| 27 |
pub type socklen_t = u32; |
| 28 |
pub type speed_t = usize; |
| 29 |
pub type suseconds_t = i32; |
| 30 |
pub type tcflag_t = u32; |
| 31 |
pub type clockid_t = i32; |
| 32 |
pub type time_t = i64; |
| 33 |
pub type wchar_t = i32; |
| 34 |
|
| 35 |
s! { |
| 36 |
pub struct stat { |
| 37 |
pub st_dev: dev_t, |
| 38 |
pub st_ino: ino_t, |
| 39 |
pub st_mode: mode_t, |
| 40 |
pub st_nlink: nlink_t, |
| 41 |
pub st_uid: u32, |
| 42 |
pub st_gid: u32, |
| 43 |
pub st_rdev: dev_t, |
| 44 |
pub st_size: off_t, |
| 45 |
pub st_atim: timespec, |
| 46 |
pub st_mtim: timespec, |
| 47 |
pub st_ctim: timespec, |
| 48 |
pub st_blksize: blksize_t, |
| 49 |
pub st_blocks: i64, |
| 50 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 51 |
} |
| 52 |
|
| 53 |
pub struct sockaddr { |
| 54 |
pub sa_family: sa_family_t, |
| 55 |
pub sa_data: [u8; 14], |
| 56 |
} |
| 57 |
|
| 58 |
pub struct passwd { |
| 59 |
pub pw_name: *const c_char, |
| 60 |
pub pw_passwd: *const c_char, |
| 61 |
pub pw_uid: u32, |
| 62 |
pub pw_gid: u32, |
| 63 |
pub pw_gecos: *const c_char, |
| 64 |
pub pw_dir: *const c_char, |
| 65 |
pub pw_shell: *const c_char, |
| 66 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 67 |
} |
| 68 |
|
| 69 |
pub struct sem_t { |
| 70 |
__val: [usize; __SEM_SIZE__], |
| 71 |
} |
| 72 |
|
| 73 |
pub struct pthread_attr_t { |
| 74 |
__val: [usize; __PTHREAD_ATTR_SIZE__], |
| 75 |
} |
| 76 |
|
| 77 |
pub struct pthread_mutex_t { |
| 78 |
__val: [usize; __PTHREAD_MUTEX_SIZE__], |
| 79 |
} |
| 80 |
|
| 81 |
pub struct pthread_cond_t { |
| 82 |
__val: [usize; __PTHREAD_COND_SIZE__], |
| 83 |
} |
| 84 |
|
| 85 |
pub struct pthread_condattr_t { |
| 86 |
__val: [usize; __PTHREAD_CONDATTR_SIZE__], |
| 87 |
} |
| 88 |
|
| 89 |
pub struct Dl_info { |
| 90 |
pub dli_fname: *const c_char, |
| 91 |
pub dli_fbase: *mut c_void, |
| 92 |
pub dli_sname: *const c_char, |
| 93 |
pub dli_saddr: *mut c_void, |
| 94 |
} |
| 95 |
|
| 96 |
pub struct lconv { |
| 97 |
pub decimal_point: *const c_char, |
| 98 |
pub thousands_sep: *const c_char, |
| 99 |
pub grouping: *const c_char, |
| 100 |
pub int_curr_symbol: *const c_char, |
| 101 |
pub currency_symbol: *const c_char, |
| 102 |
pub mon_decimal_point: *const c_char, |
| 103 |
pub mon_thousands_sep: *const c_char, |
| 104 |
pub mon_grouping: *const c_char, |
| 105 |
pub positive_sign: *const c_char, |
| 106 |
pub negative_sign: *const c_char, |
| 107 |
pub int_frac_digits: i8, |
| 108 |
pub frac_digits: i8, |
| 109 |
pub p_cs_precedes: i8, |
| 110 |
pub p_sep_by_space: i8, |
| 111 |
pub n_cs_precedes: i8, |
| 112 |
pub n_sep_by_space: i8, |
| 113 |
pub p_sign_posn: i8, |
| 114 |
pub n_sign_posn: i8, |
| 115 |
pub int_n_cs_precedes: i8, |
| 116 |
pub int_n_sep_by_space: i8, |
| 117 |
pub int_n_sign_posn: i8, |
| 118 |
pub int_p_cs_precedes: i8, |
| 119 |
pub int_p_sep_by_space: i8, |
| 120 |
pub int_p_sign_posn: i8, |
| 121 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 122 |
} |
| 123 |
|
| 124 |
pub struct tm { |
| 125 |
pub tm_sec: i32, |
| 126 |
pub tm_min: i32, |
| 127 |
pub tm_hour: i32, |
| 128 |
pub tm_mday: i32, |
| 129 |
pub tm_mon: i32, |
| 130 |
pub tm_year: i32, |
| 131 |
pub tm_wday: i32, |
| 132 |
pub tm_yday: i32, |
| 133 |
pub tm_isdst: i32, |
| 134 |
pub tm_gmtoff: isize, |
| 135 |
pub tm_zone: *const c_char, |
| 136 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 137 |
} |
| 138 |
|
| 139 |
pub struct addrinfo { |
| 140 |
pub ai_flags: i32, |
| 141 |
pub ai_family: i32, |
| 142 |
pub ai_socktype: i32, |
| 143 |
pub ai_protocol: i32, |
| 144 |
pub ai_addrlen: socklen_t, |
| 145 |
pub ai_addr: *mut sockaddr, |
| 146 |
pub ai_canonname: *mut c_char, |
| 147 |
pub ai_next: *mut addrinfo, |
| 148 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 149 |
} |
| 150 |
|
| 151 |
pub struct pthread_rwlock_t { |
| 152 |
__val: [usize; __PTHREAD_RWLOCK_SIZE__], |
| 153 |
} |
| 154 |
|
| 155 |
pub struct statvfs { |
| 156 |
pub f_bsize: usize, |
| 157 |
pub f_frsize: usize, |
| 158 |
pub f_blocks: fsblkcnt_t, |
| 159 |
pub f_bfree: fsblkcnt_t, |
| 160 |
pub f_bavail: fsblkcnt_t, |
| 161 |
pub f_files: fsblkcnt_t, |
| 162 |
pub f_ffree: fsblkcnt_t, |
| 163 |
pub f_favail: fsblkcnt_t, |
| 164 |
pub f_fsid: usize, |
| 165 |
pub f_flag: usize, |
| 166 |
pub f_namemax: usize, |
| 167 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 168 |
} |
| 169 |
|
| 170 |
pub struct dirent { |
| 171 |
pub d_type: u8, |
| 172 |
pub d_name: [c_char; __NAME_MAX__ + 1], |
| 173 |
} |
| 174 |
|
| 175 |
pub struct fd_set { |
| 176 |
__val: [u32; __FDSET_SIZE__], |
| 177 |
} |
| 178 |
|
| 179 |
pub struct sigset_t { |
| 180 |
__val: [u32; __SIGSET_SIZE__], |
| 181 |
} |
| 182 |
|
| 183 |
pub struct sigaction { |
| 184 |
pub sa_handler: usize, |
| 185 |
pub sa_mask: sigset_t, |
| 186 |
pub sa_flags: i32, |
| 187 |
pub sa_user: usize, |
| 188 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 189 |
} |
| 190 |
|
| 191 |
pub struct termios { |
| 192 |
pub c_iflag: tcflag_t, |
| 193 |
pub c_oflag: tcflag_t, |
| 194 |
pub c_cflag: tcflag_t, |
| 195 |
pub c_lflag: tcflag_t, |
| 196 |
pub c_cc: [cc_t; 12], |
| 197 |
pub c_speed: speed_t, |
| 198 |
__reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>, |
| 199 |
} |
| 200 |
|
| 201 |
pub struct in_addr { |
| 202 |
pub s_addr: in_addr_t, |
| 203 |
} |
| 204 |
|
| 205 |
pub struct sockaddr_in { |
| 206 |
pub sin_family: sa_family_t, |
| 207 |
pub sin_port: crate::in_port_t, |
| 208 |
pub sin_addr: crate::in_addr, |
| 209 |
pub sin_zero: [u8; 8], |
| 210 |
} |
| 211 |
|
| 212 |
pub struct sockaddr_in6 { |
| 213 |
pub sin6_family: sa_family_t, |
| 214 |
pub sin6_port: crate::in_port_t, |
| 215 |
pub sin6_flowinfo: u32, |
| 216 |
pub sin6_addr: crate::in6_addr, |
| 217 |
pub sin6_scope_id: u32, |
| 218 |
} |
| 219 |
|
| 220 |
pub struct sockaddr_un { |
| 221 |
pub sun_family: sa_family_t, |
| 222 |
pub sun_path: [c_char; 108], |
| 223 |
} |
| 224 |
|
| 225 |
pub struct sockaddr_storage { |
| 226 |
pub ss_family: sa_family_t, |
| 227 |
ss_data: [u32; __SOCKADDR_STORAGE_SIZE__], |
| 228 |
} |
| 229 |
|
| 230 |
pub struct ip_mreq { |
| 231 |
pub imr_multiaddr: in_addr, |
| 232 |
pub imr_interface: in_addr, |
| 233 |
} |
| 234 |
|
| 235 |
pub struct ipv6_mreq { |
| 236 |
pub ipv6mr_multiaddr: in6_addr, |
| 237 |
pub ipv6mr_interface: u32, |
| 238 |
} |
| 239 |
} |
| 240 |
|
| 241 |
// Reserved two pointer size for reserved area for some structures. |
| 242 |
// This ensures that the size of these structures is large enough |
| 243 |
// if more fields are added in the NuttX side. |
| 244 |
// |
| 245 |
// These structures are that defined by POSIX but only necessary fields are included, |
| 246 |
// for example, struct passwd, https://pubs.opengroup.org/onlinepubs/009695399/basedefs/pwd.h.html, |
| 247 |
// POSIX only defines following fields in struct passwd: |
| 248 |
// char *pw_name User's login name. |
| 249 |
// char *pw_passwd Encrypted password. |
| 250 |
// uid_t pw_uid Numerical user ID. |
| 251 |
// gid_t pw_gid Numerical group ID. |
| 252 |
// char *pw_dir Initial working directory. |
| 253 |
// char *pw_shell Program to use as shell. |
| 254 |
// Other fields can be different depending on the implementation. |
| 255 |
|
| 256 |
const __DEFAULT_RESERVED_SIZE__: usize = 2; |
| 257 |
|
| 258 |
const __SOCKADDR_STORAGE_SIZE__: usize = 36; |
| 259 |
const __PTHREAD_ATTR_SIZE__: usize = 5; |
| 260 |
const __PTHREAD_MUTEX_SIZE__: usize = 9; |
| 261 |
const __PTHREAD_COND_SIZE__: usize = 7; |
| 262 |
const __PTHREAD_CONDATTR_SIZE__: usize = 5; |
| 263 |
const __PTHREAD_RWLOCK_SIZE__: usize = 17; |
| 264 |
const __SEM_SIZE__: usize = 6; |
| 265 |
const __NAME_MAX__: usize = 64; |
| 266 |
const __FDSET_SIZE__: usize = 10; |
| 267 |
const __SIGSET_SIZE__: usize = 8; |
| 268 |
|
| 269 |
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { |
| 270 |
__val: [0; __PTHREAD_COND_SIZE__], |
| 271 |
}; |
| 272 |
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { |
| 273 |
__val: [0; __PTHREAD_MUTEX_SIZE__], |
| 274 |
}; |
| 275 |
|
| 276 |
// dlfcn.h |
| 277 |
pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut(); |
| 278 |
|
| 279 |
// stdlib.h |
| 280 |
pub const EXIT_SUCCESS: i32 = 0; |
| 281 |
pub const EXIT_FAILURE: i32 = 1; |
| 282 |
|
| 283 |
// time.h |
| 284 |
pub const CLOCK_REALTIME: i32 = 0; |
| 285 |
pub const CLOCK_MONOTONIC: i32 = 1; |
| 286 |
|
| 287 |
// errno.h |
| 288 |
pub const EPERM: i32 = 1; |
| 289 |
pub const ENOENT: i32 = 2; |
| 290 |
pub const ESRCH: i32 = 3; |
| 291 |
pub const EINTR: i32 = 4; |
| 292 |
pub const EIO: i32 = 5; |
| 293 |
pub const ENXIO: i32 = 6; |
| 294 |
pub const E2BIG: i32 = 7; |
| 295 |
pub const ENOEXEC: i32 = 8; |
| 296 |
pub const EBADF: i32 = 9; |
| 297 |
pub const ECHILD: i32 = 10; |
| 298 |
pub const EAGAIN: i32 = 11; |
| 299 |
pub const ENOMEM: i32 = 12; |
| 300 |
pub const EACCES: i32 = 13; |
| 301 |
pub const EFAULT: i32 = 14; |
| 302 |
pub const ENOTBLK: i32 = 15; |
| 303 |
pub const EBUSY: i32 = 16; |
| 304 |
pub const EEXIST: i32 = 17; |
| 305 |
pub const EXDEV: i32 = 18; |
| 306 |
pub const ENODEV: i32 = 19; |
| 307 |
pub const ENOTDIR: i32 = 20; |
| 308 |
pub const EISDIR: i32 = 21; |
| 309 |
pub const EINVAL: i32 = 22; |
| 310 |
pub const ENFILE: i32 = 23; |
| 311 |
pub const EMFILE: i32 = 24; |
| 312 |
pub const ENOTTY: i32 = 25; |
| 313 |
pub const ETXTBSY: i32 = 26; |
| 314 |
pub const EFBIG: i32 = 27; |
| 315 |
pub const ENOSPC: i32 = 28; |
| 316 |
pub const ESPIPE: i32 = 29; |
| 317 |
pub const EROFS: i32 = 30; |
| 318 |
pub const EMLINK: i32 = 31; |
| 319 |
pub const EPIPE: i32 = 32; |
| 320 |
pub const EDOM: i32 = 33; |
| 321 |
pub const ERANGE: i32 = 34; |
| 322 |
pub const EDEADLK: i32 = 35; |
| 323 |
pub const ENAMETOOLONG: i32 = 36; |
| 324 |
pub const ENOLCK: i32 = 37; |
| 325 |
pub const ENOSYS: i32 = 38; |
| 326 |
pub const ENOTEMPTY: i32 = 39; |
| 327 |
pub const ELOOP: i32 = 40; |
| 328 |
pub const EWOULDBLOCK: i32 = EAGAIN; |
| 329 |
pub const ENOMSG: i32 = 42; |
| 330 |
pub const EIDRM: i32 = 43; |
| 331 |
pub const ECHRNG: i32 = 44; |
| 332 |
pub const EL2NSYNC: i32 = 45; |
| 333 |
pub const EL3HLT: i32 = 46; |
| 334 |
pub const EL3RST: i32 = 47; |
| 335 |
pub const ELNRNG: i32 = 48; |
| 336 |
pub const EUNATCH: i32 = 49; |
| 337 |
pub const ENOCSI: i32 = 50; |
| 338 |
pub const EL2HLT: i32 = 51; |
| 339 |
pub const EBADE: i32 = 52; |
| 340 |
pub const EBADR: i32 = 53; |
| 341 |
pub const EXFULL: i32 = 54; |
| 342 |
pub const ENOANO: i32 = 55; |
| 343 |
pub const EBADRQC: i32 = 56; |
| 344 |
pub const EBADSLT: i32 = 57; |
| 345 |
pub const EDEADLOCK: i32 = EDEADLK; |
| 346 |
pub const EBFONT: i32 = 59; |
| 347 |
pub const ENOSTR: i32 = 60; |
| 348 |
pub const ENODATA: i32 = 61; |
| 349 |
pub const ETIME: i32 = 62; |
| 350 |
pub const ENOSR: i32 = 63; |
| 351 |
pub const ENONET: i32 = 64; |
| 352 |
pub const ENOPKG: i32 = 65; |
| 353 |
pub const EREMOTE: i32 = 66; |
| 354 |
pub const ENOLINK: i32 = 67; |
| 355 |
pub const EADV: i32 = 68; |
| 356 |
pub const ESRMNT: i32 = 69; |
| 357 |
pub const ECOMM: i32 = 70; |
| 358 |
pub const EPROTO: i32 = 71; |
| 359 |
pub const EMULTIHOP: i32 = 72; |
| 360 |
pub const EDOTDOT: i32 = 73; |
| 361 |
pub const EBADMSG: i32 = 74; |
| 362 |
pub const EOVERFLOW: i32 = 75; |
| 363 |
pub const ENOTUNIQ: i32 = 76; |
| 364 |
pub const EBADFD: i32 = 77; |
| 365 |
pub const EREMCHG: i32 = 78; |
| 366 |
pub const ELIBACC: i32 = 79; |
| 367 |
pub const ELIBBAD: i32 = 80; |
| 368 |
pub const ELIBSCN: i32 = 81; |
| 369 |
pub const ELIBMAX: i32 = 82; |
| 370 |
pub const ELIBEXEC: i32 = 83; |
| 371 |
pub const EILSEQ: i32 = 84; |
| 372 |
pub const ERESTART: i32 = 85; |
| 373 |
pub const ESTRPIPE: i32 = 86; |
| 374 |
pub const EUSERS: i32 = 87; |
| 375 |
pub const ENOTSOCK: i32 = 88; |
| 376 |
pub const EDESTADDRREQ: i32 = 89; |
| 377 |
pub const EMSGSIZE: i32 = 90; |
| 378 |
pub const EPROTOTYPE: i32 = 91; |
| 379 |
pub const ENOPROTOOPT: i32 = 92; |
| 380 |
pub const EPROTONOSUPPORT: i32 = 93; |
| 381 |
pub const ESOCKTNOSUPPORT: i32 = 94; |
| 382 |
pub const EOPNOTSUPP: i32 = 95; |
| 383 |
pub const EPFNOSUPPORT: i32 = 96; |
| 384 |
pub const EAFNOSUPPORT: i32 = 97; |
| 385 |
pub const EADDRINUSE: i32 = 98; |
| 386 |
pub const EADDRNOTAVAIL: i32 = 99; |
| 387 |
pub const ENETDOWN: i32 = 100; |
| 388 |
pub const ENETUNREACH: i32 = 101; |
| 389 |
pub const ENETRESET: i32 = 102; |
| 390 |
pub const ECONNABORTED: i32 = 103; |
| 391 |
pub const ECONNRESET: i32 = 104; |
| 392 |
pub const ENOBUFS: i32 = 105; |
| 393 |
pub const EISCONN: i32 = 106; |
| 394 |
pub const ENOTCONN: i32 = 107; |
| 395 |
pub const ESHUTDOWN: i32 = 108; |
| 396 |
pub const ETOOMANYREFS: i32 = 109; |
| 397 |
pub const ETIMEDOUT: i32 = 110; |
| 398 |
pub const ECONNREFUSED: i32 = 111; |
| 399 |
pub const EHOSTDOWN: i32 = 112; |
| 400 |
pub const EHOSTUNREACH: i32 = 113; |
| 401 |
pub const EALREADY: i32 = 114; |
| 402 |
pub const EINPROGRESS: i32 = 115; |
| 403 |
pub const ESTALE: i32 = 116; |
| 404 |
pub const EUCLEAN: i32 = 117; |
| 405 |
pub const ENOTNAM: i32 = 118; |
| 406 |
pub const ENAVAIL: i32 = 119; |
| 407 |
pub const EISNAM: i32 = 120; |
| 408 |
pub const EREMOTEIO: i32 = 121; |
| 409 |
pub const EDQUOT: i32 = 122; |
| 410 |
pub const ENOMEDIUM: i32 = 123; |
| 411 |
pub const EMEDIUMTYPE: i32 = 124; |
| 412 |
pub const ECANCELED: i32 = 125; |
| 413 |
pub const ENOKEY: i32 = 126; |
| 414 |
pub const EKEYEXPIRED: i32 = 127; |
| 415 |
pub const EKEYREVOKED: i32 = 128; |
| 416 |
pub const EKEYREJECTED: i32 = 129; |
| 417 |
pub const EOWNERDEAD: i32 = 130; |
| 418 |
pub const ENOTRECOVERABLE: i32 = 131; |
| 419 |
pub const ERFKILL: i32 = 132; |
| 420 |
pub const EHWPOISON: i32 = 133; |
| 421 |
pub const ELBIN: i32 = 134; |
| 422 |
pub const EFTYPE: i32 = 135; |
| 423 |
pub const ENMFILE: i32 = 136; |
| 424 |
pub const EPROCLIM: i32 = 137; |
| 425 |
pub const ENOTSUP: i32 = 138; |
| 426 |
pub const ENOSHARE: i32 = 139; |
| 427 |
pub const ECASECLASH: i32 = 140; |
| 428 |
|
| 429 |
// fcntl.h |
| 430 |
pub const FIOCLEX: i32 = 0x30b; |
| 431 |
pub const F_SETFL: i32 = 0x9; |
| 432 |
pub const F_DUPFD_CLOEXEC: i32 = 0x12; |
| 433 |
pub const F_GETFD: i32 = 0x1; |
| 434 |
pub const F_GETFL: i32 = 0x2; |
| 435 |
pub const O_RDONLY: i32 = 0x1; |
| 436 |
pub const O_WRONLY: i32 = 0x2; |
| 437 |
pub const O_RDWR: i32 = 0x3; |
| 438 |
pub const O_CREAT: i32 = 0x4; |
| 439 |
pub const O_EXCL: i32 = 0x8; |
| 440 |
pub const O_NOCTTY: i32 = 0x0; |
| 441 |
pub const O_TRUNC: i32 = 0x20; |
| 442 |
pub const O_APPEND: i32 = 0x10; |
| 443 |
pub const O_NONBLOCK: i32 = 0x40; |
| 444 |
pub const O_DSYNC: i32 = 0x80; |
| 445 |
pub const O_DIRECT: i32 = 0x200; |
| 446 |
pub const O_LARGEFILE: i32 = 0x2000; |
| 447 |
pub const O_DIRECTORY: i32 = 0x800; |
| 448 |
pub const O_NOFOLLOW: i32 = 0x1000; |
| 449 |
pub const O_NOATIME: i32 = 0x40000; |
| 450 |
pub const O_CLOEXEC: i32 = 0x400; |
| 451 |
pub const O_ACCMODE: i32 = 0x0003; |
| 452 |
pub const AT_FDCWD: i32 = -100; |
| 453 |
pub const AT_REMOVEDIR: i32 = 0x200; |
| 454 |
|
| 455 |
// sys/types.h |
| 456 |
pub const SEEK_SET: i32 = 0; |
| 457 |
pub const SEEK_CUR: i32 = 1; |
| 458 |
pub const SEEK_END: i32 = 2; |
| 459 |
|
| 460 |
// sys/stat.h |
| 461 |
pub const S_IFDIR: u32 = 0x4000; |
| 462 |
pub const S_IFLNK: u32 = 0xA000; |
| 463 |
pub const S_IFREG: u32 = 0x8000; |
| 464 |
pub const S_IFMT: u32 = 0xF000; |
| 465 |
pub const S_IFIFO: u32 = 0x1000; |
| 466 |
pub const S_IFSOCK: u32 = 0xc000; |
| 467 |
pub const S_IFBLK: u32 = 0x6000; |
| 468 |
pub const S_IFCHR: u32 = 0x2000; |
| 469 |
pub const S_IRUSR: u32 = 0x100; |
| 470 |
pub const S_IWUSR: u32 = 0x80; |
| 471 |
pub const S_IXUSR: u32 = 0x40; |
| 472 |
pub const S_IRGRP: u32 = 0x20; |
| 473 |
pub const S_IWGRP: u32 = 0x10; |
| 474 |
pub const S_IXGRP: u32 = 0x8; |
| 475 |
pub const S_IROTH: u32 = 0x004; |
| 476 |
pub const S_IWOTH: u32 = 0x002; |
| 477 |
pub const S_IXOTH: u32 = 0x001; |
| 478 |
|
| 479 |
// sys/poll.h |
| 480 |
pub const POLLIN: i16 = 0x01; |
| 481 |
pub const POLLOUT: i16 = 0x04; |
| 482 |
pub const POLLHUP: i16 = 0x10; |
| 483 |
pub const POLLERR: i16 = 0x08; |
| 484 |
pub const POLLNVAL: i16 = 0x20; |
| 485 |
|
| 486 |
// sys/socket.h |
| 487 |
pub const AF_UNIX: i32 = 1; |
| 488 |
pub const SOCK_DGRAM: i32 = 2; |
| 489 |
pub const SOCK_STREAM: i32 = 1; |
| 490 |
pub const AF_INET: i32 = 2; |
| 491 |
pub const AF_INET6: i32 = 10; |
| 492 |
pub const MSG_PEEK: i32 = 0x02; |
| 493 |
pub const SOL_SOCKET: i32 = 1; |
| 494 |
pub const SHUT_WR: i32 = 2; |
| 495 |
pub const SHUT_RD: i32 = 1; |
| 496 |
pub const SHUT_RDWR: i32 = 3; |
| 497 |
pub const SO_ERROR: i32 = 4; |
| 498 |
pub const SO_REUSEADDR: i32 = 11; |
| 499 |
pub const SOMAXCONN: i32 = 8; |
| 500 |
pub const SO_LINGER: i32 = 6; |
| 501 |
pub const SO_RCVTIMEO: i32 = 0xa; |
| 502 |
pub const SO_SNDTIMEO: i32 = 0xe; |
| 503 |
pub const SO_BROADCAST: i32 = 1; |
| 504 |
|
| 505 |
// netinet/tcp.h |
| 506 |
pub const TCP_NODELAY: i32 = 0x10; |
| 507 |
|
| 508 |
// nuttx/fs/ioctl.h |
| 509 |
pub const FIONBIO: i32 = 0x30a; |
| 510 |
|
| 511 |
// unistd.h |
| 512 |
pub const _SC_PAGESIZE: i32 = 0x36; |
| 513 |
pub const _SC_THREAD_STACK_MIN: i32 = 0x58; |
| 514 |
pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25; |
| 515 |
|
| 516 |
// signal.h |
| 517 |
pub const SIGHUP: c_int = 1; |
| 518 |
pub const SIGINT: c_int = 2; |
| 519 |
pub const SIGQUIT: c_int = 3; |
| 520 |
pub const SIGILL: c_int = 4; |
| 521 |
pub const SIGTRAP: c_int = 5; |
| 522 |
pub const SIGABRT: c_int = 6; |
| 523 |
pub const SIGBUS: c_int = 7; |
| 524 |
pub const SIGFPE: c_int = 8; |
| 525 |
pub const SIGKILL: c_int = 9; |
| 526 |
pub const SIGUSR1: c_int = 10; |
| 527 |
pub const SIGSEGV: c_int = 11; |
| 528 |
pub const SIGUSR2: c_int = 12; |
| 529 |
pub const SIGPIPE: c_int = 13; |
| 530 |
pub const SIGALRM: c_int = 14; |
| 531 |
pub const SIGTERM: c_int = 15; |
| 532 |
pub const SIGSTKFLT: c_int = 16; |
| 533 |
pub const SIGCHLD: c_int = 17; |
| 534 |
pub const SIGCONT: c_int = 18; |
| 535 |
pub const SIGSTOP: c_int = 19; |
| 536 |
pub const SIGTSTP: c_int = 20; |
| 537 |
pub const SIGTTIN: c_int = 21; |
| 538 |
pub const SIGTTOU: c_int = 22; |
| 539 |
pub const SIGURG: c_int = 23; |
| 540 |
pub const SIGXCPU: c_int = 24; |
| 541 |
pub const SIGXFSZ: c_int = 25; |
| 542 |
pub const SIGVTALRM: c_int = 26; |
| 543 |
pub const SIGPROF: c_int = 27; |
| 544 |
pub const SIGWINCH: c_int = 28; |
| 545 |
pub const SIGIO: c_int = 29; |
| 546 |
pub const SIGPOLL: c_int = SIGIO; |
| 547 |
pub const SIGPWR: c_int = 30; |
| 548 |
pub const SIGSYS: c_int = 31; |
| 549 |
|
| 550 |
// pthread.h |
| 551 |
pub const PTHREAD_MUTEX_NORMAL: i32 = 0; |
| 552 |
|
| 553 |
// netinet/in.h |
| 554 |
pub const IP_TTL: i32 = 0x1e; |
| 555 |
pub const IPV6_V6ONLY: i32 = 0x17; |
| 556 |
pub const IPV6_JOIN_GROUP: i32 = 0x11; |
| 557 |
pub const IPV6_LEAVE_GROUP: i32 = 0x12; |
| 558 |
pub const IP_MULTICAST_LOOP: i32 = 0x13; |
| 559 |
pub const IPV6_MULTICAST_LOOP: i32 = 0x15; |
| 560 |
pub const IP_MULTICAST_TTL: i32 = 0x12; |
| 561 |
pub const IP_ADD_MEMBERSHIP: i32 = 0x14; |
| 562 |
pub const IP_DROP_MEMBERSHIP: i32 = 0x15; |
| 563 |
|
| 564 |
extern "C" { |
| 565 |
pub fn __errno() -> *mut c_int; |
| 566 |
pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32; |
| 567 |
pub fn ioctl(fd: i32, request: i32, ...) -> i32; |
| 568 |
pub fn dirfd(dirp: *mut DIR) -> i32; |
| 569 |
pub fn recvfrom( |
| 570 |
sockfd: i32, |
| 571 |
buf: *mut c_void, |
| 572 |
len: usize, |
| 573 |
flags: i32, |
| 574 |
src_addr: *mut sockaddr, |
| 575 |
addrlen: *mut socklen_t, |
| 576 |
) -> i32; |
| 577 |
|
| 578 |
pub fn pthread_create( |
| 579 |
thread: *mut pthread_t, |
| 580 |
attr: *const pthread_attr_t, |
| 581 |
start_routine: extern "C" fn(*mut c_void) -> *mut c_void, |
| 582 |
arg: *mut c_void, |
| 583 |
) -> i32; |
| 584 |
|
| 585 |
pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32; |
| 586 |
pub fn futimens(fd: i32, times: *const timespec) -> i32; |
| 587 |
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> i32; |
| 588 |
pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> i32; |
| 589 |
pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: usize) -> i32; |
| 590 |
pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize; |
| 591 |
pub fn arc4random() -> u32; |
| 592 |
pub fn arc4random_buf(bytes: *mut c_void, nbytes: usize); |
| 593 |
} |