Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:plunky:20110505071320

Diff

Diff from 1.1 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc-tests/tests/c/codegen/pack.c

Annotated File View

plunky
1.1
1 /*
2  * test effects of #pragma pack()
3  *
4  * output should be the same when compiled with pcc as gcc
5  */
6
7 #include <sys/types.h>
8 #include <stddef.h>
9 #include <stdio.h>
10
11 #define PRAGMA(s)       _Pragma (#s)
12
13 #define S(size, align)          \
14 PRAGMA(pack(align))             \
15 struct s##_##size##_##align {   \
16         int##size##_t   a;      \
17         int##size##_t   b;      \
18         int##size##_t   c;      \
19 };
20
21 #define D(size)         \
22         S(size0)      \
23         S(size1)      \
24         S(size2)      \
25         S(size4)      \
26         S(size8)      \
27         S(size16)
28
29 #define O(size, align)                                          \
30         printf("s_%d_%-2d = %d, %d, %d, %d\n"sizealign,     \
31                 offsetof(struct s##_##size##_##aligna),       \
32                 offsetof(struct s##_##size##_##alignb),       \
33                 offsetof(struct s##_##size##_##alignc),       \
34                 sizeof(struct s##_##size##_##align));
35
36 #define P(size)         \
37         O(size0)      \
38         O(size1)      \
39         O(size2)      \
40         O(size4)      \
41         O(size8)      \
42         O(size16)
43
44 D(8)
45 D(16)
46 D(32)
47 D(64)
48
49 int
50 main(int acchar *av[])
51 {
52         P(8)
53         P(16)
54         P(32)
55         P(64)
56
57         return 0;
58 }
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-07-10 02:15 +0200