aboutsummaryrefslogtreecommitdiff
path: root/tcc.h
Commit message (Collapse)AuthorAgeFilesLines
* Change the way struct CStrings are handled.Edmund Grimley Evans2015-11-261-1/+5
| | | | | | | | | A CString used to be copied into a token string, which is an int array. On a 64-bit architecture the pointers were misaligned, so ASan gave lots of warnings. On a 64-bit architecture that required memory accesses to be correctly aligned it would not work at all. The CString is now included in CValue instead.
* tcc.h: Change order of built-in include paths: put TCC's own dir first.Edmund Grimley Evans2015-11-231-3/+3
| | | | | There may be compiler-specific header files that should override system headers. See TCC's include paths by running "tcc -vv".
* tccpp: cleanup #include_nextgrischka2015-11-201-1/+1
| | | | | | | | | | | | | | | | tcc_normalize_inc_dirs: normally no problem to be absolutly gcc compatible as long as it can be done the tiny way. This reverts to the state before recent related commits and reimplements a (small) part of it to fix the reported problem. Also: Revert "parsing "..." sequence" c3975cf27c792d493e76a2058a1eaf588324053e && p[1] == '.' is not a reliable way to lookahead
* tccgen: asm_label cleanupgrischka2015-11-201-1/+2
| | | | | | | - avoid memory allocation by using its (int) token number - avoid additional function parameter by using Attribute Also: fix some strange looking error messages
* Trivial changes to avoid some compiler warnings.Edmund Grimley Evans2015-11-191-4/+4
|
* Replace pointer casts with calls to (read|write)(16|32|64)le.Edmund Grimley Evans2015-11-191-0/+45
| | | | | This stops UBSan from giving runtime misaligned address errors and might eventually allow building on a non-little-endian host.
* Merge the integer members of union CValue into "uint64_t i".Edmund Grimley Evans2015-11-171-6/+1
|
* tcc.h: remove CONFIG_TCCBOOT partseyko2015-11-051-7/+0
| | | | | | curremtly no one will try to compile a linux kernel from the boot loader. With current tcc it is not possible w/o additional tuning.
* fix for the previous commitseyko2015-11-051-0/+1
| | | | | a cross-compilation from unix to win32 need a "sys/stat.h" include file
* normalize inc dirs, symplify include_nextseyko2015-11-051-0/+1
| | | | | | | | | include dirs are prepared as in gcc - for each duplicate path keep just the first one - remove each include_path that exists in sysinclude_paths include_next streamlined by introducing inc_path_index in the BufferedFile
* Define CONFIG_TCC_ELFINTERP on NetBSD as /usr/libexec/ld.elf_soKamil Rytarowski2015-10-111-0/+2
|
* Revert "fix-mixed-struct (patch by Pip Cet)"gus knight2015-07-291-5/+3
| | | | This reverts commit 4e04f67c94c97b4f28a4d73759a0ad38fb3a10f7. Requested by grischka.
* Revert all of my changes to directories & codingstyle.gus knight2015-07-291-0/+1498
|
* Reorganize the source tree.gus knight2015-07-271-1498/+0
| | | | | | | | | | * Documentation is now in "docs". * Source code is now in "src". * Misc. fixes here and there so that everything still works. I think I got everything in this commit, but I only tested this on Linux (Make) and Windows (CMake), so I might've messed something up on other platforms...
* Trim trailing spaces everywhere.gus knight2015-07-271-4/+4
|
* fix-mixed-struct (patch by Pip Cet)seyko2015-05-141-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Jsut for testing. It works for me (don't break anything) Small fixes for x86_64-gen.c in "tccpp: fix issues, add tests" are dropped in flavor of this patch. Pip Cet: Okay, here's a first patch that fixes the problem (but I've found another bug, yet unfixed, in the process), though it's not particularly pretty code (I tried hard to keep the changes to the minimum necessary). If we decide to actually get rid of VT_QLONG and VT_QFLOAT (please, can we?), there are some further simplifications in tccgen.c that might offset some of the cost of this patch. The idea is that an integer is no longer enough to describe how an argument is stored in registers. There are a number of possibilities (none, integer register, two integer registers, float register, two float registers, integer register plus float register, float register plus integer register), and instead of enumerating them I've introduced a RegArgs type that stores the offsets for each of our registers (for the other architectures, it's simply an int specifying the number of registers). If someone strongly prefers an enum, we could do that instead, but I believe this is a place where keeping things general is worth it, because this way it should be doable to add SSE or AVX support. There is one line in the patch that looks suspicious: } else { addr = (addr + align - 1) & -align; param_addr = addr; addr += size; - sse_param_index += reg_count; } break; However, this actually fixes one half of a bug we have when calling a function with eight double arguments "interrupted" by a two-double structure after the seventh double argument: f(double,double,double,double,double,double,double,struct { double x,y; },double); In this case, the last argument should be passed in %xmm7. This patch fixes the problem in gfunc_prolog, but not the corresponding problem in gfunc_call, which I'll try tackling next.
* redo of the -dD optionseyko2015-05-131-0/+2
| | | | | | | | functionality was broken some time ago and was removed by the "tccpp: fix issues, add tests" fix: LINE_MACRO_OUTPUT_FORMAT_NONE in pp_line() means: output '\n' and not "don't output at all"
* restore a max memory usage printing for a new MEM_DEBUG when -benchseyko2015-05-121-1/+1
|
* a new version of the MEM_DEBUGseyko2015-05-121-5/+15
|
* tcc_add_dll is not used if TCC_TARGET_PEseyko2015-05-101-0/+4
| | | | after "tccpp: fix issues, add tests"
* tccpp: fix issues, add testsgrischka2015-05-091-17/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * fix some macro expansion issues * add some pp tests in tests/pp * improved tcc -E output for better diff'ability * remove -dD feature (quirky code, exotic feature, didn't work well) Based partially on ideas / researches from PipCet Some issues remain with VA_ARGS macros (if used in a rather tricky way). Also, to keep it simple, the pp doesn't automtically add any extra spaces to separate tokens which otherwise would form wrong tokens if re-read from tcc -E output (such as '+' '=') GCC does that, other compilers don't. * cleanups - #line 01 "file" / # 01 "file" processing - #pragma comment(lib,"foo") - tcc -E: forward some pragmas to output (pack, comment(lib)) - fix macro parameter list parsing mess from a3fc54345949535524d01319e1ca6378b7c2c201 a715d7143d9d17da17e67fec6af1c01409a71a31 (some coffee might help, next time ;) - introduce TOK_PPSTR - to have character constants as written in the file (similar to TOK_PPNUM) - allow '\' appear in macros - new functions begin/end_macro to: - fix switching macro levels during expansion - allow unget_tok to unget more than one tok - slight speedup by using bitflags in isidnum_table Also: - x86_64.c : fix decl after statements - i386-gen,c : fix a vstack leak with VLA on windows - configure/Makefile : build on windows (MSYS) was broken - tcc_warning: fflush stderr to keep output order (win32)
* a lot simpler VLA codeseyko2015-05-041-6/+0
| | | | | | | | Author: Philip <pipcet@gmail.com> Our VLA code can be made a lot simpler (simple enough for even me to understand it) by giving up on the optimization idea, which is very tempting. There's a patch to do that attached, feel free to test and commit it if you like. (It passes all the tests, at least
* tccpp.c: fix GNU comma handlingPhilip2015-05-021-0/+1
| | | | | | | | | This requires moving TOK_PLCHLDR handling, but the new logic should make things easier even if (when?) GNU comma handling is removed. (Somewhat confusingly, GCC no longer supports GNU commas. See http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html for a description of past and current GCC behaviour.)
* tccpp.c: parse flag to accept stray \Philip2015-05-021-0/+1
| | | | | | | | | | | | | | | | | | | This adds a PARSE_FLAG_ACCEPT_STRAYS parse flag to accept stray backslashes in the source code, and uses it for pure preprocessing. For absolutely correct behaviour of # stringification, we need to use this flag when parsing macro definitions and in macro arguments, as well; this patch does not yet do so. The test case for that is something like #define STRINGIFY2(x) #x #define STRINGIFY(x) STRINGIFY2(x) STRINGIFY(\n) which should produce "\n", not a parse error or "\\n". See http://lists.nongnu.org/archive/html/tinycc-devel/2015-05/msg00002.html
* replace PARSE_FLAG_ASM_COMMENTS with PARSE_FLAG_ASM_FILEseyko2015-04-271-2/+1
| | | | | after "assign PARSE_FLAG_ASM_COMMENTS only for asm files" functions of this flags are identical
* Revert "* and #pragma pop_macro("macro_name")"grischka2015-04-231-1/+0
| | | | | | | | | | | | - pop_macro incorrect with initially undefined macro - horrible implementation (tcc_open_bf) - crashes eventually (abuse of Sym->prev_tok) - the (unrelated) asm_label part is the opposite of a fix (Despite of its name this variable has nothing to do with the built-in assembler) This reverts commit 0c8447db7970813292a8be74ee50e49091be5d15.
* * and #pragma pop_macro("macro_name")seyko2015-04-211-0/+1
| | | | | | | | | | * give warning if pragma is unknown for tcc * don't free asm_label in sym_free(), it's a job of the asm_free_labels(). The above pragmas are used in the mingw headers. Thise pragmas are implemented in gcc-4.5+ and current clang.
* ability to specify a type of the input file with the -x switchseyko2015-04-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Usage example: tcc -xc ex5.cgi From a gcc docs: You can specify the input language explicitly with the -x option: -x language Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next -x option. Possible values for language are: c c-header c-cpp-output c++ c++-header c++-cpp-output objective-c objective-c-header objective-c-cpp-output objective-c++ objective-c++-header objective-c++-cpp-output assembler assembler-with-cpp ada f77 f77-cpp-input f95 f95-cpp-input java -x none Turn off any specification of a language, so that subsequent files are handled according to their file name suffixes (as they are if -x has not been used at all)
* -fdollar-in-identifiers switch which enables '$' in identifiersseyko2015-04-121-0/+1
| | | | | | | | | | library Cello: http://libcello.org/ which uses `$` and several variations of as macros. There is also RayLanguage which also uses it as a macro for a kind of ObjC style message passing: https://github.com/kojiba/RayLanguage This is a patch from Daniel Holden.
* option to use an old algorithm of the array in struct initializationseyko2015-04-101-0/+2
| | | | | | This is for a case when no '{' is used in the initialization code. An option name is -fold-struct-init-code. A linux 2.4.26 can't find initrd when compiled with a new algorithm.
* fix a preprocessor for .Sseyko2015-04-101-0/+1
| | | | | | Lets assume that in *.S files a preprocessor directive follow '#' char w/o spaces between. Otherwise there is too many problems with the content of the comments.
* a bounds checking code for the ARCH=x86_64seyko2015-04-101-1/+1
|
* handle a -s option by executing sstrip/strip programseyko2015-04-101-0/+1
|
* fix the bug #31403: parser bug in structureseyko2015-04-101-0/+1
| | | | | | - a warning: unnamed struct/union that defines no instances - allow a nested named struct declaration w/o identifier only when option -fms-extensions is used
* fix for the previous commit (compilation on RPi)seyko2015-03-261-1/+1
|
* fix for: x86_64-tcc compiled by i386-tcc is wrongseyko2015-03-231-2/+2
| | | | | | | | | | | | | | | | | | | | | A test program (must be compiled by the above version of the tcc): /* Tickle a bug in TinyC on 64-bit systems: * the LSB of the top word or ARGP gets set * for no obvious reason. * * Source: a legacy language interpreter which * has a little stack / stack pointer for arguments. * * Output is: 0x8049620 0x10804961c * Should be: 0x8049620 0x804961c */ #include <stdio.h> #define NARGS 20000 int ARG[NARGS]; int *ARGSPACE = ARG; int *ARGP = ARG - 1; main() { printf("%p %p\n", ARGSPACE, ARGP); }
* fix to allow build tcc by build-tcc.batseyko2015-03-191-1/+1
| | | | | move call to print_defines() from tcc.c to the libtcc.c define a print_defines() as a ST_FUNC
* Fix stack overwrite on structure returnMichael Matz2015-03-091-1/+1
| | | | | | | | | The common code to move a returned structure packed into registers into memory on the caller side didn't take the register size into account when allocating local storage, so sometimes that lead to stack overwrites (e.g. in 73_arm64.c), on x86_64. This fixes it by generally making gfunc_sret also return the register size.
* arm64: Implement __clear_cache.Edmund Grimley Evans2015-03-081-0/+1
| | | | | | __clear_cache is defined in lib-arm64.c with a single call to __arm64_clear_cache, which is the real built-in function and is turned into inline assembler by gen_clear_cache in arm64-gen.c
* arm-unused-warnings: remove problems with defined but unused wariablesseyko2015-03-031-1/+1
| | | | | | | | | arm-gen.c: In function `gfunc_call': arm-gen.c:1202: warning: unused variable `variadic' arm-gen.c: In function `gfunc_prolog': arm-gen.c:1258: warning: unused variable `avregs' arm-gen.c:1340: warning: label `from_stack' defined but not used arm-gen.c:222: warning: 'default_elfinterp' defined but not used
* x86_64-win-tcc elfinterp: a bug correctionseyko2015-03-031-4/+4
| | | | | | | | | | | ./x86_64-win-tcc -vv Before elfinterp: /lib64/ld-linux-x86-64.so.2 After elfinterp: - This output is identical to the output of the i386-win-tcc
* lddir-on-x86-64: let CONFIG_LDDIR=lib64 by default if TCC_TARGET_X86_64seyko2015-03-031-1/+5
| | | | | This is done for the case when CONFIG_LDDIR is not configured. Example: ./configure --enable-cross
* A gcc preprocessor option -dD addedseyko2015-03-031-0/+2
| | | | | | | | | With this option on a defines are included into the output (inside comments). This will allow to debug a problems like: In file included from math.c:8: In file included from /usr/include/math.h:43: /usr/include/bits/nan.h:52: warning: NAN redefined
* Added a gcc preprocessor options -P, -P1seyko2015-03-031-0/+5
| | | | | | | | | | | tcc -E -P do not output a #line directive, a gcc compatible option tcc -E -P1 don't follow a gcc preprocessor style and do output a standard #line directive. In such case we don't lose a location info when we going to compile a resulting file wtith a compiler not understanding a gnu style line info.
* Move a line_ref variable from tcc_preprocess() function into struct ↵seyko2015-03-031-0/+1
| | | | | | | BufferedFile. This id needed for a right ouput in other places, precisely to calculate a number of empty lines which are waiting to output.
* Add arm64 (AArch64) as a target architecture.Edmund Grimley Evans2015-02-231-5/+25
|
* Use RELA relocations properly for R_DATA_PTR on x86_64.Edmund Grimley Evans2015-02-211-0/+2
| | | | | | | libtcc.c: Add greloca, a generalisation of greloc that takes an addend. tcc.h: Add greloca and put_elf_reloca. tccelf.c: Add put_elf_reloca, a generalisation of put_elf_reloc. tccgen.c: On x86_64, use greloca instead of greloc in init_putv.
* Allow tcc to understand a setob,... opcodes as alias to seto,...seyko2015-01-061-31/+31
| | | | | | PS: http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20101122/112576.html This is fix PR8686 for llvm: accepting a 'b' suffix at the end of all the setcc instructions.
* tcc.h (BufferedFile): Remove unnecessary static memory allocationLee Duhem2014-12-111-1/+1
| | | | | The memory needed by `buffer' will be allocated in `tcc_open_bf', these is no need to allocate them in BufferedFile statically.
* tccpe: adjust for new 'hidden' symbols featuregrischka2014-04-171-0/+4
| | | | | in order to avoid conflicts with windows specific (ab)usage of the Elf32_Sym -> st_other field.