slab* HashedObjectCache::CreateSlab(uint32 flags) { if (!check_cache_quota(this)) return NULL; Unlock(); HashedSlab* slab = allocate_slab(flags); if (slab != NULL) { void* pages = NULL; if (MemoryManager::Allocate(this, flags, pages) == B_OK && AllocateTrackingInfos(slab, slab_size, flags) == B_OK) { Lock(); if (InitSlab(slab, pages, slab_size, flags)) { hash_table.InsertUnchecked(slab); _ResizeHashTableIfNeeded(flags); return slab; } Unlock(); FreeTrackingInfos(slab, flags); } if (pages != NULL) MemoryManager::Free(pages, flags); free_slab(slab, flags); } Lock(); return NULL; }
int main () { Banner (); InitSend (); fflush (stdout); ICI = FALSE; PVHashTable = NULL; EvalHash = NULL; PawnHash = NULL; /* HACK */ PawnHashSize = (1 << 16); /* HACK */ EvalHashSize = (1 << 15); /* HACK */ #ifdef CON_ROBBO_BUILD TripleHash = NULL; TripleHashSize = (1 << 17); #endif memset ( (void*) ROOT_POSIZIONE0, 0, sizeof (typePOS)); ROOT_POSIZIONE0->DYN_ROOT = malloc (MAXIMUM_PLY * sizeof (typeDYNAMIC)); ROOT_POSIZIONE0->DYN = ROOT_POSIZIONE0->DYN_ROOT + 1; ROOT_POSIZIONE0->stop = FALSE; CPUS_SIZE = 1; #ifdef YUSUF_MULTICORE rp_init (); #endif SMP_HAS_AKTIV = FALSE; UCI_White_Bishops_Scale = 45; UCI_White_Pawn_Scale = 100; UCI_White_Knight_Scale = 300; UCI_White_Light_Scale = 310; UCI_White_Dark_Scale = 310; UCI_White_Rook_Scale = 500; UCI_White_Queen_Scale = 950; UCI_Black_Bishops_Scale = 45; UCI_Black_Pawn_Scale = 100; UCI_Black_Knight_Scale = 300; UCI_Black_Light_Scale = 310; UCI_Black_Dark_Scale = 310; UCI_Black_Rook_Scale = 500; UCI_Black_Queen_Scale = 950; UCI_MATERIAL_WEIGHTING = 1024; UCI_PAWNS_WEIGHTING = 1024; UCI_KING_SAFETY_WEIGHTING = 1024; UCI_STATIC_WEIGHTING = 1024; UCI_MOBILITY_WEIGHTING = 1024; PAWNS_HASH_ONE_EIGHTH = TRUE; UCI_PAWNS_HASH = 4; CURRENT_HASH_SIZE = 32; InitHash (32); InitPawnHash (4); InitPVHash (2); InitEvalHash (256); #ifdef SLAB_MEMORY InitSlab (SLAB_SIZE); #else InitSlab (0); #endif InitCaptureValues (); /* SLAB_MEM */ InitPawns (); /* SLAB_MEM? */ #ifdef USER_SPLIT CUT_SPLIT_DEPTH = 16; ALL_SPLIT_DEPTH = 14; PV_SPLIT_DEPTH = 14; SPLIT_AT_CUT = TRUE; #endif SEND_CURR_MOVE = FALSE; USE_ALTERNATIVE_TIME = FALSE; TIME_IMITATE = FALSE; TIME_LOSE_MORE = FALSE; TIME_WIN_MORE = FALSE; BUFFER_TIME = 0; OUTPUT_DELAY = 0; UCI_PONDER = FALSE; VERIFY_NULL = TRUE; ROBBO_LOAD = ROBBO_TOTAL_LOAD = FALSE; SEARCH_ROBBO_BASES = TRUE; MULTI_PV = 1; SEND_HASH = FALSE; /* aid GUI */ DO_HASH_FULL = TRUE; ALLOW_INSTANT_MOVE = TRUE; ZOG_AKTIV = FALSE; strcpy (ROBBO_TRIPLE_DIR, ""); strcpy (ROBBO_TOTAL_DIR, ""); SEARCH_IS_DONE = TRUE; INFINITE_LOOP = FALSE; #ifndef MINIMAL MULTI_CENTI_PAWN_PV = 65535; RANDOM_COUNT = 0; RANDOM_BITS = 1; ALWAYS_ANALYZE = FALSE; TRY_PV_IN_ANALYSIS = TRUE; FIXED_AGE_ANALYSIS = FALSE; #endif #ifdef TRACE_COMPILE TraceOn (); #endif #ifdef CON_ROBBO_BUILD RobboIniz (); InitTripleHash (1); /* ensure */ #endif TRY_LARGE_PAGES = FALSE; SUPPRESS_INPUT = FALSE; INPUT_BUFFER = malloc (65536); input_ptr = INPUT_BUFFER; STALL_MODE = FALSE; SINCE_NEW_GAME = 0; EASY_FACTOR = 15; EASY_FACTOR_PONDER = 33; BATTLE_FACTOR = 100; ORDINARY_FACTOR = 75; ABSOLUTE_PERCENT = 25; DESIRED_MILLIS = 40; BOOK_EXIT_MOVES = 0; EXTEND_IN_CHECK = FALSE; TRIPLE_WEAK_PROBE_DEPTH = -10; TRIPLE_DEFINITE_PROBE_DEPTH = 40; TRIPLE_DEFINITE_PROBE_HEIGHT = 5; LOAD_ON_WEAK_PROBE = TRUE; STALL_INPUT = FALSE; UCI_OPTION_CHESS_960 = FALSE; #ifdef LINUX_LARGE_PAGES LINUX_handle_signals (); #endif #ifdef MODE_ANALYSIS ICI_HASH_MIX = FALSE; #endif NewGame (ROOT_POSIZIONE0, TRUE); while (1) Input (ROOT_POSIZIONE0); return 0; }