1 /* Test floating-point environment includes SSE state (bug 16064).
2 Copyright (C) 2014-2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
28 unsigned int eax
, ebx
, ecx
, edx
;
30 if (!__get_cpuid (1, &eax
, &ebx
, &ecx
, &edx
))
33 return (edx
& bit_SSE2
) != 0;
36 static __attribute__ ((noinline
)) int
41 if (fegetenv (&base_env
) != 0)
43 puts ("fegetenv (&base_env) failed");
46 if (fesetround (FE_UPWARD
) != 0)
48 puts ("fesetround (FE_UPWARD) failed");
51 if (fesetenv (&base_env
) != 0)
53 puts ("fesetenv (&base_env) failed");
56 volatile float a
= 1.0f
, b
= FLT_MIN
, c
;
60 puts ("fesetenv did not restore rounding mode");
63 if (fesetround (FE_DOWNWARD
) != 0)
65 puts ("fesetround (FE_DOWNWARD) failed");
68 if (feupdateenv (&base_env
) != 0)
70 puts ("feupdateenv (&base_env) failed");
73 volatile float d
= -FLT_MIN
, e
;
77 puts ("feupdateenv did not restore rounding mode");
80 if (fesetround (FE_UPWARD
) != 0)
82 puts ("fesetround (FE_UPWARD) failed");
86 if (feholdexcept (&upward_env
) != 0)
88 puts ("feholdexcept (&upward_env) failed");
91 if (fesetround (FE_DOWNWARD
) != 0)
93 puts ("fesetround (FE_DOWNWARD) failed");
96 if (fesetenv (&upward_env
) != 0)
98 puts ("fesetenv (&upward_env) failed");
104 puts ("fesetenv did not restore rounding mode from feholdexcept");
107 if (fesetround (FE_UPWARD
) != 0)
109 puts ("fesetround (FE_UPWARD) failed");
112 if (fesetenv (FE_DFL_ENV
) != 0)
114 puts ("fesetenv (FE_DFL_ENV) failed");
120 puts ("fesetenv (FE_DFL_ENV) did not restore rounding mode");
131 puts ("CPU does not support SSE2, cannot test");
137 #define TEST_FUNCTION do_test ()
138 #include <test-skeleton.c>