| 948 | } |
| 949 | |
| 950 | BFP_EXPORT void BFP_CALLTYPE BfpSystem_Init(int version, BfpSystemInitFlags flags) |
| 951 | { |
| 952 | gCrashErrorFunc = Crash_Error; |
| 953 | InitCPUFreq(); |
| 954 | |
| 955 | ::_set_error_mode(_OUT_TO_STDERR); |
| 956 | |
| 957 | #ifdef _DEBUG |
| 958 | ::_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); |
| 959 | #endif |
| 960 | |
| 961 | ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); |
| 962 | ::SetErrorMode(SEM_FAILCRITICALERRORS); |
| 963 | |
| 964 | if (version != BFP_VERSION) |
| 965 | { |
| 966 | char msg[1024]; |
| 967 | sprintf(msg, "Bfp build version '%d' does not match requested version '%d'", BFP_VERSION, version); |
| 968 | BfpSystem_FatalError(msg, "BFP FATAL ERROR"); |
| 969 | } |
| 970 | |
| 971 | if ((flags & BfpSystemInitFlag_InstallCrashCatcher) != 0) |
| 972 | { |
| 973 | // Set up a handler for pure virtual function calls |
| 974 | _set_purecall_handler(HandlePureVirtualFunctionCall); |
| 975 | // Set up a handler for invalid parameters such as printf(NULL); |
| 976 | _set_invalid_parameter_handler(HandleInvalidParameter); |
| 977 | |
| 978 | // Set up a handler for abort(). This is done in two steps. |
| 979 | // First we ask the CRT to call an abort handler. This is the |
| 980 | // default, but explicitly setting it seems like a good idea. |
| 981 | _set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT); |
| 982 | // Then we install our abort handler. |
| 983 | sOldSIGABRTHandler = signal(SIGABRT, &AbortHandler); |
| 984 | if (sOldSIGABRTHandler == SIG_ERR) |
| 985 | sOldSIGABRTHandler = nullptr; |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | BFP_EXPORT void BFP_CALLTYPE BfpSystem_InitCrashCatcher(BfpSystemInitFlags flags) |
| 990 | { |
no test coverage detected