add lib test

This commit is contained in:
MITSUNARI Shigeo 2012-12-02 16:57:17 +09:00
parent 6f57b3cf03
commit d548d02e2c
3 changed files with 32 additions and 0 deletions

View file

@ -49,6 +49,12 @@ test_avx: normalize_prefix
clean: clean:
rm -rf *.o $(TARGET) 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) make_nm: make_nm.cpp $(XBYAK_INC)

9
test/lib_run.cpp Normal file
View file

@ -0,0 +1,9 @@
#include <stdio.h>
int ret123();
int main()
{
printf("ret=%d\n", ret123());
}

17
test/lib_test.cpp Normal file
View file

@ -0,0 +1,17 @@
#include <xbyak/xbyak.h>
struct Code : public Xbyak::CodeGenerator {
Code()
{
mov(eax, 5);
ret();
}
};
int ret123()
{
static Code code;
int (*f)() = (int (*)())code.getCode();
return f();
}