Commit 80e2b5a749208c8a18f994ec5bee84594d051cc8

twall 2008-12-22T15:21:15

clean up tests for win64 use

diff --git a/libffi/ChangeLog.libffi b/libffi/ChangeLog.libffi
index cdc9115..0b9fa59 100644
--- a/libffi/ChangeLog.libffi
+++ b/libffi/ChangeLog.libffi
@@ -1,3 +1,20 @@
+2008-12-22  Timothy Wall  <twall@users.sf.net>
+
+	* testsuite/libffi.call/closure_fn0.c,
+        testsuite/libffi.call/closure_fn1.c,    
+        testsuite/libffi.call/closure_fn2.c,    
+        testsuite/libffi.call/closure_fn3.c,    
+        testsuite/libffi.call/closure_fn4.c,    
+        testsuite/libffi.call/closure_fn5.c,    
+        testsuite/libffi.call/closure_fn6.c,    
+        testsuite/libffi.call/closure_loc_fn0.c,    
+        testsuite/libffi.call/closure_stdcall.c,    
+        testsuite/libffi.call/cls_align_pointer.c,    
+        testsuite/libffi.call/cls_pointer.c,    
+        testsuite/libffi.call/cls_pointer_stack.c: use portable cast from
+        pointer to integer (intptr_t).
+        * testsuite/libffi.call/cls_longdouble.c: disable for win64.
+	
 2008-12-19  Anthony Green  <green@redhat.com>
 
 	* configure.ac: Bump version to 3.0.8.
diff --git a/libffi/testsuite/libffi.call/closure_fn0.c b/libffi/testsuite/libffi.call/closure_fn0.c
index e487527..b42fc20 100644
--- a/libffi/testsuite/libffi.call/closure_fn0.c
+++ b/libffi/testsuite/libffi.call/closure_fn0.c
@@ -25,7 +25,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)(*(double *)args[8]) + (int)*(int *)args[9] +
     (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
     (int)*(int *)args[12] + (int)(*(int *)args[13]) +
-    (int)(*(int *)args[14]) +  *(int *)args[15] + (int)(long)userdata;
+    (int)(*(int *)args[14]) +  *(int *)args[15] + (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
@@ -37,7 +37,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)(*(int *)args[10]), (int)(*(float *)args[11]),
 	 (int)*(int *)args[12], (int)(*(int *)args[13]),
 	 (int)(*(int *)args[14]),*(int *)args[15],
-	 (int)(long)userdata, (int)*(ffi_arg *)resp);
+	 (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
 
 }
 
