[msvcrt] properly align struct _stati64's st_size

Damjan Jovanovic damjan.jov at gmail.com
Mon Feb 5 00:42:23 CST 2007


On 2/3/07, Dmitry Timoshkov <dmitry at codeweavers.com> wrote:
> "Damjan Jovanovic" <damjan.jov at gmail.com> wrote:
>
> > In wine's struct _stati64, st_size has an offset of 20 bytes from the
> > beginning of the struct, unlike mingw's and Window's 24. This breaks
> > Java 1.4.x pretty badly, it dies on startup complaining about a
> > truncated class file (#2953). Using #include <pshpack8.h> and #include
> > <pshpop8.h> around the struct didn't help, so a padding field was used
> > instead.
>
> Does the approach used in winbase.h in declaration of WIN32_STREAM_ID to
> align the Size field help?
>
> #include <pshpack8.h>
> typedef struct _WIN32_STREAM_ID {
>     DWORD   dwStreamId;
>     DWORD   dwStreamAttributes;
>     LARGE_INTEGER DECLSPEC_ALIGN(8) Size;
>     DWORD   dwStreamNameSize;
>     WCHAR   cStreamName[ANYSIZE_ARRAY];
> } WIN32_STREAM_ID, *LPWIN32_STREAM_ID;
> #include <poppack.h>

That doesn't help.

I heard somewhere GCC up to version 4.1.12 or so didn't align some
things properly (I'm using 4.0.3). Since mingw aligns it properly with
the same declaration as wine and it uses GCC 3.4.4, maybe it's a GCC
bug.

> > +static void test_stat( void )
> > +{
> > +    int offset = offsetof(struct _stati64, st_size);
> > +    ok(offset == 24, "struct _stati64's st_size is misaligned, got %d, expected 24\n", offset);
> > +}
>
> This should be a part of auto generated header tests. Have a look at
> dlls/*/tests/generated.c files.

Thanks.

> --
> Dmitry.

Damjan



More information about the wine-devel mailing list