This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libgfortran] fix for i386-darwin


Hi all,

I plan to commit the following fix after a bootstrap, unless someone
objects. This should hopefully allow gfortran to run fine on
i386-darwin.

Just a quick question: I didn't find a __DARWIN__ builtin by grepping
the gcc source, but only __APPLE__ (defined in darwin-c.c). Historical
reasons?

FX


Index: libgfortran/config/fpu-387.h
===================================================================
--- libgfortran/config/fpu-387.h        (revision 112542)
+++ libgfortran/config/fpu-387.h        (working copy)
@@ -93,6 +93,17 @@
       /* SSE */
       asm volatile ("stmxcsr %0" : "=m" (cw_sse));
       cw_sse &= 0xFFFF0000;
+#ifdef __APPLE__
+      cw_sse |= (_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM | _FPU_MASK_OM
+                | _FPU_MASK_UM | _FPU_MASK_PM ) << 7;
+      if (options.fpe & GFC_FPE_INVALID) cw_sse &= ~(_FPU_MASK_IM << 7);
+      if (options.fpe & GFC_FPE_DENORMAL) cw_sse &= ~(_FPU_MASK_DM << 7);
+      if (options.fpe & GFC_FPE_ZERO) cw_sse &= ~(_FPU_MASK_ZM << 7);
+      if (options.fpe & GFC_FPE_OVERFLOW) cw_sse &= ~(_FPU_MASK_OM << 7);
+      if (options.fpe & GFC_FPE_UNDERFLOW) cw_sse &= ~(_FPU_MASK_UM << 7);
+      if (options.fpe & GFC_FPE_PRECISION) cw_sse &= ~(_FPU_MASK_PM << 7);
+      asm volatile ("ldmxcsr %0" : : "m" (cw_sse));
+#else
       if (options.fpe & GFC_FPE_INVALID) cw_sse |= 1 << 7;
       if (options.fpe & GFC_FPE_DENORMAL) cw_sse |= 1 << 8;
       if (options.fpe & GFC_FPE_ZERO) cw_sse |= 1 << 9;
@@ -100,5 +111,6 @@
       if (options.fpe & GFC_FPE_UNDERFLOW) cw_sse |= 1 << 11;
       if (options.fpe & GFC_FPE_PRECISION) cw_sse |= 1 << 12;
       asm volatile ("ldmxcsr %0" : : "m" (cw_sse));
+#endif
     }
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]