File tree 2 files changed +18
-22
lines changed
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 {
67
67
}
68
68
69
69
/// 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!
71
72
pub fn set_errno ( e : i32 ) {
72
73
unsafe {
73
74
* errno_location ( ) = e as c_int
@@ -84,6 +85,18 @@ pub fn errno() -> i32 {
84
85
unsafe { errno as i32 }
85
86
}
86
87
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
+
87
100
/// Gets a detailed string description for the given error number.
88
101
pub fn error_string ( errno : i32 ) -> String {
89
102
extern {
Original file line number Diff line number Diff line change @@ -83,13 +83,15 @@ macro_rules! syscall {
83
83
( fn $name: ident( $( $arg_name: ident: $t: ty) ,* ) -> $ret: ty) => (
84
84
unsafe fn $name( $( $arg_name: $t) ,* ) -> $ret {
85
85
use libc;
86
+ use super :: os;
86
87
87
88
weak! { fn $name( $( $t) ,* ) -> $ret }
88
89
89
90
if let Some ( fun) = $name. get( ) {
90
91
fun( $( $arg_name) ,* )
91
92
} else {
92
- libc:: ENOSYS
93
+ os:: set_errno( libc:: ENOSYS ) ;
94
+ -1
93
95
}
94
96
}
95
97
)
@@ -105,27 +107,8 @@ macro_rules! syscall {
105
107
106
108
syscall(
107
109
concat_idents!( SYS_ , $name) ,
108
- $( :: sys :: weak :: SyscallParam :: to_param ( $arg_name) ) ,*
110
+ $( $arg_name as c_long ) ,*
109
111
) as $ret
110
112
}
111
113
)
112
114
}
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