/
mod.rs
3285 lines (2960 loc) · 106 KB
/
mod.rs
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
pub type clock_t = u32;
pub type sa_family_t = u8;
pub type speed_t = ::c_uint;
pub type tcflag_t = ::c_uint;
pub type clockid_t = ::c_int;
pub type timer_t = ::c_int;
pub type key_t = ::c_uint;
pub type id_t = ::c_int;
pub type useconds_t = u32;
pub type dev_t = u32;
pub type socklen_t = u32;
pub type mode_t = u32;
pub type rlim64_t = u64;
pub type mqd_t = ::c_int;
pub type nfds_t = ::c_uint;
pub type idtype_t = ::c_uint;
pub type errno_t = ::c_int;
pub type rsize_t = c_ulong;
pub type Elf32_Half = u16;
pub type Elf32_Word = u32;
pub type Elf32_Off = u32;
pub type Elf32_Addr = u32;
pub type Elf32_Lword = u64;
pub type Elf32_Sword = i32;
pub type Elf64_Half = u16;
pub type Elf64_Word = u32;
pub type Elf64_Off = u64;
pub type Elf64_Addr = u64;
pub type Elf64_Xword = u64;
pub type Elf64_Sxword = i64;
pub type Elf64_Lword = u64;
pub type Elf64_Sword = i32;
pub type Elf32_Section = u16;
pub type Elf64_Section = u16;
pub type _Time32t = u32;
pub type pthread_t = ::c_int;
pub type regoff_t = ::ssize_t;
pub type nlink_t = u32;
pub type blksize_t = u32;
pub type suseconds_t = i32;
pub type ino_t = u64;
pub type off_t = i64;
pub type blkcnt_t = u64;
pub type msgqnum_t = u64;
pub type msglen_t = u64;
pub type fsblkcnt_t = u64;
pub type fsfilcnt_t = u64;
pub type rlim_t = u64;
pub type posix_spawn_file_actions_t = *mut ::c_void;
pub type posix_spawnattr_t = ::uintptr_t;
pub type pthread_mutex_t = ::sync_t;
pub type pthread_mutexattr_t = ::_sync_attr;
pub type pthread_cond_t = ::sync_t;
pub type pthread_condattr_t = ::_sync_attr;
pub type pthread_rwlockattr_t = ::_sync_attr;
pub type pthread_key_t = ::c_int;
pub type pthread_spinlock_t = sync_t;
pub type pthread_barrierattr_t = _sync_attr;
pub type sem_t = sync_t;
pub type nl_item = ::c_int;
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
impl ::Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}
s! {
pub struct ip_mreq {
pub imr_multiaddr: in_addr,
pub imr_interface: in_addr,
}
#[repr(packed)]
pub struct in_addr {
pub s_addr: ::in_addr_t,
}
pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
pub sa_data: [::c_char; 14],
}
pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [i8; 8],
}
pub struct sockaddr_in6 {
pub sin6_len: u8,
pub sin6_family: sa_family_t,
pub sin6_port: ::in_port_t,
pub sin6_flowinfo: u32,
pub sin6_addr: ::in6_addr,
pub sin6_scope_id: u32,
}
// The order of the `ai_addr` field in this struct is crucial
// for converting between the Rust and C types.
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
pub ai_socktype: ::c_int,
pub ai_protocol: ::c_int,
pub ai_addrlen: socklen_t,
pub ai_canonname: *mut c_char,
pub ai_addr: *mut ::sockaddr,
pub ai_next: *mut addrinfo,
}
pub struct fd_set {
fds_bits: [::c_uint; 2 * FD_SETSIZE / ULONG_SIZE],
}
pub struct tm {
pub tm_sec: ::c_int,
pub tm_min: ::c_int,
pub tm_hour: ::c_int,
pub tm_mday: ::c_int,
pub tm_mon: ::c_int,
pub tm_year: ::c_int,
pub tm_wday: ::c_int,
pub tm_yday: ::c_int,
pub tm_isdst: ::c_int,
pub tm_gmtoff: ::c_long,
pub tm_zone: *const ::c_char,
}
#[repr(align(8))]
pub struct sched_param {
pub sched_priority: ::c_int,
pub sched_curpriority: ::c_int,
pub reserved: [::c_int; 10],
}
#[repr(align(8))]
pub struct __sched_param {
pub __sched_priority: ::c_int,
pub __sched_curpriority: ::c_int,
pub reserved: [::c_int; 10],
}
pub struct Dl_info {
pub dli_fname: *const ::c_char,
pub dli_fbase: *mut ::c_void,
pub dli_sname: *const ::c_char,
pub dli_saddr: *mut ::c_void,
}
pub struct lconv {
pub currency_symbol: *mut ::c_char,
pub int_curr_symbol: *mut ::c_char,
pub mon_decimal_point: *mut ::c_char,
pub mon_grouping: *mut ::c_char,
pub mon_thousands_sep: *mut ::c_char,
pub negative_sign: *mut ::c_char,
pub positive_sign: *mut ::c_char,
pub frac_digits: ::c_char,
pub int_frac_digits: ::c_char,
pub n_cs_precedes: ::c_char,
pub n_sep_by_space: ::c_char,
pub n_sign_posn: ::c_char,
pub p_cs_precedes: ::c_char,
pub p_sep_by_space: ::c_char,
pub p_sign_posn: ::c_char,
pub int_n_cs_precedes: ::c_char,
pub int_n_sep_by_space: ::c_char,
pub int_n_sign_posn: ::c_char,
pub int_p_cs_precedes: ::c_char,
pub int_p_sep_by_space: ::c_char,
pub int_p_sign_posn: ::c_char,
pub decimal_point: *mut ::c_char,
pub grouping: *mut ::c_char,
pub thousands_sep: *mut ::c_char,
pub _Frac_grouping: *mut ::c_char,
pub _Frac_sep: *mut ::c_char,
pub _False: *mut ::c_char,
pub _True: *mut ::c_char,
pub _No: *mut ::c_char,
pub _Yes: *mut ::c_char,
pub _Nostr: *mut ::c_char,
pub _Yesstr: *mut ::c_char,
pub _Reserved: [*mut ::c_char; 8],
}
pub struct in_pktinfo {
pub ipi_addr: ::in_addr,
pub ipi_ifindex: ::c_uint,
}
pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: ::c_uint,
pub ifa_addr: *mut ::sockaddr,
pub ifa_netmask: *mut ::sockaddr,
pub ifa_dstaddr: *mut ::sockaddr,
pub ifa_data: *mut ::c_void
}
pub struct arpreq {
pub arp_pa: ::sockaddr,
pub arp_ha: ::sockaddr,
pub arp_flags: ::c_int,
}
#[repr(packed)]
pub struct arphdr {
pub ar_hrd: u16,
pub ar_pro: u16,
pub ar_hln: u8,
pub ar_pln: u8,
pub ar_op: u16,
}
pub struct mmsghdr {
pub msg_hdr: ::msghdr,
pub msg_len: ::c_uint,
}
#[repr(align(8))]
pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_code: ::c_int,
pub si_errno: ::c_int,
__data: [u8; 36], // union
}
pub struct sigaction {
pub sa_sigaction: ::sighandler_t,
pub sa_flags: ::c_int,
pub sa_mask: ::sigset_t,
}
pub struct _sync {
_union: ::c_uint,
__owner: ::c_uint,
}
pub struct rlimit64 {
pub rlim_cur: rlim64_t,
pub rlim_max: rlim64_t,
}
pub struct glob_t {
pub gl_pathc: ::size_t,
pub gl_matchc: ::c_int,
pub gl_pathv: *mut *mut c_char,
pub gl_offs: ::size_t,
pub gl_flags: ::c_int,
pub gl_errfunc: extern "C" fn(*const ::c_char, ::c_int) -> ::c_int,
__unused1: *mut ::c_void,
__unused2: *mut ::c_void,
__unused3: *mut ::c_void,
__unused4: *mut ::c_void,
__unused5: *mut ::c_void,
}
pub struct passwd {
pub pw_name: *mut ::c_char,
pub pw_passwd: *mut ::c_char,
pub pw_uid: ::uid_t,
pub pw_gid: ::gid_t,
pub pw_age: *mut ::c_char,
pub pw_comment: *mut ::c_char,
pub pw_gecos: *mut ::c_char,
pub pw_dir: *mut ::c_char,
pub pw_shell: *mut ::c_char,
}
pub struct if_nameindex {
pub if_index: ::c_uint,
pub if_name: *mut ::c_char,
}
pub struct sembuf {
pub sem_num: ::c_ushort,
pub sem_op: ::c_short,
pub sem_flg: ::c_short,
}
pub struct Elf32_Ehdr {
pub e_ident: [::c_uchar; 16],
pub e_type: Elf32_Half,
pub e_machine: Elf32_Half,
pub e_version: Elf32_Word,
pub e_entry: Elf32_Addr,
pub e_phoff: Elf32_Off,
pub e_shoff: Elf32_Off,
pub e_flags: Elf32_Word,
pub e_ehsize: Elf32_Half,
pub e_phentsize: Elf32_Half,
pub e_phnum: Elf32_Half,
pub e_shentsize: Elf32_Half,
pub e_shnum: Elf32_Half,
pub e_shstrndx: Elf32_Half,
}
pub struct Elf64_Ehdr {
pub e_ident: [::c_uchar; 16],
pub e_type: Elf64_Half,
pub e_machine: Elf64_Half,
pub e_version: Elf64_Word,
pub e_entry: Elf64_Addr,
pub e_phoff: Elf64_Off,
pub e_shoff: Elf64_Off,
pub e_flags: Elf64_Word,
pub e_ehsize: Elf64_Half,
pub e_phentsize: Elf64_Half,
pub e_phnum: Elf64_Half,
pub e_shentsize: Elf64_Half,
pub e_shnum: Elf64_Half,
pub e_shstrndx: Elf64_Half,
}
pub struct Elf32_Sym {
pub st_name: Elf32_Word,
pub st_value: Elf32_Addr,
pub st_size: Elf32_Word,
pub st_info: ::c_uchar,
pub st_other: ::c_uchar,
pub st_shndx: Elf32_Section,
}
pub struct Elf64_Sym {
pub st_name: Elf64_Word,
pub st_info: ::c_uchar,
pub st_other: ::c_uchar,
pub st_shndx: Elf64_Section,
pub st_value: Elf64_Addr,
pub st_size: Elf64_Xword,
}
pub struct Elf32_Phdr {
pub p_type: Elf32_Word,
pub p_offset: Elf32_Off,
pub p_vaddr: Elf32_Addr,
pub p_paddr: Elf32_Addr,
pub p_filesz: Elf32_Word,
pub p_memsz: Elf32_Word,
pub p_flags: Elf32_Word,
pub p_align: Elf32_Word,
}
pub struct Elf64_Phdr {
pub p_type: Elf64_Word,
pub p_flags: Elf64_Word,
pub p_offset: Elf64_Off,
pub p_vaddr: Elf64_Addr,
pub p_paddr: Elf64_Addr,
pub p_filesz: Elf64_Xword,
pub p_memsz: Elf64_Xword,
pub p_align: Elf64_Xword,
}
pub struct Elf32_Shdr {
pub sh_name: Elf32_Word,
pub sh_type: Elf32_Word,
pub sh_flags: Elf32_Word,
pub sh_addr: Elf32_Addr,
pub sh_offset: Elf32_Off,
pub sh_size: Elf32_Word,
pub sh_link: Elf32_Word,
pub sh_info: Elf32_Word,
pub sh_addralign: Elf32_Word,
pub sh_entsize: Elf32_Word,
}
pub struct Elf64_Shdr {
pub sh_name: Elf64_Word,
pub sh_type: Elf64_Word,
pub sh_flags: Elf64_Xword,
pub sh_addr: Elf64_Addr,
pub sh_offset: Elf64_Off,
pub sh_size: Elf64_Xword,
pub sh_link: Elf64_Word,
pub sh_info: Elf64_Word,
pub sh_addralign: Elf64_Xword,
pub sh_entsize: Elf64_Xword,
}
pub struct in6_pktinfo {
pub ipi6_addr: ::in6_addr,
pub ipi6_ifindex: ::c_uint,
}
pub struct inotify_event {
pub wd: ::c_int,
pub mask: u32,
pub cookie: u32,
pub len: u32
}
pub struct regmatch_t {
pub rm_so: regoff_t,
pub rm_eo: regoff_t,
}
pub struct msghdr {
pub msg_name: *mut ::c_void,
pub msg_namelen: ::socklen_t,
pub msg_iov: *mut ::iovec,
pub msg_iovlen: ::c_int,
pub msg_control: *mut ::c_void,
pub msg_controllen: ::socklen_t,
pub msg_flags: ::c_int,
}
pub struct cmsghdr {
pub cmsg_len: ::socklen_t,
pub cmsg_level: ::c_int,
pub cmsg_type: ::c_int,
}
pub struct termios {
pub c_iflag: ::tcflag_t,
pub c_oflag: ::tcflag_t,
pub c_cflag: ::tcflag_t,
pub c_lflag: ::tcflag_t,
pub c_cc: [::cc_t; ::NCCS],
__reserved: [::c_uint; 3],
pub c_ispeed: ::speed_t,
pub c_ospeed: ::speed_t,
}
pub struct mallinfo {
pub arena: ::c_int,
pub ordblks: ::c_int,
pub smblks: ::c_int,
pub hblks: ::c_int,
pub hblkhd: ::c_int,
pub usmblks: ::c_int,
pub fsmblks: ::c_int,
pub uordblks: ::c_int,
pub fordblks: ::c_int,
pub keepcost: ::c_int,
}
pub struct flock {
pub l_type: i16,
pub l_whence: i16,
pub l_zero1: i32,
pub l_start: ::off_t,
pub l_len: ::off_t,
pub l_pid: ::pid_t,
pub l_sysid: u32,
}
pub struct statvfs {
pub f_bsize: ::c_ulong,
pub f_frsize: ::c_ulong,
pub f_blocks: ::fsblkcnt_t,
pub f_bfree: ::fsblkcnt_t,
pub f_bavail: ::fsblkcnt_t,
pub f_files: ::fsfilcnt_t,
pub f_ffree: ::fsfilcnt_t,
pub f_favail: ::fsfilcnt_t,
pub f_fsid: ::c_ulong,
pub f_basetype: [::c_char; 16],
pub f_flag: ::c_ulong,
pub f_namemax: ::c_ulong,
f_filler: [::c_uint; 21],
}
pub struct aiocb {
pub aio_fildes: ::c_int,
pub aio_reqprio: ::c_int,
pub aio_offset: off_t,
pub aio_buf: *mut ::c_void,
pub aio_nbytes: ::size_t,
pub aio_sigevent: ::sigevent,
pub aio_lio_opcode: ::c_int,
pub _aio_lio_state: *mut ::c_void,
_aio_pad: [::c_int; 3],
pub _aio_next: *mut ::aiocb,
pub _aio_flag: ::c_uint,
pub _aio_iotype: ::c_uint,
pub _aio_result: ::ssize_t,
pub _aio_error: ::c_uint,
pub _aio_suspend: *mut ::c_void,
pub _aio_plist: *mut ::c_void,
pub _aio_policy: ::c_int,
pub _aio_param: ::__sched_param,
}
pub struct pthread_attr_t {
__data1: ::c_long,
__data2: [u8; 96]
}
pub struct ipc_perm {
pub uid: ::uid_t,
pub gid: ::gid_t,
pub cuid: ::uid_t,
pub cgid: ::gid_t,
pub mode: ::mode_t,
pub seq: ::c_uint,
pub key: ::key_t,
_reserved: [::c_int; 4],
}
pub struct regex_t {
re_magic: ::c_int,
re_nsub: ::size_t,
re_endp: *const ::c_char,
re_g: *mut ::c_void,
}
pub struct _thread_attr {
pub __flags: ::c_int,
pub __stacksize: ::size_t,
pub __stackaddr: *mut ::c_void,
pub __exitfunc: ::Option<unsafe extern "C" fn(_fake: *mut ::c_void)>,
pub __policy: ::c_int,
pub __param: ::__sched_param,
pub __guardsize: ::c_uint,
pub __prealloc: ::c_uint,
__spare: [::c_int; 2],
}
pub struct _sync_attr {
pub __protocol: ::c_int,
pub __flags: ::c_int,
pub __prioceiling: ::c_int,
pub __clockid: ::c_int,
pub __count: ::c_int,
__reserved: [::c_int; 3],
}
pub struct sockcred {
pub sc_uid: ::uid_t,
pub sc_euid: ::uid_t,
pub sc_gid: ::gid_t,
pub sc_egid: ::gid_t,
pub sc_ngroups: ::c_int,
pub sc_groups: [::gid_t; 1],
}
pub struct bpf_program {
pub bf_len: ::c_uint,
pub bf_insns: *mut ::bpf_insn,
}
pub struct bpf_stat {
pub bs_recv: u64,
pub bs_drop: u64,
pub bs_capt: u64,
bs_padding: [u64; 13],
}
pub struct bpf_version {
pub bv_major: ::c_ushort,
pub bv_minor: ::c_ushort,
}
pub struct bpf_hdr {
pub bh_tstamp: ::timeval,
pub bh_caplen: u32,
pub bh_datalen: u32,
pub bh_hdrlen: u16,
}
pub struct bpf_insn {
pub code: u16,
pub jt: ::c_uchar,
pub jf: ::c_uchar,
pub k: u32,
}
pub struct bpf_dltlist {
pub bfl_len: ::c_uint,
pub bfl_list: *mut ::c_uint,
}
pub struct unpcbid {
pub unp_pid: ::pid_t,
pub unp_euid: ::uid_t,
pub unp_egid: ::gid_t,
}
pub struct dl_phdr_info {
pub dlpi_addr: ::Elf64_Addr,
pub dlpi_name: *const ::c_char,
pub dlpi_phdr: *const ::Elf64_Phdr,
pub dlpi_phnum: ::Elf64_Half,
}
#[repr(align(8))]
pub struct ucontext_t {
pub uc_link: *mut ucontext_t,
pub uc_sigmask: ::sigset_t,
pub uc_stack: stack_t,
pub uc_mcontext: mcontext_t,
}
}
s_no_extra_traits! {
pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
pub sun_path: [::c_char; 104]
}
pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
__ss_pad1: [::c_char; 6],
__ss_align: i64,
__ss_pad2: [::c_char; 112],
}
pub struct utsname {
pub sysname: [::c_char; _SYSNAME_SIZE],
pub nodename: [::c_char; _SYSNAME_SIZE],
pub release: [::c_char; _SYSNAME_SIZE],
pub version: [::c_char; _SYSNAME_SIZE],
pub machine: [::c_char; _SYSNAME_SIZE],
}
pub struct sigevent {
pub sigev_notify: ::c_int,
__sigev_un1: usize, // union
pub sigev_value: ::sigval,
__sigev_un2: usize, // union
}
pub struct dirent {
pub d_ino: ::ino_t,
pub d_offset: ::off_t,
pub d_reclen: ::c_short,
pub d_namelen: ::c_short,
pub d_name: [::c_char; 1], // flex array
}
pub struct dirent_extra {
pub d_datalen: u16,
pub d_type: u16,
pub d_reserved: u32,
}
pub struct stat {
pub st_ino: ::ino_t,
pub st_size: ::off_t,
pub st_dev: ::dev_t,
pub st_rdev: ::dev_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub __old_st_mtime: ::_Time32t,
pub __old_st_atime: ::_Time32t,
pub __old_st_ctime: ::_Time32t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_blocksize: ::blksize_t,
pub st_nblocks: i32,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt_t,
pub st_mtim: ::timespec,
pub st_atim: ::timespec,
pub st_ctim: ::timespec,
}
pub struct sigset_t {
__val: [u32; 2],
}
pub struct mq_attr {
pub mq_maxmsg: ::c_long,
pub mq_msgsize: ::c_long,
pub mq_flags: ::c_long,
pub mq_curmsgs: ::c_long,
pub mq_sendwait: ::c_long,
pub mq_recvwait: ::c_long,
}
pub struct msg {
pub msg_next: *mut ::msg,
pub msg_type: ::c_long,
pub msg_ts: ::c_ushort,
pub msg_spot: ::c_short,
_pad: [u8; 4],
}
pub struct msqid_ds {
pub msg_perm: ::ipc_perm,
pub msg_first: *mut ::msg,
pub msg_last: *mut ::msg,
pub msg_cbytes: ::msglen_t,
pub msg_qnum: ::msgqnum_t,
pub msg_qbytes: ::msglen_t,
pub msg_lspid: ::pid_t,
pub msg_lrpid: ::pid_t,
pub msg_stime: ::time_t,
msg_pad1: ::c_long,
pub msg_rtime: ::time_t,
msg_pad2: ::c_long,
pub msg_ctime: ::time_t,
msg_pad3: ::c_long,
msg_pad4: [::c_long; 4],
}
pub struct sockaddr_dl {
pub sdl_len: ::c_uchar,
pub sdl_family: ::sa_family_t,
pub sdl_index: u16,
pub sdl_type: ::c_uchar,
pub sdl_nlen: ::c_uchar,
pub sdl_alen: ::c_uchar,
pub sdl_slen: ::c_uchar,
pub sdl_data: [::c_char; 12],
}
pub struct sync_t {
__u: ::c_uint, // union
pub __owner: ::c_uint,
}
#[repr(align(4))]
pub struct pthread_barrier_t { // union
__pad: [u8; 28], // union
}
pub struct pthread_rwlock_t {
pub __active: ::c_int,
pub __blockedwriters: ::c_int,
pub __blockedreaders: ::c_int,
pub __heavy: ::c_int,
pub __lock: ::pthread_mutex_t, // union
pub __rcond: ::pthread_cond_t, // union
pub __wcond: ::pthread_cond_t, // union
pub __owner: ::c_uint,
pub __spare: ::c_uint,
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for sockaddr_un {
fn eq(&self, other: &sockaddr_un) -> bool {
self.sun_len == other.sun_len
&& self.sun_family == other.sun_family
&& self
.sun_path
.iter()
.zip(other.sun_path.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for sockaddr_un {}
impl ::fmt::Debug for sockaddr_un {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sockaddr_un")
.field("sun_len", &self.sun_len)
.field("sun_family", &self.sun_family)
// FIXME: .field("sun_path", &self.sun_path)
.finish()
}
}
impl ::hash::Hash for sockaddr_un {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sun_len.hash(state);
self.sun_family.hash(state);
self.sun_path.hash(state);
}
}
impl PartialEq for utsname {
fn eq(&self, other: &utsname) -> bool {
self.sysname
.iter()
.zip(other.sysname.iter())
.all(|(a,b)| a == b)
&& self
.nodename
.iter()
.zip(other.nodename.iter())
.all(|(a,b)| a == b)
&& self
.release
.iter()
.zip(other.release.iter())
.all(|(a,b)| a == b)
&& self
.version
.iter()
.zip(other.version.iter())
.all(|(a,b)| a == b)
&& self
.machine
.iter()
.zip(other.machine.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for utsname {}
impl ::fmt::Debug for utsname {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("utsname")
// FIXME: .field("sysname", &self.sysname)
// FIXME: .field("nodename", &self.nodename)
// FIXME: .field("release", &self.release)
// FIXME: .field("version", &self.version)
// FIXME: .field("machine", &self.machine)
.finish()
}
}
impl ::hash::Hash for utsname {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sysname.hash(state);
self.nodename.hash(state);
self.release.hash(state);
self.version.hash(state);
self.machine.hash(state);
}
}
impl PartialEq for mq_attr {
fn eq(&self, other: &mq_attr) -> bool {
self.mq_maxmsg == other.mq_maxmsg &&
self.mq_msgsize == other.mq_msgsize &&
self.mq_flags == other.mq_flags &&
self.mq_curmsgs == other.mq_curmsgs &&
self.mq_msgsize == other.mq_msgsize &&
self.mq_sendwait == other.mq_sendwait &&
self.mq_recvwait == other.mq_recvwait
}
}
impl Eq for mq_attr {}
impl ::fmt::Debug for mq_attr {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("mq_attr")
.field("mq_maxmsg", &self.mq_maxmsg)
.field("mq_msgsize", &self.mq_msgsize)
.field("mq_flags", &self.mq_flags)
.field("mq_curmsgs", &self.mq_curmsgs)
.field("mq_msgsize", &self.mq_msgsize)
.field("mq_sendwait", &self.mq_sendwait)
.field("mq_recvwait", &self.mq_recvwait)
.finish()
}
}
impl PartialEq for sockaddr_storage {
fn eq(&self, other: &sockaddr_storage) -> bool {
self.ss_len == other.ss_len
&& self.ss_family == other.ss_family
&& self.__ss_pad1 == other.__ss_pad1
&& self.__ss_align == other.__ss_align
&& self
.__ss_pad2
.iter()
.zip(other.__ss_pad2.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for sockaddr_storage {}
impl ::fmt::Debug for sockaddr_storage {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sockaddr_storage")
.field("ss_len", &self.ss_len)
.field("ss_family", &self.ss_family)
.field("__ss_pad1", &self.__ss_pad1)
.field("__ss_align", &self.__ss_align)
// FIXME: .field("__ss_pad2", &self.__ss_pad2)
.finish()
}
}
impl ::hash::Hash for sockaddr_storage {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.ss_len.hash(state);
self.ss_family.hash(state);
self.__ss_pad1.hash(state);
self.__ss_align.hash(state);
self.__ss_pad2.hash(state);
}
}
impl PartialEq for dirent {
fn eq(&self, other: &dirent) -> bool {
self.d_ino == other.d_ino
&& self.d_offset == other.d_offset
&& self.d_reclen == other.d_reclen
&& self.d_namelen == other.d_namelen
&& self
.d_name[..self.d_namelen as _]
.iter()
.zip(other.d_name.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for dirent {}
impl ::fmt::Debug for dirent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("dirent")
.field("d_ino", &self.d_ino)
.field("d_offset", &self.d_offset)
.field("d_reclen", &self.d_reclen)
.field("d_namelen", &self.d_namelen)
.field("d_name", &&self.d_name[..self.d_namelen as _])
.finish()
}
}
impl ::hash::Hash for dirent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.d_ino.hash(state);
self.d_offset.hash(state);
self.d_reclen.hash(state);
self.d_namelen.hash(state);
self.d_name[..self.d_namelen as _].hash(state);
}
}
}
}
pub const _SYSNAME_SIZE: usize = 256 + 1;
pub const RLIM_INFINITY: ::rlim_t = 0xfffffffffffffffd;
pub const O_LARGEFILE: ::c_int = 0o0100000;
// intentionally not public, only used for fd_set
cfg_if! {
if #[cfg(target_pointer_width = "32")] {
const ULONG_SIZE: usize = 32;
} else if #[cfg(target_pointer_width = "64")] {
const ULONG_SIZE: usize = 64;
} else {
// Unknown target_pointer_width
}
}
pub const EXIT_FAILURE: ::c_int = 1;
pub const EXIT_SUCCESS: ::c_int = 0;
pub const RAND_MAX: ::c_int = 32767;
pub const EOF: ::c_int = -1;
pub const SEEK_SET: ::c_int = 0;
pub const SEEK_CUR: ::c_int = 1;
pub const SEEK_END: ::c_int = 2;
pub const _IOFBF: ::c_int = 0;
pub const _IONBF: ::c_int = 2;
pub const _IOLBF: ::c_int = 1;
pub const F_DUPFD: ::c_int = 0;
pub const F_GETFD: ::c_int = 1;
pub const F_SETFD: ::c_int = 2;
pub const F_GETFL: ::c_int = 3;
pub const F_SETFL: ::c_int = 4;
pub const F_DUPFD_CLOEXEC: ::c_int = 5;
pub const SIGTRAP: ::c_int = 5;
pub const CLOCK_REALTIME: ::clockid_t = 0;
pub const CLOCK_MONOTONIC: ::clockid_t = 2;
pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 3;
pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 4;
pub const TIMER_ABSTIME: ::c_uint = 0x80000000;
pub const RUSAGE_SELF: ::c_int = 0;
pub const F_OK: ::c_int = 0;
pub const X_OK: ::c_int = 1;
pub const W_OK: ::c_int = 2;
pub const R_OK: ::c_int = 4;
pub const STDIN_FILENO: ::c_int = 0;
pub const STDOUT_FILENO: ::c_int = 1;