Merge CRT changes from cmake branch (mainly MSVC compilation fixes)

svn path=/trunk/; revision=50647
This commit is contained in:
Timo Kreuzer 2011-02-10 11:35:05 +00:00
parent 5c40e3e852
commit f24d76dc84
26 changed files with 154 additions and 9 deletions

View file

@ -63,6 +63,10 @@ typedef struct _rtti_object_locator
#define THISCALL(func) __thiscall_ ## func #define THISCALL(func) __thiscall_ ## func
#define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func) #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
#ifdef _MSC_VER
#include <internal/wine_msc.h>
#else
#define DEFINE_THISCALL_WRAPPER(func,args) \ #define DEFINE_THISCALL_WRAPPER(func,args) \
extern void THISCALL(func)(void); \ extern void THISCALL(func)(void); \
__ASM_GLOBAL_FUNC(__thiscall_ ## func, \ __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
@ -70,6 +74,8 @@ typedef struct _rtti_object_locator
"pushl %ecx\n\t" \ "pushl %ecx\n\t" \
"pushl %eax\n\t" \ "pushl %eax\n\t" \
"jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
#endif /* _MSC_VER */
#else /* __i386__ */ #else /* __i386__ */
#define THISCALL(func) func #define THISCALL(func) func
@ -658,6 +664,7 @@ void * __stdcall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int fl
/* vtables */ /* vtables */
#ifdef __GNUC__
#ifdef _WIN64 #ifdef _WIN64
#define __ASM_VTABLE(name,funcs) \ #define __ASM_VTABLE(name,funcs) \
@ -701,6 +708,16 @@ __ASM_EXCEPTION_VTABLE(__non_rtti_object)
#ifndef __GNUC__ #ifndef __GNUC__
} }
#endif #endif
#endif
#ifdef _MSC_VER
#pragma message ("HAXX!")
const vtable_ptr MSVCRT_exception_vtable;
const vtable_ptr MSVCRT_bad_typeid_vtable;
const vtable_ptr MSVCRT_bad_cast_vtable;
const vtable_ptr MSVCRT___non_rtti_object_vtable;
const vtable_ptr MSVCRT_type_info_vtable;
#endif
/* Static RTTI for exported objects */ /* Static RTTI for exported objects */

View file