diff --git a/libffi/testsuite/libffi.call/closure_fn1.c b/libffi/testsuite/libffi.call/closure_fn1.c
index db26c42..82b9b1d 100644
--- a/libffi/testsuite/libffi.call/closure_fn1.c
+++ b/libffi/testsuite/libffi.call/closure_fn1.c
@@ -21,7 +21,7 @@ static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)(*(double*)args[8]) + (int)*(int *)args[9] +
     (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
     (int)*(int *)args[12] + (int)(*(int *)args[13]) +
-    (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
+    (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(float *)args[0], (int)(*(float *)args[1]),
@@ -32,7 +32,7 @@ static void closure_test_fn1(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)(*(int *)args[10]), (int)(*(float *)args[11]),
 	 (int)*(int *)args[12], (int)(*(int *)args[13]),
 	 (int)(*(int *)args[14]), *(int *)args[15],
-	 (int)(long)userdata, (int)*(ffi_arg *)resp);
+	 (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
 }
 
 typedef int (*closure_test_type1)(float, float, float, float, signed short,
diff --git a/libffi/testsuite/libffi.call/closure_fn2.c b/libffi/testsuite/libffi.call/closure_fn2.c
index cbf7385..d0ba48e 100644
--- a/libffi/testsuite/libffi.call/closure_fn2.c
+++ b/libffi/testsuite/libffi.call/closure_fn2.c
@@ -20,7 +20,7 @@ static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)(*(double *)args[8]) + (int)*(int *)args[9] +
     (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
     (int)*(int *)args[12] + (int)(*(float *)args[13]) +
-    (int)(*(int *)args[14]) + *(int *)args[15] + (int)(long)userdata;
+    (int)(*(int *)args[14]) + *(int *)args[15] + (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(double *)args[0], (int)(*(double *)args[1]),
@@ -30,7 +30,7 @@ static void closure_test_fn2(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)(*(double*)args[8]), (int)*(int *)args[9],
 	 (int)(*(int *)args[10]), (int)(*(float *)args[11]),
 	 (int)*(int *)args[12], (int)(*(float *)args[13]),
-	 (int)(*(int *)args[14]), *(int *)args[15], (int)(long)userdata,
+	 (int)(*(int *)args[14]), *(int *)args[15], (int)(intptr_t)userdata,
 	 (int)*(ffi_arg *)resp);
 }
 
diff --git a/libffi/testsuite/libffi.call/closure_fn3.c b/libffi/testsuite/libffi.call/closure_fn3.c
index 1fb32a8..be4062d 100644
--- a/libffi/testsuite/libffi.call/closure_fn3.c
+++ b/libffi/testsuite/libffi.call/closure_fn3.c
@@ -20,7 +20,7 @@ static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args,
      (int)(*(double *)args[8]) + (int)*(int *)args[9] +
      (int)(*(float *)args[10]) + (int)(*(float *)args[11]) +
      (int)*(int *)args[12] + (int)(*(float *)args[13]) +
-     (int)(*(float *)args[14]) +  *(int *)args[15] + (int)(long)userdata;
+     (int)(*(float *)args[14]) +  *(int *)args[15] + (intptr_t)userdata;
 
    printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	  (int)*(float *)args[0], (int)(*(float *)args[1]),
@@ -30,7 +30,7 @@ static void closure_test_fn3(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	  (int)(*(double *)args[8]), (int)*(int *)args[9],
 	  (int)(*(float *)args[10]), (int)(*(float *)args[11]),
 	  (int)*(int *)args[12], (int)(*(float *)args[13]),
-	  (int)(*(float *)args[14]), *(int *)args[15], (int)(long)userdata,
+	  (int)(*(float *)args[14]), *(int *)args[15], (int)(intptr_t)userdata,
 	  (int)*(ffi_arg *)resp);
 
  }
diff --git a/libffi/testsuite/libffi.call/closure_fn4.c b/libffi/testsuite/libffi.call/closure_fn4.c
index 74506f3..9a70b99 100644
--- a/libffi/testsuite/libffi.call/closure_fn4.c
+++ b/libffi/testsuite/libffi.call/closure_fn4.c
@@ -25,7 +25,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)*(unsigned long long *)args[12] +
     (int)*(unsigned long long *)args[13] +
     (int)*(unsigned long long *)args[14] +
-    *(int *)args[15] + (int)(long)userdata;
+    *(int *)args[15] + (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(unsigned long long *)args[0],
@@ -44,7 +44,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)*(unsigned long long *)args[13],
 	 (int)*(unsigned long long *)args[14],
 	 *(int *)args[15],
-	 (int)(long)userdata, (int)*(ffi_arg *)resp);
+	 (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
 
 }
 
diff --git a/libffi/testsuite/libffi.call/closure_fn5.c b/libffi/testsuite/libffi.call/closure_fn5.c
index c64ee8d..c12491e 100644
--- a/libffi/testsuite/libffi.call/closure_fn5.c
+++ b/libffi/testsuite/libffi.call/closure_fn5.c
@@ -24,7 +24,7 @@ closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)*(unsigned long long *)args[12] +
     (int)*(unsigned long long *)args[13] +
     (int)*(unsigned long long *)args[14] +
-    *(int *)args[15] + (int)(long)userdata;
+    *(int *)args[15] + (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(unsigned long long *)args[0],
@@ -43,7 +43,7 @@ closure_test_fn5(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)*(unsigned long long *)args[13],
 	 (int)*(unsigned long long *)args[14],
 	 *(int *)args[15],
-	 (int)(long)userdata, (int)*(ffi_arg *)resp);
+	 (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
 
 }
 
