Re: W32API fixes + ddk/kbdmou.h

Filip Navara <xnavara-VIXq6x/[email protected]> Wed, 12 May 2004 12:05:23 +0200
Newsgroups gmane.comp.gnu.mingw.patches
Message-ID <[email protected]>
Hi!

Danny Smith wrote:

>Why is this necessary? Doesn't long long member force 8 byte alignment anyway?
>
>-typedef union _LARGE_INTEGER {
>+typedef union DECLSPEC_ALIGN(8) _LARGE_INTEGER {
>
>  
>
I don't know why, but the LONGLONG member doesn't force the alignment.
Even this simple example shows it:
    #include <windows.h>
    #include <stdio.h>

    int main()
    {
        printf("Alignment of LONGLONG: %x\n", __alignof(LONGLONG));
        printf("Alignment of LARGE_INTEGER: %x\n", 
__alignof(LARGE_INTEGER));
        return 0;
    }

compiled with
    gcc test.c -o test.exe

produces
    Alignment of LONGLONG: 8
    Alignment of LARGE_INTEGER: 4

and this causes some structures to have wrong layout. For example 
VIDEO_PORT_CONFIG_INFO (ddk/video.h) doesn't have a ULONG "gap" between 
EmulatorAccessEntriesContext and VdmPhysicalVideoMemoryAddress.

>Anyway should do ULARGE_INTEGER as well.
>  
>
Huh, I forgot about it. Should I resubmit the patch with ULARGE_INTEGER 
marked as DECLSPEC_ALIGN(8) too?

Thanks,
Filip



-------------------------------------------------------
This SF.Net email is sponsored by Sleepycat Software
Learn developer strategies Cisco, Motorola, Ericsson & Lucent use to 
deliver higher performing products faster, at low TCO.
http://www.sleepycat.com/telcomwpreg.php?From=osdnemail3