OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [bitfields2.c] - Blame information for rev 157

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* Test program to test bit field operations on bit fields of large
2
   integer types.  */
3
 
4
/* This file is expected to fail to compile if the type long long int
5
   is not supported, but in that case it is irrelevant.  */
6
 
7
#include <stdlib.h>
8
#include <string.h>
9
 
10
#if !defined(__STDC__) && !defined(__cplusplus)
11
#define signed  /**/
12
#endif
13
 
14
struct fields
15
{
16
  unsigned long long u1 : 15;
17
  unsigned long long u2 : 33;
18
  unsigned long long u3 : 16;
19
  signed long long   s1 : 15;
20
  signed long long   s2 : 33;
21
  signed long long   s3 : 16;
22
} flags;
23
 
24
void break1 ()
25
{
26
}
27
 
28
void break2 ()
29
{
30
}
31
 
32
void break3 ()
33
{
34
}
35
 
36
void break4 ()
37
{
38
}
39
 
40
void break5 ()
41
{
42
}
43
 
44
void break6 ()
45
{
46
}
47
 
48
void break7 ()
49
{
50
}
51
 
52
void break8 ()
53
{
54
}
55
 
56
void break9 ()
57
{
58
}
59
 
60
void break10 ()
61
{
62
}
63
 
64
/* This is used by bitfields.exp to determine if the target understands
65
   signed bitfields.  */
66
int i;
67
 
68
void tester ()
69
{
70
  memset ((char *) &flags, 0, sizeof (flags));
71
 
72
  /* For each member, set that member to 1, allow gdb to verify that the
73
     member (and only that member) is 1, and then reset it back to 0. */
74
  flags.s1 = 1;
75
  break1 ();
76
  flags.s1 = 0;
77
 
78
  flags.u1 = 1;
79
  break1 ();
80
  flags.u1 = 0;
81
 
82
  flags.s2  = 1;
83
  break1 ();
84
  flags.s2 = 0;
85
 
86
  flags.u2 = 1;
87
  break1 ();
88
  flags.u2 = 0;
89
 
90
  flags.s3  = 1;
91
  break1 ();
92
  flags.s3 = 0;
93
 
94
  flags.u3 = 1;
95
  break1 ();
96
  flags.u3 = 0;
97
 
98
  /* Fill alternating fields with all 1's and verify that none of the bits
99
     "bleed over" to the other fields. */
100
 
101
  flags.u1 = 0x7FFF;
102
  flags.u3 = 0xFFFF;
103
  flags.s2 = -1LL;
104
  break2 ();
105
  flags.u1 = 0;
106
  flags.u3 = 0;
107
  flags.s2 = 0;
108
 
109
  flags.u2 = 0x1FFFFFFFFLL;
110
  flags.s1 = -1;
111
  flags.s3 = -1;
112
  break2 ();
113
 
114
  flags.u2 = 0;
115
  flags.s1 = 0;
116
  flags.s3 = 0;
117
 
118
  /* Fill the unsigned fields with the maximum positive value and verify
119
     that the values are printed correctly. */
120
 
121
  flags.u1 = 0x7FFF;
122
  flags.u2 = 0x1FFFFFFFFLL;
123
  flags.u3 = 0xFFFF;
124
  break3 ();
125
  flags.u1 = 0;
126
  flags.u2 = 0;
127
  flags.u3 = 0;
128
 
129
  /* Fill the signed fields with the maximum positive value, then the maximally
130
     negative value, then -1, and verify in each case that the values are
131
     printed correctly. */
132
 
133
  /* Maximum positive values */
134
  flags.s1 = 0x3FFF;
135
  flags.s2 = 0xFFFFFFFFLL;
136
  flags.s3 = 0x7FFF;
137
  break4 ();
138
 
139
  /* Maximally negative values */
140
  flags.s1 = -0x4000;
141
  flags.s2 = -0x100000000LL;
142
  flags.s3 = -0x8000;
143
 
144
  /* Extract bitfield value so that bitfield.exp can check if the target
145
     understands signed bitfields.  */
146
  i = flags.s3;
147
  break4 ();
148
 
149
  /* -1 */
150
  flags.s1 = -1;
151
  flags.s2 = -1;
152
  flags.s3 = -1;
153
  break4 ();
154
 
155
  flags.s1 = 0;
156
  flags.s2 = 0;
157
  flags.s3 = 0;
158
 
159
  break5 ();
160
}
161
 
162
int main ()
163
{
164
  int i;
165
#ifdef usestubs
166
  set_debug_traps();
167
  breakpoint();
168
#endif
169
  for (i = 0; i < 5; i += 1)
170
    tester ();
171
  return 0;
172
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.