diff --git a/libffi/testsuite/libffi.call/closure_fn6.c b/libffi/testsuite/libffi.call/closure_fn6.c
index 16c52fd..5d9389d 100644
--- a/libffi/testsuite/libffi.call/closure_fn6.c
+++ b/libffi/testsuite/libffi.call/closure_fn6.c
@@ -23,7 +23,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
     (int)*(int *)args[12] + (int)(*(int *)args[13]) +
     (int)(*(double *)args[14]) +  (int)*(double *)args[15] +
-    (int)(long)userdata;
+    (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(unsigned long long  *)args[0],
@@ -36,7 +36,7 @@ closure_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)(*(int *)args[10]), (int)(*(float *)args[11]),
 	 (int)*(int *)args[12], (int)(*(int *)args[13]),
 	 (int)(*(double *)args[14]), (int)(*(double *)args[15]),
-	 (int)(long)userdata, (int)*(ffi_arg *)resp);
+	 (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
 
 }
 
diff --git a/libffi/testsuite/libffi.call/closure_loc_fn0.c b/libffi/testsuite/libffi.call/closure_loc_fn0.c
index 43f28e4..b3afa0b 100644
--- a/libffi/testsuite/libffi.call/closure_loc_fn0.c
+++ b/libffi/testsuite/libffi.call/closure_loc_fn0.c
@@ -25,7 +25,7 @@ closure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
     (int)(*(double *)args[8]) + (int)*(int *)args[9] +
     (int)(*(int *)args[10]) + (int)(*(float *)args[11]) +
     (int)*(int *)args[12] + (int)(*(int *)args[13]) +
-    (int)(*(int *)args[14]) +  *(int *)args[15] + (int)(long)userdata;
+    (int)(*(int *)args[14]) +  *(int *)args[15] + (intptr_t)userdata;
 
   printf("%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d: %d\n",
 	 (int)*(unsigned long long *)args[0], (int)(*(int *)args[1]),
@@ -37,7 +37,7 @@ closure_loc_test_fn0(ffi_cif* cif __UNUSED__, void* resp, void** args,
 	 (int)(*(int *)args[10]), (int)(*(float *)args[11]),
 	 (int)*(int *)args[12], (int)(*(int *)args[13]),
 	 (int)(*(int *)args[14]),*(int *)args[15],
-	 (int)(long)userdata, (int)*(ffi_arg *)resp);
+	 (int)(intptr_t)userdata, (int)*(ffi_arg *)resp);
 
 }
 
