Compilation fix

This commit is contained in:
Nekotekina 2015-02-13 23:24:18 +03:00
parent 5fc77fe89e
commit 0d489518ab
4 changed files with 64 additions and 54 deletions

View file

@ -263,6 +263,7 @@ namespace fmt
} }
}; };
#ifdef __APPLE__
template<> template<>
struct get_fmt<unsigned long> struct get_fmt<unsigned long>
{ {
@ -286,6 +287,7 @@ namespace fmt
} }
} }
}; };
#endif
template<> template<>
struct get_fmt<u64> struct get_fmt<u64>
@ -383,6 +385,7 @@ namespace fmt
} }
}; };
#ifdef __APPLE__
template<> template<>
struct get_fmt<long> struct get_fmt<long>
{ {
@ -406,6 +409,7 @@ namespace fmt
} }
} }
}; };
#endif
template<> template<>
struct get_fmt<s64> struct get_fmt<s64>

View file

@ -210,49 +210,50 @@ typedef ucontext_t x64_context;
uint64_t* darwin_x64reg(x64_context *context, int reg) uint64_t* darwin_x64reg(x64_context *context, int reg)
{ {
auto *state = &context->uc_mcontext->__ss; auto *state = &context->uc_mcontext->__ss;
switch(reg) switch(reg)
{ {
case 0: // RAX case 0: // RAX
return &state->__rax; return &state->__rax;
case 1: // RCX case 1: // RCX
return &state->__rcx; return &state->__rcx;
case 2: // RDX case 2: // RDX
return &state->__rdx; return &state->__rdx;
case 3: // RBX case 3: // RBX
return &state->__rbx; return &state->__rbx;
case 4: // RSP case 4: // RSP
return &state->__rsp; return &state->__rsp;
case 5: // RBP case 5: // RBP
return &state->__rbp; return &state->__rbp;
case 6: // RSI case 6: // RSI
return &state->__rsi; return &state->__rsi;
case 7: // RDI case 7: // RDI
return &state->__rdi; return &state->__rdi;
case 8: // R8 case 8: // R8
return &state->__r8; return &state->__r8;
case 9: // R9 case 9: // R9
return &state->__r9; return &state->__r9;
case 10: // R10 case 10: // R10
return &state->__r10; return &state->__r10;
case 11: // R11 case 11: // R11
return &state->__r11; return &state->__r11;
case 12: // R12 case 12: // R12
return &state->__r12; return &state->__r12;
case 13: // R13 case 13: // R13
return &state->__r13; return &state->__r13;
case 14: // R14 case 14: // R14
return &state->__r14; return &state->__r14;
case 15: // R15 case 15: // R15
return &state->__r15; return &state->__r15;
case 16: // RIP case 16: // RIP
return &state->__rip; return &state->__rip;
default: // FAIL default: // FAIL
assert(0); assert(0);
} }
} }
#else #else
typedef decltype(REG_RIP) reg_table_t; typedef decltype(REG_RIP) reg_table_t;
static const reg_table_t reg_table[17] = static const reg_table_t reg_table[17] =
@ -262,6 +263,7 @@ static const reg_table_t reg_table[17] =
}; };
#define X64REG(context, reg) (&context->uc_mcontext.gregs[reg_table[reg]]) #define X64REG(context, reg) (&context->uc_mcontext.gregs[reg_table[reg]])
#endif // __APPLE__ #endif // __APPLE__
#endif #endif
@ -379,7 +381,7 @@ void signal_handler(int sig, siginfo_t* info, void* uct)
const u64 addr64 = (u64)info->si_addr - (u64)vm::g_base_addr; const u64 addr64 = (u64)info->si_addr - (u64)vm::g_base_addr;
#ifdef __APPLE__ #ifdef __APPLE__
const bool is_writing = ((ucontext_t*)uct)->uc_mcontext->__es.__err & 0x2; const bool is_writing = ((ucontext_t*)uct)->uc_mcontext->__es.__err & 0x2;
#else #else
const bool is_writing = ((ucontext_t*)uct)->uc_mcontext.gregs[REG_ERR] & 0x2; const bool is_writing = ((ucontext_t*)uct)->uc_mcontext.gregs[REG_ERR] & 0x2;
#endif #endif

View file

@ -887,6 +887,7 @@ struct cast_ppu_gpr<u32, false>
} }
}; };
#ifdef __APPLE__
template<> template<>
struct cast_ppu_gpr<unsigned long, false> struct cast_ppu_gpr<unsigned long, false>
{ {
@ -900,6 +901,7 @@ struct cast_ppu_gpr<unsigned long, false>
return static_cast<unsigned long>(reg); return static_cast<unsigned long>(reg);
} }
}; };
#endif
template<> template<>
struct cast_ppu_gpr<u64, false> struct cast_ppu_gpr<u64, false>

View file

@ -100,20 +100,22 @@ namespace vm
} }
}; };
template<> #ifdef __APPLE__
struct cast_ptr<unsigned long> template<>
{ struct cast_ptr<unsigned long>
__forceinline static u32 cast(const unsigned long addr, const char* func) {
{ __forceinline static u32 cast(const unsigned long addr, const char* func)
const u32 res = static_cast<u32>(addr); {
if (res != addr) const u32 res = static_cast<u32>(addr);
{ if (res != addr)
vm::error(addr, func); {
} vm::error(addr, func);
}
return res; return res;
} }
}; };
#endif
template<> template<>
struct cast_ptr<u32> struct cast_ptr<u32>