Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
2b4f834e
Commit
2b4f834e
authored
Dec 14, 2006
by
Matthias Braun
Browse files
bitfields work like gcc now, we can output packing in our tests
parent
308983f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/be/test/bf_init.c
View file @
2b4f834e
...
...
@@ -12,12 +12,10 @@ struct bf {
struct
bf
mybf
=
{
0xffffffff
,
4097
,
65537
,
5
,
0xff
,
4
.
5
,
257
};
int
main
(
int
argc
,
char
**
argv
)
{
int
main
()
{
if
(
argc
>
1
)
{
dumpMem
(
&
mybf
,
sizeof
mybf
);
printf
(
"sizeof mybf %d
\n
"
,
sizeof
mybf
);
}
dumpMem
(
&
mybf
,
sizeof
mybf
);
printf
(
"sizeof mybf %d
\n
"
,
sizeof
mybf
);
printf
(
"int a (expected -1): %d
\n
"
,
mybf
.
a
);
printf
(
"unsigned x:13 (expected 4097): %u
\n
"
,
mybf
.
x
);
...
...
ir/be/test/bf_localinit.c
View file @
2b4f834e
#include <stdlib.h>
#include "dumpmem.h"
struct
bf
{
...
...
@@ -13,18 +14,16 @@ struct bf {
#ifdef offsetof
#undef offsetof
#endif
#define offsetof(TYPE, MEMB) ((
size_t
) &((TYPE *)0)->MEMB)
#define offsetof(TYPE, MEMB) ((
char*
)
(
&((TYPE *)0)->MEMB)
- (char*) 0)
int
main
(
int
argc
,
char
**
argv
)
{
struct
bf
mybf
=
{
0xffffffff
,
4097
,
65537
,
5
,
0xff
,
4
.
5
,
257
};
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
));
}
//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
));
printf
(
"int a (expected -1): %d
\n
"
,
mybf
.
a
);
printf
(
"unsigned x:13 (expected 4097): %u
\n
"
,
mybf
.
x
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment