History

Reverts & cleanups

- include/stddef.h, tcctest.c Revert "tests/tcctest.c: include stdint.h" This reverts commit 8f23997ca7c7bd34756bbbae1f5363afec422907 We don't want tcctest.c to rely on system include files - libtcc.c: Revert "libtcc.c: Remove unused defines free and realloc" To be unused is the point why they do exist This reverts commit 2f8876410044b3e8d26c79f1f7dfac5b7700a88c. - tcc.c: fix formatting of commit e73529865d97f7699b6a96fca5ecd0d6affe605b - tccpp.c: parse_include(): print skipped include files too (with tcc -vv[v] file) next_nomacro(): faster L"str" parsing - tccgen.c: fix c2y if declaration: * accept like GCC: if (int a = 0, b, c = x; c) * accept as "TCC extension": if (int a = 0, b, c = x) * "speak tcc" with symbol/function names - README: cleanup

grischka committed 1 year ago

Commit 34b45a61 parent ce8b3438 files · +38 −56Browse files

Unified · Split

8 files
  1. README +6 −9
  2. include/stddef.h +0 −1
  3. libtcc.c +4 −0
  4. tcc.c +2 −1
  5. tcc.h +2 −1
  6. tccgen.c +16 −30
  7. tccpp.c +6 −10
  8. tests/tcctest.c +2 −4
