Skip to content

Commit cc220e6

Browse files
authored
vlib: change byte to u8 (#19930)
1 parent 53e1e5e commit cc220e6

22 files changed

+39
-45
lines changed

vlib/builtin/linux_bare/memory_managment.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module builtin
22

33
import dlmalloc
44

5-
fn mm_alloc(size u64) (&byte, Errno) {
5+
fn mm_alloc(size u64) (&u8, Errno) {
66
// BEGIN CONSTS
77
// the constants need to be here, since the initialization of other constants,
88
// which happen before these ones would, require malloc

vlib/builtin/linux_bare/old/linuxsys_bare.v

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,16 @@ fn split_int_errno(rc_in u64) (i64, Errno) {
337337
}
338338

339339
// 0 sys_read unsigned int fd char *buf size_t count
340-
pub fn sys_read(fd i64, buf &byte, count u64) (i64, Errno) {
340+
pub fn sys_read(fd i64, buf &u8, count u64) (i64, Errno) {
341341
return split_int_errno(sys_call3(0, u64(fd), u64(buf), count))
342342
}
343343

344344
// 1 sys_write unsigned int fd, const char *buf, size_t count
345-
pub fn sys_write(fd i64, buf &byte, count u64) (i64, Errno) {
345+
pub fn sys_write(fd i64, buf &u8, count u64) (i64, Errno) {
346346
return split_int_errno(sys_call3(1, u64(fd), u64(buf), count))
347347
}
348348

349-
pub fn sys_open(filename &byte, flags i64, mode int) (i64, Errno) {
349+
pub fn sys_open(filename &u8, flags i64, mode int) (i64, Errno) {
350350
// 2 sys_open const char *filename int flags int mode
351351
return split_int_errno(sys_call3(2, u64(filename), u64(flags), u64(mode)))
352352
}
@@ -357,7 +357,7 @@ pub fn sys_close(fd i64) Errno {
357357
}
358358

359359
// 9 sys_mmap unsigned long addr unsigned long len unsigned long prot unsigned long flags unsigned long fd unsigned long off
360-
pub fn sys_mmap(addr &byte, len u64, prot Mm_prot, flags Map_flags, fildes u64, off u64) (&byte, Errno) {
360+
pub fn sys_mmap(addr &u8, len u64, prot Mm_prot, flags Map_flags, fildes u64, off u64) (&u8, Errno) {
361361
rc := sys_call6(9, u64(addr), len, u64(prot), u64(flags), fildes, off)
362362
a, e := split_int_errno(rc)
363363
return &u8(a), e

vlib/builtin/linux_bare/old/mm_bare.v

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn mm_pages(size u64) u32 {
1111
return u32(pages)
1212
}
1313

14-
pub fn mm_alloc(size u64) (&byte, Errno) {
14+
pub fn mm_alloc(size u64) (&u8, Errno) {
1515
pages := mm_pages(size)
1616
n_bytes := u64(pages * u32(Linux_mem.page_size))
1717

@@ -24,7 +24,7 @@ pub fn mm_alloc(size u64) (&byte, Errno) {
2424
return &u8(0), e
2525
}
2626

27-
pub fn mm_free(addr &byte) Errno {
27+
pub fn mm_free(addr &u8) Errno {
2828
ap := &int(addr - 4)
2929
size := u64(*ap) * u64(Linux_mem.page_size)
3030

@@ -41,7 +41,7 @@ pub fn mem_copy(dest0 voidptr, src0 voidptr, n isize) voidptr {
4141
}
4242

4343
@[unsafe]
44-
pub fn malloc(n isize) &byte {
44+
pub fn malloc(n isize) &u8 {
4545
if n < 0 {
4646
panic('malloc(<0)')
4747
}

vlib/builtin/linux_bare/old/string_bare.v

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ module builtin
22

33
pub struct string {
44
pub:
5-
str &byte
5+
str &u8
66
len int
77
}
88

9-
pub fn strlen(s &byte) int {
9+
pub fn strlen(s &u8) int {
1010
mut i := 0
1111
for ; s[i] != 0; i++ {}
1212
return i
1313
}
1414

15-
pub fn tos(s &byte, len int) string {
15+
pub fn tos(s &u8, len int) string {
1616
if s == 0 {
1717
panic('tos(): nil string')
1818
}
@@ -49,7 +49,7 @@ pub fn tos_clone(s byteptr) string {
4949

5050
// Same as `tos`, but calculates the length. Called by `string(bytes)` casts.
5151
// Used only internally.
52-
pub fn tos2(s &byte) string {
52+
pub fn tos2(s &u8) string {
5353
if s == 0 {
5454
panic('tos2: nil string')
5555
}
@@ -85,7 +85,7 @@ pub fn string_ne(s1 string, s2 string) bool {
8585
return !string_eq(s1, s2)
8686
}
8787

88-
pub fn i64_tos(buf &byte, len int, n0 i64, base int) string {
88+
pub fn i64_tos(buf &u8, len int, n0 i64, base int) string {
8989
if base < 2 {
9090
panic('base must be >= 2')
9191
}

vlib/builtin/map.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module builtin
22

3-
fn C.wyhash(&byte, u64, u64, &u64) u64
3+
fn C.wyhash(&u8, u64, u64, &u64) u64
44

55
fn C.wyhash64(u64, u64) u64
66

vlib/builtin/wasm_bare/libc_impl.c.v

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,11 @@ fn memcmp(a &C.void, b &C.void, n usize) int {
105105
return 0
106106
}
107107

108-
fn vsprintf(str &char, format &char, ap &byte) int {
108+
fn vsprintf(str &char, format &char, ap &u8) int {
109109
panic('vsprintf(): string interpolation is not supported in `-freestanding`')
110110
}
111111

112-
fn vsnprintf(str &char, size usize, format &char, ap &byte) int {
112+
fn vsnprintf(str &char, size usize, format &char, ap &u8) int {
113113
panic('vsnprintf(): string interpolation is not supported in `-freestanding`')
114114
}
115115

@@ -119,17 +119,17 @@ enum Errno {
119119
}
120120

121121
// not really needed
122-
fn bare_read(buf &byte, count u64) (i64, Errno) {
122+
fn bare_read(buf &u8, count u64) (i64, Errno) {
123123
return 0, Errno.eerror
124124
}
125125

126-
pub fn bare_print(buf &byte, len u64) {
126+
pub fn bare_print(buf &u8, len u64) {
127127
}
128128

129-
fn bare_eprint(buf &byte, len u64) {
129+
fn bare_eprint(buf &u8, len u64) {
130130
}
131131

132-
pub fn write(_fd i64, _buf &byte, _count u64) i64 {
132+
pub fn write(_fd i64, _buf &u8, _count u64) i64 {
133133
return -1
134134
}
135135

vlib/crypto/rand/rand_freebsd.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module rand
66

77
#include <stdlib.h>
88

9-
fn C.arc4random_buf(p &byte, n usize)
9+
fn C.arc4random_buf(p &u8, n usize)
1010

1111
// read returns an array of `bytes_needed` random bytes read from the OS.
1212
pub fn read(bytes_needed int) ![]u8 {

vlib/crypto/rand/rand_openbsd.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module rand
66

77
#include <stdlib.h>
88

9-
fn C.arc4random_buf(p &byte, n usize)
9+
fn C.arc4random_buf(p &u8, n usize)
1010

1111
// read returns an array of `bytes_needed` random bytes read from the OS.
1212
pub fn read(bytes_needed int) ![]u8 {

vlib/crypto/rand/rand_solaris.c.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module rand
66

77
#include <sys/random.h>
88

9-
fn C.getrandom(p &byte, n usize, flags u32) int
9+
fn C.getrandom(p &u8, n usize, flags u32) int
1010

1111
const (
1212
read_batch_size = 256

vlib/encoding/base32/base32.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ fn (enc &Encoding) decode_(src_ []u8, mut dst []u8) !(int, bool) {
351351

352352
// strip_newlines removes newline characters and returns the number
353353
// of non-newline characters copied to dst.
354-
// fn strip_newlines(mut dst []u8, src []byte) int {
354+
// fn strip_newlines(mut dst []u8, src []u8) int {
355355
// mut offset := 0
356356
// for b in src {
357357
// if b in [`\r`, `\n`] {

0 commit comments

Comments
 (0)