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/] [sizeof.c] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
#include <stdio.h>
2
 
3
typedef char padding[16];
4
 
5
struct {
6
  padding p1;
7
  char v;
8
  padding p2;
9
} padding_char;
10
 
11
struct {
12
  padding p1;
13
  short v;
14
  padding p2;
15
} padding_short;
16
 
17
struct {
18
  padding p1;
19
  int v;
20
  padding p2;
21
} padding_int;
22
 
23
struct {
24
  padding p1;
25
  long v;
26
  padding p2;
27
} padding_long;
28
 
29
struct {
30
  padding p1;
31
  long long v;
32
  padding p2;
33
} padding_long_long;
34
 
35
struct {
36
  padding p1;
37
  float v;
38
  padding p2;
39
} padding_float;
40
 
41
struct {
42
  padding p1;
43
  double v;
44
  padding p2;
45
} padding_double;
46
 
47
struct {
48
  padding p1;
49
  long double v;
50
  padding p2;
51
} padding_long_double;
52
 
53
static void
54
fill (void *buf, long sizeof_buf)
55
{
56
  char *p = buf;
57
  int i;
58
  for (i = 0; i < sizeof_buf; i++)
59
    p[i] = "The quick brown dingo jumped over the layzy dog."[i];
60
}
61
 
62
void
63
fill_structs (void)
64
{
65
  fill (&padding_char.p1, sizeof (padding));
66
  fill (&padding_char.v, sizeof (padding_char.v));
67
  fill (&padding_char.p2, sizeof (padding));
68
 
69
  fill (&padding_short.p1, sizeof (padding));
70
  fill (&padding_short.v, sizeof (padding_short.v));
71
  fill (&padding_short.p2, sizeof (padding));
72
 
73
  fill (&padding_int.p1, sizeof (padding));
74
  fill (&padding_int.v, sizeof (padding_int.v));
75
  fill (&padding_int.p2, sizeof (padding));
76
 
77
  fill (&padding_long.p1, sizeof (padding));
78
  fill (&padding_long.v, sizeof (padding_long.v));
79
  fill (&padding_long.p2, sizeof (padding));
80
 
81
  fill (&padding_long_long.p1, sizeof (padding));
82
  fill (&padding_long_long.v, sizeof (padding_long_long.v));
83
  fill (&padding_long_long.p2, sizeof (padding));
84
 
85
  fill (&padding_float.p1, sizeof (padding));
86
  fill (&padding_float.v, sizeof (padding_float.v));
87
  fill (&padding_float.p2, sizeof (padding));
88
 
89
  fill (&padding_double.p1, sizeof (padding));
90
  fill (&padding_double.v, sizeof (padding_double.v));
91
  fill (&padding_double.p2, sizeof (padding));
92
 
93
  fill (&padding_long_double.p1, sizeof (padding));
94
  fill (&padding_long_double.v, sizeof (padding_long_double.v));
95
  fill (&padding_long_double.p2, sizeof (padding));
96
}
97
 
98
int
99
main ()
100
{
101
  fill_structs ();
102
 
103
  printf ("sizeof (char) == %d\n", sizeof (char));
104
  printf ("sizeof (short) == %d\n", sizeof (short));
105
  printf ("sizeof (int) == %d\n", sizeof (int));
106
  printf ("sizeof (long) == %d\n", sizeof (long));
107
  printf ("sizeof (long long) == %d\n", sizeof (long long));
108
 
109
  printf ("sizeof (void *) == %d\n", sizeof (void*));
110
  printf ("sizeof (void (*)(void)) == %d\n", sizeof (void (*)(void)));
111
 
112
  printf ("sizeof (float) == %d\n", sizeof (float));
113
  printf ("sizeof (double) == %d\n", sizeof (double));
114
  printf ("sizeof (long double) == %d\n", sizeof (long double));
115
 
116
  /* Signed char?  */
117
  printf ("valueof ('\\377') == %d\n", '\377');
118
  printf ("valueof ((int) (char) -1) == %d\n", (int) (char) -1);
119
  printf ("valueof ((int) (signed char) -1) == %d\n", (int) (signed char) -1);
120
  printf ("valueof ((int) (unsigned char) -1) == %d\n", (int) (unsigned char) -1);
121
 
122
  return 0;
123
}

powered by: WebSVN 2.1.0

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