1 #include "nit_common.h"
9 void *simple_alloc(size_t s0
);
10 void *alloc(size_t s0
)
12 if (!nolibgc
) { return GC_MALLOC(s0
); }
13 else return simple_alloc(s0
);
15 #define alloc simple_alloc
18 void * alloc(size_t s0
)
20 static char * alloc_pos
= NULL
;
21 static size_t alloc_size
= 0;
23 size_t s
= ((s0
+3)/4)*4;
25 alloc_size
= s
+ 1024*1024;
26 alloc_pos
= (char *)calloc(alloc_size
, 1);
38 void exithandler(int s
) {
39 fprintf(stderr
, "Recieved signal %d\n", s
);
42 void prepare_signals(void) {
44 nolibgc
= (getenv("NIT_NOLIBGC") != NULL
);
49 signal(SIGINT
,exithandler
);
50 signal(SIGABRT
,exithandler
);
51 signal(SIGSEGV
,exithandler
);
52 signal(SIGILL
, exithandler
);
53 signal(SIGFPE
, exithandler
);
54 signal(SIGTERM
,exithandler
);
56 struct trace_t
*tracehead
= NULL
;
57 void nit_exit(int i
) {
58 fprintf(stderr
, ",---- Stack trace -- - - -\n");
59 while(tracehead
!= NULL
) {
60 fprintf(stderr
, "| %s (%s:%d)\n", tracehead
->meth
, tracehead
->file
, tracehead
->line
);
61 if (tracehead
== tracehead
->prev
) break;
62 tracehead
= tracehead
->prev
;
64 fprintf(stderr
, "`------------------- - - -\n");