cgen: backtrace and sigaction fixes
							parent
							
								
									0609756d36
								
							
						
					
					
						commit
						2738a0c776
					
				|  | @ -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 | ||||
| 
 | ||||
| // <execinfo.h>
 | ||||
| // 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 | ||||
|  |  | |||
|  | @ -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) | ||||
| 		*/ | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -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(');') | ||||
|  |  | |||
|  | @ -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 = ' | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue