From 48764132173963a682475af20a714e9dce5beca4 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Sat, 16 Jan 2010 10:55:51 +0000 Subject: [PATCH] __WORDSIZE is not available on non-GNU systems (Dominic Fandrey) --- code/qcommon/vm_interpreted.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c index a31c7195..abe24729 100644 --- a/code/qcommon/vm_interpreted.c +++ b/code/qcommon/vm_interpreted.c @@ -516,18 +516,20 @@ nextInstruction2: //VM_LogSyscalls( (int *)&image[ programStack + 4 ] ); { - intptr_t* argptr = (intptr_t *)&image[ programStack + 4 ]; - #if __WORDSIZE == 64 - // the vm has ints on the stack, we expect - // longs so we have to convert it - intptr_t argarr[16]; - int i; - for (i = 0; i < 16; ++i) { - argarr[i] = *(int*)&image[ programStack + 4 + 4*i ]; + // the vm has ints on the stack, we expect + // pointers so we might have to convert it + if (sizeof(intptr_t) != sizeof(int)) { + intptr_t argarr[16]; + int *imagePtr = (int *)&image[programStack]; + int i; + for (i = 0; i < 16; ++i) { + argarr[i] = *(++imagePtr); + } + r = vm->systemCall( argarr ); + } else { + intptr_t* argptr = (intptr_t *)&image[ programStack + 4 ]; + r = vm->systemCall( argptr ); } - argptr = argarr; - #endif - r = vm->systemCall( argptr ); } #ifdef DEBUG_VM