From 3aecdeab633403d592cebc010566b25a6245c8b8 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sat, 6 Jun 2020 18:25:58 +0300 Subject: [PATCH] os,gl,sync: cleanup, prepare for .toplevel_comments vdoc mode --- vlib/gl/1shader.v | 3 +- vlib/os/os.v | 71 ----------------------------------------------- vlib/os/os_c.v | 36 ++++++++++++++++++++++++ vlib/sync/pool.v | 4 ++- 4 files changed, 41 insertions(+), 73 deletions(-) create mode 100644 vlib/os/os_c.v diff --git a/vlib/gl/1shader.v b/vlib/gl/1shader.v index f716c0ff2d..ad1b983d03 100644 --- a/vlib/gl/1shader.v +++ b/vlib/gl/1shader.v @@ -4,10 +4,11 @@ module gl -// import os import gx import glm +// import os + // import darwin pub struct Shader { diff --git a/vlib/os/os.v b/vlib/os/os.v index f8c1e1b319..bfdc2130dc 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -3,25 +3,6 @@ // that can be found in the LICENSE file. module os -#include // #include -#include - -/* -struct dirent { - d_ino int - d_off int - d_reclen u16 - d_type byte - d_name [256]byte -} -*/ - -struct C.dirent { - d_name byteptr -} - -fn C.readdir(voidptr) C.dirent - pub const ( args = []string{} max_path_len = 4096 @@ -40,39 +21,6 @@ struct FileInfo { size int } -struct C.stat { - st_size int - st_mode u32 - st_mtime int -} - -struct C.DIR {} - -// struct C.dirent { -// d_name byteptr -// } -struct C.sigaction { -mut: - sa_mask int - sa_sigaction int - sa_flags int -} - -fn C.getline(voidptr, voidptr, voidptr) int - - -fn C.ftell(fp voidptr) int - - -fn C.sigaction(int, voidptr, int) - - -fn C.open(charptr, int, int) int - - -fn C.fdopen(int, string) voidptr - - pub fn (f File) is_opened() bool { return f.opened } @@ -206,7 +154,6 @@ pub fn mv(old, new string) { } } -fn C.CopyFile(&u32, &u32, int) int pub fn cp(old, new string) ?bool { $if windows { w_old := old.replace('/', '\\') @@ -480,11 +427,6 @@ fn vpclose(f voidptr) int { } } -struct Foo2 { - x int - -} - pub struct Result { pub: exit_code int @@ -950,13 +892,6 @@ pub fn on_segfault(f voidptr) { } } -fn C.getpid() int - - -//fn C.proc_pidpath(int, byteptr, int) int - - -fn C.readlink() int // executable returns the path name of the executable that started the current // process. pub fn executable() string { @@ -1230,12 +1165,6 @@ pub fn signal(signum int, handler voidptr) { C.signal(signum, handler) } -fn C.fork() int - - -fn C.wait() int - - pub fn fork() int { mut pid := -1 $if !windows { diff --git a/vlib/os/os_c.v b/vlib/os/os_c.v new file mode 100644 index 0000000000..dd131cf43e --- /dev/null +++ b/vlib/os/os_c.v @@ -0,0 +1,36 @@ +module os + +#include // #include +#include + +fn C.readdir(voidptr) C.dirent +fn C.getpid() int +fn C.readlink() int +fn C.getline(voidptr, voidptr, voidptr) int +fn C.ftell(fp voidptr) int +fn C.sigaction(int, voidptr, int) +fn C.open(charptr, int, int) int +fn C.fdopen(int, string) voidptr +fn C.CopyFile(&u32, &u32, int) int +fn C.fork() int +fn C.wait() int +//fn C.proc_pidpath(int, byteptr, int) int + +struct C.stat { + st_size int + st_mode u32 + st_mtime int +} + +struct C.DIR {} + +struct C.sigaction { +mut: + sa_mask int + sa_sigaction int + sa_flags int +} + +struct C.dirent { + d_name byteptr +} diff --git a/vlib/sync/pool.v b/vlib/sync/pool.v index 7e2cb5834d..6acbc33f9d 100644 --- a/vlib/sync/pool.v +++ b/vlib/sync/pool.v @@ -1,4 +1,7 @@ module sync + +import runtime + // * Goal: this file provides a convenient way to run identical tasks over a list // * of items in parallel, without worrying about waitgroups, mutexes and so on. // * @@ -36,7 +39,6 @@ module sync // * 2) idx - the index of the currently processed item // * 3) task_id - the index of the worker thread in which the callback // * function is running. -import runtime pub const ( no_result = voidptr(0)