fix static physfs linking on 32 bit archs 0.9.19
authorraptor
Mon, 03 Jun 2013 23:21:29 +0200
branch0.9.19
changeset 9110 3883b5dc600c
parent 9108 83cc372c05d9
child 9111 f529fba57ba5
fix static physfs linking on 32 bit archs
misc/libphysfs/CMakeLists.txt
misc/libphysfs/physfs_internal.h
--- a/misc/libphysfs/CMakeLists.txt	Mon Jun 03 23:09:06 2013 +0200
+++ b/misc/libphysfs/CMakeLists.txt	Mon Jun 03 23:21:29 2013 +0200
@@ -11,6 +11,11 @@
 # Increment this if/when we break backwards compatibility.
 set(PHYSFS_SOVERSION 1)
 
+# 32bit platforms won't link unless this is set
+if(CMAKE_SIZEOF_VOID_P LESS 8)
+    add_definitions(-DPHYSFS_NO_64BIT_SUPPORT=1)
+endif(CMAKE_SIZEOF_VOID_P LESS 8)
+
 # I hate that they define "WIN32" ... we're about to move to Win64...I hope!
 if(WIN32 AND NOT WINDOWS)
     set(WINDOWS TRUE)
--- a/misc/libphysfs/physfs_internal.h	Mon Jun 03 23:09:06 2013 +0200
+++ b/misc/libphysfs/physfs_internal.h	Mon Jun 03 23:21:29 2013 +0200
@@ -322,8 +322,13 @@
 #define __PHYSFS_ARRAYLEN(x) ( (sizeof (x)) / (sizeof (x[0])) )
 
 #ifdef PHYSFS_NO_64BIT_SUPPORT
-#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x))
-#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x))
+/* if a 32bit compiler sees something with this many bits: 0xFFFFFFFFFFFFFFFF
+ *  it doesn't know if it really means 64bit or if it's supposed to squeeze
+ *  it into 32 bit, so without the ULL it squeezes the number to 32 bit,
+ *  with it it forces it to be 64bits
+ */
+#define __PHYSFS_SI64(x) ((PHYSFS_sint64) (x##LL))
+#define __PHYSFS_UI64(x) ((PHYSFS_uint64) (x##ULL))
 #elif (defined __GNUC__)
 #define __PHYSFS_SI64(x) x##LL
 #define __PHYSFS_UI64(x) x##ULL