int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { int argc; char *argv[64]; // max 64 command line arguments CrashLog::InitialiseCrashLog(); #if defined(UNICODE) /* Check if a win9x user started the win32 version */ if (HasBit(GetVersion(), 31)) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again."); #endif /* Convert the command line to UTF-8. We need a dedicated buffer * for this because argv[] points into this buffer and this needs to * be available between subsequent calls to FS2OTTD(). */ char *cmdline = stredup(FS2OTTD(GetCommandLine())); #if defined(_DEBUG) CreateConsole(); #endif _set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox /* setup random seed to something quite random */ SetRandomSeed(GetTickCount()); argc = ParseCommandLine(cmdline, argv, lengthof(argv)); /* Make sure our arguments contain only valid UTF-8 characters. */ for (int i = 0; i < argc; i++) ValidateString(argv[i]); openttd_main(argc, argv); free(cmdline); return 0; }
const char *VideoDriver_Dedicated::Start(const char * const *parm) { int bpp = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); _dedicated_video_mem = (bpp == 0) ? NULL : MallocT<byte>(_cur_resolution.width * _cur_resolution.height * (bpp / 8)); _screen.width = _screen.pitch = _cur_resolution.width; _screen.height = _cur_resolution.height; _screen.dst_ptr = _dedicated_video_mem; ScreenSizeChanged(); BlitterFactory::GetCurrentBlitter()->PostResize(); #if defined(WINCE) /* WinCE doesn't support console stuff */ #elif defined(WIN32) /* For win32 we need to allocate a console (debug mode does the same) */ CreateConsole(); CreateWindowsConsoleThread(); SetConsoleTitle(_T("OpenTTD Dedicated Server")); #endif #ifdef _MSC_VER /* Disable the MSVC assertion message box. */ _set_error_mode(_OUT_TO_STDERR); #endif #ifdef __OS2__ /* For OS/2 we also need to switch to console mode instead of PM mode */ OS2_SwitchToConsoleMode(); #endif DEBUG(driver, 1, "Loading dedicated server"); return NULL; }
static PyObject* msvcrt_seterrormode(PyObject *self, PyObject *args) { int mode, res; if (!PyArg_ParseTuple(args, "i", &mode)) return NULL; res = _set_error_mode(mode); return PyLong_FromLong(res); }
int main(int argc, char* argv[]) { #ifdef _WIN32 _set_error_mode(_OUT_TO_STDERR); _set_abort_behavior(0, _WRITE_ABORT_MSG); #endif // _WIN32 int result = 0; result = wgt::BWUnitTest::runTest("", argc, argv); return result; }
extern "C" void cbStartup() { cbLock = CreateMutex( NULL, FALSE, NULL ); cbReportData = NULL; swprintf_s( cbShareName, 256, L"CrashBack_%x", GetCurrentProcessId() ); GetModuleFileName( NULL, cbReportExePath, MAX_PATH ); wcscpy_s( cbReportExeDir, MAX_PATH, cbReportExePath ); wchar_t *p = wcsrchr( cbReportExeDir, '\\' ); if ( p ) *p = 0; wcscpy_s( cbReportExePath, MAX_PATH, cbReportExeDir ); wcscat_s( cbReportExePath, MAX_PATH, L"\\" ); wcscat_s( cbReportExePath, MAX_PATH, L"crashreport.exe" ); // Check that crashreport.exe exists in the app's directory. if ( GetFileAttributes( cbReportExePath ) == INVALID_FILE_ATTRIBUTES ) return; swprintf_s( cbReportCmdLine, 1024, L"\"%s\" 0x%x", cbReportExePath, GetCurrentProcessId() ); cbGetProgramName(); cbGetCmdLine(); // Set up shared memory to communicate with the report handler EXE. HANDLE hShared = CreateFileMapping( INVALID_HANDLE_VALUE, // use paging file NULL, // default security PAGE_READWRITE, // read/write access 0, // max. object size sizeof(CbReport), // buffer size cbShareName ); // name of mapping object if ( !hShared ) return; cbReportData = (CbReport *)MapViewOfFile( hShared, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(CbReport) ); if ( !cbReportData ) { CloseHandle( hShared ); return; } // Register the handlers. SetUnhandledExceptionFilter( &cbExceptionHandler ); _set_error_mode( _OUT_TO_STDERR ); _set_purecall_handler( cbPureCallHandler ); _set_new_mode( 1 ); // malloc calls the new handler on failure _set_new_handler( cbNewHandler ); _set_invalid_parameter_handler( cbInvalidParameterHandler ); _set_abort_behavior( _CALL_REPORTFAULT, _CALL_REPORTFAULT ); }
static void restore_assert_dialogs() { #ifdef _DEBUG _CrtSetReportMode(_CRT_ASSERT, report_modes[0]); _CrtSetReportFile(_CRT_ASSERT, report_files[0]); _CrtSetReportMode(_CRT_ERROR, report_modes[1]); _CrtSetReportFile(_CRT_ERROR, report_files[1]); _CrtSetReportMode(_CRT_WARN, report_modes[2]); _CrtSetReportFile(_CRT_WARN, report_files[2]); _set_error_mode(report_modes[3]); #endif // _DEBUG }
static void disable_assert_dialogs() { #ifdef _DEBUG report_modes[0] = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); report_files[0] = _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); report_modes[1] = _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); report_files[1] = _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); report_modes[2] = _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); report_files[2] = _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); report_modes[3] = _set_error_mode(_OUT_TO_STDERR); #endif // _DEBUG }
Os::Os() : resource_path_("res/"), document_path_("") { // エラーが発生したらメッセージボックスに表示する _set_error_mode(_OUT_TO_MSGBOX); // デバッグコンソールにcoutできるようにする stream_ = std::cout.rdbuf(&dbgStream_); DOUT << "Os()" << std::endl; }
BootLoader::BootLoader() { _set_error_mode(_OUT_TO_MSGBOX); m_MDumpHandle.showMessageBox(true); //AfxEnableMemoryTracking(FALSE); InitCommonControls(); m_bHasAdminRights = false; m_pUICore = NULL; m_bRetCode = false; }
BootLoader::BootLoader() { signal(SIGABRT, CustomSigAbort); _set_error_mode(_OUT_TO_MSGBOX); m_MDumpHandle.showMessageBox(true); //AfxEnableMemoryTracking(FALSE); InitCommonControls(); m_bHasAdminRights = false; m_pUICore = nullptr; m_bRetCode = false; }
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Enable assertion failure message box // http://msdn.microsoft.com/en-us/library/sas1dkb2.aspx _set_error_mode(_OUT_TO_MSGBOX); #ifdef _MSC_VER // Enable abort message box // http://msdn.microsoft.com/en-us/library/e631wekh.aspx _set_abort_behavior(0, _CALL_REPORTFAULT); #endif assert(2 + 2 == 5); return 0; }
int CALLBACK WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { int argc = __argc; char** argv = __argv; #if _MSC_VER // affects assert.h assert() _set_error_mode ( _OUT_TO_MSGBOX ); // affects crtdbg.h _ASSERT, _ASSERTE, etc _CrtSetReportMode ( _CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_WNDW | _CRTDBG_MODE_FILE ); _CrtSetReportFile ( _CRT_ASSERT, _CRTDBG_FILE_STDERR ); #endif return GlutHost ( argc, argv ); }
const char *VideoDriver_Null::Start(const char * const *parm) { #ifdef _MSC_VER /* Disable the MSVC assertion message box. */ _set_error_mode(_OUT_TO_STDERR); #endif this->ticks = GetDriverParamInt(parm, "ticks", 1000); _screen.width = _screen.pitch = _cur_resolution.width; _screen.height = _cur_resolution.height; _screen.dst_ptr = NULL; ScreenSizeChanged(); /* Do not render, nor blit */ DEBUG(misc, 1, "Forcing blitter 'null'..."); BlitterFactory::SelectBlitter("null"); return NULL; }
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) #endif { int argc; char *argv[64]; // max 64 command line arguments char *cmdline; #if !defined(UNICODE) _codepage = GetACP(); // get system codepage as some kind of a default #endif /* UNICODE */ CrashLog::InitialiseCrashLog(); #if defined(UNICODE) #if !defined(WINCE) /* Check if a win9x user started the win32 version */ if (HasBit(GetVersion(), 31)) usererror("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again."); #endif /* For UNICODE we need to convert the commandline to char* _AND_ * save it because argv[] points into this buffer and thus needs to * be available between subsequent calls to FS2OTTD() */ char cmdlinebuf[MAX_PATH]; #endif /* UNICODE */ cmdline = WIDE_TO_MB_BUFFER(GetCommandLine(), cmdlinebuf, lengthof(cmdlinebuf)); #if defined(_DEBUG) CreateConsole(); #endif #if !defined(WINCE) _set_error_mode(_OUT_TO_MSGBOX); // force assertion output to messagebox #endif /* setup random seed to something quite random */ SetRandomSeed(GetTickCount()); argc = ParseCommandLine(cmdline, argv, lengthof(argv)); ttd_main(argc, argv); return 0; }
bool CrashHandlerWindows::registerCrashHandlers() { arx_assert(m_pPreviousCrashHandlers == 0); m_pPreviousCrashHandlers = new PlatformCrashHandlers; // Unhandled exception handler. m_pPreviousCrashHandlers->m_SEHHandler = SetUnhandledExceptionFilter(SEHHandler); // Prevent dialog box. _set_error_mode(_OUT_TO_STDERR); // Catch pure virtual function calls. // Because there is one _purecall_handler for the whole process, // calling this function immediately impacts all threads. The last // caller on any thread sets the handler. // http://msdn.microsoft.com/en-us/library/t296ys27.aspx m_pPreviousCrashHandlers->m_pureCallHandler = _set_purecall_handler(PureCallHandler); // Catch new operator memory allocation exceptions. _set_new_mode(1); // Force malloc() to call new handler too m_pPreviousCrashHandlers->m_newHandler = _set_new_handler(NewHandler); // Catch invalid parameter exceptions. m_pPreviousCrashHandlers->m_invalidParameterHandler = _set_invalid_parameter_handler(InvalidParameterHandler); // Catch an abnormal program termination. _set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT); m_pPreviousCrashHandlers->m_SIGABRTHandler = signal(SIGABRT, SignalHandler); // Catch illegal instruction handler. m_pPreviousCrashHandlers->m_SIGINTHandler = signal(SIGINT, SignalHandler); // Catch a termination request. m_pPreviousCrashHandlers->m_SIGTERMHandler = signal(SIGTERM, SignalHandler); // We must also register the main thread crash handlers. return registerThreadCrashHandlers(); }
void CORE_API set_process_exception_handler(wchar_t const* app_name, wchar_t const* report_contact) { if (app_name) { wcsncpy(app_name_, app_name, MAX_APP_NAME_LEN); } else { wchar_t filename[MAX_PATH + 1]; GetModuleFileNameW(NULL, filename, MAX_PATH); _wsplitpath(filename, nullptr, nullptr, filename, nullptr); wcsncpy(app_name_, filename, MAX_APP_NAME_LEN); } if (report_contact) { wcsncpy(report_contact_, report_contact, MAX_REPORT_CONTACT_LEN); } // SEH handler ::SetUnhandledExceptionFilter(handle_seh); #if _MSC_VER>=1400 // Visual C++ CRT handlers _set_error_mode(_OUT_TO_STDERR); _set_purecall_handler(handle_purecall); //_set_new_handler(1); _set_invalid_parameter_handler(handle_invalid_parameter); _set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT); #endif set_thread_exception_handlers(); }
void debug_disable_error_message_boxes(void) { #ifdef _WIN32 /* When Windows' error message boxes are disabled for this process (as is * typically the case when running tests in an automated fashion) we disable * CRT message boxes too. */ UINT uMode = SetErrorMode(0); SetErrorMode(uMode); if (uMode & SEM_FAILCRITICALERRORS) { /* Disable assertion failure message box. * http://msdn.microsoft.com/en-us/library/sas1dkb2.aspx */ _set_error_mode(_OUT_TO_STDERR); #ifdef _MSC_VER /* Disable abort message box. * http://msdn.microsoft.com/en-us/library/e631wekh.aspx */ _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); #endif } #endif /* _WIN32 */ }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hInstance); UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); debug_log("starting process"); // Prevent error dialogs. _set_error_mode(_OUT_TO_STDERR); _CrtSetReportHook(CrtDbgHook); SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); // The Visual Studio debugger starts us in the build\ subdirectory by // default, which will prevent us from finding the test files in the html\ // directory. This workaround will locate the html\ directory even if it's // in the parent directory so we will work in the debugger out of the box. WIN32_FIND_DATA find_data; HANDLE h = FindFirstFile("html", &find_data); if (h == INVALID_HANDLE_VALUE) { h = FindFirstFile("..\\html", &find_data); if (h != INVALID_HANDLE_VALUE) { SetCurrentDirectory(".."); } } if (h != INVALID_HANDLE_VALUE) { FindClose(h); } // Prevent automatic DPI scaling. SetProcessDPIAware(); if (__argc == 1) { debug_log("running server"); HDC desktop = GetDC(NULL); assert(desktop); if (GetDeviceCaps(desktop, LOGPIXELSX) != 96) { MessageBox(NULL, "Warning: DPI scaling is enabled. Non-DPI-aware browsers will not be able to run the test.", "Warning", MB_ICONWARNING | MB_OK); } ReleaseDC(NULL, desktop); run_server(); } debug_log("opening native reference window"); if (__argc != 3) { debug_log("Unrecognized number of arguments"); return 1; } // The first argument is the magic pattern to draw on the window, encoded as hex. memset(pattern, 0, sizeof(pattern)); if (!parse_hex_magic_pattern(__argv[1], pattern)) { debug_log("Failed to parse pattern"); return 1; } // The second argument is the handle of the parent process. HANDLE parent_process = (HANDLE)_strtoui64(__argv[2], NULL, 16); message_loop(parent_process); return 0; }
int CCrashHandler::SetProcessExceptionHandlers(DWORD dwFlags) { crSetErrorMsg(_T("Unspecified error.")); // If 0 is specified as dwFlags, assume all handlers should be // installed if((dwFlags&0x1FF)==0) dwFlags |= 0x1FFF; if(dwFlags&CR_INST_STRUCTURED_EXCEPTION_HANDLER) { // Install top-level SEH handler m_oldSehHandler = SetUnhandledExceptionFilter(SehHandler); } _set_error_mode(_OUT_TO_STDERR); #if _MSC_VER>=1300 if(dwFlags&CR_INST_PURE_CALL_HANDLER) { // Catch pure virtual function calls. // Because there is one _purecall_handler for the whole process, // calling this function immediately impacts all threads. The last // caller on any thread sets the handler. // http://msdn.microsoft.com/en-us/library/t296ys27.aspx m_prevPurec = _set_purecall_handler(PureCallHandler); } if(dwFlags&CR_INST_NEW_OPERATOR_ERROR_HANDLER) { // Catch new operator memory allocation exceptions _set_new_mode(1); // Force malloc() to call new handler too m_prevNewHandler = _set_new_handler(NewHandler); } #endif #if _MSC_VER>=1400 if(dwFlags&CR_INST_INVALID_PARAMETER_HANDLER) { // Catch invalid parameter exceptions. m_prevInvpar = _set_invalid_parameter_handler(InvalidParameterHandler); } #endif #if _MSC_VER>=1300 && _MSC_VER<1400 if(dwFlags&CR_INST_SECURITY_ERROR_HANDLER) { // Catch buffer overrun exceptions // The _set_security_error_handler is deprecated in VC8 C++ run time library m_prevSec = _set_security_error_handler(SecurityHandler); } #endif // Set up C++ signal handlers if(dwFlags&CR_INST_SIGABRT_HANDLER) { #if _MSC_VER>=1400 _set_abort_behavior(_CALL_REPORTFAULT, _CALL_REPORTFAULT); #endif // Catch an abnormal program termination m_prevSigABRT = signal(SIGABRT, SigabrtHandler); } if(dwFlags&CR_INST_SIGILL_HANDLER) { // Catch illegal instruction handler m_prevSigINT = signal(SIGINT, SigintHandler); } if(dwFlags&CR_INST_TERMINATE_HANDLER) { // Catch a termination request m_prevSigTERM = signal(SIGTERM, SigtermHandler); } crSetErrorMsg(_T("Success.")); return 0; }
int main(int argc, char** argv) { #ifdef _MSC_VER _set_error_mode(_OUT_TO_STDERR); _set_abort_behavior( 0, _WRITE_ABORT_MSG); #endif #ifdef _WIN32 get_argv_utf8(&argc, &argv); #endif char *outfile = 0; int from_stdin = 0; bool generate_source_map = false; struct Sass_Options* options = sass_make_options(); sass_option_set_output_style(options, SASS_STYLE_NESTED); sass_option_set_precision(options, 5); int c; size_t i; int long_index = 0; static struct option long_options[] = { { "stdin", no_argument, 0, 's' }, { "load-path", required_argument, 0, 'I' }, { "plugin-path", required_argument, 0, 'P' }, { "style", required_argument, 0, 't' }, { "line-numbers", no_argument, 0, 'l' }, { "line-comments", no_argument, 0, 'l' }, { "sourcemap", no_argument, 0, 'm' }, { "omit-map-comment", no_argument, 0, 'M' }, { "precision", required_argument, 0, 'p' }, { "version", no_argument, 0, 'v' }, { "help", no_argument, 0, 'h' }, { NULL, 0, NULL, 0} }; while ((c = getopt_long(argc, argv, "vhslmMp:t:I:P:", long_options, &long_index)) != -1) { switch (c) { case 's': from_stdin = 1; break; case 'I': sass_option_push_include_path(options, strdup(optarg)); break; case 'P': sass_option_push_plugin_path(options, strdup(optarg)); break; case 't': for(i = 0; i < NUM_STYLE_OPTION_STRINGS; ++i) { if(strcmp(optarg, style_option_strings[i].style_string) == 0) { sass_option_set_output_style(options, style_option_strings[i].output_style); break; } } if(i == NUM_STYLE_OPTION_STRINGS) { fprintf(stderr, "Invalid argument for -t flag: '%s'. Allowed arguments are:", optarg); for(i = 0; i < NUM_STYLE_OPTION_STRINGS; ++i) { fprintf(stderr, " %s", style_option_strings[i].style_string); } fprintf(stderr, "\n"); invalid_usage(argv[0]); } break; case 'l': sass_option_set_source_comments(options, true); break; case 'm': generate_source_map = true; break; case 'M': sass_option_set_omit_source_map_url(options, true); break; case 'p': sass_option_set_precision(options, atoi(optarg)); // TODO: make this more robust if (sass_option_get_precision(options) < 0) sass_option_set_precision(options, 5); break; case 'v': print_version(); return 0; case 'h': print_usage(argv[0]); return 0; case '?': /* Unrecognized flag or missing an expected value */ /* getopt should produce it's own error message for this case */ invalid_usage(argv[0]); default: fprintf(stderr, "Unknown error while processing arguments\n"); return 2; } } if(optind < argc - 2) { fprintf(stderr, "Error: Too many arguments.\n"); invalid_usage(argv[0]); } int result; if(optind < argc && strcmp(argv[optind], "-") != 0 && !from_stdin) { if (optind + 1 < argc) { outfile = argv[optind + 1]; } if (generate_source_map && outfile) { const char* extension = ".map"; char* source_map_file = calloc(strlen(outfile) + strlen(extension) + 1, sizeof(char)); strcpy(source_map_file, outfile); strcat(source_map_file, extension); sass_option_set_source_map_file(options, source_map_file); } result = compile_file(options, argv[optind], outfile); } else { if (optind < argc) { outfile = argv[optind]; } result = compile_stdin(options, outfile); } return result; }
int GDKinit(opt *set, int setlen) { char *dbpath = mo_find_option(set, setlen, "gdk_dbpath"); char *p; opt *n; int i, j, nlen = 0; char buf[16]; /* some sanity checks (should also find if symbols are not defined) */ assert(sizeof(char) == SIZEOF_CHAR); assert(sizeof(short) == SIZEOF_SHORT); assert(sizeof(int) == SIZEOF_INT); assert(sizeof(long) == SIZEOF_LONG); assert(sizeof(lng) == SIZEOF_LNG); assert(sizeof(oid) == SIZEOF_OID); assert(sizeof(void *) == SIZEOF_VOID_P); assert(sizeof(wrd) == SIZEOF_WRD); assert(sizeof(size_t) == SIZEOF_SIZE_T); assert(sizeof(ptrdiff_t) == SIZEOF_PTRDIFF_T); assert(SIZEOF_OID == SIZEOF_INT || SIZEOF_OID == SIZEOF_LNG); #ifdef NEED_MT_LOCK_INIT MT_lock_init(&MT_system_lock,"MT_system_lock"); ATOMIC_INIT(GDKstoppedLock, "GDKstoppedLock"); ATOMIC_INIT(mbyteslock, "mbyteslock"); MT_lock_init(&GDKnameLock, "GDKnameLock"); MT_lock_init(&GDKthreadLock, "GDKthreadLock"); MT_lock_init(&GDKtmLock, "GDKtmLock"); #endif for (i = 0; i <= BBP_BATMASK; i++) { MT_lock_init(&GDKbatLock[i].swap, "GDKswapLock"); MT_lock_init(&GDKbatLock[i].hash, "GDKhashLock"); MT_lock_init(&GDKbatLock[i].imprints, "GDKimprintsLock"); } for (i = 0; i <= BBP_THREADMASK; i++) { MT_lock_init(&GDKbbpLock[i].alloc, "GDKcacheLock"); MT_lock_init(&GDKbbpLock[i].trim, "GDKtrimLock"); GDKbbpLock[i].free = 0; } errno = 0; if (!GDKenvironment(dbpath)) return 0; if ((p = mo_find_option(set, setlen, "gdk_debug"))) GDKdebug = strtol(p, NULL, 10); if ((p = mo_find_option(set, setlen, "gdk_mem_pagebits"))) GDK_mem_pagebits = (int) strtol(p, NULL, 10); mnstr_init(); MT_init_posix(); THRinit(); #ifndef NATIVE_WIN32 BATSIGinit(); #endif #ifdef WIN32 (void) signal(SIGABRT, BATSIGabort); _set_abort_behavior(0, _CALL_REPORTFAULT | _WRITE_ABORT_MSG); _set_error_mode(_OUT_TO_STDERR); #endif GDKlockHome(); /* Mserver by default takes 80% of all memory as a default */ GDK_mem_maxsize = GDK_mem_maxsize_max = (size_t) ((double) MT_npages() * (double) MT_pagesize() * 0.815); #ifdef NATIVE_WIN32 GDK_mmap_minsize = GDK_mem_maxsize_max; #else GDK_mmap_minsize = MIN( 1<<30 , GDK_mem_maxsize_max/6 ); /* per op: 2 args + 1 res, each with head & tail => (2+1)*2 = 6 ^ */ #endif GDK_mem_bigsize = 1024*1024; GDKremovedir(DELDIR); BBPinit(); HEAPcacheInit(); GDKkey = BATnew(TYPE_void, TYPE_str, 100); GDKval = BATnew(TYPE_void, TYPE_str, 100); if (GDKkey == NULL) GDKfatal("GDKinit: Could not create environment BAT"); if (GDKval == NULL) GDKfatal("GDKinit: Could not create environment BAT"); BATseqbase(GDKkey,0); BATkey(GDKkey, BOUND2BTRUE); BATrename(GDKkey, "environment_key"); BATmode(GDKkey, TRANSIENT); BATseqbase(GDKval,0); BATkey(GDKval, BOUND2BTRUE); BATrename(GDKval, "environment_val"); BATmode(GDKval, TRANSIENT); n = (opt *) malloc(setlen * sizeof(opt)); for (i = 0; i < setlen; i++) { int done = 0; for (j = 0; j < nlen; j++) { if (strcmp(n[j].name, set[i].name) == 0) { if (n[j].kind < set[i].kind) { n[j] = set[i]; } done = 1; break; } } if (!done) { n[nlen] = set[i]; nlen++; } } for (i = 0; i < nlen; i++) GDKsetenv(n[i].name, n[i].value); free(n); if ((p = GDKgetenv("gdk_dbpath")) != NULL && (p = strrchr(p, DIR_SEP)) != NULL) { GDKsetenv("gdk_dbname", p + 1); #if DIR_SEP != '/' /* on Windows look for different separator */ } else if ((p = GDKgetenv("gdk_dbpath")) != NULL && (p = strrchr(p, '/')) != NULL) { GDKsetenv("gdk_dbname", p + 1); #endif } if ((p = GDKgetenv("gdk_mem_maxsize"))) { GDK_mem_maxsize = MAX(1 << 26, (size_t) strtoll(p, NULL, 10)); } if ((p = GDKgetenv("gdk_vm_maxsize"))) { GDK_vm_maxsize = MAX(1 << 30, (size_t) strtoll(p, NULL, 10)); } if ((p = GDKgetenv("gdk_mem_bigsize"))) { /* when allocating >6% of all RAM; do so using * vmalloc() iso malloc() */ lng max_mem_bigsize = GDK_mem_maxsize_max / 16; /* sanity check to avoid memory fragmentation */ GDK_mem_bigsize = (size_t) MIN(max_mem_bigsize, strtoll(p, NULL, 10)); } if ((p = GDKgetenv("gdk_mmap_minsize"))) { GDK_mmap_minsize = MAX(REMAP_PAGE_MAXSIZE, (size_t) strtoll(p, NULL, 10)); } if (GDKgetenv("gdk_mem_pagebits") == NULL) { snprintf(buf, sizeof(buf), "%d", GDK_mem_pagebits); GDKsetenv("gdk_mem_pagebits", buf); } if (GDKgetenv("gdk_mem_bigsize") == NULL) { snprintf(buf, sizeof(buf), SZFMT, GDK_mem_bigsize); GDKsetenv("gdk_mem_bigsize", buf); } if (GDKgetenv("monet_pid") == NULL) { snprintf(buf, sizeof(buf), "%d", (int) getpid()); GDKsetenv("monet_pid", buf); } GDKnr_threads = GDKgetenv_int("gdk_nr_threads", 0); if (GDKnr_threads == 0) GDKnr_threads = MT_check_nr_cores(); #ifdef NATIVE_WIN32 GDK_mmap_minsize /= (GDKnr_threads ? GDKnr_threads : 1); #else /* WARNING: This unconditionally overwrites above settings, */ /* incl. setting via MonetDB env. var. "gdk_mmap_minsize" ! */ GDK_mmap_minsize = MIN( 1<<30 , (GDK_mem_maxsize_max/6) / (GDKnr_threads ? GDKnr_threads : 1) ); /* per op: 2 args + 1 res, each with head & tail => (2+1)*2 = 6 ^ */ #endif if ((p = mo_find_option(set, setlen, "gdk_vmtrim")) == NULL || strcasecmp(p, "yes") == 0) MT_create_thread(&GDKvmtrim_id, GDKvmtrim, &GDK_mem_maxsize, MT_THR_JOINABLE); return 1; }
static long msvcrt_set_error_mode_impl(PyModuleDef *module, int mode) /*[clinic end generated code: output=62148adffa90867d input=046fca59c0f20872]*/ { return _set_error_mode(mode); }