]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix mingw64 build by using intptr_t for int->void* casts
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 4 Sep 2012 10:16:55 +0000 (11:16 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Tue, 4 Sep 2012 10:16:55 +0000 (11:16 +0100)
The viratomictest.c was casting from an int to a void* via a
long. This works on Linux or Mingw32, but fails on Mingw64
due to a pointer/integer size mis-match. Replacing 'long'
with 'intptr_t' ensures matching type sizes

tests/viratomictest.c

index 4250329917f0ddc2c6ad95ff8d9751426ecf4e63..4b367026d00f4a07858db5ad22e7d475b756f33e 100644 (file)
@@ -114,7 +114,7 @@ volatile int atomic;
 static void
 thread_func(void *data)
 {
-    int idx = (int)(long)data;
+    int idx = (intptr_t)data;
     int i;
     int d;
 
@@ -142,7 +142,7 @@ testThreads(const void *data ATTRIBUTE_UNUSED)
         bucket[i] = 0;
 
     for (i = 0; i < THREADS; i++) {
-        if (virThreadCreate(&(threads[i]), true, thread_func, (void*)(long)i) < 0)
+        if (virThreadCreate(&(threads[i]), true, thread_func, (void*)(intptr_t)i) < 0)
             return -1;
     }