FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / rounding-4.c
bloba4a0e96039922befb9852bda0e024a4ed99e670d
1 #include <stdio.h>
2 #include <assert.h>
3 #include "opcodes.h"
5 /* Test "load rounded" with universally available rounding modes.
6 Rounding mode is provided via FPC.
7 Also test "load lengthened" (which is independent of rounding modes). */
9 volatile double d;
10 volatile float f;
12 const char *
13 rtext(unsigned fpc_round)
15 switch (fpc_round) {
16 case 0: return "[-> near]";
17 case 1: return "[-> zero]";
18 case 2: return "[-> +inf]";
19 case 3: return "[-> -inf]";
21 assert(0);
24 void
25 set_rounding_mode(unsigned mode)
27 printf("setting FPC rounding mode to %s\n", rtext(mode));
28 register unsigned r asm("1") = mode;
29 __asm__ volatile ( SFPC(1) : : "d"(r) );
33 void
34 load_rounded(void)
36 f = d;
37 printf("load rounded d = %10.3f f = %10.3f\n", d, f);
40 void
41 load_lengthened(void)
43 d = f;
44 printf("load lengthened d = %22.20g f = %22.20g\n", d, f);
47 /* Tests for load rounded and load lengthened */
48 int main()
50 d = 12345678.25;
51 set_rounding_mode(0);
52 load_rounded();
53 set_rounding_mode(1);
54 load_rounded();
55 set_rounding_mode(2);
56 load_rounded();
57 set_rounding_mode(3);
58 load_rounded();
59 printf("======================================\n");
60 d = 12345678.75;
61 set_rounding_mode(0);
62 load_rounded();
63 set_rounding_mode(1);
64 load_rounded();
65 set_rounding_mode(2);
66 load_rounded();
67 set_rounding_mode(3);
68 load_rounded();
69 printf("======================================\n");
70 d = -12345678.25;
71 set_rounding_mode(0);
72 load_rounded();
73 set_rounding_mode(1);
74 load_rounded();
75 set_rounding_mode(2);
76 load_rounded();
77 set_rounding_mode(3);
78 load_rounded();
79 printf("======================================\n");
80 d = -12345678.75;
81 set_rounding_mode(0);
82 load_rounded();
83 set_rounding_mode(1);
84 load_rounded();
85 set_rounding_mode(2);
86 load_rounded();
87 set_rounding_mode(3);
88 load_rounded();
89 printf("\n");
91 f = 1234.5678f;
92 load_lengthened();
94 return 0;