1 /* Copyright (C) 2014-2018 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
24 #include <sys/prctl.h>
26 #if __mips_fpr != 0 || _MIPS_SPFPSET != 16
27 # error This test requires -mfpxx -mno-odd-spreg
30 /* This test verifies that mode changes between a setjmp and longjmp do
31 not corrupt the state of callee-saved registers. */
37 PR_FP_MODE_FR
| PR_FP_MODE_FRE
,
40 PR_FP_MODE_FR
| PR_FP_MODE_FRE
52 for (i
= 0 ; i
< 7 ; i
++)
55 register float test1
__asm ("$f20");
56 register double test2
__asm ("$f22");
58 /* Hide what we are doing to $f20 and $f22 from the compiler. */
59 __asm
__volatile ("l.s %0,%2\n"
61 : "=f" (test1
), "=f" (test2
)
62 : "m" (check1
), "m" (check2
));
64 retval
= setjmp (env
);
66 /* Make sure the compiler knows we want to access the variables
67 via the named registers again. */
68 __asm
__volatile ("" : : "f" (test1
), "f" (test2
));
70 if (test1
!= check1
|| test2
!= check2
)
72 printf ("Corrupt register detected: $20 %f = %f, $22 %f = %f\n",
73 test1
, check1
, test2
, check2
);
79 if (prctl (PR_SET_FP_MODE
, mode
[i
% 6]) != 0
82 printf ("prctl PR_SET_FP_MODE failed: %m");
92 #define TEST_FUNCTION do_test ()
93 #include "../../test-skeleton.c"