void _EWL_CDECL __close_all(void) { FILE * p = &__files[0]; FILE * plast; __begin_critical_region(files_access); while(p != NULL) { if (p->mode.file_kind != (uchar_t)__closed_file) { __end_critical_region(files_access); (void)fclose(p); __begin_critical_region(files_access); } plast = p; p = p->next_file_struct; if (plast->is_dynamically_allocated) { MISRA_EXCEPTION_RULE_20_4() free(plast); } else { if ((p != NULL) && p->is_dynamically_allocated) { plast->next_file_struct = NULL; } } } __end_critical_region(files_access); }
void _CleanUpMSL() { __begin_critical_region(atexit_funcs_access); while (atexit_curr_func > 0) (*atexit_funcs[--atexit_curr_func])(); __end_critical_region(atexit_funcs_access); if (__stdio_exit) { (*__stdio_exit)(); __stdio_exit = 0; } __destroy_global_chain(); __kill_critical_regions(); if (__console_exit) { (*__console_exit)(); __console_exit = 0; } }
void __exit(int status) { #if __dest_os != __be_os #pragma unused(status) #endif __begin_critical_region(atexit_funcs_access); while (__atexit_curr_func > 0) (*__atexit_funcs[--__atexit_curr_func])(); __end_critical_region(atexit_funcs_access); __kill_critical_regions(); if (__console_exit) { (*__console_exit)(); __console_exit = 0; } #if __dest_os == __mac_os ExitToShell(); #elif __dest_os == __be_os /* ELR */ ___teardown_be(status); #elif __dest_os == __win32_os ExitProcess(status); #endif }
int_t _EWL_CDECL printf_console(const char_t * format, ...) { int_t result; va_list args; __begin_critical_region(stdout_access); va_start( args, format ); result = __pformatter(__ConsoleWrite, (void *)0, format, args, 0); __end_critical_region(stdout_access); return(result); }
int __atexit(void (*func)(void)) { if (__atexit_curr_func == max_funcs) return(-1); __begin_critical_region(atexit_funcs_access); /* 961218 KO */ __setup_exit(); __atexit_funcs[__atexit_curr_func++] = func; __end_critical_region(atexit_funcs_access); return(0); }
void exit(int status) #endif { if (!__aborting) { __begin_critical_region(atexit_funcs_access); while (atexit_curr_func > 0) (*atexit_funcs[--atexit_curr_func])(); #if (__dest_os == __win32_os) && (STOP_PROGRAM_BEFORE_EXIT==1) if(GetFileType(GetStdHandle(STD_OUTPUT_HANDLE))==FILE_TYPE_CHAR) { //printf("\n \n Press Enter to continue \n"); //fflush(stdin); //getc(stdin); } #endif __end_critical_region(atexit_funcs_access); /* 970218 bkoz need to move destroy global chain above __stdio_exit as some static objects may have destructors that flush streams */ #if !__INTEL__ #if __POWERPC__ || __CFM68K__ || (__MC68K__ && __A5__) || (__dest_os == __be_os) __destroy_global_chain(); #endif #endif if (__stdio_exit) { (*__stdio_exit)(); __stdio_exit = 0; } } __exit(status); }