Commit 09570eda authored by Patrik Stridvall's avatar Patrik Stridvall Committed by Alexandre Julliard

MSVC compatibility fixes.

parent 42c74d64
......@@ -23,9 +23,10 @@
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pwd.h>
#ifdef HAVE_PWD_H
# include <pwd.h>
#endif
#include "winbase.h"
#include "windef.h"
......@@ -48,15 +49,17 @@ GetUserNameA( LPSTR lpszName, LPDWORD lpSize )
size_t len;
char *name;
#ifdef HAVE_GETPWUID
struct passwd *pwd = getpwuid( getuid() );
if (!pwd)
{
name = pwd ? pwd->pw_name : NULL;
#else
name = getenv("USER");
#endif
if (!name) {
ERR("Username lookup failed: %s\n", strerror(errno));
return 0;
}
name = pwd->pw_name;
/* We need to include the null character when determining the size of the buffer. */
len = strlen(name) + 1;
if (len > *lpSize)
......
......@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "winbase.h"
#include "winreg.h"
......
......@@ -25,7 +25,6 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
#include "wine/debug.h"
......
......@@ -26,7 +26,6 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
......
......@@ -31,7 +31,10 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_INTTYPES_H
# include <sys/inttypes.h>
......@@ -101,7 +104,7 @@ void *memmove( void *dest, const void *src, unsigned int len )
memcpy( dst, src, len );
}
/* Otherwise do it the hard way (FIXME: could do better than this) */
else if (dst < src)
else if (dst < (char *)src)
{
while (len--) *dst++ = *((char *)src)++;
}
......@@ -668,6 +671,8 @@ char *gcvt (double number, size_t ndigit, char *buff)
*/
#ifdef __i386__
#ifdef __GNUC__
__ASM_GLOBAL_FUNC(interlocked_cmpxchg,
"movl 12(%esp),%eax\n\t"
"movl 8(%esp),%ecx\n\t"
......@@ -696,6 +701,54 @@ __ASM_GLOBAL_FUNC(interlocked_xchg_add,
"lock; xaddl %eax,(%edx)\n\t"
"ret");
#elif defined(_MSC_VER)
__declspec(naked) long interlocked_cmpxchg( long *dest, long xchg, long compare )
{
__asm mov eax, 12[esp];
__asm mov ecx, 8[esp];
__asm mov edx, 4[esp];
__asm lock cmpxchg [edx], ecx;
__asm ret;
}
__declspec(naked) void *interlocked_cmpxchg_ptr( void **dest, void *xchg, void *compare )
{
__asm mov eax, 12[esp];
__asm mov ecx, 8[esp];
__asm mov edx, 4[esp];
__asm lock cmpxchg [edx], ecx;
__asm ret;
}
__declspec(naked) long interlocked_xchg( long *dest, long val )
{
__asm mov eax, 8[esp];
__asm mov edx, 4[esp];
__asm lock xchg [edx], eax;
__asm ret;
}
__declspec(naked) void *interlocked_xchg_ptr( void **dest, void *val )
{
__asm mov eax, 8[esp];
__asm mov edx, 4[esp];
__asm lock xchg [edx], eax;
__asm ret;
}
__declspec(naked) long interlocked_xchg_add( long *dest, long incr )
{
__asm mov eax, 8[esp];
__asm mov edx, 4[esp];
__asm lock xadd [edx], eax;
__asm ret;
}
#else
# error You must implement the interlocked* functions for your compiler
#endif
#elif defined(__powerpc__)
void* interlocked_cmpxchg_ptr( void **dest, void* xchg, void* compare)
{
......
......@@ -44,7 +44,7 @@ inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long
if (ISV86(context)) return PTR_REAL_TO_LIN( seg, off );
if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
if (!long_addr) off = LOWORD(off);
return MapSL( MAKESEGPTR( seg, 0 ) ) + off;
return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
}
inline static void *get_stack( CONTEXT86 *context )
......@@ -54,7 +54,7 @@ inline static void *get_stack( CONTEXT86 *context )
if (IS_SELECTOR_SYSTEM(context->SegSs))
return (void *)context->Esp;
if (IS_SELECTOR_32BIT(context->SegSs))
return MapSL( MAKESEGPTR( context->SegSs, 0 ) ) + context->Esp;
return (char *) MapSL( MAKESEGPTR( context->SegSs, 0 ) ) + context->Esp;
return MapSL( MAKESEGPTR( context->SegSs, LOWORD(context->Esp) ) );
}
......@@ -249,7 +249,7 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
if (((seg & 7) != 7) || IS_SELECTOR_FREE(seg)) return NULL;
if (wine_ldt_copy.limit[seg >> 3] < (base + (index << ss))) return NULL;
return MapSL( MAKESEGPTR( seg, 0 ) ) + base + (index << ss);
return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + base + (index << ss);
#undef GET_VAL
}
......
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