Merging r37048, r37051, r37052, r37055 from the-real-msvc branch
[reactos.git] / reactos / lib / 3rdparty / mingw / crt1.c
index 6c54beb..4f6b17c 100644 (file)
@@ -11,7 +11,7 @@
 
 /* Hide the declaration of _fmode with dllimport attribute in stdlib.h to
    avoid problems with older GCC. */
-#define __IN_MINGW_RUNTIME 
+#define __IN_MINGW_RUNTIME
 #include <stdlib.h>
 #include <stdio.h>
 #include <io.h>
@@ -34,21 +34,24 @@ extern void _pei386_runtime_relocator (void);
 extern int main (int, char **, char **);
 
 /*
- * Must have the correct app type for MSVCRT. 
+ * Must have the correct app type for MSVCRT.
  */
 
 #ifdef __MSVCRT__
 #define __UNKNOWN_APP    0
 #define __CONSOLE_APP    1
 #define __GUI_APP        2
-__MINGW_IMPORT void __set_app_type(int);
+#ifndef _M_PPC
+__MINGW_IMPORT
+#endif
+void __set_app_type(int);
 #endif /* __MSVCRT__ */
 
 /*  Global _fmode for this .exe, not the one in msvcrt.dll,
     The default is set in txtmode.o in libmingw32.a */
 /* Override the dllimport'd declarations in stdlib.h */
-#undef _fmode 
-extern int _fmode; 
+#undef _fmode
+extern int _fmode;
 #ifdef __MSVCRT__
 extern int* __p__fmode(void); /* To access the dll _fmode */
 #endif
@@ -90,7 +93,7 @@ _mingw32_init_fmode (void)
 
     /*  Now sync  the dll _fmode to the  one for this .exe.  */
 #ifdef __MSVCRT__
-    *__p__fmode() = _fmode;    
+    *__p__fmode() = _fmode;
 #else
     *_imp___fmode_dll = _fmode;
 #endif
@@ -189,7 +192,7 @@ __mingw_CRTStartup (void)
    * Set up the top-level exception handler so that signal handling
    * works as expected. The mapping between ANSI/POSIX signals and
    * Win32 SE is not 1-to-1, so caveat emptore.
-   * 
+   *
    */
   SetUnhandledExceptionFilter (_gnu_exception_handler);
 
@@ -211,10 +214,13 @@ __mingw_CRTStartup (void)
    * NOTE: DLLs don't do this because that would be rude!
    */
   _mingw32_init_fmode ();
-  
+
    /* Adust references to dllimported data that have non-zero offsets.  */
+#if defined(__i386__)
   _pei386_runtime_relocator ();
+#endif
 
+#if defined(__GNUC__)
 #if defined(__i386__)
   /* Align the stack to 16 bytes for the sake of SSE ops in main
      or in functions inlined into main.  */
@@ -227,6 +233,17 @@ __mingw_CRTStartup (void)
   asm  __volatile__  ("li 0,15\n\tandc 1,1,0" : : : "r1");
 #else
 #error Unsupported architecture
+#endif
+#elif defined(_MSC_VER)
+#if defined(_M_IX86)
+  /* Align the stack to 16 bytes for the sake of SSE ops in main
+     or in functions inlined into main.  */
+  __asm and esp, 0FFFFFFF0h
+#else
+#error TODO
+#endif
+#else
+#error TODO
 #endif
 
   /*