Bump API snapshot submodule
[mono.git] / mono / dis / util.c
old mode 100644 (file)
new mode 100755 (executable)
index 737f6fd..80b6ad4
@@ -1,5 +1,6 @@
-/*
- * util.c: Assorted utilities for the disassembler
+/**
+ * \file
+ * Assorted utilities for the disassembler
  *
  * Author:
  *   Miguel de Icaza (miguel@ximian.com)
 #include <glib.h>
 #include <string.h>
 #include <stdio.h>
+#include <math.h>
 #include "util.h"
+#include "mono/utils/mono-compiler.h"
+
+#ifdef HAVE_IEEEFP_H
+#include <ieeefp.h>
+#endif
 
 /**
- * map:
- * @code: code to lookup in table
- * @table: table to decode code
+ * \param code code to lookup in table
+ * \param table table to decode code
  *
  * Warning: returns static buffer.
  */
@@ -31,9 +37,8 @@ map (guint32 code, dis_map_t *table)
 }
 
 /**
- * flags:
- * @code: bitfield
- * @table: table to decode bitfield
+ * \param code bitfield
+ * \param table table to decode bitfield
  *
  * Warning: returns static buffer.
  */
@@ -122,3 +127,36 @@ data_dump (const char *data, int len, const char* prefix) {
        return g_string_free (str, FALSE);
 }
 
+int
+dis_isinf (double num)
+{
+#ifdef HAVE_ISINF
+       return isinf (num);
+#elif defined(HAVE_IEEEFP_H)
+       fpclass_t klass;
+
+       klass = fpclass (num);
+       if (klass == FP_NINF)
+               return -1;
+
+       if (klass == FP_PINF)
+               return 1;
+
+       return 0;
+#elif defined(HAVE__FINITE)
+       return _finite (num) ? 0 : 1;
+#else
+#error "Don't know how to implement isinf for this platform."
+#endif
+}
+
+int
+dis_isnan (double num)
+{
+#ifdef __MINGW32_VERSION
+return _isnan (num);
+#else
+return isnan (num);
+#endif
+}
+