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

os: move C struct declarations in their own _default.c.v files (#12268)

This commit is contained in:
Delyan Angelov
2021-10-22 17:08:08 +03:00
committed by GitHub
parent 0401b5ece0
commit eed94c727c
12 changed files with 78 additions and 55 deletions

View File

@@ -7,10 +7,6 @@ pub const (
args = []string{}
)
struct C.dirent {
d_name [256]char
}
fn C.readdir(voidptr) &C.dirent
fn C.readlink(pathname &char, buf &char, bufsiz usize) int
@@ -41,36 +37,6 @@ fn C.ftruncate(voidptr, u64) int
fn C._chsize_s(voidptr, u64) int
// fn C.proc_pidpath(int, byteptr, int) int
struct C.stat {
st_size u64
st_mode u32
st_mtime int
}
struct C.__stat64 {
st_size u64
st_mode u32
st_mtime int
}
struct C.DIR {
}
type FN_SA_Handler = fn (sig int)
struct C.sigaction {
mut:
sa_mask int
sa_sigaction int
sa_flags int
sa_handler FN_SA_Handler
}
struct C.dirent {
d_name &byte
}
// read_bytes returns all bytes read from file in `path`.
[manualfree]
pub fn read_bytes(path string) ?[]byte {
@@ -890,12 +856,12 @@ pub fn wait() int {
}
// file_last_mod_unix returns the "last modified" time stamp of file in `path`.
pub fn file_last_mod_unix(path string) int {
pub fn file_last_mod_unix(path string) i64 {
attr := C.stat{}
// # struct stat attr;
unsafe { C.stat(&char(path.str), &attr) }
// # stat(path.str, &attr);
return attr.st_mtime
return i64(attr.st_mtime)
// # return attr.st_mtime ;
}

View File

@@ -43,20 +43,6 @@ pub const (
s_ixoth = 0o0001 // Execute by others
)
struct C.utsname {
mut:
sysname &char
nodename &char
release &char
version &char
machine &char
}
struct C.utimbuf {
actime int
modtime int
}
fn C.utime(&char, voidptr) int
fn C.uname(name voidptr) int

View File

@@ -0,0 +1,5 @@
module os
struct C.dirent {
d_name [256]char
}

View File

@@ -0,0 +1,11 @@
module os
pub type FN_SA_Handler = fn (sig int)
struct C.sigaction {
mut:
sa_mask int
sa_sigaction int
sa_flags int
sa_handler FN_SA_Handler
}

View File

@@ -0,0 +1,13 @@
module os
struct C.stat {
st_size u64
st_mode u32
st_mtime int
}
struct C.__stat64 {
st_size u64
st_mode u32
st_mtime int
}

View File

@@ -0,0 +1,23 @@
module os
struct C.stat {
st_dev u64 // 8
st_ino u64 // 8
st_nlink u64 // 8
st_mode u32 // 4
st_uid u32 // 4
st_gid u32 // 4
st_rdev u64 // 8
st_size u64 // 8
st_blksize u64 // 8
st_blocks u64 // 8
st_atime i64 // 8
st_mtime i64 // 8
st_ctime i64 // 8
}
struct C.__stat64 {
st_mode u32
st_size u64
st_mtime u64
}

View File

@@ -0,0 +1,15 @@
module os
struct C.utsname {
mut:
sysname &char
nodename &char
release &char
version &char
machine &char
}
struct C.utimbuf {
actime int
modtime int
}