X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Ftest%2Fbf_localinit.c;h=b390b13e3e9fad48e79fd987553bbafc40925e23;hb=14b2eb0556a413314f1af10a2277bda22e68d6be;hp=f7f56f3e972571e42fcbaeb2e010a6c0bca05f1b;hpb=e4691fe2e5046a9b2ae912e23e92ddcdcd2bb6e9;p=libfirm diff --git a/ir/be/test/bf_localinit.c b/ir/be/test/bf_localinit.c index f7f56f3e9..b390b13e3 100644 --- a/ir/be/test/bf_localinit.c +++ b/ir/be/test/bf_localinit.c @@ -1,25 +1,39 @@ +#include +#include #include "dumpmem.h" struct bf { - int a; - unsigned x:13; - unsigned y:17; - unsigned z:3; - char c; - double d; - unsigned w:9; + int a; + unsigned x:13; + unsigned y:17; + unsigned z:3; + char c; + double d; + unsigned w:9; }; -#define offsetof(TYPE, MEMB) ((size_t) &((TYPE *)0)->MEMB) +#ifdef offsetof +#undef offsetof +#endif +#define offsetof(TYPE, MEMB) ((char*) (&((TYPE *)0)->MEMB) - (char*) 0) -int main(void) { - struct bf mybf = { 0xffffffff, 4097, 65537, 5, 0xff, 4.5, 257 }; +int main(int argc, char **argv) { + struct bf mybf = { 0xffffffff, 4097, 65537, 5, 0xff, 4.5, 257 }; - dumpMem(&mybf, sizeof mybf); - printf("sizeof mybf %d\n", sizeof mybf); - printf("offset a = %d\n", offsetof(struct bf, a)); - printf("offset c = %d\n", offsetof(struct bf, c)); - printf("offset d = %d\n", offsetof(struct bf, d)); + if(argc > 1) + dumpMem(&mybf, sizeof mybf); + printf("sizeof mybf %d\n", sizeof mybf); + printf("offset a = %d\n", offsetof(struct bf, a)); + printf("offset c = %d\n", offsetof(struct bf, c)); + printf("offset d = %d\n", offsetof(struct bf, d)); - return 0; + printf("int a (expected -1): %d\n", mybf.a); + printf("unsigned x:13 (expected 4097): %u\n", mybf.x); + printf("unsigned y:17 (expected 65537): %u\n", mybf.y); + printf("unsigned y:3 (expected 5): %u\n", mybf.z); + printf("char c (expected ff): %x\n", mybf.c); + printf("double d (expected 4.5): %.1f\n", mybf.d); + printf("unsigned w:9 (expected 257): %u\n", mybf.w); + + return 0; }