First set of licensing changes
[mono.git] / mono / utils / mono-hwcap-s390x.c
index baf70bc9295a5e2c713a4f4b4af7be01d61648a2..19a7fba11017251a55864c39a93fa94ff5b5b2de 100644 (file)
  * Copyright 2006 Broadcom
  * Copyright 2007-2008 Andreas Faerber
  * Copyright 2011-2013 Xamarin Inc
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include "mono/utils/mono-hwcap-s390x.h"
-
 #include <signal.h>
 
-gboolean mono_hwcap_s390x_has_ld = FALSE;
+facilityList_t facs;
 
-static void
-catch_sigill (int sig_no, siginfo_t *info, gpointer act)
+void
+mono_hwcap_arch_init (void)
 {
-       mono_hwcap_s390x_has_ld = FALSE;
+       int lFacs = sizeof(facs) / 8;
+
+       __asm__ ("      lgfr    0,%1\n"
+                "      .insn   s,0xb2b00000,%0\n"
+                : "=m" (facs) : "r" (lFacs) : "0", "cc");
 }
 
 void
-mono_hwcap_init (void)
+mono_hwcap_print (FILE *f)
 {
-       mono_hwcap_s390x_has_ld = TRUE;
-
-       struct sigaction sa, *old_sa;
-
-       /* Determine if we have a long displacement facility
-        * by executing the STY instruction. If it fails, we
-        * catch the SIGILL and assume the answer is no.
-        */
-       sa.sa_sigaction = catch_sigill;
-       sigemptyset (&sa.sa_mask);
-       sa.sa_flags = SA_SIGINFO;
-
-       sigaction (SIGILL, &sa, old_sa);
-
-       __asm__ (
-               "LGHI\t0,1\n\t"
-               "LA\t1,%0\n\t"
-               ".byte\t0xe3,0x00,0x10,0x00,0x00,0x50\n\t"
-               : "=m" (mono_hwcap_s390x_has_ld)
-               :
-               : "0", "1"
-       );
-
-       sigaction (SIGILL, old_sa, NULL);
 }