File tree Expand file tree Collapse file tree 2 files changed +18
-22
lines changed Expand file tree Collapse file tree 2 files changed +18
-22
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,8 @@ pub fn errno() -> i32 {
6767}
6868
6969/// Sets the platform-specific value of errno
70- #[ cfg( any( target_os = "solaris" , target_os = "fuchsia" ) ) ] // only needed for readdir so far
70+ #[ cfg( all( not( target_os = "linux" ) ,
71+ not( target_os = "dragonfly" ) ) ) ] // needed for readdir and syscall!
7172pub fn set_errno ( e : i32 ) {
7273 unsafe {
7374 * errno_location ( ) = e as c_int
@@ -84,6 +85,18 @@ pub fn errno() -> i32 {
8485 unsafe { errno as i32 }
8586}
8687
88+ #[ cfg( target_os = "dragonfly" ) ]
89+ pub fn set_errno ( e : i32 ) {
90+ extern {
91+ #[ thread_local]
92+ static mut errno: c_int ;
93+ }
94+
95+ unsafe {
96+ errno = e;
97+ }
98+ }
99+
87100/// Gets a detailed string description for the given error number.
88101pub fn error_string ( errno : i32 ) -> String {
89102 extern {
Original file line number Diff line number Diff line change @@ -83,13 +83,15 @@ macro_rules! syscall {
8383 ( fn $name: ident( $( $arg_name: ident: $t: ty) ,* ) -> $ret: ty) => (
8484 unsafe fn $name( $( $arg_name: $t) ,* ) -> $ret {
8585 use libc;
86+ use super :: os;
8687
8788 weak! { fn $name( $( $t) ,* ) -> $ret }
8889
8990 if let Some ( fun) = $name. get( ) {
9091 fun( $( $arg_name) ,* )
9192 } else {
92- libc:: ENOSYS
93+ os:: set_errno( libc:: ENOSYS ) ;
94+ -1
9395 }
9496 }
9597 )
@@ -105,27 +107,8 @@ macro_rules! syscall {
105107
106108 syscall(
107109 concat_idents!( SYS_ , $name) ,
108- $( :: sys :: weak :: SyscallParam :: to_param ( $arg_name) ) ,*
110+ $( $arg_name as c_long ) ,*
109111 ) as $ret
110112 }
111113 )
112114}
113-
114- #[ cfg( target_os = "linux" ) ]
115- pub trait SyscallParam {
116- fn to_param ( self ) -> libc:: c_long ;
117- }
118-
119- #[ cfg( target_os = "linux" ) ]
120- impl SyscallParam for libc:: c_int {
121- fn to_param ( self ) -> libc:: c_long {
122- self as libc:: c_long
123- }
124- }
125-
126- #[ cfg( target_os = "linux" ) ]
127- impl < T > SyscallParam for * mut T {
128- fn to_param ( self ) -> libc:: c_long {
129- unsafe { mem:: transmute ( self ) }
130- }
131- }
You can’t perform that action at this time.
0 commit comments