full build of tcc with itself - doesn't match gcc :o
This commit is contained in:
parent
59b7931165
commit
9c6b9a1450
11 changed files with 250 additions and 44 deletions
2
05/tcc-0.9.27/.gitignore
vendored
2
05/tcc-0.9.27/.gitignore
vendored
|
@ -16,6 +16,8 @@
|
|||
a.out
|
||||
tcc_g
|
||||
tcc
|
||||
tcc[0123456789]
|
||||
tcc[0123456789]a
|
||||
*-tcc
|
||||
libtcc*.def
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#define TCC_VERSION "0.9.27"
|
||||
#define CONFIG_TCC_STATIC 1
|
||||
#define CONFIG_TCC_ELFINTERP "/XXX"
|
||||
#define CONFIG_TCC_CRT_PREFIX "/XXX"
|
||||
#define CONFIG_SYSROOT "/XXX"
|
||||
//#define CONFIG_TCC_ELFINTERP "/XXX"
|
||||
//#define CONFIG_TCC_CRT_PREFIX "/XXX"
|
||||
//#define CONFIG_SYSROOT "/XXX"
|
||||
#define inline
|
||||
#define TCC_TARGET_X86_64 1
|
||||
#define ONE_SOURCE 1
|
||||
#define CONFIG_LDDIR "lib/x86_64-linux-gnu"
|
||||
#define CONFIG_TCCDIR "/usr/local/lib/tcc-bootstrap"
|
||||
|
|
|
@ -613,10 +613,17 @@ unsigned long long __fixunsxfdi (long double a1)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static long double negate_ld(long double d) {
|
||||
register unsigned long long *p = (unsigned long long *)&d;
|
||||
p[1] ^= 1ul<<15;
|
||||
return *(long double *)p;
|
||||
}
|
||||
|
||||
long long __fixxfdi (long double a1)
|
||||
{
|
||||
long long ret; int s;
|
||||
ret = __fixunsxfdi((s = a1 >= 0) ? a1 : -a1);
|
||||
ret = __fixunsxfdi((s = a1 >= 0) ? a1 : negate_ld(a1));
|
||||
return s ? ret : -ret;
|
||||
}
|
||||
#endif /* !ARM */
|
||||
|
|
|
@ -73,12 +73,25 @@ void *realloc(void *ptr, size_t size) {
|
|||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
#if 0
|
||||
// this (better) implementation doesn't seem to be copying stuff to the
|
||||
// new mapping properly
|
||||
uint64_t *memory = (char *)ptr - 16;
|
||||
uint64_t old_size = *memory;
|
||||
uint64_t *new_memory = _mremap(memory, old_size, size, MREMAP_MAYMOVE);
|
||||
if ((uint64_t)new_memory > 0xffffffffffff0000) return NULL;
|
||||
*new_memory = size;
|
||||
return (char *)new_memory + 16;
|
||||
#endif
|
||||
|
||||
uint64_t *memory = (char *)ptr - 16;
|
||||
uint64_t old_size = *memory;
|
||||
void *new = malloc(size);
|
||||
char *new_dat = (char *)new + 16;
|
||||
*(uint64_t *)new = size;
|
||||
memcpy(new_dat, ptr, old_size);
|
||||
free(ptr);
|
||||
return new_dat;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -30,14 +30,15 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
#ifdef __GNUC__
|
||||
#include <float.h>
|
||||
#if defined __GNUC__ || defined __TINYC__
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include <setjmp.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
#ifdef __GNUC__
|
||||
#if defined __GNUC__ || defined __TINYC__
|
||||
# include <unistd.h>
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
|
@ -211,7 +212,8 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
|||
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
||||
"{B}/include" \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include")
|
||||
":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/include") \
|
||||
":/usr/include/x86_64-linux-gnu"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2458,6 +2458,16 @@ static void gen_cast_s(int t)
|
|||
gen_cast(&type);
|
||||
}
|
||||
|
||||
static long double negate_ld(long double d) {
|
||||
#if LDBL_MANT_DIG == 64
|
||||
register unsigned long long *p = (unsigned long long *)&d;
|
||||
p[1] ^= 1ul<<15;
|
||||
return *(long double *)p;
|
||||
#else
|
||||
return -d;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void gen_cast(CType *type)
|
||||
{
|
||||
int sbt, dbt, sf, df, c, p;
|
||||
|
@ -2499,12 +2509,12 @@ static void gen_cast(CType *type)
|
|||
if ((sbt & VT_UNSIGNED) || !(vtop->c.i >> 63))
|
||||
vtop->c.ld = vtop->c.i;
|
||||
else
|
||||
vtop->c.ld = -(long double)-vtop->c.i;
|
||||
vtop->c.ld = negate_ld((long double)-vtop->c.i);
|
||||
} else if(!sf) {
|
||||
if ((sbt & VT_UNSIGNED) || !(vtop->c.i >> 31))
|
||||
vtop->c.ld = (uint32_t)vtop->c.i;
|
||||
else
|
||||
vtop->c.ld = -(long double)-(uint32_t)vtop->c.i;
|
||||
vtop->c.ld = negate_ld((long double)-(uint32_t)vtop->c.i);
|
||||
}
|
||||
|
||||
if (dbt == VT_FLOAT)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue