mirror of
https://github.com/vlang/v.git
synced 2025-09-08 23:07:19 -04:00
os: make minior improvement to C function semantics and related code (#21565)
This commit is contained in:
parent
a7cf1ad7d5
commit
25be36296e
@ -61,9 +61,9 @@ pub const s_iwoth = 0o0002 // Write by others
|
||||
|
||||
pub const s_ixoth = 0o0001
|
||||
|
||||
fn C.utime(&char, voidptr) int
|
||||
fn C.utime(&char, &C.utimbuf) int
|
||||
|
||||
fn C.uname(name voidptr) int
|
||||
fn C.uname(name &C.utsname) int
|
||||
|
||||
fn C.symlink(&char, &char) int
|
||||
|
||||
@ -215,7 +215,7 @@ fn native_glob_pattern(pattern string, mut matches []string) ! {
|
||||
|
||||
pub fn utime(path string, actime int, modtime int) ! {
|
||||
u := C.utimbuf{actime, modtime}
|
||||
if C.utime(&char(path.str), voidptr(&u)) != 0 {
|
||||
if C.utime(&char(path.str), &u) != 0 {
|
||||
return error_with_code(posix_get_error_msg(C.errno), C.errno)
|
||||
}
|
||||
}
|
||||
@ -238,10 +238,8 @@ pub fn utime(path string, actime int, modtime int) ! {
|
||||
// See also https://pubs.opengroup.org/onlinepubs/7908799/xsh/sysutsname.h.html
|
||||
pub fn uname() Uname {
|
||||
mut u := Uname{}
|
||||
utsize := sizeof(C.utsname)
|
||||
unsafe {
|
||||
x := malloc_noscan(int(utsize))
|
||||
d := &C.utsname(x)
|
||||
d := &C.utsname(malloc_noscan(int(sizeof(C.utsname))))
|
||||
if C.uname(d) == 0 {
|
||||
u.sysname = cstring_to_vstring(d.sysname)
|
||||
u.nodename = cstring_to_vstring(d.nodename)
|
||||
|
Loading…
x
Reference in New Issue
Block a user