Build fixes for win64
authorDavid Schleef <ds@schleef.org>
Thu, 23 Dec 2010 07:47:39 +0000 (23:47 -0800)
committerDavid Schleef <ds@schleef.org>
Thu, 23 Dec 2010 07:47:39 +0000 (23:47 -0800)
orc/orcexecutor.c
orc/orcprogram.h
orc/orcrules-neon.c
orc/orcutils.h
testsuite/abi.c
testsuite/memcpy_speed.c

index 46c0517..6e2b76a 100644 (file)
@@ -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);
         }
index 3d1bbe7..f106ca1 100644 (file)
@@ -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
index 57e78ea..ce69144 100644 (file)
@@ -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) { \
index 750f80a..f627f1b 100644 (file)
@@ -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 <stdint.h>
 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 <limits.h>
@@ -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)( \
index 553c8fa..4bf9d01 100644 (file)
@@ -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;
index cb33925..13a41b0 100644 (file)
@@ -11,7 +11,7 @@
 #include <orc-test/orcprofile.h>
 
 
-#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;