diff --git a/vlib/builtin/cfns.v b/vlib/builtin/cfns.v index ee9ca60a8d..a25dcb4096 100644 --- a/vlib/builtin/cfns.v +++ b/vlib/builtin/cfns.v @@ -21,7 +21,9 @@ fn C.strlen(s byteptr) int fn C.isdigit(s byteptr) bool // stdio.h fn C.popen(c byteptr, t byteptr) voidptr + // +// backtrace functions are not #included, that's why they have to be defined without C. fn backtrace(a voidptr, b int) int fn backtrace_symbols(voidptr, int) &byteptr diff --git a/vlib/os/os.v b/vlib/os/os.v index 5b9fb5a6bf..03ff9a9bd0 100644 --- a/vlib/os/os.v +++ b/vlib/os/os.v @@ -791,12 +791,15 @@ pub fn on_segfault(f voidptr) { return } $if macos { + C.printf("TODO") + /* mut sa := C.sigaction{} - C.memset(&sa, 0, sizeof(sigaction)) + C.memset(&sa, 0, sizeof(C.sigaction_size)) C.sigemptyset(&sa.sa_mask) sa.sa_sigaction = f sa.sa_flags = C.SA_SIGINFO C.sigaction(C.SIGSEGV, &sa, 0) + */ } } diff --git a/vlib/v/gen/cgen.v b/vlib/v/gen/cgen.v index be65c01d58..8276ef3226 100644 --- a/vlib/v/gen/cgen.v +++ b/vlib/v/gen/cgen.v @@ -100,7 +100,7 @@ pub fn (g mut Gen) typ(t table.Type) string { if styp.starts_with('C__') { styp = styp[3..] } - if styp in ['stat', 'dirent*', 'tm', 'tm*', 'winsize'] { + if styp in ['stat', 'dirent*', 'tm', 'tm*', 'winsize', 'sigaction'] { // TODO perf and other C structs styp = 'struct $styp' } @@ -536,7 +536,8 @@ fn (g mut Gen) gen_assign_stmt(assign_stmt ast.AssignStmt) { } fn (g mut Gen) gen_fn_decl(it ast.FnDecl) { - if it.is_c || it.name == 'malloc' || it.no_body { + if it.is_c || it.name == 'malloc' { + // || it.no_body { return } g.reset_tmp_count() @@ -583,6 +584,12 @@ fn (g mut Gen) gen_fn_decl(it ast.FnDecl) { */ // g.fn_args(it.args, it.is_variadic) + if it.no_body { + // Just a function header. + g.definitions.writeln(');') + g.writeln(');') + return + } g.writeln(') { ') if !is_main { g.definitions.writeln(');') diff --git a/vlib/v/gen/cheaders.v b/vlib/v/gen/cheaders.v index 52ec306323..94deb93e4b 100644 --- a/vlib/v/gen/cheaders.v +++ b/vlib/v/gen/cheaders.v @@ -190,6 +190,7 @@ int load_so(byteptr); void reload_so(); void _vinit(); void _vcleanup(); +#define sigaction_size sizeof(sigaction); // ============== wyhash ============== // Author: Wang Yi @@ -311,6 +312,7 @@ typedef byte array_fixed_byte_400 [400]; #define true 1 #define false 0 #endif + ' bare_c_headers = '