[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] PATCH: compile with 64-bit Visual Studio 2008



Hi,

the attached patch allows building pygame 1.9.1 with the 64-bit Visual Studio 2008 compiler, given that _NO_MMX_FOR_X86_64 is defined and all dependencies are also compiled with VS2008. All pygame tests pass.

Christoph
Index: src/scale.h
===================================================================
--- src/scale.h	(revision 2652)
+++ src/scale.h	(working copy)
@@ -29,7 +29,8 @@
 #if !defined(SCALE_HEADER)
 #define SCALE_HEADER
 
-#if (defined(__GNUC__) && ((defined(__x86_64__) && !defined(_NO_MMX_FOR_X86_64)) || defined(__i386__))) || defined(MS_WIN32)
+
+#if (defined(__GNUC__) && ((defined(__x86_64__) && !defined(_NO_MMX_FOR_X86_64)) || defined(__i386__))) || (defined(MS_WIN32) && !(defined(_M_X64) && defined(_NO_MMX_FOR_X86_64)))
 #define SCALE_MMX_SUPPORT
 
 /* These functions implement an area-averaging shrinking filter in the X-dimension.
Index: src/SDL_gfx/SDL_gfxPrimitives.c
===================================================================
--- src/SDL_gfx/SDL_gfxPrimitives.c	(revision 2652)
+++ src/SDL_gfx/SDL_gfxPrimitives.c	(working copy)
@@ -3028,7 +3028,12 @@
 /* sweetlilmre: added hack to detect MinGW and avoid function */
 
 #if defined(_WIN32) && !defined(__MINGW_H) && !defined(__SYMBIAN32__)
-
+#ifdef _M_X64
+#include <emmintrin.h>
+static __inline long lrint(float f) {
+    return _mm_cvtss_si32(_mm_load_ss(&f)); 
+}
+#else
 __inline long int
 lrint (double flt)
 {	
@@ -3040,8 +3045,8 @@
   };
   return intgr;
 }
-
 #endif
+#endif
 
 /* Based on code from Anders Lindstroem, based on code from SGE, based on code from TwinLib */
 
Index: setup.py
===================================================================
--- setup.py	(revision 2652)
+++ setup.py	(working copy)
@@ -366,7 +366,9 @@
                     if e.sources[i].endswith('scale_mmx.c'):
                         del e.sources[i]
                         return
-    replace_scale_mmx()
+    # linking to 64-bit mingw generated scale_mmx.obj fails
+    if not '64 bit' in sys.version:
+        replace_scale_mmx()
 
 
 #clean up the list of extensions