38c032696bb3052623064683ec599073fe63b2c6
[mono.git] / mono / utils / mono-hwcap.c
1 /*
2  * mono-hwcap.c: Hardware feature detection
3  *
4  * Authors:
5  *    Alex Rønne Petersen (alexrp@xamarin.com)
6  *    Elijah Taylor (elijahtaylor@google.com)
7  *    Miguel de Icaza (miguel@xamarin.com)
8  *    Neale Ferguson (Neale.Ferguson@SoftwareAG-usa.com)
9  *    Paolo Molaro (lupus@xamarin.com)
10  *    Rodrigo Kumpera (kumpera@gmail.com)
11  *    Sebastien Pouliot (sebastien@xamarin.com)
12  *    Zoltan Varga (vargaz@xamarin.com)
13  *
14  * Copyright 2003 Ximian, Inc.
15  * Copyright 2003-2011 Novell, Inc
16  * Copyright 2006 Broadcom
17  * Copyright 2007-2008 Andreas Faerber
18  * Copyright 2011-2013 Xamarin Inc
19  */
20
21 #include <stdlib.h>
22 #include <string.h>
23
24 #include "mono/utils/mono-hwcap.h"
25
26 static gboolean hwcap_inited = FALSE;
27
28 void
29 mono_hwcap_init (void)
30 {
31         const char *verbose = g_getenv ("MONO_VERBOSE_HWCAP");
32         const char *conservative = g_getenv ("MONO_CONSERVATIVE_HWCAP");
33
34         if (hwcap_inited)
35                 return;
36
37 #ifdef MONO_CROSS_COMPILE
38         /*
39          * If we're cross-compiling, we want to be as
40          * conservative as possible so that we produce
41          * code that's portable. Default to that.
42          */
43         if (!conservative)
44                 conservative = "1";
45 #endif
46
47         if (!conservative || strncmp (conservative, "1", 1))
48                 mono_hwcap_arch_init ();
49
50         if (verbose && !strncmp (verbose, "1", 1))
51                 mono_hwcap_print (stdout);
52 }