[msvcrt] properly align struct _stati64's st_size

Dmitry Timoshkov dmitry at codeweavers.com
Sat Feb 3 09:15:11 CST 2007


"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>

> +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.

-- 
Dmitry.



More information about the wine-devel mailing list