FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / rounding-2.c
blob32813ad267417347d9685f4c2ecf8aa9a4a1ed1c
1 #include <assert.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include "opcodes.h"
6 /* Basic test that we can set the rounding mode in the FPC and
7 query it. Covers only generally available rounding modes. */
9 void
10 set_rounding_mode(unsigned mode)
12 register unsigned r asm("1") = mode;
13 __asm__ volatile ( SFPC(1) : : "d"(r) );
16 unsigned
17 get_rounding_mode(void)
19 unsigned fpc;
21 __asm__ volatile ("stfpc %0" : "=Q"(fpc));
23 return fpc & 0x7;
27 int main(void)
29 int i;
30 const unsigned rmodes[] = { 0, 1, 2, 3 };
32 printf("initial rounding mode: %u\n", get_rounding_mode());
34 for (i = 0; i < sizeof rmodes / sizeof rmodes[0]; ++i) {
35 printf("setting rounding mode to %u\n", rmodes[i]);
36 set_rounding_mode(rmodes[i]);
37 printf("...checking: %u\n", get_rounding_mode());
40 return 0;