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); ...@@ -190,7 +190,7 @@ int mkstemp(char *tmpfn);
#endif /* HAVE_MKSTEMP */ #endif /* HAVE_MKSTEMP */
#ifndef HAVE_MEMMOVE #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) */ #endif /* !defined(HAVE_MEMMOVE) */
#ifndef HAVE_PREAD #ifndef HAVE_PREAD
...@@ -229,6 +229,12 @@ int strcasecmp(const char *str1, const char *str2); ...@@ -229,6 +229,12 @@ int strcasecmp(const char *str1, const char *str2);
int usleep (unsigned int useconds); int usleep (unsigned int useconds);
#endif /* !defined(HAVE_USLEEP) */ #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 */ /* Interlocked functions */
#if defined(__i386__) && defined(__GNUC__) #if defined(__i386__) && defined(__GNUC__)
......
...@@ -94,7 +94,7 @@ int usleep (unsigned int useconds) ...@@ -94,7 +94,7 @@ int usleep (unsigned int useconds)
* memmove * memmove
*/ */
#ifndef HAVE_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; register char *dst = dest;
...@@ -666,6 +666,19 @@ char *gcvt (double number, size_t ndigit, char *buff) ...@@ -666,6 +666,19 @@ char *gcvt (double number, size_t ndigit, char *buff)
#endif /* HAVE_ECVT */ #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 * interlocked functions
*/ */
......
...@@ -277,7 +277,7 @@ BOOL NE_InitResourceHandler( HMODULE16 hModule ) ...@@ -277,7 +277,7 @@ BOOL NE_InitResourceHandler( HMODULE16 hModule )
while(pTypeInfo->type_id) while(pTypeInfo->type_id)
{ {
memcpy( &pTypeInfo->resloader, &DefResourceHandlerProc, sizeof(FARPROC16) ); wine_memcpy_unaligned( &pTypeInfo->resloader, &DefResourceHandlerProc, sizeof(FARPROC16) );
pTypeInfo = NEXT_TYPEINFO(pTypeInfo); pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
} }
return TRUE; return TRUE;
...@@ -303,8 +303,8 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId, ...@@ -303,8 +303,8 @@ FARPROC16 WINAPI SetResourceHandler16( HMODULE16 hModule, LPCSTR typeId,
{ {
if (!(pTypeInfo = NE_FindTypeSection( pResTab, pTypeInfo, typeId ))) if (!(pTypeInfo = NE_FindTypeSection( pResTab, pTypeInfo, typeId )))
break; break;
memcpy( &prevHandler, &pTypeInfo->resloader, sizeof(FARPROC16) ); wine_memcpy_unaligned( &prevHandler, &pTypeInfo->resloader, sizeof(FARPROC16) );
memcpy( &pTypeInfo->resloader, &resourceHandler, sizeof(FARPROC16) ); wine_memcpy_unaligned( &pTypeInfo->resloader, &resourceHandler, sizeof(FARPROC16) );
pTypeInfo = NEXT_TYPEINFO(pTypeInfo); pTypeInfo = NEXT_TYPEINFO(pTypeInfo);
} }
return prevHandler; return prevHandler;
...@@ -507,7 +507,7 @@ HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc ) ...@@ -507,7 +507,7 @@ HGLOBAL16 NE_LoadResource( NE_MODULE *pModule, HRSRC16 hRsrc )
else else
{ {
FARPROC16 resloader; FARPROC16 resloader;
memcpy( &resloader, &pTypeInfo->resloader, sizeof(FARPROC16) ); wine_memcpy_unaligned( &resloader, &pTypeInfo->resloader, sizeof(FARPROC16) );
if ( resloader && resloader != DefResourceHandlerProc ) if ( resloader && resloader != DefResourceHandlerProc )
pNameInfo->handle = NE_CallTo16_word_www( pNameInfo->handle = NE_CallTo16_word_www(
resloader, pNameInfo->handle, pModule->self, hRsrc ); 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