-
Notifications
You must be signed in to change notification settings - Fork 1k
/
mod.rs
3307 lines (3042 loc) · 111 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 c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type caddr_t = *mut ::c_char;
pub type clockid_t = ::c_int;
pub type blkcnt_t = ::c_long;
pub type clock_t = ::c_long;
pub type daddr_t = ::c_long;
pub type dev_t = ::c_ulong;
pub type fsblkcnt_t = ::c_ulong;
pub type fsfilcnt_t = ::c_ulong;
pub type ino_t = ::c_ulong;
pub type key_t = ::c_int;
pub type major_t = ::c_uint;
pub type minor_t = ::c_uint;
pub type mode_t = ::c_uint;
pub type nlink_t = ::c_uint;
pub type rlim_t = ::c_ulong;
pub type speed_t = ::c_uint;
pub type tcflag_t = ::c_uint;
pub type time_t = ::c_long;
pub type timer_t = ::c_int;
pub type wchar_t = ::c_int;
pub type nfds_t = ::c_ulong;
pub type projid_t = ::c_int;
pub type zoneid_t = ::c_int;
pub type psetid_t = ::c_int;
pub type processorid_t = ::c_int;
pub type chipid_t = ::c_int;
pub type ctid_t = ::id_t;
pub type suseconds_t = ::c_long;
pub type off_t = ::c_long;
pub type useconds_t = ::c_uint;
pub type socklen_t = ::c_uint;
pub type sa_family_t = u16;
pub type pthread_t = ::c_uint;
pub type pthread_key_t = ::c_uint;
pub type thread_t = ::c_uint;
pub type blksize_t = ::c_int;
pub type nl_item = ::c_int;
pub type mqd_t = *mut ::c_void;
pub type id_t = ::c_int;
pub type idtype_t = ::c_uint;
pub type shmatt_t = ::c_ulong;
pub type lgrp_rsrc_t = ::c_int;
pub type lgrp_affinity_t = ::c_int;
pub type lgrp_id_t = ::id_t;
pub type lgrp_mem_size_t = ::c_longlong;
pub type lgrp_cookie_t = ::uintptr_t;
pub type lgrp_content_t = ::c_uint;
pub type lgrp_lat_between_t = ::c_uint;
pub type lgrp_mem_size_flag_t = ::c_uint;
pub type lgrp_view_t = ::c_uint;
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
impl ::Clone for timezone {
fn clone(&self) -> timezone {
*self
}
}
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum ucred_t {}
impl ::Copy for ucred_t {}
impl ::Clone for ucred_t {
fn clone(&self) -> ucred_t {
*self
}
}
s! {
pub struct in_addr {
pub s_addr: ::in_addr_t,
}
pub struct ip_mreq {
pub imr_multiaddr: in_addr,
pub imr_interface: in_addr,
}
pub struct ip_mreq_source {
pub imr_multiaddr: in_addr,
pub imr_sourceaddr: in_addr,
pub imr_interface: in_addr,
}
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,
}
pub struct sockaddr {
pub sa_family: sa_family_t,
pub sa_data: [::c_char; 14],
}
pub struct sockaddr_in {
pub sin_family: sa_family_t,
pub sin_port: ::in_port_t,
pub sin_addr: ::in_addr,
pub sin_zero: [::c_char; 8]
}
pub struct sockaddr_in6 {
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,
pub __sin6_src_id: u32
}
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 ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut ::c_char,
pub ifa_flags: ::c_ulong,
pub ifa_addr: *mut ::sockaddr,
pub ifa_netmask: *mut ::sockaddr,
pub ifa_dstaddr: *mut ::sockaddr,
pub ifa_data: *mut ::c_void
}
pub struct itimerspec {
pub it_interval: ::timespec,
pub it_value: ::timespec,
}
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 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 pthread_attr_t {
__pthread_attrp: *mut ::c_void
}
pub struct pthread_mutex_t {
__pthread_mutex_flag1: u16,
__pthread_mutex_flag2: u8,
__pthread_mutex_ceiling: u8,
__pthread_mutex_type: u16,
__pthread_mutex_magic: u16,
__pthread_mutex_lock: u64,
__pthread_mutex_data: u64
}
pub struct pthread_mutexattr_t {
__pthread_mutexattrp: *mut ::c_void
}
pub struct pthread_cond_t {
__pthread_cond_flag: [u8; 4],
__pthread_cond_type: u16,
__pthread_cond_magic: u16,
__pthread_cond_data: u64
}
pub struct pthread_condattr_t {
__pthread_condattrp: *mut ::c_void,
}
pub struct pthread_rwlock_t {
__pthread_rwlock_readers: i32,
__pthread_rwlock_type: u16,
__pthread_rwlock_magic: u16,
__pthread_rwlock_mutex: ::pthread_mutex_t,
__pthread_rwlock_readercv: ::pthread_cond_t,
__pthread_rwlock_writercv: ::pthread_cond_t
}
pub struct pthread_rwlockattr_t {
__pthread_rwlockattrp: *mut ::c_void,
}
pub struct dirent {
pub d_ino: ::ino_t,
pub d_off: ::off_t,
pub d_reclen: u16,
pub d_name: [::c_char; 3]
}
pub struct glob_t {
pub gl_pathc: ::size_t,
pub gl_pathv: *mut *mut ::c_char,
pub gl_offs: ::size_t,
__unused1: *mut ::c_void,
__unused2: ::c_int,
__unused3: ::c_int,
__unused4: ::c_int,
__unused5: *mut ::c_void,
__unused6: *mut ::c_void,
__unused7: *mut ::c_void,
__unused8: *mut ::c_void,
__unused9: *mut ::c_void,
__unused10: *mut ::c_void,
}
pub struct addrinfo {
pub ai_flags: ::c_int,
pub ai_family: ::c_int,
pub ai_socktype: ::c_int,
pub ai_protocol: ::c_int,
#[cfg(target_arch = "sparc64")]
__sparcv9_pad: ::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 sigset_t {
bits: [u32; 4],
}
pub struct sigaction {
pub sa_flags: ::c_int,
pub sa_sigaction: ::sighandler_t,
pub sa_mask: sigset_t,
}
pub struct stack_t {
pub ss_sp: *mut ::c_void,
pub ss_size: ::size_t,
pub ss_flags: ::c_int,
}
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,
pub f_fstr: [::c_char; 32]
}
pub struct sendfilevec_t {
pub sfv_fd: ::c_int,
pub sfv_flag: ::c_uint,
pub sfv_off: ::off_t,
pub sfv_len: ::size_t,
}
pub struct sched_param {
pub sched_priority: ::c_int,
sched_pad: [::c_int; 8]
}
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 stat {
pub st_dev: ::dev_t,
pub st_ino: ::ino_t,
pub st_mode: ::mode_t,
pub st_nlink: ::nlink_t,
pub st_uid: ::uid_t,
pub st_gid: ::gid_t,
pub st_rdev: ::dev_t,
pub st_size: ::off_t,
pub st_atime: ::time_t,
pub st_atime_nsec: ::c_long,
pub st_mtime: ::time_t,
pub st_mtime_nsec: ::c_long,
pub st_ctime: ::time_t,
pub st_ctime_nsec: ::c_long,
pub st_blksize: ::blksize_t,
pub st_blocks: ::blkcnt_t,
__unused: [::c_char; 16]
}
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]
}
pub struct lconv {
pub decimal_point: *mut ::c_char,
pub thousands_sep: *mut ::c_char,
pub grouping: *mut ::c_char,
pub int_curr_symbol: *mut ::c_char,
pub currency_symbol: *mut ::c_char,
pub mon_decimal_point: *mut ::c_char,
pub mon_thousands_sep: *mut ::c_char,
pub mon_grouping: *mut ::c_char,
pub positive_sign: *mut ::c_char,
pub negative_sign: *mut ::c_char,
pub int_frac_digits: ::c_char,
pub frac_digits: ::c_char,
pub p_cs_precedes: ::c_char,
pub p_sep_by_space: ::c_char,
pub n_cs_precedes: ::c_char,
pub n_sep_by_space: ::c_char,
pub p_sign_posn: ::c_char,
pub n_sign_posn: ::c_char,
pub int_p_cs_precedes: ::c_char,
pub int_p_sep_by_space: ::c_char,
pub int_n_cs_precedes: ::c_char,
pub int_n_sep_by_space: ::c_char,
pub int_p_sign_posn: ::c_char,
pub int_n_sign_posn: ::c_char,
}
pub struct sem_t {
pub sem_count: u32,
pub sem_type: u16,
pub sem_magic: u16,
pub sem_pad1: [u64; 3],
pub sem_pad2: [u64; 2]
}
pub struct flock {
pub l_type: ::c_short,
pub l_whence: ::c_short,
pub l_start: ::off_t,
pub l_len: ::off_t,
pub l_sysid: ::c_int,
pub l_pid: ::pid_t,
pub l_pad: [::c_long; 4]
}
pub struct if_nameindex {
pub if_index: ::c_uint,
pub if_name: *mut ::c_char,
}
pub struct mq_attr {
pub mq_flags: ::c_long,
pub mq_maxmsg: ::c_long,
pub mq_msgsize: ::c_long,
pub mq_curmsgs: ::c_long,
_pad: [::c_int; 12]
}
pub struct port_event {
pub portev_events: ::c_int,
pub portev_source: ::c_ushort,
pub portev_pad: ::c_ushort,
pub portev_object: ::uintptr_t,
pub portev_user: *mut ::c_void,
}
pub struct port_notify {
pub portnfy_port: ::c_int,
pub portnfy_user: *mut ::c_void,
}
pub struct exit_status {
e_termination: ::c_short,
e_exit: ::c_short,
}
pub struct utmp {
pub ut_user: [::c_char; 8],
pub ut_id: [::c_char; 4],
pub ut_line: [::c_char; 12],
pub ut_pid: ::c_short,
pub ut_type: ::c_short,
pub ut_exit: exit_status,
pub ut_time: ::time_t,
}
pub struct timex {
pub modes: u32,
pub offset: i32,
pub freq: i32,
pub maxerror: i32,
pub esterror: i32,
pub status: i32,
pub constant: i32,
pub precision: i32,
pub tolerance: i32,
pub ppsfreq: i32,
pub jitter: i32,
pub shift: i32,
pub stabil: i32,
pub jitcnt: i32,
pub calcnt: i32,
pub errcnt: i32,
pub stbcnt: i32,
}
pub struct ntptimeval {
pub time: ::timeval,
pub maxerror: i32,
pub esterror: i32,
}
pub struct mmapobj_result_t {
pub mr_addr: ::caddr_t,
pub mr_msize: ::size_t,
pub mr_fsize: ::size_t,
pub mr_offset: ::size_t,
pub mr_prot: ::c_uint,
pub mr_flags: ::c_uint,
}
pub struct lgrp_affinity_args {
pub idtype: ::idtype_t,
pub id: ::id_t,
pub lgrp: ::lgrp_id_t,
pub aff: ::lgrp_affinity_t,
}
pub struct processor_info_t {
pub pi_state: ::c_int,
pub pi_processor_type: [::c_char; PI_TYPELEN as usize],
pub pi_fputypes: [::c_char; PI_FPUTYPE as usize],
pub pi_clock: ::c_int,
}
pub struct option {
pub name: *const ::c_char,
pub has_arg: ::c_int,
pub flag: *mut ::c_int,
pub val: ::c_int,
}
}
s_no_extra_traits! {
#[cfg_attr(all(
any(target_arch = "x86", target_arch = "x86_64"),
libc_packedN
), repr(packed(4)))]
#[cfg_attr(all(
any(target_arch = "x86", target_arch = "x86_64"),
not(libc_packedN)
), repr(packed))]
pub struct epoll_event {
pub events: u32,
pub u64: u64,
}
pub struct utmpx {
pub ut_user: [::c_char; _UTX_USERSIZE],
pub ut_id: [::c_char; _UTX_IDSIZE],
pub ut_line: [::c_char; _UTX_LINESIZE],
pub ut_pid: ::pid_t,
pub ut_type: ::c_short,
pub ut_exit: exit_status,
pub ut_tv: ::timeval,
pub ut_session: ::c_int,
pub ut_pad: [::c_int; _UTX_PADSIZE],
pub ut_syslen: ::c_short,
pub ut_host: [::c_char; _UTX_HOSTSIZE],
}
pub struct sockaddr_un {
pub sun_family: sa_family_t,
pub sun_path: [c_char; 108]
}
pub struct utsname {
pub sysname: [::c_char; 257],
pub nodename: [::c_char; 257],
pub release: [::c_char; 257],
pub version: [::c_char; 257],
pub machine: [::c_char; 257],
}
pub struct fd_set {
#[cfg(target_pointer_width = "64")]
fds_bits: [i64; FD_SETSIZE / 64],
#[cfg(target_pointer_width = "32")]
fds_bits: [i32; FD_SETSIZE / 32],
}
pub struct sockaddr_storage {
pub ss_family: ::sa_family_t,
__ss_pad1: [u8; 6],
__ss_align: i64,
__ss_pad2: [u8; 240],
}
#[cfg_attr(all(target_pointer_width = "64", libc_align), repr(align(8)))]
pub struct siginfo_t {
pub si_signo: ::c_int,
pub si_code: ::c_int,
pub si_errno: ::c_int,
#[cfg(target_pointer_width = "64")]
pub si_pad: ::c_int,
__data_pad: [::c_int; SIGINFO_DATA_SIZE],
}
pub struct sockaddr_dl {
pub sdl_family: ::c_ushort,
pub sdl_index: ::c_ushort,
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; 244],
}
pub struct sigevent {
pub sigev_notify: ::c_int,
pub sigev_signo: ::c_int,
pub sigev_value: ::sigval,
pub ss_sp: *mut ::c_void,
pub sigev_notify_attributes: *const ::pthread_attr_t,
__sigev_pad2: ::c_int,
}
#[cfg(libc_union)]
#[cfg_attr(libc_align, repr(align(16)))]
pub union pad128_t {
// pub _q in this structure would be a "long double", of 16 bytes
pub _l: [i32; 4],
}
#[cfg(libc_union)]
#[cfg_attr(libc_align, repr(align(16)))]
pub union upad128_t {
// pub _q in this structure would be a "long double", of 16 bytes
pub _l: [u32; 4],
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
impl PartialEq for utmpx {
fn eq(&self, other: &utmpx) -> bool {
self.ut_type == other.ut_type
&& self.ut_pid == other.ut_pid
&& self.ut_user == other.ut_user
&& self.ut_line == other.ut_line
&& self.ut_id == other.ut_id
&& self.ut_exit == other.ut_exit
&& self.ut_session == other.ut_session
&& self.ut_tv == other.ut_tv
&& self.ut_syslen == other.ut_syslen
&& self.ut_pad == other.ut_pad
&& self
.ut_host
.iter()
.zip(other.ut_host.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for utmpx {}
impl ::fmt::Debug for utmpx {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("utmpx")
.field("ut_user", &self.ut_user)
.field("ut_id", &self.ut_id)
.field("ut_line", &self.ut_line)
.field("ut_pid", &self.ut_pid)
.field("ut_type", &self.ut_type)
.field("ut_exit", &self.ut_exit)
.field("ut_tv", &self.ut_tv)
.field("ut_session", &self.ut_session)
.field("ut_pad", &self.ut_pad)
.field("ut_syslen", &self.ut_syslen)
.field("ut_host", &&self.ut_host[..])
.finish()
}
}
impl ::hash::Hash for utmpx {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.ut_user.hash(state);
self.ut_type.hash(state);
self.ut_pid.hash(state);
self.ut_line.hash(state);
self.ut_id.hash(state);
self.ut_host.hash(state);
self.ut_exit.hash(state);
self.ut_session.hash(state);
self.ut_tv.hash(state);
self.ut_syslen.hash(state);
self.ut_pad.hash(state);
}
}
impl PartialEq for epoll_event {
fn eq(&self, other: &epoll_event) -> bool {
self.events == other.events
&& self.u64 == other.u64
}
}
impl Eq for epoll_event {}
impl ::fmt::Debug for epoll_event {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
let events = self.events;
let u64 = self.u64;
f.debug_struct("epoll_event")
.field("events", &events)
.field("u64", &u64)
.finish()
}
}
impl ::hash::Hash for epoll_event {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
let events = self.events;
let u64 = self.u64;
events.hash(state);
u64.hash(state);
}
}
impl PartialEq for sockaddr_un {
fn eq(&self, other: &sockaddr_un) -> bool {
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_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_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 fd_set {
fn eq(&self, other: &fd_set) -> bool {
self.fds_bits
.iter()
.zip(other.fds_bits.iter())
.all(|(a, b)| a == b)
}
}
impl Eq for fd_set {}
impl ::fmt::Debug for fd_set {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("fd_set")
// FIXME: .field("fds_bits", &self.fds_bits)
.finish()
}
}
impl ::hash::Hash for fd_set {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.fds_bits.hash(state);
}
}
impl PartialEq for sockaddr_storage {
fn eq(&self, other: &sockaddr_storage) -> bool {
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_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_family.hash(state);
self.__ss_pad1.hash(state);
self.__ss_align.hash(state);
self.__ss_pad2.hash(state);
}
}
impl siginfo_t {
/// The siginfo_t will have differing contents based on the delivered signal. Based on
/// `si_signo`, this determines how many of the `c_int` pad fields contain valid data
/// exposed by the C unions.
///
/// It is not yet exhausitive for the OS-defined types, and defaults to assuming the
/// entire data pad area is "valid" for otherwise unrecognized signal numbers.
fn data_field_count(&self) -> usize {
match self.si_signo {
::SIGSEGV | ::SIGBUS | ::SIGILL | ::SIGTRAP | ::SIGFPE => {
::mem::size_of::<siginfo_fault>() / ::mem::size_of::<::c_int>()
}
::SIGCLD => ::mem::size_of::<siginfo_sigcld>() / ::mem::size_of::<::c_int>(),
::SIGHUP
| ::SIGINT
| ::SIGQUIT
| ::SIGABRT
| ::SIGSYS
| ::SIGPIPE
| ::SIGALRM
| ::SIGTERM
| ::SIGUSR1
| ::SIGUSR2
| ::SIGPWR
| ::SIGWINCH
| ::SIGURG => ::mem::size_of::<siginfo_kill>() / ::mem::size_of::<::c_int>(),
_ => SIGINFO_DATA_SIZE,
}
}
}
impl PartialEq for siginfo_t {
fn eq(&self, other: &siginfo_t) -> bool {
if self.si_signo == other.si_signo
&& self.si_code == other.si_code
&& self.si_errno == other.si_errno {
// FIXME: The `si_pad` field in the 64-bit version of the struct is ignored
// (for now) when doing comparisons.
let field_count = self.data_field_count();
self.__data_pad[..field_count]
.iter()
.zip(other.__data_pad[..field_count].iter())
.all(|(a, b)| a == b)
} else {
false
}
}
}
impl Eq for siginfo_t {}
impl ::fmt::Debug for siginfo_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("siginfo_t")
.field("si_signo", &self.si_signo)
.field("si_code", &self.si_code)
.field("si_errno", &self.si_errno)
// FIXME: .field("__pad", &self.__pad)
.finish()
}
}
impl ::hash::Hash for siginfo_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.si_signo.hash(state);
self.si_code.hash(state);
self.si_errno.hash(state);
// FIXME: The `si_pad` field in the 64-bit version of the struct is ignored
// (for now) when doing hashing.
let field_count = self.data_field_count();
self.__data_pad[..field_count].hash(state)
}
}
impl PartialEq for sockaddr_dl {
fn eq(&self, other: &sockaddr_dl) -> bool {
self.sdl_family == other.sdl_family
&& self.sdl_index == other.sdl_index
&& self.sdl_type == other.sdl_type
&& self.sdl_nlen == other.sdl_nlen
&& self.sdl_alen == other.sdl_alen
&& self.sdl_slen == other.sdl_slen
&& self
.sdl_data
.iter()
.zip(other.sdl_data.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for sockaddr_dl {}
impl ::fmt::Debug for sockaddr_dl {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sockaddr_dl")
.field("sdl_family", &self.sdl_family)
.field("sdl_index", &self.sdl_index)
.field("sdl_type", &self.sdl_type)
.field("sdl_nlen", &self.sdl_nlen)
.field("sdl_alen", &self.sdl_alen)
.field("sdl_slen", &self.sdl_slen)
// FIXME: .field("sdl_data", &self.sdl_data)
.finish()
}
}
impl ::hash::Hash for sockaddr_dl {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sdl_family.hash(state);
self.sdl_index.hash(state);
self.sdl_type.hash(state);
self.sdl_nlen.hash(state);
self.sdl_alen.hash(state);
self.sdl_slen.hash(state);
self.sdl_data.hash(state);
}
}
impl PartialEq for sigevent {
fn eq(&self, other: &sigevent) -> bool {
self.sigev_notify == other.sigev_notify
&& self.sigev_signo == other.sigev_signo
&& self.sigev_value == other.sigev_value
&& self.ss_sp == other.ss_sp
&& self.sigev_notify_attributes
== other.sigev_notify_attributes
}
}
impl Eq for sigevent {}
impl ::fmt::Debug for sigevent {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigevent")
.field("sigev_notify", &self.sigev_notify)
.field("sigev_signo", &self.sigev_signo)
.field("sigev_value", &self.sigev_value)
.field("ss_sp", &self.ss_sp)
.field("sigev_notify_attributes",
&self.sigev_notify_attributes)
.finish()
}
}
impl ::hash::Hash for sigevent {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.sigev_notify.hash(state);
self.sigev_signo.hash(state);
self.sigev_value.hash(state);
self.ss_sp.hash(state);
self.sigev_notify_attributes.hash(state);
}
}
#[cfg(libc_union)]
impl PartialEq for pad128_t {
fn eq(&self, other: &pad128_t) -> bool {
unsafe {
// FIXME: self._q == other._q ||
self._l == other._l
}
}
}
#[cfg(libc_union)]
impl Eq for pad128_t {}
#[cfg(libc_union)]
impl ::fmt::Debug for pad128_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
f.debug_struct("pad128_t")
// FIXME: .field("_q", &{self._q})
.field("_l", &{self._l})
.finish()
}
}
}
#[cfg(libc_union)]
impl ::hash::Hash for pad128_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
// FIXME: state.write_i64(self._q as i64);
self._l.hash(state);
}
}
}
#[cfg(libc_union)]
impl PartialEq for upad128_t {
fn eq(&self, other: &upad128_t) -> bool {
unsafe {
// FIXME: self._q == other._q ||
self._l == other._l
}
}
}
#[cfg(libc_union)]
impl Eq for upad128_t {}
#[cfg(libc_union)]
impl ::fmt::Debug for upad128_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
f.debug_struct("upad128_t")
// FIXME: .field("_q", &{self._q})
.field("_l", &{self._l})
.finish()
}
}
}
#[cfg(libc_union)]
impl ::hash::Hash for upad128_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
// FIXME: state.write_i64(self._q as i64);
self._l.hash(state);
}
}
}