[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28966] trunk/blender/source/creator/ creator.c: OSX Intel: Enable floating point exceptions ( for debugging purposes)
Damien Plisson
damien.plisson at yahoo.fr
Mon May 24 22:39:01 CEST 2010
Revision: 28966
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28966
Author: damien78
Date: 2010-05-24 22:39:01 +0200 (Mon, 24 May 2010)
Log Message:
-----------
OSX Intel: Enable floating point exceptions (for debugging purposes)
>From Matt's patch [#22408]
Modified Paths:
--------------
trunk/blender/source/creator/creator.c
Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c 2010-05-24 18:53:45 UTC (rev 28965)
+++ trunk/blender/source/creator/creator.c 2010-05-24 20:39:01 UTC (rev 28966)
@@ -32,6 +32,12 @@
#include <fenv.h>
#endif
+#define OSX_SSE_FPE (defined(__APPLE__) && (defined(__i386__) || defined(__x86_64__)))
+
+#if OSX_SSE_FPE
+#include <xmmintrin.h>
+#endif
+
#include <stdlib.h>
#include <string.h>
@@ -137,7 +143,7 @@
static void setCallbacks(void);
/* on linux set breakpoints here when running in debug mode, useful to catch floating point errors */
-#if defined(__sgi) || defined(__linux__)
+#if defined(__sgi) || defined(__linux__) || OSX_SSE_FPE
static void fpe_handler(int sig)
{
// printf("SIGFPE trapped\n");
@@ -356,15 +362,23 @@
static int set_fpe(int argc, char **argv, void *data)
{
-#if defined(__sgi) || defined(__linux__)
+#if defined(__sgi) || defined(__linux__) || OSX_SSE_FPE
/* zealous but makes float issues a heck of a lot easier to find!
* set breakpoints on fpe_handler */
signal(SIGFPE, fpe_handler);
#if defined(__linux__) && defined(__GNUC__)
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW );
+#else
+#if OSX_SSE_FPE
+ /* OSX uses SSE for floating point by default, so here
+ * use SSE instructions to throw floating point exceptions */
+ _MM_SET_EXCEPTION_MASK(_MM_MASK_MASK &~
+ (_MM_MASK_OVERFLOW|_MM_MASK_INVALID|_MM_MASK_DIV_ZERO));
+#endif /* OSX_SSE_FPE */
+#endif /* defined(__linux__) && defined(__GNUC__) */
#endif
-#endif
+
return 0;
}
@@ -915,7 +929,7 @@
BLI_argsAdd(ba, 1, "-a", NULL, playback_doc, playback_mode, NULL);
BLI_argsAdd(ba, 1, "-d", "--debug", debug_doc, debug_mode, ba);
- BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions (currently linux only)", set_fpe, NULL);
+ BLI_argsAdd(ba, 1, NULL, "--debug-fpe", "\n\tEnable floating point exceptions (currently linux and osx intel only)", set_fpe, NULL);
/* second pass: custom window stuff */
BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL);
More information about the Bf-blender-cvs
mailing list