Skip to content

Commit

Permalink
add lib test
Browse files Browse the repository at this point in the history
  • Loading branch information
herumi committed Dec 2, 2012
1 parent 6f57b3c commit d548d02
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/Makefile
Expand Up @@ -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)


9 changes: 9 additions & 0 deletions test/lib_run.cpp
@@ -0,0 +1,9 @@
#include <stdio.h>

int ret123();

int main()
{
printf("ret=%d\n", ret123());
}

17 changes: 17 additions & 0 deletions test/lib_test.cpp
@@ -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();
}

0 comments on commit d548d02

Please sign in to comment.