Commit 9534d4f0 authored by Alexandre Julliard's avatar Alexandre Julliard

Added wine_memcpy_unaligned function to avoid gcc memcpy

optimizations.
parent b26206dd
......@@ -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__)
......
......@@ -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
*/
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment