summaryrefslogtreecommitdiff
path: root/src/qcommon/vm_x86_64.c
diff options
context:
space:
mode:
authorThilo Schulz <arny@ats.s.bawue.de>2011-05-14 14:34:18 +0000
committerTim Angus <tim@ngus.net>2013-01-09 22:17:33 +0000
commit79c30786d7f8c30b7e497658920d503e6f3a19b2 (patch)
treeb4eb3bd0434240723a7f7db7a112ec8baab9ce66 /src/qcommon/vm_x86_64.c
parent457f832631206027d7c92050a4b1230f378aa1e4 (diff)
ensure that ent->classname is always non-null (for entity numbers up to level.num_entities-1, and ENTITYNUM_WORLD and ENTITYNUM_NONE), for player entities and #ENTITYNUM_NONE in particular, patch by DevHC
Diffstat (limited to 'src/qcommon/vm_x86_64.c')
-rw-r--r--src/qcommon/vm_x86_64.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/qcommon/vm_x86_64.c b/src/qcommon/vm_x86_64.c
index fa2185a7..e7bb72ac 100644
--- a/src/qcommon/vm_x86_64.c
+++ b/src/qcommon/vm_x86_64.c
@@ -83,11 +83,11 @@ static void VM_Destroy_Compiled(vm_t* self);
*/
-static int64_t CROSSCALL callAsmCall(int64_t callProgramStack, int64_t callSyscallNum)
+static intptr_t CROSSCALL callAsmCall(intptr_t callProgramStack, int64_t callSyscallNum)
{
vm_t *savedVM;
- int64_t ret = 0x77;
- int64_t args[11];
+ intptr_t ret = 0x77;
+ intptr_t args[11];
// int iargs[11];
int i;
@@ -246,7 +246,7 @@ void emit(const char* fmt, ...)
emit("andl $0x%x, %%ecx", vm->dataMask &~(bytes-1)); \
emit("cmpl %%" #reg ", %%ecx"); \
emit("jz rc_ok_i_%08x", instruction); \
- emit("movq $%"PRIu64", %%rax", (uint64_t) memviolation); \
+ emit("movq $%"PRIu64", %%rax", (intptr_t) memviolation); \
emit("callq *%%rax"); \
emit("rc_ok_i_%08x:", instruction)
@@ -255,7 +255,7 @@ void emit(const char* fmt, ...)
emit("andl $0x%x, %%ecx", OPSTACK_MASK & ~0x03); \
emit("cmpl %%esi, %%ecx"); \
emit("jz oc_ok_i_%08x", instruction); \
- emit("movq $%"PRIu64", %%rax", (uint64_t) opstackviolation); \
+ emit("movq $%"PRIu64", %%rax", (intptr_t) opstackviolation); \
emit("callq *%%rax"); \
emit("oc_ok_i_%08x:", instruction)
#elif 1
@@ -280,13 +280,13 @@ void emit(const char* fmt, ...)
#define CHECK_INSTR_REG(reg) \
emit("cmpl $%u, %%"#reg, header->instructionCount); \
emit("jb jmp_ok_i_%08x", instruction); \
- emit("movq $%"PRIu64", %%rax", (uint64_t)jmpviolation); \
+ emit("movq $%"PRIu64", %%rax", (intptr_t)jmpviolation); \
emit("callq *%%rax"); \
emit("jmp_ok_i_%08x:", instruction)
#define PREPARE_JMP(reg) \
CHECK_INSTR_REG(reg); \
- emit("movq $%"PRIu64", %%rbx", (uint64_t)vm->instructionPointers); \
+ emit("movq $%"PRIu64", %%rbx", (intptr_t)vm->instructionPointers); \
emit("movl (%%rbx, %%rax, 4), %%eax"); \
emit("addq %%r10, %%rax")
@@ -607,12 +607,11 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
got_const = 0;
emit("movq $%u, %%rsi", -1-const_value); // second argument in rsi
} else {
- emit("negl %%eax"); // convert to actual number
- emit("decl %%eax");
+ emit("notl %%eax"); // convert to actual number
// first argument already in rdi
emit("movq %%rax, %%rsi"); // second argument in rsi
}
- emit("movq $%"PRIu64", %%rax", (uint64_t)callAsmCall);
+ emit("movq $%"PRIu64", %%rax", (intptr_t) callAsmCall);
emit("callq *%%rax");
emit("pop %%rbx");
emit("addq %%rbx, %%rsp");
@@ -801,7 +800,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
emit("movl 4(%%r9, %%rsi, 1), %%edi"); // 1st argument dest
emit("movl 8(%%r9, %%rsi, 1), %%esi"); // 2nd argument src
emit("movl $%d, %%edx", iarg); // 3rd argument count
- emit("movq $%"PRIu64", %%rax", (uint64_t)block_copy_vm);
+ emit("movq $%"PRIu64", %%rax", (intptr_t) block_copy_vm);
emit("callq *%%rax");
emit("pop %%rbx");
emit("addq %%rbx, %%rsp");
@@ -972,7 +971,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) {
Com_Error(ERR_DROP, "leftover const");
}
- emit("movq $%"PRIu64", %%rax", (uint64_t)eop);
+ emit("movq $%"PRIu64", %%rax", (intptr_t) eop);
emit("callq *%%rax");
} // pass loop
@@ -1107,7 +1106,7 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
" movq %2,%%r10 \r\n" \
" subq $24, %%rsp # fix alignment as call pushes one value \r\n" \
" callq *%%r10 \r\n" \
- " addq $24, %%rsp \r\n" \
+ " addq $24, %%rsp \r\n" \
" movl %%edi, %0 \r\n" \
" movl %%esi, %1 \r\n" \
: "=m" (programStack), "=m" (opStackRet)