Removed DeflateStream.UnmanagedRead Read loop. Fixes #19313.
[mono.git] / mono / utils / mono-hwcap-s390x.c
1 /*
2  * mono-hwcap-s390x.c: S/390x 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-s390x.h"
22
23 #include <signal.h>
24
25 gboolean mono_hwcap_s390x_has_ld = FALSE;
26
27 static void
28 catch_sigill (int sig_no, siginfo_t *info, gpointer act)
29 {
30         mono_hwcap_s390x_has_ld = FALSE;
31 }
32
33 void
34 mono_hwcap_arch_init (void)
35 {
36         mono_hwcap_s390x_has_ld = TRUE;
37
38         struct sigaction sa, *old_sa;
39
40         /* Determine if we have a long displacement facility
41          * by executing the STY instruction. If it fails, we
42          * catch the SIGILL and assume the answer is no.
43          */
44         sa.sa_sigaction = catch_sigill;
45         sigemptyset (&sa.sa_mask);
46         sa.sa_flags = SA_SIGINFO;
47
48         sigaction (SIGILL, &sa, old_sa);
49
50         __asm__ __volatile__ (
51                 "LGHI\t0,1\n\t"
52                 "LA\t1,%0\n\t"
53                 ".byte\t0xe3,0x00,0x10,0x00,0x00,0x50\n\t"
54                 : "=m" (mono_hwcap_s390x_has_ld)
55                 :
56                 : "0", "1"
57         );
58
59         sigaction (SIGILL, old_sa, NULL);
60 }
61
62 void
63 mono_hwcap_print (FILE *f)
64 {
65         g_fprintf (f, "mono_hwcap_s390x_has_ld = %i\n", mono_hwcap_s390x_has_ld);
66 }