1+ // Copyright (c) 2019 Wind River Systems, Inc.
12//! Interface to VxWorks C library
23
34use core:: mem:: size_of;
@@ -12,6 +13,9 @@ impl ::Clone for DIR {
1213 }
1314}
1415
16+ // Throughout we use usize / isize for types that are
17+ // (unsigned) int in ILP32 and (unsigned) long in ILP64
18+
1519pub type c_schar = i8 ;
1620pub type c_uchar = u8 ;
1721pub type c_short = i16 ;
@@ -80,9 +84,9 @@ pub type off64_t = ::c_longlong;
8084pub type off_t64 = :: c_longlong ;
8185
8286// From b_BOOL.h
83- pub type BOOL = :: c_int ; // excuse me what
87+ pub type BOOL = :: c_int ;
8488
85- //Straight from vxWind.h ..
89+ // From vxWind.h ..
8690pub type _Vx_OBJ_HANDLE = :: c_int ;
8791pub type _Vx_TASK_ID = :: _Vx_OBJ_HANDLE ;
8892pub type _Vx_MSG_Q_ID = :: _Vx_OBJ_HANDLE ;
@@ -100,8 +104,8 @@ pub type SD_ID = ::OBJ_HANDLE;
100104pub type CONDVAR_ID = :: OBJ_HANDLE ;
101105
102106// 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 ;
105109pub type _Vx_ticks_t = :: c_uint ;
106110pub type _Vx_ticks64_t = :: c_ulonglong ;
107111
@@ -112,25 +116,7 @@ pub type sa_family_t = ::c_uchar;
112116
113117// structs that only exist in userspace
114118s ! {
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 { }
134120
135121 // b_pthread_condattr_t.h
136122 pub struct pthread_condattr_t {
@@ -173,6 +159,11 @@ s! {
173159 }
174160
175161 // socket.h
162+ pub struct linger {
163+ pub l_onoff: :: c_int,
164+ pub l_linger: :: c_int,
165+ }
166+
176167 pub struct sockaddr {
177168 pub sa_len : :: c_uchar,
178169 pub sa_family : sa_family_t,
@@ -361,6 +352,19 @@ s! {
361352 pub tv_nsec: :: c_long,
362353 }
363354
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+
364368 // in.h
365369 pub struct in_addr {
366370 pub s_addr: in_addr_t,
@@ -476,7 +480,7 @@ pub const EAI_SYSTEM: ::c_int = 11;
476480
477481pub const RTLD_DEFAULT : * mut :: c_void = 0i64 as * mut :: c_void ;
478482
479- //Clock Lib Stuff
483+ // Clock Lib Stuff
480484pub const CLOCK_REALTIME : :: c_int = 0x0 ;
481485pub const CLOCK_MONOTONIC : :: c_int = 0x1 ;
482486pub const CLOCK_PROCESS_CPUTIME_ID : :: c_int = 0x2 ;
@@ -508,7 +512,7 @@ pub const EEXIST: ::c_int = 17;
508512pub const ENODEV : :: c_int = 19 ;
509513pub const EINVAL : :: c_int = 22 ;
510514pub const EPIPE : :: c_int = 32 ;
511- pub const ERANGE : :: c_int = 34 ;
515+ pub const ERANGE : :: c_int = 38 ;
512516
513517// ERRNO STUFF
514518pub const EPERM : :: c_int = 1 ; /* Not owner */
@@ -647,16 +651,25 @@ pub const S_nfsLib_NFSERR_BADTYPE: ::c_int =
647651pub const S_nfsLib_NFSERR_JUKEBOX : :: c_int =
648652 M_nfsStat | nfsstat:: NFSERR_JUKEBOX as :: c_int ;
649653
650- // IP Stuff? These are allll guesswork
654+ // in.h
651655pub 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 ;
660673
661674// STAT Stuff
662675pub const S_IFMT : :: c_int = 0xf000 ;
@@ -685,21 +698,39 @@ pub const S_IWOTH: ::c_int = 0x0002;
685698pub const S_IXOTH : :: c_int = 0x0001 ;
686699pub const S_IRWXO : :: c_int = 0x0007 ;
687700
701+ // socket.h
688702pub 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+
692728pub const SOCK_STREAM : :: c_int = 1 ;
693729pub const SOCK_DGRAM : :: c_int = 2 ;
694730pub const SOCK_RAW : :: c_int = 3 ;
695731pub const SOCK_RDM : :: c_int = 4 ;
696732pub const SOCK_SEQPACKET : :: c_int = 5 ;
697733pub 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 ;
703734
704735pub const _SS_MAXSIZE: usize = 128 ;
705736pub const _SS_ALIGNSIZE: usize = size_of :: < u32 > ( ) ;
@@ -753,7 +784,6 @@ pub const TCP_NOPUSH: ::c_int = 3;
753784pub const TCP_KEEPIDLE : :: c_int = 4 ;
754785pub const TCP_KEEPINTVL : :: c_int = 5 ;
755786pub const TCP_KEEPCNT : :: c_int = 6 ;
756- pub const SO_ERROR : :: c_int = 4 ;
757787
758788// IO Lib Definitions:
759789
@@ -772,7 +802,7 @@ pub const FIOWRITE: ::c_int = 12;
772802pub const FIODISKCHANGE : :: c_int = 13 ;
773803pub const FIOCANCEL : :: c_int = 14 ;
774804pub const FIOSQUEEZE : :: c_int = 15 ;
775- pub const FIONBIO : :: c_int = - 1878786032 ; // it goes on ...
805+ pub const FIONBIO : :: c_int = 16 ;
776806pub const _POSIX_PATH_MAX: :: c_int = 256 ;
777807
778808// Some poll stuff
@@ -814,8 +844,6 @@ pub const DT_WHT: ::c_uchar = 0xE;
814844
815845// Other Random Stuff
816846pub const VXSIM_EWOULDBLOCK : :: c_int = 70 ;
817- pub const IPV6_ADD_MEMBERSHIP : :: c_int = 20 ;
818- pub const IPV6_DROP_MEMBERSHIP : :: c_int = 21 ;
819847
820848pub const SIG_DFL : sighandler_t = 0 as sighandler_t ;
821849pub const SIG_IGN : sighandler_t = 1 as sighandler_t ;
@@ -1288,6 +1316,15 @@ extern "C" {
12881316 ) -> * mut :: c_void ;
12891317 pub fn dlclose ( handle : * mut :: c_void ) -> :: c_int ;
12901318 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 ;
12911328 pub fn difftime ( time1 : time_t , time0 : time_t ) -> :: c_double ;
12921329
12931330 pub fn mknod (
@@ -1894,7 +1931,7 @@ extern "C" {
18941931 pub fn closedir ( ptr : * mut :: DIR ) -> :: c_int ;
18951932
18961933 pub fn pwrite64 (
1897- fd : :: c_int , // if you want to use fd, you gotta fix these
1934+ fd : :: c_int ,
18981935 buf : * const :: c_void ,
18991936 count : :: size_t ,
19001937 offset : off64_t ,
0 commit comments