Wrap runtime_main as per its declaration in tcc.h. Fix preprocessor check for TCC_ARM_EABI macro definition.
Unified · Split
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | * ARMv4 code generator for TCC |
| 3 | − * | |
| 3 | + * | |
| 4 | 4 | * Copyright (c) 2003 Daniel Gl�ckner |
| 5 | 5 | * Copyright (c) 2012 Thomas Preud'homme |
| 6 | 6 | * |
| @@ -46,7 +46,7 @@ · 39 unmodified lines | ||
| 46 | 46 | #define RC_INT 0x0001 /* generic integer register */ |
| 47 | 47 | #define RC_FLOAT 0x0002 /* generic float register */ |
| 48 | 48 | #define RC_R0 0x0004 |
| 49 | −#define RC_R1 0x0008 | |
| 49 | +#define RC_R1 0x0008 | |
| 50 | 50 | #define RC_R2 0x0010 |
| 51 | 51 | #define RC_R3 0x0020 |
| 52 | 52 | #define RC_R12 0x0040 |
| @@ -211,7 +211,7 @@ void o(uint32_t i) · 158 unmodified lines | ||
| 211 | 211 | cur_text_section->data[ind++] = i&255; |
| 212 | 212 | i>>=8; |
| 213 | 213 | cur_text_section->data[ind++] = i&255; |
| 214 | − i>>=8; | |
| 214 | + i>>=8; | |
| 215 | 215 | cur_text_section->data[ind++] = i&255; |
| 216 | 216 | i>>=8; |
| 217 | 217 | cur_text_section->data[ind++] = i; |
| @@ -506,7 +506,7 @@ void load(int r, SValue *sv) · 288 unmodified lines | ||
| 506 | 506 | sign=1; |
| 507 | 507 | fc=-fc; |
| 508 | 508 | } |
| 509 | − | |
| 509 | + | |
| 510 | 510 | v = fr & VT_VALMASK; |
| 511 | 511 | if (fr & VT_LVAL) { |
| 512 | 512 | uint32_t base = 0xB; // fp |
| @@ -645,8 +645,8 @@ void store(int r, SValue *sv) · 132 unmodified lines | ||
| 645 | 645 | sign=1; |
| 646 | 646 | fc=-fc; |
| 647 | 647 | } |
| 648 | − | |
| 649 | − v = fr & VT_VALMASK; | |
| 648 | + | |
| 649 | + v = fr & VT_VALMASK; | |
| 650 | 650 | if (fr & VT_LVAL || fr == VT_LOCAL) { |
| 651 | 651 | uint32_t base = 0xb; |
| 652 | 652 | if(v < VT_CONST) { |
| @@ -660,16 +660,16 @@ void store(int r, SValue *sv) · 7 unmodified lines | ||
| 660 | 660 | v1.sym=sv->sym; |
| 661 | 661 | load(base=14, &v1); |
| 662 | 662 | fc=sign=0; |
| 663 | − v=VT_LOCAL; | |
| 663 | + v=VT_LOCAL; | |
| 664 | 664 | } |
| 665 | 665 | if(v == VT_LOCAL) { |
| 666 | 666 | if(is_float(ft)) { |
| 667 | 667 | calcaddr(&base,&fc,&sign,1020,2); |
| 668 | 668 | #ifdef TCC_ARM_VFP |
| 669 | 669 | op=0xED000A00; /* fsts */ |
| 670 | − if(!sign) | |
| 671 | − op|=0x800000; | |
| 672 | − if ((ft & VT_BTYPE) != VT_FLOAT) | |
| 670 | + if(!sign) | |
| 671 | + op|=0x800000; | |
| 672 | + if ((ft & VT_BTYPE) != VT_FLOAT) | |
| 673 | 673 | op|=0x100; /* fsts -> fstd */ |
| 674 | 674 | o(op|(vfpr(r)<<12)|(fc>>2)|(base<<16)); |
| 675 | 675 | #else |
| @@ -802,7 +802,7 @@ int assign_fpreg(struct avail_regs *avregs, int align, int size) · 126 unmodified lines | ||
| 802 | 802 | |
| 803 | 803 | /* Return 1 if this function returns via an sret pointer, 0 otherwise */ |
| 804 | 804 | ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) { |
| 805 | −#if TCC_ARM_EABI | |
| 805 | +#ifdef TCC_ARM_EABI | |
| 806 | 806 | int size, align; |
| 807 | 807 | size = type_size(vt, &align); |
| 808 | 808 | if (size > 4) { |
| @@ -855,7 +855,7 @@ void gfunc_call(int nb_args) · 46 unmodified lines | ||
| 855 | 855 | vtop[-nb_args+1]=tmp; |
| 856 | 856 | --nb_args; |
| 857 | 857 | } |
| 858 | − | |
| 858 | + | |
| 859 | 859 | vpushi(0), nb_args++; |
| 860 | 860 | vtop->type.t = VT_LLONG; |
| 861 | 861 | #endif |
| @@ -1023,7 +1023,7 @@ void gfunc_call(int nb_args) · 161 unmodified lines | ||
| 1023 | 1023 | size = 8; |
| 1024 | 1024 | else |
| 1025 | 1025 | size = LDOUBLE_SIZE; |
| 1026 | − | |
| 1026 | + | |
| 1027 | 1027 | if (size == 12) |
| 1028 | 1028 | r|=0x400000; |
| 1029 | 1029 | else if(size == 8) |
| @@ -1362,7 +1362,7 @@ int gtst(int inv, int t) · 332 unmodified lines | ||
| 1362 | 1362 | return gtst(inv, t); |
| 1363 | 1363 | } else if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) { |
| 1364 | 1364 | /* constant jmp optimization */ |
| 1365 | − if ((vtop->c.i != 0) != inv) | |
| 1365 | + if ((vtop->c.i != 0) != inv) | |
| 1366 | 1366 | t = gjmp(t); |
| 1367 | 1367 | } else { |
| 1368 | 1368 | v = gv(RC_INT); |
| @@ -1370,7 +1370,7 @@ int gtst(int inv, int t) · 1 unmodified line | ||
| 1370 | 1370 | vtop->r = VT_CMP; |
| 1371 | 1371 | vtop->c.i = TOK_NE; |
| 1372 | 1372 | return gtst(inv, t); |
| 1373 | − } | |
| 1373 | + } | |
| 1374 | 1374 | } |
| 1375 | 1375 | vtop--; |
| 1376 | 1376 | return t; |
| @@ -1628,7 +1628,7 @@ void gen_opf(int op) · 251 unmodified lines | ||
| 1628 | 1628 | case TOK_UGE: op=TOK_GE; break; |
| 1629 | 1629 | case TOK_UGT: op=TOK_GT; break; |
| 1630 | 1630 | } |
| 1631 | − | |
| 1631 | + | |
| 1632 | 1632 | vtop->r = VT_CMP; |
| 1633 | 1633 | vtop->c.i = op; |
| 1634 | 1634 | return; |
| @@ -1779,7 +1779,7 @@ void gen_opf(int op) · 144 unmodified lines | ||
| 1779 | 1779 | r=fpr(gv(RC_FLOAT)); |
| 1780 | 1780 | vswap(); |
| 1781 | 1781 | r2=fpr(gv(RC_FLOAT)); |
| 1782 | − } | |
| 1782 | + } | |
| 1783 | 1783 | break; |
| 1784 | 1784 | default: |
| 1785 | 1785 | if(op >= TOK_ULT && op <= TOK_GT) { |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | * TCC - Tiny C Compiler |
| 3 | − * | |
| 3 | + * | |
| 4 | 4 | * Copyright (c) 2001-2004 Fabrice Bellard |
| 5 | 5 | * |
| 6 | 6 | * This library is free software; you can redistribute it and/or |
| @@ -156,7 +156,7 @@ PUB_FUNC char *pstrcat(char *buf, int buf_size, const char *s) · 149 unmodified lines | ||
| 156 | 156 | { |
| 157 | 157 | int len; |
| 158 | 158 | len = strlen(buf); |
| 159 | − if (len < buf_size) | |
| 159 | + if (len < buf_size) | |
| 160 | 160 | pstrcpy(buf + len, buf_size - len, s); |
| 161 | 161 | return buf; |
| 162 | 162 | } |
| @@ -275,7 +275,7 @@ ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) · 112 unmodified lines | ||
| 275 | 275 | { |
| 276 | 276 | int nb, nb_alloc; |
| 277 | 277 | void **pp; |
| 278 | − | |
| 278 | + | |
| 279 | 279 | nb = *nb_ptr; |
| 280 | 280 | pp = *ptab; |
| 281 | 281 | /* every power of two we double array size */ |
| @@ -371,7 +371,7 @@ ST_FUNC void section_realloc(Section *sec, unsigned long new_size) · 89 unmodified lines | ||
| 371 | 371 | { |
| 372 | 372 | unsigned long size; |
| 373 | 373 | unsigned char *data; |
| 374 | − | |
| 374 | + | |
| 375 | 375 | size = sec->data_allocated; |
| 376 | 376 | if (size == 0) |
| 377 | 377 | size = 1; |
| @@ -414,7 +414,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) · 36 unmodified lines | ||
| 414 | 414 | int i; |
| 415 | 415 | for(i = 1; i < s1->nb_sections; i++) { |
| 416 | 416 | sec = s1->sections[i]; |
| 417 | − if (!strcmp(name, sec->name)) | |
| 417 | + if (!strcmp(name, sec->name)) | |
| 418 | 418 | return sec; |
| 419 | 419 | } |
| 420 | 420 | /* sections are created as PROGBITS */ |
| @@ -423,7 +423,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) · 2 unmodified lines | ||
| 423 | 423 | |
| 424 | 424 | /* update sym->c so that it points to an external symbol in section |
| 425 | 425 | 'section' with value 'value' */ |
| 426 | −ST_FUNC void put_extern_sym2(Sym *sym, Section *section, | |
| 426 | +ST_FUNC void put_extern_sym2(Sym *sym, Section *section, | |
| 427 | 427 | addr_t value, unsigned long size, |
| 428 | 428 | int can_add_underscore) |
| 429 | 429 | { |
| @@ -434,7 +434,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 4 unmodified lines | ||
| 434 | 434 | |
| 435 | 435 | if (section == NULL) |
| 436 | 436 | sh_num = SHN_UNDEF; |
| 437 | − else if (section == SECTION_ABS) | |
| 437 | + else if (section == SECTION_ABS) | |
| 438 | 438 | sh_num = SHN_ABS; |
| 439 | 439 | else |
| 440 | 440 | sh_num = section->sh_num; |
| @@ -468,13 +468,13 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 27 unmodified lines | ||
| 468 | 468 | switch(sym->v) { |
| 469 | 469 | #ifdef TCC_TARGET_PE |
| 470 | 470 | /* XXX: we rely only on malloc hooks */ |
| 471 | − case TOK_malloc: | |
| 472 | − case TOK_free: | |
| 473 | − case TOK_realloc: | |
| 474 | − case TOK_memalign: | |
| 475 | − case TOK_calloc: | |
| 471 | + case TOK_malloc: | |
| 472 | + case TOK_free: | |
| 473 | + case TOK_realloc: | |
| 474 | + case TOK_memalign: | |
| 475 | + case TOK_calloc: | |
| 476 | 476 | #endif |
| 477 | − case TOK_memcpy: | |
| 477 | + case TOK_memcpy: | |
| 478 | 478 | case TOK_memmove: |
| 479 | 479 | case TOK_memset: |
| 480 | 480 | case TOK_strlen: |
| @@ -527,7 +527,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 46 unmodified lines | ||
| 527 | 527 | } |
| 528 | 528 | } |
| 529 | 529 | |
| 530 | −ST_FUNC void put_extern_sym(Sym *sym, Section *section, | |
| 530 | +ST_FUNC void put_extern_sym(Sym *sym, Section *section, | |
| 531 | 531 | addr_t value, unsigned long size) |
| 532 | 532 | { |
| 533 | 533 | put_extern_sym2(sym, section, value, size, 1); |
| @@ -567,7 +567,7 @@ static void error1(TCCState *s1, int is_warning, const char *fmt, va_list ap) · 33 unmodified lines | ||
| 567 | 567 | { |
| 568 | 568 | char buf[2048]; |
| 569 | 569 | BufferedFile **pf, *f; |
| 570 | − | |
| 570 | + | |
| 571 | 571 | buf[0] = '\0'; |
| 572 | 572 | /* use upper file if inline ":asm:" or token ":paste:" */ |
| 573 | 573 | for (f = file; f && f->filename[0] == ':'; f = f->prev) |
| @@ -718,28 +718,28 @@ static int tcc_compile(TCCState *s1) · 144 unmodified lines | ||
| 718 | 718 | |
| 719 | 719 | cur_text_section = NULL; |
| 720 | 720 | funcname = ""; |
| 721 | − anon_sym = SYM_FIRST_ANOM; | |
| 721 | + anon_sym = SYM_FIRST_ANOM; | |
| 722 | 722 | |
| 723 | 723 | /* file info: full path + filename */ |
| 724 | 724 | section_sym = 0; /* avoid warning */ |
| 725 | 725 | if (s1->do_debug) { |
| 726 | − section_sym = put_elf_sym(symtab_section, 0, 0, | |
| 727 | − ELFW(ST_INFO)(STB_LOCAL, STT_SECTION), 0, | |
| 726 | + section_sym = put_elf_sym(symtab_section, 0, 0, | |
| 727 | + ELFW(ST_INFO)(STB_LOCAL, STT_SECTION), 0, | |
| 728 | 728 | text_section->sh_num, NULL); |
| 729 | 729 | getcwd(buf, sizeof(buf)); |
| 730 | 730 | #ifdef _WIN32 |
| 731 | 731 | normalize_slashes(buf); |
| 732 | 732 | #endif |
| 733 | 733 | pstrcat(buf, sizeof(buf), "/"); |
| 734 | − put_stabs_r(buf, N_SO, 0, 0, | |
| 734 | + put_stabs_r(buf, N_SO, 0, 0, | |
| 735 | 735 | text_section->data_offset, text_section, section_sym); |
| 736 | − put_stabs_r(file->filename, N_SO, 0, 0, | |
| 736 | + put_stabs_r(file->filename, N_SO, 0, 0, | |
| 737 | 737 | text_section->data_offset, text_section, section_sym); |
| 738 | 738 | } |
| 739 | 739 | /* an elf symbol of type STT_FILE must be put so that STB_LOCAL |
| 740 | 740 | symbols can be safely used */ |
| 741 | − put_elf_sym(symtab_section, 0, 0, | |
| 742 | − ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0, | |
| 741 | + put_elf_sym(symtab_section, 0, 0, | |
| 742 | + ELFW(ST_INFO)(STB_LOCAL, STT_FILE), 0, | |
| 743 | 743 | SHN_ABS, file->filename); |
| 744 | 744 | |
| 745 | 745 | /* define some often used types */ |
| @@ -794,7 +794,7 @@ static int tcc_compile(TCCState *s1) · 48 unmodified lines | ||
| 794 | 794 | |
| 795 | 795 | /* end of translation unit info */ |
| 796 | 796 | if (s1->do_debug) { |
| 797 | − put_stabs_r(NULL, N_SO, 0, 0, | |
| 797 | + put_stabs_r(NULL, N_SO, 0, 0, | |
| 798 | 798 | text_section->data_offset, text_section, section_sym); |
| 799 | 799 | } |
| 800 | 800 | } |
| @@ -803,7 +803,7 @@ static int tcc_compile(TCCState *s1) · 2 unmodified lines | ||
| 803 | 803 | |
| 804 | 804 | /* reset define stack, but leave -Dsymbols (may be incorrect if |
| 805 | 805 | they are undefined) */ |
| 806 | − free_defines(define_start); | |
| 806 | + free_defines(define_start); | |
| 807 | 807 | |
| 808 | 808 | gen_inline_functions(); |
| 809 | 809 | |
| @@ -1004,13 +1004,13 @@ LIBTCCAPI TCCState *tcc_new(void) · 194 unmodified lines | ||
| 1004 | 1004 | /* symbols are always generated for linking stage */ |
| 1005 | 1005 | symtab_section = new_symtab(s, ".symtab", SHT_SYMTAB, 0, |
| 1006 | 1006 | ".strtab", |
| 1007 | − ".hashtab", SHF_PRIVATE); | |
| 1007 | + ".hashtab", SHF_PRIVATE); | |
| 1008 | 1008 | strtab_section = symtab_section->link; |
| 1009 | 1009 | s->symtab = symtab_section; |
| 1010 | − | |
| 1010 | + | |
| 1011 | 1011 | /* private symbol table for dynamic symbols */ |
| 1012 | 1012 | s->dynsymtab_section = new_symtab(s, ".dynsymtab", SHT_SYMTAB, SHF_PRIVATE, |
| 1013 | − ".dynstrtab", | |
| 1013 | + ".dynstrtab", | |
| 1014 | 1014 | ".dynhashtab", SHF_PRIVATE); |
| 1015 | 1015 | s->alacarte_link = 1; |
| 1016 | 1016 | s->nocommon = 1; |
| @@ -1026,7 +1026,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 9 unmodified lines | ||
| 1026 | 1026 | #ifdef TCC_TARGET_I386 |
| 1027 | 1027 | s->seg_size = 32; |
| 1028 | 1028 | #endif |
| 1029 | +#ifdef TCC_IS_NATIVE | |
| 1029 | 1030 | s->runtime_main = "main"; |
| 1031 | +#endif | |
| 1030 | 1032 | return s; |
| 1031 | 1033 | } |
| 1032 | 1034 | |
| @@ -1044,7 +1046,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 11 unmodified lines | ||
| 1044 | 1046 | for(i = 0; i < s1->nb_priv_sections; i++) |
| 1045 | 1047 | free_section(s1->priv_sections[i]); |
| 1046 | 1048 | dynarray_reset(&s1->priv_sections, &s1->nb_priv_sections); |
| 1047 | − | |
| 1049 | + | |
| 1048 | 1050 | /* free any loaded DLLs */ |
| 1049 | 1051 | #ifdef TCC_IS_NATIVE |
| 1050 | 1052 | for ( i = 0; i < s1->nb_loaded_dlls; i++) { |
| @@ -1053,7 +1055,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 2 unmodified lines | ||
| 1053 | 1055 | dlclose(ref->handle); |
| 1054 | 1056 | } |
| 1055 | 1057 | #endif |
| 1056 | − | |
| 1058 | + | |
| 1057 | 1059 | /* free loaded dlls array */ |
| 1058 | 1060 | dynarray_reset(&s1->loaded_dlls, &s1->nb_loaded_dlls); |
| 1059 | 1061 | |
| @@ -1079,7 +1081,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 19 unmodified lines | ||
| 1079 | 1081 | #ifdef TCC_IS_NATIVE |
| 1080 | 1082 | # ifdef HAVE_SELINUX |
| 1081 | 1083 | munmap (s1->write_mem, s1->mem_size); |
| 1082 | − munmap (s1->runtime_mem, s1->mem_size); | |
| 1084 | + munmap (s1->runtime_mem, s1->mem_size); | |
| 1083 | 1085 | # else |
| 1084 | 1086 | tcc_free(s1->runtime_mem); |
| 1085 | 1087 | # endif |
| @@ -1186,7 +1188,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 100 unmodified lines | ||
| 1186 | 1188 | #endif |
| 1187 | 1189 | ret = 0; |
| 1188 | 1190 | } else { |
| 1189 | − ret = tcc_load_dll(s1, fd, filename, | |
| 1191 | + ret = tcc_load_dll(s1, fd, filename, | |
| 1190 | 1192 | (flags & AFF_REFERENCED_DLL) != 0); |
| 1191 | 1193 | } |
| 1192 | 1194 | goto the_end; |
| @@ -1318,9 +1320,9 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 125 unmodified lines | ||
| 1318 | 1320 | /* define symbol */ |
| 1319 | 1321 | tcc_define_symbol(s, "__BOUNDS_CHECKING_ON", NULL); |
| 1320 | 1322 | /* create bounds sections */ |
| 1321 | − bounds_section = new_section(s, ".bounds", | |
| 1323 | + bounds_section = new_section(s, ".bounds", | |
| 1322 | 1324 | SHT_PROGBITS, SHF_ALLOC); |
| 1323 | − lbounds_section = new_section(s, ".lbounds", | |
| 1325 | + lbounds_section = new_section(s, ".lbounds", | |
| 1324 | 1326 | SHT_PROGBITS, SHF_ALLOC); |
| 1325 | 1327 | } |
| 1326 | 1328 | #endif |
| @@ -1693,7 +1695,7 @@ static const TCCOption tcc_options[] = { · 366 unmodified lines | ||
| 1693 | 1695 | { "isystem", TCC_OPTION_isystem, TCC_OPTION_HAS_ARG }, |
| 1694 | 1696 | { "nostdinc", TCC_OPTION_nostdinc, 0 }, |
| 1695 | 1697 | { "nostdlib", TCC_OPTION_nostdlib, 0 }, |
| 1696 | − { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, | |
| 1698 | + { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, | |
| 1697 | 1699 | { "v", TCC_OPTION_v, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1698 | 1700 | { "w", TCC_OPTION_w, 0 }, |
| 1699 | 1701 | { "pipe", TCC_OPTION_pipe, 0}, |
| @@ -1859,7 +1861,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 159 unmodified lines | ||
| 1859 | 1861 | goto unsupported_option; |
| 1860 | 1862 | break; |
| 1861 | 1863 | case TCC_OPTION_W: |
| 1862 | − if (tcc_set_warning(s, optarg, 1) < 0 && | |
| 1864 | + if (tcc_set_warning(s, optarg, 1) < 0 && | |
| 1863 | 1865 | s->warn_unsupported) |
| 1864 | 1866 | goto unsupported_option; |
| 1865 | 1867 | break; |
| @@ -1946,7 +1948,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) · 80 unmodified lines | ||
| 1946 | 1948 | tt = 0.001; |
| 1947 | 1949 | if (total_bytes < 1) |
| 1948 | 1950 | total_bytes = 1; |
| 1949 | − printf("%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", | |
| 1951 | + printf("%d idents, %d lines, %d bytes, %0.3f s, %d lines/s, %0.1f MB/s\n", | |
| 1950 | 1952 | tok_ident - TOK_IDENT, total_lines, total_bytes, |
| 1951 | 1953 | tt, (int)(total_lines / tt), |
| 1952 | 1954 | total_bytes / tt / 1000000.0); |
| @@ -1955,7 +1957,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) · 2 unmodified lines | ||
| 1955 | 1957 | PUB_FUNC void tcc_set_environment(TCCState *s) |
| 1956 | 1958 | { |
| 1957 | 1959 | char * path; |
| 1958 | − | |
| 1960 | + | |
| 1959 | 1961 | path = getenv("C_INCLUDE_PATH"); |
| 1960 | 1962 | if(path != NULL) { |
| 1961 | 1963 | tcc_add_include_path(s, path); |