README+6−9
@@ -7,9 +7,8 @@ Features: · 6 unmodified lines
7- SMALL! You can compile and execute C code everywhere, for example on7- SMALL! You can compile and execute C code everywhere, for example on
8 rescue disks.8 rescue disks.
9 9
10- FAST! tcc generates optimized x86 code. No byte code10- FAST! tcc generates machine code for i386, x86_64, arm, aarch64 or
11 overhead. Compile, assemble and link about 7 times faster than 'gcc11 riscv64. Compiles and links about 10 times faster than 'gcc -O0'.
12 -O0'.
13 12
14- UNLIMITED! Any C dynamic library can be used directly. TCC is13- UNLIMITED! Any C dynamic library can be used directly. TCC is
15 heading toward full ISOC99 compliance. TCC can of course compile14 heading toward full ISOC99 compliance. TCC can of course compile
@@ -28,15 +27,14 @@ Features: · 12 unmodified lines
28Documentation:27Documentation:
29-------------28-------------
30 29
311) Installation on a i386/x86_64/arm/aarch64/riscv64301) Installation on Linux, BSD variants or macOS hosts:
32 Linux/macOS/FreeBSD/NetBSD/OpenBSD hosts.
33 31
34 ./configure32 ./configure
35 make33 make
36 make test34 make test
37 make install35 make install
38 36
39 Notes: For FreeBSD, NetBSD and OpenBSD, gmake should be used instead of make.37 Notes: On BSD hosts, gmake should be used instead of make.
40 For Windows read tcc-win32.txt.38 For Windows read tcc-win32.txt.
41 39
42makeinfo must be installed to compile the doc. By default, tcc is40makeinfo must be installed to compile the doc. By default, tcc is
@@ -83,9 +81,8 @@ when doing 'make test'. · 40 unmodified lines
83 81
844) Full Documentation824) Full Documentation
85 83
86Please read tcc-doc.html to have all the features of TCC.84Please read tcc-doc.html to have all the features of TCC. Additional
87 85information for the Windows port is in tcc-win32.txt.
88Additional information is available for the Windows port in tcc-win32.txt.
89 86
90License:87License:
91-------88-------
include/stddef.h+0−1
@@ -1,6 +1,5 @@
1#ifndef _STDDEF_H1#ifndef _STDDEF_H
2#define _STDDEF_H2#define _STDDEF_H
3#define _TINYC_STDDEF
4 3
5typedef __SIZE_TYPE__ size_t;4typedef __SIZE_TYPE__ size_t;
6typedef __PTRDIFF_TYPE__ ssize_t;5typedef __PTRDIFF_TYPE__ ssize_t;
libtcc.c+4−0
@@ -257,6 +257,10 @@ ST_FUNC void libc_free(void *ptr) · 256 unmodified lines
257 free(ptr);257 free(ptr);
258}258}
259 259
260/* defined to be not used */
261#define free(p) use_tcc_free(p)
262#define realloc(p, s) use_tcc_realloc(p, s)
263
260/* global so that every tcc_alloc()/tcc_free() call doesn't need to be changed */264/* global so that every tcc_alloc()/tcc_free() call doesn't need to be changed */
261static void *(*reallocator)(void*, unsigned long) = default_reallocator;265static void *(*reallocator)(void*, unsigned long) = default_reallocator;
262 266
tcc.c+2−1
@@ -87,7 +87,8 @@ static const char help[] = · 86 unmodified lines
87#ifdef TCC_TARGET_PE87#ifdef TCC_TARGET_PE
88 " create def file : tcc -impdef lib.dll [-v] [-o lib.def]\n"88 " create def file : tcc -impdef lib.dll [-v] [-o lib.def]\n"
89#endif89#endif
90 " report bugs to the mailing list http://lists.nongnu.org/mailman/listinfo/tinycc-devel\n"90 "Discussion & bug reports:\n"
91 " https://lists.nongnu.org/mailman/listinfo/tinycc-devel\n"
91 ;92 ;
92 93
93static const char help2[] =94static const char help2[] =
tcc.h+2−1
@@ -56,7 +56,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 55 unmodified lines
56# include <io.h> /* open, close etc. */56# include <io.h> /* open, close etc. */
57# include <direct.h> /* getcwd */57# include <direct.h> /* getcwd */
58# include <malloc.h> /* alloca */58# include <malloc.h> /* alloca */
59# ifdef __GNUC__59# ifndef _MSC_VER
60# include <stdint.h>60# include <stdint.h>
61# endif61# endif
62# define inline __inline62# define inline __inline
@@ -1235,6 +1235,7 @@ PUB_FUNC char *tcc_strdup_debug(const char *str, const char *file, int line); · 1172 unmodified lines
1235#endif1235#endif
1236 1236
1237ST_FUNC void libc_free(void *ptr);1237ST_FUNC void libc_free(void *ptr);
1238/* defined to be not used */
1238#define free(p) use_tcc_free(p)1239#define free(p) use_tcc_free(p)
1239#define malloc(s) use_tcc_malloc(s)1240#define malloc(s) use_tcc_malloc(s)
1240#define realloc(p, s) use_tcc_realloc(p, s)1241#define realloc(p, s) use_tcc_realloc(p, s)
tccgen.c+16−30
@@ -7108,28 +7108,18 @@ static void lblock(int *bsym, int *csym) · 7107 unmodified lines
7108 }7108 }
7109}7109}
7110 7110
7111static void condition_expresion(void)7111/* c2y if/switch declaration */
7112{7112static void gexpr_decl(void)
7113 Sym *s;7113{
7114 int decl_ret;7114 int v = decl(VT_JMP);
7115 7115 if (v > 1 && tok != ';') {
7116 /* c2y if init decl? */7116 Sym *s = sym_find(v);
7117 if (!(decl_ret = decl(VT_JMPI))) {7117 vset(&s->type, s->r, (s->r & VT_SYM) ? 0 : s->c);
7118 /* no, regular if init expr */7118 vtop->sym = s;
7119 gexpr();
7120 } else {7119 } else {
7121 if (decl_ret == 1)7120 if (v)
7122 tcc_error("declaration in the controlling expression must have an initializer");7121 skip(';');
7123 7122 gexpr();
7124 if (tok == ';') {
7125 /* finish the push */
7126 next();
7127 gexpr();
7128 } else {
7129 s = sym_find(decl_ret);
7130 vset(&s->type, s->r, s->c);
7131 vtop->sym = s;
7132 }
7133 }7123 }
7134}7124}
7135 7125
@@ -7153,7 +7143,7 @@ again: · 17 unmodified lines
7153 if (t == TOK_IF) {7143 if (t == TOK_IF) {
7154 new_scope_s(&o);7144 new_scope_s(&o);
7155 skip('(');7145 skip('(');
7156 condition_expresion();7146 gexpr_decl();
7157 a = gvtst(1, 0);7147 a = gvtst(1, 0);
7158 skip(')');7148 skip(')');
7159 block(0);7149 block(0);
@@ -7322,7 +7312,7 @@ again: · 162 unmodified lines
7322 7312
7323 new_scope_s(&o);7313 new_scope_s(&o);
7324 skip('(');7314 skip('(');
7325 condition_expresion();7315 gexpr_decl();
7326 if (!is_integer_btype(vtop->type.t & VT_BTYPE))7316 if (!is_integer_btype(vtop->type.t & VT_BTYPE))
7327 tcc_error("switch value not an integer");7317 tcc_error("switch value not an integer");
7328 skip(')');7318 skip(')');
@@ -8654,9 +8644,7 @@ static void pe_check_linkage(CType *type, AttributeDef *ad) · 1325 unmodified lines
8654 8644
8655/* 'l' is VT_LOCAL or VT_CONST to define default storage type8645/* 'l' is VT_LOCAL or VT_CONST to define default storage type
8656 or VT_CMP if parsing old style parameter list8646 or VT_CMP if parsing old style parameter list
8657 or VT_JMP if parsing c99 for decl: for (int i = 0, ...)8647 or VT_JMP if parsing c99 for decl: for (int i = 0, ...) */
8658 or VT_JMPI if parsing c2y if decl; if (int = 0; ...)
8659*/
8660static int decl(int l)8648static int decl(int l)
8661{8649{
8662 int v, has_init, r, oldint;8650 int v, has_init, r, oldint;
@@ -8669,7 +8657,7 @@ static int decl(int l) · 6 unmodified lines
8669 8657
8670 oldint = 0;8658 oldint = 0;
8671 if (!parse_btype(&btype, &adbase, l == VT_LOCAL)) {8659 if (!parse_btype(&btype, &adbase, l == VT_LOCAL)) {
8672 if (l == VT_JMP || l == VT_JMPI)8660 if (l == VT_JMP)
8673 return 0;8661 return 0;
8674 /* skip redundant ';' if not in old parameter decl scope */8662 /* skip redundant ';' if not in old parameter decl scope */
8675 if (tok == ';' && l != VT_CMP) {8663 if (tok == ';' && l != VT_CMP) {
@@ -8896,12 +8884,10 @@ static int decl(int l) · 220 unmodified lines
8896 }8884 }
8897 }8885 }
8898 if (tok != ',') {8886 if (tok != ',') {
8899 if (l == VT_JMP || l == VT_JMPI)8887 if (l == VT_JMP)
8900 return has_init ? v : 1;8888 return has_init ? v : 1;
8901 skip(';');8889 skip(';');
8902 break;8890 break;
8903 } else if (l == VT_JMPI) {
8904 tcc_error("declaration in condition can only declare a single object");
8905 }8891 }
8906 next();8892 next();
8907 }8893 }
tccpp.c+6−10
@@ -1418,6 +1418,9 @@ static int parse_include(TCCState *s1, int do_next, int test) · 1417 unmodified lines
1418#ifdef INC_DEBUG1418#ifdef INC_DEBUG
1419 printf("%s: skipping cached %s\n", file->filename, buf);1419 printf("%s: skipping cached %s\n", file->filename, buf);
1420#endif1420#endif
1421 if ((s1->verbose | 1) == 3) /* -vv[v] */
1422 printf("=> %*s%s\n",
1423 (int)(s1->include_stack_ptr - s1->include_stack), "", buf);
1421 return 1;1424 return 1;
1422 }1425 }
1423 if (tcc_open(s1, buf) >= 0)1426 if (tcc_open(s1, buf) >= 0)
@@ -2740,7 +2743,6 @@ maybe_newline: · 1316 unmodified lines
2740 cstr_cat(&tokcstr, (char *) p1, len);2743 cstr_cat(&tokcstr, (char *) p1, len);
2741 p--;2744 p--;
2742 PEEKC(c, p);2745 PEEKC(c, p);
2743 parse_ident_slow:
2744 while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))2746 while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
2745 {2747 {
2746 cstr_ccat(&tokcstr, c);2748 cstr_ccat(&tokcstr, c);
@@ -2752,21 +2754,15 @@ maybe_newline: · 5 unmodified lines
2752 break;2754 break;
2753 case 'L':2755 case 'L':
2754 t = p[1];2756 t = p[1];
2755 if (t != '\\' && t != '\'' && t != '\"') {2757 if (t == '\'' || t == '\"' || t == '\\') {
2756 /* fast case */
2757 goto parse_ident_fast;
2758 } else {
2759 PEEKC(c, p);2758 PEEKC(c, p);
2760 if (c == '\'' || c == '\"') {2759 if (c == '\'' || c == '\"') {
2761 is_long = 1;2760 is_long = 1;
2762 goto str_const;2761 goto str_const;
2763 } else {
2764 cstr_reset(&tokcstr);
2765 cstr_ccat(&tokcstr, 'L');
2766 goto parse_ident_slow;
2767 }2762 }
2763 *--p = c = 'L';
2768 }2764 }
2769 break;2765 goto parse_ident_fast;
2770 2766
2771 case '0': case '1': case '2': case '3':2767 case '0': case '1': case '2': case '3':
2772 case '4': case '5': case '6': case '7':2768 case '4': case '5': case '6': case '7':
tests/tcctest.c+2−4
@@ -41,6 +41,8 @@ · 40 unmodified lines
41#define LONG_DOUBLE_LITERAL(x) x ## L41#define LONG_DOUBLE_LITERAL(x) x ## L
42#endif42#endif
43 43
44typedef __SIZE_TYPE__ uintptr_t;
45
44/* test various include syntaxes */46/* test various include syntaxes */
45 47
46#define TCCLIB_INC <tcclib.h>48#define TCCLIB_INC <tcclib.h>
@@ -62,10 +64,6 @@ · 15 unmodified lines
62 64
63#include "tcctest.h"65#include "tcctest.h"
64 66
65#ifndef _TINYC_STDDEF
66#include <stdint.h>
67#endif
68
69/* Test two more ways to include a file named like a pp-number */67/* Test two more ways to include a file named like a pp-number */
70#define INC(name) <tests/name.h>68#define INC(name) <tests/name.h>
71#define funnyname 42test.h69#define funnyname 42test.h

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