diff --git a/test/Makefile b/test/Makefile index cffcd92..c2be64d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -49,12 +49,8 @@ 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 +lib_run: lib_test.cpp lib_run.cpp + $(CXX) $(CFLAGS) lib_run.cpp lib_test.cpp -o lib_run make_nm: make_nm.cpp $(XBYAK_INC) diff --git a/test/lib.h b/test/lib.h new file mode 100644 index 0000000..86a6f41 --- /dev/null +++ b/test/lib.h @@ -0,0 +1,13 @@ +#pragma once +#include + +void init(); + +static struct Init { + Init() + { + puts("Init"); + init(); + } +} s_init; + diff --git a/test/lib_run.cpp b/test/lib_run.cpp index d1e1127..cf18722 100644 --- a/test/lib_run.cpp +++ b/test/lib_run.cpp @@ -1,9 +1,6 @@ -#include - -int ret123(); +#include "lib.h" int main() { - printf("ret=%d\n", ret123()); } diff --git a/test/lib_test.cpp b/test/lib_test.cpp index 399d1fa..d5c91fe 100644 --- a/test/lib_test.cpp +++ b/test/lib_test.cpp @@ -1,17 +1,23 @@ +#include "lib.h" #include struct Code : public Xbyak::CodeGenerator { Code() { - mov(eax, 5); + printf("Code:%s\n", eax.toString()); ret(); } }; -int ret123() +void init() + try { + static bool init = true; + printf("in lib_test %d\n", init); + if (!init) return; + init = false; static Code code; - int (*f)() = (int (*)())code.getCode(); - return f(); +} catch (const Xbyak::Error& e) { + printf("err=%s\n", Xbyak::ConvertErrorToString(e)); }