Fix the layout of bitfields
Francois Gouget
fgouget at free.fr
Thu Aug 19 13:10:25 CDT 2004
On Thu, 19 Aug 2004, Robert Shearman wrote:
> Francois Gouget wrote:
>
> >gcc and msvc deal with bitfields very differently.
> >
> Is MIDL_STUB_MESSAGE in wine/include/rpcndr.h ok? I assume so because of
> the fUnused at the end of the bitfields:
>
> int fInDontFree:1;
> int fDontCallFreeInst:1;
> int fInOnlyParam:1;
> int fHasReturn:1;
> int fHasExtensions:1;
> int fHasNewCorrDesc:1;
> int fUnused:10;
No, the fUnused field is not enough.
You have to compare the total number of bits in the bitfield with the
size of the underlying integer. Here we have a total of 16 bits and the
underlying type is an 'int' which is 32 bits wide. So gcc will allocate
2 bytes, just enough for 16 bits, while MSVC will allocate 4 bytes, i.e.
as much as specified by the underlying integer.
What saves us here, I think, is that the packing is 4 bytes, not 1 byte.
So the layout should be the same anyway.
However MS must have had similar issues because I see that they added an
fUnused2 field that makes up the remaining 16 bits...
Also this shows we could use generated tests for the rpcndr types. I
guess these should go in dlls/rpcrt4/tests?
Changelog:
* include/rpcndr.h
Add missing field to MIDL_STUB_MESSAGE.
Index: include/rpcndr.h
===================================================================
RCS file: /var/cvs/wine/include/rpcndr.h,v
retrieving revision 1.24
diff -u -r1.24 rpcndr.h
--- include/rpcndr.h 22 Mar 2004 22:58:04 -0000 1.24
+++ include/rpcndr.h 19 Aug 2004 18:04:26 -0000
@@ -187,6 +187,7 @@
int fHasExtensions:1;
int fHasNewCorrDesc:1;
int fUnused:10;
+ int fUnused2:16;
unsigned long dwDestContext;
void *pvDestContext;
NDR_SCONTEXT *SavedContextHandles;
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
War doesn't determine who's right. War determines who's left.
More information about the wine-patches
mailing list