Added wine_memcpy_unaligned function to avoid gcc memcpy

optimizations.
This commit is contained in:
Alexandre Julliard 2002-10-18 00:27:38 +00:00
parent b26206dd8a
commit 9534d4f0fe
3 changed files with 25 additions and 6 deletions

View File

@ -190,7 +190,7 @@ int mkstemp(char *tmpfn);
#endif /* HAVE_MKSTEMP */
#ifndef HAVE_MEMMOVE
void *memmove(void *dest, const void *src, unsigned int len);
void *memmove(void *dest, const void *src, size_t len);
#endif /* !defined(HAVE_MEMMOVE) */
#ifndef HAVE_PREAD
@ -229,6 +229,12 @@ int strcasecmp(const char *str1, const char *str2);
int usleep (unsigned int useconds);
#endif /* !defined(HAVE_USLEEP) */
#ifdef __i386__
#define wine_memcpy_unaligned memcpy
#else
extern void *wine_memcpy_unaligned( void *dst, const void *src, size_t size );
#endif /* __i386__ */
/* Interlocked functions */
#if defined(__i386__) && defined(__GNUC__)

View File

@ -94,7 +94,7 @@ int usleep (unsigned int useconds)
* memmove
*/
#ifndef HAVE_MEMMOVE
void *memmove( void *dest, const void *src, unsigned int len )
void *memmove( void *dest, const void *src, size_t len )
{
register char *dst = dest;
@ -666,6 +666,19 @@ char *gcvt (double number, size_t ndigit, char *buff)
#endif /* HAVE_ECVT */
#ifndef wine_memcpy_unaligned
/***********************************************************************
* wine_memcpy_unaligned
*
* This is necessary to defeat optimizations of memcpy by gcc.
*/
void *wine_memcpy_unaligned( void *dst, const void *src, size_t size )
{
return memcpy( dst, src, size );
}
#endif
/***********************************************************************
* interlocked functions
*/

View File

@ -277,7 +277,7 @@ BOOL NE_InitResourceHandler( HMODULE16 hModule )
while(pTypeInfo->type_id)
{
memcpy( &pTypeInfo->resloader, &DefResourceHandlerProc, sizeof(FARPROC16) );
wine_memcpy_unaligned( &pTypeInfo->resloader, &DefResourceHandlerProc, sizeof(FARPROC16) );
pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
}
return TRUE;
@ -303,8 +303,8 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId,
{
if (!(pTypeInfo = NE_FindTypeSection( pResTab, pTypeInfo, typeId )))
break;
memcpy( &prevHandler, &pTypeInfo->resloader, sizeof(FARPROC16) );
memcpy( &pTypeInfo->resloader, &resourceHandler, sizeof(FARPROC16) );
wine_memcpy_unaligned( &prevHandler, &pTypeInfo->resloader, sizeof(FARPROC16) );
wine_memcpy_unaligned( &pTypeInfo->resloader, &resourceHandler, sizeof(FARPROC16) );
pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
}
return prevHandler;
@ -507,7 +507,7 @@ HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc )
else
{
FARPROC16 resloader;
memcpy( &resloader, &pTypeInfo->resloader, sizeof(FARPROC16) );
wine_memcpy_unaligned( &resloader, &pTypeInfo->resloader, sizeof(FARPROC16) );
if ( resloader && resloader != DefResourceHandlerProc )
pNameInfo->handle = NE_CallTo16_word_www(
resloader, pNameInfo->handle, pModule->self, hRsrc );