diff --git a/reactos/lib/sdk/crt/except/cpp.c b/reactos/lib/sdk/crt/except/cpp.c index 445ce084691..158a277c9ec 100644 --- a/reactos/lib/sdk/crt/except/cpp.c +++ b/reactos/lib/sdk/crt/except/cpp.c @@ -63,6 +63,10 @@ typedef struct _rtti_object_locator #define THISCALL(func) __thiscall_ ## func #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func) + +#ifdef _MSC_VER +#include +#else #define DEFINE_THISCALL_WRAPPER(func,args) \ extern void THISCALL(func)(void); \ __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ @@ -70,6 +74,8 @@ typedef struct _rtti_object_locator "pushl %ecx\n\t" \ "pushl %eax\n\t" \ "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) +#endif /* _MSC_VER */ + #else /* __i386__ */ #define THISCALL(func) func @@ -658,6 +664,7 @@ void * __stdcall MSVCRT_type_info_vector_dtor(type_info * _this, unsigned int fl /* vtables */ +#ifdef __GNUC__ #ifdef _WIN64 #define __ASM_VTABLE(name,funcs) \ @@ -701,6 +708,16 @@ __ASM_EXCEPTION_VTABLE(__non_rtti_object) #ifndef __GNUC__ } #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 */ diff --git a/reactos/lib/sdk/crt/except/cppexcept.c b/reactos/lib/sdk/crt/except/cppexcept.c index 02a74a952e9..5ff9e2b0f39 100644 --- a/reactos/lib/sdk/crt/except/cppexcept.c +++ b/reactos/lib/sdk/crt/except/cppexcept.c @@ -45,6 +45,9 @@ static inline void *call_ebp_func( void *func, void *ebp ) { void *ret; int dummy; +#ifdef _MSC_VER +#pragma message ("call_ebp_func is unimplemented for MSC") +#else __asm__ __volatile__ ("pushl %%ebx\n\t" "pushl %%ebp\n\t" "movl %4,%%ebp\n\t" @@ -53,6 +56,7 @@ static inline void *call_ebp_func( void *func, void *ebp ) "popl %%ebx" : "=a" (ret), "=S" (dummy), "=D" (dummy) : "0" (func), "1" (ebp) : "ecx", "edx", "memory" ); +#endif 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 ) { 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) /* in that case copy ctor takes an extra bool indicating whether to copy the base class */ __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 __asm__ __volatile__("pushl %2; call *%0" : : "r" (func), "c" (this), "r" (src) : "eax", "edx", "memory" ); +#endif } /* call the destructor of the exception 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" ); +#endif } /* continue execution to the specified address after exception is caught */ 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" : : "r" (frame), "a" (addr) ); +#endif 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, 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, "pushl $0\n\t" /* nested_trylevel */ __ASM_CFI(".cfi_adjust_cfa_offset 4\n\t") @@ -434,7 +458,7 @@ __ASM_GLOBAL_FUNC( __CxxFrameHandler, "add $28,%esp\n\t" __ASM_CFI(".cfi_adjust_cfa_offset -28\n\t") "ret" ) - +#endif /********************************************************************* * __CxxLongjmpUnwind (MSVCRT.@) diff --git a/reactos/lib/sdk/crt/except/except.c b/reactos/lib/sdk/crt/except/except.c index 663677776fd..af143593527 100644 --- a/reactos/lib/sdk/crt/except/except.c +++ b/reactos/lib/sdk/crt/except/except.c @@ -96,6 +96,57 @@ static inline int call_unwind_func( int (*func)(void), void *ebp ) : "ecx", "edx", "memory" ); 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 static DWORD MSVCRT_nested_handler(PEXCEPTION_RECORD rec, diff --git a/reactos/lib/sdk/crt/include/internal/file.h b/reactos/lib/sdk/crt/include/internal/file.h index bb175fe42ea..247aa48bec9 100644 --- a/reactos/lib/sdk/crt/include/internal/file.h +++ b/reactos/lib/sdk/crt/include/internal/file.h @@ -127,8 +127,6 @@ int access_dirW(const wchar_t *_path); int _isnanl(long double x); int _isinfl(long double x); -int _isnan(double x); -int _isinf(double x); /* Flags for the iobuf structure (for reference) */ #if 0 diff --git a/reactos/lib/sdk/crt/include/internal/time.h b/reactos/lib/sdk/crt/include/internal/time.h index ad7227981fd..852bdabec4f 100644 --- a/reactos/lib/sdk/crt/include/internal/time.h +++ b/reactos/lib/sdk/crt/include/internal/time.h @@ -20,9 +20,9 @@ FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm) ULargeInt.HighPart = FileTime->dwHighDateTime; ULargeInt.QuadPart -= DIFFTIME; - time = ULargeInt.QuadPart / 10000000; + time = (time_t)(ULargeInt.QuadPart / 10000000); if (millitm) - *millitm = (ULargeInt.QuadPart % 10000000) / 10000; + *millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000); return time; } diff --git a/reactos/lib/sdk/crt/math/abs.c b/reactos/lib/sdk/crt/math/abs.c index a18f19b2666..7563c362b6c 100644 --- a/reactos/lib/sdk/crt/math/abs.c +++ b/reactos/lib/sdk/crt/math/abs.c @@ -1,5 +1,10 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#ifdef _MSC_VER +#pragma warning(disable: 4164) +#pragma function(abs) +#endif + /* * @implemented */ diff --git a/reactos/lib/sdk/crt/math/acos.c b/reactos/lib/sdk/crt/math/acos.c index ac348f87228..4f7a65069eb 100644 --- a/reactos/lib/sdk/crt/math/acos.c +++ b/reactos/lib/sdk/crt/math/acos.c @@ -21,6 +21,9 @@ #include +#ifdef _MSC_VER +#pragma function(acos) +#endif double acos(double __x) { diff --git a/reactos/lib/sdk/crt/math/asin.c b/reactos/lib/sdk/crt/math/asin.c index 5be040d1154..9a7ececcc6a 100644 --- a/reactos/lib/sdk/crt/math/asin.c +++ b/reactos/lib/sdk/crt/math/asin.c @@ -21,6 +21,9 @@ #include +#ifdef _MSC_VER +#pragma function(asin) +#endif double asin(double __x) { diff --git a/reactos/lib/sdk/crt/math/cosf.c b/reactos/lib/sdk/crt/math/cosf.c index d2329c7f254..0605582efd4 100644 --- a/reactos/lib/sdk/crt/math/cosf.c +++ b/reactos/lib/sdk/crt/math/cosf.c @@ -3,7 +3,9 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ +#define cosf _dummy_cosf #include +#undef cosf float cosf(float _X) { diff --git a/reactos/lib/sdk/crt/math/cosh.c b/reactos/lib/sdk/crt/math/cosh.c index e81fde563f8..e97651f549c 100644 --- a/reactos/lib/sdk/crt/math/cosh.c +++ b/reactos/lib/sdk/crt/math/cosh.c @@ -1,6 +1,9 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +#ifdef _MSC_VER +#pragma function(cosh) +#endif /* * @implemented diff --git a/reactos/lib/sdk/crt/math/labs.c b/reactos/lib/sdk/crt/math/labs.c index b4fc33ec0a0..51a1d80f8f9 100644 --- a/reactos/lib/sdk/crt/math/labs.c +++ b/reactos/lib/sdk/crt/math/labs.c @@ -1,5 +1,10 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ +#ifdef _MSC_VER +#pragma warning(disable: 4164) +#pragma function(labs) +#endif + /* * @implemented */ diff --git a/reactos/lib/sdk/crt/math/logf.c b/reactos/lib/sdk/crt/math/logf.c index 0da1dae909f..417250f46a8 100644 --- a/reactos/lib/sdk/crt/math/logf.c +++ b/reactos/lib/sdk/crt/math/logf.c @@ -3,7 +3,9 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ +#define logf _dummy_logf #include +#undef logf float logf(float _X) { diff --git a/reactos/lib/sdk/crt/math/modf.c b/reactos/lib/sdk/crt/math/modf.c index 8212070e2c8..c6d959293ff 100644 --- a/reactos/lib/sdk/crt/math/modf.c +++ b/reactos/lib/sdk/crt/math/modf.c @@ -9,8 +9,9 @@ * is preserved. * ==================================================== */ - +#define modfl _dummy_modfl #include +#undef modfl //static const double one = 1.0; diff --git a/reactos/lib/sdk/crt/math/powf.c b/reactos/lib/sdk/crt/math/powf.c index 55eb92a2e3f..e9cc35ad642 100644 --- a/reactos/lib/sdk/crt/math/powf.c +++ b/reactos/lib/sdk/crt/math/powf.c @@ -3,7 +3,8 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ -#include + +double __cdecl pow(double x, double y); float powf(float x, float y) { diff --git a/reactos/lib/sdk/crt/math/sinf.c b/reactos/lib/sdk/crt/math/sinf.c index 1069dcf18b7..92ffc9900d4 100644 --- a/reactos/lib/sdk/crt/math/sinf.c +++ b/reactos/lib/sdk/crt/math/sinf.c @@ -3,7 +3,9 @@ * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ +#define sinf _dummy_sinf #include +#undef sinf float sinf(float _X) { diff --git a/reactos/lib/sdk/crt/math/sinh.c b/reactos/lib/sdk/crt/math/sinh.c index fa9e5f7586d..7de7744348c 100644 --- a/reactos/lib/sdk/crt/math/sinh.c +++ b/reactos/lib/sdk/crt/math/sinh.c @@ -1,6 +1,10 @@ /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */ #include +#ifdef _MSC_VER +#pragma function(sinh) +#endif + /* * @implemented */ diff --git a/reactos/lib/sdk/crt/math/tanh.c b/reactos/lib/sdk/crt/math/tanh.c index 8c231c12c3a..43262f3b4ee 100644 --- a/reactos/lib/sdk/crt/math/tanh.c +++ b/reactos/lib/sdk/crt/math/tanh.c @@ -2,6 +2,10 @@ #include +#ifdef _MSC_VER +#pragma function(tanh) +#endif + /* * @implemented */ diff --git a/reactos/lib/sdk/crt/mem/memcmp.c b/reactos/lib/sdk/crt/mem/memcmp.c index 078238ebd20..b9b4334260f 100644 --- a/reactos/lib/sdk/crt/mem/memcmp.c +++ b/reactos/lib/sdk/crt/mem/memcmp.c @@ -4,6 +4,11 @@ #include +#ifdef _MSC_VER +#pragma warning(disable: 4164) +#pragma function(memcmp) +#endif + int memcmp(const void *s1, const void *s2, size_t n) { if (n != 0) { diff --git a/reactos/lib/sdk/crt/misc/assert.c b/reactos/lib/sdk/crt/misc/assert.c index bc196fd8417..693e42d1056 100644 --- a/reactos/lib/sdk/crt/misc/assert.c +++ b/reactos/lib/sdk/crt/misc/assert.c @@ -32,7 +32,7 @@ void _assert(const char *exp, const char *file, unsigned line) /* Get MessageBoxA function pointer */ hmodUser32 = LoadLibrary("user32.dll"); - pMessageBoxA = GetProcAddress(hmodUser32, "MessageBoxA"); + pMessageBoxA = (PVOID)GetProcAddress(hmodUser32, "MessageBoxA"); if (!pMessageBoxA) { abort(); diff --git a/reactos/lib/sdk/crt/stdlib/rot.c b/reactos/lib/sdk/crt/stdlib/rot.c index 7502fb74fe2..d9655a263c6 100644 --- a/reactos/lib/sdk/crt/stdlib/rot.c +++ b/reactos/lib/sdk/crt/stdlib/rot.c @@ -10,6 +10,10 @@ #include +#ifdef _MSC_VER +#pragma function(_rotr, _rotl, _rotr, _lrotl, _lrotr) +#endif + unsigned int _rotr( unsigned int value, int shift ); /* * @implemented diff --git a/reactos/lib/sdk/crt/string/scanf.h b/reactos/lib/sdk/crt/string/scanf.h index 25c6336e1a1..4be9d8d4343 100644 --- a/reactos/lib/sdk/crt/string/scanf.h +++ b/reactos/lib/sdk/crt/string/scanf.h @@ -460,7 +460,7 @@ _FUNCTION_ { if ((*(format - 1)) < *(format + 1)) RtlSetBits(&bitMask, *(format - 1) +1 , *(format + 1) - *(format - 1)); else - RtlSetBits(&bitMask, *(format + 1) , *(format - 1) - *(format + 1)); + RtlSetBits(&bitMask, *(format + 1) , *(format - 1) - *(format + 1)); format++; } else RtlSetBits(&bitMask, *format, 1); diff --git a/reactos/lib/sdk/crt/string/strset.c b/reactos/lib/sdk/crt/string/strset.c index 29a72121197..5f5e641ba02 100644 --- a/reactos/lib/sdk/crt/string/strset.c +++ b/reactos/lib/sdk/crt/string/strset.c @@ -10,6 +10,9 @@ #if defined(__GNUC__) && !defined(__clang__) #define __int64 long long +#elif defined(_MSC_VER) +#pragma warning(disable: 4164) +#pragma function(_strset) #endif #ifdef _WIN64 @@ -49,3 +52,4 @@ char* _strset(char* szToFill, int szFill) } return t; } + diff --git a/reactos/lib/sdk/crt/string/wcs.c b/reactos/lib/sdk/crt/string/wcs.c index 8c4fff9e411..dcef8c4cca5 100644 --- a/reactos/lib/sdk/crt/string/wcs.c +++ b/reactos/lib/sdk/crt/string/wcs.c @@ -47,6 +47,10 @@ #undef vprintf #undef vwprintf +#ifdef _MSC_VER +#pragma function(_wcsset) +#endif + #ifndef _LIBCNT_ /********************************************************************* * _wcsdup (MSVCRT.@) diff --git a/reactos/lib/sdk/crt/time/ctime.c b/reactos/lib/sdk/crt/time/ctime.c index b6d1bfb6cd1..3b93ba1ec4f 100644 --- a/reactos/lib/sdk/crt/time/ctime.c +++ b/reactos/lib/sdk/crt/time/ctime.c @@ -7,6 +7,7 @@ */ #define MINGW_HAS_SECURE_API 1 +#define RC_INVOKED 1 // to prevent inline functions #include #include #include "bitsfixup.h" diff --git a/reactos/lib/sdk/crt/time/futime.c b/reactos/lib/sdk/crt/time/futime.c index 99010f09f57..8e3ae8625be 100644 --- a/reactos/lib/sdk/crt/time/futime.c +++ b/reactos/lib/sdk/crt/time/futime.c @@ -6,6 +6,7 @@ * PROGRAMERS: Timo Kreuzer */ #include +#define RC_INVOKED 1 // to prevent inline functions #include #include #include "bitsfixup.h" diff --git a/reactos/lib/sdk/crt/time/utime.c b/reactos/lib/sdk/crt/time/utime.c index 130e5a400ba..d879d49d115 100644 --- a/reactos/lib/sdk/crt/time/utime.c +++ b/reactos/lib/sdk/crt/time/utime.c @@ -7,6 +7,7 @@ */ #include #include +#define RC_INVOKED 1 // to prevent inline functions #include #include "bitsfixup.h"