History

Workaround for MinGWs use of 80-bit long double on Win32.

This is incompatible with MSVC and TCC on Win32. Bounds checking appears to be broken (test4).

James Lyon committed 13 years ago

Commit 05fa2e71 parent 23f73e92 files · +27 −8Browse files

Unified · Split

2 files
  1. tests/Makefile +6 −6
  2. tests/abitest.c +21 −2
tests/Makefile+6−6
@@ -108,20 +108,20 @@ test3: test.ref · 107 unmodified lines
108test4: test.ref108test4: test.ref
109 @echo ------------ $@ ------------109 @echo ------------ $@ ------------
110# object + link output110# object + link output
111 $(TCC) -c -o tcctest3.o tcctest.c111 $(TCC) -c -o tcctest3.o $(SRCDIR)/tcctest.c
112 $(TCC) -o tcctest3 tcctest3.o112 $(TCC) -o tcctest3 tcctest3.o
113 ./tcctest3 > test3.out113 ./tcctest3 > test3.out
114 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi114 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
115# dynamic output115# dynamic output
116 $(TCC) -o tcctest1 tcctest.c116 $(TCC) -o tcctest1 $(SRCDIR)/tcctest.c
117 ./tcctest1 > test1.out117 ./tcctest1 > test1.out
118 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi118 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
119# dynamic output + bound check119# dynamic output + bound check
120 $(TCC) -b -o tcctest4 tcctest.c120 $(TCC) -b -o tcctest4 $(SRCDIR)/tcctest.c
121 ./tcctest4 > test4.out121 ./tcctest4 > test4.out
122 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi122 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
123# static output123# static output
124 $(TCC) -static -o tcctest2 tcctest.c124 $(TCC) -static -o tcctest2 $(SRCDIR)/tcctest.c
125 ./tcctest2 > test2.out125 ./tcctest2 > test2.out
126 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi126 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
127 127
@@ -188,8 +188,8 @@ abitest-tcc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) · 60 unmodified lines
188 188
189abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF)189abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF)
190 @echo ------------ $@ ------------190 @echo ------------ $@ ------------
191 ./abitest-cc$(EXESUF) lib_path=..191 ./abitest-cc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"
192 ./abitest-tcc$(EXESUF) lib_path=..192 ./abitest-tcc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"
193 193
194# targets for development194# targets for development
195%.bin: %.c tcc195%.bin: %.c tcc
tests/abitest.c+21−2
@@ -4,7 +4,17 @@ · 3 unmodified lines
4#include <string.h>4#include <string.h>
5#include <stdarg.h>5#include <stdarg.h>
6 6
7// MinGW has 80-bit rather than 64-bit long double which isn't compatible with TCC or MSVC
8#if defined(_WIN32) && defined(__GNUC__)
9#define LONG_DOUBLE double
10#define LONG_DOUBLE_LITERAL(x) x
11#else
12#define LONG_DOUBLE long double
13#define LONG_DOUBLE_LITERAL(x) x ## L
14#endif
15
7static const char *tccdir = NULL;16static const char *tccdir = NULL;
17static const char *include_dir = NULL;
8 18
9typedef int (*callback_type) (void*);19typedef int (*callback_type) (void*);
10 20
@@ -21,6 +31,10 @@ static int run_callback(const char *src, callback_type callback) { · 10 unmodified lines
21 return -1;31 return -1;
22 if (tccdir)32 if (tccdir)
23 tcc_set_lib_path(s, tccdir);33 tcc_set_lib_path(s, tccdir);
34 if (include_dir) {
35 if (tcc_add_include_path(s, include_dir) == -1)
36 return -1;
37 }
24 if (tcc_set_output_type(s, TCC_OUTPUT_MEMORY) == -1)38 if (tcc_set_output_type(s, TCC_OUTPUT_MEMORY) == -1)
25 return -1;39 return -1;
26 if (tcc_compile_string(s, src) == -1)40 if (tcc_compile_string(s, src) == -1)
@@ -38,6 +52,9 @@ static int run_callback(const char *src, callback_type callback) { · 11 unmodified lines
38 return result;52 return result;
39}53}
40 54
55#define STR2(x) #x
56#define STR(x) STR2(x)
57
41#define RET_PRIMITIVE_TEST(name, type, val) \58#define RET_PRIMITIVE_TEST(name, type, val) \
42 static int ret_ ## name ## _test_callback(void *ptr) { \59 static int ret_ ## name ## _test_callback(void *ptr) { \
43 type (*callback) (type) = (type(*)(type))ptr; \60 type (*callback) (type) = (type(*)(type))ptr; \
@@ -47,7 +64,7 @@ static int run_callback(const char *src, callback_type callback) { · 3 unmodified lines
47 } \64 } \
48 \65 \
49 static int ret_ ## name ## _test(void) { \66 static int ret_ ## name ## _test(void) { \
50 const char *src = #type " f(" #type " x) {return x+x;}"; \67 const char *src = STR(type) " f(" STR(type) " x) {return x+x;}"; \
51 return run_callback(src, ret_ ## name ## _test_callback); \68 return run_callback(src, ret_ ## name ## _test_callback); \
52 }69 }
53 70
@@ -55,7 +72,7 @@ RET_PRIMITIVE_TEST(int, int, 70000) · 1 unmodified line
55RET_PRIMITIVE_TEST(longlong, long long, 4333369356528LL)72RET_PRIMITIVE_TEST(longlong, long long, 4333369356528LL)
56RET_PRIMITIVE_TEST(float, float, 63.0)73RET_PRIMITIVE_TEST(float, float, 63.0)
57RET_PRIMITIVE_TEST(double, double, 14789798.0)74RET_PRIMITIVE_TEST(double, double, 14789798.0)
58RET_PRIMITIVE_TEST(longdouble, long double, 378943892.0)75RET_PRIMITIVE_TEST(longdouble, LONG_DOUBLE, LONG_DOUBLE_LITERAL(378943892.0))
59 76
60/*77/*
61 * ret_2float_test:78 * ret_2float_test:
@@ -303,6 +320,8 @@ int main(int argc, char **argv) { · 241 unmodified lines
303 tccdir = argv[i] + 9;320 tccdir = argv[i] + 9;
304 else if (!memcmp(argv[i], "run_test=", 9))321 else if (!memcmp(argv[i], "run_test=", 9))
305 testname = argv[i] + 9;322 testname = argv[i] + 9;
323 else if (!memcmp(argv[i], "include=", 8))
324 include_dir = argv[i] + 8;
306 } 325 }
307 326
308 RUN_TEST(ret_int_test);327 RUN_TEST(ret_int_test);

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