diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index 59a997b084f..14159b47a24 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -39,6 +39,10 @@ extern BOOLEAN UseRealHeap; extern ULONG LoaderPagesSpanned; extern BOOLEAN AcpiPresent; +extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation; +extern BOOLEAN WinLdrTerminalConnected; +extern void WinLdrSetupEms(IN PCHAR BootOptions); + BOOLEAN WinLdrCheckForLoadedDll(IN OUT PLOADER_PARAMETER_BLOCK WinLdrBlock, IN PCH DllName, @@ -206,8 +210,6 @@ WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, #ifdef _M_IX86 /* Set headless block pointer */ - extern HEADLESS_LOADER_BLOCK LoaderRedirectionInformation; - extern BOOLEAN WinLdrTerminalConnected; if (WinLdrTerminalConnected) { Extension->HeadlessLoaderBlock = MmHeapAlloc(sizeof(HEADLESS_LOADER_BLOCK)); @@ -537,7 +539,6 @@ LoadAndBootWindows(PCSTR OperatingSystemName, #ifdef _M_IX86 /* Setup redirection support */ - extern void WinLdrSetupEms(IN PCHAR BootOptions); WinLdrSetupEms(BootOptions); #endif /* Detect hardware */ diff --git a/reactos/drivers/storage/classpnp/class.c b/reactos/drivers/storage/classpnp/class.c index bf73d776523..2da38e04de8 100644 --- a/reactos/drivers/storage/classpnp/class.c +++ b/reactos/drivers/storage/classpnp/class.c @@ -2485,7 +2485,7 @@ ClassIoComplete( retry = TRUE; } - if (retry && (irpStack->Parameters.Others.Argument4--)) { + if (retry && ((*(PCHAR*)&irpStack->Parameters.Others.Argument4)--)) { // // Retry request. diff --git a/reactos/drivers/storage/classpnp/obsolete.c b/reactos/drivers/storage/classpnp/obsolete.c index 1dec49c4306..c0d6792d9cb 100644 --- a/reactos/drivers/storage/classpnp/obsolete.c +++ b/reactos/drivers/storage/classpnp/obsolete.c @@ -161,7 +161,7 @@ ClassIoCompleteAssociated( retry = TRUE; } - if (retry && (irpStack->Parameters.Others.Argument4--)) { + if (retry && ((*(PCHAR*)&irpStack->Parameters.Others.Argument4)--)) { // // Retry request. If the class driver has supplied a StartIo, diff --git a/reactos/include/crt/mingw32/intrin_x86.h b/reactos/include/crt/mingw32/intrin_x86.h index 1be110c4473..a92f2b307ef 100644 --- a/reactos/include/crt/mingw32/intrin_x86.h +++ b/reactos/include/crt/mingw32/intrin_x86.h @@ -1128,6 +1128,39 @@ __INTRIN_INLINE void __outdwordstring(unsigned short const Port, const unsigned __asm__ __volatile__("rep; outsl" : : [Port] "d" (Port), [Buffer] "S" (Buffer), "c" (Count)); } +__INTRIN_INLINE int _inp(unsigned short Port) +{ + return __inbyte(Port); +} + +__INTRIN_INLINE unsigned short _inpw(unsigned short Port) +{ + return __inword(Port); +} + +__INTRIN_INLINE unsigned long _inpd(unsigned short Port) +{ + return __indword(Port); +} + +__INTRIN_INLINE int _outp(unsigned short Port, int databyte) +{ + __outbyte(Port, databyte); + return databyte; +} + +__INTRIN_INLINE unsigned short _outpw(unsigned short Port, unsigned short dataword) +{ + __outword(Port, dataword); + return dataword; +} + +__INTRIN_INLINE unsigned long _outpd(unsigned short Port, unsigned long dataword) +{ + __outdword(Port, dataword); + return dataword; +} + /*** System information ***/ __INTRIN_INLINE void __cpuid(int CPUInfo[], const int InfoType) diff --git a/reactos/include/crt/setjmp.h b/reactos/include/crt/setjmp.h index 002e525c050..3c1ab86995f 100644 --- a/reactos/include/crt/setjmp.h +++ b/reactos/include/crt/setjmp.h @@ -145,9 +145,6 @@ extern "C" { #define _JMP_BUF_DEFINED #endif -#ifdef _MSC_VER -int __cdecl __MINGW_NOTHROW setjmp(jmp_buf _Buf); -#else #ifdef USE_MINGW_SETJMP_TWO_ARGS #ifndef _INC_SETJMPEX #if defined(__x86_64) @@ -158,20 +155,19 @@ int __cdecl __MINGW_NOTHROW setjmp(jmp_buf _Buf); ({ void* value; __asm__ __volatile__("movl %%esp, %[value]" : [value] "=r" (value)); value; }) #endif #define setjmp(BUF) _setjmp((BUF),mingw_getsp()) - int __cdecl __MINGW_NOTHROW _setjmp(jmp_buf _Buf,void *_Ctx); -#else + int __MINGW_NOTHROW __cdecl _setjmp(jmp_buf _Buf,void *_Ctx); +#else /* _INC_SETJMPEX */ #undef setjmp #define setjmp(BUF) _setjmpex((BUF),mingw_getsp()) #define setjmpex(BUF) _setjmpex((BUF),mingw_getsp()) - int __cdecl __MINGW_NOTHROW _setjmpex(jmp_buf _Buf,void *_Ctx); -#endif -#else + int __MINGW_NOTHROW __cdecl _setjmpex(jmp_buf _Buf,void *_Ctx); +#endif /* _INC_SETJMPEX */ +#else /* !USE_MINGW_SETJMP_TWO_ARGS */ #ifndef _INC_SETJMPEX #define setjmp _setjmp #endif - int __cdecl __MINGW_NOTHROW setjmp(jmp_buf _Buf); -#endif -#endif + int __MINGW_NOTHROW __cdecl setjmp(jmp_buf _Buf); +#endif /* !USE_MINGW_SETJMP_TWO_ARGS */ __declspec(noreturn) __MINGW_NOTHROW void __cdecl ms_longjmp(jmp_buf _Buf,int _Value)/* throw(...)*/; __declspec(noreturn) __MINGW_NOTHROW void __cdecl longjmp(jmp_buf _Buf,int _Value); diff --git a/reactos/include/crt/stddef.h b/reactos/include/crt/stddef.h index 0c366e977fd..97a519ea88e 100644 --- a/reactos/include/crt/stddef.h +++ b/reactos/include/crt/stddef.h @@ -13,13 +13,7 @@ extern "C" { #endif -#ifndef _CRT_ERRNO_DEFINED -#define _CRT_ERRNO_DEFINED - _CRTIMP extern int *__cdecl _errno(void); -#define errno (*_errno()) - errno_t __cdecl _set_errno(int _Value); - errno_t __cdecl _get_errno(int *_Value); -#endif +#include _CRTIMP extern unsigned long __cdecl __threadid(void); #define _threadid (__threadid()) diff --git a/reactos/include/crt/stdlib.h b/reactos/include/crt/stdlib.h index 800ad1ca61d..475bf924342 100644 --- a/reactos/include/crt/stdlib.h +++ b/reactos/include/crt/stdlib.h @@ -134,13 +134,7 @@ extern "C" { _invalid_parameter_handler __cdecl _set_invalid_parameter_handler(_invalid_parameter_handler _Handler); _invalid_parameter_handler __cdecl _get_invalid_parameter_handler(void); -#ifndef _CRT_ERRNO_DEFINED -#define _CRT_ERRNO_DEFINED - _CRTIMP extern int *__cdecl _errno(void); -#define errno (*_errno()) - errno_t __cdecl _set_errno(int _Value); - errno_t __cdecl _get_errno(int *_Value); -#endif +#include _CRTIMP unsigned long *__cdecl __doserrno(void); #define _doserrno (*__doserrno()) errno_t __cdecl _set_doserrno(unsigned long _Value); @@ -447,10 +441,10 @@ extern "C" { _CRTIMP void __cdecl _wsplitpath(const wchar_t *_FullPath,wchar_t *_Drive,wchar_t *_Dir,wchar_t *_Filename,wchar_t *_Ext); #endif - _CRTIMP void __cdecl _beep(unsigned _Frequency,unsigned _Duration) __MINGW_ATTRIB_DEPRECATED; + _CRTIMP __MINGW_ATTRIB_DEPRECATED void __cdecl _beep(unsigned _Frequency,unsigned _Duration); /* Not to be confused with _set_error_mode (int). */ - _CRTIMP void __cdecl _seterrormode(int _Mode) __MINGW_ATTRIB_DEPRECATED; - _CRTIMP void __cdecl _sleep(unsigned long _Duration) __MINGW_ATTRIB_DEPRECATED; + _CRTIMP __MINGW_ATTRIB_DEPRECATED void __cdecl _seterrormode(int _Mode); + _CRTIMP __MINGW_ATTRIB_DEPRECATED void __cdecl _sleep(unsigned long _Duration); #endif #ifndef NO_OLDNAMES diff --git a/reactos/include/crt/string.h b/reactos/include/crt/string.h index 0ecde8b7ee5..472d76ce9fe 100644 --- a/reactos/include/crt/string.h +++ b/reactos/include/crt/string.h @@ -82,6 +82,17 @@ extern "C" { _CRTIMP char *_strupr_l(char *_String,_locale_t _Locale); _CRTIMP size_t __cdecl strxfrm(char *_Dst,const char *_Src,size_t _MaxCount); _CRTIMP size_t __cdecl _strxfrm_l(char *_Dst,const char *_Src,size_t _MaxCount,_locale_t _Locale); +#if __STDC_WANT_SECURE_LIB__ + _CRTIMP errno_t __cdecl _strset_s(char *_Dst,size_t _DstSize,int _Value); + _CRTIMP errno_t __cdecl _strerror_s(char *_Buf,size_t _SizeInBytes,const char *_ErrMsg); + _CRTIMP errno_t __cdecl _strlwr_s(char *_Str,size_t _Size); + _CRTIMP errno_t __cdecl _strlwr_s_l(char *_Str,size_t _Size,_locale_t _Locale); + _CRTIMP errno_t __cdecl _strnset_s(char *_Str,size_t _Size,int _Val,size_t _MaxCount); + _CRTIMP errno_t __cdecl _strupr_s(char *_Str,size_t _Size); + _CRTIMP errno_t __cdecl _strupr_s_l(char *_Str,size_t _Size,_locale_t _Locale); + _CRTIMP errno_t __cdecl strcpy_s(char *_Dst, size_t _Size, const char *_Src); + _CRTIMP errno_t __cdecl strcat_s(char *_Dst, size_t _Size, const char *_Src); +#endif #ifndef NO_OLDNAMES _CRTIMP _CRT_NONSTDC_DEPRECATE(_strdup) char *__cdecl strdup(const char *_Src); @@ -102,27 +113,15 @@ extern "C" { _CRTIMP wchar_t *__cdecl _wcsdup(const wchar_t *_Str); _CRTIMP _CRT_INSECURE_DEPRECATE(wcsat_s) wchar_t *__cdecl wcscat(wchar_t *_Dest,const wchar_t *_Source); -#if __STDC_WANT_SECURE_LIB__ - _CRTIMP errno_t __cdecl wcsat_s(wchar_t * Dest, size_t SizeInWords, const wchar_t * _Source); -#endif _CRTIMP _CONST_RETURN wchar_t *__cdecl wcschr(const wchar_t *_Str,wchar_t _Ch); _CRTIMP int __cdecl wcscmp(const wchar_t *_Str1,const wchar_t *_Str2); _CRTIMP _CRT_INSECURE_DEPRECATE(wcscpy_s) wchar_t *__cdecl wcscpy(wchar_t *_Dest,const wchar_t *_Source); -#if __STDC_WANT_SECURE_LIB__ - _CRTIMP errno_t __cdecl wcscpy_s(wchar_t * Dest, size_t SizeInWords, const wchar_t * _Source); -#endif _CRTIMP size_t __cdecl wcscspn(const wchar_t *_Str,const wchar_t *_Control); _CRTIMP wchar_t *wcsncat(wchar_t *_Dest,const wchar_t *_Source,size_t _Count); _CRTIMP size_t __cdecl wcslen(const wchar_t *_Str); _CRTIMP _CRT_INSECURE_DEPRECATE(wcsnlen_s) size_t __cdecl wcsnlen(const wchar_t *_Src,size_t _MaxCount); -#if __STDC_WANT_SECURE_LIB__ - _CRTIMP errno_t __cdecl wcsnlen_s(wchar_t **_Src, size_t _MaxCount); -#endif _CRTIMP int __cdecl wcsncmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); _CRTIMP _CRT_INSECURE_DEPRECATE(wcsncpy_s) wchar_t *wcsncpy(wchar_t *_Dest,const wchar_t *_Source,size_t _Count); -#if __STDC_WANT_SECURE_LIB__ - _CRTIMP errno_t __cdecl wcsncpy_s(wchar_t *_Dest, size_t SizeInWords, const wchar_t *_Source ,size_t _Count); -#endif _CRTIMP _CONST_RETURN wchar_t *__cdecl wcspbrk(const wchar_t *_Str,const wchar_t *_Control); _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(const wchar_t *_Str,wchar_t _Ch); _CRTIMP size_t __cdecl wcsspn(const wchar_t *_Str,const wchar_t *_Control); @@ -151,6 +150,20 @@ extern "C" { _CRTIMP int __cdecl _wcsncoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); _CRTIMP int __cdecl _wcsnicoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); _CRTIMP int __cdecl _wcsnicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); +#if __STDC_WANT_SECURE_LIB__ + _CRTIMP errno_t __cdecl wcsat_s(wchar_t * Dest, size_t SizeInWords, const wchar_t * _Source); + _CRTIMP errno_t __cdecl wcscpy_s(wchar_t * Dest, size_t SizeInWords, const wchar_t * _Source); + _CRTIMP errno_t __cdecl wcsnlen_s(wchar_t **_Src, size_t _MaxCount); + _CRTIMP errno_t __cdecl wcsncpy_s(wchar_t *_Dest, size_t SizeInWords, const wchar_t *_Source ,size_t _Count); + _CRTIMP errno_t __cdecl _wcserror_s(wchar_t *_Buf,size_t _SizeInWords,int _ErrNum); + _CRTIMP errno_t __cdecl __wcserror_s(wchar_t *_Buffer,size_t _SizeInWords,const wchar_t *_ErrMsg); + _CRTIMP errno_t __cdecl _wcsnset_s(wchar_t *_Dst,size_t _DstSizeInWords,wchar_t _Val,size_t _MaxCount); + _CRTIMP errno_t __cdecl _wcsset_s(wchar_t *_Str,size_t _SizeInWords,wchar_t _Val); + _CRTIMP errno_t __cdecl _wcslwr_s(wchar_t *_Str,size_t _SizeInWords); + _CRTIMP errno_t __cdecl _wcslwr_s_l(wchar_t *_Str,size_t _SizeInWords,_locale_t _Locale); + _CRTIMP errno_t __cdecl _wcsupr_s(wchar_t *_Str,size_t _Size); + _CRTIMP errno_t __cdecl _wcsupr_s_l(wchar_t *_Str,size_t _Size,_locale_t _Locale); +#endif #ifndef NO_OLDNAMES _CRTIMP _CRT_NONSTDC_DEPRECATE(_wcsdup) wchar_t *__cdecl wcsdup(const wchar_t *_Str); @@ -171,8 +184,6 @@ extern "C" { } #endif -#include - // HACK #define strcasecmp _stricmp #define strncasecmp _strnicmp @@ -180,3 +191,4 @@ extern "C" { #define wcsicmp _wcsicmp #endif + diff --git a/reactos/include/crt/sys/stat.h b/reactos/include/crt/sys/stat.h index 22bfb0f32c7..45ec7eaad57 100644 --- a/reactos/include/crt/sys/stat.h +++ b/reactos/include/crt/sys/stat.h @@ -187,9 +187,9 @@ extern "C" { _Stat->st_gid = _Stat64.st_gid; _Stat->st_rdev = _Stat64.st_rdev; _Stat->st_size = _Stat64.st_size; - _Stat->st_atime = _Stat64.st_atime; - _Stat->st_mtime = _Stat64.st_mtime; - _Stat->st_ctime = _Stat64.st_ctime; + _Stat->st_atime = (__time32_t)_Stat64.st_atime; + _Stat->st_mtime = (__time32_t)_Stat64.st_mtime; + _Stat->st_ctime = (__time32_t)_Stat64.st_ctime; return ret; } __CRT_INLINE int __cdecl _fstat32i64(int _FileDes, struct _stat32i64 *_Stat) @@ -204,9 +204,9 @@ extern "C" { _Stat->st_gid = _Stat64.st_gid; _Stat->st_rdev = _Stat64.st_rdev; _Stat->st_size = _Stat64.st_size; - _Stat->st_atime = _Stat64.st_atime; - _Stat->st_mtime = _Stat64.st_mtime; - _Stat->st_ctime = _Stat64.st_ctime; + _Stat->st_atime = (__time32_t)_Stat64.st_atime; + _Stat->st_mtime = (__time32_t)_Stat64.st_mtime; + _Stat->st_ctime = (__time32_t)_Stat64.st_ctime; return ret; } #endif /* _USE_32BIT_TIME_T */ diff --git a/reactos/include/crt/vadefs.h b/reactos/include/crt/vadefs.h index 6a72792d171..6e14de7500e 100644 --- a/reactos/include/crt/vadefs.h +++ b/reactos/include/crt/vadefs.h @@ -81,14 +81,24 @@ extern "C" { #define __va_copy(d,s) __builtin_va_copy(d,s) #elif defined(_MSC_VER) -#if defined(_M_IA64) || defined(_M_AMD64) || defined(_M_CEE) -#error Please implement me -#endif - +#if defined(_M_IX86) #define _crt_va_start(v,l) ((void)((v) = (va_list)_ADDRESSOF(l) + _INTSIZEOF(l))) #define _crt_va_arg(v,l) (*(l *)(((v) += _INTSIZEOF(l)) - _INTSIZEOF(l))) #define _crt_va_end(v) ((void)((v) = (va_list)0)) #define __va_copy(d,s) ((void)((d) = (s))) +#elif defined(_M_AMD64) +#define _PTRSIZEOF(n) ((sizeof(n) + sizeof(void*) - 1) & ~(sizeof(void*) - 1)) +#define _ISSTRUCT(t) ((sizeof(t) > sizeof(void*)) || (sizeof(t) & (sizeof(t)-1)) != 0) +#define _crt_va_start(v,l) ((void)((v) = (va_list)_ADDRESSOF(l) + _PTRSIZEOF(l))) +#define _crt_va_arg(v,t) (_ISSTRUCT(t) ? \ + (**(t**)(((v) += sizeof(void*)) - sizeof(void*))) : \ + (*(t*)(((v) += sizeof(void*)) - sizeof(void*)))) +#define _crt_va_end(v) ((void)((v) = (va_list)0)) +#define __va_copy(d,s) ((void)((d) = (s))) +#else //if defined(_M_IA64) || defined(_M_CEE) +#error Please implement me +#endif + #endif #if !defined(va_copy) && (!defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L) diff --git a/reactos/include/ndk/inline_ntcurrentteb.h b/reactos/include/ndk/inline_ntcurrentteb.h index ffda4d96924..4f874e6d7b1 100644 --- a/reactos/include/ndk/inline_ntcurrentteb.h +++ b/reactos/include/ndk/inline_ntcurrentteb.h @@ -1,20 +1,10 @@ #ifndef _INLINE_NT_CURRENTTEB_H_ #define _INLINE_NT_CURRENTTEB_H_ -#ifdef __GNUC__ - #if defined(_M_IX86) FORCEINLINE struct _TEB * NtCurrentTeb(void) { - struct _TEB *ret; - - __asm__ __volatile__ ( - "movl %%fs:0x18, %0\n" - : "=r" (ret) - : /* no inputs */ - ); - - return ret; + return (struct _TEB *)__readfsdword(0x18); } #elif defined(_M_ARM) @@ -24,63 +14,17 @@ FORCEINLINE struct _TEB * NtCurrentTeb(void) #include #elif defined(_M_AMD64) -FORCEINLINE struct _TEB * NtCurrentTeb(VOID) +FORCEINLINE struct _TEB * NtCurrentTeb(void) { return (struct _TEB *)__readgsqword(FIELD_OFFSET(NT_TIB, Self)); } #elif defined(_M_PPC) -extern __inline__ struct _TEB * NtCurrentTeb(void) +FORCEINLINE struct _TEB * NtCurrentTeb(void) { - return __readfsdword_winnt(0x18); + return (struct _TEB *)__readfsdword_winnt(0x18); } #else -extern __inline__ struct _TEB * NtCurrentTeb(void) -{ - return __readfsdword_winnt(0x18); -} +#error Unsupported architecture #endif -#elif defined(__WATCOMC__) - -extern PVOID GetCurrentFiber(void); -#pragma aux GetCurrentFiber = \ - "mov eax, dword ptr fs:0x10" \ - value [eax] \ - modify [eax]; - -extern struct _TEB * NtCurrentTeb(void); -#pragma aux NtCurrentTeb = \ - "mov eax, dword ptr fs:0x18" \ - value [eax] \ - modify [eax]; - -#elif defined(_MSC_VER) - -#if (_MSC_FULL_VER >= 13012035) - -__inline PVOID GetCurrentFiber(void) { return (PVOID)(ULONG_PTR)__readfsdword(0x10); } -__inline struct _TEB * NtCurrentTeb(void) { return (struct _TEB *)(ULONG_PTR)__readfsdword(0x18); } - -#else - -static __inline PVOID GetCurrentFiber(void) -{ - PVOID p; - __asm mov eax, fs:[10h] - __asm mov [p], eax - return p; -} - -static __inline struct _TEB * NtCurrentTeb(void) -{ - struct _TEB *p; - __asm mov eax, fs:[18h] - __asm mov [p], eax - return p; -} - -#endif /* _MSC_FULL_VER */ - -#endif /* __GNUC__/__WATCOMC__/_MSC_VER */ - #endif//_INLINE_NT_CURRENTTEB_H_ diff --git a/reactos/include/ndk/peb_teb.h b/reactos/include/ndk/peb_teb.h index ec4b2d33617..4f43d058234 100644 --- a/reactos/include/ndk/peb_teb.h +++ b/reactos/include/ndk/peb_teb.h @@ -12,7 +12,7 @@ #define PTR(x) x #endif -#if defined(_WIN64) && !defined(EXPLICIT_32BIT) +#if (defined(_WIN64) && !defined(EXPLICIT_32BIT)) || defined(EXPLICIT_64BIT) #define GDI_HANDLE_BUFFER_SIZE 60 #else #define GDI_HANDLE_BUFFER_SIZE 34 diff --git a/reactos/include/psdk/rpc.h b/reactos/include/psdk/rpc.h index de8aa7cfa29..800abf44fe2 100644 --- a/reactos/include/psdk/rpc.h +++ b/reactos/include/psdk/rpc.h @@ -1,17 +1,11 @@ #if !defined( RPC_NO_WINDOWS_H ) && !defined( MAC ) && !defined( _MAC ) -#if defined (_OLE32_) -#ifndef RC_INVOKED -#include -#endif -#include -#include -#else +#ifndef _INC_WINDOWS #include -#endif +#endif /* _INC_WINDOWS */ #endif -#ifdef __GNUC__ +#ifndef RC_INVOKED #include #endif diff --git a/reactos/include/psdk/strsafe.h b/reactos/include/psdk/strsafe.h index 7f09e1bd0fe..0f84a20dd77 100644 --- a/reactos/include/psdk/strsafe.h +++ b/reactos/include/psdk/strsafe.h @@ -1,6 +1,7 @@ #ifndef __STRSAFE_H_ #define __STRSAFE_H_ +#include #include #include @@ -238,7 +239,11 @@ STRSAFEAPI StringCxxVPrintfEx(STRSAFE_LPTSTR pszDest, size_t cxDest, STRSAFE_LPT #else // !STRSAFE_LIB /* Create inlined versions */ +#ifdef __GNUC__ #define STRSAFEAPI HRESULT static __inline__ +#else +#define STRSAFEAPI HRESULT __inline +#endif #define STRSAFE_MAX_CXX STRSAFE_CCHtoCXX(STRSAFE_MAX_CCH) @@ -496,7 +501,7 @@ StringCxxVPrintfEx( if (SUCCEEDED(hr)) { - if ((dwFlags & STRSAFE_FILL_BEHIND_NULL) && (iResult + 1 < cchMax)) + if ((dwFlags & STRSAFE_FILL_BEHIND_NULL) && ((size_t)iResult + 1 < cchMax)) { memset(pszDest + iResult + 1, dwFlags & 0xff, diff --git a/reactos/include/psdk/unknown.h b/reactos/include/psdk/unknown.h index 6fe27fc3658..8c0ea17a1ce 100644 --- a/reactos/include/psdk/unknown.h +++ b/reactos/include/psdk/unknown.h @@ -16,8 +16,8 @@ * */ -#ifndef __unknwn_h__ -#define __unknwn_h__ +#ifndef _UNKNOWN_H_ +#define _UNKNOWN_H_ #ifdef __cplusplus extern "C" { @@ -70,5 +70,5 @@ HRESULT IN POOL_TYPE PoolType ); -#endif +#endif /* _UNKNOWN_H_ */ diff --git a/reactos/include/psdk/wspiapi.h b/reactos/include/psdk/wspiapi.h index ea41ec8ab47..bbb01e10ee9 100644 --- a/reactos/include/psdk/wspiapi.h +++ b/reactos/include/psdk/wspiapi.h @@ -45,6 +45,12 @@ char (&__wspiapi_countof_helper(__CountofType (&_Array)[_N]))[_N]; #define getnameinfo WspiapiGetNameInfo #define freeaddrinfo WspiapiFreeAddrInfo +#if _MSC_VER +#define WSPIAPI_INLINE __inline +#else +#define WSPIAPI_INLINE static inline +#endif + typedef int (WINAPI *WSPIAPI_PGETADDRINFO)( IN const char *nodename, @@ -436,12 +442,12 @@ typedef struct { } WSPIAPI_FUNCTION; #define WSPIAPI_FUNCTION_ARRAY { \ - "getaddrinfo", (FARPROC) WspiapiLegacyGetAddrInfo, \ - "getnameinfo", (FARPROC) WspiapiLegacyGetNameInfo, \ - "freeaddrinfo", (FARPROC) WspiapiLegacyFreeAddrInfo, \ + {"getaddrinfo", (FARPROC) WspiapiLegacyGetAddrInfo}, \ + {"getnameinfo", (FARPROC) WspiapiLegacyGetNameInfo}, \ + {"freeaddrinfo", (FARPROC) WspiapiLegacyFreeAddrInfo} \ } -FORCEINLINE +WSPIAPI_INLINE FARPROC WINAPI WspiapiLoad( @@ -503,7 +509,7 @@ WspiapiLoad( return (rgtGlobal[wFunction].pfAddress); } -FORCEINLINE +WSPIAPI_INLINE int WINAPI WspiapiGetAddrInfo( @@ -522,7 +528,7 @@ WspiapiGetAddrInfo( return iError; } -FORCEINLINE +WSPIAPI_INLINE int WINAPI WspiapiGetNameInfo( @@ -544,7 +550,7 @@ WspiapiGetNameInfo( return iError; } -FORCEINLINE +WSPIAPI_INLINE void WINAPI WspiapiFreeAddrInfo( diff --git a/reactos/include/reactos/asm.h b/reactos/include/reactos/asm.h index 4a6f20b9f08..f617926d1b5 100644 --- a/reactos/include/reactos/asm.h +++ b/reactos/include/reactos/asm.h @@ -12,6 +12,7 @@ OPTION DOTNAME .586 +.XMM .MODEL FLAT ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING @@ -75,6 +76,10 @@ ENDM dd args ENDM +.double MACRO args:VARARG + dq args +ENDM + UNIMPLEMENTED MACRO name ENDM @@ -117,6 +122,10 @@ ENDM .global \symbol .endm +/* Dummy ASSUME */ +.macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8 +.endm + /* MASM compatible ALIGN */ #define ALIGN .align diff --git a/reactos/include/reactos/mingw-w64/sect_attribs.h b/reactos/include/reactos/mingw-w64/sect_attribs.h index 6e59216dbde..4d1a24f2173 100644 --- a/reactos/include/reactos/mingw-w64/sect_attribs.h +++ b/reactos/include/reactos/mingw-w64/sect_attribs.h @@ -9,7 +9,7 @@ #if defined(_M_IA64) || defined(_M_AMD64) #define _ATTRIBUTES #else -#define _ATTRIBUTES shared +#define _ATTRIBUTES read #endif /* Reference list of existing section for msvcrt. */ diff --git a/reactos/include/xdk/kefuncs.h b/reactos/include/xdk/kefuncs.h index 27049e651ba..eb5c7a25c5e 100644 --- a/reactos/include/xdk/kefuncs.h +++ b/reactos/include/xdk/kefuncs.h @@ -208,7 +208,7 @@ KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock) #endif NTKERNELAPI -DECLSPEC_NORETURN +//DECLSPEC_NORETURN VOID NTAPI KeBugCheckEx( diff --git a/reactos/lib/drivers/ip/network/i386/checksum.S b/reactos/lib/drivers/ip/network/i386/checksum.S index 16a4e02ccec..219120debbc 100644 --- a/reactos/lib/drivers/ip/network/i386/checksum.S +++ b/reactos/lib/drivers/ip/network/i386/checksum.S @@ -24,109 +24,111 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ - + /* * computes a partial checksum, e.g. for TCP/UDP fragments */ -/* +/* unsigned int csum_partial(const unsigned char * buff, int len, unsigned int sum) */ - -.text + +#include + +.code .align 4 -.globl _csum_partial - +PUBLIC _csum_partial + #ifndef CONFIG_X86_USE_PPRO_CHECKSUM - /* + /* * Experiments with Ethernet and SLIP connections show that buff * is aligned on either a 2-byte or 4-byte boundary. We get at * least a twofold speedup on 486 and Pentium if it is 4-byte aligned. * Fortunately, it is easy to convert 2-byte alignment to 4-byte * alignment for the unrolled loop. - */ -_csum_partial: - pushl %esi - pushl %ebx - movl 20(%esp),%eax # Function arg: unsigned int sum - movl 16(%esp),%ecx # Function arg: int len - movl 12(%esp),%esi # Function arg: unsigned char *buff - testl $3, %esi # Check alignment. - jz 2f # Jump if alignment is ok. - testl $1, %esi # Check alignment. - jz 10f # Jump if alignment is boundary of 2bytes. + */ +_csum_partial: + push esi + push ebx + mov eax, [esp + 20] // Function arg: unsigned int sum + mov ecx, [esp + 16] // Function arg: int len + mov esi, [esp + 12] // Function arg: unsigned char *buff + test esi, 3 // Check alignment. + jz m2 // Jump if alignment is ok. + test esi, 1 // Check alignment. + jz l10 // Jump if alignment is boundary of 2bytes. // buf is odd - dec %ecx - jl 8f - movzbl (%esi), %ebx - adcl %ebx, %eax - roll $8, %eax - inc %esi - testl $2, %esi - jz 2f -10: - subl $2, %ecx # Alignment uses up two bytes. - jae 1f # Jump if we had at least two bytes. - addl $2, %ecx # ecx was < 2. Deal with it. - jmp 4f -1: movw (%esi), %bx - addl $2, %esi - addw %bx, %ax - adcl $0, %eax -2: - movl %ecx, %edx - shrl $5, %ecx - jz 2f - testl %esi, %esi -1: movl (%esi), %ebx - adcl %ebx, %eax - movl 4(%esi), %ebx - adcl %ebx, %eax - movl 8(%esi), %ebx - adcl %ebx, %eax - movl 12(%esi), %ebx - adcl %ebx, %eax - movl 16(%esi), %ebx - adcl %ebx, %eax - movl 20(%esi), %ebx - adcl %ebx, %eax - movl 24(%esi), %ebx - adcl %ebx, %eax - movl 28(%esi), %ebx - adcl %ebx, %eax - lea 32(%esi), %esi - dec %ecx - jne 1b - adcl $0, %eax -2: movl %edx, %ecx - andl $0x1c, %edx - je 4f - shrl $2, %edx # This clears CF -3: adcl (%esi), %eax - lea 4(%esi), %esi - dec %edx - jne 3b - adcl $0, %eax -4: andl $3, %ecx - jz 7f - cmpl $2, %ecx - jb 5f - movw (%esi),%cx - leal 2(%esi),%esi - je 6f - shll $16,%ecx -5: movb (%esi),%cl -6: addl %ecx,%eax - adcl $0, %eax -7: - testl $1, 12(%esp) - jz 8f - roll $8, %eax -8: - popl %ebx - popl %esi + dec ecx + jl l8 + movzx ebx, byte ptr [esi] + adc eax, ebx + rol eax, 8 + inc esi + test esi, 2 + jz m2 +l10: + sub ecx, 2 // Alignment uses up two bytes. + jae m1 // Jump if we had at least two bytes. + add ecx, 2 // ecx was < 2. Deal with it. + jmp l4 +m1: mov bx, [esi] + add esi, 2 + add ax, bx + adc eax, 0 +m2: + mov edx, ecx + shr ecx, 5 + jz l2 + test esi, esi +l1: mov ebx, [esi] + adc eax, ebx + mov ebx, [esi + 4] + adc eax, ebx + mov ebx, [esi + 8] + adc eax, ebx + mov ebx, [esi + 12] + adc eax, ebx + mov ebx, [esi + 16] + adc eax, ebx + mov ebx, [esi + 20] + adc eax, ebx + mov ebx, [esi + 24] + adc eax, ebx + mov ebx, [esi + 28] + adc eax, ebx + lea esi, [esi + 32] + dec ecx + jne l1 + adc eax, 0 +l2: mov ecx, edx + and edx, HEX(1c) + je l4 + shr edx, 2 // This clears CF +l3: adc eax, [esi] + lea esi, [esi + 4] + dec edx + jne l3 + adc eax, 0 +l4: and ecx, 3 + jz l7 + cmp ecx, 2 + jb l5 + mov cx, [esi] + lea esi, [esi + 2] + je l6 + shl ecx, 16 +l5: mov cl, [esi] +l6: add eax, ecx + adc eax, 0 +l7: + test dword ptr [esp + 12], 1 + jz l8 + rol eax, 8 +l8: + pop ebx + pop esi ret #else @@ -134,116 +136,118 @@ _csum_partial: /* Version for PentiumII/PPro */ csum_partial: - pushl %esi - pushl %ebx - movl 20(%esp),%eax # Function arg: unsigned int sum - movl 16(%esp),%ecx # Function arg: int len - movl 12(%esp),%esi # Function arg: const unsigned char *buf + push esi + push ebx + mov eax, [esp + 20] # Function arg: unsigned int sum + mov ecx, [esp + 16] # Function arg: int len + mov esi, [esp + 12] # Function arg: const unsigned char *buf - testl $3, %esi - jnz 25f -10: - movl %ecx, %edx - movl %ecx, %ebx - andl $0x7c, %ebx - shrl $7, %ecx - addl %ebx,%esi - shrl $2, %ebx - negl %ebx - lea 45f(%ebx,%ebx,2), %ebx - testl %esi, %esi - jmp *%ebx + test esi, 3 + jnz l25f +l10: + mov edx, ecx + mov ebx, ecx + and ebx, HEX(7c) + shr ecx, 7 + add esi, ebx + shr ebx, 2 + neg ebx + lea ebx, l45[ebx + ebx * 2] + test esi, esi + jmp dword ptr [ebx] - # Handle 2-byte-aligned regions -20: addw (%esi), %ax - lea 2(%esi), %esi - adcl $0, %eax - jmp 10b -25: - testl $1, %esi - jz 30f - # buf is odd - dec %ecx - jl 90f - movzbl (%esi), %ebx - addl %ebx, %eax - adcl $0, %eax - roll $8, %eax - inc %esi - testl $2, %esi - jz 10b + // Handle 2-byte-aligned regions +l20: add ax, [esi] + lea esi, [esi + 2] + adc eax, 0 + jmp l10b +l25: + test esi, 1 + jz l30f + // buf is odd + dec ecx + jl l90 + movzb ebx, [esi] + add eax, ebx + adc eax, 0 + rol eax, 8 + inc esi + test esi, 2 + jz l10b -30: subl $2, %ecx - ja 20b - je 32f - addl $2, %ecx - jz 80f - movzbl (%esi),%ebx # csumming 1 byte, 2-aligned - addl %ebx, %eax - adcl $0, %eax - jmp 80f -32: - addw (%esi), %ax # csumming 2 bytes, 2-aligned - adcl $0, %eax - jmp 80f +l30: sub ecx, 2 + ja l20 + je l32 + add ecx, 2 + jz l80 + movzb ebx, [esi] // csumming 1 byte, 2-aligned + add eax, ebx + adc eax, 0 + jmp l80 +l32: + add ax, [esi] // csumming 2 bytes, 2-aligned + adc eax, 0 + jmp l80 -40: - addl -128(%esi), %eax - adcl -124(%esi), %eax - adcl -120(%esi), %eax - adcl -116(%esi), %eax - adcl -112(%esi), %eax - adcl -108(%esi), %eax - adcl -104(%esi), %eax - adcl -100(%esi), %eax - adcl -96(%esi), %eax - adcl -92(%esi), %eax - adcl -88(%esi), %eax - adcl -84(%esi), %eax - adcl -80(%esi), %eax - adcl -76(%esi), %eax - adcl -72(%esi), %eax - adcl -68(%esi), %eax - adcl -64(%esi), %eax - adcl -60(%esi), %eax - adcl -56(%esi), %eax - adcl -52(%esi), %eax - adcl -48(%esi), %eax - adcl -44(%esi), %eax - adcl -40(%esi), %eax - adcl -36(%esi), %eax - adcl -32(%esi), %eax - adcl -28(%esi), %eax - adcl -24(%esi), %eax - adcl -20(%esi), %eax - adcl -16(%esi), %eax - adcl -12(%esi), %eax - adcl -8(%esi), %eax - adcl -4(%esi), %eax -45: - lea 128(%esi), %esi - adcl $0, %eax - dec %ecx - jge 40b - movl %edx, %ecx -50: andl $3, %ecx - jz 80f +l40: + add eax, [esi -128] + adc eax, [esi -124] + adc eax, [esi -120] + adc eax, [esi -116] + adc eax, [esi -112] + adc eax, [esi -108] + adc eax, [esi -104] + adc eax, [esi -100] + adc eax, [esi -96] + adc eax, [esi -92] + adc eax, [esi -88] + adc eax, [esi -84] + adc eax, [esi -80] + adc eax, [esi -76] + adc eax, [esi -72] + adc eax, [esi -68] + adc eax, [esi -64] + adc eax, [esi -60] + adc eax, [esi -56] + adc eax, [esi -52] + adc eax, [esi -48] + adc eax, [esi -44] + adc eax, [esi -40] + adc eax, [esi -36] + adc eax, [esi -32] + adc eax, [esi -28] + adc eax, [esi -24] + adc eax, [esi -20] + adc eax, [esi -16] + adc eax, [esi -12] + adc eax, [esi -8] + adc eax, [esi -4] +l45: + lea esi, [esi + 128] + adc eax, 0 + dec ecx + jge l40 + mov ecx, edx +l50: and ecx, 3 + jz l80 - # Handle the last 1-3 bytes without jumping - notl %ecx # 1->2, 2->1, 3->0, higher bits are masked - movl $0xffffff,%ebx # by the shll and shrl instructions - shll $3,%ecx - shrl %cl,%ebx - andl -128(%esi),%ebx # esi is 4-aligned so should be ok - addl %ebx,%eax - adcl $0,%eax -80: - testl $1, 12(%esp) - jz 90f - roll $8, %eax -90: - popl %ebx - popl %esi + // Handle the last 1-3 bytes without jumping + not ecx // 1->2, 2->1, 3->0, higher bits are masked + mov ebx, HEX(ffffff) // by the shll and shrl instructions + shl ecx, 3 + shr ebx, cl + and ebx, [esi -128] // esi is 4-aligned so should be ok + add eax, ebx + adc eax, 0 +l80: + test dword ptr [esp + 12], 1 + jz l90 + rol eax, 8 +l90: + pop ebx + pop esi ret - + #endif + +END diff --git a/reactos/ntoskrnl/include/internal/i386/intrin_i.h b/reactos/ntoskrnl/include/internal/i386/intrin_i.h index 6cb2a7cbf0a..3a2664ba5b4 100644 --- a/reactos/ntoskrnl/include/internal/i386/intrin_i.h +++ b/reactos/ntoskrnl/include/internal/i386/intrin_i.h @@ -144,6 +144,32 @@ __sgdt(OUT PVOID Descriptor) sgdt [eax] } } + +FORCEINLINE +VOID +__fxsave(OUT PFX_SAVE_AREA SaveArea) +{ + __asm mov eax, SaveArea + __asm fxsave [eax] +} + +FORCEINLINE +VOID +__fxrstor(IN PFX_SAVE_AREA SaveArea) +{ + __asm mov eax, SaveArea + __asm fxrstor [eax] +} + +FORCEINLINE +VOID +__fnsave(OUT PFLOATING_SAVE_AREA SaveArea) +{ + __asm mov eax, SaveArea + __asm fnsave [eax] + __asm wait; +} + #define Ke386GetGlobalDescriptorTable __sgdt FORCEINLINE @@ -268,6 +294,28 @@ Ke386SetGs(IN USHORT Value) __asm mov gs, ax; } +extern ULONG KeI386FxsrPresent; + +FORCEINLINE +VOID +Ke386SaveFpuState(IN PVOID SaveArea) +{ + if (KeI386FxsrPresent) + { + __fxsave(SaveArea); + } + else + { + __fnsave(SaveArea); + } +} + +#define Ke386FnSave __fnsave +#define Ke386FxSave __fxsave +// The name suggest, that the original author didn't understand what frstor means +#define Ke386FxStore __fxrstor + + #else #error Unknown compiler for inline assembler #endif diff --git a/reactos/ntoskrnl/ke/i386/cpu.c b/reactos/ntoskrnl/ke/i386/cpu.c index a8db4d5b5dd..2606297c1b4 100644 --- a/reactos/ntoskrnl/ke/i386/cpu.c +++ b/reactos/ntoskrnl/ke/i386/cpu.c @@ -109,7 +109,13 @@ RDMSR(IN ULONG Register) #define CX86_CCR1 0xc1 /* NSC/Cyrix CPU indexed register access macros */ -#define getCx86(reg) ({ WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23); }) +static __inline +ULONG +getCx86(UCHAR reg) +{ + WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22, reg); + return READ_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x23); +} #define setCx86(reg, data) do { \ WRITE_PORT_UCHAR((PUCHAR)(ULONG_PTR)0x22,(reg)); \ diff --git a/reactos/ntoskrnl/mm/ARM3/i386/init.c b/reactos/ntoskrnl/mm/ARM3/i386/init.c index 116271c6618..0f91b30ce67 100644 --- a/reactos/ntoskrnl/mm/ARM3/i386/init.c +++ b/reactos/ntoskrnl/mm/ARM3/i386/init.c @@ -18,15 +18,16 @@ /* GLOBALS ********************************************************************/ /* Template PTE and PDE for a kernel page */ -MMPTE ValidKernelPde = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1, .u.Hard.Accessed = 1}; -MMPTE ValidKernelPte = {.u.Hard.Valid = 1, .u.Hard.Write = 1, .u.Hard.Dirty = 1, .u.Hard.Accessed = 1}; +MMPTE ValidKernelPde = {{PTE_VALID|PTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}; +MMPTE ValidKernelPte = {{PTE_VALID|PTE_READWRITE|PTE_DIRTY|PTE_ACCESSED}}; /* Template PDE for a demand-zero page */ -MMPDE DemandZeroPde = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)}; -MMPTE DemandZeroPte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS)}; +MMPDE DemandZeroPde = {{MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS}}; +MMPTE DemandZeroPte = {{MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS}}; /* Template PTE for prototype page */ -MMPTE PrototypePte = {.u.Long = (MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << PAGE_SHIFT)}; +MMPTE PrototypePte = {{(MM_READWRITE << MM_PTE_SOFTWARE_PROTECTION_BITS) | + PTE_PROTOTYPE | (MI_PTE_LOOKUP_NEEDED << PAGE_SHIFT)}}; /* PRIVATE FUNCTIONS **********************************************************/ diff --git a/reactos/ntoskrnl/mm/ARM3/miarm.h b/reactos/ntoskrnl/mm/ARM3/miarm.h index 4c17cd27973..7b24a18062d 100644 --- a/reactos/ntoskrnl/mm/ARM3/miarm.h +++ b/reactos/ntoskrnl/mm/ARM3/miarm.h @@ -128,6 +128,14 @@ C_ASSERT(SYSTEM_PD_SIZE == PAGE_SIZE); #define PTE_EXECUTE_READWRITE 0x2 // Not worrying about NX yet #define PTE_EXECUTE_WRITECOPY 0x200 #define PTE_PROTOTYPE 0x400 + +// +// State Flags +// +#define PTE_VALID 0x1 +#define PTE_ACCESSED 0x20 +#define PTE_DIRTY 0x40 + // // Cache flags // diff --git a/reactos/tools/unicode/string.c b/reactos/tools/unicode/string.c index d9f6144bb9a..c55a96f3669 100644 --- a/reactos/tools/unicode/string.c +++ b/reactos/tools/unicode/string.c @@ -21,7 +21,6 @@ #include #include #include -#include #define WINE_UNICODE_INLINE /* nothing */ #include "wine/unicode.h" @@ -465,7 +464,7 @@ int vsnprintfW(WCHAR *str, size_t len, const WCHAR *format, va_list valist) *fmta = '\0'; if (*iter == 'a' || *iter == 'A' || *iter == 'e' || *iter == 'E' || - *iter == 'f' || *iter == 'F' || + *iter == 'f' || *iter == 'F' || *iter == 'g' || *iter == 'G') sprintf(bufaiter, fmtbufa, va_arg(valist, double)); else diff --git a/reactos/tools/unicode/wine/unicode.h b/reactos/tools/unicode/wine/unicode.h index 7f64b3c5f78..3bd09a8995b 100644 --- a/reactos/tools/unicode/wine/unicode.h +++ b/reactos/tools/unicode/wine/unicode.h @@ -18,10 +18,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#ifndef __WINE_UNICODE_H -#define __WINE_UNICODE_H +#ifndef __WINE_WINE_UNICODE_H +#define __WINE_WINE_UNICODE_H #include +#include #include // Definitions copied from @@ -44,12 +45,24 @@ #define WC_NO_BEST_FIT_CHARS 1024 #define WC_ERR_INVALID_CHARS 0x0080 +#ifdef __WINE_WINE_TEST_H +#error This file should not be used in Wine tests +#endif + +#ifdef __cplusplus +extern "C" { +#endif + #ifndef WINE_UNICODE_API -#define WINE_UNICODE_API DECLSPEC_IMPORT +# if defined(_MSC_VER) || defined(__MINGW32__) +# define WINE_UNICODE_API DECLSPEC_IMPORT +# else +# define WINE_UNICODE_API +# endif #endif #ifndef WINE_UNICODE_INLINE -#define WINE_UNICODE_INLINE extern inline +#define WINE_UNICODE_INLINE static inline #endif /* code page info common to SBCS and DBCS */ @@ -117,20 +130,17 @@ extern int snprintfW( WCHAR *str, size_t len, const WCHAR *format, ... ); extern int vsprintfW( WCHAR *str, const WCHAR *format, va_list valist ); extern int vsnprintfW( WCHAR *str, size_t len, const WCHAR *format, va_list valist ); -WINE_UNICODE_INLINE int wine_is_dbcs_leadbyte( const union cptable *table, unsigned char ch ); WINE_UNICODE_INLINE int wine_is_dbcs_leadbyte( const union cptable *table, unsigned char ch ) { return (table->info.char_size == 2) && (table->dbcs.cp2uni_leadbytes[ch]); } -WINE_UNICODE_INLINE WCHAR tolowerW( WCHAR ch ); WINE_UNICODE_INLINE WCHAR tolowerW( WCHAR ch ) { extern WINE_UNICODE_API const WCHAR wine_casemap_lower[]; return ch + wine_casemap_lower[wine_casemap_lower[ch >> 8] + (ch & 0xff)]; } -WINE_UNICODE_INLINE WCHAR toupperW( WCHAR ch ); WINE_UNICODE_INLINE WCHAR toupperW( WCHAR ch ) { extern WINE_UNICODE_API const WCHAR wine_casemap_upper[]; @@ -139,74 +149,62 @@ WINE_UNICODE_INLINE WCHAR toupperW( WCHAR ch ) /* the character type contains the C1_* flags in the low 12 bits */ /* and the C2_* type in the high 4 bits */ -WINE_UNICODE_INLINE unsigned short get_char_typeW( WCHAR ch ); WINE_UNICODE_INLINE unsigned short get_char_typeW( WCHAR ch ) { extern WINE_UNICODE_API const unsigned short wine_wctype_table[]; return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)]; } -WINE_UNICODE_INLINE int iscntrlW( WCHAR wc ); WINE_UNICODE_INLINE int iscntrlW( WCHAR wc ) { return get_char_typeW(wc) & C1_CNTRL; } -WINE_UNICODE_INLINE int ispunctW( WCHAR wc ); WINE_UNICODE_INLINE int ispunctW( WCHAR wc ) { return get_char_typeW(wc) & C1_PUNCT; } -WINE_UNICODE_INLINE int isspaceW( WCHAR wc ); WINE_UNICODE_INLINE int isspaceW( WCHAR wc ) { return get_char_typeW(wc) & C1_SPACE; } -WINE_UNICODE_INLINE int isdigitW( WCHAR wc ); WINE_UNICODE_INLINE int isdigitW( WCHAR wc ) { return get_char_typeW(wc) & C1_DIGIT; } -WINE_UNICODE_INLINE int isxdigitW( WCHAR wc ); WINE_UNICODE_INLINE int isxdigitW( WCHAR wc ) { return get_char_typeW(wc) & C1_XDIGIT; } -WINE_UNICODE_INLINE int islowerW( WCHAR wc ); WINE_UNICODE_INLINE int islowerW( WCHAR wc ) { return get_char_typeW(wc) & C1_LOWER; } -WINE_UNICODE_INLINE int isupperW( WCHAR wc ); WINE_UNICODE_INLINE int isupperW( WCHAR wc ) { return get_char_typeW(wc) & C1_UPPER; } -WINE_UNICODE_INLINE int isalnumW( WCHAR wc ); WINE_UNICODE_INLINE int isalnumW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT|C1_LOWER|C1_UPPER); } -WINE_UNICODE_INLINE int isalphaW( WCHAR wc ); WINE_UNICODE_INLINE int isalphaW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_LOWER|C1_UPPER); } -WINE_UNICODE_INLINE int isgraphW( WCHAR wc ); WINE_UNICODE_INLINE int isgraphW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER); } -WINE_UNICODE_INLINE int isprintW( WCHAR wc ); WINE_UNICODE_INLINE int isprintW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_BLANK|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER); @@ -214,15 +212,13 @@ WINE_UNICODE_INLINE int isprintW( WCHAR wc ) /* some useful string manipulation routines */ -WINE_UNICODE_INLINE unsigned int strlenW( const WCHAR *str ); WINE_UNICODE_INLINE unsigned int strlenW( const WCHAR *str ) { const WCHAR *s = str; while (*s) s++; - return s - str; + return (unsigned int)(s - str); } -WINE_UNICODE_INLINE WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ); WINE_UNICODE_INLINE WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) { WCHAR *p = dst; @@ -233,14 +229,12 @@ WINE_UNICODE_INLINE WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) /* strncpy doesn't do what you think, don't use it */ #define strncpyW(d,s,n) error do_not_use_strncpyW_use_lstrcpynW_or_memcpy_instead -WINE_UNICODE_INLINE int strcmpW( const WCHAR *str1, const WCHAR *str2 ); WINE_UNICODE_INLINE int strcmpW( const WCHAR *str1, const WCHAR *str2 ) { while (*str1 && (*str1 == *str2)) { str1++; str2++; } return *str1 - *str2; } -WINE_UNICODE_INLINE int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ); WINE_UNICODE_INLINE int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) { if (n <= 0) return 0; @@ -248,21 +242,18 @@ WINE_UNICODE_INLINE int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) return *str1 - *str2; } -WINE_UNICODE_INLINE WCHAR *strcatW( WCHAR *dst, const WCHAR *src ); WINE_UNICODE_INLINE WCHAR *strcatW( WCHAR *dst, const WCHAR *src ) { strcpyW( dst + strlenW(dst), src ); return dst; } -WINE_UNICODE_INLINE WCHAR *strchrW( const WCHAR *str, WCHAR ch ); WINE_UNICODE_INLINE WCHAR *strchrW( const WCHAR *str, WCHAR ch ) { do { if (*str == ch) return (WCHAR *)(ULONG_PTR)str; } while (*str++); return NULL; } -WINE_UNICODE_INLINE WCHAR *strrchrW( const WCHAR *str, WCHAR ch ); WINE_UNICODE_INLINE WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) { WCHAR *ret = NULL; @@ -270,14 +261,12 @@ WINE_UNICODE_INLINE WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) return ret; } -WINE_UNICODE_INLINE WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept ); WINE_UNICODE_INLINE WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept ) { for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)(ULONG_PTR)str; return NULL; } -WINE_UNICODE_INLINE size_t strspnW( const WCHAR *str, const WCHAR *accept ); WINE_UNICODE_INLINE size_t strspnW( const WCHAR *str, const WCHAR *accept ) { const WCHAR *ptr; @@ -285,7 +274,6 @@ WINE_UNICODE_INLINE size_t strspnW( const WCHAR *str, const WCHAR *accept ) return ptr - str; } -WINE_UNICODE_INLINE size_t strcspnW( const WCHAR *str, const WCHAR *reject ); WINE_UNICODE_INLINE size_t strcspnW( const WCHAR *str, const WCHAR *reject ) { const WCHAR *ptr; @@ -293,7 +281,6 @@ WINE_UNICODE_INLINE size_t strcspnW( const WCHAR *str, const WCHAR *reject ) return ptr - str; } -WINE_UNICODE_INLINE WCHAR *strlwrW( WCHAR *str ); WINE_UNICODE_INLINE WCHAR *strlwrW( WCHAR *str ) { WCHAR *ret = str; @@ -301,7 +288,6 @@ WINE_UNICODE_INLINE WCHAR *strlwrW( WCHAR *str ) return ret; } -WINE_UNICODE_INLINE WCHAR *struprW( WCHAR *str ); WINE_UNICODE_INLINE WCHAR *struprW( WCHAR *str ) { WCHAR *ret = str; @@ -309,7 +295,6 @@ WINE_UNICODE_INLINE WCHAR *struprW( WCHAR *str ) return ret; } -WINE_UNICODE_INLINE WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n ); WINE_UNICODE_INLINE WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n ) { const WCHAR *end; @@ -317,7 +302,6 @@ WINE_UNICODE_INLINE WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n ) return NULL; } -WINE_UNICODE_INLINE WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n ); WINE_UNICODE_INLINE WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n ) { const WCHAR *end; @@ -326,13 +310,11 @@ WINE_UNICODE_INLINE WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n ) return ret; } -WINE_UNICODE_INLINE long int atolW( const WCHAR *str ); WINE_UNICODE_INLINE long int atolW( const WCHAR *str ) { return strtolW( str, (WCHAR **)0, 10 ); } -WINE_UNICODE_INLINE int atoiW( const WCHAR *str ); WINE_UNICODE_INLINE int atoiW( const WCHAR *str ) { return (int)atolW( str ); @@ -340,4 +322,8 @@ WINE_UNICODE_INLINE int atoiW( const WCHAR *str ) #undef WINE_UNICODE_INLINE -#endif /* __WINE_UNICODE_H */ +#ifdef __cplusplus +} +#endif + +#endif /* __WINE_WINE_UNICODE_H */