simple test for init
This commit is contained in:
parent
5f696277f7
commit
3f66cdac5d
4 changed files with 32 additions and 14 deletions
|
@ -47,7 +47,7 @@ test_avx: normalize_prefix
|
||||||
./test_avx.sh 64
|
./test_avx.sh 64
|
||||||
./test_avx.sh Y64
|
./test_avx.sh Y64
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o $(TARGET)
|
rm -rf *.o $(TARGET) lib_run
|
||||||
|
|
||||||
lib_run: lib_test.cpp lib_run.cpp
|
lib_run: lib_test.cpp lib_run.cpp
|
||||||
$(CXX) $(CFLAGS) lib_run.cpp lib_test.cpp -o lib_run
|
$(CXX) $(CFLAGS) lib_run.cpp lib_test.cpp -o lib_run
|
||||||
|
|
27
test/lib.h
27
test/lib.h
|
@ -1,6 +1,33 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int a;
|
||||||
|
A()
|
||||||
|
: a(5)
|
||||||
|
{
|
||||||
|
puts("A cstr");
|
||||||
|
}
|
||||||
|
~A()
|
||||||
|
{
|
||||||
|
puts("A dstr");
|
||||||
|
}
|
||||||
|
void put() const
|
||||||
|
{
|
||||||
|
printf("a=%d\n", a);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<int dummy = 0>
|
||||||
|
struct XT {
|
||||||
|
static A a;
|
||||||
|
};
|
||||||
|
|
||||||
|
template<int dummy>
|
||||||
|
A XT<dummy>::a;
|
||||||
|
|
||||||
|
typedef XT<0> X;
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
static struct Init {
|
static struct Init {
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
puts("main");
|
||||||
|
X::a.put();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,12 @@
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include <xbyak/xbyak.h>
|
|
||||||
|
|
||||||
struct Code : public Xbyak::CodeGenerator {
|
|
||||||
Code()
|
|
||||||
{
|
|
||||||
printf("Code:%s\n", eax.toString());
|
|
||||||
ret();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
void init()
|
void init()
|
||||||
try
|
|
||||||
{
|
{
|
||||||
static bool init = true;
|
static bool init = true;
|
||||||
printf("in lib_test %d\n", init);
|
printf("in lib_test %d\n", init);
|
||||||
if (!init) return;
|
if (!init) return;
|
||||||
init = false;
|
init = false;
|
||||||
static Code code;
|
X::a.put();
|
||||||
} catch (const Xbyak::Error& e) {
|
|
||||||
printf("err=%s\n", Xbyak::ConvertErrorToString(e));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue