From da8c62f75d893449e232944fc62566c020b4d010 Mon Sep 17 00:00:00 2001 From: grischka Date: Wed, 11 Oct 2017 18:13:43 +0200 Subject: various stuff win32/Makefile ("for cygwin") removed - On cygwin, the normal ./configure && make can be used with either cygwin's "GCC for Win32 Toolchain" ./configure --cross-prefix=i686-w64-mingw32- or with an existing tcc: ./configure --cc=/tcc.exe tcctest.c: - exclude test_high_clobbers() on _WIN64 (does not work) tests2/95_bitfield.c: - use 'signed char' for ARM (where default 'char' is unsigned) tests: - remove -I "expr" diff option to allow tests with busybox-diff. libtcc.c, tcc.c: - removed -iwithprefix option. It is supposed to be combined with -iprefix which we don't have either. tccgen.c: - fix assignments and return of 'void', as in void f() { void *p, *q; *p = *q: return *p; } This appears to be allowed but should do nothing. tcc.h, libtcc.c, tccpp.c: - Revert "Introduce VIP sysinclude paths which are always searched first" This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1. The patch was giving tcc's system includes priority over -I which is not how it should be. tccelf.c: - add DT_TEXTREL tag only if text relocations are actually used (which is likely not the case on x86_64) - prepare_dynamic_rel(): avoid relocation of unresolved (weak) symbols tccrun.c: - for HAVE_SELINUX, use two mappings to the same (real) file. (it was so once except the RX mapping wasn't used at all). tccpe.c: - fix relocation constant used for x86_64 (by Andrei E. Warentin) - #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin. tccasm.c: - keep forward asm labels static, otherwise they will endup in dynsym eventually. configure, Makefile: - mingw32: respect ./configure options --bindir --docdir --libdir - allow overriding tcc when building libtcc1.a and libtcc.def with make XTCC= - use $(wildcard ...) for install to allow installing just a cross compiler for example make cross-arm make install - use name -libtcc1.a build-tcc.bat: - add options: -clean, -b bindir --- tccpp.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) (limited to 'tccpp.c') diff --git a/tccpp.c b/tccpp.c index 3d11dc3..76f9e42 100644 --- a/tccpp.c +++ b/tccpp.c @@ -591,7 +591,7 @@ ST_FUNC int handle_eob(void) /* only tries to read if really end of buffer */ if (bf->buf_ptr >= bf->buf_end) { - if (bf->fd != -1) { + if (bf->fd >= 0) { #if defined(PARSE_DEBUG) len = 1; #else @@ -1803,8 +1803,7 @@ ST_FUNC void preprocess(int is_bof) /* store current file in stack, but increment stack later below */ *s1->include_stack_ptr = file; i = tok == TOK_INCLUDE_NEXT ? file->include_next_index : 0; - n = 2 + s1->nb_tccinclude_paths + s1->nb_include_paths + - s1->nb_sysinclude_paths; + n = 2 + s1->nb_include_paths + s1->nb_sysinclude_paths; for (; i < n; ++i) { char buf1[sizeof file->filename]; CachedInclude *e; @@ -1826,14 +1825,8 @@ ST_FUNC void preprocess(int is_bof) } else { /* search in all the include paths */ - int k, j = i - 2; - - if (j < (k = s1->nb_tccinclude_paths)) - path = s1->tccinclude_paths[j]; - else if ((j -= k) < s1->nb_include_paths) - path = s1->include_paths[j]; - else if ((j -= s1->nb_include_paths) < s1->nb_sysinclude_paths) - path = s1->sysinclude_paths[j]; + int j = i - 2, k = j - s1->nb_include_paths; + path = k < 0 ? s1->include_paths[j] : s1->sysinclude_paths[k]; pstrcpy(buf1, sizeof(buf1), path); pstrcat(buf1, sizeof(buf1), "/"); } @@ -2635,6 +2628,8 @@ static inline void next_nomacro1(void) tcc_close(); s1->include_stack_ptr--; p = file->buf_ptr; + if (p == file->buffer) + tok_flags = TOK_FLAG_BOF|TOK_FLAG_BOL; goto redo_no_start; } } @@ -2968,7 +2963,7 @@ maybe_newline: keep_tok_flags: file->buf_ptr = p; #if defined(PARSE_DEBUG) - printf("token = %s\n", get_tok_str(tok, &tokc)); + printf("token = %d %s\n", tok, get_tok_str(tok, &tokc)); #endif } @@ -3585,7 +3580,8 @@ ST_INLN void unget_tok(int last_tok) ST_FUNC void preprocess_start(TCCState *s1, int is_asm) { - char *buf; + CString cstr; + int i; s1->include_stack_ptr = s1->include_stack; s1->ifdef_stack_ptr = s1->ifdef_stack; @@ -3601,25 +3597,24 @@ ST_FUNC void preprocess_start(TCCState *s1, int is_asm) set_idnum('$', s1->dollars_in_identifiers ? IS_ID : 0); set_idnum('.', is_asm ? IS_ID : 0); - buf = tcc_malloc(3 + strlen(file->filename)); - sprintf(buf, "\"%s\"", file->filename); - tcc_define_symbol(s1, "__BASE_FILE__", buf); - tcc_free(buf); - - if (s1->nb_cmd_include_files) { - CString cstr; - int i; - cstr_new(&cstr); - for (i = 0; i < s1->nb_cmd_include_files; i++) { - cstr_cat(&cstr, "#include \"", -1); - cstr_cat(&cstr, s1->cmd_include_files[i], -1); - cstr_cat(&cstr, "\"\n", -1); - } + cstr_new(&cstr); + cstr_cat(&cstr, "\"", -1); + cstr_cat(&cstr, file->filename, -1); + cstr_cat(&cstr, "\"", 0); + tcc_define_symbol(s1, "__BASE_FILE__", cstr.data); + + cstr_reset(&cstr); + for (i = 0; i < s1->nb_cmd_include_files; i++) { + cstr_cat(&cstr, "#include \"", -1); + cstr_cat(&cstr, s1->cmd_include_files[i], -1); + cstr_cat(&cstr, "\"\n", -1); + } + if (cstr.size) { *s1->include_stack_ptr++ = file; tcc_open_bf(s1, "", cstr.size); memcpy(file->buffer, cstr.data, cstr.size); - cstr_free(&cstr); } + cstr_free(&cstr); if (is_asm) tcc_define_symbol(s1, "__ASSEMBLER__", NULL); -- cgit v1.3.1