From: David Schleef Date: Thu, 23 Dec 2010 07:47:39 +0000 (-0800) Subject: Build fixes for win64 X-Git-Tag: orc-0.4.12~29 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd25bfa219d840763497eb4f52218015c0a1c37c;p=platform%2Fupstream%2Forc.git Build fixes for win64 --- diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index 46c0517..6e2b76a 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -297,13 +297,13 @@ orc_executor_emulate (OrcExecutor *ex) } else if (var->vartype == ORC_VAR_TYPE_TEMP) { opcode_ex[j].src_ptrs[k] = tmpspace[insn->src_args[k]]; } else if (var->vartype == ORC_VAR_TYPE_SRC) { - if (((unsigned long)ex->arrays[insn->src_args[k]]) & (var->size - 1)) { + if (ORC_PTR_TO_INT(ex->arrays[insn->src_args[k]]) & (var->size - 1)) { ORC_ERROR("Unaligned array for src%d, program %s", (insn->src_args[k]-ORC_VAR_S1), ex->program->name); } opcode_ex[j].src_ptrs[k] = ex->arrays[insn->src_args[k]]; } else if (var->vartype == ORC_VAR_TYPE_DEST) { - if (((unsigned long)ex->arrays[insn->src_args[k]]) & (var->size - 1)) { + if (ORC_PTR_TO_INT(ex->arrays[insn->src_args[k]]) & (var->size - 1)) { ORC_ERROR("Unaligned array for dest%d, program %s", (insn->src_args[k]-ORC_VAR_D1), ex->program->name); } @@ -321,7 +321,7 @@ orc_executor_emulate (OrcExecutor *ex) opcode_ex[j].dest_ptrs[k] = &ex->accumulators[insn->dest_args[k] - ORC_VAR_A1]; } else if (var->vartype == ORC_VAR_TYPE_DEST) { - if (((unsigned long)ex->arrays[insn->dest_args[k]]) & (var->size - 1)) { + if (ORC_PTR_TO_INT(ex->arrays[insn->dest_args[k]]) & (var->size - 1)) { ORC_ERROR("Unaligned array for dest%d, program %s", (insn->dest_args[k]-ORC_VAR_D1), ex->program->name); } diff --git a/orc/orcprogram.h b/orc/orcprogram.h index 3d1bbe7..f106ca1 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -50,9 +50,6 @@ typedef void (*OrcExecutorFunc)(OrcExecutor *ex); #define ORC_MAX_VAR_SIZE 8 -#define ORC_STRUCT_OFFSET(struct_type, member) \ - ((long) ((unsigned int *) &((struct_type*) 0)->member)) - #ifndef TRUE #define TRUE 1 #endif diff --git a/orc/orcrules-neon.c b/orc/orcrules-neon.c index 57e78ea..ce69144 100644 --- a/orc/orcrules-neon.c +++ b/orc/orcrules-neon.c @@ -1456,7 +1456,7 @@ ShiftInfo regshift_info[] = { static void orc_neon_rule_shift (OrcCompiler *p, void *user, OrcInstruction *insn) { - int type = (unsigned long)user; + int type = ORC_PTR_TO_INT(user); orc_uint32 code; if (p->vars[insn->src_args[1]].vartype == ORC_VAR_TYPE_CONST) { @@ -1602,7 +1602,7 @@ orc_neon_rule_shrsl (OrcCompiler *p, void *user, OrcInstruction *insn) static void orc_neon_rule_andn (OrcCompiler *p, void *user, OrcInstruction *insn) { - int max_shift = (long)user; + int max_shift = ORC_PTR_TO_INT(user); /* this is special because the operand order is reversed */ if (p->insn_shift <= max_shift) { \ diff --git a/orc/orcutils.h b/orc/orcutils.h index 750f80a..f627f1b 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -30,7 +30,7 @@ #ifndef _ORC_INTEGER_TYPEDEFS_ #define _ORC_INTEGER_TYPEDEFS_ -#if defined(_x_STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L +#if defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L #include typedef int8_t orc_int8; typedef int16_t orc_int16; @@ -40,6 +40,7 @@ typedef uint8_t orc_uint8; typedef uint16_t orc_uint16; typedef uint32_t orc_uint32; typedef uint64_t orc_uint64; +typedef intptr_t orc_intptr; #define ORC_UINT64_C(x) UINT64_C(x) #elif defined(_MSC_VER) typedef signed __int8 orc_int8; @@ -50,6 +51,11 @@ typedef unsigned __int8 orc_uint8; typedef unsigned __int16 orc_uint16; typedef unsigned __int32 orc_uint32; typedef unsigned __int64 orc_uint64; +#ifdef _WIN64 +typedef unsigned __int64 orc_intptr; +#else +typedef unsigned long orc_intptr; +#endif #define ORC_UINT64_C(x) (x##Ui64) #else #include @@ -68,6 +74,11 @@ typedef long orc_int64; typedef unsigned long orc_uint64; #define ORC_UINT64_C(x) (x##UL) #endif +#ifdef _WIN64 +typedef unsigned __int64 orc_intptr; +#else +typedef unsigned long orc_intptr; +#endif #endif typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16; typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32; @@ -83,6 +94,11 @@ typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 typedef unsigned int orc_bool; +#define ORC_PTR_TO_INT(x) ((int)(orc_intptr)(x)) +#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) +#define ORC_STRUCT_OFFSET(struct_type, member) \ + (ORC_PTR_TO_INT((unsigned char *) &((struct_type*) 0)->member)) + #ifdef ORC_ENABLE_UNSTABLE_API #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) @@ -95,8 +111,6 @@ typedef unsigned int orc_bool; #ifndef ORC_CLAMP #define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x))) #endif -#define ORC_PTR_TO_INT(x) ((int)(long)(x)) -#define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset))) #define ORC_READ_UINT32_LE(ptr) \ ((orc_uint32)( \ diff --git a/testsuite/abi.c b/testsuite/abi.c index 553c8fa..4bf9d01 100644 --- a/testsuite/abi.c +++ b/testsuite/abi.c @@ -14,7 +14,7 @@ int main (int argc, char *argv[]) int expected_offset; int error = 0; - offset = ((long) ((unsigned char *) &((OrcProgram*) 0)->code_exec)); + offset = ORC_STRUCT_OFFSET (OrcProgram, code_exec); if (sizeof(void *) == 4) { expected_offset = 8360; diff --git a/testsuite/memcpy_speed.c b/testsuite/memcpy_speed.c index cb33925..13a41b0 100644 --- a/testsuite/memcpy_speed.c +++ b/testsuite/memcpy_speed.c @@ -11,7 +11,7 @@ #include -#define ALIGN(ptr,n) ((void *)((unsigned long)(ptr) & (~(unsigned long)(n-1)))) +#define ALIGN(ptr,n) ((void *)((orc_intptr)(ptr) & (~(orc_intptr)(n-1)))) int hot_src = TRUE; int hot_dest = TRUE;