void GncSqlBackend::sync_all(QofBook* book) { g_return_if_fail (book != NULL); reset_version_info(); ENTER ("book=%p, sql_be->book=%p", book, m_book); update_progress(); /* Create new tables */ m_is_pristine_db = true; create_tables(); /* Save all contents */ m_book = book; auto is_ok = m_conn->begin_transaction(); // FIXME: should write the set of commodities that are used // write_commodities(sql_be, book); if (is_ok) { auto obe = m_backend_registry.get_object_backend(GNC_ID_BOOK); is_ok = obe->commit (this, QOF_INSTANCE (book)); } if (is_ok) { is_ok = write_accounts(); } if (is_ok) { is_ok = write_transactions(); } if (is_ok) { is_ok = write_template_transactions(); } if (is_ok) { is_ok = write_schedXactions(); } if (is_ok) { for (auto entry : m_backend_registry) std::get<1>(entry)->write (this); } if (is_ok) { is_ok = m_conn->commit_transaction(); } if (is_ok) { m_is_pristine_db = false; /* Mark the session as clean -- though it shouldn't ever get * marked dirty with this backend */ qof_book_mark_session_saved(book); } else { if (!qof_backend_check_error (&qof_be)) qof_backend_set_error (&qof_be, ERR_BACKEND_SERVER_ERR); is_ok = m_conn->rollback_transaction (); } finish_progress(); LEAVE ("book=%p", book); }
void Interface::run(TL::DTO& dto) { reset_version_info(); // Run looking up for every "#pragma nanos" PragmaCustomCompilerPhase::run(dto); // Create versioning symbols Source versioning_symbols; DEBUG_CODE() { for(std::map<std::string, int>::iterator it = Version::_interfaces.begin(); it != Version::_interfaces.end(); it++) std::cerr << "Interface => Version::family '" << it->first << "'" << ", Version::version '" << it->second << "'" << std::endl; } CXX_LANGUAGE() { versioning_symbols << "extern \"C\" { " ; } // Code to maintain the Nanos4 version versioning_symbols << "const char* __nanos_family __attribute__((weak)) = \"" << Version::_interfaces.begin()->first << "\";" << "int __nanos_version __attribute__((weak)) = " << Version::_interfaces.begin()->second << ";" ; // Code for Nanox version for(std::map<std::string, int>::iterator it = Version::_interfaces.begin(); it != Version::_interfaces.end(); it++) versioning_symbols << "int __mcc_" << it->first << " __attribute__((weak)) = " << it->second << ";" ; CXX_LANGUAGE() { versioning_symbols << "}" ; } AST_t translation_unit = dto["translation_unit"]; ScopeLink scope_link = dto["scope_link"]; AST_t versioning_symbols_tree = versioning_symbols.parse_global(translation_unit, scope_link); // Get the translation_unit tree // and prepend these declarations translation_unit.prepend_to_translation_unit(versioning_symbols_tree); // We need to obtain the name of the file without the path const char* filename = give_basename(translation_unit.get_file().c_str()); const char* ptr_extension = strrchr(filename, '.'); // If The filename have not extension then error if (ptr_extension == NULL) { internal_error("code unreachable.", 0); } std::string name (filename, (ptr_extension - filename)); if (!_map_events.empty()) { Source declare_events, register_events; declare_events << "static void __register_events(void* p __attribute__((unused)))" << "{" << "nanos_event_key_t nanos_instr_name_key = 0;" << register_events << "}" << "__attribute__((section(\"nanos_post_init\"))) nanos_init_desc_t " << name << "__register_events_list = { __register_events, (void*)0 };" ; // Register events for (map_events::iterator it = _map_events.begin(); it != _map_events.end(); it++) { register_events << "nanos_instrument_register_key(&nanos_instr_name_key, \"" << it->first << "\", " << it->second << ", /* abort */ 0);" ; } AST_t tree = declare_events.parse_global(translation_unit, scope_link); translation_unit.append_to_translation_unit(tree); } }