diff --git a/sample/bf.cpp b/sample/bf.cpp index 6968920..20a0fd9 100644 --- a/sample/bf.cpp +++ b/sample/bf.cpp @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) Brainfuck bf(ifs); if (mode == 0) { static int stack[128 * 1024]; - bf.getCode()(Xbyak::CastTo(putchar), Xbyak::CastTo(getchar), stack); + bf.getCode()(reinterpret_cast(putchar), reinterpret_cast(getchar), stack); } else { dump(bf.getCode(), bf.getSize()); } diff --git a/sample/static_buf.cpp b/sample/static_buf.cpp index 7cf8038..0a8ff57 100644 --- a/sample/static_buf.cpp +++ b/sample/static_buf.cpp @@ -32,7 +32,7 @@ struct Code : Xbyak::CodeGenerator { inline int add(int a, int b) { - return Xbyak::CastTo(buf)(a, b); + return reinterpret_cast(buf)(a, b); } int main() diff --git a/sample/test0.cpp b/sample/test0.cpp index cd19e48..5a4d91b 100644 --- a/sample/test0.cpp +++ b/sample/test0.cpp @@ -77,7 +77,7 @@ public: #ifdef XBYAK_VARIADIC_TEMPLATE call(atoi); #else - call(Xbyak::CastTo(atoi)); + call(reinterpret_cast(atoi)); #endif add(esp, 4); #endif @@ -96,7 +96,7 @@ public: mov(rax, (size_t)atoi); jmp(rax); #else - jmp(Xbyak::CastTo(atoi)); + jmp(reinterpret_cast(atoi)); #endif } int (*get() const)(const char *) { return getCode(); } @@ -171,8 +171,9 @@ int main() return 1; } int (*func)(int) = s.getCode(); - if (Xbyak::CastTo(func) != p) { - fprintf(stderr, "internal error %p %p\n", p, Xbyak::CastTo(func)); + const uint8 *funcp = reinterpret_cast(func); + if (funcp != p) { + fprintf(stderr, "internal error %p %p\n", p, funcp); return 1; } printf("0 + ... + %d = %d\n", 100, func(100)); diff --git a/sample/toyvm.cpp b/sample/toyvm.cpp index 4dedad4..cd869ea 100644 --- a/sample/toyvm.cpp +++ b/sample/toyvm.cpp @@ -204,7 +204,7 @@ public: push(reg[r]); push('A' + r); push((int)str); - call(Xbyak::CastTo(printf)); + call(reinterpret_cast(printf)); add(esp, 4 * 4); pop(ecx); pop(edx); diff --git a/test/sf_test.cpp b/test/sf_test.cpp index 8988bb0..286ecd1 100644 --- a/test/sf_test.cpp +++ b/test/sf_test.cpp @@ -222,19 +222,19 @@ void verify(const Xbyak::uint8 *f, int pNum) { switch (pNum) { case 0: - check(1, Xbyak::CastTo(f)()); + check(1, reinterpret_cast(f)()); return; case 1: - check(11, Xbyak::CastTo(f)(10)); + check(11, reinterpret_cast(f)(10)); return; case 2: - check(111, Xbyak::CastTo(f)(10, 100)); + check(111, reinterpret_cast(f)(10, 100)); return; case 3: - check(1111, Xbyak::CastTo(f)(10, 100, 1000)); + check(1111, reinterpret_cast(f)(10, 100, 1000)); return; case 4: - check(11111, Xbyak::CastTo(f)(10, 100, 1000, 10000)); + check(11111, reinterpret_cast(f)(10, 100, 1000, 10000)); return; default: printf("ERR pNum=%d\n", pNum); diff --git a/xbyak/xbyak.h b/xbyak/xbyak.h index 47494ef..679d24b 100644 --- a/xbyak/xbyak.h +++ b/xbyak/xbyak.h @@ -275,11 +275,6 @@ inline void AlignedFree(void *p) #endif } -template -inline const To CastTo(From p) throw() -{ - return (const To)(size_t)(p); -} namespace inner { static const size_t ALIGN_PAGE_SIZE = 4096; @@ -925,10 +920,10 @@ public: void dq(uint64 code) { db(code, 8); } const uint8 *getCode() const { return top_; } template - const F getCode() const { return CastTo(top_); } + const F getCode() const { return reinterpret_cast(top_); } const uint8 *getCurr() const { return &top_[size_]; } template - const F getCurr() const { return CastTo(&top_[size_]); } + const F getCurr() const { return reinterpret_cast(&top_[size_]); } size_t getSize() const { return size_; } void setSize(size_t size) { @@ -2200,7 +2195,7 @@ public: // call(function pointer) #ifdef XBYAK_VARIADIC_TEMPLATE template - void call(Ret(*func)(Params...)) { call(CastTo(func)); } + void call(Ret(*func)(Params...)) { call(reinterpret_cast(func)); } #endif void call(const void *addr) { opJmpAbs(addr, T_NEAR, 0, 0xE8); }