-
Notifications
You must be signed in to change notification settings - Fork 1k
/
mod.rs
1941 lines (1656 loc) · 61 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
//! Interface to VxWorks C library
use core::mem::size_of;
use core::ptr::null_mut;
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum DIR {}
impl ::Copy for DIR {}
impl ::Clone for DIR {
fn clone(&self) -> DIR {
*self
}
}
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_float = f32;
pub type c_double = f64;
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intmax_t = i64;
pub type uintmax_t = u64;
pub type uintptr_t = usize;
pub type intptr_t = isize;
pub type ptrdiff_t = isize;
pub type size_t = ::uintptr_t;
pub type ssize_t = ::intptr_t;
pub type pid_t = ::c_int;
pub type in_addr_t = u32;
pub type sighandler_t = ::size_t;
pub type cpuset_t = u32;
pub type blkcnt_t = ::c_long;
pub type blksize_t = ::c_long;
pub type ino_t = ::c_ulong;
pub type rlim_t = ::c_ulong;
pub type suseconds_t = ::c_long;
pub type time_t = ::c_long;
pub type errno_t = ::c_int;
pub type useconds_t = ::c_ulong;
pub type socklen_t = ::c_uint;
pub type pthread_t = ::c_ulong;
pub type clockid_t = ::c_int;
//defined for the structs
pub type dev_t = ::c_ulong;
pub type mode_t = ::c_int;
pub type nlink_t = ::c_ulong;
pub type uid_t = ::c_ushort;
pub type gid_t = ::c_ushort;
pub type sigset_t = ::c_ulonglong;
pub type key_t = ::c_long;
pub type nfds_t = ::c_uint;
pub type stat64 = ::stat;
pub type pthread_key_t = ::c_ulong;
// From b_off_t.h
pub type off_t = ::c_longlong;
pub type off64_t = off_t;
// From b_BOOL.h
pub type BOOL = ::c_int;
// From vxWind.h ..
pub type _Vx_OBJ_HANDLE = ::c_int;
pub type _Vx_TASK_ID = ::_Vx_OBJ_HANDLE;
pub type _Vx_MSG_Q_ID = ::_Vx_OBJ_HANDLE;
pub type _Vx_SEM_ID_KERNEL = ::_Vx_OBJ_HANDLE;
pub type _Vx_RTP_ID = ::_Vx_OBJ_HANDLE;
pub type _Vx_SD_ID = ::_Vx_OBJ_HANDLE;
pub type _Vx_CONDVAR_ID = ::_Vx_OBJ_HANDLE;
pub type _Vx_SEM_ID = *mut ::_Vx_semaphore;
pub type OBJ_HANDLE = ::_Vx_OBJ_HANDLE;
pub type TASK_ID = ::OBJ_HANDLE;
pub type MSG_Q_ID = ::OBJ_HANDLE;
pub type SEM_ID_KERNEL = ::OBJ_HANDLE;
pub type RTP_ID = ::OBJ_HANDLE;
pub type SD_ID = ::OBJ_HANDLE;
pub type CONDVAR_ID = ::OBJ_HANDLE;
// From vxTypes.h
pub type _Vx_usr_arg_t = isize;
pub type _Vx_exit_code_t = isize;
pub type _Vx_ticks_t = ::c_uint;
pub type _Vx_ticks64_t = ::c_ulonglong;
pub type sa_family_t = ::c_uchar;
// mqueue.h
pub type mqd_t = ::c_int;
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum _Vx_semaphore {}
impl ::Copy for _Vx_semaphore {}
impl ::Clone for _Vx_semaphore {
fn clone(&self) -> _Vx_semaphore {
*self
}
}
impl siginfo_t {
pub unsafe fn si_addr(&self) -> *mut ::c_void {
self.si_addr
}
pub unsafe fn si_value(&self) -> ::sigval {
self.si_value
}
pub unsafe fn si_pid(&self) -> ::pid_t {
self.si_pid
}
pub unsafe fn si_uid(&self) -> ::uid_t {
self.si_uid
}
pub unsafe fn si_status(&self) -> ::c_int {
self.si_status
}
}
s! {
// b_pthread_condattr_t.h
pub struct pthread_condattr_t {
pub condAttrStatus: ::c_int,
pub condAttrPshared: ::c_int,
pub condAttrClockId: ::clockid_t,
}
// b_pthread_cond_t.h
pub struct pthread_cond_t{
pub condSemId: ::_Vx_SEM_ID,
pub condValid: ::c_int,
pub condInitted: ::c_int,
pub condRefCount: ::c_int,
pub condMutex: *mut ::pthread_mutex_t,
pub condAttr: ::pthread_condattr_t,
pub condSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX]
}
// b_pthread_rwlockattr_t.h
pub struct pthread_rwlockattr_t {
pub rwlockAttrStatus: ::c_int,
pub rwlockAttrPshared: ::c_int,
pub rwlockAttrMaxReaders: ::c_uint,
pub rwlockAttrConformOpt: ::c_uint,
}
// b_pthread_rwlock_t.h
pub struct pthread_rwlock_t {
pub rwlockSemId: :: _Vx_SEM_ID,
pub rwlockReadersRefCount: ::c_uint,
pub rwlockValid: ::c_int,
pub rwlockInitted: ::c_int,
pub rwlockAttr: ::pthread_rwlockattr_t,
pub rwlockSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX]
}
// b_struct_timeval.h
pub struct timeval {
pub tv_sec: ::time_t,
pub tv_usec: ::suseconds_t,
}
// socket.h
pub struct linger {
pub l_onoff: ::c_int,
pub l_linger: ::c_int,
}
pub struct sockaddr {
pub sa_len : ::c_uchar,
pub sa_family : sa_family_t,
pub sa_data : [::c_char; 14],
}
pub struct iovec {
pub iov_base: *mut ::c_void,
pub iov_len: ::size_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,
}
// poll.h
pub struct pollfd {
pub fd : ::c_int,
pub events : ::c_short,
pub revents : ::c_short,
}
// resource.h
pub struct rlimit {
pub rlim_cur : ::rlim_t,
pub rlim_max : ::rlim_t,
}
// stat.h
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_mtime : ::time_t,
pub st_ctime : ::time_t,
pub st_blksize : ::blksize_t,
pub st_blocks : ::blkcnt_t,
pub st_attrib : ::c_uchar,
pub st_reserved1 : ::c_int,
pub st_reserved2 : ::c_int,
pub st_reserved3 : ::c_int,
pub st_reserved4 : ::c_int,
}
//b_struct__Timespec.h
pub struct _Timespec {
pub tv_sec : ::time_t,
pub tv_nsec : ::c_long,
}
// b_struct__Sched_param.h
pub struct _Sched_param {
pub sched_priority: ::c_int, /* scheduling priority */
pub sched_ss_low_priority: ::c_int, /* low scheduling priority */
pub sched_ss_repl_period: ::_Timespec, /* replenishment period */
pub sched_ss_init_budget: ::_Timespec, /* initial budget */
pub sched_ss_max_repl: ::c_int, /* max pending replenishment */
}
// b_pthread_attr_t.h
pub struct pthread_attr_t {
pub threadAttrStatus : ::c_int,
pub threadAttrStacksize : ::size_t,
pub threadAttrStackaddr : *mut ::c_void,
pub threadAttrGuardsize : ::size_t,
pub threadAttrDetachstate : ::c_int,
pub threadAttrContentionscope : ::c_int,
pub threadAttrInheritsched : ::c_int,
pub threadAttrSchedpolicy : ::c_int,
pub threadAttrName : *mut ::c_char,
pub threadAttrOptions : ::c_int,
pub threadAttrSchedparam : ::_Sched_param,
}
// signal.h
pub struct sigaction {
pub sa_u : ::sa_u_t,
pub sa_mask : ::sigset_t,
pub sa_flags : ::c_int,
}
// b_stack_t.h
pub struct stack_t {
pub ss_sp : *mut ::c_void,
pub ss_size : ::size_t,
pub ss_flags : ::c_int,
}
// signal.h
pub struct siginfo_t {
pub si_signo : ::c_int,
pub si_code : ::c_int,
pub si_value : ::sigval,
pub si_errno : ::c_int,
pub si_status: ::c_int,
pub si_addr: *mut ::c_void,
pub si_uid: ::uid_t,
pub si_pid: ::pid_t,
}
// pthread.h (krnl)
// b_pthread_mutexattr_t.h (usr)
pub struct pthread_mutexattr_t {
mutexAttrStatus : ::c_int,
mutexAttrPshared : ::c_int,
mutexAttrProtocol : ::c_int,
mutexAttrPrioceiling : ::c_int,
mutexAttrType : ::c_int,
}
// pthread.h (krnl)
// b_pthread_mutex_t.h (usr)
pub struct pthread_mutex_t {
pub mutexSemId: ::_Vx_SEM_ID, /*_Vx_SEM_ID ..*/
pub mutexValid: ::c_int,
pub mutexInitted: ::c_int,
pub mutexCondRefCount: ::c_int,
pub mutexSavPriority: ::c_int,
pub mutexAttr: ::pthread_mutexattr_t,
pub mutexSemName: [::c_char; _PTHREAD_SHARED_SEM_NAME_MAX],
}
// b_struct_timespec.h
pub struct timespec {
pub tv_sec: ::time_t,
pub tv_nsec: ::c_long,
}
// time.h
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,
}
// in.h
pub struct in_addr {
pub s_addr: in_addr_t,
}
// in.h
pub struct ip_mreq {
pub imr_multiaddr: in_addr,
pub imr_interface: in_addr,
}
// in6.h
#[repr(align(4))]
pub struct in6_addr {
pub s6_addr: [u8; 16],
}
// in6.h
pub struct ipv6_mreq {
pub ipv6mr_multiaddr: in6_addr,
pub ipv6mr_interface: ::c_uint,
}
// netdb.h
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 : ::size_t,
pub ai_canonname: *mut ::c_char,
pub ai_addr : *mut ::sockaddr,
pub ai_next : *mut ::addrinfo,
}
// in.h
pub struct sockaddr_in {
pub sin_len : u8,
pub sin_family: u8,
pub sin_port : u16,
pub sin_addr : ::in_addr,
pub sin_zero : [::c_char; 8],
}
// in6.h
pub struct sockaddr_in6 {
pub sin6_len : u8,
pub sin6_family : u8,
pub sin6_port : u16,
pub sin6_flowinfo: u32,
pub sin6_addr : ::in6_addr,
pub sin6_scope_id: u32,
}
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 mq_attr {
pub mq_maxmsg: ::c_long,
pub mq_msgsize: ::c_long,
pub mq_flags: ::c_long,
pub mq_curmsgs: ::c_long,
}
}
s_no_extra_traits! {
// dirent.h
pub struct dirent {
pub d_ino : ::ino_t,
pub d_name : [::c_char; _PARM_NAME_MAX as usize + 1],
}
pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
pub sun_path: [::c_char; 104]
}
// rtpLibCommon.h
pub struct RTP_DESC {
pub status : ::c_int,
pub options : u32,
pub entrAddr : *mut ::c_void,
pub initTaskId: ::TASK_ID,
pub parentId : ::RTP_ID,
pub pathName : [::c_char; VX_RTP_NAME_LENGTH as usize + 1],
pub taskCnt : ::c_int,
pub textStart : *mut ::c_void,
pub textEnd : *mut ::c_void,
}
// socket.h
pub struct sockaddr_storage {
pub ss_len : ::c_uchar,
pub ss_family : ::sa_family_t,
pub __ss_pad1 : [::c_char; _SS_PAD1SIZE],
pub __ss_align : i32,
pub __ss_pad2 : [::c_char; _SS_PAD2SIZE],
}
pub union sa_u_t {
pub sa_handler : ::Option<unsafe extern "C" fn(::c_int) -> !>,
pub sa_sigaction: ::Option<unsafe extern "C" fn(::c_int,
*mut ::siginfo_t,
*mut ::c_void) -> !>,
}
pub union sigval {
pub sival_int : ::c_int,
pub sival_ptr : *mut ::c_void,
}
}
cfg_if! {
if #[cfg(feature = "extra_traits")] {
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_name", &&self.d_name[..])
.finish()
}
}
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)
.field("sun_path", &&self.sun_path[..])
.finish()
}
}
impl ::fmt::Debug for RTP_DESC {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("RTP_DESC")
.field("status", &self.status)
.field("options", &self.options)
.field("entrAddr", &self.entrAddr)
.field("initTaskId", &self.initTaskId)
.field("parentId", &self.parentId)
.field("pathName", &&self.pathName[..])
.field("taskCnt", &self.taskCnt)
.field("textStart", &self.textStart)
.field("textEnd", &self.textEnd)
.finish()
}
}
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)
.field("__ss_pad2", &&self.__ss_pad2[..])
.finish()
}
}
impl PartialEq for sa_u_t {
fn eq(&self, other: &sa_u_t) -> bool {
unsafe {
let h1 = match self.sa_handler {
Some(handler) => handler as usize,
None => 0 as usize,
};
let h2 = match other.sa_handler {
Some(handler) => handler as usize,
None => 0 as usize,
};
h1 == h2
}
}
}
impl Eq for sa_u_t {}
impl ::fmt::Debug for sa_u_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
unsafe {
let h = match self.sa_handler {
Some(handler) => handler as usize,
None => 0 as usize,
};
f.debug_struct("sa_u_t")
.field("sa_handler", &h)
.finish()
}
}
}
impl ::hash::Hash for sa_u_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe {
let h = match self.sa_handler {
Some(handler) => handler as usize,
None => 0 as usize,
};
h.hash(state)
}
}
}
impl PartialEq for sigval {
fn eq(&self, other: &sigval) -> bool {
unsafe { self.sival_ptr as usize == other.sival_ptr as usize }
}
}
impl Eq for sigval {}
impl ::fmt::Debug for sigval {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("sigval")
.field("sival_ptr", unsafe { &(self.sival_ptr as usize) })
.finish()
}
}
impl ::hash::Hash for sigval {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
unsafe { (self.sival_ptr as usize).hash(state) };
}
}
}
}
pub const STDIN_FILENO: ::c_int = 0;
pub const STDOUT_FILENO: ::c_int = 1;
pub const STDERR_FILENO: ::c_int = 2;
pub const EXIT_SUCCESS: ::c_int = 0;
pub const EXIT_FAILURE: ::c_int = 1;
pub const EAI_SERVICE: ::c_int = 9;
pub const EAI_SOCKTYPE: ::c_int = 10;
pub const EAI_SYSTEM: ::c_int = 11;
// FIXME: This is not defined in vxWorks, but we have to define it here
// to make the building pass for getrandom and std
pub const RTLD_DEFAULT: *mut ::c_void = 0i64 as *mut ::c_void;
//Clock Lib Stuff
pub const CLOCK_REALTIME: ::c_int = 0x0;
pub const CLOCK_MONOTONIC: ::c_int = 0x1;
pub const CLOCK_PROCESS_CPUTIME_ID: ::c_int = 0x2;
pub const CLOCK_THREAD_CPUTIME_ID: ::c_int = 0x3;
pub const TIMER_ABSTIME: ::c_int = 0x1;
pub const TIMER_RELTIME: ::c_int = 0x0;
// PTHREAD STUFF
pub const PTHREAD_INITIALIZED_OBJ: ::c_int = 0xF70990EF;
pub const PTHREAD_DESTROYED_OBJ: ::c_int = -1;
pub const PTHREAD_VALID_OBJ: ::c_int = 0xEC542A37;
pub const PTHREAD_INVALID_OBJ: ::c_int = -1;
pub const PTHREAD_UNUSED_YET_OBJ: ::c_int = -1;
pub const PTHREAD_PRIO_NONE: ::c_int = 0;
pub const PTHREAD_PRIO_INHERIT: ::c_int = 1;
pub const PTHREAD_PRIO_PROTECT: ::c_int = 2;
pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_NORMAL;
pub const PTHREAD_STACK_MIN: usize = 4096;
pub const _PTHREAD_SHARED_SEM_NAME_MAX: usize = 30;
// ERRNO STUFF
pub const OK: ::c_int = 0;
pub const EPERM: ::c_int = 1; /* Not owner */
pub const ENOENT: ::c_int = 2; /* No such file or directory */
pub const ESRCH: ::c_int = 3; /* No such process */
pub const EINTR: ::c_int = 4; /* Interrupted system call */
pub const EIO: ::c_int = 5; /* I/O error */
pub const ENXIO: ::c_int = 6; /* No such device or address */
pub const E2BIG: ::c_int = 7; /* Arg list too long */
pub const ENOEXEC: ::c_int = 8; /* Exec format error */
pub const EBADF: ::c_int = 9; /* Bad file number */
pub const ECHILD: ::c_int = 10; /* No children */
pub const EAGAIN: ::c_int = 11; /* No more processes */
pub const ENOMEM: ::c_int = 12; /* Not enough core */
pub const EACCES: ::c_int = 13; /* Permission denied */
pub const EFAULT: ::c_int = 14;
pub const ENOTEMPTY: ::c_int = 15;
pub const EBUSY: ::c_int = 16;
pub const EEXIST: ::c_int = 17;
pub const EXDEV: ::c_int = 18;
pub const ENODEV: ::c_int = 19;
pub const ENOTDIR: ::c_int = 20;
pub const EISDIR: ::c_int = 21;
pub const EINVAL: ::c_int = 22;
pub const ENAMETOOLONG: ::c_int = 26;
pub const EFBIG: ::c_int = 27;
pub const ENOSPC: ::c_int = 28;
pub const ESPIPE: ::c_int = 29;
pub const EROFS: ::c_int = 30;
pub const EMLINK: ::c_int = 31;
pub const EPIPE: ::c_int = 32;
pub const EDEADLK: ::c_int = 33;
pub const ERANGE: ::c_int = 38;
pub const EDESTADDRREQ: ::c_int = 40;
pub const EPROTOTYPE: ::c_int = 41;
pub const ENOPROTOOPT: ::c_int = 42;
pub const EPROTONOSUPPORT: ::c_int = 43;
pub const ESOCKTNOSUPPORT: ::c_int = 44;
pub const EOPNOTSUPP: ::c_int = 45;
pub const EPFNOSUPPORT: ::c_int = 46;
pub const EAFNOSUPPORT: ::c_int = 47;
pub const EADDRINUSE: ::c_int = 48;
pub const EADDRNOTAVAIL: ::c_int = 49;
pub const ENOTSOCK: ::c_int = 50;
pub const ENETUNREACH: ::c_int = 51;
pub const ENETRESET: ::c_int = 52;
pub const ECONNABORTED: ::c_int = 53;
pub const ECONNRESET: ::c_int = 54;
pub const ENOBUFS: ::c_int = 55;
pub const EISCONN: ::c_int = 56;
pub const ENOTCONN: ::c_int = 57;
pub const ESHUTDOWN: ::c_int = 58;
pub const ETOOMANYREFS: ::c_int = 59;
pub const ETIMEDOUT: ::c_int = 60;
pub const ECONNREFUSED: ::c_int = 61;
pub const ENETDOWN: ::c_int = 62;
pub const ETXTBSY: ::c_int = 63;
pub const ELOOP: ::c_int = 64;
pub const EHOSTUNREACH: ::c_int = 65;
pub const EINPROGRESS: ::c_int = 68;
pub const EALREADY: ::c_int = 69;
pub const EWOULDBLOCK: ::c_int = 70;
pub const ENOSYS: ::c_int = 71;
pub const EDQUOT: ::c_int = 83;
pub const ESTALE: ::c_int = 88;
// NFS errnos: Refer to pkgs_v2/storage/fs/nfs/h/nfs/nfsCommon.h
const M_nfsStat: ::c_int = 48 << 16;
enum nfsstat {
NFSERR_REMOTE = 71,
NFSERR_WFLUSH = 99,
NFSERR_BADHANDLE = 10001,
NFSERR_NOT_SYNC = 10002,
NFSERR_BAD_COOKIE = 10003,
NFSERR_TOOSMALL = 10005,
NFSERR_BADTYPE = 10007,
NFSERR_JUKEBOX = 10008,
}
pub const S_nfsLib_NFS_OK: ::c_int = OK;
pub const S_nfsLib_NFSERR_PERM: ::c_int = EPERM;
pub const S_nfsLib_NFSERR_NOENT: ::c_int = ENOENT;
pub const S_nfsLib_NFSERR_IO: ::c_int = EIO;
pub const S_nfsLib_NFSERR_NXIO: ::c_int = ENXIO;
pub const S_nfsLib_NFSERR_ACCESS: ::c_int = EACCES;
pub const S_nfsLib_NFSERR_EXIST: ::c_int = EEXIST;
pub const S_nfsLib_NFSERR_ENODEV: ::c_int = ENODEV;
pub const S_nfsLib_NFSERR_NOTDIR: ::c_int = ENOTDIR;
pub const S_nfsLib_NFSERR_ISDIR: ::c_int = EISDIR;
pub const S_nfsLib_NFSERR_INVAL: ::c_int = EINVAL;
pub const S_nfsLib_NFSERR_FBIG: ::c_int = EFBIG;
pub const S_nfsLib_NFSERR_NOSPC: ::c_int = ENOSPC;
pub const S_nfsLib_NFSERR_ROFS: ::c_int = EROFS;
pub const S_nfsLib_NFSERR_NAMETOOLONG: ::c_int = ENAMETOOLONG;
pub const S_nfsLib_NFSERR_NOTEMPTY: ::c_int = ENOTEMPTY;
pub const S_nfsLib_NFSERR_DQUOT: ::c_int = EDQUOT;
pub const S_nfsLib_NFSERR_STALE: ::c_int = ESTALE;
pub const S_nfsLib_NFSERR_WFLUSH: ::c_int = M_nfsStat | nfsstat::NFSERR_WFLUSH as ::c_int;
pub const S_nfsLib_NFSERR_REMOTE: ::c_int = M_nfsStat | nfsstat::NFSERR_REMOTE as ::c_int;
pub const S_nfsLib_NFSERR_BADHANDLE: ::c_int = M_nfsStat | nfsstat::NFSERR_BADHANDLE as ::c_int;
pub const S_nfsLib_NFSERR_NOT_SYNC: ::c_int = M_nfsStat | nfsstat::NFSERR_NOT_SYNC as ::c_int;
pub const S_nfsLib_NFSERR_BAD_COOKIE: ::c_int = M_nfsStat | nfsstat::NFSERR_BAD_COOKIE as ::c_int;
pub const S_nfsLib_NFSERR_NOTSUPP: ::c_int = EOPNOTSUPP;
pub const S_nfsLib_NFSERR_TOOSMALL: ::c_int = M_nfsStat | nfsstat::NFSERR_TOOSMALL as ::c_int;
pub const S_nfsLib_NFSERR_SERVERFAULT: ::c_int = EIO;
pub const S_nfsLib_NFSERR_BADTYPE: ::c_int = M_nfsStat | nfsstat::NFSERR_BADTYPE as ::c_int;
pub const S_nfsLib_NFSERR_JUKEBOX: ::c_int = M_nfsStat | nfsstat::NFSERR_JUKEBOX as ::c_int;
// in.h
pub const IPPROTO_IP: ::c_int = 0;
pub const IPPROTO_IPV6: ::c_int = 41;
pub const IP_TTL: ::c_int = 4;
pub const IP_MULTICAST_IF: ::c_int = 9;
pub const IP_MULTICAST_TTL: ::c_int = 10;
pub const IP_MULTICAST_LOOP: ::c_int = 11;
pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
// in6.h
pub const IPV6_V6ONLY: ::c_int = 1;
pub const IPV6_UNICAST_HOPS: ::c_int = 4;
pub const IPV6_MULTICAST_IF: ::c_int = 9;
pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
// STAT Stuff
pub const S_IFMT: ::c_int = 0o17_0000;
pub const S_IFIFO: ::c_int = 0o1_0000;
pub const S_IFCHR: ::c_int = 0o2_0000;
pub const S_IFDIR: ::c_int = 0o4_0000;
pub const S_IFBLK: ::c_int = 0o6_0000;
pub const S_IFREG: ::c_int = 0o10_0000;
pub const S_IFLNK: ::c_int = 0o12_0000;
pub const S_IFSHM: ::c_int = 0o13_0000;
pub const S_IFSOCK: ::c_int = 0o14_0000;
pub const S_ISUID: ::c_int = 0o4000;
pub const S_ISGID: ::c_int = 0o2000;
pub const S_ISTXT: ::c_int = 0o1000;
pub const S_ISVTX: mode_t = 0o1000;
pub const S_IRUSR: ::c_int = 0o0400;
pub const S_IWUSR: ::c_int = 0o0200;
pub const S_IXUSR: ::c_int = 0o0100;
pub const S_IRWXU: ::c_int = 0o0700;
pub const S_IRGRP: ::c_int = 0o0040;
pub const S_IWGRP: ::c_int = 0o0020;
pub const S_IXGRP: ::c_int = 0o0010;
pub const S_IRWXG: ::c_int = 0o0070;
pub const S_IROTH: ::c_int = 0o0004;
pub const S_IWOTH: ::c_int = 0o0002;
pub const S_IXOTH: ::c_int = 0o0001;
pub const S_IRWXO: ::c_int = 0o0007;
// socket.h
pub const SOL_SOCKET: ::c_int = 0xffff;
pub const SOMAXCONN: ::c_int = 128;
pub const SO_DEBUG: ::c_int = 0x0001;
pub const SO_REUSEADDR: ::c_int = 0x0004;
pub const SO_KEEPALIVE: ::c_int = 0x0008;
pub const SO_DONTROUTE: ::c_int = 0x0010;
pub const SO_RCVLOWAT: ::c_int = 0x0012;
pub const SO_SNDLOWAT: ::c_int = 0x0013;
pub const SO_SNDTIMEO: ::c_int = 0x1005;
pub const SO_ACCEPTCONN: ::c_int = 0x001e;
pub const SO_BROADCAST: ::c_int = 0x0020;
pub const SO_USELOOPBACK: ::c_int = 0x0040;
pub const SO_LINGER: ::c_int = 0x0080;
pub const SO_REUSEPORT: ::c_int = 0x0200;
pub const SO_VLAN: ::c_int = 0x8000;
pub const SO_SNDBUF: ::c_int = 0x1001;
pub const SO_RCVBUF: ::c_int = 0x1002;
pub const SO_RCVTIMEO: ::c_int = 0x1006;
pub const SO_ERROR: ::c_int = 0x1007;
pub const SO_TYPE: ::c_int = 0x1008;
pub const SO_BINDTODEVICE: ::c_int = 0x1010;
pub const SO_OOBINLINE: ::c_int = 0x1011;
pub const SO_CONNTIMEO: ::c_int = 0x100a;
pub const SOCK_STREAM: ::c_int = 1;
pub const SOCK_DGRAM: ::c_int = 2;
pub const SOCK_RAW: ::c_int = 3;
pub const SOCK_RDM: ::c_int = 4;
pub const SOCK_SEQPACKET: ::c_int = 5;
pub const SOCK_PACKET: ::c_int = 10;
pub const _SS_MAXSIZE: usize = 128;
pub const _SS_ALIGNSIZE: usize = size_of::<u32>();
pub const _SS_PAD1SIZE: usize = _SS_ALIGNSIZE - size_of::<::c_uchar>() - size_of::<::sa_family_t>();
pub const _SS_PAD2SIZE: usize = _SS_MAXSIZE
- size_of::<::c_uchar>()
- size_of::<::sa_family_t>()
- _SS_PAD1SIZE
- _SS_ALIGNSIZE;
pub const MSG_OOB: ::c_int = 0x0001;
pub const MSG_PEEK: ::c_int = 0x0002;
pub const MSG_DONTROUTE: ::c_int = 0x0004;
pub const MSG_EOR: ::c_int = 0x0008;
pub const MSG_TRUNC: ::c_int = 0x0010;
pub const MSG_CTRUNC: ::c_int = 0x0020;
pub const MSG_WAITALL: ::c_int = 0x0040;
pub const MSG_DONTWAIT: ::c_int = 0x0080;
pub const MSG_EOF: ::c_int = 0x0100;
pub const MSG_EXP: ::c_int = 0x0200;
pub const MSG_MBUF: ::c_int = 0x0400;
pub const MSG_NOTIFICATION: ::c_int = 0x0800;
pub const MSG_COMPAT: ::c_int = 0x8000;
pub const AF_UNSPEC: ::c_int = 0;
pub const AF_LOCAL: ::c_int = 1;
pub const AF_UNIX: ::c_int = AF_LOCAL;
pub const AF_INET: ::c_int = 2;
pub const AF_NETLINK: ::c_int = 16;
pub const AF_ROUTE: ::c_int = 17;
pub const AF_LINK: ::c_int = 18;
pub const AF_PACKET: ::c_int = 19;
pub const pseudo_AF_KEY: ::c_int = 27;
pub const AF_KEY: ::c_int = pseudo_AF_KEY;
pub const AF_INET6: ::c_int = 28;
pub const AF_SOCKDEV: ::c_int = 31;
pub const AF_TIPC: ::c_int = 33;
pub const AF_MIPC: ::c_int = 34;
pub const AF_MIPC_SAFE: ::c_int = 35;
pub const AF_MAX: ::c_int = 37;
pub const SHUT_RD: ::c_int = 0;
pub const SHUT_WR: ::c_int = 1;
pub const SHUT_RDWR: ::c_int = 2;
pub const IPPROTO_TCP: ::c_int = 6;
pub const TCP_NODELAY: ::c_int = 1;
pub const TCP_MAXSEG: ::c_int = 2;
pub const TCP_NOPUSH: ::c_int = 3;
pub const TCP_KEEPIDLE: ::c_int = 4;
pub const TCP_KEEPINTVL: ::c_int = 5;
pub const TCP_KEEPCNT: ::c_int = 6;
// ioLib.h
pub const FIONREAD: ::c_int = 0x40040001;
pub const FIOFLUSH: ::c_int = 2;
pub const FIOOPTIONS: ::c_int = 3;
pub const FIOBAUDRATE: ::c_int = 4;
pub const FIODISKFORMAT: ::c_int = 5;
pub const FIODISKINIT: ::c_int = 6;
pub const FIOSEEK: ::c_int = 7;
pub const FIOWHERE: ::c_int = 8;
pub const FIODIRENTRY: ::c_int = 9;
pub const FIORENAME: ::c_int = 10;
pub const FIOREADYCHANGE: ::c_int = 11;
pub const FIODISKCHANGE: ::c_int = 13;
pub const FIOCANCEL: ::c_int = 14;
pub const FIOSQUEEZE: ::c_int = 15;
pub const FIOGETNAME: ::c_int = 18;
pub const FIONBIO: ::c_int = 0x90040010;
// limits.h
pub const PATH_MAX: ::c_int = _PARM_PATH_MAX;
pub const _POSIX_PATH_MAX: ::c_int = 256;
// Some poll stuff
pub const POLLIN: ::c_short = 0x0001;
pub const POLLPRI: ::c_short = 0x0002;
pub const POLLOUT: ::c_short = 0x0004;
pub const POLLRDNORM: ::c_short = 0x0040;
pub const POLLWRNORM: ::c_short = POLLOUT;
pub const POLLRDBAND: ::c_short = 0x0080;
pub const POLLWRBAND: ::c_short = 0x0100;
pub const POLLERR: ::c_short = 0x0008;
pub const POLLHUP: ::c_short = 0x0010;
pub const POLLNVAL: ::c_short = 0x0020;
// fnctlcom.h
pub const FD_CLOEXEC: ::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_GETOWN: ::c_int = 5;
pub const F_SETOWN: ::c_int = 6;
pub const F_GETLK: ::c_int = 7;
pub const F_SETLK: ::c_int = 8;
pub const F_SETLKW: ::c_int = 9;
pub const F_DUPFD_CLOEXEC: ::c_int = 14;
// signal.h
pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
pub const SIG_IGN: sighandler_t = 1 as sighandler_t;
pub const SIG_ERR: sighandler_t = -1 as isize as sighandler_t;
pub const SIGHUP: ::c_int = 1;
pub const SIGINT: ::c_int = 2;
pub const SIGQUIT: ::c_int = 3;
pub const SIGILL: ::c_int = 4;
pub const SIGTRAP: ::c_int = 5;
pub const SIGABRT: ::c_int = 6;
pub const SIGEMT: ::c_int = 7;
pub const SIGFPE: ::c_int = 8;
pub const SIGKILL: ::c_int = 9;
pub const SIGBUS: ::c_int = 10;
pub const SIGSEGV: ::c_int = 11;
pub const SIGFMT: ::c_int = 12;
pub const SIGPIPE: ::c_int = 13;
pub const SIGALRM: ::c_int = 14;
pub const SIGTERM: ::c_int = 15;
pub const SIGCNCL: ::c_int = 16;
pub const SIGSTOP: ::c_int = 17;
pub const SIGTSTP: ::c_int = 18;
pub const SIGCONT: ::c_int = 19;
pub const SIGCHLD: ::c_int = 20;
pub const SIGTTIN: ::c_int = 21;
pub const SIGTTOU: ::c_int = 22;
pub const SIG_BLOCK: ::c_int = 1;
pub const SIG_UNBLOCK: ::c_int = 2;
pub const SIG_SETMASK: ::c_int = 3;
pub const SI_SYNC: ::c_int = 0;
pub const SI_USER: ::c_int = -1;
pub const SI_QUEUE: ::c_int = -2;
pub const SI_TIMER: ::c_int = -3;
pub const SI_ASYNCIO: ::c_int = -4;
pub const SI_MESGQ: ::c_int = -5;
pub const SI_CHILD: ::c_int = -6;
pub const SI_KILL: ::c_int = SI_USER;
// vxParams.h definitions
pub const _PARM_NAME_MAX: ::c_int = 255;
pub const _PARM_PATH_MAX: ::c_int = 1024;
// WAIT STUFF
pub const WNOHANG: ::c_int = 0x01;
pub const WUNTRACED: ::c_int = 0x02;
const PTHREAD_MUTEXATTR_INITIALIZER: pthread_mutexattr_t = pthread_mutexattr_t {
mutexAttrStatus: PTHREAD_INITIALIZED_OBJ,
mutexAttrProtocol: PTHREAD_PRIO_NONE,
mutexAttrPrioceiling: 0,
mutexAttrType: PTHREAD_MUTEX_DEFAULT,
mutexAttrPshared: 1,
};
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
mutexSemId: null_mut(),
mutexValid: PTHREAD_VALID_OBJ,
mutexInitted: PTHREAD_UNUSED_YET_OBJ,
mutexCondRefCount: 0,
mutexSavPriority: -1,
mutexAttr: PTHREAD_MUTEXATTR_INITIALIZER,
mutexSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
};
const PTHREAD_CONDATTR_INITIALIZER: pthread_condattr_t = pthread_condattr_t {
condAttrStatus: 0xf70990ef,
condAttrPshared: 1,
condAttrClockId: CLOCK_REALTIME,
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
condSemId: null_mut(),
condValid: PTHREAD_VALID_OBJ,
condInitted: PTHREAD_UNUSED_YET_OBJ,
condRefCount: 0,
condMutex: null_mut(),
condAttr: PTHREAD_CONDATTR_INITIALIZER,
condSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
};
const PTHREAD_RWLOCKATTR_INITIALIZER: pthread_rwlockattr_t = pthread_rwlockattr_t {
rwlockAttrStatus: PTHREAD_INITIALIZED_OBJ,
rwlockAttrPshared: 1,
rwlockAttrMaxReaders: 0,
rwlockAttrConformOpt: 1,
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
rwlockSemId: null_mut(),
rwlockReadersRefCount: 0,
rwlockValid: PTHREAD_VALID_OBJ,
rwlockInitted: PTHREAD_UNUSED_YET_OBJ,
rwlockAttr: PTHREAD_RWLOCKATTR_INITIALIZER,
rwlockSemName: [0; _PTHREAD_SHARED_SEM_NAME_MAX],
};