mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
ci: fix some of v test-cleancode
3
This commit is contained in:
@ -337,16 +337,16 @@ fn split_int_errno(rc_in u64) (i64, Errno) {
|
||||
}
|
||||
|
||||
// 0 sys_read unsigned int fd char *buf size_t count
|
||||
pub fn sys_read(fd i64, buf byteptr, count u64) (i64, Errno) {
|
||||
pub fn sys_read(fd i64, buf &byte, count u64) (i64, Errno) {
|
||||
return split_int_errno(sys_call3(0, u64(fd), u64(buf), count))
|
||||
}
|
||||
|
||||
// 1 sys_write unsigned int fd, const char *buf, size_t count
|
||||
pub fn sys_write(fd i64, buf byteptr, count u64) (i64, Errno) {
|
||||
pub fn sys_write(fd i64, buf &byte, count u64) (i64, Errno) {
|
||||
return split_int_errno(sys_call3(1, u64(fd), u64(buf), count))
|
||||
}
|
||||
|
||||
pub fn sys_open(filename byteptr, flags i64, mode int) (i64, Errno) {
|
||||
pub fn sys_open(filename &byte, flags i64, mode int) (i64, Errno) {
|
||||
// 2 sys_open const char *filename int flags int mode
|
||||
return split_int_errno(sys_call3(2, u64(filename), u64(flags), u64(mode)))
|
||||
}
|
||||
@ -357,10 +357,10 @@ pub fn sys_close(fd i64) Errno {
|
||||
}
|
||||
|
||||
// 9 sys_mmap unsigned long addr unsigned long len unsigned long prot unsigned long flags unsigned long fd unsigned long off
|
||||
pub fn sys_mmap(addr byteptr, len u64, prot Mm_prot, flags Map_flags, fildes u64, off u64) (byteptr, Errno) {
|
||||
pub fn sys_mmap(addr &byte, len u64, prot Mm_prot, flags Map_flags, fildes u64, off u64) (&byte, Errno) {
|
||||
rc := sys_call6(9, u64(addr), len, u64(prot), u64(flags), fildes, off)
|
||||
a, e := split_int_errno(rc)
|
||||
return byteptr(a), e
|
||||
return &byte(a), e
|
||||
}
|
||||
|
||||
pub fn sys_munmap(addr voidptr, len u64) Errno {
|
||||
|
@ -11,7 +11,7 @@ pub fn mm_pages(size u64) u32 {
|
||||
return u32(pages)
|
||||
}
|
||||
|
||||
pub fn mm_alloc(size u64) (byteptr, Errno) {
|
||||
pub fn mm_alloc(size u64) (&byte, Errno) {
|
||||
pages := mm_pages(size)
|
||||
n_bytes := u64(pages * u32(Linux_mem.page_size))
|
||||
|
||||
@ -19,12 +19,12 @@ pub fn mm_alloc(size u64) (byteptr, Errno) {
|
||||
if e == .enoerror {
|
||||
mut ap := &int(a)
|
||||
*ap = pages
|
||||
return byteptr(a + 4), e
|
||||
return &byte(a + 4), e
|
||||
}
|
||||
return byteptr(0), e
|
||||
return &byte(0), e
|
||||
}
|
||||
|
||||
pub fn mm_free(addr byteptr) Errno {
|
||||
pub fn mm_free(addr &byte) Errno {
|
||||
ap := &int(addr - 4)
|
||||
size := u64(*ap) * u64(Linux_mem.page_size)
|
||||
|
||||
@ -32,8 +32,8 @@ pub fn mm_free(addr byteptr) Errno {
|
||||
}
|
||||
|
||||
pub fn mem_copy(dest0 voidptr, src0 voidptr, n int) voidptr {
|
||||
mut dest := byteptr(dest0)
|
||||
src := byteptr(src0)
|
||||
mut dest := &byte(dest0)
|
||||
src := &byte(src0)
|
||||
for i in 0 .. n {
|
||||
dest[i] = src[i]
|
||||
}
|
||||
@ -41,7 +41,7 @@ pub fn mem_copy(dest0 voidptr, src0 voidptr, n int) voidptr {
|
||||
}
|
||||
|
||||
[unsafe]
|
||||
pub fn malloc(n int) byteptr {
|
||||
pub fn malloc(n int) &byte {
|
||||
if n < 0 {
|
||||
panic('malloc(<0)')
|
||||
}
|
||||
|
@ -2,17 +2,17 @@ module builtin
|
||||
|
||||
pub struct string {
|
||||
pub:
|
||||
str byteptr
|
||||
str &byte
|
||||
len int
|
||||
}
|
||||
|
||||
pub fn strlen(s byteptr) int {
|
||||
pub fn strlen(s &byte) int {
|
||||
mut i := 0
|
||||
for ; s[i] != 0; i++ {}
|
||||
return i
|
||||
}
|
||||
|
||||
pub fn tos(s byteptr, len int) string {
|
||||
pub fn tos(s &byte, len int) string {
|
||||
if s == 0 {
|
||||
panic('tos(): nil string')
|
||||
}
|
||||
@ -49,7 +49,7 @@ pub fn tos_clone(s byteptr) string {
|
||||
|
||||
// Same as `tos`, but calculates the length. Called by `string(bytes)` casts.
|
||||
// Used only internally.
|
||||
pub fn tos2(s byteptr) string {
|
||||
pub fn tos2(s &byte) string {
|
||||
if s == 0 {
|
||||
panic('tos2: nil string')
|
||||
}
|
||||
@ -59,13 +59,13 @@ pub fn tos2(s byteptr) string {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tos3(s charptr) string {
|
||||
pub fn tos3(s &char) string {
|
||||
if s == 0 {
|
||||
panic('tos3: nil string')
|
||||
}
|
||||
return string{
|
||||
str: byteptr(s)
|
||||
len: strlen(byteptr(s))
|
||||
str: &byte(s)
|
||||
len: strlen(&byte(s))
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ pub fn string_ne(s1 string, s2 string) bool {
|
||||
return !string_eq(s1, s2)
|
||||
}
|
||||
|
||||
pub fn i64_tos(buf byteptr, len int, n0 i64, base int) string {
|
||||
pub fn i64_tos(buf &byte, len int, n0 i64, base int) string {
|
||||
if base < 2 {
|
||||
panic('base must be >= 2')
|
||||
}
|
||||
|
Reference in New Issue
Block a user