Commit Graph

75 Commits

Author SHA1 Message Date
Edmund Grimley Evans
eb00777309 tcctok.h: Put TOK_memmove in the correct places (I hope).
This should have been part of b051549. Someone should test on ARM.
2015-11-05 19:37:04 +00:00
Edmund Grimley Evans
7f0b798418 tcctok.h: Revert 41408f2, which moved TOK_memmove. 2015-11-05 19:33:46 +00:00
seyko
41408f2104 fix for the "tccgen.c: Use memmove for struct assignment"
./configure --enable-cross
    make
    tcc -o i386-tcc tcc.c
    tcc -o x86_64-tcc tcc.c
    tcc -o i386-win-tcc tcc.c
    In file included from tcc.c:22:
    In file included from libtcc.c:39:
    tccgen.c:2580: error: 'TOK_memmove' undeclared
2015-11-05 20:24:04 +03:00
gus knight
89ad24e7d6 Revert all of my changes to directories & codingstyle. 2015-07-29 16:57:12 -04:00
gus knight
47e06c6d4e Reorganize the source tree.
* 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...
2015-07-27 16:03:25 -04:00
gus knight
41031221c8 Trim trailing spaces everywhere. 2015-07-27 12:43:40 -04:00
grischka
72e8ff11e9 tccpp: alternative #pragma push/pop_macro
using next_nomacro() so that for example
    #define push_macro foobar
does not affect how the pragma works (same behavior
as gcc, albeit not MS's cl).
2015-04-23 23:27:36 +02:00
grischka
7c27186a83 Revert "* and #pragma pop_macro("macro_name")"
- 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 0c8447db79.
2015-04-23 23:26:46 +02:00
seyko
b08ce88082 "#pragma once" implementation 2015-04-21 15:46:29 +03:00
seyko
0c8447db79 * and #pragma pop_macro("macro_name")
* 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.
2015-04-21 06:34:35 +03:00
Steven G. Messervey
aeaff94ec1 implement #pragma comment(lib,...) 2015-04-15 22:56:21 -04:00
Steven G. Messervey
e50d68e417 Revert "implement #pragma comment(lib,...)"
This reverts commit 8615bb40fb.

Reverting as it breaks on MinGW targets
2015-04-15 21:24:15 -04:00
Steven G. Messervey
8615bb40fb implement #pragma comment(lib,...) 2015-04-15 17:00:26 -04:00
seyko
e7a60e4d01 replace a method to force bcheck.o linking
* define __bound_init as external_global_sym insteed of the compiling
      a tiny program
    * remove warning about buf[] when CONFIG_TCC_BCHECK is not defined
2015-04-12 04:47:15 +03:00
Edmund Grimley Evans
d73b488401 arm64: Implement __clear_cache.
__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
2015-03-08 00:10:44 +00:00
Edmund Grimley Evans
238e760a29 Add __builtin_return_address.
Implementation is mostly shared with __builtin_frame_address.
It seems to work on arm64, i386 and x86_64. It may need to be
adapted for other targets.
2015-03-06 21:01:14 +00:00
seyko
664c19ad5e partial revert of the commit 4ad186c5ef
A test program:

    /* result of the new version inroduced in 4ad186c5ef: t2a = 44100312 */
    #include<stdio.h>
    int main() {
	int t1 = 176401255;
	float f = 0.25f;
	int t2a = (int)(t1 * f); // must be 44100313
	int t2b = (int)(t1 * (float)0.25f);
	printf("t2a=%d t2b=%d \n",t2a,t2b);
	return 0;
    }
2015-03-04 16:25:51 +03:00
Edmund Grimley Evans
b14ef0e24b Add arm64 (AArch64) as a target architecture. 2015-02-23 22:51:03 +00:00
Reimar Döffinger
ff783b94c7 Add support for .p2align asm directive.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
2015-01-20 08:49:49 +01:00
Michael Matz
a9fda392a0 Parse assembler .hidden directive
This makes TCCs assembler understand the '.hidden symbol' directive
(and emits a STV_HIDDEN ELF symbol then).
2014-04-14 03:33:50 +02:00
Michael Matz
fbda78aefe Parse and emit hidden visibility
This adds parsing of (GCC compatible) visibility attribute
in order to mark selected global symbols as hidden.  The generated
.o files contain hidden symbols already, the TCC linker doesn't
yet do the right thing.
2014-04-14 02:53:11 +02:00
Thomas Preud'homme
b125743323 Create bcheck region for argv and arge argument
For program manipulating argv or arge as pointer with construct such as:

(while *argv++) {
  do_something_with_argv;
}

it is necessary to have argv and arge inside a region. This patch create
regions argv and arge) if main is declared with those parameters.
2014-03-29 14:46:26 +08:00
grischka
4ad186c5ef i386: use __fixdfdi instead of __tcc_cvt_ftol
Variants __fixsfdi/__fixxfdi are not needed for now because
the value is converted to double always.

Also:
- remove __tcc_fpinit for unix as it seems redundant by the
  __setfpucw call in the startup code
- avoid reference to s->runtime_main in cross compilers
- configure: fix --with-libgcc help
- tcctok.h: cleanup
2014-01-06 19:07:08 +01:00
Thomas Preud'homme
cf02f920c1 Revert "Add support for thread-local storage variables"
TLS support in tinyCC is absolutely not ready:
- segment register not select in load and store
- no relocation added for computing offset of per-thread symbol
- no support for TLS-specific relocations
- no program header added as per Drepper document about TLS

