[PATCH 5/57][Arm][GAS] Add support for MVE instructions: vmull{b,t}
[binutils-gdb.git] / gdb / testsuite / gdb.base / bitfields.c
blob3a6b76fb99be7786de2216f55adf0927eb947e67
1 /* Test program to test bit field operations */
3 /* For non-ANSI compilers, use plain ints for the signed bit fields. However,
4 whether they actually end up signed or not is implementation defined, so
5 this may cause some tests to fail. But at least we can still compile
6 the test program and run the tests... */
8 #if !defined(__STDC__) && !defined(__cplusplus)
9 #define signed /**/
10 #endif
12 struct fields
14 unsigned char uc ;
15 signed int s1 : 1;
16 unsigned int u1 : 1;
17 signed int s2 : 2;
18 unsigned int u2 : 2;
19 signed int s3 : 3;
20 unsigned int u3 : 3;
21 signed int s9 : 9;
22 unsigned int u9 : 9;
23 signed char sc ;
24 } flags;
26 struct internalvartest
28 unsigned int a : 1;
29 struct
31 unsigned int b : 1;
32 struct
34 unsigned int c : 1;
35 signed int d : 1;
36 } deep;
37 signed int e : 1;
38 } inner;
39 signed int f : 1;
40 } dummy_internalvartest;
42 void break1 ()
46 void break2 ()
50 void break3 ()
54 void break4 ()
58 void break5 ()
62 void break6 ()
66 void break7 ()
70 void break8 ()
74 void break9 ()
78 void break10 ()
82 struct container
84 struct fields one;
85 struct fields two;
86 } container;
88 /* This is used by bitfields.exp to determine if the target understands
89 signed bitfields. */
90 int i;
92 int main ()
94 /* For each member, set that member to 1, allow gdb to verify that the
95 member (and only that member) is 1, and then reset it back to 0. */
97 flags.uc = 1;
98 break1 ();
99 flags.uc = 0;
101 flags.s1 = -1;
102 break1 ();
103 flags.s1 = 0;
105 flags.u1 = 1;
106 break1 ();
107 flags.u1 = 0;
109 flags.s2 = 1;
110 break1 ();
111 flags.s2 = 0;
113 flags.u2 = 1;
114 break1 ();
115 flags.u2 = 0;
117 flags.s3 = 1;
118 break1 ();
119 flags.s3 = 0;
121 flags.u3 = 1;
122 break1 ();
123 flags.u3 = 0;
125 flags.s9 = 1;
126 break1 ();
127 flags.s9 = 0;
129 flags.u9 = 1;
130 break1 ();
131 flags.u9 = 0;
133 flags.sc = 1;
134 break1 ();
135 flags.sc = 0;
137 /* Fill alternating fields with all 1's and verify that none of the bits
138 "bleed over" to the other fields. */
140 flags.uc = 0xFF;
141 flags.u1 = 0x1;
142 flags.u2 = 0x3;
143 flags.u3 = 0x7;
144 flags.u9 = 0x1FF;
145 break2 ();
146 flags.uc = 0;
147 flags.u1 = 0;
148 flags.u2 = 0;
149 flags.u3 = 0;
150 flags.u9 = 0;
152 flags.s1 = -1;
153 flags.s2 = -1;
154 flags.s3 = -1;
155 flags.s9 = -1;
156 flags.sc = 0xFF;
157 break2 ();
158 flags.s1 = 0;
159 flags.s2 = 0;
160 flags.s3 = 0;
161 flags.s9 = 0;
162 flags.sc = 0;
164 /* Fill the unsigned fields with the maximum positive value and verify
165 that the values are printed correctly. */
167 /* Maximum positive values */
168 flags.u1 = 0x1;
169 flags.u2 = 0x3;
170 flags.u3 = 0x7;
171 flags.u9 = 0x1FF;
172 break3 ();
173 flags.u1 = 0;
174 flags.u2 = 0;
175 flags.u3 = 0;
176 flags.u9 = 0;
178 /* Fill the signed fields with the maximum positive value, then the maximally
179 negative value, then -1, and verify in each case that the values are
180 printed correctly. */
182 /* Maximum positive values */
183 flags.s1 = 0x0;
184 flags.s2 = 0x1;
185 flags.s3 = 0x3;
186 flags.s9 = 0xFF;
187 break4 ();
189 /* Maximally negative values */
190 flags.s1 = -0x1;
191 flags.s2 = -0x2;
192 flags.s3 = -0x4;
193 flags.s9 = -0x100;
194 /* Extract bitfield value so that bitfield.exp can check if the target
195 understands signed bitfields. */
196 i = flags.s9;
197 break4 ();
199 /* -1 */
200 flags.s1 = -1;
201 flags.s2 = -1;
202 flags.s3 = -1;
203 flags.s9 = -1;
204 break4 ();
206 flags.s1 = 0;
207 flags.s2 = 0;
208 flags.s3 = 0;
209 flags.s9 = 0;
211 /* Bitfields at a non-zero offset in a containing structure. */
212 container.one.u3 = 5;
213 container.two.u3 = 3;
214 break5 ();
216 return 0;