Author: hyperion
Date: Thu Jun 18 04:41:56 2009
New Revision: 41442
URL:
http://svn.reactos.org/svn/reactos?rev=41442&view=rev
Log:
Miscellaneous Visual C++ compilation fixes
modified include/crt/mingw32/intrin_x86.h
modified include/crt/msc/intrin.h
Fixed declarations of _InterlockedDecrement16 and _InterlockedIncrement16
Fixed declarations of __readcr0, __readcr2, __readcr3 and __readcr4 for x86
Implement __readdr and __writedr for x86 too
Added missing semicolon
modified include/crt/stdlib.h
modified lib/3rdparty/mingw/crtexe.c
Use Visual C++-compatible attribute placement
modified lib/3rdparty/mingw/crtexe.c
Get rid of useless assembly, replace with __writefsdword (it's still useless)
modified lib/3rdparty/mingw/mingw.rbuild
Disable Visual C++ warning C4733 ("Inline asm assigning to 'FS:0' :
handler not registered as safe handler") for mingw_wmain
modified lib/sdk/scrnsave/scrnsave.c
Silence a warning
modified ReactOS-generic.rbuild
Disable Visual C++ warning C4711 ("function 'function' selected for inline
expansion") globally
modified tools/rbuild/backend/mingw/compilers/msc.mak
Fix Visual C++ compiler rules to emit an uniquely named PDB for each object file
Modified:
trunk/reactos/ReactOS-generic.rbuild
trunk/reactos/include/crt/mingw32/intrin_x86.h
trunk/reactos/include/crt/msc/intrin.h
trunk/reactos/include/crt/stdlib.h
trunk/reactos/lib/3rdparty/mingw/crtexe.c
trunk/reactos/lib/3rdparty/mingw/mingw.rbuild
trunk/reactos/lib/sdk/scrnsave/scrnsave.c
trunk/reactos/tools/rbuild/backend/mingw/compilers/msc.mak
Modified: trunk/reactos/ReactOS-generic.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/ReactOS-generic.rbuild?rev…
==============================================================================
--- trunk/reactos/ReactOS-generic.rbuild [iso-8859-1] (original)
+++ trunk/reactos/ReactOS-generic.rbuild [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -127,4 +127,6 @@
</directory>
<compilerflag compiler="cxx"
compilerset="gcc">-Wno-non-virtual-dtor</compilerflag>
+
+ <compilerflag compilerset="msc">/wd4711</compilerflag>
</group>
Modified: trunk/reactos/include/crt/mingw32/intrin_x86.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/mingw32/intrin…
==============================================================================
--- trunk/reactos/include/crt/mingw32/intrin_x86.h [iso-8859-1] (original)
+++ trunk/reactos/include/crt/mingw32/intrin_x86.h [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -479,12 +479,12 @@
return _InterlockedExchangeAdd(lpAddend, 1) + 1;
}
-__INTRIN_INLINE long _InterlockedDecrement16(volatile short * const lpAddend)
+__INTRIN_INLINE short _InterlockedDecrement16(volatile short * const lpAddend)
{
return _InterlockedExchangeAdd16(lpAddend, -1) - 1;
}
-__INTRIN_INLINE long _InterlockedIncrement16(volatile short * const lpAddend)
+__INTRIN_INLINE short _InterlockedIncrement16(volatile short * const lpAddend)
{
return _InterlockedExchangeAdd16(lpAddend, 1) + 1;
}
@@ -1132,7 +1132,6 @@
{
__asm__("mov %[Data], %%cr8" : : [Data] "q" (Data) :
"memory");
}
-#endif
__INTRIN_INLINE unsigned __int64 __readcr0(void)
{
@@ -1162,11 +1161,38 @@
return value;
}
-#ifdef _M_AMD64
__INTRIN_INLINE unsigned __int64 __readcr8(void)
{
unsigned __int64 value;
__asm__ __volatile__("movq %%cr8, %q[value]" : [value] "=q"
(value));
+ return value;
+}
+#else
+__INTRIN_INLINE unsigned long __readcr0(void)
+{
+ unsigned long value;
+ __asm__ __volatile__("mov %%cr0, %[value]" : [value] "=q" (value));
+ return value;
+}
+
+__INTRIN_INLINE unsigned long __readcr2(void)
+{
+ unsigned long value;
+ __asm__ __volatile__("mov %%cr2, %[value]" : [value] "=q" (value));
+ return value;
+}
+
+__INTRIN_INLINE unsigned long __readcr3(void)
+{
+ unsigned long value;
+ __asm__ __volatile__("mov %%cr3, %[value]" : [value] "=q" (value));
+ return value;
+}
+
+__INTRIN_INLINE unsigned long __readcr4(void)
+{
+ unsigned long value;
+ __asm__ __volatile__("mov %%cr4, %[value]" : [value] "=q" (value));
return value;
}
#endif
@@ -1206,6 +1232,70 @@
}
__INTRIN_INLINE void __writedr(unsigned reg, unsigned __int64 value)
+{
+ switch (reg)
+ {
+ case 0:
+ __asm__("movq %q[value], %%dr0" : : [value] "q" (value) :
"memory");
+ break;
+ case 1:
+ __asm__("movq %q[value], %%dr1" : : [value] "q" (value) :
"memory");
+ break;
+ case 2:
+ __asm__("movq %q[value], %%dr2" : : [value] "q" (value) :
"memory");
+ break;
+ case 3:
+ __asm__("movq %q[value], %%dr3" : : [value] "q" (value) :
"memory");
+ break;
+ case 4:
+ __asm__("movq %q[value], %%dr4" : : [value] "q" (value) :
"memory");
+ break;
+ case 5:
+ __asm__("movq %q[value], %%dr5" : : [value] "q" (value) :
"memory");
+ break;
+ case 6:
+ __asm__("movq %q[value], %%dr6" : : [value] "q" (value) :
"memory");
+ break;
+ case 7:
+ __asm__("movq %q[value], %%dr7" : : [value] "q" (value) :
"memory");
+ break;
+ }
+}
+#else
+__INTRIN_INLINE unsigned int __readdr(unsigned int reg)
+{
+ unsigned int value;
+ switch (reg)
+ {
+ case 0:
+ __asm__ __volatile__("movq %%dr0, %q[value]" : [value] "=q"
(value));
+ break;
+ case 1:
+ __asm__ __volatile__("movq %%dr1, %q[value]" : [value] "=q"
(value));
+ break;
+ case 2:
+ __asm__ __volatile__("movq %%dr2, %q[value]" : [value] "=q"
(value));
+ break;
+ case 3:
+ __asm__ __volatile__("movq %%dr3, %q[value]" : [value] "=q"
(value));
+ break;
+ case 4:
+ __asm__ __volatile__("movq %%dr4, %q[value]" : [value] "=q"
(value));
+ break;
+ case 5:
+ __asm__ __volatile__("movq %%dr5, %q[value]" : [value] "=q"
(value));
+ break;
+ case 6:
+ __asm__ __volatile__("movq %%dr6, %q[value]" : [value] "=q"
(value));
+ break;
+ case 7:
+ __asm__ __volatile__("movq %%dr7, %q[value]" : [value] "=q"
(value));
+ break;
+ }
+ return value;
+}
+
+__INTRIN_INLINE void __writedr(unsigned reg, unsigned int value)
{
switch (reg)
{
Modified: trunk/reactos/include/crt/msc/intrin.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/msc/intrin.h?r…
==============================================================================
--- trunk/reactos/include/crt/msc/intrin.h [iso-8859-1] (original)
+++ trunk/reactos/include/crt/msc/intrin.h [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -35,8 +35,8 @@
long _InterlockedAddLargeStatistic(volatile __int64 * const Addend, const long Value);
long _InterlockedDecrement(volatile long * const lpAddend);
long _InterlockedIncrement(volatile long * const lpAddend);
-long _InterlockedDecrement16(volatile short * const lpAddend);
-long _InterlockedIncrement16(volatile short * const lpAddend);
+short _InterlockedDecrement16(volatile short * const lpAddend);
+short _InterlockedIncrement16(volatile short * const lpAddend);
unsigned char _interlockedbittestandreset(volatile long * a, const long b);
unsigned char _interlockedbittestandset(volatile long * a, const long b);
@@ -92,7 +92,7 @@
void __incfsdword(const unsigned long Offset);
void __addfsbyte(const unsigned long Offset, const unsigned char Data);
void __addfsword(const unsigned long Offset, const unsigned short Data);
-void __addfsdword(const unsigned long Offset, const unsigned int Data)
+void __addfsdword(const unsigned long Offset, const unsigned int Data);
#endif
@@ -153,19 +153,21 @@
#ifdef _M_AMD64
void __writecr8(const unsigned __int64 Data);
-#endif
-
unsigned __int64 __readcr0(void);
unsigned __int64 __readcr2(void);
unsigned __int64 __readcr3(void);
unsigned __int64 __readcr4(void);
-
-#ifdef _M_AMD64
unsigned __int64 __readcr8(void);
-#endif
-
unsigned __int64 __readdr(unsigned int reg);
void __writedr(unsigned reg, unsigned __int64 value);
+#else
+unsigned long __readcr0(void);
+unsigned long __readcr2(void);
+unsigned long __readcr3(void);
+unsigned long __readcr4(void);
+unsigned int __readdr(unsigned int reg);
+void __writedr(unsigned reg, unsigned int value);
+#endif
void __invlpg(void * const Address);
Modified: trunk/reactos/include/crt/stdlib.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/stdlib.h?rev=4…
==============================================================================
--- trunk/reactos/include/crt/stdlib.h [iso-8859-1] (original)
+++ trunk/reactos/include/crt/stdlib.h [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -304,7 +304,7 @@
_CRTIMP __declspec(noreturn) void __cdecl _exit(int _Code);
#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */
/* C99 function name */
- void __cdecl __declspec(noreturn) _Exit(int); /* Declare to get noreturn attribute.
*/
+ __declspec(noreturn) void __cdecl _Exit(int); /* Declare to get noreturn attribute.
*/
__CRT_INLINE void __cdecl _Exit(int status)
{ _exit(status); }
#endif
@@ -312,7 +312,7 @@
#pragma push_macro("abort")
#undef abort
#endif
- void __cdecl __declspec(noreturn) abort(void);
+ __declspec(noreturn) void __cdecl abort(void);
#if __MINGW_GNUC_PREREQ(4,4)
#pragma pop_macro("abort")
#endif
Modified: trunk/reactos/lib/3rdparty/mingw/crtexe.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/mingw/crtexe.…
==============================================================================
--- trunk/reactos/lib/3rdparty/mingw/crtexe.c [iso-8859-1] (original)
+++ trunk/reactos/lib/3rdparty/mingw/crtexe.c [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -20,6 +20,7 @@
#include <tchar.h>
#include <sect_attribs.h>
#include <locale.h>
+#include <intrin.h>
#ifndef __winitenv
extern wchar_t ***_imp____winitenv;
@@ -86,7 +87,7 @@
static _startupinfo startinfo;
extern void _pei386_runtime_relocator (void);
-static CALLBACK long _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
+static long CALLBACK _gnu_exception_handler (EXCEPTION_POINTERS * exception_data);
static LONG __mingw_vex(EXCEPTION_POINTERS * exception_data);
#ifdef WPRFLAG
static void duplicate_ppstrings (int ac, wchar_t ***av);
@@ -169,7 +170,7 @@
STARTUPINFO StartupInfo;
BOOL inDoubleQuote = FALSE;
memset (&StartupInfo, 0, sizeof (STARTUPINFO));
-
+
if (mingw_app_type)
GetStartupInfo (&StartupInfo);
{
@@ -206,26 +207,18 @@
_ASSERTE(__native_startup_state == __initialized);
if (! nested)
(VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock,
0);
-
+
if (__dyn_tls_init_callback != NULL && _IsNonwritableInCurrentImage ((PBYTE)
&__dyn_tls_init_callback))
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
-
+
_pei386_runtime_relocator ();
-
- #ifdef _WIN64
- __asm__ __volatile__ (
- "xorq %rax,%rax\n\t"
- "decq %rax\n\t"
- "movq %rax,%gs:0" "\n");
- #else
- __asm__ __volatile__ (
- "xorl %eax,%eax\n\t"
- "decl %eax\n\t"
- "movl %eax,%fs:0" "\n");
- #endif
+
+#if defined(__i386__) || defined(_M_IX86)
+ __writefsdword(0, 0xffffffff);
+#endif
AddVectoredExceptionHandler (0, (PVECTORED_EXCEPTION_HANDLER)__mingw_vex);
SetUnhandledExceptionFilter (_gnu_exception_handler);
-
+
_fpreset ();
if (mingw_app_type)
@@ -330,7 +323,7 @@
return 0;
}
-static CALLBACK long
+static long CALLBACK
_gnu_exception_handler (EXCEPTION_POINTERS * exception_data)
{
void (*old_handler) (int);
@@ -466,7 +459,7 @@
char **avl;
int i;
char **n = (char **) malloc (sizeof (char *) * (ac + 1));
-
+
avl=*av;
for (i=0; i < ac; i++)
{
Modified: trunk/reactos/lib/3rdparty/mingw/mingw.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/3rdparty/mingw/mingw.r…
==============================================================================
--- trunk/reactos/lib/3rdparty/mingw/mingw.rbuild [iso-8859-1] (original)
+++ trunk/reactos/lib/3rdparty/mingw/mingw.rbuild [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -39,6 +39,7 @@
<define name="_CRTBLD" />
<define name="WPRFLAG" />
<include base="ReactOS">include/reactos/mingw-w64</include>
+ <compilerflag compilerset="msc">/wd4733</compilerflag>
<file>crt0_w.c</file>
<file>crtexe.c</file>
<file>dllargv.c</file>
Modified: trunk/reactos/lib/sdk/scrnsave/scrnsave.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/scrnsave/scrnsave.…
==============================================================================
--- trunk/reactos/lib/sdk/scrnsave/scrnsave.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/scrnsave/scrnsave.c [iso-8859-1] Thu Jun 18 04:41:56 2009
@@ -204,6 +204,9 @@
{
LPTSTR p;
+ UNREFERENCED_PARAMETER(nCmdShow);
+ UNREFERENCED_PARAMETER(hPrevInst);
+
hMainInstance = hInst;
// Parse the arguments
Modified: trunk/reactos/tools/rbuild/backend/mingw/compilers/msc.mak
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw…
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/compilers/msc.mak [iso-8859-1] (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/compilers/msc.mak [iso-8859-1] Thu Jun 18
04:41:56 2009
@@ -47,13 +47,13 @@
$(5): $(2) $(5).d $(3) $$(RBUILD_HELPER_TARGET) | ${call RBUILD_dir,$(5)}
$$(ECHO_CC)
- $${cl} /TC /Fo$$@ ${call RBUILD_cflags,$(1),$(4)} /c $$<
+ $${cl} /TC /Fo$$@ /Fd$(basename $$(a)).pdb ${call RBUILD_cflags,$(1),$(4)} /c $$<
else
$(5): $(2) $(3) $$(RBUILD_HELPER_TARGET) | ${call RBUILD_dir,$(5)}
$$(ECHO_CC)
- $${cl} /TC /Fo$$@ ${call RBUILD_cflags,$(1),$(4)} /c $$<
+ $${cl} /TC /Fo$$@ /Fd$(basename $$(a)).pdb ${call RBUILD_cflags,$(1),$(4)} /c $$<
endif
@@ -71,13 +71,13 @@
$(5): $(2) $(5).d $(3) $$(RBUILD_HELPER_TARGET) | ${call RBUILD_dir,$(5)}
$$(ECHO_CC)
- $${cl} /TP /Fo$$@ ${call RBUILD_cxxflags,$(1),$(4)} /c $$<
+ $${cl} /TP /Fo$$@ /Fd$(basename $$(a)).pdb ${call RBUILD_cxxflags,$(1),$(4)} /c $$<
else
$(5): $(2) $(3) $$(RBUILD_HELPER_TARGET) | ${call RBUILD_dir,$(5)}
$$(ECHO_CC)
- $${cl} /TP /Fo$$@ ${call RBUILD_cxxflags,$(1),$(4)} /c $$<
+ $${cl} /TP /Fo$$@ /Fd$(basename $$(a)).pdb ${call RBUILD_cxxflags,$(1),$(4)} /c $$<
endif