void build_version_patch(string old_path, string new_path, string output_path) { // setup output path if ( access(output_path.c_str(), 0) != 0 && mkdir(output_path.c_str()) != 0 ) { error_msg("can't create output path!"); } // open log file s_process_log_fp = fopen(string(s_log_path + "/" + s_process_log).c_str(), "w+"); if ( !s_process_log_fp ) { error_msg("can't create log file!"); } printf("***start version-patch builder:\n --- oldver=%s, newver=%s, patch_output=%s\n", old_path.c_str(), new_path.c_str(), output_path.c_str()); fprintf(s_process_log_fp, "***start version patch builder:\n --- oldver=%s, newver=%s, patch_output=%s\n", old_path.c_str(), new_path.c_str(), output_path.c_str()); s_input_oldpath = old_path; s_input_newpath = new_path; s_outputpath = output_path; // load old path sp_processing_idxmap = &s_oldidxmap; visit_load(s_input_oldpath); // load new path sp_processing_idxmap = &s_newidxmap; visit_load(s_input_newpath); // build changed build_changed(); // output patched build_patched(); printf("***end version-patch builder: \n"); printf(" --- (%d) error occured! \n", s_error_counter); printf(" --- (%d) old version files; (%d) new version files. \n", s_oldidxmap.size(), s_newidxmap.size()); printf(" --- (%d) added; (%d) modified; (%d) deleted; (%d) unchanged. \n", s_added_set.size(), s_modified_set.size(), s_deleted_set.size(), s_unchanged_set.size() ); printf("***all done! \n"); fprintf(s_process_log_fp, "***end version-patch builder: \n"); fprintf(s_process_log_fp, " --- (%d) error occured! \n", s_error_counter); fprintf(s_process_log_fp, " --- (%d) old version files; (%d) new version files. \n", s_oldidxmap.size(), s_newidxmap.size()); fprintf(s_process_log_fp, " --- (%d) added; (%d) modified; (%d) deleted; (%d) unchanged. \n", s_added_set.size(), s_modified_set.size(), s_deleted_set.size(), s_unchanged_set.size() ); fprintf(s_process_log_fp, "***all done! \n"); fclose(s_process_log_fp); }
static void visit_load(string path, string relpath = "") { struct _finddata_t file_info; long handle; if( (handle=_findfirst(string(path + "/*").c_str(),&file_info)) == -1L ) { printf("-- no file --\n"); } else { while( !_findnext(handle,&file_info) ) // first is "." { if( (file_info.attrib & _A_SUBDIR) == _A_SUBDIR && strcmp(file_info.name, "..") ) { printf("folder:%s", string(relpath + "/"+ file_info.name).c_str()); process_folder(path + "/", relpath + "/", file_info.name) ? printf("[OK]\n") : printf("[FAILED]\n"); visit_load(path + "/" + file_info.name, relpath + "/" + file_info.name); } else if(!(file_info.attrib & _A_SUBDIR)) { printf("file:%s", string(relpath + "/"+ file_info.name).c_str()); process_file(path + "/", relpath + "/", file_info.name) ? printf("[OK]\n") : printf("[IGN]\n"); } } _findclose(handle); } }
bool walk_stmt_load_store_addr_ops (gimple stmt, void *data, bool (*visit_load)(gimple, tree, void *), bool (*visit_store)(gimple, tree, void *), bool (*visit_addr)(gimple, tree, void *)) { bool ret = false; unsigned i; if (gimple_assign_single_p (stmt)) { tree lhs, rhs; if (visit_store) { lhs = get_base_loadstore (gimple_assign_lhs (stmt)); if (lhs) ret |= visit_store (stmt, lhs, data); } rhs = gimple_assign_rhs1 (stmt); while (handled_component_p (rhs)) rhs = TREE_OPERAND (rhs, 0); if (visit_addr) { if (TREE_CODE (rhs) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (rhs, 0), data); else if (TREE_CODE (rhs) == TARGET_MEM_REF && TREE_CODE (TMR_BASE (rhs)) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (rhs), 0), data); else if (TREE_CODE (rhs) == OBJ_TYPE_REF && TREE_CODE (OBJ_TYPE_REF_OBJECT (rhs)) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (rhs), 0), data); else if (TREE_CODE (rhs) == CONSTRUCTOR) { unsigned int ix; tree val; FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (rhs), ix, val) if (TREE_CODE (val) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (val, 0), data); else if (TREE_CODE (val) == OBJ_TYPE_REF && TREE_CODE (OBJ_TYPE_REF_OBJECT (val)) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (OBJ_TYPE_REF_OBJECT (val), 0), data); } lhs = gimple_assign_lhs (stmt); if (TREE_CODE (lhs) == TARGET_MEM_REF && TREE_CODE (TMR_BASE (lhs)) == ADDR_EXPR) ret |= visit_addr (stmt, TREE_OPERAND (TMR_BASE (lhs), 0), data); } if (visit_load) { rhs = get_base_loadstore (rhs); if (rhs) ret |= visit_load (stmt, rhs, data); } }