From d548d02e2c9def7c728db2edbc5477a9e41cedbc Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Sun, 2 Dec 2012 16:57:17 +0900 Subject: [PATCH] add lib test --- test/Makefile | 6 ++++++ test/lib_run.cpp | 9 +++++++++ test/lib_test.cpp | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 test/lib_run.cpp create mode 100644 test/lib_test.cpp diff --git a/test/Makefile b/test/Makefile index 27075ee4..cffcd92c 100644 --- a/test/Makefile +++ b/test/Makefile @@ -49,6 +49,12 @@ test_avx: normalize_prefix clean: rm -rf *.o $(TARGET) +lib_test.a: lib_test.cpp + $(CXX) -c $(CFLAGS) lib_test.cpp + ar r lib_test.a lib_test.o + +lib_run: lib_test.a lib_run.cpp + $(CXX) $(CFLAGS) lib_run.cpp lib_test.a -o lib_run make_nm: make_nm.cpp $(XBYAK_INC) diff --git a/test/lib_run.cpp b/test/lib_run.cpp new file mode 100644 index 00000000..d1e1127e --- /dev/null +++ b/test/lib_run.cpp @@ -0,0 +1,9 @@ +#include + +int ret123(); + +int main() +{ + printf("ret=%d\n", ret123()); +} + diff --git a/test/lib_test.cpp b/test/lib_test.cpp new file mode 100644 index 00000000..399d1fa8 --- /dev/null +++ b/test/lib_test.cpp @@ -0,0 +1,17 @@ +#include + +struct Code : public Xbyak::CodeGenerator { + Code() + { + mov(eax, 5); + ret(); + } +}; + +int ret123() +{ + static Code code; + int (*f)() = (int (*)())code.getCode(); + return f(); +} +