-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathy.c
2089 lines (1442 loc) · 41.8 KB
/
y.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
typedef __builtin_va_list __gnuc_va_list;
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef short __int16_t;
typedef unsigned short __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
typedef long __darwin_intptr_t;
typedef unsigned int __darwin_natural_t;
typedef int __darwin_ct_rune_t;
typedef union {
char __mbstate8[128];
long long _mbstateL;
} __mbstate_t;
typedef __mbstate_t __darwin_mbstate_t;
typedef long int __darwin_ptrdiff_t;
typedef long unsigned int __darwin_size_t;
typedef __builtin_va_list __darwin_va_list;
typedef int __darwin_wchar_t;
typedef __darwin_wchar_t __darwin_rune_t;
typedef int __darwin_wint_t;
typedef unsigned long __darwin_clock_t;
typedef __uint32_t __darwin_socklen_t;
typedef long __darwin_ssize_t;
typedef long __darwin_time_t;
typedef __int64_t __darwin_blkcnt_t;
typedef __int32_t __darwin_blksize_t;
typedef __int32_t __darwin_dev_t;
typedef unsigned int __darwin_fsblkcnt_t;
typedef unsigned int __darwin_fsfilcnt_t;
typedef __uint32_t __darwin_gid_t;
typedef __uint32_t __darwin_id_t;
typedef __uint64_t __darwin_ino64_t;
typedef __darwin_ino64_t __darwin_ino_t;
typedef __darwin_natural_t __darwin_mach_port_name_t;
typedef __darwin_mach_port_name_t __darwin_mach_port_t;
typedef __uint16_t __darwin_mode_t;
typedef __int64_t __darwin_off_t;
typedef __int32_t __darwin_pid_t;
typedef __uint32_t __darwin_sigset_t;
typedef __int32_t __darwin_suseconds_t;
typedef __uint32_t __darwin_uid_t;
typedef __uint32_t __darwin_useconds_t;
typedef unsigned char __darwin_uuid_t[16];
typedef char __darwin_uuid_string_t[37];
struct __darwin_pthread_handler_rec {
void (*__routine) (void *);
void *__arg;
struct __darwin_pthread_handler_rec *__next;
};
struct _opaque_pthread_attr_t {
long __sig;
char __opaque [56];
};
struct _opaque_pthread_cond_t {
long __sig;
char __opaque [40];
};
struct _opaque_pthread_condattr_t {
long __sig;
char __opaque [8];
};
struct _opaque_pthread_mutex_t {
long __sig;
char __opaque [56];
};
struct _opaque_pthread_mutexattr_t {
long __sig;
char __opaque [8];
};
struct _opaque_pthread_once_t {
long __sig;
char __opaque [8];
};
struct _opaque_pthread_rwlock_t {
long __sig;
char __opaque [192];
};
struct _opaque_pthread_rwlockattr_t {
long __sig;
char __opaque [16];
};
struct _opaque_pthread_t {
long __sig;
struct __darwin_pthread_handler_rec *__cleanup_stack;
char __opaque [8176];
};
typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t;
typedef struct _opaque_pthread_cond_t __darwin_pthread_cond_t;
typedef struct _opaque_pthread_condattr_t __darwin_pthread_condattr_t;
typedef unsigned long __darwin_pthread_key_t;
typedef struct _opaque_pthread_mutex_t __darwin_pthread_mutex_t;
typedef struct _opaque_pthread_mutexattr_t __darwin_pthread_mutexattr_t;
typedef struct _opaque_pthread_once_t __darwin_pthread_once_t;
typedef struct _opaque_pthread_rwlock_t __darwin_pthread_rwlock_t;
typedef struct _opaque_pthread_rwlockattr_t __darwin_pthread_rwlockattr_t;
typedef struct _opaque_pthread_t *__darwin_pthread_t;
typedef int __darwin_nl_item;
typedef int __darwin_wctrans_t;
typedef __uint32_t __darwin_wctype_t;
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
typedef unsigned long long u_int64_t;
typedef int64_t register_t;
typedef __darwin_intptr_t intptr_t;
typedef unsigned long uintptr_t;
typedef u_int64_t user_addr_t;
typedef u_int64_t user_size_t;
typedef int64_t user_ssize_t;
typedef int64_t user_long_t;
typedef u_int64_t user_ulong_t;
typedef int64_t user_time_t;
typedef int64_t user_off_t;
typedef u_int64_t syscall_arg_t;
typedef __darwin_va_list va_list;
typedef __darwin_size_t size_t;
int
renameat(int, const char *, int, const char *);
int
renamex_np(const char *, const char *, unsigned int);
int
renameatx_np(int, const char *, int, const char *, unsigned int);
typedef __darwin_off_t fpos_t;
struct __sbuf {
unsigned char *_base;
int _size;
};
struct __sFILEX;
typedef struct __sFILE {
unsigned char *_p;
int _r;
int _w;
short _flags;
short _file;
struct __sbuf _bf;
int _lbfsize;
void *_cookie;
int (*_close) (void *);
int (*_read) (void *, char *, int);
fpos_t (*_seek) (void *, fpos_t, int);
int (*_write) (void *, const char *, int);
struct __sbuf _ub;
struct __sFILEX *_extra;
int _ur;
unsigned char _ubuf[3];
unsigned char _nbuf[1];
struct __sbuf _lb;
int _blksize;
fpos_t _offset;
} FILE;
extern FILE *__stdinp;
extern FILE *__stdoutp;
extern FILE *__stderrp;
void clearerr (FILE *);
int fclose (FILE *);
int feof (FILE *);
int ferror (FILE *);
int fflush (FILE *);
int fgetc (FILE *);
int fgetpos (FILE * restrict, fpos_t *);
char *fgets(char *restrict, int, FILE *);
FILE *fopen(const char *restrict __filename, const char *restrict __mode)__asm("_" "fopen");
int fprintf (FILE * restrict, const char *restrict,...)__attribute__((__format__(__printf__, 2, 3)));
int fputc (int, FILE *);
int fputs (const char *restrict, FILE * restrict)__asm("_" "fputs");
size_t fread (void *restrict __ptr, size_t __size, size_t __nitems, FILE * restrict __stream);
FILE *
freopen(const char *restrict, const char *restrict,
FILE * restrict)__asm("_" "freopen");
int fscanf (FILE * restrict, const char *restrict,...)__attribute__((__format__(__scanf__, 2, 3)));
int fseek (FILE *, long, int);
int fsetpos (FILE *, const fpos_t *);
long ftell (FILE *);
size_t fwrite (const void *restrict __ptr, size_t __size, size_t __nitems, FILE * restrict __stream)__asm("_" "fwrite");
int getc (FILE *);
int getchar (void);
char *gets(char *);
void perror (const char *)__attribute__((__cold__));
int printf (const char *restrict,...)__attribute__((__format__(__printf__, 1, 2)));
int putc (int, FILE *);
int putchar (int);
int puts (const char *);
int remove (const char *);
int rename (const char *__old, const char *__new);
void rewind (FILE *);
int scanf (const char *restrict,...)__attribute__((__format__(__scanf__, 1, 2)));
void setbuf (FILE * restrict, char *restrict);
int setvbuf (FILE * restrict, char *restrict, int, size_t);
int sprintf (char *restrict, const char *restrict,...)__attribute__((__format__(__printf__, 2, 3)));
int sscanf (const char *restrict, const char *restrict,...)__attribute__((__format__(__scanf__, 2, 3)));
FILE *tmpfile(void);
__attribute__((__deprecated__("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.")))
char *tmpnam(char *);
int ungetc (int, FILE *);
int vfprintf (FILE * restrict, const char *restrict, __gnuc_va_list)__attribute__((__format__(__printf__, 2, 0)));
int vprintf (const char *restrict, __gnuc_va_list)__attribute__((__format__(__printf__, 1, 0)));
int vsprintf (char *restrict, const char *restrict, __gnuc_va_list)__attribute__((__format__(__printf__, 2, 0)));
char *ctermid(char *);
FILE *fdopen(int, const char *)__asm("_" "fdopen");
int fileno (FILE *);
int pclose (FILE *);
FILE *popen(const char *, const char *)__asm("_" "popen");
int __srget (FILE *);
int __svfscanf (FILE *, const char *, __gnuc_va_list)__attribute__((__format__(__scanf__, 2, 0)));
int __swbuf (int, FILE *);
extern __inline __attribute__((__gnu_inline__)) __attribute__((__always_inline__))
int __sputc (int _c, FILE * _p)
{
if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n'))
return (*_p->_p++ = _c);
else
return (__swbuf(_c, _p));
}
void flockfile (FILE *);
int ftrylockfile(FILE *);
void funlockfile(FILE *);
int getc_unlocked(FILE *);
int getchar_unlocked(void);
int putc_unlocked(int, FILE *);
int putchar_unlocked(int);
int getw (FILE *);
int putw (int, FILE *);
__attribute__((__deprecated__("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of tempnam(3), it is highly recommended that you use mkstemp(3) instead.")))
char *tempnam(const char *__dir, const char *__prefix)__asm("_" "tempnam");
typedef __darwin_off_t off_t;
int fseeko (FILE * __stream, off_t __offset, int __whence);
off_t ftello (FILE * __stream);
int snprintf (char *restrict __str, size_t __size, const char *restrict __format,...)__attribute__((__format__(__printf__, 3, 4)));
int vfscanf (FILE * restrict __stream, const char *restrict __format, __gnuc_va_list)__attribute__((__format__(__scanf__, 2, 0)));
int vscanf (const char *restrict __format, __gnuc_va_list)__attribute__((__format__(__scanf__, 1, 0)));
int vsnprintf (char *restrict __str, size_t __size, const char *restrict __format, __gnuc_va_list)__attribute__((__format__(__printf__, 3, 0)));
int vsscanf (const char *restrict __str, const char *restrict __format, __gnuc_va_list)__attribute__((__format__(__scanf__, 2, 0)));
typedef __darwin_ssize_t ssize_t;
int dprintf (int, const char *restrict,...)__attribute__((__format__(__printf__, 2, 3)));
int vdprintf (int, const char *restrict, __gnuc_va_list)__attribute__((__format__(__printf__, 2, 0)));
ssize_t getdelim(char **restrict __linep, size_t * restrict __linecapp, int __delimiter, FILE * restrict __stream);
ssize_t getline(char **restrict __linep, size_t * restrict __linecapp, FILE * restrict __stream);
FILE *fmemopen(void *restrict __buf, size_t __size, const char *restrict __mode);
FILE *open_memstream(char **__bufp, size_t * __sizep);
extern const int sys_nerr;
extern const char *const sys_errlist[];
int asprintf (char **restrict, const char *restrict,...)__attribute__((__format__(__printf__, 2, 3)));
char *ctermid_r(char *);
char *fgetln(FILE *, size_t *);
const char *fmtcheck(const char *, const char *);
int fpurge (FILE *);
void setbuffer (FILE *, char *, int);
int setlinebuf (FILE *);
int vasprintf (char **restrict, const char *restrict, __gnuc_va_list)__attribute__((__format__(__printf__, 2, 0)));
FILE *funopen(const void *,
int (*) (void *, char *, int),
int (*) (void *, const char *, int),
fpos_t (*) (void *, fpos_t, int),
int (*) (void *));
extern int __sprintf_chk(char *restrict, int, size_t,
const char *restrict,...);
extern int __snprintf_chk(char *restrict, size_t, int, size_t,
const char *restrict,...);
extern int __vsprintf_chk(char *restrict, int, size_t,
const char *restrict, va_list);
extern int __vsnprintf_chk(char *restrict, size_t, int, size_t,
const char *restrict, va_list);
typedef enum {
P_ALL,
P_PID,
P_PGID
} idtype_t;
typedef __darwin_pid_t pid_t;
typedef __darwin_id_t id_t;
typedef int sig_atomic_t;
struct __darwin_arm_exception_state {
__uint32_t __exception;
__uint32_t __fsr;
__uint32_t __far;
};
struct __darwin_arm_exception_state64 {
__uint64_t __far;
__uint32_t __esr;
__uint32_t __exception;
};
struct __darwin_arm_thread_state {
__uint32_t __r [13];
__uint32_t __sp;
__uint32_t __lr;
__uint32_t __pc;
__uint32_t __cpsr;
};
struct __darwin_arm_thread_state64 {
__uint64_t __x [29];
__uint64_t __fp;
__uint64_t __lr;
__uint64_t __sp;
__uint64_t __pc;
__uint32_t __cpsr;
__uint32_t __pad;
};
struct __darwin_arm_vfp_state {
__uint32_t __r [64];
__uint32_t __fpscr;
};
struct __darwin_arm_neon_state64 {
__uint128_t __v [32];
__uint32_t __fpsr;
__uint32_t __fpcr;
};
struct __darwin_arm_neon_state {
__uint128_t __v [16];
__uint32_t __fpsr;
__uint32_t __fpcr;
};
struct __arm_pagein_state {
int __pagein_error;
};
struct __arm_legacy_debug_state {
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
};
struct __darwin_arm_debug_state32 {
__uint32_t __bvr[16];
__uint32_t __bcr[16];
__uint32_t __wvr[16];
__uint32_t __wcr[16];
__uint64_t __mdscr_el1;
};
struct __darwin_arm_debug_state64 {
__uint64_t __bvr[16];
__uint64_t __bcr[16];
__uint64_t __wvr[16];
__uint64_t __wcr[16];
__uint64_t __mdscr_el1;
};
struct __darwin_arm_cpmu_state64 {
__uint64_t __ctrs[16];
};
struct __darwin_mcontext32 {
struct __darwin_arm_exception_state __es;
struct __darwin_arm_thread_state __ss;
struct __darwin_arm_vfp_state __fs;
};
struct __darwin_mcontext64 {
struct __darwin_arm_exception_state64 __es;
struct __darwin_arm_thread_state64 __ss;
struct __darwin_arm_neon_state64 __ns;
};
typedef struct __darwin_mcontext64 *mcontext_t;
typedef __darwin_pthread_attr_t pthread_attr_t;
struct __darwin_sigaltstack {
void *ss_sp;
__darwin_size_t ss_size;
int ss_flags;
};
typedef struct __darwin_sigaltstack stack_t;
struct __darwin_ucontext {
int uc_onstack;
__darwin_sigset_t uc_sigmask;
struct __darwin_sigaltstack uc_stack;
struct __darwin_ucontext *uc_link;
__darwin_size_t uc_mcsize;
struct __darwin_mcontext64 *uc_mcontext;
};
typedef struct __darwin_ucontext ucontext_t;
typedef __darwin_sigset_t sigset_t;
typedef __darwin_uid_t uid_t;
union sigval {
int sival_int;
void *sival_ptr;
};
struct sigevent {
int sigev_notify;
int sigev_signo;
union sigval sigev_value;
void (*sigev_notify_function) (union sigval);
pthread_attr_t *sigev_notify_attributes;
};
typedef struct __siginfo {
int si_signo;
int si_errno;
int si_code;
pid_t si_pid;
uid_t si_uid;
int si_status;
void *si_addr;
union sigval si_value;
long si_band;
unsigned long __pad[7];
} siginfo_t;
union __sigaction_u {
void (*__sa_handler) (int);
void (*__sa_sigaction) (int, struct __siginfo *,
void *);
};
struct __sigaction {
union __sigaction_u __sigaction_u;
void (*sa_tramp) (void *, int, int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
};
struct sigaction {
union __sigaction_u __sigaction_u;
sigset_t sa_mask;
int sa_flags;
};
typedef void (*sig_t) (int);
struct sigvec {
void (*sv_handler) (int);
int sv_mask;
int sv_flags;
};
struct sigstack {
char *ss_sp;
int ss_onstack;
};
void (*signal(int, void (*) (int))) (int);
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;
typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;
typedef int8_t int_fast8_t;
typedef int16_t int_fast16_t;
typedef int32_t int_fast32_t;
typedef int64_t int_fast64_t;
typedef uint8_t uint_fast8_t;
typedef uint16_t uint_fast16_t;
typedef uint32_t uint_fast32_t;
typedef uint64_t uint_fast64_t;
typedef long int intmax_t;
typedef long unsigned int uintmax_t;
struct timeval {
__darwin_time_t tv_sec;
__darwin_suseconds_t tv_usec;
};
typedef __uint64_t rlim_t;
struct rusage {
struct timeval ru_utime;
struct timeval ru_stime;
long ru_maxrss;
long ru_ixrss;
long ru_idrss;
long ru_isrss;
long ru_minflt;
long ru_majflt;
long ru_nswap;
long ru_inblock;
long ru_oublock;
long ru_msgsnd;
long ru_msgrcv;
long ru_nsignals;
long ru_nvcsw;
long ru_nivcsw;
};
typedef void *rusage_info_t;
struct rusage_info_v0 {
uint8_t ri_uuid[16];
uint64_t ri_user_time;
uint64_t ri_system_time;
uint64_t ri_pkg_idle_wkups;
uint64_t ri_interrupt_wkups;
uint64_t ri_pageins;
uint64_t ri_wired_size;
uint64_t ri_resident_size;
uint64_t ri_phys_footprint;
uint64_t ri_proc_start_abstime;
uint64_t ri_proc_exit_abstime;
};
struct rusage_info_v1 {
uint8_t ri_uuid[16];
uint64_t ri_user_time;
uint64_t ri_system_time;
uint64_t ri_pkg_idle_wkups;
uint64_t ri_interrupt_wkups;
uint64_t ri_pageins;
uint64_t ri_wired_size;
uint64_t ri_resident_size;
uint64_t ri_phys_footprint;
uint64_t ri_proc_start_abstime;
uint64_t ri_proc_exit_abstime;
uint64_t ri_child_user_time;
uint64_t ri_child_system_time;
uint64_t ri_child_pkg_idle_wkups;
uint64_t ri_child_interrupt_wkups;
uint64_t ri_child_pageins;
uint64_t ri_child_elapsed_abstime;
};
struct rusage_info_v2 {
uint8_t ri_uuid[16];
uint64_t ri_user_time;
uint64_t ri_system_time;
uint64_t ri_pkg_idle_wkups;
uint64_t ri_interrupt_wkups;
uint64_t ri_pageins;
uint64_t ri_wired_size;
uint64_t ri_resident_size;
uint64_t ri_phys_footprint;
uint64_t ri_proc_start_abstime;
uint64_t ri_proc_exit_abstime;
uint64_t ri_child_user_time;
uint64_t ri_child_system_time;
uint64_t ri_child_pkg_idle_wkups;
uint64_t ri_child_interrupt_wkups;
uint64_t ri_child_pageins;
uint64_t ri_child_elapsed_abstime;
uint64_t ri_diskio_bytesread;
uint64_t ri_diskio_byteswritten;
};
struct rusage_info_v3 {
uint8_t ri_uuid[16];
uint64_t ri_user_time;
uint64_t ri_system_time;
uint64_t ri_pkg_idle_wkups;
uint64_t ri_interrupt_wkups;
uint64_t ri_pageins;
uint64_t ri_wired_size;
uint64_t ri_resident_size;
uint64_t ri_phys_footprint;
uint64_t ri_proc_start_abstime;
uint64_t ri_proc_exit_abstime;
uint64_t ri_child_user_time;
uint64_t ri_child_system_time;
uint64_t ri_child_pkg_idle_wkups;
uint64_t ri_child_interrupt_wkups;
uint64_t ri_child_pageins;
uint64_t ri_child_elapsed_abstime;
uint64_t ri_diskio_bytesread;
uint64_t ri_diskio_byteswritten;
uint64_t ri_cpu_time_qos_default;
uint64_t ri_cpu_time_qos_maintenance;
uint64_t ri_cpu_time_qos_background;
uint64_t ri_cpu_time_qos_utility;
uint64_t ri_cpu_time_qos_legacy;
uint64_t ri_cpu_time_qos_user_initiated;
uint64_t ri_cpu_time_qos_user_interactive;
uint64_t ri_billed_system_time;
uint64_t ri_serviced_system_time;
};
struct rusage_info_v4 {
uint8_t ri_uuid[16];
uint64_t ri_user_time;
uint64_t ri_system_time;
uint64_t ri_pkg_idle_wkups;
uint64_t ri_interrupt_wkups;
uint64_t ri_pageins;
uint64_t ri_wired_size;
uint64_t ri_resident_size;
uint64_t ri_phys_footprint;
uint64_t ri_proc_start_abstime;
uint64_t ri_proc_exit_abstime;
uint64_t ri_child_user_time;
uint64_t ri_child_system_time;
uint64_t ri_child_pkg_idle_wkups;
uint64_t ri_child_interrupt_wkups;
uint64_t ri_child_pageins;
uint64_t ri_child_elapsed_abstime;
uint64_t ri_diskio_bytesread;
uint64_t ri_diskio_byteswritten;
uint64_t ri_cpu_time_qos_default;
uint64_t ri_cpu_time_qos_maintenance;
uint64_t ri_cpu_time_qos_background;
uint64_t ri_cpu_time_qos_utility;
uint64_t ri_cpu_time_qos_legacy;
uint64_t ri_cpu_time_qos_user_initiated;
uint64_t ri_cpu_time_qos_user_interactive;
uint64_t ri_billed_system_time;
uint64_t ri_serviced_system_time;
uint64_t ri_logical_writes;
uint64_t ri_lifetime_max_phys_footprint;
uint64_t ri_instructions;
uint64_t ri_cycles;
uint64_t ri_billed_energy;
uint64_t ri_serviced_energy;
uint64_t ri_interval_max_phys_footprint;
uint64_t ri_runnable_time;
};
struct rusage_info_v5 {
uint8_t ri_uuid[16];
uint64_t ri_user_time;
uint64_t ri_system_time;
uint64_t ri_pkg_idle_wkups;
uint64_t ri_interrupt_wkups;
uint64_t ri_pageins;
uint64_t ri_wired_size;
uint64_t ri_resident_size;
uint64_t ri_phys_footprint;
uint64_t ri_proc_start_abstime;
uint64_t ri_proc_exit_abstime;
uint64_t ri_child_user_time;
uint64_t ri_child_system_time;
uint64_t ri_child_pkg_idle_wkups;
uint64_t ri_child_interrupt_wkups;
uint64_t ri_child_pageins;
uint64_t ri_child_elapsed_abstime;
uint64_t ri_diskio_bytesread;
uint64_t ri_diskio_byteswritten;
uint64_t ri_cpu_time_qos_default;
uint64_t ri_cpu_time_qos_maintenance;
uint64_t ri_cpu_time_qos_background;
uint64_t ri_cpu_time_qos_utility;
uint64_t ri_cpu_time_qos_legacy;
uint64_t ri_cpu_time_qos_user_initiated;
uint64_t ri_cpu_time_qos_user_interactive;
uint64_t ri_billed_system_time;
uint64_t ri_serviced_system_time;
uint64_t ri_logical_writes;
uint64_t ri_lifetime_max_phys_footprint;
uint64_t ri_instructions;
uint64_t ri_cycles;
uint64_t ri_billed_energy;
uint64_t ri_serviced_energy;
uint64_t ri_interval_max_phys_footprint;
uint64_t ri_runnable_time;
uint64_t ri_flags;
};
typedef struct rusage_info_v5 rusage_info_current;
struct rlimit {
rlim_t rlim_cur;
rlim_t rlim_max;
};
struct proc_rlimit_control_wakeupmon {
uint32_t wm_flags;
int32_t wm_rate;
};
int getpriority(int, id_t);
int getiopolicy_np(int, int);
int getrlimit (int, struct rlimit *)__asm("_" "getrlimit");
int getrusage (int, struct rusage *);
int setpriority(int, id_t, int);
int setiopolicy_np(int, int, int);
int setrlimit (int, const struct rlimit *)__asm("_" "setrlimit");
static inline
uint16_t
_OSSwapInt16 (
uint16_t _data
)
{
return (uint16_t) (_data << 8 | _data >> 8);
}
static inline
uint32_t
_OSSwapInt32(
uint32_t _data
)
{
_data = (((_data ^ (_data >> 16 | (_data << 16))) & 0xFF00FFFF) >> 8) ^ (_data >> 8 | _data << 24);
return _data;
}
static inline
uint64_t
_OSSwapInt64(
uint64_t _data
)
{
union {
uint64_t _ull;
uint32_t _ul [2];
} _u;
_u._ul[0] = (uint32_t) (_data >> 32);
_u._ul[1] = (uint32_t) (_data & 0xffffffff);
_u._ul[0] = _OSSwapInt32(_u._ul[0]);
_u._ul[1] = _OSSwapInt32(_u._ul[1]);
return _u._ull;
}
struct _OSUnalignedU16 {
volatile uint16_t __val;
} __attribute__((__packed__));
struct _OSUnalignedU32 {
volatile uint32_t __val;
} __attribute__((__packed__));
struct _OSUnalignedU64 {
volatile uint64_t __val;
} __attribute__((__packed__));
static inline
uint16_t
OSReadSwapInt16(
const volatile void *_base,
uintptr_t _offset
)
{
return _OSSwapInt16(((struct _OSUnalignedU16 *)((uintptr_t) _base + _offset))->__val);
}
static inline
uint32_t
OSReadSwapInt32(
const volatile void *_base,
uintptr_t _offset
)
{
return _OSSwapInt32(((struct _OSUnalignedU32 *)((uintptr_t) _base + _offset))->__val);
}
static inline
uint64_t
OSReadSwapInt64(
const volatile void *_base,
uintptr_t _offset
)
{
return _OSSwapInt64(((struct _OSUnalignedU64 *)((uintptr_t) _base + _offset))->__val);
}
static inline
void
OSWriteSwapInt16(
volatile void *_base,
uintptr_t _offset,
uint16_t _data
)
{
((struct _OSUnalignedU16 *)((uintptr_t) _base + _offset))->__val = _OSSwapInt16(_data);
}
static inline
void
OSWriteSwapInt32(
volatile void *_base,