int main(int argc, char *argv[]) { #else int wmain(int argc, wchar_t *argv[], wchar_t *envp[]) { int i; for (i=0; i<argc; i++) { // write the command line to UTF8 wchar_t *warg = argv[i]; size_t wlen = wcslen(warg)+1; size_t len = WideCharToMultiByte(CP_UTF8, 0, warg, wlen, NULL, 0, NULL, NULL); if (!len) return 1; char *arg = (char*)alloca(len); if (!WideCharToMultiByte(CP_UTF8, 0, warg, wlen, arg, len, NULL, NULL)) return 1; argv[i] = (wchar_t*)arg; } #endif libsupport_init(); parse_opts(&argc, (char***)&argv); if (lisp_prompt) { jl_lisp_prompt(); return 0; } julia_init(imagepathspecified ? JL_IMAGE_CWD : JL_IMAGE_JULIA_HOME); int ret = true_main(argc, (char**)argv); jl_atexit_hook(); julia_save(); return ret; }
DLLEXPORT void jl_atexit_hook(int exitcode) { if (exitcode == 0) julia_save(); jl_print_gc_stats(JL_STDERR); if (jl_options.code_coverage) jl_write_coverage_data(); if (jl_options.malloc_log) jl_write_malloc_log(); if (jl_base_module) { jl_value_t *f = jl_get_global(jl_base_module, jl_symbol("_atexit")); if (f!=NULL && jl_is_function(f)) { JL_TRY { jl_apply((jl_function_t*)f, NULL, 0); } JL_CATCH { jl_printf(JL_STDERR, "\natexit hook threw an error: "); jl_static_show(JL_STDERR, jl_exception_in_transit); } } }