Re: Alexandre Julliard : ntdll: Fixed a compiler warning for size_t/ unsigned int mismatch.
On Fri, 9 Mar 2007, Alexandre Julliard wrote: [...]
void * __cdecl _lfind( const void *key, const void *base, unsigned int *nmemb, - unsigned int size, int(*compar)(const void *, const void *) ) + size_t size, int(*compar)(const void *, const void *) ) { - return lfind( key, base, nmemb, size, compar ); + size_t n = *nmemb; + return lfind( key, base, &n, size, compar ); }
The problem is that Microsoft's _lfind() takes an 'unsigned int' and not a size_t. Or, more precisely, the msvcrt one declared in search.h does. There's no official prototype for the ntdll implementation that I know of, but I'd expect it to have the same prototype. So my understanding is that replacing this parameter type with a size_t could be a problem on 64bit systems. -- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ Stolen from an Internet user: "f u cn rd ths, u cn gt a gd jb n cmptr prgrmmng !"
Francois Gouget <fgouget(a)free.fr> writes:
On Fri, 9 Mar 2007, Alexandre Julliard wrote: [...]
void * __cdecl _lfind( const void *key, const void *base, unsigned int *nmemb, - unsigned int size, int(*compar)(const void *, const void *) ) + size_t size, int(*compar)(const void *, const void *) ) { - return lfind( key, base, nmemb, size, compar ); + size_t n = *nmemb; + return lfind( key, base, &n, size, compar ); }
The problem is that Microsoft's _lfind() takes an 'unsigned int' and not a size_t. Or, more precisely, the msvcrt one declared in search.h does. There's no official prototype for the ntdll implementation that I know of, but I'd expect it to have the same prototype.
So my understanding is that replacing this parameter type with a size_t could be a problem on 64bit systems.
Yes, that's why I left *nmemb as an unsigned int. For parameters passed by value it doesn't matter, the compiler will expand things as needed. -- Alexandre Julliard julliard(a)winehq.org
On Sat, 10 Mar 2007, Alexandre Julliard wrote:
Francois Gouget <fgouget(a)free.fr> writes:
On Fri, 9 Mar 2007, Alexandre Julliard wrote: [...]
void * __cdecl _lfind( const void *key, const void *base, unsigned int *nmemb, - unsigned int size, int(*compar)(const void *, const void *) ) + size_t size, int(*compar)(const void *, const void *) ) { - return lfind( key, base, nmemb, size, compar ); + size_t n = *nmemb; + return lfind( key, base, &n, size, compar ); }
The problem is that Microsoft's _lfind() takes an 'unsigned int' and not a size_t. Or, more precisely, the msvcrt one declared in search.h does. There's no official prototype for the ntdll implementation that I know of, but I'd expect it to have the same prototype.
So my understanding is that replacing this parameter type with a size_t could be a problem on 64bit systems.
Yes, that's why I left *nmemb as an unsigned int. For parameters passed by value it doesn't matter, the compiler will expand things as needed.
Even so I think we can get a problem for the Win64 case: on Windows the size parameter will still be 32bits since it's an 'unsigned int'. So 64bit Windows applications will generate code that passes a 32bit size to _lfind(). But Wine's implementation will expect the size parameter to be 64bit since it's a size_t (which is 64bits in both Windows and Unix) and thus it will try to pop too much stuff off the stack. -- Francois Gouget <fgouget(a)free.fr> http://fgouget.free.fr/ It really galls me that most of the computer power in the world is wasted on screen savers. Chris Caldwell from the GIMPS project http://www.mersenne.org/prime.htm
Francois Gouget <fgouget(a)free.fr> writes:
Even so I think we can get a problem for the Win64 case: on Windows the size parameter will still be 32bits since it's an 'unsigned int'. So 64bit Windows applications will generate code that passes a 32bit size to _lfind(). But Wine's implementation will expect the size parameter to be 64bit since it's a size_t (which is 64bits in both Windows and Unix) and thus it will try to pop too much stuff off the stack.
Parameters are always 64-bit on a 64-bit platform (and they are usually passed by registers anyway...) -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alexandre Julliard -
Francois Gouget