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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [testsuite/] [gcc.c-torture/] [execute/] [991014-1.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 jlechner
 
2
typedef typeof(sizeof(char)) Size_t;
3
 
4
#define bufsize ((1L << (8 * sizeof(Size_t) - 2))-256)
5
 
6
struct huge_struct
7
{
8
  short buf[bufsize];
9
  int a;
10
  int b;
11
  int c;
12
  int d;
13
};
14
 
15
union huge_union
16
{
17
  int a;
18
  char buf[bufsize];
19
};
20
 
21
unsigned long union_size()
22
{
23
  return sizeof(union huge_union);
24
}
25
 
26
unsigned long struct_size()
27
{
28
  return sizeof(struct huge_struct);
29
}
30
 
31
unsigned long struct_a_offset()
32
{
33
  return (unsigned long)(&((struct huge_struct *) 0)->a);
34
}
35
 
36
int main()
37
{
38
  /* Check the exact sizeof value. bufsize is aligned on 256b. */
39
  if (union_size() != sizeof(char) * bufsize)
40
    abort();
41
 
42
  if (struct_size() != sizeof(short) * bufsize + 4*sizeof(int))
43
    abort();
44
 
45
  if (struct_a_offset() < sizeof(short) * bufsize)
46
    abort();
47
 
48
  return 0;
49
}
50
 

powered by: WebSVN 2.1.0

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