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
108108 test4: test.ref
109109 @echo ------------ $@ ------------
110110 # object + link output
111− $(TCC) -c -o tcctest3.o tcctest.c
111+ $(TCC) -c -o tcctest3.o $(SRCDIR)/tcctest.c
112112 $(TCC) -o tcctest3 tcctest3.o
113113 ./tcctest3 > test3.out
114114 @if diff -u test.ref test3.out ; then echo "Object Auto Test OK"; fi
115115 # dynamic output
116− $(TCC) -o tcctest1 tcctest.c
116+ $(TCC) -o tcctest1 $(SRCDIR)/tcctest.c
117117 ./tcctest1 > test1.out
118118 @if diff -u test.ref test1.out ; then echo "Dynamic Auto Test OK"; fi
119119 # dynamic output + bound check
120− $(TCC) -b -o tcctest4 tcctest.c
120+ $(TCC) -b -o tcctest4 $(SRCDIR)/tcctest.c
121121 ./tcctest4 > test4.out
122122 @if diff -u test.ref test4.out ; then echo "BCheck Auto Test OK"; fi
123123 # static output
124− $(TCC) -static -o tcctest2 tcctest.c
124+ $(TCC) -static -o tcctest2 $(SRCDIR)/tcctest.c
125125 ./tcctest2 > test2.out
126126 @if diff -u test.ref test2.out ; then echo "Static Auto Test OK"; fi
127127
@@ -188,8 +188,8 @@ abitest-tcc$(EXESUF): abitest.c $(top_builddir)/$(LIBTCC) · 60 unmodified lines
188188
189189 abitest: abitest-cc$(EXESUF) abitest-tcc$(EXESUF)
190190 @echo ------------ $@ ------------
191− ./abitest-cc$(EXESUF) lib_path=..
192− ./abitest-tcc$(EXESUF) lib_path=..
191+ ./abitest-cc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"
192+ ./abitest-tcc$(EXESUF) lib_path=.. include="$(top_srcdir)/include"
193193
194194 # targets for development
195195 %.bin: %.c tcc
tests/abitest.c+21−2
@@ -4,7 +4,17 @@ · 3 unmodified lines
44 #include <string.h>
55 #include <stdarg.h>
66
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+
716 static const char *tccdir = NULL;
17+static const char *include_dir = NULL;
818
919 typedef int (*callback_type) (void*);
1020
@@ -21,6 +31,10 @@ static int run_callback(const char *src, callback_type callback) { · 10 unmodified lines
2131 return -1;
2232 if (tccdir)
2333 tcc_set_lib_path(s, tccdir);
34+ if (include_dir) {
35+ if (tcc_add_include_path(s, include_dir) == -1)
36+ return -1;
37+ }
2438 if (tcc_set_output_type(s, TCC_OUTPUT_MEMORY) == -1)
2539 return -1;
2640 if (tcc_compile_string(s, src) == -1)
@@ -38,6 +52,9 @@ static int run_callback(const char *src, callback_type callback) { · 11 unmodified lines
3852 return result;
3953 }
4054
55+#define STR2(x) #x
56+#define STR(x) STR2(x)
57+
4158 #define RET_PRIMITIVE_TEST(name, type, val) \
4259 static int ret_ ## name ## _test_callback(void *ptr) { \
4360 type (*callback) (type) = (type(*)(type))ptr; \
@@ -47,7 +64,7 @@ static int run_callback(const char *src, callback_type callback) { · 3 unmodified lines
4764 } \
4865 \
4966 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;}"; \
5168 return run_callback(src, ret_ ## name ## _test_callback); \
5269 }
5370
@@ -55,7 +72,7 @@ RET_PRIMITIVE_TEST(int, int, 70000) · 1 unmodified line
5572 RET_PRIMITIVE_TEST(longlong, long long, 4333369356528LL)
5673 RET_PRIMITIVE_TEST(float, float, 63.0)
5774 RET_PRIMITIVE_TEST(double, double, 14789798.0)
58−RET_PRIMITIVE_TEST(longdouble, long double, 378943892.0)
75+RET_PRIMITIVE_TEST(longdouble, LONG_DOUBLE, LONG_DOUBLE_LITERAL(378943892.0))
5976
6077 /*
6178 * ret_2float_test:
@@ -303,6 +320,8 @@ int main(int argc, char **argv) { · 241 unmodified lines
303320 tccdir = argv[i] + 9;
304321 else if (!memcmp(argv[i], "run_test=", 9))
305322 testname = argv[i] + 9;
323+ else if (!memcmp(argv[i], "include=", 8))
324+ include_dir = argv[i] + 8;
306325 }
307326
308327 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