@@ -37,7 +37,7 @@ cfg_if::cfg_if! {
3737}
3838
3939extern "C" {
40- #[ cfg( not( target_os = "dragonfly" ) ) ]
40+ #[ cfg( not( any ( target_os = "dragonfly" , target_os = "vxworks" ) ) ) ]
4141 #[ cfg_attr(
4242 any(
4343 target_os = "linux" ,
@@ -67,18 +67,28 @@ extern "C" {
6767}
6868
6969/// Returns the platform-specific value of errno
70- #[ cfg( not( target_os = "dragonfly" ) ) ]
70+ #[ cfg( not( any ( target_os = "dragonfly" , target_os = "vxworks" ) ) ) ]
7171pub fn errno ( ) -> i32 {
7272 unsafe { ( * errno_location ( ) ) as i32 }
7373}
7474
7575/// Sets the platform-specific value of errno
76- #[ cfg( all( not( target_os = "linux" ) , not( target_os = "dragonfly" ) ) ) ] // needed for readdir and syscall!
76+ #[ cfg( all( not( target_os = "linux" ) , not( target_os = "dragonfly" ) , not ( target_os = "vxworks" ) ) ) ] // needed for readdir and syscall!
7777#[ allow( dead_code) ] // but not all target cfgs actually end up using it
7878pub fn set_errno ( e : i32 ) {
7979 unsafe { * errno_location ( ) = e as c_int }
8080}
8181
82+ #[ cfg( target_os = "vxworks" ) ]
83+ pub fn errno ( ) -> i32 {
84+ unsafe { libc:: errnoGet ( ) }
85+ }
86+
87+ #[ cfg( target_os = "vxworks" ) ]
88+ pub fn set_errno ( e : i32 ) {
89+ unsafe { libc:: errnoSet ( e as c_int ) } ;
90+ }
91+
8292#[ cfg( target_os = "dragonfly" ) ]
8393pub fn errno ( ) -> i32 {
8494 extern "C" {
@@ -439,6 +449,19 @@ pub fn current_exe() -> io::Result<PathBuf> {
439449 Err ( io:: Error :: new ( ErrorKind :: Other , "Not yet implemented!" ) )
440450}
441451
452+ #[ cfg( target_os = "vxworks" ) ]
453+ pub fn current_exe ( ) -> io:: Result < PathBuf > {
454+ #[ cfg( test) ]
455+ use realstd:: env;
456+
457+ #[ cfg( not( test) ) ]
458+ use crate :: env;
459+
460+ let exe_path = env:: args ( ) . next ( ) . unwrap ( ) ;
461+ let path = path:: Path :: new ( & exe_path) ;
462+ path. canonicalize ( )
463+ }
464+
442465pub struct Env {
443466 iter : vec:: IntoIter < ( OsString , OsString ) > ,
444467 _dont_send_or_sync_me : PhantomData < * mut ( ) > ,
@@ -568,7 +591,8 @@ pub fn home_dir() -> Option<PathBuf> {
568591 target_os = "android" ,
569592 target_os = "ios" ,
570593 target_os = "emscripten" ,
571- target_os = "redox"
594+ target_os = "redox" ,
595+ target_os = "vxworks"
572596 ) ) ]
573597 unsafe fn fallback ( ) -> Option < OsString > {
574598 None
@@ -577,7 +601,8 @@ pub fn home_dir() -> Option<PathBuf> {
577601 target_os = "android" ,
578602 target_os = "ios" ,
579603 target_os = "emscripten" ,
580- target_os = "redox"
604+ target_os = "redox" ,
605+ target_os = "vxworks"
581606 ) ) ) ]
582607 unsafe fn fallback ( ) -> Option < OsString > {
583608 let amt = match libc:: sysconf ( libc:: _SC_GETPW_R_SIZE_MAX) {
0 commit comments