gdb/riscv: Add command to switch between numeric & abi register names
[binutils-gdb.git] / gdb / testsuite / gdb.base / sizeof.c
blob4cf8c55898b8d9f8f561badb4889a7a732104324
1 typedef char padding[16];
3 struct {
4 padding p1;
5 char v;
6 padding p2;
7 } padding_char;
9 struct {
10 padding p1;
11 short v;
12 padding p2;
13 } padding_short;
15 struct {
16 padding p1;
17 int v;
18 padding p2;
19 } padding_int;
21 struct {
22 padding p1;
23 long v;
24 padding p2;
25 } padding_long;
27 struct {
28 padding p1;
29 long long v;
30 padding p2;
31 } padding_long_long;
33 struct {
34 padding p1;
35 float v;
36 padding p2;
37 } padding_float;
39 struct {
40 padding p1;
41 double v;
42 padding p2;
43 } padding_double;
45 struct {
46 padding p1;
47 long double v;
48 padding p2;
49 } padding_long_double;
51 static void
52 fill (void *buf, long sizeof_buf)
54 char *p = (char *) buf;
55 int i;
56 for (i = 0; i < sizeof_buf; i++)
57 p[i] = "The quick brown dingo jumped over the layzy dog."[i];
60 void
61 fill_structs (void)
63 fill (&padding_char.p1, sizeof (padding));
64 fill (&padding_char.v, sizeof (padding_char.v));
65 fill (&padding_char.p2, sizeof (padding));
67 fill (&padding_short.p1, sizeof (padding));
68 fill (&padding_short.v, sizeof (padding_short.v));
69 fill (&padding_short.p2, sizeof (padding));
71 fill (&padding_int.p1, sizeof (padding));
72 fill (&padding_int.v, sizeof (padding_int.v));
73 fill (&padding_int.p2, sizeof (padding));
75 fill (&padding_long.p1, sizeof (padding));
76 fill (&padding_long.v, sizeof (padding_long.v));
77 fill (&padding_long.p2, sizeof (padding));
79 fill (&padding_long_long.p1, sizeof (padding));
80 fill (&padding_long_long.v, sizeof (padding_long_long.v));
81 fill (&padding_long_long.p2, sizeof (padding));
83 fill (&padding_float.p1, sizeof (padding));
84 fill (&padding_float.v, sizeof (padding_float.v));
85 fill (&padding_float.p2, sizeof (padding));
87 fill (&padding_double.p1, sizeof (padding));
88 fill (&padding_double.v, sizeof (padding_double.v));
89 fill (&padding_double.p2, sizeof (padding));
91 fill (&padding_long_double.p1, sizeof (padding));
92 fill (&padding_long_double.v, sizeof (padding_long_double.v));
93 fill (&padding_long_double.p2, sizeof (padding));
96 int
97 main ()
99 int size, value;
101 fill_structs ();
103 size = (int) sizeof (char);
104 size = (int) sizeof (short);
105 size = (int) sizeof (int);
106 size = (int) sizeof (long);
107 size = (int) sizeof (long long);
108 size = (int) sizeof (void*);
109 size = (int) sizeof (void (*)(void));
110 size = (int) sizeof (float);
111 size = (int) sizeof (double);
112 size = (int) sizeof (long double);
114 /* Signed char? */
115 value = '\377';
116 value = (int) (char) -1;
117 value = (int) (signed char) -1;
118 value = (int) (unsigned char) -1;
120 return 0;