diff --git a/libffi/testsuite/libffi.call/closure_stdcall.c b/libffi/testsuite/libffi.call/closure_stdcall.c
index e80b10b..020b469 100644
--- a/libffi/testsuite/libffi.call/closure_stdcall.c
+++ b/libffi/testsuite/libffi.call/closure_stdcall.c
@@ -14,7 +14,7 @@ closure_test_stdcall(ffi_cif* cif __UNUSED__, void* resp, void** args,
   *(ffi_arg*)resp =
     (int)*(int *)args[0] + (int)(*(int *)args[1])
     + (int)(*(int *)args[2])  + (int)(*(int *)args[3])
-    + (int)(long)userdata;
+    + (int)(intptr_t)userdata;
 
   printf("%d %d %d %d: %d\n",
 	 (int)*(int *)args[0], (int)(*(int *)args[1]),
diff --git a/libffi/testsuite/libffi.call/cls_align_pointer.c b/libffi/testsuite/libffi.call/cls_align_pointer.c
index 441edcb..9a79922 100644
--- a/libffi/testsuite/libffi.call/cls_align_pointer.c
+++ b/libffi/testsuite/libffi.call/cls_align_pointer.c
@@ -19,11 +19,13 @@ cls_struct_align cls_struct_align_fn(struct cls_struct_align a1,
   struct cls_struct_align result;
 
   result.a = a1.a + a2.a;
-  result.b = (void *)((unsigned long)a1.b + (unsigned long)a2.b);
+  result.b = (void *)((uintptr_t)a1.b + (uintptr_t)a2.b);
   result.c = a1.c + a2.c;
 
-  printf("%d %lu %d %d %lu %d: %d %lu %d\n", a1.a, (unsigned long)a1.b, a1.c,
-	 a2.a, (unsigned long)a2.b, a2.c, result.a, (unsigned long)result.b,
+  printf("%d %" PRIuPTR " %d %d %" PRIuPTR " %d: %d %" PRIuPTR " %d\n", 
+         a1.a, (uintptr_t)a1.b, a1.c,
+	 a2.a, (uintptr_t)a2.b, a2.c,
+         result.a, (uintptr_t)result.b,
 	 result.c);
 
   return result;
@@ -87,14 +89,14 @@ int main (void)
 
   ffi_call(&cif, FFI_FN(cls_struct_align_fn), &res_dbl, args_dbl);
   /* { dg-output "12 4951 127 1 9320 13: 13 14271 140" } */
-  printf("res: %d %lu %d\n", res_dbl.a, (unsigned long)res_dbl.b, res_dbl.c);
+  printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c);
   /* { dg-output "\nres: 13 14271 140" } */
 
   CHECK(ffi_prep_closure(pcl, &cif, cls_struct_align_gn, NULL) == FFI_OK);
 
   res_dbl = ((cls_struct_align(*)(cls_struct_align, cls_struct_align))(pcl))(g_dbl, f_dbl);
   /* { dg-output "\n12 4951 127 1 9320 13: 13 14271 140" } */
-  printf("res: %d %lu %d\n", res_dbl.a, (unsigned long)res_dbl.b, res_dbl.c);
+  printf("res: %d %" PRIuPTR " %d\n", res_dbl.a, (uintptr_t)res_dbl.b, res_dbl.c);
   /* { dg-output "\nres: 13 14271 140" } */
 
   exit(0);
diff --git a/libffi/testsuite/libffi.call/cls_longdouble.c b/libffi/testsuite/libffi.call/cls_longdouble.c
index 8d7bd27..8a6643d 100644
--- a/libffi/testsuite/libffi.call/cls_longdouble.c
+++ b/libffi/testsuite/libffi.call/cls_longdouble.c
@@ -4,7 +4,7 @@
    PR:			none.
    Originator:	Blake Chaffin	*/
 
-/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* } } */
+/* { dg-do run { xfail mips*-*-* arm*-*-* strongarm*-*-* xscale*-*-* x86_64-*-mingw x86_64-*-cygwin } } */
 /* { dg-options -mlong-double-128 { target powerpc64*-*-* } } */
 
 #include "ffitest.h"
diff --git a/libffi/testsuite/libffi.call/cls_pointer.c b/libffi/testsuite/libffi.call/cls_pointer.c
index 993b5ca..ffc1f6a 100644
--- a/libffi/testsuite/libffi.call/cls_pointer.c
+++ b/libffi/testsuite/libffi.call/cls_pointer.c
@@ -9,10 +9,12 @@
 
 void* cls_pointer_fn(void* a1, void* a2)
 {
-	void*	result	= (void*)((long)a1 + (long)a2);
+	void*	result	= (void*)((intptr_t)a1 + (intptr_t)a2);
 
 	printf("0x%08x 0x%08x: 0x%08x\n", 
-	       (unsigned int) a1, (unsigned int) a2, (unsigned int) result);
+	       (unsigned int)(uintptr_t) a1,
+               (unsigned int)(uintptr_t) a2,
+               (unsigned int)(uintptr_t) result);
 
 	return result;
 }
