@@ -29,9 +29,9 @@ pub mod os;
29
29
pub mod path;
30
30
pub mod pipe;
31
31
pub mod process;
32
+ pub mod stdio;
32
33
pub mod thread;
33
34
pub mod time;
34
- pub mod stdio;
35
35
36
36
#[ path = "../unix/os_str.rs" ]
37
37
pub mod os_str;
@@ -42,31 +42,50 @@ pub mod rwlock;
42
42
pub mod thread_local_dtor;
43
43
pub mod thread_local_key;
44
44
45
+ #[ cfg( not( target_feature = "static-syscalls" ) ) ]
45
46
extern "C" {
46
47
fn abort ( ) -> !;
47
48
#[ allow( improper_ctypes) ]
48
49
fn custom_panic ( info : & core:: panic:: PanicInfo < ' _ > ) ;
49
50
fn sol_log_ ( message : * const u8 , length : u64 ) ;
50
51
}
51
52
53
+ #[ cfg( target_feature = "static-syscalls" ) ]
54
+ unsafe extern "C" fn abort ( ) -> ! {
55
+ let syscall: extern "C" fn ( ) -> ! = core:: mem:: transmute ( 3069975057u64 ) ; // murmur32 hash of "abort"
56
+ syscall ( )
57
+ }
58
+
59
+ #[ cfg( target_feature = "static-syscalls" ) ]
60
+ unsafe extern "C" fn sol_log_ ( message : * const u8 , length : u64 ) {
61
+ let syscall: extern "C" fn ( * const u8 , u64 ) = core:: mem:: transmute ( 544561597u64 ) ; // murmur32 hash of "sol_log_"
62
+ syscall ( message, length)
63
+ }
64
+
52
65
pub fn sol_log ( message : & [ u8 ] ) {
53
66
unsafe {
54
67
sol_log_ ( message. as_ptr ( ) , message. len ( ) as u64 ) ;
55
68
}
56
69
}
57
70
58
71
pub fn panic ( info : & core:: panic:: PanicInfo < ' _ > ) -> ! {
59
- unsafe { custom_panic ( info) ; }
60
- unsafe { abort ( ) ; }
72
+ unsafe {
73
+ #[ cfg( not( target_feature = "static-syscalls" ) ) ]
74
+ custom_panic ( info) ;
75
+
76
+ #[ cfg( target_feature = "static-syscalls" ) ]
77
+ sol_log ( info. to_string ( ) . as_bytes ( ) ) ;
78
+
79
+ abort ( ) ;
80
+ }
61
81
}
62
82
63
83
pub fn unsupported < T > ( ) -> crate :: io:: Result < T > {
64
84
Err ( unsupported_err ( ) )
65
85
}
66
86
67
87
pub fn unsupported_err ( ) -> crate :: io:: Error {
68
- crate :: io:: Error :: new ( crate :: io:: ErrorKind :: Other ,
69
- "operation not supported on SBF yet" )
88
+ crate :: io:: Error :: new ( crate :: io:: ErrorKind :: Other , "operation not supported on SBF yet" )
70
89
}
71
90
72
91
pub fn decode_error_kind ( _code : i32 ) -> crate :: io:: ErrorKind {
@@ -84,7 +103,7 @@ pub unsafe fn strlen(mut s: *const c_char) -> usize {
84
103
n += 1 ;
85
104
s = s. offset ( 1 ) ;
86
105
}
87
- return n
106
+ return n;
88
107
}
89
108
90
109
pub fn abort_internal ( ) -> ! {
0 commit comments