@ -45,6 +45,9 @@ static inline void *call_ebp_func( void *func, void *ebp )
{ {
void *ret; void *ret;
int dummy; int dummy;
#ifdef _MSC_VER
#pragma message ("call_ebp_func is unimplemented for MSC")
#else
__asm__ __volatile__ ("pushl %%ebx\n\t" __asm__ __volatile__ ("pushl %%ebx\n\t"
"pushl %%ebp\n\t" "pushl %%ebp\n\t"
"movl %4,%%ebp\n\t" "movl %4,%%ebp\n\t"
@ -53,6 +56,7 @@ static inline void *call_ebp_func( void *func, void *ebp )
"popl %%ebx" "popl %%ebx"
: "=a" (ret), "=S" (dummy), "=D" (dummy) : "=a" (ret), "=S" (dummy), "=D" (dummy)
: "0" (func), "1" (ebp) : "ecx", "edx", "memory" ); : "0" (func), "1" (ebp) : "ecx", "edx", "memory" );
#endif
return ret; return ret;
} }
@ -60,6 +64,9 @@ static inline void *call_ebp_func( void *func, void *ebp )
static inline void call_copy_ctor( void *func, void *this, void *src, int has_vbase ) static inline void call_copy_ctor( void *func, void *this, void *src, int has_vbase )
{ {
TRACE( "calling copy ctor %p object %p src %p\n", func, this, src ); TRACE( "calling copy ctor %p object %p src %p\n", func, this, src );
#ifdef _MSC_VER
#pragma message ("call_copy_ctor is unimplemented for MSC")
#else
if (has_vbase) if (has_vbase)
/* in that case copy ctor takes an extra bool indicating whether to copy the base class */ /* in that case copy ctor takes an extra bool indicating whether to copy the base class */
__asm__ __volatile__("pushl $1; pushl %2; call *%0" __asm__ __volatile__("pushl $1; pushl %2; call *%0"
@ -67,19 +74,28 @@ static inline void call_copy_ctor( void *func, void *this, void *src, int has_vb
else else
__asm__ __volatile__("pushl %2; call *%0" __asm__ __volatile__("pushl %2; call *%0"
: : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" ); : : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" );
#endif
} }
/* call the destructor of the exception object */ /* call the destructor of the exception object */
static inline void call_dtor( void *func, void *object ) static inline void call_dtor( void *func, void *object )
{ {
#ifdef _MSC_VER
#pragma message ("call_dtor is unimplemented for MSC")
#else
__asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" ); __asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" );
#endif
} }
/* continue execution to the specified address after exception is caught */ /* continue execution to the specified address after exception is caught */
static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr ) static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{ {
#ifdef _MSC_VER
#pragma message ("continue_after_catch is unimplemented for MSC")
#else
__asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1" __asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1"
: : "r" (frame), "a" (addr) ); : : "r" (frame), "a" (addr) );
#endif
for (;;) ; /* unreached */ for (;;) ; /* unreached */
} }
@ -415,6 +431,14 @@ DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame
*/ */
extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch ); PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch );
#ifdef _MSC_VER
#pragma message ("__CxxFrameHandler is unimplemented for MSC")
DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch )
{
return 0;
}
#else
__ASM_GLOBAL_FUNC( __CxxFrameHandler, __ASM_GLOBAL_FUNC( __CxxFrameHandler,
"pushl $0\n\t" /* nested_trylevel */ "pushl $0\n\t" /* nested_trylevel */
__ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t")
@ -434,7 +458,7 @@ __ASM_GLOBAL_FUNC( __CxxFrameHandler,
"add $28,%esp\n\t" "add $28,%esp\n\t"
__ASM_CFI(".cfi_adjust_cfa_offset -28\n\t") __ASM_CFI(".cfi_adjust_cfa_offset -28\n\t")
"ret" ) "ret" )
#endif
/********************************************************************* /*********************************************************************
* __CxxLongjmpUnwind (MSVCRT.@) * __CxxLongjmpUnwind (MSVCRT.@)

View file

@ -96,6 +96,57 @@ static inline int call_unwind_func( int (*func)(void), void *ebp )
: "ecx", "edx", "memory" ); : "ecx", "edx", "memory" );
return ret; return ret;
} }
#elif defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4731) // Don't complain about changing ebp
void __inline call_finally_block( void *code_block, void *base_ptr )
{
__asm
{
mov eax, code_block
mov ebp, base_ptr
call [eax]
}
}
int __inline call_filter( int (*func)(PEXCEPTION_POINTERS), void *arg, void *_ebp )
{
int _ret;
__asm
{
push ebp
mov eax, arg
push eax
mov ebp, _ebp
mov eax, func
call [eax]
mov _ret, eax
pop ebp
pop ebp
}
return _ret;
}
int __inline call_unwind_func( int (*func)(void), void *_ebp )
{
int _ret;
__asm
{
push ebp
push ebx
push esi
push edi
mov ebp, _ebp
call dword ptr [func]
mov _ret, eax
pop edi
pop esi
pop ebx
pop ebp
}
return _ret;
}
#pragma warning(pop)
#endif #endif
static DWORD MSVCRT_nested_handler(PEXCEPTION_RECORD rec, static DWORD MSVCRT_nested_handler(PEXCEPTION_RECORD rec,

View file

@ -127,8 +127,6 @@ int access_dirW(const wchar_t *_path);
int _isnanl(long double x); int _isnanl(long double x);
int _isinfl(long double x); int _isinfl(long double x);
int _isnan(double x);
int _isinf(double x);
/* Flags for the iobuf structure (for reference) */ /* Flags for the iobuf structure (for reference) */
#if 0 #if 0

View file

@ -20,9 +20,9 @@ FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
ULargeInt.HighPart = FileTime->dwHighDateTime; ULargeInt.HighPart = FileTime->dwHighDateTime;
ULargeInt.QuadPart -= DIFFTIME; ULargeInt.QuadPart -= DIFFTIME;
time = ULargeInt.QuadPart / 10000000; time = (time_t)(ULargeInt.QuadPart / 10000000);
if (millitm) if (millitm)
*millitm = (ULargeInt.QuadPart % 10000000) / 10000; *millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000);
return time; return time;
} }

View file

@ -1,5 +1,10 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#ifdef _MSC_VER
#pragma warning(disable: 4164)
#pragma function(abs)
#endif
/* /*
* @implemented * @implemented
*/ */

View file

