From 33150e7f40f034cbffcb43fba1d560ce162ab3ff Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Sun, 20 Mar 2011 15:34:29 +0000 Subject: [PATCH] * fenv.cc (_feinitialise); Don't use SSE instructions on systems not supporting them. * wincap.h (wincaps::supports_sse): New element. * wincap.cc: Implement above element throughout. --- winsup/cygwin/ChangeLog | 7 +++++++ winsup/cygwin/fenv.cc | 11 +++++++---- winsup/cygwin/wincap.cc | 9 +++++++++ winsup/cygwin/wincap.h | 2 ++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 72ec96da4..9fb90b5ad 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2011-03-20 Corinna Vinschen + + * fenv.cc (_feinitialise); Don't use SSE instructions on systems not + supporting them. + * wincap.h (wincaps::supports_sse): New element. + * wincap.cc: Implement above element throughout. + 2011-03-18 Corinna Vinschen * cygwin.sc: Raise default cygheap size to 2 Megs. diff --git a/winsup/cygwin/fenv.cc b/winsup/cygwin/fenv.cc index 63670f7ab..87466365a 100755 --- a/winsup/cygwin/fenv.cc +++ b/winsup/cygwin/fenv.cc @@ -1,6 +1,6 @@ /* fenv.cc - Copyright 2010 Red Hat, Inc. + Copyright 2010, 2011 Red Hat, Inc. This file is part of Cygwin. @@ -8,9 +8,11 @@ This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for details. */ -#include +#include "winsup.h" #include "fenv.h" #include "errno.h" +#include "wincap.h" +#include /* Mask and shift amount for rounding bits. */ #define FE_CW_ROUND_MASK (0x0c00) @@ -419,8 +421,9 @@ _feinitialise (void) /* Check for presence of SSE: invoke CPUID #1, check EDX bit 25. */ eax = 1; __asm__ volatile ("cpuid" : "=d" (edx), "+a" (eax) :: "%ecx", "%ebx"); - /* If this flag isn't set, we'll avoid trying to execute any SSE. */ - if (edx & (1 << 25)) + /* If this flag isn't set, or if the OS doesn't support SSE (NT4, at least + up to SP4) we'll avoid trying to execute any SSE. */ + if ((edx & (1 << 25)) != 0 && wincap.supports_sse ()) use_sse = true; /* Reset FPU: extended prec, all exceptions cleared and masked off. */ diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index c15372113..ee790eb63 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -63,6 +63,7 @@ wincaps wincap_nt4sp4 __attribute__((section (".cygwin_dll_common"), shared)) = has_restricted_raw_disk_access:false, use_dont_resolve_hack:false, use_get_sec_info_on_dirs:false, + supports_sse:false, }; wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -105,6 +106,7 @@ wincaps wincap_2000 __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:false, use_dont_resolve_hack:false, use_get_sec_info_on_dirs:false, + supports_sse:true, }; wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -147,6 +149,7 @@ wincaps wincap_2000sp4 __attribute__((section (".cygwin_dll_common"), shared)) = has_restricted_raw_disk_access:false, use_dont_resolve_hack:false, use_get_sec_info_on_dirs:false, + supports_sse:true, }; wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -189,6 +192,7 @@ wincaps wincap_xp __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:false, use_dont_resolve_hack:true, use_get_sec_info_on_dirs:true, + supports_sse:true, }; wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -231,6 +235,7 @@ wincaps wincap_xpsp1 __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:false, use_dont_resolve_hack:true, use_get_sec_info_on_dirs:true, + supports_sse:true, }; wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -273,6 +278,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:false, use_dont_resolve_hack:true, use_get_sec_info_on_dirs:true, + supports_sse:true, }; wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -315,6 +321,7 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:false, use_dont_resolve_hack:false, use_get_sec_info_on_dirs:true, + supports_sse:true, }; wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -357,6 +364,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:true, use_dont_resolve_hack:false, use_get_sec_info_on_dirs:false, + supports_sse:true, }; wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -399,6 +407,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { has_restricted_raw_disk_access:true, use_dont_resolve_hack:false, use_get_sec_info_on_dirs:false, + supports_sse:true, }; wincapc wincap __attribute__((section (".cygwin_dll_common"), shared)); diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index 60d051268..af86b1020 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -53,6 +53,7 @@ struct wincaps unsigned has_restricted_raw_disk_access : 1; unsigned use_dont_resolve_hack : 1; unsigned use_get_sec_info_on_dirs : 1; + unsigned supports_sse : 1; }; class wincapc @@ -111,6 +112,7 @@ public: bool IMPLEMENT (has_restricted_raw_disk_access) bool IMPLEMENT (use_dont_resolve_hack) bool IMPLEMENT (use_get_sec_info_on_dirs) + bool IMPLEMENT (supports_sse) #undef IMPLEMENT };