aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--sample/bf.cpp2
-rw-r--r--sample/static_buf.cpp2
-rw-r--r--sample/test0.cpp9
-rw-r--r--sample/toyvm.cpp2
-rw-r--r--test/sf_test.cpp10
-rw-r--r--xbyak/xbyak.h11
6 files changed, 16 insertions, 20 deletions
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<void (*)(void*, void*, int *)>()(Xbyak::CastTo<void*>(putchar), Xbyak::CastTo<void*>(getchar), stack);
+ bf.getCode<void (*)(const void*, const void*, int *)>()(reinterpret_cast<const void*>(putchar), reinterpret_cast<const void*>(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<int (*)(int,int)>(buf)(a, b);
+ return reinterpret_cast<int (*)(int, int)>(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<void*>(atoi));
+ call(reinterpret_cast<const void*>(atoi));
#endif
add(esp, 4);
#endif
@@ -96,7 +96,7 @@ public:
mov(rax, (size_t)atoi);
jmp(rax);
#else
- jmp(Xbyak::CastTo<void*>(atoi));
+ jmp(reinterpret_cast<const void*>(atoi));
#endif
}
int (*get() const)(const char *) { return getCode<int (*)(const char *)>(); }
@@ -171,8 +171,9 @@ int main()
return 1;
}
int (*func)(int) = s.getCode<int (*)(int)>();
- if (Xbyak::CastTo<uint8*>(func) != p) {
- fprintf(stderr, "internal error %p %p\n", p, Xbyak::CastTo<uint8*>(func));
+ const uint8 *funcp = reinterpret_cast<const uint8*>(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<void*>(printf));
+ call(reinterpret_cast<const void*>(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<int (*)()>(f)());
+ check(1, reinterpret_cast<int (*)()>(f)());
return;
case 1:
- check(11, Xbyak::CastTo<int (*)(int)>(f)(10));
+ check(11, reinterpret_cast<int (*)(int)>(f)(10));
return;
case 2:
- check(111, Xbyak::CastTo<int (*)(int, int)>(f)(10, 100));
+ check(111, reinterpret_cast<int (*)(int, int)>(f)(10, 100));
return;
case 3:
- check(1111, Xbyak::CastTo<int (*)(int, int, int)>(f)(10, 100, 1000));
+ check(1111, reinterpret_cast<int (*)(int, int, int)>(f)(10, 100, 1000));
return;
case 4:
- check(11111, Xbyak::CastTo<int (*)(int, int, int, int)>(f)(10, 100, 1000, 10000));
+ check(11111, reinterpret_cast<int (*)(int, int, int, int)>(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<class To, class From>
-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<class F>
- const F getCode() const { return CastTo<F>(top_); }
+ const F getCode() const { return reinterpret_cast<F>(top_); }
const uint8 *getCurr() const { return &top_[size_]; }
template<class F>
- const F getCurr() const { return CastTo<F>(&top_[size_]); }
+ const F getCurr() const { return reinterpret_cast<F>(&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<class Ret, class... Params>
- void call(Ret(*func)(Params...)) { call(CastTo<const void*>(func)); }
+ void call(Ret(*func)(Params...)) { call(reinterpret_cast<const void*>(func)); }
#endif
void call(const void *addr) { opJmpAbs(addr, T_NEAR, 0, 0xE8); }