@@ -37,7 +37,7 @@ cfg_if::cfg_if! {
37
37
}
38
38
39
39
extern "C" {
40
- #[ cfg( not( target_os = "dragonfly" ) ) ]
40
+ #[ cfg( not( any ( target_os = "dragonfly" , target_os = "vxworks" ) ) ) ]
41
41
#[ cfg_attr(
42
42
any(
43
43
target_os = "linux" ,
@@ -67,18 +67,28 @@ extern "C" {
67
67
}
68
68
69
69
/// Returns the platform-specific value of errno
70
- #[ cfg( not( target_os = "dragonfly" ) ) ]
70
+ #[ cfg( not( any ( target_os = "dragonfly" , target_os = "vxworks" ) ) ) ]
71
71
pub fn errno ( ) -> i32 {
72
72
unsafe { ( * errno_location ( ) ) as i32 }
73
73
}
74
74
75
75
/// 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!
77
77
#[ allow( dead_code) ] // but not all target cfgs actually end up using it
78
78
pub fn set_errno ( e : i32 ) {
79
79
unsafe { * errno_location ( ) = e as c_int }
80
80
}
81
81
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
+
82
92
#[ cfg( target_os = "dragonfly" ) ]
83
93
pub fn errno ( ) -> i32 {
84
94
extern "C" {
@@ -439,6 +449,19 @@ pub fn current_exe() -> io::Result<PathBuf> {
439
449
Err ( io:: Error :: new ( ErrorKind :: Other , "Not yet implemented!" ) )
440
450
}
441
451
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
+
442
465
pub struct Env {
443
466
iter : vec:: IntoIter < ( OsString , OsString ) > ,
444
467
_dont_send_or_sync_me : PhantomData < * mut ( ) > ,
@@ -568,7 +591,8 @@ pub fn home_dir() -> Option<PathBuf> {
568
591
target_os = "android" ,
569
592
target_os = "ios" ,
570
593
target_os = "emscripten" ,
571
- target_os = "redox"
594
+ target_os = "redox" ,
595
+ target_os = "vxworks"
572
596
) ) ]
573
597
unsafe fn fallback ( ) -> Option < OsString > {
574
598
None
@@ -577,7 +601,8 @@ pub fn home_dir() -> Option<PathBuf> {
577
601
target_os = "android" ,
578
602
target_os = "ios" ,
579
603
target_os = "emscripten" ,
580
- target_os = "redox"
604
+ target_os = "redox" ,
605
+ target_os = "vxworks"
581
606
) ) ) ]
582
607
unsafe fn fallback ( ) -> Option < OsString > {
583
608
let amt = match libc:: sysconf ( libc:: _SC_GETPW_R_SIZE_MAX) {
0 commit comments