/* 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>
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
/* 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
* 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);
* 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. */
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
/*