1
+ // Copyright (c) 2019 Wind River Systems, Inc.
1
2
//! Interface to VxWorks C library
2
3
3
4
use core:: mem:: size_of;
@@ -12,6 +13,9 @@ impl ::Clone for DIR {
12
13
}
13
14
}
14
15
16
+ // Throughout we use usize / isize for types that are
17
+ // (unsigned) int in ILP32 and (unsigned) long in ILP64
18
+
15
19
pub type c_schar = i8 ;
16
20
pub type c_uchar = u8 ;
17
21
pub type c_short = i16 ;
@@ -80,9 +84,9 @@ pub type off64_t = ::c_longlong;
80
84
pub type off_t64 = :: c_longlong ;
81
85
82
86
// From b_BOOL.h
83
- pub type BOOL = :: c_int ; // excuse me what
87
+ pub type BOOL = :: c_int ;
84
88
85
- //Straight from vxWind.h ..
89
+ // From vxWind.h ..
86
90
pub type _Vx_OBJ_HANDLE = :: c_int ;
87
91
pub type _Vx_TASK_ID = :: _Vx_OBJ_HANDLE ;
88
92
pub type _Vx_MSG_Q_ID = :: _Vx_OBJ_HANDLE ;
@@ -100,8 +104,8 @@ pub type SD_ID = ::OBJ_HANDLE;
100
104
pub type CONDVAR_ID = :: OBJ_HANDLE ;
101
105
102
106
// From vxTypes.h
103
- pub type _Vx_usr_arg_t = :: ssize_t ; // c_int for LP32
104
- pub type _Vx_exit_code_t = :: ssize_t ; // c_int for LP32
107
+ pub type _Vx_usr_arg_t = :: isize ;
108
+ pub type _Vx_exit_code_t = :: isize ;
105
109
pub type _Vx_ticks_t = :: c_uint ;
106
110
pub type _Vx_ticks64_t = :: c_ulonglong ;
107
111
@@ -112,25 +116,7 @@ pub type sa_family_t = ::c_uchar;
112
116
113
117
// structs that only exist in userspace
114
118
s ! {
115
- // b_struct_vx_eventsResourceCb.h
116
- pub struct _Vx_EVENTS_RSRC {
117
- pub registered : :: c_uint,
118
- pub taskId : :: c_int,
119
- pub options : :: c_uchar,
120
- pub pad : [ :: c_uchar; 3 ] ,
121
- }
122
-
123
- // b_struct_vx_semaphore.h
124
- pub struct _Vx_semaphore {
125
- pub magic : :: c_uint,
126
- pub semType: :: c_uint,
127
- pub options: :: c_uint,
128
- pub recurse: :: c_uint,
129
- pub owned_k: :: c_uint, // owned_k is volatile
130
- pub semId_k: :: _Vx_SEM_ID_KERNEL,
131
- pub state : :: c_uint, //state is union of _Vx_UINT and _Vx_UINT
132
- pub events : :: _Vx_EVENTS_RSRC,
133
- }
119
+ pub struct _Vx_semaphore { }
134
120
135
121
// b_pthread_condattr_t.h
136
122
pub struct pthread_condattr_t {
@@ -173,6 +159,11 @@ s! {
173
159
}
174
160
175
161
// socket.h
162
+ pub struct linger {
163
+ pub l_onoff: :: c_int,
164
+ pub l_linger: :: c_int,
165
+ }
166
+
176
167
pub struct sockaddr {
177
168
pub sa_len : :: c_uchar,
178
169
pub sa_family : sa_family_t,
@@ -361,6 +352,19 @@ s! {
361
352
pub tv_nsec: :: c_long,
362
353
}
363
354
355
+ // time.h
356
+ pub struct tm {
357
+ pub tm_sec: :: c_int,
358
+ pub tm_min: :: c_int,
359
+ pub tm_hour: :: c_int,
360
+ pub tm_mday: :: c_int,
361
+ pub tm_mon: :: c_int,
362
+ pub tm_year: :: c_int,
363
+ pub tm_wday: :: c_int,
364
+ pub tm_yday: :: c_int,
365
+ pub tm_isdst: :: c_int,
366
+ }
367
+
364
368
// in.h
365
369
pub struct in_addr {
366
370
pub s_addr: in_addr_t,
@@ -476,7 +480,7 @@ pub const EAI_SYSTEM: ::c_int = 11;
476
480
477
481
pub const RTLD_DEFAULT : * mut :: c_void = 0i64 as * mut :: c_void ;
478
482
479
- //Clock Lib Stuff
483
+ // Clock Lib Stuff
480
484
pub const CLOCK_REALTIME : :: c_int = 0x0 ;
481
485
pub const CLOCK_MONOTONIC : :: c_int = 0x1 ;
482
486
pub const CLOCK_PROCESS_CPUTIME_ID : :: c_int = 0x2 ;
@@ -508,7 +512,7 @@ pub const EEXIST: ::c_int = 17;
508
512
pub const ENODEV : :: c_int = 19 ;
509
513
pub const EINVAL : :: c_int = 22 ;
510
514
pub const EPIPE : :: c_int = 32 ;
511
- pub const ERANGE : :: c_int = 34 ;
515
+ pub const ERANGE : :: c_int = 38 ;
512
516
513
517
// ERRNO STUFF
514
518
pub const EPERM : :: c_int = 1 ; /* Not owner */
@@ -647,16 +651,25 @@ pub const S_nfsLib_NFSERR_BADTYPE: ::c_int =
647
651
pub const S_nfsLib_NFSERR_JUKEBOX : :: c_int =
648
652
M_nfsStat | nfsstat:: NFSERR_JUKEBOX as :: c_int ;
649
653
650
- // IP Stuff? These are allll guesswork
654
+ // in.h
651
655
pub const IPPROTO_IP : :: c_int = 0 ;
652
- pub const IP_TTL : :: c_int = 4 ; // not sure if this is right
653
- pub const IP_ADD_MEMBERSHIP : :: c_int = 11 ;
654
- pub const IP_DROP_MEMBERSHIP : :: c_int = 12 ;
655
- pub const IPV6_V6ONLY : :: c_int = 26 ;
656
- pub const IP_MULTICAST_TTL : :: c_int = 33 ;
657
- pub const IP_MULTICAST_LOOP : :: c_int = 34 ;
658
- pub const IPV6_MULTICAST_LOOP : :: c_int = 19 ;
659
- pub const IPPROTO_IPV6 : :: c_int = 41 ; // or this one, for that matter
656
+ pub const IPPROTO_IPV6 : :: c_int = 41 ;
657
+
658
+ pub const IP_TTL : :: c_int = 4 ;
659
+ pub const IP_MULTICAST_IF : :: c_int = 9 ;
660
+ pub const IP_MULTICAST_TTL : :: c_int = 10 ;
661
+ pub const IP_MULTICAST_LOOP : :: c_int = 11 ;
662
+ pub const IP_ADD_MEMBERSHIP : :: c_int = 12 ;
663
+ pub const IP_DROP_MEMBERSHIP : :: c_int = 13 ;
664
+
665
+ // in6.h
666
+ pub const IPV6_V6ONLY : :: c_int = 1 ;
667
+ pub const IPV6_UNICAST_HOPS : :: c_int = 4 ;
668
+ pub const IPV6_MULTICAST_IF : :: c_int = 9 ;
669
+ pub const IPV6_MULTICAST_HOPS : :: c_int = 10 ;
670
+ pub const IPV6_MULTICAST_LOOP : :: c_int = 11 ;
671
+ pub const IPV6_ADD_MEMBERSHIP : :: c_int = 12 ;
672
+ pub const IPV6_DROP_MEMBERSHIP : :: c_int = 13 ;
660
673
661
674
// STAT Stuff
662
675
pub const S_IFMT : :: c_int = 0xf000 ;
@@ -685,21 +698,39 @@ pub const S_IWOTH: ::c_int = 0x0002;
685
698
pub const S_IXOTH : :: c_int = 0x0001 ;
686
699
pub const S_IRWXO : :: c_int = 0x0007 ;
687
700
701
+ // socket.h
688
702
pub const SOL_SOCKET : :: c_int = 0xffff ;
689
- pub const SO_BROADCAST : :: c_int = 0x001e ;
690
- pub const SO_SNDTIMEO : :: c_int = 0x1005 ;
691
- pub const SO_RCVTIMEO : :: c_int = 0x1006 ;
703
+
704
+ pub const SO_DEBUG : :: c_int = 0x0001 ;
705
+ pub const SO_REUSEADDR : :: c_int = 0x0004 ;
706
+ pub const SO_KEEPALIVE : :: c_int = 0x0008 ;
707
+ pub const SO_DONTROUTE : :: c_int = 0x0010 ;
708
+ pub const SO_RCVLOWAT : :: c_int = 0x0012 ;
709
+ pub const SO_SNDLOWAT : :: c_int = 0x0013 ;
710
+ pub const SO_SNDTIMEO : :: c_int = 0x1005 ;
711
+ pub const SO_ACCEPTCONN : :: c_int = 0x001e ;
712
+ pub const SO_BROADCAST : :: c_int = 0x0020 ;
713
+ pub const SO_USELOOPBACK : :: c_int = 0x0040 ;
714
+ pub const SO_LINGER : :: c_int = 0x0080 ;
715
+ pub const SO_REUSEPORT : :: c_int = 0x0200 ;
716
+
717
+ pub const SO_VLAN : :: c_int = 0x8000 ;
718
+
719
+ pub const SO_SNDBUF : :: c_int = 0x1001 ;
720
+ pub const SO_RCVBUF : :: c_int = 0x1002 ;
721
+ pub const SO_RCVTIMEO : :: c_int = 0x1006 ;
722
+ pub const SO_ERROR : :: c_int = 0x1007 ;
723
+ pub const SO_TYPE : :: c_int = 0x1008 ;
724
+ pub const SO_BINDTODEVICE : :: c_int = 0x1010 ;
725
+ pub const SO_OOBINLINE : :: c_int = 0x1011 ;
726
+ pub const SO_CONNTIMEO : :: c_int = 0x100a ;
727
+
692
728
pub const SOCK_STREAM : :: c_int = 1 ;
693
729
pub const SOCK_DGRAM : :: c_int = 2 ;
694
730
pub const SOCK_RAW : :: c_int = 3 ;
695
731
pub const SOCK_RDM : :: c_int = 4 ;
696
732
pub const SOCK_SEQPACKET : :: c_int = 5 ;
697
733
pub const SOCK_PACKET : :: c_int = 10 ;
698
- pub const SO_DEBUG : :: c_int = 0x0001 ;
699
- pub const SO_REUSEADDR : :: c_int = 0x0004 ;
700
- pub const SO_KEEPALIVE : :: c_int = 0x0008 ;
701
- pub const SO_DONTROUTE : :: c_int = 0x0010 ;
702
- pub const SO_RCVLOWAT : :: c_int = 0x0012 ;
703
734
704
735
pub const _SS_MAXSIZE: usize = 128 ;
705
736
pub const _SS_ALIGNSIZE: usize = size_of :: < u32 > ( ) ;
@@ -753,7 +784,6 @@ pub const TCP_NOPUSH: ::c_int = 3;
753
784
pub const TCP_KEEPIDLE : :: c_int = 4 ;
754
785
pub const TCP_KEEPINTVL : :: c_int = 5 ;
755
786
pub const TCP_KEEPCNT : :: c_int = 6 ;
756
- pub const SO_ERROR : :: c_int = 4 ;
757
787
758
788
// IO Lib Definitions:
759
789
@@ -772,7 +802,7 @@ pub const FIOWRITE: ::c_int = 12;
772
802
pub const FIODISKCHANGE : :: c_int = 13 ;
773
803
pub const FIOCANCEL : :: c_int = 14 ;
774
804
pub const FIOSQUEEZE : :: c_int = 15 ;
775
- pub const FIONBIO : :: c_int = - 1878786032 ; // it goes on ...
805
+ pub const FIONBIO : :: c_int = 16 ;
776
806
pub const _POSIX_PATH_MAX: :: c_int = 256 ;
777
807
778
808
// Some poll stuff
@@ -814,8 +844,6 @@ pub const DT_WHT: ::c_uchar = 0xE;
814
844
815
845
// Other Random Stuff
816
846
pub const VXSIM_EWOULDBLOCK : :: c_int = 70 ;
817
- pub const IPV6_ADD_MEMBERSHIP : :: c_int = 20 ;
818
- pub const IPV6_DROP_MEMBERSHIP : :: c_int = 21 ;
819
847
820
848
pub const SIG_DFL : sighandler_t = 0 as sighandler_t ;
821
849
pub const SIG_IGN : sighandler_t = 1 as sighandler_t ;
@@ -1288,6 +1316,15 @@ extern "C" {
1288
1316
) -> * mut :: c_void ;
1289
1317
pub fn dlclose ( handle : * mut :: c_void ) -> :: c_int ;
1290
1318
pub fn res_init ( ) -> :: c_int ;
1319
+
1320
+ // time.h
1321
+ pub fn gmtime_r ( time_p : * const time_t , result : * mut tm ) -> * mut tm ;
1322
+ pub fn localtime_r ( time_p : * const time_t , result : * mut tm ) -> * mut tm ;
1323
+ pub fn mktime ( tm : * mut tm ) -> time_t ;
1324
+ pub fn time ( time : * mut time_t ) -> time_t ;
1325
+ pub fn gmtime ( time_p : * const time_t ) -> * mut tm ;
1326
+ pub fn localtime ( time_p : * const time_t ) -> * mut tm ;
1327
+ pub fn timegm ( tm : * mut tm ) -> time_t ;
1291
1328
pub fn difftime ( time1 : time_t , time0 : time_t ) -> :: c_double ;
1292
1329
1293
1330
pub fn mknod (
@@ -1894,7 +1931,7 @@ extern "C" {
1894
1931
pub fn closedir ( ptr : * mut :: DIR ) -> :: c_int ;
1895
1932
1896
1933
pub fn pwrite64 (
1897
- fd : :: c_int , // if you want to use fd, you gotta fix these
1934
+ fd : :: c_int ,
1898
1935
buf : * const :: c_void ,
1899
1936
count : :: size_t ,
1900
1937
offset : off64_t ,
0 commit comments