This reverts commit 1c4afd1350.
2013-11-03 18:55:54 +08:00
Thomas Preud'homme
1c4afd1350 Add support for thread-local storage variables 2013-10-29 22:10:02 +08:00
grischka
73faaea227 i386-gen: preserve fp control word in gen_cvt_ftoi
- Use runtime function for conversion
- Also initialize fp with tcc -run on windows

This fixes a bug where
  double x = 1.0;
  double y = 1.0000000000000001;
  double z = x < y ? 0 : sqrt (x*x - y*y);
caused a bad sqrt because rounding precision for the x < y comparison
was different to the one used within the sqrt function.

This also fixes a bug where
  printf("%d, %d", (int)pow(10, 2), (int)pow(10, 2));
would print
  100, 99

Unrelated:
  win32: document relative include & lib lookup
  win32: normalize_slashes: do not mirror silly gcc behavior
  This reverts part of commit 8a81f9e103
  winapi: add missing WINAPI decl. for some functions
2013-08-28 22:55:05 +02:00
James Lyon
5c35ba66c5 64-bit tests now pass (well, nearly).
tcctest1-3 fail, but this appears to be due to bugs in GCC rather than TCC
(from manual inspection of the output).
2013-04-24 02:19:15 +01:00
Joe Soroka
46e2dd7c32 tcctok.h: fix ifdef target/host confusion 2011-04-12 00:11:47 -07:00
Joe Soroka
ace0f7f259 re-apply VLA by Thomas Preud'homme 2011-04-06 09:17:03 -07:00
Joe Soroka
c93eca4fe4 tccgen: handle __attribute((alias("target"))) 2011-03-03 01:58:45 -08:00
Thomas Preud'homme
c1b7267a2f Revert "Make TOK_alloca available for x86-64"
This reverts commit af26ac56bf.
2011-02-05 02:33:45 +01:00
Thomas Preud'homme
af26ac56bf Make TOK_alloca available for x86-64
TOK_alloca is now available on x86-64 so make put definition of
TOK_alloca outside the BCHECK conditional macro definition but test if
arch is i386 or x86-64. This makes C99 VLA works (understand compile) on
x86-64.
2011-02-04 13:25:38 +01:00
Shinichiro Hamaji
0ed7ba3f5e Support struct arguments with stdarg.h
- add __builtin_va_arg_types to check how arguments were passed
- move most code of stdarg into libtcc1.c
- remove __builtin_malloc and __builtin_free
- add a test case based on the bug report
  (http://www.mail-archive.com/tinycc-devel@nongnu.org/msg03036.html)
2010-12-28 19:32:40 +09:00
Thomas Preud'homme
8eb86ab78d Add nan, snan and inf float constants 2010-05-06 02:20:35 +02:00
Detlef Riekenberg
a135dd50c6 tccasm: Detect (but ignore) .ident directive
tcc is now able to compile many asm files generated by gcc

--
By by ... Detlef
2010-04-05 12:45:52 +02:00
Detlef Riekenberg
558258a301 tccasm: Detect (but ignore) .size directive
--
By by ... Detlef
2010-04-05 12:43:51 +02:00
Detlef Riekenberg
6825c5db72 tccasm: Support .type directive (only name,@function)
--
By by ... Detlef
2010-04-05 12:31:45 +02:00
Detlef Riekenberg
9ff7a0bc98 tccasm: Detect (but ignore) the .file directive
Some patches, to allow tcc to compile asm sources generated by gcc
and help tcc with the autoconf stuff used in Wine
( http://source.winehq.org/git/wine.git/ )

--
By by ... Detlef
2010-04-05 12:19:49 +02:00
Manuel Simoni
95b9a477b6 weak function symbols 2010-02-27 17:37:59 +01:00
Detlef Riekenberg
a975008ae7 Add support for the __mode__ attribute
--
By by ... Detlef
2010-01-26 22:56:22 +01:00
grischka
7fa712e00c win32: enable bounds checker & exception handler
exception handler borrowed from k1w1. Thanks.
2009-12-19 22:22:43 +01:00
grischka
1308e8ebcf integrate x86_64-asm.c into i386-asm.c
Also, disable 16bit support for now as it causes bugs
in 32bit mode.  #define I386_ASM_16 if you want it.
2009-12-19 22:16:20 +01:00
Frederic Feret
ae23c46ce2 fixed and added missing file for x86_64 assembly 2009-11-13 18:09:01 +01:00
Frederic Feret
526c464504 first support of x86_64 assembly 2009-11-13 18:08:59 +01:00
Frederic Feret
0d768b9713 added 16-bit x86 assembly support 2009-11-13 18:08:58 +01:00
grischka
5b113f3ee3 win32: handle __declspec(dllimport) 2009-11-13 18:04:56 +01:00
grischka
110a4edc15 drop alloca #define
(Because GNU's alloca.h unconditionally #undef's alloca)

Also, remove gcc specific sections in headers. and
instead change tests such that gcc does not use them.
2009-05-16 22:30:13 +02:00
grischka
9a8b2912ed TOK_builtin_malloc: alternative solution 2009-04-18 15:08:02 +02:00
Shinichiro Hamaji
ebb874e216 Remove multiple definition error caused by combination of x86-64 and va_list.
We need malloc and free to implement va_start and va_end.
Since malloc and free may be replaced by #define, we add __builtin_malloc and __builtin_free.
2009-04-18 15:07:09 +02:00
Shinichiro Hamaji
d6072d3703 Add __builtin_frame_address(0)
Adding the GCC extension __builtin_frame_address(). We support only zero as the argument for now.
With this functionality, we can implement GCC compatible stdarg by macros in x86-64.
2008-12-02 02:25:59 +01:00