/* * __os_spin -- * Return the number of default spins before blocking. * * PUBLIC: int __os_spin __P((void)); */ int __os_spin() { /* * If the application specified a value or we've already figured it * out, return it. * * XXX * We don't want to repeatedly call the underlying function because * it can be expensive (e.g., requiring multiple filesystem accesses * under Debian Linux). */ if (DB_GLOBAL(db_tas_spins) != 0) return (DB_GLOBAL(db_tas_spins)); DB_GLOBAL(db_tas_spins) = 1; #if defined(HAVE_PSTAT_GETDYNAMIC) DB_GLOBAL(db_tas_spins) = __os_pstat_getdynamic(); #endif #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) DB_GLOBAL(db_tas_spins) = __os_sysconf(); #endif /* * Spin 50 times per processor, we have anecdotal evidence that this * is a reasonable value. */ if (DB_GLOBAL(db_tas_spins) != 1) DB_GLOBAL(db_tas_spins) *= 50; return (DB_GLOBAL(db_tas_spins)); }
/* * brew_bdb_begin -- * Initialize the BREW port of Berkeley DB. */ int brew_bdb_begin() { void *p; /* * The BREW ARM compiler can't handle statics or globals, so we have * store them off the AEEApplet and initialize them in in-line code. */ p = ((BDBApp *)GETAPPINSTANCE())->db_global_values; if (p == NULL) { if ((p = malloc(sizeof(DB_GLOBALS))) == NULL) return (ENOMEM); memset(p, 0, sizeof(DB_GLOBALS)); ((BDBApp *)GETAPPINSTANCE())->db_global_values = p; TAILQ_INIT(&DB_GLOBAL(db_envq)); DB_GLOBAL(db_line) = "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="; } return (0); }