History

-bench fix

Put total_lines etc. into TCCState. Also, initialize the predefined compiler types for the preprocessor too. tccpe.c: fix BaseOfCode if .init section present (with tcc -b)

grischka committed 6 years ago

Commit ff3b5ee1 parent b476a5f8 files · +83 −75Browse files

Unified · Split

8 files
  1. libtcc.c +15 −20
  2. tcc.h +16 −8
  3. tccelf.c +9 −4
  4. tccgen.c +29 −27
  5. tccpe.c +4 −2
  6. tccpp.c +6 −11
  7. tccrun.c +1 −1
  8. tests/libtcc_test_mt.c +3 −2
libtcc.c+15−20
@@ -64,7 +64,9 @@ · 63 unmodified lines
64/* XXX: get rid of this ASAP (or maybe not) */64/* XXX: get rid of this ASAP (or maybe not) */
65ST_DATA struct TCCState *tcc_state;65ST_DATA struct TCCState *tcc_state;
66 66
67#ifdef MEM_DEBUG
67static int nb_states;68static int nb_states;
69#endif
68 70
69/********************************************************/71/********************************************************/
70#ifdef _WIN3272#ifdef _WIN32
@@ -245,10 +247,6 @@ PUB_FUNC char *tcc_strdup(const char *str) · 174 unmodified lines
245 return ptr;247 return ptr;
246}248}
247 249
248PUB_FUNC void tcc_memcheck(void)
249{
250}
251
252#else250#else
253 251
254#define MEM_DEBUG_MAGIC1 0xFEEDDEB1252#define MEM_DEBUG_MAGIC1 0xFEEDDEB1
@@ -631,6 +629,7 @@ ST_FUNC void tcc_open_bf(TCCState *s1, const char *filename, int initlen) · 376 unmodified lines
631 629
632ST_FUNC void tcc_close(void)630ST_FUNC void tcc_close(void)
633{631{
632 TCCState *s1 = tcc_state;
634 BufferedFile *bf = file;633 BufferedFile *bf = file;
635 if (bf->fd > 0) {634 if (bf->fd > 0) {
636 close(bf->fd);635 close(bf->fd);
@@ -668,15 +667,10 @@ ST_FUNC int tcc_open(TCCState *s1, const char *filename) · 31 unmodified lines
668/* compile the file opened in 'file'. Return non zero if errors. */667/* compile the file opened in 'file'. Return non zero if errors. */
669static int tcc_compile(TCCState *s1, int filetype, const char *str, int fd)668static int tcc_compile(TCCState *s1, int filetype, const char *str, int fd)
670{669{
671 tccelf_begin_file(s1);
672
673 /* Here we enter the code section where we use the global variables for670 /* Here we enter the code section where we use the global variables for
674 parsing and code generation (tccpp.c, tccgen.c, <target>-gen.c).671 parsing and code generation (tccpp.c, tccgen.c, <target>-gen.c).
675 Other threads need to wait until we're done.672 Other threads need to wait until we're done.
676 673
677 Alternatively we could of course pass TCCState *s1 everwhere
678 except that it would look extremly ugly.
679
680 Alternatively we could use thread local storage for those global674 Alternatively we could use thread local storage for those global
681 variables, which may or may not have advantages */675 variables, which may or may not have advantages */
682 676
@@ -698,7 +692,9 @@ static int tcc_compile(TCCState *s1, int filetype, const char *str, int fd) · 15 unmodified lines
698 }692 }
699 693
700 is_asm = !!(filetype & (AFF_TYPE_ASM|AFF_TYPE_ASMPP));694 is_asm = !!(filetype & (AFF_TYPE_ASM|AFF_TYPE_ASMPP));
695 tccelf_begin_file(s1);
701 preprocess_start(s1, is_asm);696 preprocess_start(s1, is_asm);
697 tccgen_init(s1);
702 if (s1->output_type == TCC_OUTPUT_PREPROCESS) {698 if (s1->output_type == TCC_OUTPUT_PREPROCESS) {
703 tcc_preprocess(s1);699 tcc_preprocess(s1);
704 } else if (is_asm) {700 } else if (is_asm) {
@@ -712,13 +708,12 @@ static int tcc_compile(TCCState *s1, int filetype, const char *str, int fd) · 7 unmodified lines
712 }708 }
713 }709 }
714 s1->error_set_jmp_enabled = 0;710 s1->error_set_jmp_enabled = 0;
715 tccgen_finish(s1, 1);711 tccgen_finish(s1);
716 preprocess_end(s1);712 preprocess_end(s1);
717 tccgen_finish(s1, 2);713 tccelf_end_file(s1);
718 714
719 tcc_state = NULL;715 tcc_state = NULL;
720 POST_SEM();716 POST_SEM();
721 tccelf_end_file(s1);
722 return s1->nb_errors != 0 ? -1 : 0;717 return s1->nb_errors != 0 ? -1 : 0;
723}718}
724 719
@@ -749,9 +744,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 24 unmodified lines
749 s = tcc_mallocz(sizeof(TCCState));744 s = tcc_mallocz(sizeof(TCCState));
750 if (!s)745 if (!s)
751 return NULL;746 return NULL;
752 WAIT_SEM();747#ifdef MEM_DEBUG
753 ++nb_states;748 ++nb_states;
754 POST_SEM();749#endif
755 750
756#undef gnu_ext751#undef gnu_ext
757 752
@@ -960,10 +955,10 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 202 unmodified lines
960#endif955#endif
961 956
962 tcc_free(s1);957 tcc_free(s1);
963 WAIT_SEM();958#ifdef MEM_DEBUG
964 if (0 == --nb_states)959 if (0 == --nb_states)
965 tcc_memcheck();960 tcc_memcheck();
966 POST_SEM();961#endif
967}962}
968 963
969LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)964LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
@@ -1824,7 +1819,7 @@ reparse: · 854 unmodified lines
1824 else if (*optarg == 't')1819 else if (*optarg == 't')
1825 s->dflag = 16;1820 s->dflag = 16;
1826 else if (isnum(*optarg))1821 else if (isnum(*optarg))
1827 g_debug = atoi(optarg);1822 s->g_debug |= atoi(optarg);
1828 else1823 else
1829 goto unsupported_option;1824 goto unsupported_option;
1830 break;1825 break;
@@ -1925,7 +1920,7 @@ reparse: · 94 unmodified lines
1925 tcc_add_sysinclude_path(s, optarg);1920 tcc_add_sysinclude_path(s, optarg);
1926 break;1921 break;
1927 case TCC_OPTION_include:1922 case TCC_OPTION_include:
1928 cstr_printf(&s->cmdline_defs, "#include \"%s\"\n", optarg);1923 cstr_printf(&s->cmdline_incl, "#include \"%s\"\n", optarg);
1929 break;1924 break;
1930 case TCC_OPTION_nostdinc:1925 case TCC_OPTION_nostdinc:
1931 s->nostdinc = 1;1926 s->nostdinc = 1;
@@ -2077,7 +2072,7 @@ LIBTCCAPI void tcc_set_options(TCCState *s, const char *r) · 145 unmodified lines
2077 dynarray_reset(&argv, &argc);2072 dynarray_reset(&argv, &argc);
2078}2073}
2079 2074
2080PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time)2075PUB_FUNC void tcc_print_stats(TCCState *s1, unsigned total_time)
2081{2076{
2082 if (total_time < 1)2077 if (total_time < 1)
2083 total_time = 1;2078 total_time = 1;
@@ -2085,7 +2080,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, unsigned total_time) · 1 unmodified line
2085 total_bytes = 1;2080 total_bytes = 1;
2086 fprintf(stderr, "* %d idents, %d lines, %d bytes\n"2081 fprintf(stderr, "* %d idents, %d lines, %d bytes\n"
2087 "* %0.3f s, %u lines/s, %0.1f MB/s\n",2082 "* %0.3f s, %u lines/s, %0.1f MB/s\n",
2088 tok_ident - TOK_IDENT, total_lines, total_bytes,2083 total_idents, total_lines, total_bytes,
2089 (double)total_time/1000,2084 (double)total_time/1000,
2090 (unsigned)total_lines*1000/total_time,2085 (unsigned)total_lines*1000/total_time,
2091 (double)total_bytes/1000/total_time);2086 (double)total_bytes/1000/total_time);
tcc.h+16−8
@@ -128,7 +128,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 127 unmodified lines
128/* #define PP_DEBUG */128/* #define PP_DEBUG */
129/* include file debug */129/* include file debug */
130/* #define INC_DEBUG */130/* #define INC_DEBUG */
131/* memory leak debug */131/* memory leak debug (only for single threaded usage) */
132/* #define MEM_DEBUG */132/* #define MEM_DEBUG */
133/* assembler debug */133/* assembler debug */
134/* #define ASM_DEBUG */134/* #define ASM_DEBUG */
@@ -889,6 +889,14 @@ struct TCCState { · 754 unmodified lines
889 889
890 int fd, cc; /* used by tcc_load_ldscript */890 int fd, cc; /* used by tcc_load_ldscript */
891 891
892 /* benchmark info */
893 int total_idents;
894 int total_lines;
895 int total_bytes;
896
897 /* option -dnum (for general development purposes) */
898 int g_debug;
899
892 /* used by main and tcc_parse_args only */900 /* used by main and tcc_parse_args only */
893 struct filespec **files; /* files seen on command line */901 struct filespec **files; /* files seen on command line */
894 int nb_files; /* number thereof */902 int nb_files; /* number thereof */
@@ -1192,7 +1200,6 @@ PUB_FUNC char *tcc_strdup_debug(const char *str, const char *file, int line); · 297 unmodified lines
1192#define realloc(p, s) use_tcc_realloc(p, s)1200#define realloc(p, s) use_tcc_realloc(p, s)
1193#undef strdup1201#undef strdup
1194#define strdup(s) use_tcc_strdup(s)1202#define strdup(s) use_tcc_strdup(s)
1195PUB_FUNC void tcc_memcheck(void);
1196PUB_FUNC void _tcc_error_noabort(const char *fmt, ...);1203PUB_FUNC void _tcc_error_noabort(const char *fmt, ...);
1197PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...);1204PUB_FUNC NORETURN void _tcc_error(const char *fmt, ...);
1198PUB_FUNC void _tcc_warning(const char *fmt, ...);1205PUB_FUNC void _tcc_warning(const char *fmt, ...);
@@ -1277,8 +1284,6 @@ ST_DATA int tok_flags; · 78 unmodified lines
1277ST_DATA CString tokcstr; /* current parsed string, if any */1284ST_DATA CString tokcstr; /* current parsed string, if any */
1278 1285
1279/* display benchmark infos */1286/* display benchmark infos */
1280ST_DATA int total_lines;
1281ST_DATA int total_bytes;
1282ST_DATA int tok_ident;1287ST_DATA int tok_ident;
1283ST_DATA TokenSym **table_ident;1288ST_DATA TokenSym **table_ident;
1284 1289
@@ -1360,8 +1365,7 @@ ST_DATA Sym *local_label_stack; · 75 unmodified lines
1360ST_DATA Sym *global_label_stack;1365ST_DATA Sym *global_label_stack;
1361ST_DATA Sym *define_stack;1366ST_DATA Sym *define_stack;
1362ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;1367ST_DATA CType char_pointer_type, func_old_type, int_type, size_type;
1363ST_DATA SValue __vstack[1+/*to make bcheck happy*/ VSTACK_SIZE], *vtop, *pvtop;1368ST_DATA SValue *vtop;
1364#define vstack (__vstack + 1)
1365ST_DATA int rsym, anon_sym, ind, loc;1369ST_DATA int rsym, anon_sym, ind, loc;
1366 1370
1367ST_DATA int const_wanted; /* true if constant wanted */1371ST_DATA int const_wanted; /* true if constant wanted */
@@ -1371,7 +1375,6 @@ ST_DATA CType func_vt; /* current function return type (used by return instructi · 3 unmodified lines
1371ST_DATA int func_var; /* true if current function is variadic */1375ST_DATA int func_var; /* true if current function is variadic */
1372ST_DATA int func_vc;1376ST_DATA int func_vc;
1373ST_DATA const char *funcname;1377ST_DATA const char *funcname;
1374ST_DATA int g_debug;
1375 1378
1376ST_FUNC void tcc_debug_start(TCCState *s1);1379ST_FUNC void tcc_debug_start(TCCState *s1);
1377ST_FUNC void tcc_debug_end(TCCState *s1);1380ST_FUNC void tcc_debug_end(TCCState *s1);
@@ -1382,8 +1385,9 @@ ST_FUNC void tcc_debug_funcstart(TCCState *s1, Sym *sym); · 4 unmodified lines
1382ST_FUNC void tcc_debug_funcend(TCCState *s1, int size);1385ST_FUNC void tcc_debug_funcend(TCCState *s1, int size);
1383ST_FUNC void tcc_debug_line(TCCState *s1);1386ST_FUNC void tcc_debug_line(TCCState *s1);
1384 1387
1388ST_FUNC void tccgen_init(TCCState *s1);
1385ST_FUNC int tccgen_compile(TCCState *s1);1389ST_FUNC int tccgen_compile(TCCState *s1);
1386ST_FUNC void tccgen_finish(TCCState *s1, int f);1390ST_FUNC void tccgen_finish(TCCState *s1);
1387ST_FUNC void check_vstack(void);1391ST_FUNC void check_vstack(void);
1388 1392
1389ST_INLN int is_float(int t);1393ST_INLN int is_float(int t);
@@ -1751,6 +1755,10 @@ ST_FUNC void gen_makedeps(TCCState *s, const char *target, const char *filename) · 361 unmodified lines
1751#define tcc_error TCC_SET_STATE(_tcc_error)1755#define tcc_error TCC_SET_STATE(_tcc_error)
1752#define tcc_warning TCC_SET_STATE(_tcc_warning)1756#define tcc_warning TCC_SET_STATE(_tcc_warning)
1753 1757
1758#define total_idents TCC_STATE_VAR(total_idents)
1759#define total_lines TCC_STATE_VAR(total_lines)
1760#define total_bytes TCC_STATE_VAR(total_bytes)
1761
1754PUB_FUNC void tcc_enter_state(TCCState *s1);1762PUB_FUNC void tcc_enter_state(TCCState *s1);
1755 1763
1756/********************************************************/1764/********************************************************/
tccelf.c+9−4
@@ -3318,8 +3318,11 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 3317 unmodified lines
3318 if (!as_needed)3318 if (!as_needed)
3319 s1->new_undef_sym = 0;3319 s1->new_undef_sym = 0;
3320 t = ld_next(s1, filename, sizeof(filename));3320 t = ld_next(s1, filename, sizeof(filename));
3321 if (t != '(')3321 if (t != '(') {
3322 expect("(");3322 tcc_error_noabort("( expected");
3323 ret = -1;
3324 goto lib_parse_error;
3325 }
3323 t = ld_next(s1, filename, sizeof(filename));3326 t = ld_next(s1, filename, sizeof(filename));
3324 for(;;) {3327 for(;;) {
3325 libname[0] = '\0';3328 libname[0] = '\0';
@@ -3408,8 +3411,10 @@ ST_FUNC int tcc_load_ldscript(TCCState *s1, int fd) · 82 unmodified lines
3408 !strcmp(cmd, "TARGET")) {3411 !strcmp(cmd, "TARGET")) {
3409 /* ignore some commands */3412 /* ignore some commands */
3410 t = ld_next(s1, cmd, sizeof(cmd));3413 t = ld_next(s1, cmd, sizeof(cmd));
3411 if (t != '(')3414 if (t != '(') {
3412 expect("(");3415 tcc_error_noabort("( expected");
3416 return -1;
3417 }
3413 for(;;) {3418 for(;;) {
3414 t = ld_next(s1, filename, sizeof(filename));3419 t = ld_next(s1, filename, sizeof(filename));
3415 if (t == LD_TOK_EOF) {3420 if (t == LD_TOK_EOF) {
tccgen.c+29−27
@@ -47,7 +47,9 @@ static int in_sizeof; · 46 unmodified lines
47static int in_generic;47static int in_generic;
48static int section_sym;48static int section_sym;
49 49
50ST_DATA SValue __vstack[1+VSTACK_SIZE], *vtop, *pvtop;50ST_DATA SValue *vtop;
51static SValue _vstack[1 + VSTACK_SIZE];
52#define vstack (_vstack + 1)
51 53
52ST_DATA int const_wanted; /* true if constant wanted */54ST_DATA int const_wanted; /* true if constant wanted */
53ST_DATA int nocode_wanted; /* no code generation wanted */55ST_DATA int nocode_wanted; /* no code generation wanted */
@@ -77,7 +79,6 @@ ST_DATA int func_var; /* true if current function is variadic (used by return in · 23 unmodified lines
77ST_DATA int func_vc;79ST_DATA int func_vc;
78static int last_line_num, new_file, func_ind; /* debug info control */80static int last_line_num, new_file, func_ind; /* debug info control */
79ST_DATA const char *funcname;81ST_DATA const char *funcname;
80ST_DATA int g_debug;
81 82
82ST_DATA CType char_pointer_type, func_old_type, int_type, size_type, ptrdiff_type;83ST_DATA CType char_pointer_type, func_old_type, int_type, size_type, ptrdiff_type;
83 84
@@ -180,8 +181,8 @@ ST_FUNC void test_lvalue(void) · 96 unmodified lines
180 181
181ST_FUNC void check_vstack(void)182ST_FUNC void check_vstack(void)
182{183{
183 if (pvtop != vtop)184 if (vtop != vstack - 1)
184 tcc_error("internal compiler error: vstack leak (%d)", vtop - pvtop);185 tcc_error("internal compiler error: vstack leak (%d)", vtop - vstack + 1);
185}186}
186 187
187/* ------------------------------------------------------------------------- */188/* ------------------------------------------------------------------------- */
@@ -325,15 +326,11 @@ ST_FUNC void tcc_debug_eincl(TCCState *s1) · 137 unmodified lines
325}326}
326 327
327/* ------------------------------------------------------------------------- */328/* ------------------------------------------------------------------------- */
328ST_FUNC int tccgen_compile(TCCState *s1)329/* initialize vstack and types. This must be done also for tcc -E */
330ST_FUNC void tccgen_init(TCCState *s1)
329{331{
330 cur_text_section = NULL;332 vtop = vstack - 1;
331 funcname = "";333 memset(vtop, 0, sizeof *vtop);
332 anon_sym = SYM_FIRST_ANOM;
333 section_sym = 0;
334 const_wanted = 0;
335 nocode_wanted = 0x80000000;
336 local_scope = 0;
337 334
338 /* define some often used types */335 /* define some often used types */
339 int_type.t = VT_INT;336 int_type.t = VT_INT;
@@ -353,17 +350,25 @@ ST_FUNC int tccgen_compile(TCCState *s1) · 13 unmodified lines
353 func_old_type.ref = sym_push(SYM_FIELD, &int_type, 0, 0);350 func_old_type.ref = sym_push(SYM_FIELD, &int_type, 0, 0);
354 func_old_type.ref->f.func_call = FUNC_CDECL;351 func_old_type.ref->f.func_call = FUNC_CDECL;
355 func_old_type.ref->f.func_type = FUNC_OLD;352 func_old_type.ref->f.func_type = FUNC_OLD;
353}
356 354
357 tcc_debug_start(s1);355ST_FUNC int tccgen_compile(TCCState *s1)
356{
357 cur_text_section = NULL;
358 funcname = "";
359 anon_sym = SYM_FIRST_ANOM;
360 section_sym = 0;
361 const_wanted = 0;
362 nocode_wanted = 0x80000000;
363 local_scope = 0;
358 364
365 tcc_debug_start(s1);
359#ifdef TCC_TARGET_ARM366#ifdef TCC_TARGET_ARM
360 arm_init(s1);367 arm_init(s1);
361#endif368#endif
362
363#ifdef INC_DEBUG369#ifdef INC_DEBUG
364 printf("%s: **** new file\n", file->filename);370 printf("%s: **** new file\n", file->filename);
365#endif371#endif
366
367 parse_flags = PARSE_FLAG_PREPROCESS | PARSE_FLAG_TOK_NUM | PARSE_FLAG_TOK_STR;372 parse_flags = PARSE_FLAG_PREPROCESS | PARSE_FLAG_TOK_NUM | PARSE_FLAG_TOK_STR;
368 next();373 next();
369 decl(VT_CONST);374 decl(VT_CONST);
@@ -374,19 +379,16 @@ ST_FUNC int tccgen_compile(TCCState *s1) · 4 unmodified lines
374 return 0;379 return 0;
375}380}
376 381
377ST_FUNC void tccgen_finish(TCCState *s1, int f)382ST_FUNC void tccgen_finish(TCCState *s1)
378{383{
379 if (f == 1) {384 free_inline_functions(s1);
380 free_inline_functions(s1);385 sym_pop(&global_stack, NULL, 0);
381 sym_pop(&global_stack, NULL, 0);386 sym_pop(&local_stack, NULL, 0);
382 sym_pop(&local_stack, NULL, 0);387 /* free preprocessor macros */
383 }388 free_defines(NULL);
384 389 /* free sym_pools */
385 if (f == 2) {390 dynarray_reset(&sym_pools, &nb_sym_pools);
386 /* free sym_pools */391 sym_free_first = NULL;
387 dynarray_reset(&sym_pools, &nb_sym_pools);
388 sym_free_first = NULL;
389 }
390}392}
391 393
392/* ------------------------------------------------------------------------- */394/* ------------------------------------------------------------------------- */
tccpe.c+4−2
@@ -636,12 +636,14 @@ static int pe_write(struct pe_info *pe) · 635 unmodified lines
636 636
637 switch (si->cls) {637 switch (si->cls) {
638 case sec_text:638 case sec_text:
639 pe_header.opthdr.BaseOfCode = addr;639 if (!pe_header.opthdr.BaseOfCode)
640 pe_header.opthdr.BaseOfCode = addr;
640 break;641 break;
641 642
642 case sec_data:643 case sec_data:
643#ifndef TCC_TARGET_X86_64644#ifndef TCC_TARGET_X86_64
644 pe_header.opthdr.BaseOfData = addr;645 if (!pe_header.opthdr.BaseOfData)
646 pe_header.opthdr.BaseOfData = addr;
645#endif647#endif
646 break;648 break;
647 649
tccpp.c+6−11
@@ -34,8 +34,6 @@ ST_DATA const int *macro_ptr; · 33 unmodified lines
34ST_DATA CString tokcstr; /* current parsed string, if any */34ST_DATA CString tokcstr; /* current parsed string, if any */
35 35
36/* display benchmark infos */36/* display benchmark infos */
37ST_DATA int total_lines;
38ST_DATA int total_bytes;
39ST_DATA int tok_ident;37ST_DATA int tok_ident;
40ST_DATA TokenSym **table_ident;38ST_DATA TokenSym **table_ident;
41 39
@@ -604,7 +602,7 @@ ST_FUNC const char *get_tok_str(int v, CValue *cv) · 562 unmodified lines
604 602
605/* return the current character, handling end of block if necessary603/* return the current character, handling end of block if necessary
606 (but not stray) */604 (but not stray) */
607ST_FUNC int handle_eob(void)605static int handle_eob(void)
608{606{
609 BufferedFile *bf = file;607 BufferedFile *bf = file;
610 int len;608 int len;
@@ -637,7 +635,7 @@ ST_FUNC int handle_eob(void) · 26 unmodified lines
637}635}
638 636
639/* read next char from current input file and handle end of input buffer */637/* read next char from current input file and handle end of input buffer */
640ST_INLN void inp(void)638static inline void inp(void)
641{639{
642 ch = *(++(file->buf_ptr));640 ch = *(++(file->buf_ptr));
643 /* end of buffer/file handling */641 /* end of buffer/file handling */
@@ -723,7 +721,7 @@ static int handle_stray1(uint8_t *p) · 79 unmodified lines
723/* input with '\[\r]\n' handling. Note that this function cannot721/* input with '\[\r]\n' handling. Note that this function cannot
724 handle other characters after '\', so you cannot call it inside722 handle other characters after '\', so you cannot call it inside
725 strings or comments */723 strings or comments */
726ST_FUNC void minp(void)724static void minp(void)
727{725{
728 inp();726 inp();
729 if (ch == '\\') 727 if (ch == '\\')
@@ -768,7 +766,7 @@ static uint8_t *parse_line_comment(uint8_t *p) · 38 unmodified lines
768}766}
769 767
770/* C comments */768/* C comments */
771ST_FUNC uint8_t *parse_comment(uint8_t *p)769static uint8_t *parse_comment(uint8_t *p)
772{770{
773 int c;771 int c;
774 772
@@ -3597,8 +3595,6 @@ ST_FUNC void preprocess_start(TCCState *s1, int is_asm) · 2822 unmodified lines
3597 pp_counter = 0;3595 pp_counter = 0;
3598 pp_debug_tok = pp_debug_symv = 0;3596 pp_debug_tok = pp_debug_symv = 0;
3599 pp_once++;3597 pp_once++;
3600 pvtop = vtop = vstack - 1;
3601 memset(vtop, 0, sizeof *vtop);
3602 s1->pack_stack[0] = 0;3598 s1->pack_stack[0] = 0;
3603 s1->pack_stack_ptr = s1->pack_stack;3599 s1->pack_stack_ptr = s1->pack_stack;
3604 3600
@@ -3629,10 +3625,8 @@ ST_FUNC void preprocess_end(TCCState *s1) · 24 unmodified lines
3629 while (macro_stack)3625 while (macro_stack)
3630 end_macro();3626 end_macro();
3631 macro_ptr = NULL;3627 macro_ptr = NULL;
3632
3633 while (file)3628 while (file)
3634 tcc_close();3629 tcc_close();
3635
3636 tccpp_delete(s1);3630 tccpp_delete(s1);
3637}3631}
3638 3632
@@ -3690,11 +3684,12 @@ ST_FUNC void tccpp_delete(TCCState *s) · 51 unmodified lines
3690{3684{
3691 int i, n;3685 int i, n;
3692 3686
3693 free_defines(NULL);
3694 dynarray_reset(&s->cached_includes, &s->nb_cached_includes);3687 dynarray_reset(&s->cached_includes, &s->nb_cached_includes);
3695 3688
3696 /* free tokens */3689 /* free tokens */
3697 n = tok_ident - TOK_IDENT;3690 n = tok_ident - TOK_IDENT;
3691 if (n > total_idents)
3692 total_idents = n;
3698 for(i = 0; i < n; i++)3693 for(i = 0; i < n; i++)
3699 tal_free(toksym_alloc, table_ident[i]);3694 tal_free(toksym_alloc, table_ident[i]);
3700 tcc_free(table_ident);3695 tcc_free(table_ident);
tccrun.c+1−1
@@ -373,7 +373,7 @@ static addr_t rt_printline(TCCState *s1, addr_t wanted_pc, const char *msg) · 372 unmodified lines
373 if (symtab_section) {373 if (symtab_section) {
374 esym_start = (ElfW(Sym) *)(symtab_section->data);374 esym_start = (ElfW(Sym) *)(symtab_section->data);
375 esym_end = (ElfW(Sym) *)(symtab_section->data + symtab_section->data_offset);375 esym_end = (ElfW(Sym) *)(symtab_section->data + symtab_section->data_offset);
376 elf_str = symtab_section->link->data;376 elf_str = (char *) symtab_section->link->data;
377 }377 }
378 378
379 for (sym = stab_sym + 1; sym < stab_sym_end; ++sym) {379 for (sym = stab_sym + 1; sym < stab_sym_end; ++sym) {
tests/libtcc_test_mt.c+3−2
@@ -218,12 +218,13 @@ TF_TYPE(thread_test_complex, vn) · 217 unmodified lines
218 argv[argc] = NULL;218 argv[argc] = NULL;
219 219
220 s = new_state(1);220 s = new_state(1);
221 sleep_ms(1);221 sleep_ms(2);
222 ret = tcc_add_file(s, argv[0]);222 ret = tcc_add_file(s, argv[0]);
223 sleep_ms(1);223 sleep_ms(3);
224 if (ret >= 0)224 if (ret >= 0)
225 tcc_run(s, argc, argv);225 tcc_run(s, argc, argv);
226 tcc_delete(s);226 tcc_delete(s);
227 fflush(stdout);
227 return 0;228 return 0;
228}229}
229 230