Debian Codegraph @

debian/missing-sources/libc/src/teeos/mod.rs

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