diff --git a/dll/win32/msvcrt/cppexcept.h b/dll/win32/msvcrt/cppexcept.h index e6afd1e871e..faae296dc82 100644 --- a/dll/win32/msvcrt/cppexcept.h +++ b/dll/win32/msvcrt/cppexcept.h @@ -24,6 +24,10 @@ #include #include "cxx.h" +#ifdef __REACTOS__ +#include "msvc_fwd_decl.h" +#endif + #define CXX_FRAME_MAGIC_VC6 0x19930520 #define CXX_FRAME_MAGIC_VC7 0x19930521 #define CXX_FRAME_MAGIC_VC8 0x19930522 @@ -137,7 +141,7 @@ typedef struct #define TYPE_FLAG_VOLATILE 2 #define TYPE_FLAG_REFERENCE 8 -void WINAPI DECLSPEC_NORETURN _CxxThrowException(void*,const cxx_exception_type*); +DECLSPEC_NORETURN void WINAPI _CxxThrowException(void*,const cxx_exception_type*); static inline BOOL is_cxx_exception( EXCEPTION_RECORD *rec ) { diff --git a/dll/win32/msvcrt/cxx.h b/dll/win32/msvcrt/cxx.h index 8037d7def56..d39e869afbe 100644 --- a/dll/win32/msvcrt/cxx.h +++ b/dll/win32/msvcrt/cxx.h @@ -27,6 +27,9 @@ #define RTTI_USE_RVA 1 #endif +#ifdef _MSC_VER +#define __ASM_VTABLE(name,funcs) +#else #ifdef _WIN64 #define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n" @@ -52,6 +55,7 @@ funcs "\n\t.text") #endif /* _WIN64 */ +#endif // _MSC_VER #ifndef RTTI_USE_RVA @@ -481,6 +485,10 @@ static inline void *rtti_rva( const void *ptr, uintptr_t base ) #endif +#ifdef __REACTOS__ +void * __thiscall type_info_vector_dtor(type_info * _this, unsigned int flags); +#endif + #define CREATE_TYPE_INFO_VTABLE \ DEFINE_THISCALL_WRAPPER(type_info_vector_dtor,8) \ void * __thiscall type_info_vector_dtor(type_info * _this, unsigned int flags) \ diff --git a/dll/win32/msvcrt/except_i386.c b/dll/win32/msvcrt/except_i386.c index 61e6e882dc1..fc6a7a2e940 100644 --- a/dll/win32/msvcrt/except_i386.c +++ b/dll/win32/msvcrt/except_i386.c @@ -601,8 +601,11 @@ int CDECL _except_handler3(PEXCEPTION_RECORD rec, rec->ExceptionCode, rec->ExceptionFlags, rec->ExceptionAddress, frame->handler, context, dispatcher); +#ifdef _MSC_VER + __asm{ cld } +#else __asm__ __volatile__ ("cld"); - +#endif if (rec->ExceptionFlags & (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND)) { /* Unwinding the current frame */ diff --git a/dll/win32/msvcrt/include/conio.h b/dll/win32/msvcrt/include/conio.h index 49c2b94962a..d9607613db6 100644 --- a/dll/win32/msvcrt/include/conio.h +++ b/dll/win32/msvcrt/include/conio.h @@ -46,11 +46,13 @@ static inline int kbhit(void) { return _kbhit(); } static inline int putch(int c) { return _putch(c); } static inline int ungetch(int c) { return _ungetch(c); } #ifdef _M_IX86 +#ifndef _MSC_VER static inline int inp(unsigned short i) { return _inp(i); } static inline unsigned short inpw(unsigned short i) { return _inpw(i); } static inline int outp(unsigned short i, int j) { return _outp(i, j); } static inline unsigned short outpw(unsigned short i, unsigned short j) { return _outpw(i, j); } #endif +#endif #if defined(__GNUC__) && (__GNUC__ < 4) _ACRTIMP int __cdecl cprintf(const char*,...) __attribute__((alias("_cprintf"),format(printf,1,2))); diff --git a/dll/win32/msvcrt/include/stdlib.h b/dll/win32/msvcrt/include/stdlib.h index 9cb8ccb110a..25bb4949058 100644 --- a/dll/win32/msvcrt/include/stdlib.h +++ b/dll/win32/msvcrt/include/stdlib.h @@ -297,6 +297,7 @@ static inline unsigned __int64 __cdecl strtoull(const char *ptr, char **endptr, static inline void swab(char* src, char* dst, int len) { _swab(src, dst, len); } static inline char* ultoa(__msvcrt_ulong value, char* str, int radix) { return _ultoa(value, str, radix); } +#ifndef __REACTOS__ #ifdef __i386__ static inline div_t __wine_msvcrt_div(int num, int denom) { @@ -319,6 +320,7 @@ static inline ldiv_t __wine_msvcrt_ldiv(__msvcrt_long num, __msvcrt_long denom) #define div(num,denom) __wine_msvcrt_div(num,denom) #define ldiv(num,denom) __wine_msvcrt_ldiv(num,denom) #endif +#endif /* !__REACTOS__ */ #include diff --git a/dll/win32/msvcrt/include/string.h b/dll/win32/msvcrt/include/string.h index 10fbf12e99e..b2bdeb1c01a 100644 --- a/dll/win32/msvcrt/include/string.h +++ b/dll/win32/msvcrt/include/string.h @@ -16,6 +16,10 @@ #define _NLSCMP_DEFINED #endif +#ifdef _MSC_VER +#pragma function(strset) +#endif + #ifdef __cplusplus extern "C" { #endif diff --git a/dll/win32/msvcrt/include/sys/timeb.h b/dll/win32/msvcrt/include/sys/timeb.h index e948daab012..66156ca6014 100644 --- a/dll/win32/msvcrt/include/sys/timeb.h +++ b/dll/win32/msvcrt/include/sys/timeb.h @@ -62,14 +62,14 @@ _ACRTIMP void __cdecl _ftime64(struct __timeb64*); #endif #ifdef _USE_32BIT_TIME_T -static inline void __cdecl _ftime(struct _timeb *tb) { return _ftime32((struct __timeb32*)tb); } +static inline void __cdecl _ftime(struct _timeb *tb) { _ftime32((struct __timeb32*)tb); } #else -static inline void __cdecl _ftime(struct _timeb *tb) { return _ftime64((struct __timeb64*)tb); } +static inline void __cdecl _ftime(struct _timeb *tb) { _ftime64((struct __timeb64*)tb); } #endif #define timeb _timeb -static inline void ftime(struct _timeb* ptr) { return _ftime(ptr); } +static inline void ftime(struct _timeb* ptr) { _ftime(ptr); } #include diff --git a/dll/win32/msvcrt/math.c b/dll/win32/msvcrt/math.c index be345fb7a4a..0ec4fde011b 100644 --- a/dll/win32/msvcrt/math.c +++ b/dll/win32/msvcrt/math.c @@ -52,6 +52,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); +#ifdef _MSC_VER +#pragma function(abs,labs,div,ldiv) +#endif + #undef div #undef ldiv @@ -699,13 +703,19 @@ intmax_t CDECL imaxabs( intmax_t n ) /********************************************************************* * _abs64 (MSVCRT.@) */ +#ifdef _MSC_VER +#pragma function(_abs64) +#endif __int64 CDECL _abs64( __int64 n ) { return n >= 0 ? n : -n; } #if defined(__i386__) || defined(__x86_64__) - +#ifdef _MSC_VER +#define get_mxcsr() _mm_getcsr() +#define set_mxcsr(val) _mm_setcsr(val) +#else static unsigned int get_mxcsr(void) { unsigned int ret; @@ -727,6 +737,7 @@ static void set_mxcsr( unsigned int val ) __asm__ __volatile__( "ldmxcsr %0" : : "m" (val) ); #endif } +#endif static void _setfp_sse( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask ) @@ -826,7 +837,7 @@ static void _setfp_sse( unsigned int *cw, unsigned int cw_mask, static void _setfp( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask ) { -#if (defined(__GNUC__) || defined(__clang__)) && defined(__i386__) +#if (defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)) && defined(__i386__) unsigned long oldcw = 0, newcw = 0; unsigned long oldsw = 0, newsw = 0; unsigned int flags; @@ -836,7 +847,11 @@ static void _setfp( unsigned int *cw, unsigned int cw_mask, if (sw) { +#ifdef _MSC_VER + __asm { fstsw newsw } +#else __asm__ __volatile__( "fstsw %0" : "=m" (newsw) ); +#endif oldsw = newsw; flags = 0; @@ -861,7 +876,11 @@ static void _setfp( unsigned int *cw, unsigned int cw_mask, if (cw) { - __asm__ __volatile__( "fstcw %0" : "=m" (newcw) ); +#ifdef _MSC_VER + __asm { fstcw newcw } +#else + __asm__ __volatile__( "fstcw %0" : "=m" (newcw) ); +#endif oldcw = newcw; flags = 0; @@ -928,18 +947,34 @@ static void _setfp( unsigned int *cw, unsigned int cw_mask, assert(cw); +#ifdef _MSC_VER + __asm { fnstenv fenv } +#else __asm__ __volatile__( "fnstenv %0" : "=m" (fenv) ); +#endif fenv.control_word = newcw; fenv.status_word = newsw; +#ifdef _MSC_VER + __asm { fldenv fenv } +#else __asm__ __volatile__( "fldenv %0" : : "m" (fenv) : "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" ); +#endif return; } if (oldsw != newsw) +#ifdef _MSC_VER + __asm { fnclex } +#else __asm__ __volatile__( "fnclex" ); +#endif if (oldcw != newcw) +#ifdef _MSC_VER + __asm { fldcw newcw } +#else __asm__ __volatile__( "fldcw %0" : : "m" (newcw) ); +#endif #elif defined(__x86_64__) _setfp_sse(cw, cw_mask, sw, sw_mask); #elif defined(__aarch64__) @@ -2012,6 +2047,7 @@ int CDECL _gcvt_s(char *buff, size_t size, double number, int digits) #include /* div_t, ldiv_t */ +#ifndef __REACTOS__ /********************************************************************* * div (MSVCRT.@) * VERSION @@ -2078,6 +2114,7 @@ ldiv_t CDECL ldiv(__msvcrt_long num, __msvcrt_long denom) return ret; } #endif /* ifdef __i386__ */ +#endif /* !__REACTOS__ */ #if _MSVCR_VER>=100 /********************************************************************* @@ -2325,6 +2362,7 @@ void _safe_fprem1(void) TRACE("(): stub\n"); } +#ifndef __REACTOS__ /*********************************************************************** * __libm_sse2_acos (MSVCRT.@) */ @@ -2580,6 +2618,7 @@ void __cdecl __libm_sse2_sqrt_precise(void) } __asm__ __volatile__( "sqrtsd %xmm0, %xmm0" ); } +#endif /* !__REACTOS__ */ #endif /* __i386__ */ #if _MSVCR_VER>=120 diff --git a/dll/win32/msvcrt/misc.c b/dll/win32/msvcrt/misc.c index 559bb7288b3..6977406e428 100644 --- a/dll/win32/msvcrt/misc.c +++ b/dll/win32/msvcrt/misc.c @@ -31,6 +31,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); static unsigned int output_format; +#ifdef _MSC_VER +#pragma function(_byteswap_ushort, _byteswap_ulong, _byteswap_uint64) +#endif + /********************************************************************* * _beep (MSVCRT.@) */ diff --git a/dll/win32/msvcrt/msvc_fwd_decl.h b/dll/win32/msvcrt/msvc_fwd_decl.h new file mode 100644 index 00000000000..3b51fce986a --- /dev/null +++ b/dll/win32/msvcrt/msvc_fwd_decl.h @@ -0,0 +1,45 @@ + +#define bad_cast exception +#define bad_typeid exception +#define __non_rtti_object exception + +exception* __thiscall exception_ctor(exception* _this, const char** name); +exception* __thiscall exception_copy_ctor(exception* _this, const exception* rhs); +exception* __thiscall exception_ctor_noalloc(exception* _this, char** name, int noalloc); +exception* __thiscall exception_default_ctor(exception* _this); +exception* __thiscall exception_opequals(exception* _this, const exception* rhs); +void __thiscall exception_dtor(exception* _this); +void* __thiscall exception_vector_dtor(exception* _this, unsigned int flags); +void* __thiscall exception_scalar_dtor(exception* _this, unsigned int flags); +const char* __thiscall exception_what(exception* _this); +bad_typeid* __thiscall bad_typeid_copy_ctor(bad_typeid* _this, const bad_typeid* rhs); +bad_typeid* __thiscall bad_typeid_ctor(bad_typeid* _this, const char* name); +bad_typeid* __thiscall bad_typeid_default_ctor(bad_typeid* _this); +void __thiscall bad_typeid_dtor(bad_typeid* _this); +bad_typeid* __thiscall bad_typeid_opequals(bad_typeid* _this, const bad_typeid* rhs); +void* __thiscall bad_typeid_vector_dtor(bad_typeid* _this, unsigned int flags); +void* __thiscall bad_typeid_scalar_dtor(bad_typeid* _this, unsigned int flags); +__non_rtti_object* __thiscall __non_rtti_object_copy_ctor(__non_rtti_object* _this, const __non_rtti_object* rhs); +__non_rtti_object* __thiscall __non_rtti_object_ctor(__non_rtti_object* _this, const char* name); +void __thiscall __non_rtti_object_dtor(__non_rtti_object* _this); +__non_rtti_object* __thiscall __non_rtti_object_opequals(__non_rtti_object* _this, const __non_rtti_object* rhs); +void* __thiscall __non_rtti_object_vector_dtor(__non_rtti_object* _this, unsigned int flags); +void* __thiscall __non_rtti_object_scalar_dtor(__non_rtti_object* _this, unsigned int flags); +bad_cast* __thiscall bad_cast_ctor(bad_cast* _this, const char** name); +bad_cast* __thiscall bad_cast_copy_ctor(bad_cast* _this, const bad_cast* rhs); +bad_cast* __thiscall bad_cast_ctor_charptr(bad_cast* _this, const char* name); +bad_cast* __thiscall bad_cast_default_ctor(bad_cast* _this); +void __thiscall bad_cast_dtor(bad_cast* _this); +void* __thiscall bad_cast_vector_dtor(bad_cast* _this, unsigned int flags); +void* __thiscall bad_cast_scalar_dtor(bad_cast* _this, unsigned int flags); +bad_cast* __thiscall bad_cast_opequals(bad_cast* _this, const bad_cast* rhs); +int __thiscall type_info_opequals_equals(type_info* _this, const type_info* rhs); +int __thiscall type_info_opnot_equals(type_info* _this, const type_info* rhs); +int __thiscall type_info_before(type_info* _this, const type_info *rhs); +void __thiscall type_info_dtor(type_info* _this); +const char* __thiscall type_info_name(type_info* _this); +const char* __thiscall type_info_raw_name(type_info* _this); + +#undef bad_cast +#undef bad_typeid +#undef __non_rtti_object diff --git a/dll/win32/msvcrt/printf.h b/dll/win32/msvcrt/printf.h index be30d6ae719..561678f6819 100644 --- a/dll/win32/msvcrt/printf.h +++ b/dll/win32/msvcrt/printf.h @@ -605,7 +605,11 @@ static inline int FUNC_NAME(pf_output_fp)(FUNC_NAME(puts_clbk) pf_puts, void *pu BOOL standard_rounding) { int e2, e10 = 0, round_pos, round_limb, radix_pos, first_limb_len, i, len, r, ret; +#ifdef _MSC_VER + BYTE bnum_data[FIELD_OFFSET(struct bnum, data) + BNUM_PREC64 * sizeof(DWORD)]; +#else BYTE bnum_data[FIELD_OFFSET(struct bnum, data[BNUM_PREC64])]; +#endif struct bnum *b = (struct bnum*)bnum_data; APICHAR buf[LIMB_DIGITS + 1]; BOOL trim_tail = FALSE, round_up = FALSE; diff --git a/dll/win32/msvcrt/string.c b/dll/win32/msvcrt/string.c index a5d04c94583..1fd3b13754c 100644 --- a/dll/win32/msvcrt/string.c +++ b/dll/win32/msvcrt/string.c @@ -36,6 +36,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); +#ifdef _MSC_VER +#pragma function(_strset,memchr,memcmp,memcpy,memset,strcat,strcmp,strcpy,strlen) +#endif + /********************************************************************* * _mbsdup (MSVCRT.@) * _strdup (MSVCRT.@) @@ -978,13 +982,21 @@ struct fpnum fpnum_parse(wchar_t (*get)(void *ctx), void (*unget)(void *ctx), void *ctx, pthreadlocinfo locinfo, BOOL ldouble) { if(!ldouble) { +#ifdef _MSC_VER + BYTE bnum_data[FIELD_OFFSET(struct bnum, data) + BNUM_PREC64 * sizeof(DWORD)]; +#else BYTE bnum_data[FIELD_OFFSET(struct bnum, data[BNUM_PREC64])]; +#endif struct bnum *b = (struct bnum*)bnum_data; b->size = BNUM_PREC64; return fpnum_parse_bnum(get, unget, ctx, locinfo, ldouble, b); } else { +#ifdef _MSC_VER + BYTE bnum_data[FIELD_OFFSET(struct bnum, data) + BNUM_PREC80 * sizeof(DWORD)]; +#else BYTE bnum_data[FIELD_OFFSET(struct bnum, data[BNUM_PREC80])]; +#endif struct bnum *b = (struct bnum*)bnum_data; b->size = BNUM_PREC80; diff --git a/dll/win32/msvcrt/wcs.c b/dll/win32/msvcrt/wcs.c index 1b7bc3e54e0..af9da19d8d7 100644 --- a/dll/win32/msvcrt/wcs.c +++ b/dll/win32/msvcrt/wcs.c @@ -33,6 +33,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); +#ifdef _MSC_VER +#pragma function(_wcsset,wcscat,wcscmp,wcscpy,wcslen) +#endif + typedef struct { enum { LEN_DEFAULT, LEN_SHORT, LEN_LONG } IntegerLength;