FreeBSD: add file descriptor tracking for _umtx_op
[valgrind.git] / none / tests / s390x / srnmb.c
blob548b644ca39978d4cc1521616f100e76e7d14ee0
1 #include <assert.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include "opcodes.h"
6 #define srnmb(b,d) \
7 ({ \
8 __asm__ volatile ( "lghi 8," #b "\n\t" \
9 SRNMB(8,d) \
10 ::: "8"); \
14 /* Like srnm above, except it uses r0 as a base register */
15 #define srnmb0(d) \
16 ({ \
17 __asm__ volatile ( SRNMB(0,d) \
18 ::: "0"); \
21 #define get_rounding_mode() \
22 ({ \
23 unsigned fpc; \
24 __asm__ volatile ("stfpc %0" : "=Q"(fpc)); \
25 fpc & 0x7; \
28 int main(void)
30 printf("initial rounding mode = %u\n", get_rounding_mode());
32 /* Set basic rounding modes in various ways */
33 srnmb(1,002); // 1 + 2 = 3
34 printf("rounding mode = %u\n", get_rounding_mode());
36 srnmb(2,000);
37 printf("rounding mode = %u\n", get_rounding_mode());
39 srnmb(0,001);
40 printf("rounding mode = %u\n", get_rounding_mode());
42 srnmb(0,000);
43 printf("rounding mode = %u\n", get_rounding_mode());
45 #if 0
46 // fpext
47 srnmb(7,000); // -> 7
48 printf("rounding mode = %u\n", get_rounding_mode());
50 srnmb(0,000); // -> 0
51 printf("rounding mode = %u\n", get_rounding_mode());
53 srnmb(0,007); // -> 7
54 printf("rounding mode = %u\n", get_rounding_mode());
55 #endif
57 srnmb(0,001);
58 printf("rounding mode = %u\n", get_rounding_mode());
60 srnmb0(004); // -> emul warning invalid rounding mode
61 printf("rounding mode = %u\n", get_rounding_mode());
63 return 0;