File tree 1 file changed +19
-3
lines changed
library/std/src/sys/pal/safaos 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,21 @@ fn syscall1(num: usize, arg1: usize) -> ErrorStatus {
55
55
56
56
crate :: mem:: transmute ( result)
57
57
}
58
+ }
59
+
60
+ fn syscall2 ( num : usize , arg1 : usize , arg2 : usize ) -> ErrorStatus {
61
+ let result: u16 ;
62
+ unsafe {
63
+ asm ! (
64
+ "int 0x80" ,
65
+ in( "rax" ) num,
66
+ in( "rdi" ) arg1,
67
+ in( "rsi" ) arg2,
68
+ lateout( "rax" ) result,
69
+ ) ;
58
70
71
+ crate :: mem:: transmute ( result)
72
+ }
59
73
}
60
74
61
75
fn syscall5 (
@@ -97,7 +111,9 @@ pub fn syssync(fd: usize) -> ErrorStatus {
97
111
syscall1 ( 0x10 , fd)
98
112
}
99
113
100
-
101
114
pub fn syssbrk ( size : isize ) -> Result < * mut u8 , ErrorStatus > {
102
- todo ! ( )
103
- }
115
+ let mut target_ptr: * mut u8 = core:: ptr:: null_mut ( ) ;
116
+ let err = syscall2 ( 0x12 , size as usize , ( & mut target_ptr) as * mut _ as usize ) ;
117
+
118
+ if err != ErrorStatus :: None { Err ( err) } else { Ok ( target_ptr) }
119
+ }
You can’t perform that action at this time.
0 commit comments