summaryrefslogtreecommitdiff
path: root/mono/utils/mono-hwcap-sparc.c
blob: 87bf9ca899e7c8462bcbca353e73a060e294dcf4 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * mono-hwcap-sparc.c: SPARC 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 "mono/utils/mono-hwcap-sparc.h"

#include <string.h>

#if !defined(__linux__)
#include <sys/systeminfo.h>
#else
#include <unistd.h>
#endif

gboolean mono_hwcap_sparc_is_v9 = FALSE;

#if defined(MONO_CROSS_COMPILE)
void
mono_hwcap_arch_init (void)
{
}
#else
void
mono_hwcap_arch_init (void)
{
	char buf [1024];

#if !defined(__linux__)
	if (!sysinfo (SI_ISALIST, buf, 1024))
		g_assert_not_reached ();
#else
	/* If the page size is 8192, we're on a 64-bit SPARC, which
	 * in turn means a v9 or better.
	 */
	if (getpagesize () == 8192)
		strcpy (buf, "sparcv9")
	else
		strcpy (buf, "sparcv8")
#endif

	mono_hwcap_sparc_is_v9 = strstr (buf, "sparcv9");
}
#endif

void
mono_hwcap_print (FILE *f)
{
	g_fprintf (f, "mono_hwcap_sparc_is_v9 = %i\n", mono_hwcap_sparc_is_v9);
}