mirror of
git://repo.or.cz/tinycc.git
synced 2026-06-17 15:44:18 +08:00
Reverts & cleanups
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Some checks failed
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
- include/stddef.h, tcctest.c Revert "tests/tcctest.c: include stdint.h" This reverts commit8f23997ca7We 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 commit2f88764100. - tcc.c: fix formatting of commite73529865d- 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
This commit is contained in:
parent
ce8b3432bf
commit
34b45a69ff
15
README
15
README
@ -7,9 +7,8 @@ Features:
|
|||||||
- SMALL! You can compile and execute C code everywhere, for example on
|
- SMALL! You can compile and execute C code everywhere, for example on
|
||||||
rescue disks.
|
rescue disks.
|
||||||
|
|
||||||
- FAST! tcc generates optimized x86 code. No byte code
|
- FAST! tcc generates machine code for i386, x86_64, arm, aarch64 or
|
||||||
overhead. Compile, assemble and link about 7 times faster than 'gcc
|
riscv64. Compiles and links about 10 times faster than 'gcc -O0'.
|
||||||
-O0'.
|
|
||||||
|
|
||||||
- UNLIMITED! Any C dynamic library can be used directly. TCC is
|
- UNLIMITED! Any C dynamic library can be used directly. TCC is
|
||||||
heading toward full ISOC99 compliance. TCC can of course compile
|
heading toward full ISOC99 compliance. TCC can of course compile
|
||||||
@ -28,15 +27,14 @@ Features:
|
|||||||
Documentation:
|
Documentation:
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
1) Installation on a i386/x86_64/arm/aarch64/riscv64
|
1) Installation on Linux, BSD variants or macOS hosts:
|
||||||
Linux/macOS/FreeBSD/NetBSD/OpenBSD hosts.
|
|
||||||
|
|
||||||
./configure
|
./configure
|
||||||
make
|
make
|
||||||
make test
|
make test
|
||||||
make install
|
make install
|
||||||
|
|
||||||
Notes: For FreeBSD, NetBSD and OpenBSD, gmake should be used instead of make.
|
Notes: On BSD hosts, gmake should be used instead of make.
|
||||||
For Windows read tcc-win32.txt.
|
For Windows read tcc-win32.txt.
|
||||||
|
|
||||||
makeinfo must be installed to compile the doc. By default, tcc is
|
makeinfo must be installed to compile the doc. By default, tcc is
|
||||||
@ -83,9 +81,8 @@ when doing 'make test'.
|
|||||||
|
|
||||||
4) Full Documentation
|
4) Full Documentation
|
||||||
|
|
||||||
Please read tcc-doc.html to have all the features of TCC.
|
Please read tcc-doc.html to have all the features of TCC. Additional
|
||||||
|
information for the Windows port is in tcc-win32.txt.
|
||||||
Additional information is available for the Windows port in tcc-win32.txt.
|
|
||||||
|
|
||||||
License:
|
License:
|
||||||
-------
|
-------
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
#ifndef _STDDEF_H
|
#ifndef _STDDEF_H
|
||||||
#define _STDDEF_H
|
#define _STDDEF_H
|
||||||
#define _TINYC_STDDEF
|
|
||||||
|
|
||||||
typedef __SIZE_TYPE__ size_t;
|
typedef __SIZE_TYPE__ size_t;
|
||||||
typedef __PTRDIFF_TYPE__ ssize_t;
|
typedef __PTRDIFF_TYPE__ ssize_t;
|
||||||
|
|||||||
4
libtcc.c
4
libtcc.c
@ -257,6 +257,10 @@ ST_FUNC void libc_free(void *ptr)
|
|||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* defined to be not used */
|
||||||
|
#define free(p) use_tcc_free(p)
|
||||||
|
#define realloc(p, s) use_tcc_realloc(p, s)
|
||||||
|
|
||||||
/* global so that every tcc_alloc()/tcc_free() call doesn't need to be changed */
|
/* global so that every tcc_alloc()/tcc_free() call doesn't need to be changed */
|
||||||
static void *(*reallocator)(void*, unsigned long) = default_reallocator;
|
static void *(*reallocator)(void*, unsigned long) = default_reallocator;
|
||||||
|
|
||||||
|
|||||||
3
tcc.c
3
tcc.c
@ -87,7 +87,8 @@ static const char help[] =
|
|||||||
#ifdef TCC_TARGET_PE
|
#ifdef TCC_TARGET_PE
|
||||||
" create def file : tcc -impdef lib.dll [-v] [-o lib.def]\n"
|
" create def file : tcc -impdef lib.dll [-v] [-o lib.def]\n"
|
||||||
#endif
|
#endif
|
||||||
" report bugs to the mailing list http://lists.nongnu.org/mailman/listinfo/tinycc-devel\n"
|
"Discussion & bug reports:\n"
|
||||||
|
" https://lists.nongnu.org/mailman/listinfo/tinycc-devel\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
static const char help2[] =
|
static const char help2[] =
|
||||||
|
|||||||
3
tcc.h
3
tcc.h
@ -56,7 +56,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
|||||||
# include <io.h> /* open, close etc. */
|
# include <io.h> /* open, close etc. */
|
||||||
# include <direct.h> /* getcwd */
|
# include <direct.h> /* getcwd */
|
||||||
# include <malloc.h> /* alloca */
|
# include <malloc.h> /* alloca */
|
||||||
# ifdef __GNUC__
|
# ifndef _MSC_VER
|
||||||
# include <stdint.h>
|
# include <stdint.h>
|
||||||
# endif
|
# endif
|
||||||
# define inline __inline
|
# define inline __inline
|
||||||
@ -1235,6 +1235,7 @@ PUB_FUNC char *tcc_strdup_debug(const char *str, const char *file, int line);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ST_FUNC void libc_free(void *ptr);
|
ST_FUNC void libc_free(void *ptr);
|
||||||
|
/* defined to be not used */
|
||||||
#define free(p) use_tcc_free(p)
|
#define free(p) use_tcc_free(p)
|
||||||
#define malloc(s) use_tcc_malloc(s)
|
#define malloc(s) use_tcc_malloc(s)
|
||||||
#define realloc(p, s) use_tcc_realloc(p, s)
|
#define realloc(p, s) use_tcc_realloc(p, s)
|
||||||
|
|||||||
44
tccgen.c
44
tccgen.c
@ -7108,28 +7108,18 @@ static void lblock(int *bsym, int *csym)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void condition_expresion(void)
|
/* c2y if/switch declaration */
|
||||||
|
static void gexpr_decl(void)
|
||||||
{
|
{
|
||||||
Sym *s;
|
int v = decl(VT_JMP);
|
||||||
int decl_ret;
|
if (v > 1 && tok != ';') {
|
||||||
|
Sym *s = sym_find(v);
|
||||||
/* c2y if init decl? */
|
vset(&s->type, s->r, (s->r & VT_SYM) ? 0 : s->c);
|
||||||
if (!(decl_ret = decl(VT_JMPI))) {
|
|
||||||
/* no, regular if init expr */
|
|
||||||
gexpr();
|
|
||||||
} else {
|
|
||||||
if (decl_ret == 1)
|
|
||||||
tcc_error("declaration in the controlling expression must have an initializer");
|
|
||||||
|
|
||||||
if (tok == ';') {
|
|
||||||
/* finish the push */
|
|
||||||
next();
|
|
||||||
gexpr();
|
|
||||||
} else {
|
|
||||||
s = sym_find(decl_ret);
|
|
||||||
vset(&s->type, s->r, s->c);
|
|
||||||
vtop->sym = s;
|
vtop->sym = s;
|
||||||
}
|
} else {
|
||||||
|
if (v)
|
||||||
|
skip(';');
|
||||||
|
gexpr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7153,7 +7143,7 @@ again:
|
|||||||
if (t == TOK_IF) {
|
if (t == TOK_IF) {
|
||||||
new_scope_s(&o);
|
new_scope_s(&o);
|
||||||
skip('(');
|
skip('(');
|
||||||
condition_expresion();
|
gexpr_decl();
|
||||||
a = gvtst(1, 0);
|
a = gvtst(1, 0);
|
||||||
skip(')');
|
skip(')');
|
||||||
block(0);
|
block(0);
|
||||||
@ -7322,7 +7312,7 @@ again:
|
|||||||
|
|
||||||
new_scope_s(&o);
|
new_scope_s(&o);
|
||||||
skip('(');
|
skip('(');
|
||||||
condition_expresion();
|
gexpr_decl();
|
||||||
if (!is_integer_btype(vtop->type.t & VT_BTYPE))
|
if (!is_integer_btype(vtop->type.t & VT_BTYPE))
|
||||||
tcc_error("switch value not an integer");
|
tcc_error("switch value not an integer");
|
||||||
skip(')');
|
skip(')');
|
||||||
@ -8654,9 +8644,7 @@ static void pe_check_linkage(CType *type, AttributeDef *ad)
|
|||||||
|
|
||||||
/* 'l' is VT_LOCAL or VT_CONST to define default storage type
|
/* 'l' is VT_LOCAL or VT_CONST to define default storage type
|
||||||
or VT_CMP if parsing old style parameter list
|
or VT_CMP if parsing old style parameter list
|
||||||
or VT_JMP if parsing c99 for decl: for (int i = 0, ...)
|
or VT_JMP if parsing c99 for decl: for (int i = 0, ...) */
|
||||||
or VT_JMPI if parsing c2y if decl; if (int = 0; ...)
|
|
||||||
*/
|
|
||||||
static int decl(int l)
|
static int decl(int l)
|
||||||
{
|
{
|
||||||
int v, has_init, r, oldint;
|
int v, has_init, r, oldint;
|
||||||
@ -8669,7 +8657,7 @@ static int decl(int l)
|
|||||||
|
|
||||||
oldint = 0;
|
oldint = 0;
|
||||||
if (!parse_btype(&btype, &adbase, l == VT_LOCAL)) {
|
if (!parse_btype(&btype, &adbase, l == VT_LOCAL)) {
|
||||||
if (l == VT_JMP || l == VT_JMPI)
|
if (l == VT_JMP)
|
||||||
return 0;
|
return 0;
|
||||||
/* skip redundant ';' if not in old parameter decl scope */
|
/* skip redundant ';' if not in old parameter decl scope */
|
||||||
if (tok == ';' && l != VT_CMP) {
|
if (tok == ';' && l != VT_CMP) {
|
||||||
@ -8896,12 +8884,10 @@ static int decl(int l)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tok != ',') {
|
if (tok != ',') {
|
||||||
if (l == VT_JMP || l == VT_JMPI)
|
if (l == VT_JMP)
|
||||||
return has_init ? v : 1;
|
return has_init ? v : 1;
|
||||||
skip(';');
|
skip(';');
|
||||||
break;
|
break;
|
||||||
} else if (l == VT_JMPI) {
|
|
||||||
tcc_error("declaration in condition can only declare a single object");
|
|
||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|||||||
16
tccpp.c
16
tccpp.c
@ -1418,6 +1418,9 @@ static int parse_include(TCCState *s1, int do_next, int test)
|
|||||||
#ifdef INC_DEBUG
|
#ifdef INC_DEBUG
|
||||||
printf("%s: skipping cached %s\n", file->filename, buf);
|
printf("%s: skipping cached %s\n", file->filename, buf);
|
||||||
#endif
|
#endif
|
||||||
|
if ((s1->verbose | 1) == 3) /* -vv[v] */
|
||||||
|
printf("=> %*s%s\n",
|
||||||
|
(int)(s1->include_stack_ptr - s1->include_stack), "", buf);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (tcc_open(s1, buf) >= 0)
|
if (tcc_open(s1, buf) >= 0)
|
||||||
@ -2740,7 +2743,6 @@ maybe_newline:
|
|||||||
cstr_cat(&tokcstr, (char *) p1, len);
|
cstr_cat(&tokcstr, (char *) p1, len);
|
||||||
p--;
|
p--;
|
||||||
PEEKC(c, p);
|
PEEKC(c, p);
|
||||||
parse_ident_slow:
|
|
||||||
while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
|
while (isidnum_table[c - CH_EOF] & (IS_ID|IS_NUM))
|
||||||
{
|
{
|
||||||
cstr_ccat(&tokcstr, c);
|
cstr_ccat(&tokcstr, c);
|
||||||
@ -2752,21 +2754,15 @@ maybe_newline:
|
|||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
t = p[1];
|
t = p[1];
|
||||||
if (t != '\\' && t != '\'' && t != '\"') {
|
if (t == '\'' || t == '\"' || t == '\\') {
|
||||||
/* fast case */
|
|
||||||
goto parse_ident_fast;
|
|
||||||
} else {
|
|
||||||
PEEKC(c, p);
|
PEEKC(c, p);
|
||||||
if (c == '\'' || c == '\"') {
|
if (c == '\'' || c == '\"') {
|
||||||
is_long = 1;
|
is_long = 1;
|
||||||
goto str_const;
|
goto str_const;
|
||||||
} else {
|
|
||||||
cstr_reset(&tokcstr);
|
|
||||||
cstr_ccat(&tokcstr, 'L');
|
|
||||||
goto parse_ident_slow;
|
|
||||||
}
|
}
|
||||||
|
*--p = c = 'L';
|
||||||
}
|
}
|
||||||
break;
|
goto parse_ident_fast;
|
||||||
|
|
||||||
case '0': case '1': case '2': case '3':
|
case '0': case '1': case '2': case '3':
|
||||||
case '4': case '5': case '6': case '7':
|
case '4': case '5': case '6': case '7':
|
||||||
|
|||||||
@ -41,6 +41,8 @@
|
|||||||
#define LONG_DOUBLE_LITERAL(x) x ## L
|
#define LONG_DOUBLE_LITERAL(x) x ## L
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef __SIZE_TYPE__ uintptr_t;
|
||||||
|
|
||||||
/* test various include syntaxes */
|
/* test various include syntaxes */
|
||||||
|
|
||||||
#define TCCLIB_INC <tcclib.h>
|
#define TCCLIB_INC <tcclib.h>
|
||||||
@ -62,10 +64,6 @@
|
|||||||
|
|
||||||
#include "tcctest.h"
|
#include "tcctest.h"
|
||||||
|
|
||||||
#ifndef _TINYC_STDDEF
|
|
||||||
#include <stdint.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Test two more ways to include a file named like a pp-number */
|
/* Test two more ways to include a file named like a pp-number */
|
||||||
#define INC(name) <tests/name.h>
|
#define INC(name) <tests/name.h>
|
||||||
#define funnyname 42test.h
|
#define funnyname 42test.h
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user