@ -21,6 +21,9 @@
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#pragma function(acos)
#endif
double acos(double __x) double acos(double __x)
{ {

View file

@ -21,6 +21,9 @@
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#pragma function(asin)
#endif
double asin(double __x) double asin(double __x)
{ {

View file

@ -3,7 +3,9 @@
* This file is part of the w64 mingw-runtime package. * This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/ */
#define cosf _dummy_cosf
#include <math.h> #include <math.h>
#undef cosf
float cosf(float _X) float cosf(float _X)
{ {

View file

@ -1,6 +1,9 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#pragma function(cosh)
#endif
/* /*
* @implemented * @implemented

View file

@ -1,5 +1,10 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#ifdef _MSC_VER
#pragma warning(disable: 4164)
#pragma function(labs)
#endif
/* /*
* @implemented * @implemented
*/ */

View file

@ -3,7 +3,9 @@
* This file is part of the w64 mingw-runtime package. * This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/ */
#define logf _dummy_logf
#include <math.h> #include <math.h>
#undef logf
float logf(float _X) float logf(float _X)
{ {

View file

@ -9,8 +9,9 @@
* is preserved. * is preserved.
* ==================================================== * ====================================================
*/ */
#define modfl _dummy_modfl
#include <precomp.h> #include <precomp.h>
#undef modfl
//static const double one = 1.0; //static const double one = 1.0;

View file

@ -3,7 +3,8 @@
* This file is part of the w64 mingw-runtime package. * This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/ */
#include <math.h>
double __cdecl pow(double x, double y);
float powf(float x, float y) float powf(float x, float y)
{ {

View file

@ -3,7 +3,9 @@
* This file is part of the w64 mingw-runtime package. * This file is part of the w64 mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package. * No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/ */
#define sinf _dummy_sinf
#include <math.h> #include <math.h>
#undef sinf
float sinf(float _X) float sinf(float _X)
{ {

View file

@ -1,6 +1,10 @@
/* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#pragma function(sinh)
#endif
/* /*
* @implemented * @implemented
*/ */

View file

@ -2,6 +2,10 @@
#include <math.h> #include <math.h>
#ifdef _MSC_VER
#pragma function(tanh)
#endif
/* /*
* @implemented * @implemented
*/ */

View file

@ -4,6 +4,11 @@
#include <string.h> #include <string.h>
#ifdef _MSC_VER
#pragma warning(disable: 4164)
#pragma function(memcmp)
#endif
int memcmp(const void *s1, const void *s2, size_t n) int memcmp(const void *s1, const void *s2, size_t n)
{ {
if (n != 0) { if (n != 0) {

View file

@ -32,7 +32,7 @@ void _assert(const char *exp, const char *file, unsigned line)
/* Get MessageBoxA function pointer */ /* Get MessageBoxA function pointer */
hmodUser32 = LoadLibrary("user32.dll"); hmodUser32 = LoadLibrary("user32.dll");
pMessageBoxA = GetProcAddress(hmodUser32, "MessageBoxA"); pMessageBoxA = (PVOID)GetProcAddress(hmodUser32, "MessageBoxA");
if (!pMessageBoxA) if (!pMessageBoxA)
{ {
abort(); abort();

View file

@ -10,6 +10,10 @@
#include <stdlib.h> #include <stdlib.h>
#ifdef _MSC_VER
#pragma function(_rotr, _rotl, _rotr, _lrotl, _lrotr)
#endif
unsigned int _rotr( unsigned int value, int shift ); unsigned int _rotr( unsigned int value, int shift );
/* /*
* @implemented * @implemented

View file

@ -10,6 +10,9 @@
#if defined(__GNUC__) && !defined(__clang__) #if defined(__GNUC__) && !defined(__clang__)
#define __int64 long long #define __int64 long long
#elif defined(_MSC_VER)
#pragma warning(disable: 4164)
#pragma function(_strset)
#endif #endif
#ifdef _WIN64 #ifdef _WIN64
@ -49,3 +52,4 @@ char* _strset(char* szToFill, int szFill)
} }
return t; return t;
} }

View file

@ -47,6 +47,10 @@
#undef vprintf #undef vprintf
#undef vwprintf #undef vwprintf
#ifdef _MSC_VER
#pragma function(_wcsset)
#endif
#ifndef _LIBCNT_ #ifndef _LIBCNT_
/********************************************************************* /*********************************************************************
* _wcsdup (MSVCRT.@) * _wcsdup (MSVCRT.@)

View file

@ -7,6 +7,7 @@
*/ */
#define MINGW_HAS_SECURE_API 1 #define MINGW_HAS_SECURE_API 1
#define RC_INVOKED 1 // to prevent inline functions
#include <tchar.h> #include <tchar.h>
#include <time.h> #include <time.h>
#include "bitsfixup.h" #include "bitsfixup.h"

View file

@ -6,6 +6,7 @@
* PROGRAMERS: Timo Kreuzer * PROGRAMERS: Timo Kreuzer
*/ */
#include <precomp.h> #include <precomp.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <time.h> #include <time.h>
#include <sys/utime.h> #include <sys/utime.h>
#include "bitsfixup.h" #include "bitsfixup.h"

View file

@ -7,6 +7,7 @@
*/ */
#include <precomp.h> #include <precomp.h>
#include <tchar.h> #include <tchar.h>
#define RC_INVOKED 1 // to prevent inline functions
#include <sys/utime.h> #include <sys/utime.h>
#include "bitsfixup.h" #include "bitsfixup.h"