[cogl/msvc-support] Bug 650833: Add MSVC/32-bit modff workaround



commit d82c50734b868b5e9931a6400ce9a55f88f6be72
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Tue Jul 19 00:16:36 2011 +0800

    Bug 650833: Add MSVC/32-bit modff workaround
    
    The modff in 32-bit MSVC-compiled platforms seems to have a bug that
    corrupts the stack.  Add a replacement modff as a workaround in 32-bit
    MSVC environments

 cogl/cogl-texture-2d.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/cogl/cogl-texture-2d.c b/cogl/cogl-texture-2d.c
index 71ff44a..d12cb43 100644
--- a/cogl/cogl-texture-2d.c
+++ b/cogl/cogl-texture-2d.c
@@ -48,6 +48,27 @@
 #include <wayland-server.h>
 #endif
 
+#ifdef COGL_HAS_WIN32_SUPPORT
+#ifdef _MSC_VER
+#ifdef _M_IX86
+/* Add a workaround for modff on Visual C++
+   under 32-bit compilation as the default modff
+   has a bug that will corrupt the second parameter
+   passed into it at times, which is evident in
+   _cogl_texture_2d_wrap_coords
+   */
+#ifdef modff
+#undef modff
+#endif
+inline float modff(float x, float * y)
+{
+  *y=((int)x);
+  return (x-*y);
+}
+#endif /* ifdef _M_IX86 */
+#endif /* ifdef _MSC_VER */
+#endif /* ifdef COGL_HAS_WIN32_SUPPORT */
+
 static void _cogl_texture_2d_free (CoglTexture2D *tex_2d);
 
 COGL_TEXTURE_DEFINE (Texture2D, texture_2d);



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