Merge pull request #587 from madewokherd/gdipdllmap
[mono.git] / mono / utils / mono-hwcap-sparc.c
1 /*
2  * mono-hwcap-sparc.c: SPARC 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 "mono/utils/mono-hwcap-sparc.h"
22
23 #include <string.h>
24
25 #if !defined(__linux__)
26 #include <sys/systeminfo.h>
27 #else
28 #include <unistd.h>
29 #endif
30
31 gboolean mono_hwcap_sparc_is_v9 = FALSE;
32
33 #if defined(MONO_CROSS_COMPILE)
34 void
35 mono_hwcap_arch_init (void)
36 {
37 }
38 #else
39 void
40 mono_hwcap_arch_init (void)
41 {
42         char buf [1024];
43
44 #if !defined(__linux__)
45         if (!sysinfo (SI_ISALIST, buf, 1024))
46                 g_assert_not_reached ();
47 #else
48         /* If the page size is 8192, we're on a 64-bit SPARC, which
49          * in turn means a v9 or better.
50          */
51         if (getpagesize () == 8192)
52                 strcpy (buf, "sparcv9");
53         else
54                 strcpy (buf, "sparcv8");
55 #endif
56
57         mono_hwcap_sparc_is_v9 = strstr (buf, "sparcv9");
58 }
59 #endif
60
61 void
62 mono_hwcap_print (FILE *f)
63 {
64         g_fprintf (f, "mono_hwcap_sparc_is_v9 = %i\n", mono_hwcap_sparc_is_v9);
65 }