Merge pull request #3528 from BrzVlad/fix-sgen-check-before-collections
[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  * Licensed under the MIT license. See LICENSE file in the project root for full license information.
20  */
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "mono/utils/mono-hwcap.h"
26
27 #define MONO_HWCAP_VAR(NAME) gboolean mono_hwcap_ ## NAME = FALSE;
28 #include "mono/utils/mono-hwcap-vars.h"
29 #undef MONO_HWCAP_VAR
30
31 static gboolean hwcap_inited = FALSE;
32
33 void
34 mono_hwcap_init (void)
35 {
36         const char *verbose = g_getenv ("MONO_VERBOSE_HWCAP");
37         const char *conservative = g_getenv ("MONO_CONSERVATIVE_HWCAP");
38
39         if (hwcap_inited)
40                 return;
41
42         if (!conservative || strncmp (conservative, "1", 1))
43                 mono_hwcap_arch_init ();
44
45         if (verbose && !strncmp (verbose, "1", 1))
46                 mono_hwcap_print ();
47 }
48
49 void
50 mono_hwcap_print (void)
51 {
52         g_print ("[mono-hwcap] Detected following hardware capabilities:\n\n");
53
54 #define MONO_HWCAP_VAR(NAME) g_print ("\t" #NAME " = %s\n", mono_hwcap_ ## NAME ? "yes" : "no");
55 #include "mono/utils/mono-hwcap-vars.h"
56 #undef MONO_HWCAP_VAR
57
58         g_print ("\n");
59 }