[MLton-commit] r6694

Wesley Terpstra wesley at mlton.org
Fri Aug 8 05:13:11 PDT 2008


The old HAS_FEROUND ifdef could keep defines from system headers which are
incompatible with the runtime's implementation of feset/getround.


----------------------------------------------------------------------

U   mlton/trunk/runtime/platform.h

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/platform.h
===================================================================
--- mlton/trunk/runtime/platform.h	2008-08-08 12:00:51 UTC (rev 6693)
+++ mlton/trunk/runtime/platform.h	2008-08-08 12:13:09 UTC (rev 6694)
@@ -67,6 +67,13 @@
 #define SPAWN_MODE 0
 #endif
 
+
+/* Because HAS_FPCLASSIFY is unset, the runtime will provide it's own
+ * implementation. It doesn't matter much what the values are, because
+ * the runtime doesn't depend on the bit representation; it just returns
+ * these values. Therefore, prefer to keep the system's own values, but
+ * if they don't exist, setup our own.
+ */
 #if not HAS_FPCLASSIFY
 #ifndef FP_INFINITE
 #define FP_INFINITE 1
@@ -87,29 +94,31 @@
 
 #define FE_NOSUPPORT -1
 
-/* Can't handle undefined rounding modes with code like the following.
- *  #ifndef FE_TONEAREST
- *  #define FE_TONEAREST FE_NOSUPPORT
- *  #endif
- * On some platforms, FE_* are defined via an enum, not the
- * preprocessor, and hence don't show up as #defined.  In that case,
- * the below code overwrites them.
+/* With HAS_FEROUND unset, the runtime will provide the implementation.
+ * That implementation depends on FE_* having the values we set below.
+ * We must therefore make sure to eliminate any existing #defines and
+ * then create our own defines, which will also take precedence over
+ * any enums we included from system headers.
  */
 
 #if not HAS_FEROUND
-#ifndef FE_TONEAREST
+#ifdef FE_TONEAREST
+#undef FE_TONEAREST
+#endif
+#ifdef FE_DOWNWARD
+#undef FE_DOWNWARD
+#endif
+#ifdef FE_UPWARD
+#undef FE_UPWARD
+#endif
+#ifdef FE_TOWARDZERO
+#undef FE_TOWARDZERO
+#endif
 #define FE_TONEAREST 0
-#endif
-#ifndef FE_DOWNWARD
 #define FE_DOWNWARD 1
-#endif
-#ifndef FE_UPWARD
 #define FE_UPWARD 2
-#endif
-#ifndef FE_TOWARDZERO
 #define FE_TOWARDZERO 3
 #endif
-#endif
 
 #ifndef MLTON_CODEGEN_STATIC_INLINE
 #define MLTON_CODEGEN_STATIC_INLINE /*static inline*/




More information about the MLton-commit mailing list