1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

os_linux.v

This commit is contained in:
Alexander Medvednikov
2019-11-15 03:17:47 +03:00
parent 1dadf9d966
commit d1b8d34dd5
7 changed files with 84 additions and 27 deletions

View File

@ -1,28 +1,9 @@
module builtin
pub fn syscall5(number, arg1, arg2, arg3, arg4, arg5 voidptr) voidptr
// TODO no pub => error
pub fn write(fd int, data voidptr, nbytes int) int {
return syscall5(
1, // SYS_write
fd,
data,
nbytes,
0, // ignored
0 // ignored
)
}
pub fn println(s string) {
write(1, s.str, s.len)
}
//pub fn syscall5(number, arg1, arg2, arg3, arg4, arg5 voidptr) voidptr
//pub fn syscall6(number, arg1, arg2, arg3, arg4, arg5, arg6 voidptr) voidptr
pub fn panic(s string) {
write(1, s.str, s.len)
//write(1, s.str, s.len)
}
pub fn malloc(n int) voidptr {
return syscall5(0,0,0,0,0,0)
}

View File

@ -24,12 +24,14 @@ pub fn tos(s byteptr, len int) string {
}
}
/*
pub fn tos_clone(s byteptr) string {
if s == 0 {
panic('tos: nil string')
}
return tos2(s).clone()
}
*/
// Same as `tos`, but calculates the length. Called by `string(bytes)` casts.
// Used only internally.
@ -53,6 +55,7 @@ pub fn tos3(s *C.char) string {
}
}
/*
pub fn (a string) clone() string {
mut b := string {
len: a.len
@ -64,3 +67,4 @@ pub fn (a string) clone() string {
b[a.len] = `\0`
return b
}
*/