1 //! Libc bindings for teeos
2 //!
3 //! Apparently the loader just dynamically links it anyway, but fails
4 //! when linking is explicitly requested.
5 #![allow(non_camel_case_types)]
6 #![allow(non_snake_case)]
7
8 use crate::prelude::*;
9
10 pub type c_bool = i32;
11
12 pub type intmax_t = i64;
13
14 pub type uintmax_t = u64;
15
16 pub type size_t = usize;
17
18 pub type ptrdiff_t = isize;
19
20 pub type intptr_t = isize;
21
22 pub type uintptr_t = usize;
23
24 pub type ssize_t = isize;
25
26 pub type pid_t = c_int;
27
28 pub type wchar_t = u32;
29
30 // long double in C means A float point value, which has 128bit length.
31 // but some bit maybe not used, so the real length of long double could be 80(x86) or 128(power pc/IEEE)
32 // this is different from f128(not stable and not included default) in Rust, so we use u128 for FFI(Rust to C).
33 // this is unstable and will cause to memfault/data abort.
34 pub type c_longdouble = _CLongDouble;
35
36 pub type pthread_t = c_ulong;
37
38 pub type pthread_key_t = c_uint;
39
40 pub type pthread_spinlock_t = c_int;
41
42 pub type off_t = i64;
43
44 pub type time_t = c_long;
45
46 pub type clock_t = c_long;
47
48 pub type clockid_t = c_int;
49
50 pub type suseconds_t = c_long;
51
52 pub type once_fn = extern "C" fn() -> c_void;
53
54 pub type pthread_once_t = c_int;
55
56 pub type va_list = *mut c_char;
57
58 pub type wint_t = c_uint;
59
60 pub type wctype_t = c_ulong;
61
62 pub type cmpfunc = extern "C" fn(x: *const c_void, y: *const c_void) -> c_int;
63
64 #[repr(align(16))]
65 pub struct _CLongDouble(pub u128);
66
67 #[repr(align(8))]
68 #[repr(C)]
69 pub struct pthread_cond_t {
70 #[doc(hidden)]
71 size: [u8; __SIZEOF_PTHREAD_COND_T],
72 }
73
74 #[repr(align(8))]
75 #[repr(C)]
76 pub struct pthread_mutex_t {
77 #[doc(hidden)]
78 size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
79 }
80
81 #[repr(align(4))]
82 #[repr(C)]
83 pub struct pthread_mutexattr_t {
84 #[doc(hidden)]
85 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
86 }
87
88 #[repr(align(4))]
89 #[repr(C)]
90 pub struct pthread_condattr_t {
91 #[doc(hidden)]
92 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
93 }
94
95 #[repr(C)]
96 pub struct pthread_attr_t {
97 __size: [u64; 7],
98 }
99
100 #[repr(C)]
101 pub struct cpu_set_t {
102 bits: [c_ulong; 128 / core::mem::size_of::<c_ulong>()],
103 }
104
105 #[repr(C)]
106 pub struct timespec {
107 pub tv_sec: time_t,
108 pub tv_nsec: c_long,
109 }
110
111 #[repr(C)]
112 pub struct timeval {
113 pub tv_sec: time_t,
114 pub tv_usec: suseconds_t,
115 }
116
117 #[repr(C)]
118 pub struct tm {
119 pub tm_sec: c_int,
120 pub tm_min: c_int,
121 pub tm_hour: c_int,
122 pub tm_mday: c_int,
123 pub tm_mon: c_int,
124 pub tm_year: c_int,
125 pub tm_wday: c_int,
126 pub tm_yday: c_int,
127 pub tm_isdst: c_int,
128 pub __tm_gmtoff: c_long,
129 pub __tm_zone: *const c_char,
130 }
131
132 #[repr(C)]
133 pub struct mbstate_t {
134 pub __opaque1: c_uint,
135 pub __opaque2: c_uint,
136 }
137
138 #[repr(C)]
139 pub struct sem_t {
140 pub __val: [c_int; 4 * core::mem::size_of::<c_long>() / core::mem::size_of::<c_int>()],
141 }
142
143 #[repr(C)]
144 pub struct div_t {
145 pub quot: c_int,
146 pub rem: c_int,
147 }
148
149 // fcntl
150 pub const O_CREAT: u32 = 0o100;
151
152 pub const O_EXCL: u32 = 0o200;
153
154 pub const O_NOCTTY: u32 = 0o400;
155
156 pub const O_TRUNC: u32 = 0o1000;
157
158 pub const O_APPEND: u32 = 0o2000;
159
160 pub const O_NONBLOCK: u32 = 0o4000;
161
162 pub const O_DSYNC: u32 = 0o10000;
163
164 pub const O_SYNC: u32 = 0o4010000;
165
166 pub const O_RSYNC: u32 = 0o4010000;
167
168 pub const O_DIRECTORY: u32 = 0o200000;
169
170 pub const O_NOFOLLOW: u32 = 0o400000;
171
172 pub const O_CLOEXEC: u32 = 0o2000000;
173
174 pub const O_ASYNC: u32 = 0o20000;
175
176 pub const O_DIRECT: u32 = 0o40000;
177
178 pub const O_LARGEFILE: u32 = 0o100000;
179
180 pub const O_NOATIME: u32 = 0o1000000;
181
182 pub const O_PATH: u32 = 0o10000000;
183
184 pub const O_TMPFILE: u32 = 0o20200000;
185
186 pub const O_NDELAY: u32 = O_NONBLOCK;
187
188 pub const F_DUPFD: u32 = 0;
189
190 pub const F_GETFD: u32 = 1;
191
192 pub const F_SETFD: u32 = 2;
193
194 pub const F_GETFL: u32 = 3;
195
196 pub const F_SETFL: u32 = 4;
197
198 pub const F_SETOWN: u32 = 8;
199
200 pub const F_GETOWN: u32 = 9;
201
202 pub const F_SETSIG: u32 = 10;
203
204 pub const F_GETSIG: u32 = 11;
205
206 pub const F_GETLK: u32 = 12;
207
208 pub const F_SETLK: u32 = 13;
209
210 pub const F_SETLKW: u32 = 14;
211
212 pub const F_SETOWN_EX: u32 = 15;
213
214 pub const F_GETOWN_EX: u32 = 16;
215
216 pub const F_GETOWNER_UIDS: u32 = 17;
217
218 // mman
219 pub const MAP_FAILED: u64 = 0xffffffffffffffff;
220
221 pub const MAP_FIXED_NOREPLACE: u32 = 0x100000;
222
223 pub const MAP_SHARED_VALIDATE: u32 = 0x03;
224
225 pub const MAP_SHARED: u32 = 0x01;
226
227 pub const MAP_PRIVATE: u32 = 0x02;
228
229 pub const MAP_TYPE: u32 = 0x0f;
230
231 pub const MAP_FIXED: u32 = 0x10;
232
233 pub const MAP_ANON: u32 = 0x20;
234
235 pub const MAP_ANONYMOUS: u32 = MAP_ANON;
236
237 pub const MAP_NORESERVE: u32 = 0x4000;
238
239 pub const MAP_GROWSDOWN: u32 = 0x0100;
240
241 pub const MAP_DENYWRITE: u32 = 0x0800;
242
243 pub const MAP_EXECUTABLE: u32 = 0x1000;
244
245 pub const MAP_LOCKED: u32 = 0x2000;
246
247 pub const MAP_POPULATE: u32 = 0x8000;
248
249 pub const MAP_NONBLOCK: u32 = 0x10000;
250
251 pub const MAP_STACK: u32 = 0x20000;
252
253 pub const MAP_HUGETLB: u32 = 0x40000;
254
255 pub const MAP_SYNC: u32 = 0x80000;
256
257 pub const MAP_FILE: u32 = 0;
258
259 pub const MAP_HUGE_SHIFT: u32 = 26;
260
261 pub const MAP_HUGE_MASK: u32 = 0x3f;
262
263 pub const MAP_HUGE_16KB: u32 = 14 << 26;
264
265 pub const MAP_HUGE_64KB: u32 = 16 << 26;
266
267 pub const MAP_HUGE_512KB: u32 = 19 << 26;
268
269 pub const MAP_HUGE_1MB: u32 = 20 << 26;
270
271 pub const MAP_HUGE_2MB: u32 = 21 << 26;
272
273 pub const MAP_HUGE_8MB: u32 = 23 << 26;
274
275 pub const MAP_HUGE_16MB: u32 = 24 << 26;
276
277 pub const MAP_HUGE_32MB: u32 = 25 << 26;
278
279 pub const MAP_HUGE_256MB: u32 = 28 << 26;
280
281 pub const MAP_HUGE_512MB: u32 = 29 << 26;
282
283 pub const MAP_HUGE_1GB: u32 = 30 << 26;
284
285 pub const MAP_HUGE_2GB: u32 = 31 << 26;
286
287 pub const MAP_HUGE_16GB: u32 = 34u32 << 26;
288
289 pub const PROT_NONE: u32 = 0;
290
291 pub const PROT_READ: u32 = 1;
292
293 pub const PROT_WRITE: u32 = 2;
294
295 pub const PROT_EXEC: u32 = 4;
296
297 pub const PROT_GROWSDOWN: u32 = 0x01000000;
298
299 pub const PROT_GROWSUP: u32 = 0x02000000;
300
301 pub const MS_ASYNC: u32 = 1;
302
303 pub const MS_INVALIDATE: u32 = 2;
304
305 pub const MS_SYNC: u32 = 4;
306
307 pub const MCL_CURRENT: u32 = 1;
308
309 pub const MCL_FUTURE: u32 = 2;
310
311 pub const MCL_ONFAULT: u32 = 4;
312
313 pub const POSIX_MADV_NORMAL: u32 = 0;
314
315 pub const POSIX_MADV_RANDOM: u32 = 1;
316
317 pub const POSIX_MADV_SEQUENTIAL: u32 = 2;
318
319 pub const POSIX_MADV_WILLNEED: u32 = 3;
320
321 pub const POSIX_MADV_DONTNEED: u32 = 4;
322
323 // wctype
324 pub const WCTYPE_ALNUM: u64 = 1;
325
326 pub const WCTYPE_ALPHA: u64 = 2;
327
328 pub const WCTYPE_BLANK: u64 = 3;
329
330 pub const WCTYPE_CNTRL: u64 = 4;
331
332 pub const WCTYPE_DIGIT: u64 = 5;
333
334 pub const WCTYPE_GRAPH: u64 = 6;
335
336 pub const WCTYPE_LOWER: u64 = 7;
337
338 pub const WCTYPE_PRINT: u64 = 8;
339
340 pub const WCTYPE_PUNCT: u64 = 9;
341
342 pub const WCTYPE_SPACE: u64 = 10;
343
344 pub const WCTYPE_UPPER: u64 = 11;
345
346 pub const WCTYPE_XDIGIT: u64 = 12;
347
348 // locale
349 pub const LC_CTYPE: i32 = 0;
350
351 pub const LC_NUMERIC: i32 = 1;
352
353 pub const LC_TIME: i32 = 2;
354
355 pub const LC_COLLATE: i32 = 3;
356
357 pub const LC_MONETARY: i32 = 4;
358
359 pub const LC_MESSAGES: i32 = 5;
360
361 pub const LC_ALL: i32 = 6;
362
363 // pthread
364 pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
365
366 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
367
368 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
369
370 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
371
372 // errno.h
373 pub const EPERM: c_int = 1;
374
375 pub const ENOENT: c_int = 2;
376
377 pub const ESRCH: c_int = 3;
378
379 pub const EINTR: c_int = 4;
380
381 pub const EIO: c_int = 5;
382
383 pub const ENXIO: c_int = 6;
384
385 pub const E2BIG: c_int = 7;
386
387 pub const ENOEXEC: c_int = 8;
388
389 pub const EBADF: c_int = 9;
390
391 pub const ECHILD: c_int = 10;
392
393 pub const EAGAIN: c_int = 11;
394
395 pub const ENOMEM: c_int = 12;
396
397 pub const EACCES: c_int = 13;
398
399 pub const EFAULT: c_int = 14;
400
401 pub const ENOTBLK: c_int = 15;
402
403 pub const EBUSY: c_int = 16;
404
405 pub const EEXIST: c_int = 17;
406
407 pub const EXDEV: c_int = 18;
408
409 pub const ENODEV: c_int = 19;
410
411 pub const ENOTDIR: c_int = 20;
412
413 pub const EISDIR: c_int = 21;
414
415 pub const EINVAL: c_int = 22;
416
417 pub const ENFILE: c_int = 23;
418
419 pub const EMFILE: c_int = 24;
420
421 pub const ENOTTY: c_int = 25;
422
423 pub const ETXTBSY: c_int = 26;
424
425 pub const EFBIG: c_int = 27;
426
427 pub const ENOSPC: c_int = 28;
428
429 pub const ESPIPE: c_int = 29;
430
431 pub const EROFS: c_int = 30;
432
433 pub const EMLINK: c_int = 31;
434
435 pub const EPIPE: c_int = 32;
436
437 pub const EDOM: c_int = 33;
438
439 pub const ERANGE: c_int = 34;
440
441 pub const EDEADLK: c_int = 35;
442
443 pub const ENAMETOOLONG: c_int = 36;
444
445 pub const ENOLCK: c_int = 37;
446
447 pub const ENOSYS: c_int = 38;
448
449 pub const ENOTEMPTY: c_int = 39;
450
451 pub const ELOOP: c_int = 40;
452
453 pub const EWOULDBLOCK: c_int = EAGAIN;
454
455 pub const ENOMSG: c_int = 42;
456
457 pub const EIDRM: c_int = 43;
458
459 pub const ECHRNG: c_int = 44;
460
461 pub const EL2NSYNC: c_int = 45;
462
463 pub const EL3HLT: c_int = 46;
464
465 pub const EL3RST: c_int = 47;
466
467 pub const ELNRNG: c_int = 48;
468
469 pub const EUNATCH: c_int = 49;
470
471 pub const ENOCSI: c_int = 50;
472
473 pub const EL2HLT: c_int = 51;
474
475 pub const EBADE: c_int = 52;
476
477 pub const EBADR: c_int = 53;
478
479 pub const EXFULL: c_int = 54;
480
481 pub const ENOANO: c_int = 55;
482
483 pub const EBADRQC: c_int = 56;
484
485 pub const EBADSLT: c_int = 57;
486
487 pub const EDEADLOCK: c_int = EDEADLK;
488
489 pub const EBFONT: c_int = 59;
490
491 pub const ENOSTR: c_int = 60;
492
493 pub const ENODATA: c_int = 61;
494
495 pub const ETIME: c_int = 62;
496
497 pub const ENOSR: c_int = 63;
498
499 pub const ENONET: c_int = 64;
500
501 pub const ENOPKG: c_int = 65;
502
503 pub const EREMOTE: c_int = 66;
504
505 pub const ENOLINK: c_int = 67;
506
507 pub const EADV: c_int = 68;
508
509 pub const ESRMNT: c_int = 69;
510
511 pub const ECOMM: c_int = 70;
512
513 pub const EPROTO: c_int = 71;
514
515 pub const EMULTIHOP: c_int = 72;
516
517 pub const EDOTDOT: c_int = 73;
518
519 pub const EBADMSG: c_int = 74;
520
521 pub const EOVERFLOW: c_int = 75;
522
523 pub const ENOTUNIQ: c_int = 76;
524
525 pub const EBADFD: c_int = 77;
526
527 pub const EREMCHG: c_int = 78;
528
529 pub const ELIBACC: c_int = 79;
530
531 pub const ELIBBAD: c_int = 80;
532
533 pub const ELIBSCN: c_int = 81;
534
535 pub const ELIBMAX: c_int = 82;
536
537 pub const ELIBEXEC: c_int = 83;
538
539 pub const EILSEQ: c_int = 84;
540
541 pub const ERESTART: c_int = 85;
542
543 pub const ESTRPIPE: c_int = 86;
544
545 pub const EUSERS: c_int = 87;
546
547 pub const ENOTSOCK: c_int = 88;
548
549 pub const EDESTADDRREQ: c_int = 89;
550
551 pub const EMSGSIZE: c_int = 90;
552
553 pub const EPROTOTYPE: c_int = 91;
554
555 pub const ENOPROTOOPT: c_int = 92;
556
557 pub const EPROTONOSUPPOR: c_int = 93;
558
559 pub const ESOCKTNOSUPPOR: c_int = 94;
560
561 pub const EOPNOTSUPP: c_int = 95;
562
563 pub const ENOTSUP: c_int = EOPNOTSUPP;
564
565 pub const EPFNOSUPPORT: c_int = 96;
566
567 pub const EAFNOSUPPORT: c_int = 97;
568
569 pub const EADDRINUSE: c_int = 98;
570
571 pub const EADDRNOTAVAIL: c_int = 99;
572
573 pub const ENETDOWN: c_int = 100;
574
575 pub const ENETUNREACH: c_int = 101;
576
577 pub const ENETRESET: c_int = 102;
578
579 pub const ECONNABORTED: c_int = 103;
580
581 pub const ECONNRESET: c_int = 104;
582
583 pub const ENOBUFS: c_int = 105;
584
585 pub const EISCONN: c_int = 106;
586
587 pub const ENOTCONN: c_int = 107;
588
589 pub const ESHUTDOWN: c_int = 108;
590
591 pub const ETOOMANYREFS: c_int = 109;
592
593 pub const ETIMEDOUT: c_int = 110;
594
595 pub const ECONNREFUSED: c_int = 111;
596
597 pub const EHOSTDOWN: c_int = 112;
598
599 pub const EHOSTUNREACH: c_int = 113;
600
601 pub const EALREADY: c_int = 114;
602
603 pub const EINPROGRESS: c_int = 115;
604
605 pub const ESTALE: c_int = 116;
606
607 pub const EUCLEAN: c_int = 117;
608
609 pub const ENOTNAM: c_int = 118;
610
611 pub const ENAVAIL: c_int = 119;
612
613 pub const EISNAM: c_int = 120;
614
615 pub const EREMOTEIO: c_int = 121;
616
617 pub const EDQUOT: c_int = 122;
618
619 pub const ENOMEDIUM: c_int = 123;
620
621 pub const EMEDIUMTYPE: c_int = 124;
622
623 pub const ECANCELED: c_int = 125;
624
625 pub const ENOKEY: c_int = 126;
626
627 pub const EKEYEXPIRED: c_int = 127;
628
629 pub const EKEYREVOKED: c_int = 128;
630
631 pub const EKEYREJECTED: c_int = 129;
632
633 pub const EOWNERDEAD: c_int = 130;
634
635 pub const ENOTRECOVERABLE: c_int = 131;
636
637 pub const ERFKILL: c_int = 132;
638
639 pub const EHWPOISON: c_int = 133;
640
641 // pthread_attr.h
642 pub const TEESMP_THREAD_ATTR_CA_WILDCARD: c_int = 0;
643
644 pub const TEESMP_THREAD_ATTR_CA_INHERIT: c_int = -1;
645
646 pub const TEESMP_THREAD_ATTR_TASK_ID_INHERIT: c_int = -1;
647
648 pub const TEESMP_THREAD_ATTR_HAS_SHADOW: c_int = 0x1;
649
650 pub const TEESMP_THREAD_ATTR_NO_SHADOW: c_int = 0x0;
651
652 // unistd.h
653 pub const _SC_ARG_MAX: c_int = 0;
654
655 pub const _SC_CHILD_MAX: c_int = 1;
656
657 pub const _SC_CLK_TCK: c_int = 2;
658
659 pub const _SC_NGROUPS_MAX: c_int = 3;
660
661 pub const _SC_OPEN_MAX: c_int = 4;
662
663 pub const _SC_STREAM_MAX: c_int = 5;
664
665 pub const _SC_TZNAME_MAX: c_int = 6;
666
667 pub const _SC_JOB_CONTROL: c_int = 7;
668
669 pub const _SC_SAVED_IDS: c_int = 8;
670
671 pub const _SC_REALTIME_SIGNALS: c_int = 9;
672
673 pub const _SC_PRIORITY_SCHEDULING: c_int = 10;
674
675 pub const _SC_TIMERS: c_int = 11;
676
677 pub const _SC_ASYNCHRONOUS_IO: c_int = 12;
678
679 pub const _SC_PRIORITIZED_IO: c_int = 13;
680
681 pub const _SC_SYNCHRONIZED_IO: c_int = 14;
682
683 pub const _SC_FSYNC: c_int = 15;
684
685 pub const _SC_MAPPED_FILES: c_int = 16;
686
687 pub const _SC_MEMLOCK: c_int = 17;
688
689 pub const _SC_MEMLOCK_RANGE: c_int = 18;
690
691 pub const _SC_MEMORY_PROTECTION: c_int = 19;
692
693 pub const _SC_MESSAGE_PASSING: c_int = 20;
694
695 pub const _SC_SEMAPHORES: c_int = 21;
696
697 pub const _SC_SHARED_MEMORY_OBJECTS: c_int = 22;
698
699 pub const _SC_AIO_LISTIO_MAX: c_int = 23;
700
701 pub const _SC_AIO_MAX: c_int = 24;
702
703 pub const _SC_AIO_PRIO_DELTA_MAX: c_int = 25;
704
705 pub const _SC_DELAYTIMER_MAX: c_int = 26;
706
707 pub const _SC_MQ_OPEN_MAX: c_int = 27;
708
709 pub const _SC_MQ_PRIO_MAX: c_int = 28;
710
711 pub const _SC_VERSION: c_int = 29;
712
713 pub const _SC_PAGE_SIZE: c_int = 30;
714
715 pub const _SC_PAGESIZE: c_int = 30; /* !! */
716
717 pub const _SC_RTSIG_MAX: c_int = 31;
718
719 pub const _SC_SEM_NSEMS_MAX: c_int = 32;
720
721 pub const _SC_SEM_VALUE_MAX: c_int = 33;
722
723 pub const _SC_SIGQUEUE_MAX: c_int = 34;
724
725 pub const _SC_TIMER_MAX: c_int = 35;
726
727 pub const _SC_BC_BASE_MAX: c_int = 36;
728
729 pub const _SC_BC_DIM_MAX: c_int = 37;
730
731 pub const _SC_BC_SCALE_MAX: c_int = 38;
732
733 pub const _SC_BC_STRING_MAX: c_int = 39;
734
735 pub const _SC_COLL_WEIGHTS_MAX: c_int = 40;
736
737 pub const _SC_EXPR_NEST_MAX: c_int = 42;
738
739 pub const _SC_LINE_MAX: c_int = 43;
740
741 pub const _SC_RE_DUP_MAX: c_int = 44;
742
743 pub const _SC_2_VERSION: c_int = 46;
744
745 pub const _SC_2_C_BIND: c_int = 47;
746
747 pub const _SC_2_C_DEV: c_int = 48;
748
749 pub const _SC_2_FORT_DEV: c_int = 49;
750
751 pub const _SC_2_FORT_RUN: c_int = 50;
752
753 pub const _SC_2_SW_DEV: c_int = 51;
754
755 pub const _SC_2_LOCALEDEF: c_int = 52;
756
757 pub const _SC_UIO_MAXIOV: c_int = 60; /* !! */
758
759 pub const _SC_IOV_MAX: c_int = 60;
760
761 pub const _SC_THREADS: c_int = 67;
762
763 pub const _SC_THREAD_SAFE_FUNCTIONS: c_int = 68;
764
765 pub const _SC_GETGR_R_SIZE_MAX: c_int = 69;
766
767 pub const _SC_GETPW_R_SIZE_MAX: c_int = 70;
768
769 pub const _SC_LOGIN_NAME_MAX: c_int = 71;
770
771 pub const _SC_TTY_NAME_MAX: c_int = 72;
772
773 pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: c_int = 73;
774
775 pub const _SC_THREAD_KEYS_MAX: c_int = 74;
776
777 pub const _SC_THREAD_STACK_MIN: c_int = 75;
778
779 pub const _SC_THREAD_THREADS_MAX: c_int = 76;
780
781 pub const _SC_THREAD_ATTR_STACKADDR: c_int = 77;
782
783 pub const _SC_THREAD_ATTR_STACKSIZE: c_int = 78;
784
785 pub const _SC_THREAD_PRIORITY_SCHEDULING: c_int = 79;
786
787 pub const _SC_THREAD_PRIO_INHERIT: c_int = 80;
788
789 pub const _SC_THREAD_PRIO_PROTECT: c_int = 81;
790
791 pub const _SC_THREAD_PROCESS_SHARED: c_int = 82;
792
793 pub const _SC_NPROCESSORS_CONF: c_int = 83;
794
795 pub const _SC_NPROCESSORS_ONLN: c_int = 84;
796
797 pub const _SC_PHYS_PAGES: c_int = 85;
798
799 pub const _SC_AVPHYS_PAGES: c_int = 86;
800
801 pub const _SC_ATEXIT_MAX: c_int = 87;
802
803 pub const _SC_PASS_MAX: c_int = 88;
804
805 pub const _SC_XOPEN_VERSION: c_int = 89;
806
807 pub const _SC_XOPEN_XCU_VERSION: c_int = 90;
808
809 pub const _SC_XOPEN_UNIX: c_int = 91;
810
811 pub const _SC_XOPEN_CRYPT: c_int = 92;
812
813 pub const _SC_XOPEN_ENH_I18N: c_int = 93;
814
815 pub const _SC_XOPEN_SHM: c_int = 94;
816
817 pub const _SC_2_CHAR_TERM: c_int = 95;
818
819 pub const _SC_2_UPE: c_int = 97;
820
821 pub const _SC_XOPEN_XPG2: c_int = 98;
822
823 pub const _SC_XOPEN_XPG3: c_int = 99;
824
825 pub const _SC_XOPEN_XPG4: c_int = 100;
826
827 pub const _SC_NZERO: c_int = 109;
828
829 pub const _SC_XBS5_ILP32_OFF32: c_int = 125;
830
831 pub const _SC_XBS5_ILP32_OFFBIG: c_int = 126;
832
833 pub const _SC_XBS5_LP64_OFF64: c_int = 127;
834
835 pub const _SC_XBS5_LPBIG_OFFBIG: c_int = 128;
836
837 pub const _SC_XOPEN_LEGACY: c_int = 129;
838
839 pub const _SC_XOPEN_REALTIME: c_int = 130;
840
841 pub const _SC_XOPEN_REALTIME_THREADS: c_int = 131;
842
843 pub const _SC_ADVISORY_INFO: c_int = 132;
844
845 pub const _SC_BARRIERS: c_int = 133;
846
847 pub const _SC_CLOCK_SELECTION: c_int = 137;
848
849 pub const _SC_CPUTIME: c_int = 138;
850
851 pub const _SC_THREAD_CPUTIME: c_int = 139;
852
853 pub const _SC_MONOTONIC_CLOCK: c_int = 149;
854
855 pub const _SC_READER_WRITER_LOCKS: c_int = 153;
856
857 pub const _SC_SPIN_LOCKS: c_int = 154;
858
859 pub const _SC_REGEXP: c_int = 155;
860
861 pub const _SC_SHELL: c_int = 157;
862
863 pub const _SC_SPAWN: c_int = 159;
864
865 pub const _SC_SPORADIC_SERVER: c_int = 160;
866
867 pub const _SC_THREAD_SPORADIC_SERVER: c_int = 161;
868
869 pub const _SC_TIMEOUTS: c_int = 164;
870
871 pub const _SC_TYPED_MEMORY_OBJECTS: c_int = 165;
872
873 pub const _SC_2_PBS: c_int = 168;
874
875 pub const _SC_2_PBS_ACCOUNTING: c_int = 169;
876
877 pub const _SC_2_PBS_LOCATE: c_int = 170;
878
879 pub const _SC_2_PBS_MESSAGE: c_int = 171;
880
881 pub const _SC_2_PBS_TRACK: c_int = 172;
882
883 pub const _SC_SYMLOOP_MAX: c_int = 173;
884
885 pub const _SC_STREAMS: c_int = 174;
886
887 pub const _SC_2_PBS_CHECKPOINT: c_int = 175;
888
889 pub const _SC_V6_ILP32_OFF32: c_int = 176;
890
891 pub const _SC_V6_ILP32_OFFBIG: c_int = 177;
892
893 pub const _SC_V6_LP64_OFF64: c_int = 178;
894
895 pub const _SC_V6_LPBIG_OFFBIG: c_int = 179;
896
897 pub const _SC_HOST_NAME_MAX: c_int = 180;
898
899 pub const _SC_TRACE: c_int = 181;
900
901 pub const _SC_TRACE_EVENT_FILTER: c_int = 182;
902
903 pub const _SC_TRACE_INHERIT: c_int = 183;
904
905 pub const _SC_TRACE_LOG: c_int = 184;
906
907 pub const _SC_IPV6: c_int = 235;
908
909 pub const _SC_RAW_SOCKETS: c_int = 236;
910
911 pub const _SC_V7_ILP32_OFF32: c_int = 237;
912
913 pub const _SC_V7_ILP32_OFFBIG: c_int = 238;
914
915 pub const _SC_V7_LP64_OFF64: c_int = 239;
916
917 pub const _SC_V7_LPBIG_OFFBIG: c_int = 240;
918
919 pub const _SC_SS_REPL_MAX: c_int = 241;
920
921 pub const _SC_TRACE_EVENT_NAME_MAX: c_int = 242;
922
923 pub const _SC_TRACE_NAME_MAX: c_int = 243;
924
925 pub const _SC_TRACE_SYS_MAX: c_int = 244;
926
927 pub const _SC_TRACE_USER_EVENT_MAX: c_int = 245;
928
929 pub const _SC_XOPEN_STREAMS: c_int = 246;
930
931 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247;
932
933 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248;
934
935 // limits.h
936 pub const PTHREAD_KEYS_MAX: c_int = 128;
937
938 pub const PTHREAD_STACK_MIN: c_int = 2048;
939
940 pub const PTHREAD_DESTRUCTOR_ITERATIONS: c_int = 4;
941
942 pub const SEM_VALUE_MAX: c_int = 0x7fffffff;
943
944 pub const SEM_NSEMS_MAX: c_int = 256;
945
946 pub const DELAYTIMER_MAX: c_int = 0x7fffffff;
947
948 pub const MQ_PRIO_MAX: c_int = 32768;
949
950 pub const LOGIN_NAME_MAX: c_int = 256;
951
952 // time.h
953 pub const CLOCK_REALTIME: clockid_t = 0;
954
955 pub const CLOCK_MONOTONIC: clockid_t = 1;
956
957 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
958 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
959 };
960
961 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
962 size: [0; __SIZEOF_PTHREAD_COND_T],
963 };
964
965 pub const PTHREAD_MUTEX_NORMAL: c_int = 0;
966
967 pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1;
968
969 pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2;
970
971 pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL;
972
973 pub const PTHREAD_MUTEX_STALLED: c_int = 0;
974
975 pub const PTHREAD_MUTEX_ROBUST: c_int = 1;
976
977 extern "C" {
978 // ---- ALLOC -----------------------------------------------------------------------------
calloc(nobj: size_t, size: size_t) -> *mut c_void979 pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
980
malloc(size: size_t) -> *mut c_void981 pub fn malloc(size: size_t) -> *mut c_void;
982
realloc(p: *mut c_void, size: size_t) -> *mut c_void983 pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void;
984
aligned_alloc(align: size_t, len: size_t) -> *mut c_void985 pub fn aligned_alloc(align: size_t, len: size_t) -> *mut c_void;
986
free(p: *mut c_void)987 pub fn free(p: *mut c_void);
988
posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int989 pub fn posix_memalign(memptr: *mut *mut c_void, align: size_t, size: size_t) -> c_int;
990
memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void991 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
992
wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t993 pub fn wmemchr(cx: *const wchar_t, c: wchar_t, n: size_t) -> *mut wchar_t;
994
memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int995 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
996
memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void997 pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
998
memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void999 pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
1000
memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void1001 pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
1002
1003 // ----- PTHREAD ---------------------------------------------------------------------------
pthread_self() -> pthread_t1004 pub fn pthread_self() -> pthread_t;
1005
pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int1006 pub fn pthread_join(native: pthread_t, value: *mut *mut c_void) -> c_int;
1007
1008 // detach or pthread_attr_setdetachstate must not be called!
1009 //pub fn pthread_detach(thread: pthread_t) -> c_int;
1010
pthread_exit(value: *mut c_void) -> !1011 pub fn pthread_exit(value: *mut c_void) -> !;
1012
pthread_attr_init(attr: *mut pthread_attr_t) -> c_int1013 pub fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int;
1014
pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int1015 pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> c_int;
1016
pthread_attr_getstack( attr: *const pthread_attr_t, stackaddr: *mut *mut c_void, stacksize: *mut size_t, ) -> c_int1017 pub fn pthread_attr_getstack(
1018 attr: *const pthread_attr_t,
1019 stackaddr: *mut *mut c_void,
1020 stacksize: *mut size_t,
1021 ) -> c_int;
1022
pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int1023 pub fn pthread_attr_setstacksize(attr: *mut pthread_attr_t, stack_size: size_t) -> c_int;
1024
pthread_attr_getstacksize(attr: *const pthread_attr_t, size: *mut size_t) -> c_int1025 pub fn pthread_attr_getstacksize(attr: *const pthread_attr_t, size: *mut size_t) -> c_int;
1026
pthread_attr_settee( attr: *mut pthread_attr_t, ca: c_int, task_id: c_int, shadow: c_int, ) -> c_int1027 pub fn pthread_attr_settee(
1028 attr: *mut pthread_attr_t,
1029 ca: c_int,
1030 task_id: c_int,
1031 shadow: c_int,
1032 ) -> c_int;
1033
1034 // C-TA API do not include this interface, but TA can use.
sched_yield() -> c_int1035 pub fn sched_yield() -> c_int;
1036
pthread_key_create( key: *mut pthread_key_t, dtor: Option<unsafe extern "C" fn(*mut c_void)>, ) -> c_int1037 pub fn pthread_key_create(
1038 key: *mut pthread_key_t,
1039 dtor: Option<unsafe extern "C" fn(*mut c_void)>,
1040 ) -> c_int;
1041
pthread_key_delete(key: pthread_key_t) -> c_int1042 pub fn pthread_key_delete(key: pthread_key_t) -> c_int;
1043
pthread_getspecific(key: pthread_key_t) -> *mut c_void1044 pub fn pthread_getspecific(key: pthread_key_t) -> *mut c_void;
1045
pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int1046 pub fn pthread_setspecific(key: pthread_key_t, value: *const c_void) -> c_int;
1047
pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int1048 pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> c_int;
1049
pthread_mutex_init( lock: *mut pthread_mutex_t, attr: *const pthread_mutexattr_t, ) -> c_int1050 pub fn pthread_mutex_init(
1051 lock: *mut pthread_mutex_t,
1052 attr: *const pthread_mutexattr_t,
1053 ) -> c_int;
1054
pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int1055 pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> c_int;
1056
pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int1057 pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> c_int;
1058
pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int1059 pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> c_int;
1060
pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int1061 pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> c_int;
1062
pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int1063 pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> c_int;
1064
pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int1065 pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, _type: c_int) -> c_int;
1066
pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int1067 pub fn pthread_mutexattr_setpshared(attr: *mut pthread_mutexattr_t, pshared: c_int) -> c_int;
1068
pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int1069 pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> c_int;
1070
pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int1071 pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> c_int;
1072
pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int1073 pub fn pthread_cond_init(cond: *mut pthread_cond_t, attr: *const pthread_condattr_t) -> c_int;
1074
pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int1075 pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> c_int;
1076
pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int1077 pub fn pthread_cond_wait(cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t) -> c_int;
1078
pthread_cond_timedwait( cond: *mut pthread_cond_t, lock: *mut pthread_mutex_t, abstime: *const timespec, ) -> c_int1079 pub fn pthread_cond_timedwait(
1080 cond: *mut pthread_cond_t,
1081 lock: *mut pthread_mutex_t,
1082 abstime: *const timespec,
1083 ) -> c_int;
1084
pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: c_int) -> c_int1085 pub fn pthread_mutexattr_setrobust(attr: *mut pthread_mutexattr_t, robustness: c_int) -> c_int;
1086
pthread_create( native: *mut pthread_t, attr: *const pthread_attr_t, f: extern "C" fn(*mut c_void) -> *mut c_void, value: *mut c_void, ) -> c_int1087 pub fn pthread_create(
1088 native: *mut pthread_t,
1089 attr: *const pthread_attr_t,
1090 f: extern "C" fn(*mut c_void) -> *mut c_void,
1091 value: *mut c_void,
1092 ) -> c_int;
1093
pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int1094 pub fn pthread_spin_init(lock: *mut pthread_spinlock_t, pshared: c_int) -> c_int;
1095
pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int1096 pub fn pthread_spin_destroy(lock: *mut pthread_spinlock_t) -> c_int;
1097
pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int1098 pub fn pthread_spin_lock(lock: *mut pthread_spinlock_t) -> c_int;
1099
pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int1100 pub fn pthread_spin_trylock(lock: *mut pthread_spinlock_t) -> c_int;
1101
pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int1102 pub fn pthread_spin_unlock(lock: *mut pthread_spinlock_t) -> c_int;
1103
pthread_setschedprio(native: pthread_t, priority: c_int) -> c_int1104 pub fn pthread_setschedprio(native: pthread_t, priority: c_int) -> c_int;
1105
pthread_once(pot: *mut pthread_once_t, f: Option<once_fn>) -> c_int1106 pub fn pthread_once(pot: *mut pthread_once_t, f: Option<once_fn>) -> c_int;
1107
pthread_equal(p1: pthread_t, p2: pthread_t) -> c_int1108 pub fn pthread_equal(p1: pthread_t, p2: pthread_t) -> c_int;
1109
pthread_mutexattr_setprotocol(a: *mut pthread_mutexattr_t, protocol: c_int) -> c_int1110 pub fn pthread_mutexattr_setprotocol(a: *mut pthread_mutexattr_t, protocol: c_int) -> c_int;
1111
pthread_attr_setstack( attr: *mut pthread_attr_t, stack: *mut c_void, size: size_t, ) -> c_int1112 pub fn pthread_attr_setstack(
1113 attr: *mut pthread_attr_t,
1114 stack: *mut c_void,
1115 size: size_t,
1116 ) -> c_int;
1117
pthread_setaffinity_np(td: pthread_t, size: size_t, set: *const cpu_set_t) -> c_int1118 pub fn pthread_setaffinity_np(td: pthread_t, size: size_t, set: *const cpu_set_t) -> c_int;
1119
pthread_getaffinity_np(td: pthread_t, size: size_t, set: *mut cpu_set_t) -> c_int1120 pub fn pthread_getaffinity_np(td: pthread_t, size: size_t, set: *mut cpu_set_t) -> c_int;
1121
1122 // stdio.h
printf(fmt: *const c_char, ...) -> c_int1123 pub fn printf(fmt: *const c_char, ...) -> c_int;
1124
scanf(fmt: *const c_char, ...) -> c_int1125 pub fn scanf(fmt: *const c_char, ...) -> c_int;
1126
snprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ...) -> c_int1127 pub fn snprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ...) -> c_int;
1128
sprintf(s: *mut c_char, fmt: *const c_char, ...) -> c_int1129 pub fn sprintf(s: *mut c_char, fmt: *const c_char, ...) -> c_int;
1130
vsnprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ap: va_list) -> c_int1131 pub fn vsnprintf(s: *mut c_char, n: size_t, fmt: *const c_char, ap: va_list) -> c_int;
1132
vsprintf(s: *mut c_char, fmt: *const c_char, ap: va_list) -> c_int1133 pub fn vsprintf(s: *mut c_char, fmt: *const c_char, ap: va_list) -> c_int;
1134
1135 // Not available.
1136 //pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> c_int;
1137
abort() -> !1138 pub fn abort() -> !;
1139
1140 // Not available.
1141 //pub fn prctl(op: c_int, ...) -> c_int;
1142
sched_getaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *mut cpu_set_t) -> c_int1143 pub fn sched_getaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *mut cpu_set_t) -> c_int;
1144
sched_setaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *const cpu_set_t) -> c_int1145 pub fn sched_setaffinity(pid: pid_t, cpusetsize: size_t, cpuset: *const cpu_set_t) -> c_int;
1146
1147 // sysconf is currently only implemented as a stub.
sysconf(name: c_int) -> c_long1148 pub fn sysconf(name: c_int) -> c_long;
1149
1150 // mman.h
mmap( addr: *mut c_void, len: size_t, prot: c_int, flags: c_int, fd: c_int, offset: off_t, ) -> *mut c_void1151 pub fn mmap(
1152 addr: *mut c_void,
1153 len: size_t,
1154 prot: c_int,
1155 flags: c_int,
1156 fd: c_int,
1157 offset: off_t,
1158 ) -> *mut c_void;
munmap(addr: *mut c_void, len: size_t) -> c_int1159 pub fn munmap(addr: *mut c_void, len: size_t) -> c_int;
1160
1161 // errno.h
__errno_location() -> *mut c_int1162 pub fn __errno_location() -> *mut c_int;
1163
strerror(e: c_int) -> *mut c_char1164 pub fn strerror(e: c_int) -> *mut c_char;
1165
1166 // time.h
clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int1167 pub fn clock_gettime(clock_id: clockid_t, tp: *mut timespec) -> c_int;
1168
1169 // unistd
getpid() -> pid_t1170 pub fn getpid() -> pid_t;
1171
1172 // time
gettimeofday(tv: *mut timeval, tz: *mut c_void) -> c_int1173 pub fn gettimeofday(tv: *mut timeval, tz: *mut c_void) -> c_int;
1174
strftime( restrict: *mut c_char, sz: size_t, _restrict: *const c_char, __restrict: *const tm, ) -> size_t1175 pub fn strftime(
1176 restrict: *mut c_char,
1177 sz: size_t,
1178 _restrict: *const c_char,
1179 __restrict: *const tm,
1180 ) -> size_t;
1181
time(t: *mut time_t) -> time_t1182 pub fn time(t: *mut time_t) -> time_t;
1183
1184 // sem
sem_close(sem: *mut sem_t) -> c_int1185 pub fn sem_close(sem: *mut sem_t) -> c_int;
1186
sem_destroy(sem: *mut sem_t) -> c_int1187 pub fn sem_destroy(sem: *mut sem_t) -> c_int;
1188
sem_getvalue(sem: *mut sem_t, valp: *mut c_int) -> c_int1189 pub fn sem_getvalue(sem: *mut sem_t, valp: *mut c_int) -> c_int;
1190
sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int1191 pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int;
1192
sem_open(name: *const c_char, flags: c_int, ...) -> *mut sem_t1193 pub fn sem_open(name: *const c_char, flags: c_int, ...) -> *mut sem_t;
1194
sem_post(sem: *mut sem_t) -> c_int1195 pub fn sem_post(sem: *mut sem_t) -> c_int;
1196
sem_unlink(name: *const c_char) -> c_int1197 pub fn sem_unlink(name: *const c_char) -> c_int;
1198
sem_wait(sem: *mut sem_t) -> c_int1199 pub fn sem_wait(sem: *mut sem_t) -> c_int;
1200
1201 // locale
setlocale(cat: c_int, name: *const c_char) -> *mut c_char1202 pub fn setlocale(cat: c_int, name: *const c_char) -> *mut c_char;
1203
strcoll(l: *const c_char, r: *const c_char) -> c_int1204 pub fn strcoll(l: *const c_char, r: *const c_char) -> c_int;
1205
strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t1206 pub fn strxfrm(dest: *mut c_char, src: *const c_char, n: size_t) -> size_t;
1207
strtod(s: *const c_char, p: *mut *mut c_char) -> c_double1208 pub fn strtod(s: *const c_char, p: *mut *mut c_char) -> c_double;
1209
1210 // multibyte
mbrtowc(wc: *mut wchar_t, src: *const c_char, n: size_t, st: *mut mbstate_t) -> size_t1211 pub fn mbrtowc(wc: *mut wchar_t, src: *const c_char, n: size_t, st: *mut mbstate_t) -> size_t;
1212
wcrtomb(s: *mut c_char, wc: wchar_t, st: *mut mbstate_t) -> size_t1213 pub fn wcrtomb(s: *mut c_char, wc: wchar_t, st: *mut mbstate_t) -> size_t;
1214
wctob(c: wint_t) -> c_int1215 pub fn wctob(c: wint_t) -> c_int;
1216
1217 // prng
srandom(seed: c_uint)1218 pub fn srandom(seed: c_uint);
1219
initstate(seed: c_uint, state: *mut c_char, size: size_t) -> *mut c_char1220 pub fn initstate(seed: c_uint, state: *mut c_char, size: size_t) -> *mut c_char;
1221
setstate(state: *mut c_char) -> *mut c_char1222 pub fn setstate(state: *mut c_char) -> *mut c_char;
1223
random() -> c_long1224 pub fn random() -> c_long;
1225
1226 // string
strchr(s: *const c_char, c: c_int) -> *mut c_char1227 pub fn strchr(s: *const c_char, c: c_int) -> *mut c_char;
1228
strlen(cs: *const c_char) -> size_t1229 pub fn strlen(cs: *const c_char) -> size_t;
1230
strcmp(l: *const c_char, r: *const c_char) -> c_int1231 pub fn strcmp(l: *const c_char, r: *const c_char) -> c_int;
1232
strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char1233 pub fn strcpy(dest: *mut c_char, src: *const c_char) -> *mut c_char;
1234
strncmp(_l: *const c_char, r: *const c_char, n: size_t) -> c_int1235 pub fn strncmp(_l: *const c_char, r: *const c_char, n: size_t) -> c_int;
1236
strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char1237 pub fn strncpy(dest: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
1238
strnlen(cs: *const c_char, n: size_t) -> size_t1239 pub fn strnlen(cs: *const c_char, n: size_t) -> size_t;
1240
strrchr(s: *const c_char, c: c_int) -> *mut c_char1241 pub fn strrchr(s: *const c_char, c: c_int) -> *mut c_char;
1242
strstr(h: *const c_char, n: *const c_char) -> *mut c_char1243 pub fn strstr(h: *const c_char, n: *const c_char) -> *mut c_char;
1244
wcschr(s: *const wchar_t, c: wchar_t) -> *mut wchar_t1245 pub fn wcschr(s: *const wchar_t, c: wchar_t) -> *mut wchar_t;
1246
wcslen(s: *const wchar_t) -> size_t1247 pub fn wcslen(s: *const wchar_t) -> size_t;
1248
1249 // ctype
isalpha(c: c_int) -> c_int1250 pub fn isalpha(c: c_int) -> c_int;
1251
isascii(c: c_int) -> c_int1252 pub fn isascii(c: c_int) -> c_int;
1253
isdigit(c: c_int) -> c_int1254 pub fn isdigit(c: c_int) -> c_int;
1255
islower(c: c_int) -> c_int1256 pub fn islower(c: c_int) -> c_int;
1257
isprint(c: c_int) -> c_int1258 pub fn isprint(c: c_int) -> c_int;
1259
isspace(c: c_int) -> c_int1260 pub fn isspace(c: c_int) -> c_int;
1261
iswctype(wc: wint_t, ttype: wctype_t) -> c_int1262 pub fn iswctype(wc: wint_t, ttype: wctype_t) -> c_int;
1263
iswdigit(wc: wint_t) -> c_int1264 pub fn iswdigit(wc: wint_t) -> c_int;
1265
iswlower(wc: wint_t) -> c_int1266 pub fn iswlower(wc: wint_t) -> c_int;
1267
iswspace(wc: wint_t) -> c_int1268 pub fn iswspace(wc: wint_t) -> c_int;
1269
iswupper(wc: wint_t) -> c_int1270 pub fn iswupper(wc: wint_t) -> c_int;
1271
towupper(wc: wint_t) -> wint_t1272 pub fn towupper(wc: wint_t) -> wint_t;
1273
towlower(wc: wint_t) -> wint_t1274 pub fn towlower(wc: wint_t) -> wint_t;
1275
1276 // cmath
atan(x: c_double) -> c_double1277 pub fn atan(x: c_double) -> c_double;
1278
ceil(x: c_double) -> c_double1279 pub fn ceil(x: c_double) -> c_double;
1280
ceilf(x: c_float) -> c_float1281 pub fn ceilf(x: c_float) -> c_float;
1282
exp(x: c_double) -> c_double1283 pub fn exp(x: c_double) -> c_double;
1284
fabs(x: c_double) -> c_double1285 pub fn fabs(x: c_double) -> c_double;
1286
floor(x: c_double) -> c_double1287 pub fn floor(x: c_double) -> c_double;
1288
frexp(x: c_double, e: *mut c_int) -> c_double1289 pub fn frexp(x: c_double, e: *mut c_int) -> c_double;
1290
log(x: c_double) -> c_double1291 pub fn log(x: c_double) -> c_double;
1292
log2(x: c_double) -> c_double1293 pub fn log2(x: c_double) -> c_double;
1294
pow(x: c_double, y: c_double) -> c_double1295 pub fn pow(x: c_double, y: c_double) -> c_double;
1296
roundf(x: c_float) -> c_float1297 pub fn roundf(x: c_float) -> c_float;
1298
scalbn(x: c_double, n: c_int) -> c_double1299 pub fn scalbn(x: c_double, n: c_int) -> c_double;
1300
sqrt(x: c_double) -> c_double1301 pub fn sqrt(x: c_double) -> c_double;
1302
1303 // stdlib
abs(x: c_int) -> c_int1304 pub fn abs(x: c_int) -> c_int;
1305
atof(s: *const c_char) -> c_double1306 pub fn atof(s: *const c_char) -> c_double;
1307
atoi(s: *const c_char) -> c_int1308 pub fn atoi(s: *const c_char) -> c_int;
1309
atol(s: *const c_char) -> c_long1310 pub fn atol(s: *const c_char) -> c_long;
1311
atoll(s: *const c_char) -> c_longlong1312 pub fn atoll(s: *const c_char) -> c_longlong;
1313
bsearch( key: *const c_void, base: *const c_void, nel: size_t, width: size_t, cmp: cmpfunc, ) -> *mut c_void1314 pub fn bsearch(
1315 key: *const c_void,
1316 base: *const c_void,
1317 nel: size_t,
1318 width: size_t,
1319 cmp: cmpfunc,
1320 ) -> *mut c_void;
1321
div(num: c_int, den: c_int) -> div_t1322 pub fn div(num: c_int, den: c_int) -> div_t;
1323
ecvt(x: c_double, n: c_int, dp: *mut c_int, sign: *mut c_int) -> *mut c_char1324 pub fn ecvt(x: c_double, n: c_int, dp: *mut c_int, sign: *mut c_int) -> *mut c_char;
1325
imaxabs(a: intmax_t) -> intmax_t1326 pub fn imaxabs(a: intmax_t) -> intmax_t;
1327
llabs(a: c_longlong) -> c_longlong1328 pub fn llabs(a: c_longlong) -> c_longlong;
1329
qsort(base: *mut c_void, nel: size_t, width: size_t, cmp: cmpfunc)1330 pub fn qsort(base: *mut c_void, nel: size_t, width: size_t, cmp: cmpfunc);
1331
strtoul(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_ulong1332 pub fn strtoul(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_ulong;
1333
strtol(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_long1334 pub fn strtol(s: *const c_char, p: *mut *mut c_char, base: c_int) -> c_long;
1335
wcstod(s: *const wchar_t, p: *mut *mut wchar_t) -> c_double1336 pub fn wcstod(s: *const wchar_t, p: *mut *mut wchar_t) -> c_double;
1337 }
1338
errno() -> c_int1339 pub fn errno() -> c_int {
1340 unsafe { *__errno_location() }
1341 }
1342
CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int1343 pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> c_int {
1344 let mut s: u32 = 0;
1345 let size_of_mask = core::mem::size_of_val(&cpuset.bits[0]);
1346
1347 for i in cpuset.bits[..(size / size_of_mask)].iter() {
1348 s += i.count_ones();
1349 }
1350 s as c_int
1351 }
1352
CPU_COUNT(cpuset: &cpu_set_t) -> c_int1353 pub fn CPU_COUNT(cpuset: &cpu_set_t) -> c_int {
1354 CPU_COUNT_S(core::mem::size_of::<cpu_set_t>(), cpuset)
1355 }
1356