Update
[qemu-kvm/fedora.git] / tests / cris / check_bound.c
blob411d2ad56e0f89331fbc1bc6d235ff08102287dd
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdint.h>
4 #include "sys.h"
5 #include "crisutils.h"
7 extern inline int cris_bound_b(int v, int b) {
8 int r = v;
9 asm ("bound.b\t%1, %0\n" : "+r" (r) : "ri" (b));
10 return r;
13 extern inline int cris_bound_w(int v, int b) {
14 int r = v;
15 asm ("bound.w\t%1, %0\n" : "+r" (r) : "ri" (b));
16 return r;
19 extern inline int cris_bound_d(int v, int b) {
20 int r = v;
21 asm ("bound.d\t%1, %0\n" : "+r" (r) : "ri" (b));
22 return r;
25 int main(void)
27 int r;
29 cris_tst_cc_init();
30 r = cris_bound_d(-1, 2);
31 cris_tst_cc(0, 0, 0, 0);
32 if (r != 2)
33 err();
35 cris_tst_cc_init();
36 r = cris_bound_d(2, 0xffffffff);
37 cris_tst_cc(0, 0, 0, 0);
38 if (r != 2)
39 err();
41 cris_tst_cc_init();
42 r = cris_bound_d(0xffff, 0xffff);
43 cris_tst_cc(0, 0, 0, 0);
44 if (r != 0xffff)
45 err();
47 cris_tst_cc_init();
48 r = cris_bound_d(-1, 0xffffffff);
49 cris_tst_cc(1, 0, 0, 0);
50 if (r != 0xffffffff)
51 err();
53 cris_tst_cc_init();
54 r = cris_bound_d(0x78134452, 0x5432f789);
55 cris_tst_cc(0, 0, 0, 0);
56 if (r != 0x5432f789)
57 err();
59 cris_tst_cc_init();
60 r = cris_bound_w(-1, 2);
61 cris_tst_cc(0, 0, 0, 0);
62 if (r != 2)
63 err();
65 cris_tst_cc_init();
66 r = cris_bound_w(-1, 0xffff);
67 cris_tst_cc(0, 0, 0, 0);
68 if (r != 0xffff)
69 err();
71 cris_tst_cc_init();
72 r = cris_bound_w(2, 0xffff);
73 cris_tst_cc(0, 0, 0, 0);
74 if (r != 2)
75 err();
77 cris_tst_cc_init();
78 r = cris_bound_w(0xfedaffff, 0xffff);
79 cris_tst_cc(0, 0, 0, 0);
80 if (r != 0xffff)
81 err();
83 cris_tst_cc_init();
84 r = cris_bound_w(0x78134452, 0xf789);
85 cris_tst_cc(0, 0, 0, 0);
86 if (r != 0xf789)
87 err();
89 cris_tst_cc_init();
90 r = cris_bound_b(-1, 2);
91 cris_tst_cc(0, 0, 0, 0);
92 if (r != 2)
93 err();
95 cris_tst_cc_init();
96 r = cris_bound_b(2, 0xff);
97 cris_tst_cc(0, 0, 0, 0);
98 if (r != 2)
99 err();
101 cris_tst_cc_init();
102 r = cris_bound_b(-1, 0xff);
103 cris_tst_cc(0, 0, 0, 0);
104 if (r != 0xff)
105 err();
107 cris_tst_cc_init();
108 r = cris_bound_b(0xff, 0xff);
109 cris_tst_cc(0, 0, 0, 0);
110 if (r != 0xff)
111 err();
113 cris_tst_cc_init();
114 r = cris_bound_b(0xfeda49ff, 0xff);
115 cris_tst_cc(0, 0, 0, 0);
116 if (r != 0xff)
117 err();
119 cris_tst_cc_init();
120 r = cris_bound_b(0x78134452, 0x89);
121 cris_tst_cc(0, 0, 0, 0);
122 if (r != 0x89)
123 err();
125 cris_tst_cc_init();
126 r = cris_bound_w(0x78134452, 0);
127 cris_tst_cc(0, 1, 0, 0);
128 if (r != 0)
129 err();
131 cris_tst_cc_init();
132 r = cris_bound_b(0xffff, -1);
133 cris_tst_cc(0, 0, 0, 0);
134 if (r != 0xff)
135 err();
137 pass();
138 return 0;