Temporary fix to trying to put a pointer in a DWORD

Vincent Béron vberon at mecano.gme.usherb.ca
Sun Oct 17 10:31:25 CDT 2004


Le dim 17/10/2004 à 01:24, Shachar Shemesh a écrit :
> Vincent Béron wrote:
> 
> >Le sam 16/10/2004 à 23:54, Dmitry Timoshkov a écrit :
> >  
> >
> >>"Vincent Béron" <vberon at mecano.gme.usherb.ca> wrote:
> >>
> >>    
> >>
> >>>We try to put a pointer in a DWORD in a static initialization of
> >>>CRITICAL_SECTION_DEBUGs. Of course it doesn't work on Win64. We'll have
> >>>to find a better solution though.
> >>>      
> >>>
> >>Another way to fix it is to use full 'DWORD Spare[2]' to store a pointer
> >>on Win64 and leave it as it is now for Win32.
> >>    
> >>
> >
> >I tried, but since it's a static initialization you don't have access to
> >& (addessof), so you can't put the high part in one and the low part in
> >the other. Maybe with a union, but then we'd extend a MS type.
> >
> >Vincent
> >  
> >
> How about this, then?
> 
> -- 
> Shachar Shemesh
> Lingnu Open Source Consulting ltd.
> http://www.lingnu.com/
> 
> ----
> 

> Index: dlls/dinput/keyboard.c
> ===================================================================
> RCS file: /home/sun/sources/cvs/wine/dlls/dinput/keyboard.c,v
> retrieving revision 1.9
> diff -u -r1.9 keyboard.c
> --- dlls/dinput/keyboard.c	21 Sep 2004 20:04:37 -0000	1.9
> +++ dlls/dinput/keyboard.c	17 Oct 2004 05:23:04 -0000
> @@ -75,11 +75,12 @@
>  static BYTE DInputKeyState[256]; /* array for 'GetDeviceState' */
>  
>  static CRITICAL_SECTION keyboard_crit;
> +static const char * const critsect_debug_strid = __FILE__ ": keyboard_crit";
>  static CRITICAL_SECTION_DEBUG critsect_debug =
>  {
>      0, 0, &keyboard_crit,
>      { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
> -      0, 0, { 0, (DWORD)(__FILE__ ": keyboard_crit") }
> +      0, 0, { HIDWORD(critsect_debug_strid), LODDWORD(critsect_debug_strid) }

Besides the fact that HIDWORD and LODWORD (typo in LODDWORD) do not
exist, it looks fine as long as you don't actually compile it.

Writing those two and compiling yields the error "initializer element is
not constant".

Vincent





More information about the wine-devel mailing list