From b0b2d5d2e9548c83aab494831def6e028eecc9e4 Mon Sep 17 00:00:00 2001 From: bellard Date: Mon, 17 Dec 2001 21:57:01 +0000 Subject: [PATCH] update --- Makefile | 30 ++++++++++++++++++++---------- README | 49 +++++++------------------------------------------ TODO | 14 +++++++------- stdbool.h | 10 ++++++++++ stddef.h | 3 ++- tcc-doc.texi | 4 ++-- tcclib.h | 1 + 7 files changed, 49 insertions(+), 62 deletions(-) create mode 100644 stdbool.h diff --git a/Makefile b/Makefile index 435a0803..e8288289 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,13 @@ prefix=/usr/local CFLAGS=-O2 -g -Wall -Wno-parentheses -Wno-missing-braces -I. LIBS=-ldl -#CFLAGS=-O2 -g -Wall -Wno-parentheses -I. -pg -static -DPROFILE -#LIBS= +CFLAGS_P=$(CFLAGS) -pg -static -DCONFIG_TCC_STATIC +LIBS_P= CFLAGS+=-m386 -malign-functions=0 DISAS=objdump -D -b binary -m i386 INSTALL=install -VERSION=0.9.1 +VERSION=0.9.2 all: tcc @@ -21,7 +21,7 @@ test: test.ref test.out @if diff -u test.ref test.out ; then echo "Auto Test OK"; fi prog.ref: prog.c - gcc $(CFLAGS) -o $@ $< + gcc3 $(CFLAGS) -o $@ $< test.ref: prog.ref ./prog.ref > $@ @@ -33,12 +33,12 @@ run: tcc prog.c ./tcc -I. prog.c # iterated test2 (compile tcc then compile prog.c !) -test2: tcc tcc.c prog.c +test2: tcc tcc.c prog.c test.ref ./tcc -I. tcc.c -I. prog.c > test.out2 @if diff -u test.ref test.out2 ; then echo "Auto Test2 OK"; fi # iterated test3 (compile tcc then compile tcc then compile prog.c !) -test3: tcc tcc.c prog.c +test3: tcc tcc.c prog.c test.ref ./tcc -I. tcc.c -I. tcc.c -I. prog.c > test.out3 @if diff -u test.ref test.out3 ; then echo "Auto Test3 OK"; fi @@ -57,7 +57,7 @@ ex3: ex3.c # Tiny C Compiler -tcc_g: tcc.c Makefile +tcc_g: tcc.c i386-gen.c Makefile gcc $(CFLAGS) -o $@ $< $(LIBS) tcc: tcc_g @@ -66,11 +66,15 @@ tcc: tcc_g install: tcc $(INSTALL) -m755 tcc $(prefix)/bin mkdir -p $(prefix)/lib/tcc - $(INSTALL) -m644 stdarg.h stddef.h tcclib.h $(prefix)/lib/tcc + $(INSTALL) -m644 stdarg.h stddef.h float.h tcclib.h $(prefix)/lib/tcc clean: rm -f *~ *.o tcc tcc1 tcct tcc_g prog.ref *.bin *.i ex2 \ - core gmon.out test.out test.ref a.out + core gmon.out test.out test.ref a.out tcc_p + +# profiling version +tcc_p: tcc.c Makefile + gcc $(CFLAGS_P) -o $@ $< $(LIBS_P) # target for development @@ -78,6 +82,9 @@ clean: ./tcc -o $@ -I. $< $(DISAS) $@ +instr: instr.o + objdump -d instr.o + instr.o: instr.S gcc -O2 -Wall -g -c -o $@ $< @@ -88,6 +95,9 @@ tar: cp -r ../tcc /tmp/$(FILE) ( cd /tmp ; tar zcvf ~/$(FILE).tar.gz \ $(FILE)/Makefile $(FILE)/README $(FILE)/TODO $(FILE)/COPYING \ - $(FILE)/tcc.c $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/tcclib.h \ + $(FILE)/Changelog $(FILE)/tcc-doc.html \ + $(FILE)/tcc.c $(FILE)/i386-gen.c \ + $(FILE)/stddef.h $(FILE)/stdarg.h $(FILE)/stdbool.h $(FILE)/float.h \ + $(FILE)/tcclib.h \ $(FILE)/ex*.c $(FILE)/prog.c ) rm -rf /tmp/$(FILE) diff --git a/README b/README index 67bf04d4..4043652d 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ Features: -------- - SMALL! You can compile and execute C code everywhere, for example on - rescue disks (29KB for x86 TCC executable). + rescue disks. - FAST! tcc generates optimized x86 code. No byte code overhead. Compiles, assemble and link about 7 times faster than 'gcc @@ -27,7 +27,7 @@ Documentation: 1) Installation -***TCC currently only work on Linux x86***. +***TCC currently only works on Linux x86***. Type 'make install' to compile and install tcc in /usr/local/bin and /usr/local/lib/tcc. @@ -60,8 +60,8 @@ default ones are: /usr/include, /usr/lib/tcc, /usr/local/lib/tcc. libxxx.so. Standard library paths are checked, including those specificed with LD_LIBRARY_PATH. -Only one source code can be compiled. If you have multiple source -files, add one which includes all your sources. +'-i file' : compile C source 'file' before main C source. With this +command, multiple C files can be compiled and linked together. 4) Examples @@ -84,44 +84,9 @@ generator. prog.c: auto test for TCC which tests many subtle possible bugs. Used when doing 'make test'. -Exact differences with ANSI C: ------------------------------ +5) Full Documentation -- Preprocessor: the preprocessor tokens are the same as C. It means - that in some rare cases, preprocessed numbers are not handled - exactly as in ANSI C. This approach has the advantage of being - simpler and FAST! - -- Types: floating point numbers are not supported yet. - -- Bit fields are not supported. - -- Linking: extern variables must appear in a referenced dll and cannot - appear in current source. - -Supported ANSI C extensions: ---------------------------- - -- 'inline' keyword is ignored (ISOC99). - -- 'restrict' keyword is ignored (ISOC99). - -- '__func__' is a string variable containing the current function name (ISOC99). - -- Variadic macros: __VA_ARGS__ can be used for function-like macros (ISOC99): - #define dprintf(level, __VA_ARGS__) printf(__VA_ARGS__). - -- Declarations can appear anywhere in a block (ISOC99). - -- Array and struct/union elements can be initialized in any order by - using designators (.e.g. { [0].x = 1 }) (ISOC99). - -- Compound initializers are supported (e.g. int *p = (int []){ 1, 2, - 3}) (ISOC99). - -- '#!' at the start of a line is ignored to allow scripting. - -- Binary digits can be entered ('0b101' instead of '5'). +Please read tcc-doc.html to have all the features of TCC. Technical Description: --------------------- @@ -162,7 +127,7 @@ License: TCC is distributed under the GNU General Public License (see COPYING file). -I accept only patches where you give your copyright explictely to me +I accept only patches where you give your copyright explicitely to me to simplify licensing issues. Fabrice Bellard - Nov 17, 2001. diff --git a/TODO b/TODO index 052835f5..b424e0a7 100644 --- a/TODO +++ b/TODO @@ -1,21 +1,21 @@ TODO list: Critical: - -- add float/double support (should be as small as possible while being - usable for RISC code generator too). +- finish float/double support. add function type convertion. +- section generation and GNUC __attributte__ handling. +- D option with '=' handling - 0 is pointer - fix type compare -- add message if external function or variable not found. - To check: 'sizeof' may not work if too complex expression is given. -- fix 'char' and 'short' casts (in function parameters and in assignment). -- function pointers to forward reference (patch code generator). +- fix 'char' and 'short' casts (only in function parameters and in + assignment). Not critical: +- interactive mode - fix multiple compound literals inits in blocks (ISOC99 normative example - only relevant when using gotos! -> must add boolean variable to tell if compound literal was already initialized). -- fix L"\x1234" wide string case (need to store them as ints ?) */ +- fix L"\x1234" wide string case (need to store them as utf8 ?) - fix preprocessor symbol redefinition - better constant opt (&&, ||, ?:) - add ELF executable and shared library output option (would be needed diff --git a/stdbool.h b/stdbool.h new file mode 100644 index 00000000..6ed13a61 --- /dev/null +++ b/stdbool.h @@ -0,0 +1,10 @@ +#ifndef _STDBOOL_H +#define _STDBOOL_H + +/* ISOC99 boolean */ + +#define bool _Bool +#define true 1 +#define false 0 + +#endif /* _STDBOOL_H */ diff --git a/stddef.h b/stddef.h index 5e7a8671..f83db266 100644 --- a/stddef.h +++ b/stddef.h @@ -1,9 +1,10 @@ #ifndef _STDDEF_H #define _STDDEF_H -/* TCC include file */ #define NULL ((void *)0) typedef unsigned int size_t; typedef int wchar_t; +typedef int ptrdiff_t; +#define offsetof(type, field) ((size_t) &((type *)0)->field) #endif diff --git a/tcc-doc.texi b/tcc-doc.texi index f1930d77..4347fb17 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -29,8 +29,8 @@ it was an executable.

Exact differences with ANSI C

-TCC implements almost all the ANSI C standard, except floating point -and long long numbers. +TCC implements almost all the ANSI C standard, except floating points +numbers.