Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
5364c38c9bb733bd5a3c340b4e65ad552b0d764a
[simgrid.git] / buildtools / CPACK / tmp / prog_GRAS_CHECK_STRUCT_COMPACTION.c
1 #include <sys/types.h>
2 #include <stddef.h> /* offsetof() */
3 #include <stdio.h>
4
5 void main (void)
6 {
7
8 struct s0 {char c0; double d0;};
9 struct s1 {double d1; int i1; char c1;};
10 struct s2 {double d2; int i2; char c2[6];};
11 struct s3 {double d3; int a3; int b3;}; 
12
13 int gras_struct_packed;
14 int gras_struct_compact;
15 int gras_array_straddle_struct;
16 int gras_compact_struct;
17
18         if (sizeof(struct s0) == sizeof(double)+sizeof(char))
19         {
20                 gras_struct_packed=1;
21         }
22         else
23         {
24                 gras_struct_packed=0;
25         }
26         if (offsetof(struct s1,c1) == sizeof(double)+sizeof(int))
27         {
28                 gras_struct_compact=1;
29         }
30         else
31         {
32                 gras_struct_compact=0;
33         }
34         if (offsetof(struct s2,c2) == sizeof(double)+sizeof(int))
35         {
36                 gras_array_straddle_struct=1;
37         }
38         else
39         {
40                 gras_array_straddle_struct=0;
41         }
42         if (offsetof(struct s3,b3) == sizeof(double)+sizeof(int))
43         {
44                 gras_compact_struct=1;
45         }
46         else
47         {
48                 gras_compact_struct=0;
49         }
50
51
52         if(gras_struct_packed == 0 && gras_struct_compact == 1) printf("GRAS_STRUCT_COMPACT ");
53
54         if(gras_array_straddle_struct == 1) printf("GRAS_ARRAY_STRADDLE_STRUCT ");
55
56         if(gras_compact_struct == 1) printf("GRAS_COMPACT_STRUCT ");
57
58 }