mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
freestanding: sys_getuid, sys_waitid; minimal fork check; remove bare.S
This commit is contained in:

committed by
Alexander Medvednikov

parent
39655a7d9b
commit
a9aaa13a09
@@ -1,39 +0,0 @@
|
||||
.intel_syntax noprefix
|
||||
.text
|
||||
.globl _start, main__syscall5
|
||||
|
||||
_start:
|
||||
xor rbp,rbp
|
||||
pop rdi
|
||||
mov rsi,rsp
|
||||
and rsp,-16
|
||||
call main
|
||||
|
||||
mov rdi,rax /* syscall param 1 = rax (ret value of main) */
|
||||
mov rax,60 /* SYS_exit */
|
||||
syscall
|
||||
|
||||
ret /* should never be reached, but if the OS somehow fails
|
||||
to kill us, it will cause a segmentation fault */
|
||||
|
||||
main__syscall5:
|
||||
mov rax,rdi
|
||||
mov rdi,rsi
|
||||
mov rsi,rdx
|
||||
mov rdx,rcx
|
||||
mov r10,r8
|
||||
mov r8,r9
|
||||
syscall
|
||||
ret
|
||||
|
||||
main__syscall6:
|
||||
mov rax,rdi
|
||||
mov rdi,rsi
|
||||
mov rsi,rdx
|
||||
mov rdx,rcx
|
||||
mov r10,r8
|
||||
mov r8,r9
|
||||
mov r9, [rsp+8]
|
||||
syscall
|
||||
ret
|
||||
|
@@ -1,20 +1,7 @@
|
||||
fn syscall5(number, arg1, arg2, arg3, arg4, arg5 voidptr) voidptr
|
||||
|
||||
fn write(fd int, data voidptr, nbytes int) int {
|
||||
return syscall5(
|
||||
1, // SYS_write
|
||||
fd,
|
||||
data,
|
||||
nbytes,
|
||||
0, // ignored
|
||||
0 // ignored
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
write(1, c'hello\n', 6)
|
||||
s := 'test string'
|
||||
write(1, s.str, s.len)
|
||||
sys_write(1, 'hello\n'.str, 6)
|
||||
s := 'test string\n'
|
||||
sys_write(1, s.str, u64(s.len))
|
||||
a := s[0]
|
||||
println("Hello freestanding!")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user