[CRT]
[reactos.git] / reactos / lib / sdk / crt / startup / mscmain.c
1 /**
2 * This file has no copyright assigned and is placed in the Public Domain.
3 * This file is part of the w64 mingw-runtime package.
4 * No warranty is given; refer to the file DISCLAIMER.PD within this package.
5 */
6
7 #include <windows.h>
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <stdarg.h>
11 #include <rtcapi.h>
12 #include <assert.h>
13 #include <internal.h>
14
15 #if defined(_M_IX86)
16 #pragma comment(linker, "/alternatename:__RTC_Initialize=__RTC_NoInitialize")
17 #elif defined(_M_IA64) || defined(_M_AMD64) || defined(_M_ARM)
18 #pragma comment(linker, "/alternatename:_RTC_Initialize=_RTC_NoInitialize")
19 #else
20 #error Unsupported platform
21 #endif
22
23 void _pei386_runtime_relocator(void)
24 {
25 }
26
27 int __mingw_init_ehandler(void)
28 {
29 /* Nothing to do */
30 return 1;
31 }
32
33 BOOL
34 WINAPI
35 _CRT_INIT0(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
36 {
37 return TRUE;
38 }
39
40 int
41 __cdecl
42 Catch_RTC_Failure(
43 int errType,
44 const wchar_t *file,
45 int line,
46 const wchar_t *module,
47 const wchar_t *format,
48 ...)
49 {
50 /* FIXME: better failure routine */
51 __debugbreak();
52 return 0;
53 }
54
55 extern
56 void
57 __cdecl
58 _RTC_NoInitialize(void)
59 {
60 /* Do nothing, if RunTmChk.lib is not pulled in */
61 }
62
63 _RTC_error_fnW
64 __cdecl
65 _CRT_RTC_INITW(
66 void *_Res0,
67 void **_Res1,
68 int _Res2,
69 int _Res3,
70 int _Res4)
71 {
72 return &Catch_RTC_Failure;
73 }
74
75 static int initialized = 0;
76
77 void
78 __main(void)
79 {
80 if (!initialized)
81 {
82 initialized = 1;
83
84 _RTC_Initialize();
85 }
86 }
87
88