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