builtin: bootstrap for backtrace functions cleanup

pull/4903/head
Delyan Angelov 2020-05-15 14:18:49 +03:00
parent 0701c9f204
commit 2c93deb884
3 changed files with 23 additions and 7 deletions

View File

@ -27,12 +27,9 @@ fn C.popen(c byteptr, t byteptr) voidptr
// <execinfo.h> // <execinfo.h>
// backtrace functions are not #included, that's why they have to be defined without C. // backtrace functions are not #included, that's why they have to be defined without C.
fn backtrace(a voidptr, b int) int fn backtrace(a &voidptr, b int) int
fn backtrace_symbols(a &voidptr, size int) &charptr
fn backtrace_symbols(voidptr, int) &byteptr fn backtrace_symbols_fd(a &voidptr, size int, fd int) void
fn backtrace_symbols_fd(voidptr, int, int)
// <libproc.h> // <libproc.h>
fn proc_pidpath(int, voidptr, int) int fn proc_pidpath(int, voidptr, int) int

View File

@ -69,7 +69,20 @@ typedef int (*qsort_callback_func)(const void*, const void*);
#ifdef __cplusplus #ifdef __cplusplus
#include <utility> #include <utility>
#define _MOV std::move #define _MOV std::move
#include <execinfo.h> #endif
#if defined(__ANDROID__)
int backtrace (void **__array, int __size) { return 0; }
char **backtrace_symbols (void *const *__array, int __size){ return 0; }
void backtrace_symbols_fd (void *const *__array, int __size, int __fd){}
#else
#ifndef _WIN32
#if defined __has_include
#if __has_include (<execinfo.h>)
# include <execinfo.h>
#endif
#endif
#endif
#endif #endif
//#include "fns.h" //#include "fns.h"

View File

@ -22,6 +22,12 @@ fn (mut g Gen) gen_fn_decl(it ast.FnDecl) {
if g.attr == 'inline' { if g.attr == 'inline' {
g.write('inline ') g.write('inline ')
} }
if it.name in ['backtrace', 'backtrace_symbols', 'backtrace_symbols_fd'] {
// these are actually defined as C functions in execinfo.h
// TODO: remove this check, *after* they are defined as C. in cfns.c.v
// in bootstrap phase 2
return
}
// //
is_livefn := g.attr == 'live' is_livefn := g.attr == 'live'
is_livemain := g.pref.is_livemain && is_livefn is_livemain := g.pref.is_livemain && is_livefn