Merge pull request #4621 from alexanderkyte/strdup_env
[mono.git] / mono / utils / mono-hwcap.c
index 38c032696bb3052623064683ec599073fe63b2c6..c0e68ee034fffc8368b0ce06660a2f9ae4eadcd6 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * mono-hwcap.c: Hardware feature detection
+/**
+ * \file
+ * Hardware feature detection
  *
  * Authors:
  *    Alex Rønne Petersen (alexrp@xamarin.com)
@@ -16,6 +17,7 @@
  * Copyright 2006 Broadcom
  * Copyright 2007-2008 Andreas Faerber
  * Copyright 2011-2013 Xamarin Inc
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <stdlib.h>
 
 #include "mono/utils/mono-hwcap.h"
 
+#define MONO_HWCAP_VAR(NAME) gboolean mono_hwcap_ ## NAME = FALSE;
+#include "mono/utils/mono-hwcap-vars.h"
+#undef MONO_HWCAP_VAR
+
 static gboolean hwcap_inited = FALSE;
 
 void
 mono_hwcap_init (void)
 {
-       const char *verbose = g_getenv ("MONO_VERBOSE_HWCAP");
-       const char *conservative = g_getenv ("MONO_CONSERVATIVE_HWCAP");
+       char *verbose = g_getenv ("MONO_VERBOSE_HWCAP");
+       char *conservative = g_getenv ("MONO_CONSERVATIVE_HWCAP");
 
        if (hwcap_inited)
                return;
 
-#ifdef MONO_CROSS_COMPILE
-       /*
-        * If we're cross-compiling, we want to be as
-        * conservative as possible so that we produce
-        * code that's portable. Default to that.
-        */
-       if (!conservative)
-               conservative = "1";
-#endif
-
        if (!conservative || strncmp (conservative, "1", 1))
                mono_hwcap_arch_init ();
 
        if (verbose && !strncmp (verbose, "1", 1))
-               mono_hwcap_print (stdout);
+               mono_hwcap_print ();
+
+       g_free (verbose);
+       g_free (conservative);
+}
+
+void
+mono_hwcap_print (void)
+{
+       g_print ("[mono-hwcap] Detected following hardware capabilities:\n\n");
+
+#define MONO_HWCAP_VAR(NAME) g_print ("\t" #NAME " = %s\n", mono_hwcap_ ## NAME ? "yes" : "no");
+#include "mono/utils/mono-hwcap-vars.h"
+#undef MONO_HWCAP_VAR
+
+       g_print ("\n");
 }