34f3102727f55e2a7fc5f01b206f4a903694c202
[libfirm] / ir / be / test / bf_localinit.c
1 #include "dumpmem.h"
2
3 struct bf {
4   int a;
5   unsigned x:13;
6   unsigned y:17;
7   unsigned z:3;
8   char c;
9   double d;
10   unsigned w:9;
11 };
12
13 #define offsetof(TYPE, MEMB) ((size_t) &((TYPE *)0)->MEMB)
14
15 int main(void) {
16   struct bf mybf = { 0xffffffff, 4097, 65537, 5, 0xff, 4.5, 257 };
17
18 #if 0
19   dumpMem(&mybf, sizeof mybf);
20   printf("sizeof mybf %d\n", sizeof mybf);
21   printf("offset a = %d\n", offsetof(struct bf, a));
22   printf("offset c = %d\n", offsetof(struct bf, c));
23   printf("offset d = %d\n", offsetof(struct bf, d));
24 #endif
25
26   printf("int a (expected -1): %d\n", mybf.a);
27   printf("unsigned x:13 (expected 4097): %u\n", mybf.x);
28   printf("unsigned y:17 (expected 65537): %u\n", mybf.y);
29   printf("unsigned y:3 (expected 5): %u\n", mybf.z);
30   printf("char c (expected ff): %x\n", mybf.c);
31   printf("double d (expected 4.5): %.1f\n", mybf.d);
32   printf("unsigned w:9 (expected 257): %u\n", mybf.w);
33
34   return 0;
35 }