History

struct variable behind guard, proper macro check, and remove some whitespace.

Wrap runtime_main as per its declaration in tcc.h. Fix preprocessor check for TCC_ARM_EABI macro definition.

Joseph Poirier committed 13 years ago

Commit 0650ab01 parent fbb48412 files · +56 −54Browse files

Unified · Split

2 files
  1. arm-gen.c +17 −17
  2. libtcc.c +39 −37
arm-gen.c+17−17
@@ -1,6 +1,6 @@
11 /*
22 * ARMv4 code generator for TCC
3− *
3+ *
44 * Copyright (c) 2003 Daniel Gl�ckner
55 * Copyright (c) 2012 Thomas Preud'homme
66 *
@@ -46,7 +46,7 @@ · 39 unmodified lines
4646 #define RC_INT 0x0001 /* generic integer register */
4747 #define RC_FLOAT 0x0002 /* generic float register */
4848 #define RC_R0 0x0004
49−#define RC_R1 0x0008
49+#define RC_R1 0x0008
5050 #define RC_R2 0x0010
5151 #define RC_R3 0x0020
5252 #define RC_R12 0x0040
@@ -211,7 +211,7 @@ void o(uint32_t i) · 158 unmodified lines
211211 cur_text_section->data[ind++] = i&255;
212212 i>>=8;
213213 cur_text_section->data[ind++] = i&255;
214− i>>=8;
214+ i>>=8;
215215 cur_text_section->data[ind++] = i&255;
216216 i>>=8;
217217 cur_text_section->data[ind++] = i;
@@ -506,7 +506,7 @@ void load(int r, SValue *sv) · 288 unmodified lines
506506 sign=1;
507507 fc=-fc;
508508 }
509−
509+
510510 v = fr & VT_VALMASK;
511511 if (fr & VT_LVAL) {
512512 uint32_t base = 0xB; // fp
@@ -645,8 +645,8 @@ void store(int r, SValue *sv) · 132 unmodified lines
645645 sign=1;
646646 fc=-fc;
647647 }
648−
649− v = fr & VT_VALMASK;
648+
649+ v = fr & VT_VALMASK;
650650 if (fr & VT_LVAL || fr == VT_LOCAL) {
651651 uint32_t base = 0xb;
652652 if(v < VT_CONST) {
@@ -660,16 +660,16 @@ void store(int r, SValue *sv) · 7 unmodified lines
660660 v1.sym=sv->sym;
661661 load(base=14, &v1);
662662 fc=sign=0;
663− v=VT_LOCAL;
663+ v=VT_LOCAL;
664664 }
665665 if(v == VT_LOCAL) {
666666 if(is_float(ft)) {
667667 calcaddr(&base,&fc,&sign,1020,2);
668668 #ifdef TCC_ARM_VFP
669669 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)
673673 op|=0x100; /* fsts -> fstd */
674674 o(op|(vfpr(r)<<12)|(fc>>2)|(base<<16));
675675 #else
@@ -802,7 +802,7 @@ int assign_fpreg(struct avail_regs *avregs, int align, int size) · 126 unmodified lines
802802
803803 /* Return 1 if this function returns via an sret pointer, 0 otherwise */
804804 ST_FUNC int gfunc_sret(CType *vt, CType *ret, int *ret_align) {
805−#if TCC_ARM_EABI
805+#ifdef TCC_ARM_EABI
806806 int size, align;
807807 size = type_size(vt, &align);
808808 if (size > 4) {
@@ -855,7 +855,7 @@ void gfunc_call(int nb_args) · 46 unmodified lines
855855 vtop[-nb_args+1]=tmp;
856856 --nb_args;
857857 }
858−
858+
859859 vpushi(0), nb_args++;
860860 vtop->type.t = VT_LLONG;
861861 #endif
@@ -1023,7 +1023,7 @@ void gfunc_call(int nb_args) · 161 unmodified lines
10231023 size = 8;
10241024 else
10251025 size = LDOUBLE_SIZE;
1026−
1026+
10271027 if (size == 12)
10281028 r|=0x400000;
10291029 else if(size == 8)
@@ -1362,7 +1362,7 @@ int gtst(int inv, int t) · 332 unmodified lines
13621362 return gtst(inv, t);
13631363 } else if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
13641364 /* constant jmp optimization */
1365− if ((vtop->c.i != 0) != inv)
1365+ if ((vtop->c.i != 0) != inv)
13661366 t = gjmp(t);
13671367 } else {
13681368 v = gv(RC_INT);
@@ -1370,7 +1370,7 @@ int gtst(int inv, int t) · 1 unmodified line
13701370 vtop->r = VT_CMP;
13711371 vtop->c.i = TOK_NE;
13721372 return gtst(inv, t);
1373− }
1373+ }
13741374 }
13751375 vtop--;
13761376 return t;
@@ -1628,7 +1628,7 @@ void gen_opf(int op) · 251 unmodified lines
16281628 case TOK_UGE: op=TOK_GE; break;
16291629 case TOK_UGT: op=TOK_GT; break;
16301630 }
1631−
1631+
16321632 vtop->r = VT_CMP;
16331633 vtop->c.i = op;
16341634 return;
@@ -1779,7 +1779,7 @@ void gen_opf(int op) · 144 unmodified lines
17791779 r=fpr(gv(RC_FLOAT));
17801780 vswap();
17811781 r2=fpr(gv(RC_FLOAT));
1782− }
1782+ }
17831783 break;
17841784 default:
17851785 if(op >= TOK_ULT && op <= TOK_GT) {
libtcc.c+39−37
@@ -1,6 +1,6 @@
11 /*
22 * TCC - Tiny C Compiler
3− *
3+ *
44 * Copyright (c) 2001-2004 Fabrice Bellard
55 *
66 * 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
156156 {
157157 int len;
158158 len = strlen(buf);
159− if (len < buf_size)
159+ if (len < buf_size)
160160 pstrcpy(buf + len, buf_size - len, s);
161161 return buf;
162162 }
@@ -275,7 +275,7 @@ ST_FUNC void dynarray_add(void ***ptab, int *nb_ptr, void *data) · 112 unmodified lines
275275 {
276276 int nb, nb_alloc;
277277 void **pp;
278−
278+
279279 nb = *nb_ptr;
280280 pp = *ptab;
281281 /* 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
371371 {
372372 unsigned long size;
373373 unsigned char *data;
374−
374+
375375 size = sec->data_allocated;
376376 if (size == 0)
377377 size = 1;
@@ -414,7 +414,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) · 36 unmodified lines
414414 int i;
415415 for(i = 1; i < s1->nb_sections; i++) {
416416 sec = s1->sections[i];
417− if (!strcmp(name, sec->name))
417+ if (!strcmp(name, sec->name))
418418 return sec;
419419 }
420420 /* sections are created as PROGBITS */
@@ -423,7 +423,7 @@ ST_FUNC Section *find_section(TCCState *s1, const char *name) · 2 unmodified lines
423423
424424 /* update sym->c so that it points to an external symbol in section
425425 '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,
427427 addr_t value, unsigned long size,
428428 int can_add_underscore)
429429 {
@@ -434,7 +434,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 4 unmodified lines
434434
435435 if (section == NULL)
436436 sh_num = SHN_UNDEF;
437− else if (section == SECTION_ABS)
437+ else if (section == SECTION_ABS)
438438 sh_num = SHN_ABS;
439439 else
440440 sh_num = section->sh_num;
@@ -468,13 +468,13 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 27 unmodified lines
468468 switch(sym->v) {
469469 #ifdef TCC_TARGET_PE
470470 /* 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:
476476 #endif
477− case TOK_memcpy:
477+ case TOK_memcpy:
478478 case TOK_memmove:
479479 case TOK_memset:
480480 case TOK_strlen:
@@ -527,7 +527,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section, · 46 unmodified lines
527527 }
528528 }
529529
530−ST_FUNC void put_extern_sym(Sym *sym, Section *section,
530+ST_FUNC void put_extern_sym(Sym *sym, Section *section,
531531 addr_t value, unsigned long size)
532532 {
533533 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
567567 {
568568 char buf[2048];
569569 BufferedFile **pf, *f;
570−
570+
571571 buf[0] = '\0';
572572 /* use upper file if inline ":asm:" or token ":paste:" */
573573 for (f = file; f && f->filename[0] == ':'; f = f->prev)
@@ -718,28 +718,28 @@ static int tcc_compile(TCCState *s1) · 144 unmodified lines
718718
719719 cur_text_section = NULL;
720720 funcname = "";
721− anon_sym = SYM_FIRST_ANOM;
721+ anon_sym = SYM_FIRST_ANOM;
722722
723723 /* file info: full path + filename */
724724 section_sym = 0; /* avoid warning */
725725 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,
728728 text_section->sh_num, NULL);
729729 getcwd(buf, sizeof(buf));
730730 #ifdef _WIN32
731731 normalize_slashes(buf);
732732 #endif
733733 pstrcat(buf, sizeof(buf), "/");
734− put_stabs_r(buf, N_SO, 0, 0,
734+ put_stabs_r(buf, N_SO, 0, 0,
735735 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,
737737 text_section->data_offset, text_section, section_sym);
738738 }
739739 /* an elf symbol of type STT_FILE must be put so that STB_LOCAL
740740 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,
743743 SHN_ABS, file->filename);
744744
745745 /* define some often used types */
@@ -794,7 +794,7 @@ static int tcc_compile(TCCState *s1) · 48 unmodified lines
794794
795795 /* end of translation unit info */
796796 if (s1->do_debug) {
797− put_stabs_r(NULL, N_SO, 0, 0,
797+ put_stabs_r(NULL, N_SO, 0, 0,
798798 text_section->data_offset, text_section, section_sym);
799799 }
800800 }
@@ -803,7 +803,7 @@ static int tcc_compile(TCCState *s1) · 2 unmodified lines
803803
804804 /* reset define stack, but leave -Dsymbols (may be incorrect if
805805 they are undefined) */
806− free_defines(define_start);
806+ free_defines(define_start);
807807
808808 gen_inline_functions();
809809
@@ -1004,13 +1004,13 @@ LIBTCCAPI TCCState *tcc_new(void) · 194 unmodified lines
10041004 /* symbols are always generated for linking stage */
10051005 symtab_section = new_symtab(s, ".symtab", SHT_SYMTAB, 0,
10061006 ".strtab",
1007− ".hashtab", SHF_PRIVATE);
1007+ ".hashtab", SHF_PRIVATE);
10081008 strtab_section = symtab_section->link;
10091009 s->symtab = symtab_section;
1010−
1010+
10111011 /* private symbol table for dynamic symbols */
10121012 s->dynsymtab_section = new_symtab(s, ".dynsymtab", SHT_SYMTAB, SHF_PRIVATE,
1013− ".dynstrtab",
1013+ ".dynstrtab",
10141014 ".dynhashtab", SHF_PRIVATE);
10151015 s->alacarte_link = 1;
10161016 s->nocommon = 1;
@@ -1026,7 +1026,9 @@ LIBTCCAPI TCCState *tcc_new(void) · 9 unmodified lines
10261026 #ifdef TCC_TARGET_I386
10271027 s->seg_size = 32;
10281028 #endif
1029+#ifdef TCC_IS_NATIVE
10291030 s->runtime_main = "main";
1031+#endif
10301032 return s;
10311033 }
10321034
@@ -1044,7 +1046,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 11 unmodified lines
10441046 for(i = 0; i < s1->nb_priv_sections; i++)
10451047 free_section(s1->priv_sections[i]);
10461048 dynarray_reset(&s1->priv_sections, &s1->nb_priv_sections);
1047−
1049+
10481050 /* free any loaded DLLs */
10491051 #ifdef TCC_IS_NATIVE
10501052 for ( i = 0; i < s1->nb_loaded_dlls; i++) {
@@ -1053,7 +1055,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 2 unmodified lines
10531055 dlclose(ref->handle);
10541056 }
10551057 #endif
1056−
1058+
10571059 /* free loaded dlls array */
10581060 dynarray_reset(&s1->loaded_dlls, &s1->nb_loaded_dlls);
10591061
@@ -1079,7 +1081,7 @@ LIBTCCAPI void tcc_delete(TCCState *s1) · 19 unmodified lines
10791081 #ifdef TCC_IS_NATIVE
10801082 # ifdef HAVE_SELINUX
10811083 munmap (s1->write_mem, s1->mem_size);
1082− munmap (s1->runtime_mem, s1->mem_size);
1084+ munmap (s1->runtime_mem, s1->mem_size);
10831085 # else
10841086 tcc_free(s1->runtime_mem);
10851087 # endif
@@ -1186,7 +1188,7 @@ ST_FUNC int tcc_add_file_internal(TCCState *s1, const char *filename, int flags) · 100 unmodified lines
11861188 #endif
11871189 ret = 0;
11881190 } else {
1189− ret = tcc_load_dll(s1, fd, filename,
1191+ ret = tcc_load_dll(s1, fd, filename,
11901192 (flags & AFF_REFERENCED_DLL) != 0);
11911193 }
11921194 goto the_end;
@@ -1318,9 +1320,9 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 125 unmodified lines
13181320 /* define symbol */
13191321 tcc_define_symbol(s, "__BOUNDS_CHECKING_ON", NULL);
13201322 /* create bounds sections */
1321− bounds_section = new_section(s, ".bounds",
1323+ bounds_section = new_section(s, ".bounds",
13221324 SHT_PROGBITS, SHF_ALLOC);
1323− lbounds_section = new_section(s, ".lbounds",
1325+ lbounds_section = new_section(s, ".lbounds",
13241326 SHT_PROGBITS, SHF_ALLOC);
13251327 }
13261328 #endif
@@ -1693,7 +1695,7 @@ static const TCCOption tcc_options[] = { · 366 unmodified lines
16931695 { "isystem", TCC_OPTION_isystem, TCC_OPTION_HAS_ARG },
16941696 { "nostdinc", TCC_OPTION_nostdinc, 0 },
16951697 { "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 },
16971699 { "v", TCC_OPTION_v, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
16981700 { "w", TCC_OPTION_w, 0 },
16991701 { "pipe", TCC_OPTION_pipe, 0},
@@ -1859,7 +1861,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 159 unmodified lines
18591861 goto unsupported_option;
18601862 break;
18611863 case TCC_OPTION_W:
1862− if (tcc_set_warning(s, optarg, 1) < 0 &&
1864+ if (tcc_set_warning(s, optarg, 1) < 0 &&
18631865 s->warn_unsupported)
18641866 goto unsupported_option;
18651867 break;
@@ -1946,7 +1948,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) · 80 unmodified lines
19461948 tt = 0.001;
19471949 if (total_bytes < 1)
19481950 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",
19501952 tok_ident - TOK_IDENT, total_lines, total_bytes,
19511953 tt, (int)(total_lines / tt),
19521954 total_bytes / tt / 1000000.0);
@@ -1955,7 +1957,7 @@ PUB_FUNC void tcc_print_stats(TCCState *s, int64_t total_time) · 2 unmodified lines
19551957 PUB_FUNC void tcc_set_environment(TCCState *s)
19561958 {
19571959 char * path;
1958−
1960+
19591961 path = getenv("C_INCLUDE_PATH");
19601962 if(path != NULL) {
19611963 tcc_add_include_path(s, path);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t