diff --git a/libffi/testsuite/libffi.call/cls_pointer_stack.c b/libffi/testsuite/libffi.call/cls_pointer_stack.c
index 2c792b9..c7ab55b 100644
--- a/libffi/testsuite/libffi.call/cls_pointer_stack.c
+++ b/libffi/testsuite/libffi.call/cls_pointer_stack.c
@@ -20,43 +20,48 @@ long dummy_func(
 
 void* cls_pointer_fn2(void* a1, void* a2)
 {
-	long double	trample1	= (long)a1 + (long)a2;
+	long double	trample1	= (intptr_t)a1 + (intptr_t)a2;
 	char		trample2	= ((char*)&a1)[0] + ((char*)&a2)[0];
-	long double	trample3	= (long)trample1 + (long)a1;
+	long double	trample3	= (intptr_t)trample1 + (intptr_t)a1;
 	char		trample4	= trample2 + ((char*)&a1)[1];
-	long double	trample5	= (long)trample3 + (long)a2;
+	long double	trample5	= (intptr_t)trample3 + (intptr_t)a2;
 	char		trample6	= trample4 + ((char*)&a2)[1];
-	long double	trample7	= (long)trample5 + (long)trample1;
+	long double	trample7	= (intptr_t)trample5 + (intptr_t)trample1;
 	char		trample8	= trample6 + trample2;
 
 	dummyVar	= dummy_func(trample1, trample2, trample3, trample4,
 		trample5, trample6, trample7, trample8);
 
-	void*	result	= (void*)((long)a1 + (long)a2);
+	void*	result	= (void*)((intptr_t)a1 + (intptr_t)a2);
 
 	printf("0x%08x 0x%08x: 0x%08x\n", 
-	       (unsigned int) a1, (unsigned int) a2, (unsigned int) result);
+	       (unsigned int)(uintptr_t) a1,
+               (unsigned int)(uintptr_t) a2,
+               (unsigned int)(uintptr_t) result);
 
 	return result;
 }
 
 void* cls_pointer_fn1(void* a1, void* a2)
 {
-	long double	trample1	= (long)a1 + (long)a2;
+	long double	trample1	= (intptr_t)a1 + (intptr_t)a2;
 	char		trample2	= ((char*)&a1)[0] + ((char*)&a2)[0];
-	long double	trample3	= (long)trample1 + (long)a1;
+	long double	trample3	= (intptr_t)trample1 + (intptr_t)a1;
 	char		trample4	= trample2 + ((char*)&a1)[1];
-	long double	trample5	= (long)trample3 + (long)a2;
+	long double	trample5	= (intptr_t)trample3 + (intptr_t)a2;
 	char		trample6	= trample4 + ((char*)&a2)[1];
-	long double	trample7	= (long)trample5 + (long)trample1;
+	long double	trample7	= (intptr_t)trample5 + (intptr_t)trample1;
 	char		trample8	= trample6 + trample2;
 
 	dummyVar	= dummy_func(trample1, trample2, trample3, trample4,
 		trample5, trample6, trample7, trample8);
 
-	void*	result	= (void*)((long)a1 + (long)a2);
+	void*	result	= (void*)((intptr_t)a1 + (intptr_t)a2);
 
-	printf("0x%08x 0x%08x: 0x%08x\n", a1, a2, result);
+	printf("0x%08x 0x%08x: 0x%08x\n",
+               (unsigned int)(intptr_t) a1,
+               (unsigned int)(intptr_t) a2,
+               (unsigned int)(intptr_t) result);
 
 	result	= cls_pointer_fn2(result, a1);
 
@@ -70,13 +75,13 @@ cls_pointer_gn(ffi_cif* cif __UNUSED__, void* resp,
 	void*	a1	= *(void**)(args[0]);
 	void*	a2	= *(void**)(args[1]);
 
-	long double	trample1	= (long)a1 + (long)a2;
+	long double	trample1	= (intptr_t)a1 + (intptr_t)a2;
 	char		trample2	= ((char*)&a1)[0] + ((char*)&a2)[0];
-	long double	trample3	= (long)trample1 + (long)a1;
+	long double	trample3	= (intptr_t)trample1 + (intptr_t)a1;
 	char		trample4	= trample2 + ((char*)&a1)[1];
-	long double	trample5	= (long)trample3 + (long)a2;
+	long double	trample5	= (intptr_t)trample3 + (intptr_t)a2;
 	char		trample6	= trample4 + ((char*)&a2)[1];
-	long double	trample7	= (long)trample5 + (long)trample1;
+	long double	trample7	= (intptr_t)trample5 + (intptr_t)trample1;
 	char		trample8	= trample6 + trample2;
 
 	dummyVar	= dummy_func(trample1, trample2, trample3, trample4,
diff --git a/libffi/testsuite/libffi.call/ffitest.h b/libffi/testsuite/libffi.call/ffitest.h
index e73f758..8a437e4 100644
--- a/libffi/testsuite/libffi.call/ffitest.h
+++ b/libffi/testsuite/libffi.call/ffitest.h
@@ -2,6 +2,8 @@
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
+#include <stdint.h>
+#include <inttypes.h>
 #include <ffi.h>
 #include "fficonfig.h"