GCC Bugzilla – Attachment 29122 Details for
Bug 52991
[6/7/8 Regression] attribute packed broken on mingw32?
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Testcase for bitfield and structure field-aligning by attribute
msbit_tests3.c (text/plain), 1.55 KB, created by
Kai Tietz
on 2013-01-09 13:37:13 UTC
(
hide
)
Description:
Testcase for bitfield and structure field-aligning by attribute
Filename:
MIME Type:
Creator:
Kai Tietz
Created:
2013-01-09 13:37:13 UTC
Size:
1.55 KB
patch
obsolete
>#include <stdio.h> > >#ifdef __GNUC__ >#define MS_ALIGN(N) __declspec(aligned(N)) >#define GNU_ALIGN(N) >#else >#define GNU_ALIGN(N) >#define MS_ALIGN(N) __declspec(align(N)) >#endif > >static int diff_ptr (const void *p1, const void *p2) >{ > const char *c1 = (const char *) p1; > const char *c2 = (const char *) p2; > return (int) (c2 - c1); >} > >static int check_ptr (const void *base, const void *off, int expect) >{ > int v = diff_ptr (base, off); > if (v == expect) > return 1; > printf (" expect %d, but we got %d", expect, v); > return 0; >} > >MS_ALIGN(1) struct sP1_1 { > char a; > unsigned char b; > MS_ALIGN(1) short c GNU_ALIGN(1); >} GNU_ALIGN(1); > >MS_ALIGN(1) struct sP2_1 { > char a; > unsigned char b; > MS_ALIGN(2) short c GNU_ALIGN(2); >} GNU_ALIGN(1); > >MS_ALIGN(1) struct sP4_1 { > char a; > unsigned char b; > MS_ALIGN(4) short c GNU_ALIGN(4); >} GNU_ALIGN(1); > >MS_ALIGN(1) struct sP8_1 { > char a; > unsigned char b; > MS_ALIGN(8) short c GNU_ALIGN(8); >} GNU_ALIGN(1); > >#define chk(STR, FIELD, EXPECT) \ > { struct STR a##STR; \ > if (!check_ptr (&a##STR, &a##STR.FIELD, EXPECT)) \ > printf (" %s (%s - .) == %d: failed\n", "a" #STR, #FIELD, EXPECT); \ > } > >#define siz(STR, SZ) \ > if (sizeof (struct STR) != SZ) \ > printf ("sizeof(%s): is %d and not equal to expected %d\n", #STR, (int) sizeof (struct STR), SZ); \ > >int main() >{ > chk(sP1_1, c, 2); > siz(sP1_1, 4); > chk(sP2_1, c, 2); > siz(sP2_1, 4); > chk(sP4_1, c, 4); > siz(sP4_1, 8); > chk(sP8_1, c, 8); > siz(sP8_1, 16); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 52991
:
29119
|
29121
| 29122 |
43522