]>
git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/powerpc/powerpc64/tst-ucontext-ppc64-vscr.c
1 /* Test if POWER vscr read by ucontext.
2 Copyright (C) 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/>. */
19 #include <support/check.h>
29 /* This test is supported only on POWER 5 or higher. */
30 #define PPC_CPU_SUPPORTED (PPC_FEATURE_POWER5 | PPC_FEATURE_POWER5_PLUS \
31 | PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_ARCH_2_06 \
32 | PPC_FEATURE2_ARCH_2_07)
37 if (!(getauxval(AT_HWCAP2
) & PPC_CPU_SUPPORTED
))
39 if (!(getauxval(AT_HWCAP
) & PPC_CPU_SUPPORTED
))
40 FAIL_UNSUPPORTED("This test is unsupported on POWER < 5\n");
43 uint32_t vscr
[4] __attribute__ ((aligned (16)));
44 uint32_t* vscr_ptr
= vscr
;
47 __vector
unsigned int v0
= {0};
48 __vector
unsigned int v1
= {0};
50 /* Set SAT bit in VSCR register. */
51 asm volatile (".machine push;\n"
52 ".machine \"power5\";\n"
59 : "=v" (v0
), "=v" (v1
)
62 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
68 if ((vscr_word
& SAT
) != SAT
)
70 FAIL_EXIT1("FAIL: SAT bit is not set.\n");
73 if (getcontext (&ucp
))
75 FAIL_EXIT1("FAIL: getcontext error\n");
77 if (ucp
.uc_mcontext
.v_regs
->vscr
.vscr_word
!= vscr_word
)
79 FAIL_EXIT1("FAIL: ucontext vscr does not match with vscr\n");
84 #include <support/test-driver.c>