void matrix_solver_t::solve_base(C *p) { m_stat_vsolver_calls++; if (is_dynamic()) { int this_resched; int newton_loops = 0; do { update_dynamic(); // Gauss-Seidel will revert to Gaussian elemination if steps exceeded. this_resched = p->vsolve_non_dynamic(true); newton_loops++; } while (this_resched > 1 && newton_loops < m_params.m_nr_loops); m_stat_newton_raphson += newton_loops; // reschedule .... if (this_resched > 1 && !m_Q_sync.net().is_queued()) { log().warning("NEWTON_LOOPS exceeded on net {1}... reschedule", this->name()); m_Q_sync.net().reschedule_in_queue(m_params.m_nt_sync_delay); } } else { p->vsolve_non_dynamic(false); } }
/* Load a built-in or dynamically linked module. If the `reg_fn' * argument is non-NULL, assume a built-in module and use reg_fn to * register it. Otherwise, search for a dynamic NSS module. */ static void nss_load_module(const char *source, nss_module_register_fn reg_fn) { char buf[PATH_MAX]; ns_mod mod; nss_module_register_fn fn; memset(&mod, 0, sizeof(mod)); mod.name = strdup(source); if (mod.name == NULL) { nss_log_simple(LOG_ERR, "memory allocation failure"); return; } if (reg_fn != NULL) { /* The placeholder is required, as a NULL handle * represents an invalid module. */ mod.handle = nss_builtin_handle; fn = reg_fn; } else if (!is_dynamic()) goto fin; else { if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name, NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf)) goto fin; mod.handle = libc_dlopen(buf, RTLD_LOCAL|RTLD_LAZY); if (mod.handle == NULL) { #ifdef _NSS_DEBUG /* This gets pretty annoying since the built-in * sources aren't modules yet. */ nss_log(LOG_DEBUG, "%s, %s", mod.name, dlerror()); #endif goto fin; } fn = (nss_module_register_fn)dlfunc(mod.handle, "nss_module_register"); if (fn == NULL) { (void)dlclose(mod.handle); mod.handle = NULL; nss_log(LOG_ERR, "%s, %s", mod.name, dlerror()); goto fin; } } mod.mtab = fn(mod.name, &mod.mtabsize, &mod.unregister); if (mod.mtab == NULL || mod.mtabsize == 0) { if (mod.handle != nss_builtin_handle) (void)dlclose(mod.handle); mod.handle = NULL; nss_log(LOG_ERR, "%s, registration failed", mod.name); goto fin; } if (mod.mtabsize > 1) qsort(mod.mtab, mod.mtabsize, sizeof(mod.mtab[0]), mtab_compare); fin: _nsmod = vector_append(&mod, _nsmod, &_nsmodsize, sizeof(*_nsmod)); vector_sort(_nsmod, _nsmodsize, sizeof(*_nsmod), string_compare); }
void dynamic_string::optimize() { if (!m_len) clear(); else { if ((m_len + 1U) <= cSmallStringBufSize) { if (is_dynamic()) { char *pStr = m_dyn.m_pStr; memcpy(m_small.m_buf, pStr, m_len + 1); vogl_delete_array(pStr); set_small_string_flag(); } } else { if (!is_dynamic()) { VOGL_ASSERT_ALWAYS; clear(); return; } uint32 min_buf_size = m_len + 1; // TODO: In some cases it'll make no difference to try to shrink the block due to allocation alignment, etc. issues if (m_dyn.m_buf_size > min_buf_size) { char *p = vogl_new_array(char, min_buf_size); memcpy(p, m_dyn.m_pStr, m_len + 1); vogl_delete_array(m_dyn.m_pStr); set_dyn_string_ptr(p); m_dyn.m_buf_size = min_buf_size; } } }
void dynamic_string::clear() { check(); if (is_dynamic()) { vogl_delete_array(m_dyn.m_pStr); } set_to_empty_small_string(); }