summaryrefslogtreecommitdiff
path: root/mono/utils/mono-hwcap.c
blob: 38c032696bb3052623064683ec599073fe63b2c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * mono-hwcap.c: Hardware feature detection
 *
 * Authors:
 *    Alex Rønne Petersen (alexrp@xamarin.com)
 *    Elijah Taylor (elijahtaylor@google.com)
 *    Miguel de Icaza (miguel@xamarin.com)
 *    Neale Ferguson (Neale.Ferguson@SoftwareAG-usa.com)
 *    Paolo Molaro (lupus@xamarin.com)
 *    Rodrigo Kumpera (kumpera@gmail.com)
 *    Sebastien Pouliot (sebastien@xamarin.com)
 *    Zoltan Varga (vargaz@xamarin.com)
 *
 * Copyright 2003 Ximian, Inc.
 * Copyright 2003-2011 Novell, Inc
 * Copyright 2006 Broadcom
 * Copyright 2007-2008 Andreas Faerber
 * Copyright 2011-2013 Xamarin Inc
 */

#include <stdlib.h>
#include <string.h>

#include "mono/utils/mono-hwcap.h"

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");

	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);
}