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