aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile11
-rw-r--r--tests/asm-c-connect-1.c31
-rw-r--r--tests/asm-c-connect-2.c7
3 files changed, 48 insertions, 1 deletions
diff --git a/tests/Makefile b/tests/Makefile
index 6a61717..61b585e 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -16,6 +16,7 @@ TESTS = \
memtest \
dlltest \
abitest \
+ asm-c-connect-test \
vla_test-run \
cross-test \
tests2-dir \
@@ -44,7 +45,7 @@ ifeq ($(CONFIG_arm_eabi),yes)
TESTS := $(filter-out test3,$(TESTS))
endif
ifeq (,$(filter i386 x86_64,$(ARCH)))
- TESTS := $(filter-out dlltest,$(TESTS))
+ TESTS := $(filter-out dlltest asm-c-connect-test,$(TESTS))
endif
ifndef CONFIG_cross
TESTS := $(filter-out cross-%,$(TESTS))
@@ -231,6 +232,13 @@ vla_test-run: vla_test$(EXESUF)
@echo ------------ $@ ------------
./vla_test$(EXESUF)
+asm-c-connect$(EXESUF): asm-c-connect-1.c asm-c-connect-2.c
+ $(TCC) -o $@ $^
+
+asm-c-connect-test: asm-c-connect$(EXESUF)
+ @echo ------------ $@ ------------
+ ./asm-c-connect$(EXESUF)
+
cross-test :
@echo ------------ $@ ------------
$(TOP)/i386-tcc$(EXESUF) $(TCCFLAGS-unx) -c $(TOPSRC)/examples/ex3.c && echo "ok"
@@ -264,6 +272,7 @@ cache: tcc_g
clean:
rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc
rm -f *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234]
+ rm -f asm-c-connect$(EXESUF)
rm -f ex? tcc_g weaktest.*.txt *.def
@$(MAKE) -C tests2 $@
@$(MAKE) -C pp $@
diff --git a/tests/asm-c-connect-1.c b/tests/asm-c-connect-1.c
new file mode 100644
index 0000000..3f7b010
--- /dev/null
+++ b/tests/asm-c-connect-1.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+
+#if defined _WIN32 && !defined __TINYC__
+# define U "_"
+#else
+# define U
+#endif
+
+const char str[] = "x1\n";
+#ifdef __x86_64__
+asm(U"x1: push %rbp; mov $"U"str, %rdi; call "U"printf; pop %rbp; ret");
+#elif defined (__i386__)
+asm(U"x1: push $"U"str; call "U"printf; pop %eax; ret");
+#endif
+
+int main(int argc, char *argv[])
+{
+ asm("call "U"x1");
+ asm("call "U"x2");
+ asm("call "U"x3");
+ return 0;
+}
+
+static
+int x2(void)
+{
+ printf("x2\n");
+ return 2;
+}
+
+extern int x3(void);
diff --git a/tests/asm-c-connect-2.c b/tests/asm-c-connect-2.c
new file mode 100644
index 0000000..3a8cff2
--- /dev/null
+++ b/tests/asm-c-connect-2.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int x3(void)
+{
+ printf("x3\n");
+ return 3;
+}