mirror of
https://github.com/frida/tinycc
synced 2024-11-25 00:59:37 +03:00
Fixed silly error in Windows build of tests (abitest-cc not linking to libtcc)
I really should do this when less tired; I keep breaking one platform while fixing another. I've also fixed some Windows issues with tcctest since Windows printf() uses different format flags to those on Linux, and removed some conditional compilation tests in tcctest since they now should work.
This commit is contained in:
parent
ae2ece93da
commit
41d76e1fcb
@ -5,13 +5,12 @@ if(WIN32)
|
||||
set(TCC_CFLAGS ${TCC_CFLAGS} -I${CMAKE_SOURCE_DIR}/win32/include)
|
||||
else()
|
||||
set(TCC_MATH_LDFLAGS -lm)
|
||||
set(LIBTCC_EXTRA_LIBS dl)
|
||||
set(LIBTCC_LDFLAGS -ldl -lm -Wl,-rpath=${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
add_executable(abitest-cc abitest.c)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(abitest-cc libtcc dl)
|
||||
endif()
|
||||
target_link_libraries(abitest-cc libtcc ${LIBTCC_EXTRA_LIBS})
|
||||
add_test(NAME abitest-cc WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND abitest-cc lib_path=${CMAKE_BINARY_DIR} include=${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
set(ABITEST_TCC abitest-tcc${CMAKE_EXECUTABLE_SUFFIX})
|
||||
|
@ -16,6 +16,14 @@
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define LONG_LONG_FORMAT "%lld"
|
||||
#define ULONG_LONG_FORMAT "%llu"
|
||||
#else
|
||||
#define LONG_LONG_FORMAT "%Ld"
|
||||
#define ULONG_LONG_FORMAT "%Lu"
|
||||
#endif
|
||||
|
||||
// MinGW has 80-bit rather than 64-bit long double which isn't compatible with TCC or MSVC
|
||||
#if defined(_WIN32) && defined(__GNUC__)
|
||||
#define LONG_DOUBLE double
|
||||
@ -263,7 +271,7 @@ void macro_test(void)
|
||||
printf("func='%s'\n", __FUNCTION__);
|
||||
|
||||
/* complicated macros in glibc */
|
||||
printf("INT64_MIN=%Ld\n", INT64_MIN);
|
||||
printf("INT64_MIN=" LONG_LONG_FORMAT "\n", INT64_MIN);
|
||||
{
|
||||
int a;
|
||||
a = 1;
|
||||
@ -1711,19 +1719,19 @@ void lloptest(long long a, long long b)
|
||||
ua = a;
|
||||
ub = b;
|
||||
/* arith */
|
||||
printf("arith: %Ld %Ld %Ld\n",
|
||||
printf("arith: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
|
||||
a + b,
|
||||
a - b,
|
||||
a * b);
|
||||
|
||||
if (b != 0) {
|
||||
printf("arith1: %Ld %Ld\n",
|
||||
printf("arith1: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
|
||||
a / b,
|
||||
a % b);
|
||||
}
|
||||
|
||||
/* binary */
|
||||
printf("bin: %Ld %Ld %Ld\n",
|
||||
printf("bin: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
|
||||
a & b,
|
||||
a | b,
|
||||
a ^ b);
|
||||
@ -1748,25 +1756,25 @@ void lloptest(long long a, long long b)
|
||||
/* arith2 */
|
||||
a++;
|
||||
b++;
|
||||
printf("arith2: %Ld %Ld\n", a, b);
|
||||
printf("arith2: %Ld %Ld\n", a++, b++);
|
||||
printf("arith2: %Ld %Ld\n", --a, --b);
|
||||
printf("arith2: %Ld %Ld\n", a, b);
|
||||
printf("arith2: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", a, b);
|
||||
printf("arith2: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", a++, b++);
|
||||
printf("arith2: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", --a, --b);
|
||||
printf("arith2: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", a, b);
|
||||
b = ub = 0;
|
||||
printf("not: %d %d %d %d\n", !a, !ua, !b, !ub);
|
||||
}
|
||||
|
||||
void llshift(long long a, int b)
|
||||
{
|
||||
printf("shift: %Ld %Ld %Ld\n",
|
||||
printf("shift: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
|
||||
(unsigned long long)a >> b,
|
||||
a >> b,
|
||||
a << b);
|
||||
printf("shiftc: %Ld %Ld %Ld\n",
|
||||
printf("shiftc: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
|
||||
(unsigned long long)a >> 3,
|
||||
a >> 3,
|
||||
a << 3);
|
||||
printf("shiftc: %Ld %Ld %Ld\n",
|
||||
printf("shiftc: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n",
|
||||
(unsigned long long)a >> 35,
|
||||
a >> 35,
|
||||
a << 35);
|
||||
@ -1783,7 +1791,7 @@ void llfloat(void)
|
||||
ula = 0x72345678;
|
||||
la = (la << 20) | 0x12345;
|
||||
ula = ula << 33;
|
||||
printf("la=%Ld ula=%Lu\n", la, ula);
|
||||
printf("la=" LONG_LONG_FORMAT " ula=" ULONG_LONG_FORMAT "\n", la, ula);
|
||||
|
||||
fa = la;
|
||||
da = la;
|
||||
@ -1793,7 +1801,7 @@ void llfloat(void)
|
||||
la = fa;
|
||||
lb = da;
|
||||
lc = lda;
|
||||
printf("ftoll: %Ld %Ld %Ld\n", la, lb, lc);
|
||||
printf("ftoll: " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", la, lb, lc);
|
||||
|
||||
fa = ula;
|
||||
da = ula;
|
||||
@ -1803,7 +1811,7 @@ void llfloat(void)
|
||||
ula = fa;
|
||||
ulb = da;
|
||||
ulc = lda;
|
||||
printf("ftoull: %Lu %Lu %Lu\n", ula, ulb, ulc);
|
||||
printf("ftoull: " ULONG_LONG_FORMAT " " ULONG_LONG_FORMAT " " ULONG_LONG_FORMAT "\n", ula, ulb, ulc);
|
||||
}
|
||||
|
||||
long long llfunc1(int a)
|
||||
@ -1832,14 +1840,14 @@ void longlong_test(void)
|
||||
ua = -2;
|
||||
a = ia;
|
||||
b = ua;
|
||||
printf("%Ld %Ld\n", a, b);
|
||||
printf("%Ld %Ld %Ld %Lx\n",
|
||||
printf(LONG_LONG_FORMAT " " LONG_LONG_FORMAT "\n", a, b);
|
||||
printf(LONG_LONG_FORMAT " " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " %Lx\n",
|
||||
(long long)1,
|
||||
(long long)-2,
|
||||
1LL,
|
||||
0x1234567812345679);
|
||||
a = llfunc1(-3);
|
||||
printf("%Ld\n", a);
|
||||
printf(LONG_LONG_FORMAT "\n", a);
|
||||
|
||||
lloptest(1000, 23);
|
||||
lloptest(0xff, 0x1234);
|
||||
@ -1880,7 +1888,7 @@ void longlong_test(void)
|
||||
b = 4294967295LL;
|
||||
printf("%d %d %d %d\n", a > b, a < b, a >= b, a <= b);
|
||||
|
||||
printf("%Ld\n", 0x123456789LLU);
|
||||
printf(LONG_LONG_FORMAT "\n", 0x123456789LLU);
|
||||
}
|
||||
|
||||
void manyarg_test(void)
|
||||
@ -1891,34 +1899,31 @@ void manyarg_test(void)
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0);
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Ld %Ld %f %f\n",
|
||||
LONG_LONG_FORMAT " " LONG_LONG_FORMAT " %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0);
|
||||
printf("%Lf %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Ld %Ld %f %f\n",
|
||||
LONG_LONG_FORMAT " " LONG_LONG_FORMAT " %f %f\n",
|
||||
ld, 1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0);
|
||||
/* XXX: known bug of x86-64 */
|
||||
#ifndef __x86_64__
|
||||
printf("%d %d %d %d %d %d %d %d %Lf\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8, ld);
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Ld %Ld %f %f %Lf\n",
|
||||
LONG_LONG_FORMAT " " LONG_LONG_FORMAT "%f %f %Lf\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0, ld);
|
||||
printf("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f "
|
||||
"%Lf %Ld %Ld %f %f %Lf\n",
|
||||
"%Lf " LONG_LONG_FORMAT " " LONG_LONG_FORMAT " %f %f %Lf\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8, 8.9, 9.0,
|
||||
ld, 1234567891234LL, 987654321986LL,
|
||||
42.0, 43.0, ld);
|
||||
#endif
|
||||
}
|
||||
|
||||
void vprintf1(const char *fmt, ...)
|
||||
@ -1954,7 +1959,7 @@ void vprintf1(const char *fmt, ...)
|
||||
break;
|
||||
case 'l':
|
||||
ll = va_arg(ap, long long);
|
||||
printf("%Ld", ll);
|
||||
printf(LONG_LONG_FORMAT, ll);
|
||||
break;
|
||||
case 'F':
|
||||
ld = va_arg(ap, LONG_DOUBLE);
|
||||
@ -1999,11 +2004,8 @@ void stdarg_test(void)
|
||||
vprintf1("%f %d %f\n", 1.0, 2, 3.0);
|
||||
vprintf1("%l %l %d %f\n", 1234567891234LL, 987654321986LL, 3, 1234.0);
|
||||
vprintf1("%F %F %F\n", LONG_DOUBLE_LITERAL(1.2), LONG_DOUBLE_LITERAL(2.3), LONG_DOUBLE_LITERAL(3.4));
|
||||
#ifdef __x86_64__
|
||||
/* a bug of x86's TCC */
|
||||
vprintf1("%d %f %l %F %d %f %l %F\n",
|
||||
1, 1.2, 3L, 4.5L, 6, 7.8, 9L, 0.1L);
|
||||
#endif
|
||||
1, 1.2, 3LL, LONG_DOUBLE_LITERAL(4.5), 6, 7.8, 9LL, LONG_DOUBLE_LITERAL(0.1));
|
||||
vprintf1("%d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f\n",
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
0.1, 1.2, 2.3, 3.4, 4.5, 5.6, 6.7, 7.8);
|
||||
|
Loading…
Reference in New Issue
Block a user