view release on metacpan or search on metacpan
the results of an actual subdirectory search, rather than by sheer
guesswork, as used to be the case.
[BUG FIXES]
* BSDs were switched to use cc, but that is clang (at least on some
BSDs) so we need to add the heinous-gnu-extensions flag.
* Add patch for Mac OSX to #define _VA_LIST_T. Macs were hitting trouble
with incompatible preprocessor definitions. If the macros and internal
definitions had all been expanded, the definitions for variadic function
lists would have been the same, but tcc doesn't know that.
[OTHER]
* The test suite has been made robust against compiler warnings. It now
searches for expected printouts as substrings of the obtained printouts.
0.10 Thu, June 2, 2016
[BUG FIXES]
src/arm-gen.c view on Meta::CPAN
else if(size == 8)
r|=0x8000;
o(0xED2D0100|r|(size>>2)); /* some kind of vpush for FPA */
#endif
} else {
/* simple type (currently always same size) */
/* XXX: implicit cast ? */
size=4;
if ((pplan->sval->type.t & VT_BTYPE) == VT_LLONG) {
lexpand_nr();
size = 8;
r = gv(RC_INT);
o(0xE52D0004|(intr(r)<<12)); /* push r */
vtop--;
}
r = gv(RC_INT);
o(0xE52D0004|(intr(r)<<12)); /* push r */
}
if (i == STACK_CLASS && pplan->prev)
gadd_sp(pplan->prev->end - pplan->start); /* Add padding if any */
src/arm-gen.c view on Meta::CPAN
case VFP_CLASS:
gv(regmask(TREG_F0 + (pplan->start >> 1)));
if (pplan->start & 1) { /* Must be in upper part of double register */
o(0xEEF00A40|((pplan->start>>1)<<12)|(pplan->start>>1)); /* vmov.f32 s(n+1), sn */
vtop->r = VT_CONST; /* avoid being saved on stack by gv for next float */
}
break;
case CORE_CLASS:
if ((pplan->sval->type.t & VT_BTYPE) == VT_LLONG) {
lexpand_nr();
gv(regmask(pplan->end));
pplan->sval->r2 = vtop->r;
vtop--;
}
gv(regmask(pplan->start));
/* Mark register as used so that gcall_or_jmp use another one
(regs >=4 are free as never used to pass parameters) */
pplan->sval->r = vtop->r;
break;
}
ST_FUNC void vpushi(int v);
ST_FUNC Sym *external_global_sym(int v, CType *type, int r);
ST_FUNC void vset(CType *type, int r, int v);
ST_FUNC void vswap(void);
ST_FUNC void vpush_global_sym(CType *type, int v);
ST_FUNC void vrote(SValue *e, int n);
ST_FUNC void vrott(int n);
ST_FUNC void vrotb(int n);
#ifdef TCC_TARGET_ARM
ST_FUNC int get_reg_ex(int rc, int rc2);
ST_FUNC void lexpand_nr(void);
#endif
ST_FUNC void vpushv(SValue *v);
ST_FUNC void save_reg(int r);
ST_FUNC void save_reg_upstack(int r, int n);
ST_FUNC int get_reg(int rc);
ST_FUNC void save_regs(int n);
ST_FUNC void gaddrof(void);
ST_FUNC int gv(int rc);
ST_FUNC void gv2(int rc1, int rc2);
ST_FUNC void vpop(void);
src/tccgen.c view on Meta::CPAN
#if defined(TCC_TARGET_ARM64) || defined(TCC_TARGET_X86_64)
if (((vtop->type.t & VT_BTYPE) == VT_QLONG) || ((vtop->type.t & VT_BTYPE) == VT_QFLOAT)) {
int addr_type = VT_LLONG, load_size = 8, load_type = ((vtop->type.t & VT_BTYPE) == VT_QLONG) ? VT_LLONG : VT_DOUBLE;
#else
if ((vtop->type.t & VT_BTYPE) == VT_LLONG) {
int addr_type = VT_INT, load_size = 4, load_type = VT_INT;
unsigned long long ll;
#endif
int r2, original_type;
original_type = vtop->type.t;
/* two register type load : expand to two words
temporarily */
#if !defined(TCC_TARGET_ARM64) && !defined(TCC_TARGET_X86_64)
if ((vtop->r & (VT_VALMASK | VT_LVAL)) == VT_CONST) {
/* load constant */
ll = vtop->c.i;
vtop->c.i = ll; /* first word */
load(r, vtop);
vtop->r = r; /* save register value */
vpushi(ll >> 32); /* second word */
} else
src/tccgen.c view on Meta::CPAN
static int reg_fret(int t)
{
#ifdef TCC_TARGET_X86_64
if (t == VT_LDOUBLE) {
return TREG_ST0;
}
#endif
return REG_FRET;
}
/* expand 64bit on stack in two ints */
static void lexpand(void)
{
int u, v;
u = vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED);
v = vtop->r & (VT_VALMASK | VT_LVAL);
if (v == VT_CONST) {
vdup();
vtop[0].c.i >>= 32;
} else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) {
vdup();
vtop[0].c.i += 4;
} else {
gv(RC_INT);
vdup();
vtop[0].r = vtop[-1].r2;
vtop[0].r2 = vtop[-1].r2 = VT_CONST;
}
vtop[0].type.t = vtop[-1].type.t = VT_INT | u;
}
#ifdef TCC_TARGET_ARM
/* expand long long on stack */
ST_FUNC void lexpand_nr(void)
{
int u,v;
u = vtop->type.t & (VT_DEFSIGN | VT_UNSIGNED);
vdup();
vtop->r2 = VT_CONST;
vtop->type.t = VT_INT | u;
v=vtop[-1].r & (VT_VALMASK | VT_LVAL);
if (v == VT_CONST) {
vtop[-1].c.i = vtop->c.i;
vtop->c.i = vtop->c.i >> 32;
vtop->r = VT_CONST;
} else if (v == (VT_LVAL|VT_CONST) || v == (VT_LVAL|VT_LOCAL)) {
vtop->c.i += 4;
vtop->r = vtop[-1].r;
} else if (v > VT_CONST) {
vtop--;
lexpand();
} else
vtop->r = vtop[-1].r2;
vtop[-1].r2 = VT_CONST;
vtop[-1].type.t = VT_INT | u;
}
#endif
#if !defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_ARM64)
/* build a long long from two ints */
static void lbuild(int t)
src/tccgen.c view on Meta::CPAN
/* convert stack entry to register and duplicate its value in another
register */
static void gv_dup(void)
{
int rc, t, r, r1;
SValue sv;
t = vtop->type.t;
#if !defined(TCC_TARGET_X86_64) && !defined(TCC_TARGET_ARM64)
if ((t & VT_BTYPE) == VT_LLONG) {
lexpand();
gv_dup();
vswap();
vrotb(3);
gv_dup();
vrotb(4);
/* stack: H L L1 H1 */
lbuild(t);
vrotb(3);
vrotb(3);
vswap();
src/tccgen.c view on Meta::CPAN
break;
case '^':
case '&':
case '|':
case '*':
case '+':
case '-':
//pv("gen_opl A",0,2);
t = vtop->type.t;
vswap();
lexpand();
vrotb(3);
lexpand();
/* stack: L1 H1 L2 H2 */
tmp = vtop[0];
vtop[0] = vtop[-3];
vtop[-3] = tmp;
tmp = vtop[-2];
vtop[-2] = vtop[-3];
vtop[-3] = tmp;
vswap();
/* stack: H1 H2 L1 L2 */
//pv("gen_opl B",0,4);
if (op == '*') {
vpushv(vtop - 1);
vpushv(vtop - 1);
gen_op(TOK_UMULL);
lexpand();
/* stack: H1 H2 L1 L2 ML MH */
for(i=0;i<4;i++)
vrotb(6);
/* stack: ML MH H1 H2 L1 L2 */
tmp = vtop[0];
vtop[0] = vtop[-2];
vtop[-2] = tmp;
/* stack: ML MH H1 L2 H2 L1 */
gen_op('*');
vrotb(3);
src/tccgen.c view on Meta::CPAN
}
/* stack: L H */
lbuild(t);
break;
case TOK_SAR:
case TOK_SHR:
case TOK_SHL:
if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
t = vtop[-1].type.t;
vswap();
lexpand();
vrotb(3);
/* stack: L H shift */
c = (int)vtop->c.i;
/* constant: simpler */
/* NOTE: all comments are for SHL. the other cases are
done by swaping words */
vpop();
if (op != TOK_SHL)
vswap();
if (c >= 32) {
src/tccgen.c view on Meta::CPAN
case TOK_SHL:
func = TOK___ashldi3;
goto gen_func;
}
}
break;
default:
/* compare operations */
t = vtop->type.t;
vswap();
lexpand();
vrotb(3);
lexpand();
/* stack: L1 H1 L2 H2 */
tmp = vtop[-1];
vtop[-1] = vtop[-2];
vtop[-2] = tmp;
/* stack: L1 L2 H1 H2 */
/* compare high */
op1 = op;
/* when values are equal, we need to compare low words. since
the jump is inverted, we invert the test too. */
if (op1 == TOK_LT)
src/tccgen.c view on Meta::CPAN
(dbt & VT_BTYPE) == VT_SHORT) {
if (sbt == VT_PTR) {
vtop->type.t = VT_INT;
tcc_warning("nonportable conversion from pointer to char/short");
}
force_charshort_cast(dbt);
} else if ((dbt & VT_BTYPE) == VT_INT) {
/* scalar to int */
if ((sbt & VT_BTYPE) == VT_LLONG) {
/* from long long: just take low order word */
lexpand();
vpop();
}
/* if lvalue and single word type, nothing to do because
the lvalue already contains the real type size (see
VT_LVAL_xxx constants) */
}
}
} else if ((dbt & VT_BTYPE) == VT_PTR && !(vtop->r & VT_LVAL)) {
/* if we are casting between pointer types,
we must update the VT_LVAL_xxx size */
src/tccpp.c view on Meta::CPAN
/* ------------------------------------------------------------------------- */
/* allocate a new token */
static TokenSym *tok_alloc_new(TokenSym **pts, const char *str, int len)
{
TokenSym *ts, **ptable;
int i;
if (tok_ident >= SYM_FIRST_ANOM)
tcc_error("memory full (symbols)");
/* expand token table if needed */
i = tok_ident - TOK_IDENT;
if ((i % TOK_ALLOC_INCR) == 0) {
ptable = tcc_realloc(table_ident, (i + TOK_ALLOC_INCR) * sizeof(TokenSym *));
table_ident = ptable;
}
ts = tal_realloc(toksym_alloc, 0, sizeof(TokenSym) + len);
table_ident[i] = ts;
ts->tok = tok_ident++;
ts->sym_define = NULL;
src/tests/tests2/00_assignment.c view on Meta::CPAN
int b = 64;
printf("%d\n", b);
int c = 12, d = 34;
printf("%d, %d\n", c, d);
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/01_comment.c view on Meta::CPAN
{
printf("Hello\n");
printf("Hello\n"); /* this is a comment */ printf("Hello\n");
printf("Hello\n");
// this is also a comment sayhello();
printf("Hello\n");
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/02_printf.c view on Meta::CPAN
for (Count = -5; Count <= 5; Count++)
printf("Count = %d\n", Count);
printf("String 'hello', 'there' is '%s', '%s'\n", "hello", "there");
printf("Character 'A' is '%c'\n", 65);
printf("Character 'a' is '%c'\n", 'a');
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/04_for.c view on Meta::CPAN
int Count;
for (Count = 1; Count <= 10; Count++)
{
printf("%d\n", Count);
}
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/05_array.c view on Meta::CPAN
}
for (Count = 0; Count < 10; Count++)
{
printf("%d\n", Array[Count]);
}
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/06_case.c view on Meta::CPAN
default:
printf("%d\n", 0);
break;
}
}
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/07_function.c view on Meta::CPAN
printf("%d\n", myfunc(3));
printf("%d\n", myfunc(4));
vfunc(1234);
qfunc();
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/08_while.c view on Meta::CPAN
{
printf("%d\n", a);
t = a;
a = t + p;
p = t;
}
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/09_do_while.c view on Meta::CPAN
{
printf("%d\n", a);
t = a;
a = t + p;
p = t;
} while (a < 100);
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/10_pointer.c view on Meta::CPAN
printf("tsar->a = %d\n", tsar->a);
printf("tsar->b = %d\n", tsar->b);
printf("tsar->c = %d\n", tsar->c);
b = &(bolshevic.b);
printf("bolshevic.b = %d\n", *b);
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/11_precedence.c view on Meta::CPAN
printf("%d, %d\n", a != a, a != b);
printf("%d\n", a != b && c != d);
printf("%d\n", a + b * c / f);
printf("%d\n", a + b * c / f);
printf("%d\n", (4 << 4));
printf("%d\n", (64 >> 4));
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/12_hashdefine.c view on Meta::CPAN
#define BLOGGS(x) (12*(x))
int main()
{
printf("%d\n", FRED);
printf("%d, %d, %d\n", BLOGGS(1), BLOGGS(2), BLOGGS(3));
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/13_integer_literals.c view on Meta::CPAN
printf("%d\n", a);
printf("%d\n", b);
printf("%d\n", c);
printf("%d\n", d);
printf("%d\n", e);
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/14_if.c view on Meta::CPAN
int b = 0;
if (b)
printf("b is true\n");
else
printf("b is false\n");
return 0;
}
// vim: set expandtab ts=4 sw=3 sts=3 tw=80 :
src/tests/tests2/15_recursion.c view on Meta::CPAN
int main()
{
int Count;
for (Count = 1; Count <= 10; Count++)
printf("%d\n", factorial(Count));
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/16_nesting.c view on Meta::CPAN
for (z = 0; z < 3; z++)
{
printf("%d %d %d\n", x, y, z);
}
}
}
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/17_enum.c view on Meta::CPAN
printf("%d %d %d %d %d %d %d %d\n", a, b, c, d, e, f, g, h);
/* printf("%d\n", frod); */
frod = 12;
printf("%d\n", frod);
frod = e;
printf("%d\n", frod);
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/18_include.c view on Meta::CPAN
int main()
{
printf("including\n");
#include "18_include.h"
printf("done\n");
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/19_pointer_arithmetic.c view on Meta::CPAN
printf("b is not NULL\n");
if (c == NULL)
printf("c is NULL\n");
else
printf("c is not NULL\n");
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/20_pointer_comparison.c view on Meta::CPAN
printf("%d\n", *e);
printf("%d\n", d == e);
printf("%d\n", d != e);
d = e;
printf("%d\n", d == e);
printf("%d\n", d != e);
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/21_char_array.c view on Meta::CPAN
while (*src != 0)
*dest++ = *src++;
*dest = 0;
printf("copied string is %s\n", destarray);
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/22_floating_point.c view on Meta::CPAN
printf("%f\n", -12.34);
// type coercion
a = 2;
printf("%f\n", a);
printf("%f\n", sin(2));
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/23_type_coercion.c view on Meta::CPAN
printf("%d %d\n", d, e);
float f = 'a';
float g = 97;
printf("%f %f\n", f, g);
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/24_math_library.c view on Meta::CPAN
printf("%f\n", log10(0.12));
printf("%f\n", pow(0.12, 0.12));
printf("%f\n", sqrt(0.12));
printf("%f\n", round(12.34));
printf("%f\n", ceil(12.34));
printf("%f\n", floor(12.34));
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/
src/tests/tests2/25_quicksort.c view on Meta::CPAN
quicksort(0, 15);
for (i = 0; i < 16; i++)
printf("%d ", array[i]);
printf("\n");
return 0;
}
/* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/