mad_status MADIMPENTRY( RegModified )( const mad_reg_set_data *rsd, const mad_reg_info *ri, const mad_registers *old, const mad_registers *cur ) { unsigned_64 new_ip; unsigned_8 *p_old; unsigned_8 *p_cur; unsigned mask; unsigned size; rsd = rsd; if( ri->bit_start == BIT_OFF( pal.nt.fir ) ) { new_ip = old->axp.pal.nt.fir; //NYI: 64 bit new_ip.u._32[0] += sizeof( unsigned_32 ); if( new_ip.u._32[0] != cur->axp.pal.nt.fir.u._32[0] ) { return( MS_MODIFIED_SIGNIFICANTLY ); } else if( old->axp.pal.nt.fir.u._32[0] != cur->axp.pal.nt.fir.u._32[0] ) { return( MS_MODIFIED ); } } else { p_old = (unsigned_8 *)old + BYTEIDX( ri->bit_start ); p_cur = (unsigned_8 *)cur + BYTEIDX( ri->bit_start ); size = ri->bit_size; if( size >= BYTES2BITS( 1 ) ) { /* it's going to be byte aligned */ return( memcmp( p_old, p_cur, BITS2BYTES( size ) ) != 0 ? MS_MODIFIED_SIGNIFICANTLY : MS_OK ); } else { mask = (1 << size) - 1; #define GET_VAL( w ) (((*p_##w >> BITIDX( ri->bit_start ))) & mask) return( GET_VAL( old ) != GET_VAL( cur ) ? MS_MODIFIED_SIGNIFICANTLY : MS_OK ); } } return( MS_OK ); }
static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring, struct xgene_enet_raw_desc *raw_desc) { struct sk_buff *skb; struct device *dev; u16 skb_index; u8 status; int ret = 0; skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0)); skb = cp_ring->cp_skb[skb_index]; dev = ndev_to_dev(cp_ring->ndev); dma_unmap_single(dev, GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)), GET_VAL(BUFDATALEN, le64_to_cpu(raw_desc->m1)), DMA_TO_DEVICE); /* Checking for error */ status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0)); if (unlikely(status > 2)) { xgene_enet_parse_error(cp_ring, netdev_priv(cp_ring->ndev), status); ret = -EIO; } if (likely(skb)) { dev_kfree_skb_any(skb); } else { netdev_err(cp_ring->ndev, "completion skb is NULL\n"); ret = -EIO; } return ret; }
/* Query whether a register value differs between the two register sets 'old' and 'cur'. The following return codes are possible: MS_OK - value is unchanged MS_MODIFIED - value is different MS_MODIFIED_SIGNIFICANTLY - value has changed in a way that the user cares about */ mad_status DIGENTRY MIRegModified( const mad_reg_set_data *rsd, const mad_reg_info *ri, const mad_registers *old, const mad_registers *cur ) { addr_ptr new_ip; unsigned_8 *p_old; unsigned_8 *p_cur; unsigned mask; unsigned size; if( ri->bit_start == BIT_OFF( pc ) ) { new_ip = old->jvm.pc; //NYI: find length of instruction new_ip.offset += sizeof( unsigned_32 ); if( new_ip.segment != cur->jvm.pc.segment || new_ip.offset != cur->jvm.pc.offset ) { return( MS_MODIFIED_SIGNIFICANTLY ); } else if( old->jvm.pc.segment != cur->jvm.pc.segment || old->jvm.pc.offset != cur->jvm.pc.offset ) { return( MS_MODIFIED ); } } else { p_old = (unsigned_8 *)old + (ri->bit_start / BITS_PER_BYTE); p_cur = (unsigned_8 *)cur + (ri->bit_start / BITS_PER_BYTE); size = ri->bit_size; if( size >= BITS_PER_BYTE ) { /* it's going to be byte aligned */ return( memcmp( p_old, p_cur, size / BITS_PER_BYTE ) != 0 ? MS_MODIFIED_SIGNIFICANTLY : MS_OK ); } else { mask = (1 << size) - 1; #define GET_VAL( w ) (((*p_##w >> (ri->bit_start % BITS_PER_BYTE))) & mask) return( GET_VAL( old ) != GET_VAL( cur ) ? MS_MODIFIED_SIGNIFICANTLY : MS_OK ); } } return( MS_OK ); }
mad_status DIGENTRY MIRegModified( const mad_reg_set_data *rsd, const mad_reg_info *ri, const mad_registers *old, const mad_registers *cur ) { unsigned_64 new_ip; unsigned_8 *p_old; unsigned_8 *p_cur; unsigned mask; unsigned size; if( ri->bit_start == BIT_OFF( iar ) ) { new_ip = old->ppc.iar; //NYI: 64 bit new_ip.u._32[I64LO32] += sizeof( unsigned_32 ); if( new_ip.u._32[I64LO32] != cur->ppc.iar.u._32[I64LO32] ) { return( MS_MODIFIED_SIGNIFICANTLY ); } else if( old->ppc.iar.u._32[I64LO32] != cur->ppc.iar.u._32[I64LO32] ) { return( MS_MODIFIED ); } } else { p_old = (unsigned_8 *)old + (ri->bit_start / BITS_PER_BYTE); p_cur = (unsigned_8 *)cur + (ri->bit_start / BITS_PER_BYTE); size = ri->bit_size; if( size >= BITS_PER_BYTE ) { /* it's going to be byte aligned */ return( memcmp( p_old, p_cur, size / BITS_PER_BYTE ) != 0 ? MS_MODIFIED_SIGNIFICANTLY : MS_OK ); } else { mask = (1 << size) - 1; #define GET_VAL( w ) (((*p_##w >> (ri->bit_start % BITS_PER_BYTE))) & mask) return( GET_VAL( old ) != GET_VAL( cur ) ? MS_MODIFIED_SIGNIFICANTLY : MS_OK ); } } return( MS_OK ); }
void PropertiesDialog::TransferFrom(Catalog *cat) { cat->Header().Charset = GetCharsetFromCombobox(m_charset); cat->Header().SourceCodeCharset = GetCharsetFromCombobox(m_sourceCodeCharset); #define GET_VAL(what,what2) cat->Header().what = m_##what2->GetValue() GET_VAL(Team, team); GET_VAL(TeamEmail, teamEmail); GET_VAL(Project, project); GET_VAL(BasePath, basePath); #undef GET_VAL Language lang = m_language->GetLang(); if (lang.IsValid()) cat->Header().Lang = lang; wxString dummy; wxArrayString arr; cat->Header().SearchPaths.Clear(); cat->Header().Keywords.Clear(); m_paths->GetStrings(arr); for (size_t i = 0; i < arr.GetCount(); i++) { dummy = arr[i]; if (dummy[dummy.Length() - 1] == _T('/') || dummy[dummy.Length() - 1] == _T('\\')) dummy.RemoveLast(); if (!dummy.empty()) cat->Header().SearchPaths.Add(dummy); } if (arr.GetCount() > 0 && cat->Header().BasePath.empty()) cat->Header().BasePath = "."; m_keywords->GetStrings(arr); cat->Header().Keywords = arr; wxString pluralForms; if (m_pluralFormsDefault->GetValue() && cat->Header().Lang.IsValid()) { pluralForms = cat->Header().Lang.DefaultPluralFormsExpr(); } if (pluralForms.empty()) { pluralForms = m_pluralFormsExpr->GetValue().Strip(wxString::both); if ( !pluralForms.empty() && !pluralForms.EndsWith(";") ) pluralForms += ";"; } cat->Header().SetHeaderNotEmpty("Plural-Forms", pluralForms); }
void FS_TopDownMerge(FS_LNODE ** DL, val_t * V, FS_LNODE * B, int d, int di, fsp_t a, fsp_t m, fsp_t b) { int i0=a, i1=m, j; for (j=a; j<b; j++) { //while we haven't sorted the whole run, // if left run is nonexhausted, and the right run IS, or smallest L run item is LEQ smallest R run item if (i0 < m && (i1 >= b || GET_VAL(DL, V, d, di, i0) <= GET_VAL(DL, V, d, di, i1))) { SET_EQUAL(&B[j], DL, di, i0); //B[j] = A[i0] i0++; //move onto next item of Left run } else { //right run has next smallest element SET_EQUAL(&B[j], DL, di, i1); //B[j] = A[i1] i1++; //move onto next item of right run } } }
tween_t * tween_new(void *ptr, tween_type_t type, unsigned int total_steps, tween_value_t start, tween_value_t end, tween_dir_t dir, tween_func_t tween_cb) { tween_t *tween = mem_alloc(sizeof(tween_t)); tween->ptr.ptr = ptr; tween->type = type; tween->steps = (dir == TWEEN_IN ? 0 : total_steps); tween->total_steps = total_steps; SET_VAL(tween, tween->current, (dir == TWEEN_IN ? 0 : GET_VAL(tween, start) - GET_VAL(tween, end))); SET_VAL(tween, tween->end, (dir == TWEEN_IN ? GET_VAL(tween, end) - GET_VAL(tween, start) : GET_VAL(tween, start) - GET_VAL(tween, end))); tween->dir = dir; tween->tween_cb = tween_cb; link_init(&(tween->all_tweens_link)); link_init(&(tween->tweens_link)); return tween; }
const char *LuaScript::toString(void *context, void *object) { DECL_STATE(L, context); String ret(GET_VAL(L, string, object)); return ret.data(); }
int read_dbconfig(const char *fileName, const char *dbCfgname ,struct nd_db_config *db_cfg) { //ND_TRACE_FUNC() ; int ret = -1; ndxml *xmlroot, *xmlsub, *xmlnode ; ndxml_root xmlfile; #define GET_VAL(name) \ xmlnode = ndxml_refsub(xmlsub, #name) ; \ if (!xmlnode){ \ ret = -1; \ goto READ_EXIT ; \ } \ strncpy(db_cfg->db_##name, ndxml_getval(xmlnode), sizeof(db_cfg->db_##name) ) if ( 0 != ndxml_load(fileName , &xmlfile ) ){ nd_logfatal("read file %s error %s\n", fileName, nd_last_error() ) ; return -1; } xmlroot = ndxml_getnode( &xmlfile, "root" ) ; if ( !xmlroot ) { goto READ_EXIT; } //read connect config xmlsub = ndxml_refsub( xmlroot, dbCfgname ) ; if ( !xmlsub ) { goto READ_EXIT; } GET_VAL( host ) ; GET_VAL( database ) ; GET_VAL( user ) ; GET_VAL( password) ; ret = 0 ; READ_EXIT: ndxml_destroy( &xmlfile ); return ret ; }
static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring, struct xgene_enet_raw_desc *raw_desc) { struct sk_buff *skb; struct device *dev; skb_frag_t *frag; dma_addr_t *frag_dma_addr; u16 skb_index; u8 status; int i, ret = 0; skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0)); skb = cp_ring->cp_skb[skb_index]; frag_dma_addr = &cp_ring->frag_dma_addr[skb_index * MAX_SKB_FRAGS]; dev = ndev_to_dev(cp_ring->ndev); dma_unmap_single(dev, GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)), skb_headlen(skb), DMA_TO_DEVICE); for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { frag = &skb_shinfo(skb)->frags[i]; dma_unmap_page(dev, frag_dma_addr[i], skb_frag_size(frag), DMA_TO_DEVICE); } /* Checking for error */ status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0)); if (unlikely(status > 2)) { xgene_enet_parse_error(cp_ring, netdev_priv(cp_ring->ndev), status); ret = -EIO; } if (likely(skb)) { dev_kfree_skb_any(skb); } else { netdev_err(cp_ring->ndev, "completion skb is NULL\n"); ret = -EIO; } return ret; }
void PropertiesDialog::TransferFrom(Catalog *cat) { cat->Header().Charset = GetCharsetFromCombobox(m_charset); cat->Header().SourceCodeCharset = GetCharsetFromCombobox(m_sourceCodeCharset); #define GET_VAL(what,what2) cat->Header().what = m_##what2->GetValue() GET_VAL(Team, team); GET_VAL(TeamEmail, teamEmail); GET_VAL(Project, project); GET_VAL(BasePath, basePath); #undef GET_VAL Language lang = m_language->GetLang(); if (lang.IsValid()) cat->Header().Lang = lang; GetStringsFromControl(m_keywords, cat->Header().Keywords); GetPathsFromControl(m_paths, cat->Header().SearchPaths); GetPathsFromControl(m_excludedPaths, cat->Header().SearchPathsExcluded); if (!cat->Header().SearchPaths.empty() && cat->Header().BasePath.empty()) cat->Header().BasePath = "."; m_keywords->GetStrings(cat->Header().Keywords); wxString pluralForms; if (m_pluralFormsDefault->GetValue() && cat->Header().Lang.IsValid()) { pluralForms = cat->Header().Lang.DefaultPluralFormsExpr(); } if (pluralForms.empty()) { pluralForms = m_pluralFormsExpr->GetValue().Strip(wxString::both); if ( !pluralForms.empty() && !pluralForms.EndsWith(";") ) pluralForms += ";"; } cat->Header().SetHeaderNotEmpty("Plural-Forms", pluralForms); }
int r92su_hw_read_chip_version(struct r92su *r92su) { u8 rev; rev = GET_VAL(PCM_FSM_VER, r92su_read32(r92su, REG_PMC_FSM)); if (rev != R92SU_C_CUT) { rev = (rev >> 1) + 1; if (rev > R92SU_C_CUT) { /* the vendor code will default to B_CUT * in this case. But I'm not sure what the * math above is all about. */ return -EINVAL; } }
void PropertiesDialog::TransferFrom(Catalog *cat) { cat->Header().Charset = GetCharsetFromCombobox(m_charset); cat->Header().SourceCodeCharset = GetCharsetFromCombobox(m_sourceCodeCharset); #define GET_VAL(what,what2) cat->Header().what = m_##what2->GetValue() GET_VAL(LanguageCode, language); GET_VAL(Team, team); GET_VAL(TeamEmail, teamEmail); GET_VAL(Project, project); GET_VAL(BasePath, basePath); #undef GET_VAL wxString dummy; wxArrayString arr; cat->Header().SearchPaths.Clear(); cat->Header().Keywords.Clear(); m_paths->GetStrings(arr); for (size_t i = 0; i < arr.GetCount(); i++) { dummy = arr[i]; if (dummy[dummy.Length() - 1] == _T('/') || dummy[dummy.Length() - 1] == _T('\\')) dummy.RemoveLast(); cat->Header().SearchPaths.Add(dummy); } if (arr.GetCount() > 0 && cat->Header().BasePath.empty()) cat->Header().BasePath = _T("."); m_keywords->GetStrings(arr); cat->Header().Keywords = arr; cat->Header().SetHeaderNotEmpty(_T("Plural-Forms"), m_pluralForms->GetValue()); }
static void assign_triggers(GntMenu *menu) { GList *iter; gboolean bools[37]; memset(bools, 0, sizeof(bools)); bools[36] = 1; for (iter = menu->list; iter; iter = iter->next) { GntMenuItem *item = iter->data; char trigger = tolower(gnt_menuitem_get_trigger(item)); if (trigger == '\0' || trigger == ' ') continue; bools[(int)GET_VAL(trigger)] = 1; } for (iter = menu->list; iter; iter = iter->next) { GntMenuItem *item = iter->data; char trigger = gnt_menuitem_get_trigger(item); const char *text = item->text; if (trigger != '\0') continue; while (*text) { char ch = tolower(*text++); char t[2] = {ch, '\0'}; if (ch == ' ' || bools[(int)GET_VAL(ch)] || gnt_bindable_check_key(GNT_BINDABLE(menu), t)) continue; trigger = ch; break; } if (trigger == 0) trigger = item->text[0]; gnt_menuitem_set_trigger(item, trigger); bools[(int)GET_VAL(trigger)] = 1; } }
int parse_braille() { int i; for(i=0;i<length[0];i+=3) { char *first = lines[0]; char *second = lines[1]; char *third = lines[2]; first+=i;second+=i;third+=i; int braille_rep = get_braille_rep(first,second,third); if(braille_rep == -1) return -1; printf("%c",GET_VAL(braille_rep)); } printf("\n"); return 0; }
static void xgene_enet_delete_bufpool(struct xgene_enet_desc_ring *buf_pool) { struct xgene_enet_raw_desc16 *raw_desc; u32 slots = buf_pool->slots - 1; u32 tail = buf_pool->tail; u32 userinfo; int i, len; len = xgene_enet_ring_len(buf_pool); for (i = 0; i < len; i++) { tail = (tail - 1) & slots; raw_desc = &buf_pool->raw_desc16[tail]; /* Hardware stores descriptor in little endian format */ userinfo = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0)); dev_kfree_skb_any(buf_pool->rx_skb[userinfo]); } iowrite32(-len, buf_pool->cmd); buf_pool->tail = tail; }
static void xgene_enet_delete_bufpool(struct xgene_enet_desc_ring *buf_pool) { struct xgene_enet_pdata *pdata = netdev_priv(buf_pool->ndev); struct xgene_enet_raw_desc16 *raw_desc; u32 slots = buf_pool->slots - 1; u32 tail = buf_pool->tail; u32 userinfo; int i, len; len = pdata->ring_ops->len(buf_pool); for (i = 0; i < len; i++) { tail = (tail - 1) & slots; raw_desc = &buf_pool->raw_desc16[tail]; /* Hardware stores descriptor in little endian format */ userinfo = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0)); dev_kfree_skb_any(buf_pool->rx_skb[userinfo]); } pdata->ring_ops->wr_cmd(buf_pool, -len); buf_pool->tail = tail; }
void *run_thread(void *tid) { int i, id = (int)(long) tid; struct timespec start, end; int iters = shared.num_iters; pthread_barrier_wait(&shared.barrier); tracepoint(tl, start_test_thread, id); clock_gettime(CLOCK_MONOTONIC, &start); for (i = 0; i < iters; i++) { int r = rand() % DATA_SIZE_FULL; if ((rand() % 100) < 80) { cache_get(shared.cache, GET_KEY(r)); } else { cache_put(shared.cache, GET_KEY(r), GET_VAL(r)); } } clock_gettime(CLOCK_MONOTONIC, &end); tracepoint(tl, end_test_thread, id, ELAPSED_TIME(start, end)); //~ printf("%d\n", id); pthread_exit(NULL); }
void EffectOptionsMenu (void) { static int choice = 0; CMenu m; int i, j; int optEnableFx, optGatlingTrails, optStaticSmoke, optSoftParticles [3]; #if 0 int optShockwaves; #endif char szSlider [50]; pszExplShrapnels [0] = TXT_NONE; pszExplShrapnels [1] = TXT_FEW; pszExplShrapnels [2] = TXT_MEDIUM; pszExplShrapnels [3] = TXT_MANY; pszExplShrapnels [4] = TXT_EXTREME; pszNoneBasicFull [0] = TXT_NONE; pszNoneBasicFull [1] = TXT_BASIC; pszNoneBasicFull [2] = TXT_FULL; pszNoneBasicAdv [0] = TXT_NONE; pszNoneBasicAdv [1] = TXT_BASIC; pszNoneBasicAdv [2] = TXT_ADVANCED; pszThrusters [0] = TXT_NONE; pszThrusters [1] = TXT_2D; pszThrusters [2] = TXT_3D; nCoronas = gameOpts->render.coronas.bUse ? gameOpts->render.coronas.nStyle == 2 ? 2 : 1 : 0; nShadows = extraGameInfo [0].bShadows ? ((gameOpts->render.shadows.nReach == 2) && (gameOpts->render.shadows.nClip == 2)) ? 2 : 1 : 0; nLightTrails = extraGameInfo [0].bLightTrails ? gameOpts->render.particles.bPlasmaTrails ? 2 : 1 : 0; do { m.Destroy (); m.Create (30); optEnableFx = m.AddCheck (TXT_ENABLE_EFFECTS, gameOpts->render.effects.bEnabled, KEY_F, HTX_ENABLE_EFFECTS); m.AddText (""); sprintf (szSlider + 1, TXT_SMOKE, pszNoneBasicFull [gameOpts->render.particles.nQuality]); *szSlider = *(TXT_SMOKE - 1); effectOpts.nSmoke = m.AddSlider (szSlider + 1, gameOpts->render.particles.nQuality, 0, 2, KEY_S, HTX_SMOKE); if (!gameStates.render.bHaveStencilBuffer) effectOpts.nShadows = -1; else { sprintf (szSlider + 1, TXT_SHADOWS, pszNoneBasicFull [nShadows]); *szSlider = *(TXT_SHADOWS - 1); effectOpts.nShadows = m.AddSlider (szSlider + 1, nShadows, 0, 2, KEY_H, HTX_SHADOWS); } sprintf (szSlider + 1, TXT_CORONAS, pszNoneBasicAdv [nCoronas]); *szSlider = *(TXT_CORONAS - 1); effectOpts.nCoronas = m.AddSlider (szSlider + 1, nCoronas, 0, 1 + ogl.m_states.bDepthBlending, KEY_O, HTX_CORONAS); sprintf (szSlider + 1, TXT_LIGHTNING, pszNoneBasicFull [int (extraGameInfo [0].bUseLightning)]); *szSlider = *(TXT_LIGHTNING - 1); effectOpts.nLightning = m.AddSlider (szSlider + 1, extraGameInfo [0].bUseLightning, 0, 2, KEY_L, HTX_LIGHTNING); m.AddText (""); if (extraGameInfo [0].bUseParticles) { sprintf (szSlider + 1, TXT_EXPLOSION_SHRAPNELS, pszExplShrapnels [gameOpts->render.effects.nShrapnels]); *szSlider = *(TXT_EXPLOSION_SHRAPNELS - 1); effectOpts.nExplShrapnels = m.AddSlider (szSlider + 1, gameOpts->render.effects.nShrapnels, 0, 4, KEY_E, HTX_EXPLOSION_SHRAPNELS); } else effectOpts.nExplShrapnels = -1; sprintf (szSlider + 1, TXT_LIGHTTRAIL_QUAL, pszNoneBasicAdv [nLightTrails]); *szSlider = *(TXT_LIGHTTRAIL_QUAL - 1); effectOpts.nLightTrails = m.AddSlider (szSlider + 1, nLightTrails, 0, 1 + extraGameInfo [0].bUseParticles, KEY_T, HTX_LIGHTTRAIL_QUAL); sprintf (szSlider + 1, TXT_THRUSTER_FLAMES, pszThrusters [int (extraGameInfo [0].bThrusterFlames)]); *szSlider = *(TXT_THRUSTER_FLAMES - 1); effectOpts.nThrusters = m.AddSlider (szSlider + 1, extraGameInfo [0].bThrusterFlames, 0, 2, KEY_U, HTX_THRUSTER_FLAMES); m.AddText (""); if (extraGameInfo [0].bUseParticles) { optStaticSmoke = m.AddCheck (TXT_SMOKE_STATIC, gameOpts->render.particles.bStatic, KEY_A, HTX_ADVRND_STATICSMOKE); optGatlingTrails = m.AddCheck (TXT_GATLING_TRAILS, extraGameInfo [0].bGatlingTrails, KEY_G, HTX_GATLING_TRAILS); } else optStaticSmoke = optGatlingTrails = -1; if ((gameOptions [0].render.nQuality < 3) || (gameOpts->app.bExpertMode != SUPERUSER)) optSoftParticles [0] = optSoftParticles [1] = optSoftParticles [2] = -1; else { m.AddText (""); optSoftParticles [0] = m.AddCheck (TXT_SOFT_SPRITES, (gameOpts->render.effects.bSoftParticles & 1) != 0, KEY_I, HTX_SOFT_SPRITES); optSoftParticles [1] = m.AddCheck (TXT_SOFT_SPARKS, (gameOpts->render.effects.bSoftParticles & 2) != 0, KEY_A, HTX_SOFT_SPARKS); if (extraGameInfo [0].bUseParticles) optSoftParticles [2] = m.AddCheck (TXT_SOFT_SMOKE, (gameOpts->render.effects.bSoftParticles & 4) != 0, KEY_O, HTX_SOFT_SMOKE); else optSoftParticles [2] = -1; } for (;;) { i = m.Menu (NULL, TXT_EFFECT_MENUTITLE, EffectOptionsCallback, &choice); if (i < 0) break; } extraGameInfo [0].bUseParticles = (gameOpts->render.particles.nQuality != 0); if (effectOpts.nShadows >= 0) { if ((extraGameInfo [0].bShadows = (nShadows != 0))) gameOpts->render.shadows.nReach = gameOpts->render.shadows.nClip = nShadows; } if ((gameOpts->render.coronas.bUse = (nCoronas != 0))) gameOpts->render.coronas.nStyle = nCoronas; for (j = 0; j < 3; j++) { if (optSoftParticles [j] >= 0) { if (m [optSoftParticles [j]].m_value) gameOpts->render.effects.bSoftParticles |= 1 << j; else gameOpts->render.effects.bSoftParticles &= ~(1 << j); } } GET_VAL (gameOpts->render.effects.bEnabled, optEnableFx); GET_VAL (gameOpts->render.particles.bStatic, optStaticSmoke); GET_VAL (extraGameInfo [0].bGatlingTrails, optGatlingTrails); if ((extraGameInfo [0].bLightTrails = (nLightTrails != 0))) gameOpts->render.particles.bPlasmaTrails = (nLightTrails == 2); } while (i == -2); SetDebrisCollisions (); DefaultEffectSettings (); if (gameOpts->render.effects.bEnabled && gameOpts->render.effects.bEnergySparks && gameStates.app.bGameRunning && !sparkManager.HaveSparks ()) sparkManager.Setup (); }
void NewGameMenu (void) { CMenu m; int optSelMsn, optMsnName, optLevelText, optLevel, optUseMod, optLaunch, optLoadout; int nMission = gameData.missions.nLastMission, bMsnLoaded = 0; int i, choice = 0, bEnableMod = gameOpts->app.bEnableMods; char szDifficulty [50]; char szLevelText [32]; char szLevel [5]; #if DBG int optLives; char szLives [5]; #endif static int nPlayerMaxLevel = 1; static int nLevel = 0; if (gameStates.app.bNostalgia) { LegacyNewGameMenu (); return; } gameStates.app.bD1Mission = 0; gameStates.app.bD1Data = 0; gameOpts->app.nVersionFilter = 3; SetDataVersion (-1); if (nMission < 0) gameFolders.szMsnSubDir [0] = '\0'; else if (gameOpts->app.bSinglePlayer) { if (!strstr (gameFolders.szMsnSubDir, "single/")) nMission = -1; gameFolders.szMsnSubDir [0] = '\0'; } hogFileManager.UseMission (""); for (;;) { m.Destroy (); m.Create (15); optLevel = optUseMod = -1; optSelMsn = m.AddMenu (TXT_SEL_MISSION, KEY_I, HTX_MULTI_MISSION); optMsnName = m.AddText ((nMission < 0) ? TXT_NONE_SELECTED : gameData.missions.list [nMission].szMissionName, 0); if ((nMission >= 0) && (nPlayerMaxLevel > 1)) { sprintf (szLevelText, "%s (1-%d)", TXT_LEVEL_, nPlayerMaxLevel); Assert (strlen (szLevelText) < 100); optLevelText = m.AddText (szLevelText, 0); m [optLevelText].m_bRebuild = 1; sprintf (szLevel, "%d", nLevel); optLevel = m.AddInput (szLevel, 4, HTX_MULTI_LEVEL); } if (nMission >= 0) { gameOpts->app.bEnableMods = 1; MakeModFolders (hogFileManager.m_files.MsnHogFiles.szName); gameOpts->app.bEnableMods = bEnableMod; if (gameStates.app.bHaveMod == IsBuiltInMission (hogFileManager.m_files.MsnHogFiles.szName)) { m.AddText ("", 0); optUseMod = m.AddCheck (TXT_ENABLE_MODS, gameOpts->app.bEnableMods, KEY_O, HTX_ENABLE_MODS); } } #if DBG m.AddText (""); m.AddText ("Initial Lives:"); sprintf (szLives, "%d", gameStates.gameplay.nInitialLives); optLives = m.AddInput (szLives, 4); #endif m.AddText (" ", 0); sprintf (szDifficulty + 1, TXT_DIFFICULTY2, MENU_DIFFICULTY_TEXT (gameStates.app.nDifficultyLevel)); *szDifficulty = *(TXT_DIFFICULTY2 - 1); nOptDifficulty = m.AddSlider (szDifficulty + 1, gameStates.app.nDifficultyLevel, 0, 4, KEY_D, HTX_GPLAY_DIFFICULTY); m.AddText ("", 0); optLoadout = m.AddMenu (TXT_LOADOUT_OPTION, KEY_B, HTX_MULTI_LOADOUT); if (nMission >= 0) { m.AddText ("", 0); optLaunch = m.AddMenu (TXT_LAUNCH_GAME, KEY_L, ""); m [optLaunch].m_bCentered = 1; } else optLaunch = -1; i = m.Menu (NULL, TXT_NEWGAME_MENUTITLE, NewGameMenuCallback, &choice); if (i < 0) { SetFunctionMode (FMODE_MENU); return; } GET_VAL (gameOpts->app.bEnableMods, optUseMod); if (choice == optLoadout) LoadoutOptionsMenu (); else if (choice == optSelMsn) { i = SelectAndLoadMission (0, NULL); if (i >= 0) { bMsnLoaded = 1; nMission = i; nLevel = 1; PrintLog (" getting highest level allowed to play\n"); nPlayerMaxLevel = GetHighestLevel (); if (nPlayerMaxLevel > gameData.missions.nLastLevel) nPlayerMaxLevel = gameData.missions.nLastLevel; } } else if (choice == optLevel) { i = atoi (m [optLevel].m_text); #if DBG if (!i || (i < -gameData.missions.nSecretLevels) || (i > nPlayerMaxLevel)) #else if ((i <= 0) || (i > nPlayerMaxLevel)) #endif MsgBox (NULL, NULL, 1, TXT_OK, TXT_INVALID_LEVEL); else if (nLevel == i) break; else nLevel = i; } else if (nMission >= 0) { if ((optLevel > 0) && !(nLevel = atoi (m [optLevel].m_text))) { MsgBox (NULL, NULL, 1, TXT_OK, TXT_INVALID_LEVEL); nLevel = 1; } else break; } #if DBG else { i = atoi (m [optLives].m_text); if (i > 0) gameStates.gameplay.nInitialLives = min (i, 255); } #endif } i = m [nOptDifficulty].m_value; if (gameStates.app.nDifficultyLevel != i) { gameStates.app.nDifficultyLevel = i; gameData.bosses.InitGateIntervals (); } SavePlayerProfile (); paletteManager.DisableEffect (); if (!bMsnLoaded) LoadMission (nMission); if (!StartNewGame (nLevel)) SetFunctionMode (FMODE_MENU); }
int LuaScript::toInt(void *context, void *object) { DECL_STATE(L, context); return (int)GET_VAL(L, integer, object); }
int Compute_NotOptT26( int neighbors[27] ) { /*--- the neighborhood is numbered as follows 0 1 2 - 9 10 11 - 18 19 20 3 4 5 - 12 13 14 - 21 22 23 6 7 8 - 15 16 17 - 24 25 26 A point belongs to the background if its value is 0, else it belongs to the object. We consider here the connected components of the object. The maximal number of 26-connected components is obviously 8 (one per each vertex). We attribute one label per each possible connected component. Those labels are : 0 . 1 - . . . - 4 . 5 . . . - . . . - . . . 2 . 3 - . . . - 6 . 7 * Connected component #i may exist if and only if one among 8 points belongs to the object. Those points are respectively : for component #0, points 0 1 3 4 9 10 12 13 for component #1, points 1 2 4 5 10 11 13 14 for component #2, points 3 4 6 7 12 13 15 16 for component #3, points 4 5 7 8 13 14 16 17 for component #4, points 9 10 12 13 18 19 21 22 for component #5, points 10 11 13 14 19 20 22 23 for component #6, points 12 13 15 16 21 22 24 25 for component #7, points 13 14 16 17 22 23 25 26 * If a object point belongs to more than one component, these components are equivalent. ---*/ int label_vertex[8], label_exists[8]; register int i, min_label, nb, old_label; register int a_label, b_label; /*--- initialization: Each label is set to its possible value, but we do not known if each component will exist. ---*/ for ( i = 0; i < 8; i ++ ) { label_vertex[i] = i; label_exists[i] = _FALSE_; } /*--- Let consider component #0 and its possible equivalences: we will examinate the possible points of #0 which may generate an equivalence with an other component: - 3 points (4, 10, 12) yield an equivalence between four components (e.g. 4 yields an equivalence between #0, #1, #2 and #3) - 3 points (1, 3, 9) yield an equivalence between two components (e.g. 1 yields an equivalence between #0 and #1) At this point, no conflict between labels can occur. ---*/ if ( GET_VAL( neighbors, 4 ) != 0 ) { min_label = label_vertex[0]; if ( label_vertex[1] < min_label ) min_label = label_vertex[1]; if ( label_vertex[2] < min_label ) min_label = label_vertex[2]; if ( label_vertex[3] < min_label ) min_label = label_vertex[3]; if ( label_vertex[0] != min_label ) _T26_EQUIVALENCE( min_label, 0 ) if ( label_vertex[1] != min_label ) _T26_EQUIVALENCE( min_label, 1 ) if ( label_vertex[2] != min_label ) _T26_EQUIVALENCE( min_label, 2 ) if ( label_vertex[3] != min_label ) _T26_EQUIVALENCE( min_label, 3 ) label_exists[0] = label_exists[1] = label_exists[2] = label_exists[3] = _TRUE_; } else {
long LuaScript::toLong(void *context, void *object) { DECL_STATE(L, context); return (long)GET_VAL(L, integer, object); }
float LuaScript::toFloat(void *context, void *object) { DECL_STATE(L, context); return (float)GET_VAL(L, number, object); }
/* Recursively create FS tree Inputs: T - pointer to first node in tree's node array ti - pointer to ind of first empty spot in T DL - the doubly-linked lists V - N-by-D array of values d - number of dimensions first - vector of inds of first element in list for each dimension last - vector of inds of last element in list for each dimension */ fsp_t FS_RECURSE(FS_TNODE * T, fsp_t * ti, FS_LNODE ** DL, val_t * V, int d, fsp_t * first, fsp_t * last) { // Declare variables int di; //dimension counter float mdw, tdw; //max dimension width, this dimension's width int mdi; //max dimension ind fsp_t fbi, fei, i; //index of search from beginning, and end, total step counter fsp_t adp; //pointer to this point in adjacent dimension fsp_t * firsts1, * firsts2, * lasts1, * lasts2; //firsts and lasts for new lists int td; //this dimension // Check to see if base case (list of length 1) if (first[0] == last[0]) { //if we've got only a single point, (first==last in any dimension) T[*ti].c1 = DL[0][first[0]].data; //store pointer to this point's data T[*ti].c2 = -1; //store null value to signify leaf //T[*ti].wspl = NULL; //no wsp list yet T[*ti].Ra = NULL; //points dont have bounds, and re-storing data would be waste of O(n) space; it's already in V T[*ti].Rb = NULL; (*ti)++; //we used the spot at ti, so increment next avail spot (NOTE: increment operator binds tighter than the f@%&ing dereference operator, so can't do "*ti++"!!!) return *ti-1; //return pointer to this tree node } // 1. Find widest dimension mdw = 0; //max dimension width, mdi = 0; //max dimension ind for (di=0; di<d; di++) { // for each dimension tdw = GET_VAL(DL, V, d, di, last[di]) - GET_VAL(DL, V, d, di, first[di]); //width of dimension di if ( tdw > mdw ) { //if widest dimension so far, mdw = tdw; //store new max dim width mdi = di; //this dim is widest so far } } // 2. Walk thru widest dim's list from each end to find midpoint //assigning .half=0 or 1 as you go to points in adjacent dims i=0; //index of search from beginning, and end, total step counter fbi = first[mdi]; //start from beginning of this list in widest dim fei = last[mdi]; //and last while ( 1 ) { //while we haven't met in the middle if (i%2==0) { //step from beginning half the time adp = DL[mdi][fbi].adj_n; //pointer to this point in adjacent dimension for (di=1; di<d; di++) { // set flags for this point in adjacent dimension's lists DL[(mdi+di)%d][adp].half = (char) 0; //set flag to first half adp = DL[(mdi+di)%d][adp].adj_n; //pointer to this point in dim after that } if ( fei==fbi ) break; //quit if we've met in middle fbi = DL[mdi][fbi].next; //step forward } else { //step from end other half of the time adp = DL[mdi][fei].adj_n; //pointer to this point in adjacent dimension for (di=1; di<d; di++) { // set flags for this point in adjacent dimension's lists DL[(mdi+di)%d][adp].half = (char) 1; //set flag to first half adp = DL[(mdi+di)%d][adp].adj_n; //pointer to this point in dim after that } if ( fei==fbi ) break; //quit if we've met in middle fei = DL[mdi][fei].prev; //step backwards } i++; //increment step counter } // 3. Split widest dim's list (node we met at is last element in 1st half's list) // Create new firsts and lasts lists for both lists // Then set this list's midpoint to have null next pointer, and mid+1 to have null prev pointer //fsp_t firsts1[d], firsts2[d], lasts1[d], lasts2[d]; //firsts and lasts for new lists firsts1 = malloc(d*sizeof(fsp_t)); //firsts and lasts for new lists firsts2 = malloc(d*sizeof(fsp_t)); lasts1 = malloc(d*sizeof(fsp_t)); lasts2 = malloc(d*sizeof(fsp_t)); if (i%2==0) { // we met in the exact middle of the list fei = DL[mdi][fbi].next; //point to first element of 2nd half's list } else { // list had even #, met after middle fbi = DL[mdi][fbi].prev; //point to last element of 1st half's list } DL[mdi][fbi].next = -1; //make fbi last element of 1st half's list DL[mdi][fei].prev = -1; //make fei first element of 2nd half's list firsts1[mdi] = first[mdi]; //same first element for this dim firsts2[mdi] = fei; //2nd list now starts at fei lasts1[mdi] = fbi; //first half's list now ends at fbi lasts2[mdi] = last[mdi]; //second half's list ends at same place // 4. Spit other dim's lists according to widest dim's split //Walk through each adjacent dim's list, re-setting pointers according to the 0/1 flags, to create 2 separate lists for (di=1; di<d; di++) { // for each dimension td = (mdi+di)%d; //this dimension fbi = -1; // now is pointer to most recent element in first half fei = -1; // now is pointer to most recent element in second half i = first[td]; //first in this list overall while ( fbi!=last[td] && fei!=last[td] ) { //while we haven't hit the end of the list if (DL[td][i].half==0) { //this node to go in first half's list DL[td][i].prev = fbi; //point back to most recent element in list 1 if (fbi >= 0) { //if this isn't the first element in the list, DL[td][fbi].next = i; //previous element of list 1 points next to here } else { //this is the first element of list 1 firsts1[td] = i; //store pointer to first element of list 1 } fbi = i; //store most recent entry in list 1 } else { //this node to go in 2nd half's list DL[td][i].prev = fei; //point back to most recent element in list 2 if (fei >= 0) { //if this isn't the first element in the list, DL[td][fei].next = i; //previous element of list 2 points next to here } else { //this is the first element of list 1 firsts2[td] = i; //store pointer to first element of list 1 } fei = i; //store most recent entry in list 1 } i = DL[td][i].next; //move on to next node in parent list } DL[td][fbi].next = -1; //last element of first list points next to null DL[td][fei].next = -1; //last element of 2nd list points next to null lasts1[td] = fbi; //store last element of 1st list lasts2[td] = fei; //store last element of 2nd list } // 5. Recursively split each list, getting pointers to Tree nodes for each fbi = FS_RECURSE(T, ti, DL, V, d, firsts1, lasts1); //get pointer to tree node for 1st half fei = FS_RECURSE(T, ti, DL, V, d, firsts2, lasts2); //get pointer to tree node for 2nd half // 6. Create new tree node, and link to its children, store bounding box if internal node, increment value at ti T[*ti].c1 = fbi; //store pointer to child 1 (1st half of list) T[*ti].c2 = fei; //store pointer to child 2 (2nd half of list) //T[*ti].wspl = NULL; //no wsp list yet T[*ti].Ra = malloc(d*sizeof(val_t)); //store lower bounds for dimensions T[*ti].Rb = malloc(d*sizeof(val_t)); //store upper bounds for dimensions for (di=0; di<d; di++){ T[*ti].Ra[di] = GET_VAL(DL, V, d, di, first[di]); //lower bound for this dim T[*ti].Rb[di] = GET_VAL(DL, V, d, di, last[di]); //lower bound for this dim } (*ti)++; //we used the spot at ti, so increment next avail spot (NOTE: increment operator binds tighter than the damn dereference operator, so can't do "*ti++") free(firsts1); free(firsts2); free(lasts1); free(lasts2); //free the arrays return *ti-1; //return pointer to this tree node }
float LuaScript::toDouble(void *context, void *object) { DECL_STATE(L, context); return (double)GET_VAL(L, number, object); }
bool LuaScript::toBool(void *context, void *object) { DECL_STATE(L, context); return (bool)GET_VAL(L, boolean, object); }
static bool _decode( zson_t *zd, zsnode_t *z, const char *src, size_t start, size_t maxsize, bool keyval, bool bit64 ){ memset(z,0,sizeof(zsnode_t)); const char* origin = src; int header = src[start]; int minsize = bit64 ? minsize64[header] : minsize32[header]; int headersize = bit64 ? headersize64[header] : headersize32[header]; size_t size = minsize; z->type = header; z->start = start; z->entity = src; z->has_next = false; z->content_start = headersize; z->content = src + headersize; z->size = minsize; if(header == 0 || header >= ZSON_TYPE_COUNT){ zson_set_error(zd, ZSON_ERROR_INVALID_HEADER, "invalid header"); return false; }else if(minsize > maxsize){ zson_set_error(zd, ZSON_ERROR_INVALID_SIZE, "exceeding parent size"); return false; } src = src+start; switch(header){ case ZSON_NO_ENT: case ZSON_NULL: break; case ZSON_TRUE: z->value.boolean = 1; break; case ZSON_FALSE: z->value.boolean = 0; break; case ZSON_INT8: z->value.int8 = (int8_t)src[1]; break; case ZSON_INT16: z->value.int16 = GET_VAL(src,1,int16_t); break; case ZSON_INT32: z->value.int32 = GET_VAL(src,1,int32_t); break; case ZSON_INT64: z->value.int64 = GET_VAL(src,1,int64_t); break; case ZSON_UINT8: z->value.uint8 = (int8_t)src[1]; break; case ZSON_UINT16: z->value.uint16 = GET_VAL(src,1,uint16_t); break; case ZSON_UINT32: z->value.uint32 = GET_VAL(src,1,uint32_t); break; case ZSON_UINT64: z->value.uint64 = GET_VAL(src,1,uint64_t); break; case ZSON_FLOAT32: z->value.float32 = GET_VAL(src,1,float); break; case ZSON_FLOAT64: z->value.float64 = GET_VAL(src,1,double); break; case ZSON_STRING4: case ZSON_STRING8: case ZSON_STRING12: z->value.string = src + 1; if(src[z->size -1] != 0){ zson_set_error( zd, ZSON_ERROR_RUNAWAY_STRING, "strings must be null terminated"); return false; } break; default: { size = bit64 ? GET_VAL(src,1,uint64_t) : GET_VAL(src,1,uint32_t); z->size = size; if(size > maxsize){ zson_set_error( zd, ZSON_ERROR_INVALID_SIZE, "size exceeds parent size"); return false; }else if( size < minsize){ zson_set_error(zd, ZSON_ERROR_INVALID_SIZE, "size too small"); return false; } if (header == ZSON_STRING){ if(size - headersize <= 0 || src[z->size -1] != 0){ zson_set_error( zd, ZSON_ERROR_RUNAWAY_STRING, "zero length strings must also be null terminated"); return false; } z->value.string = src + headersize; z->length = size - headersize - 1; }else if(header == ZSON_OBJECT || header == ZSON_ARRAY){ z->has_child = size > headersize; }else if(header >= ZSON_ARRAY_INT8 && header <= ZSON_ARRAY_FLOAT64){ if( size == headersize){ z->value.ptr = NULL; z->length = 0; }else{ int padding = subsize[z->type]; padding = padding <= 1 ? 0 : (padding - start % padding) % padding; if( headersize + padding > size){ zson_set_error( zd, ZSON_ERROR_INVALID_PADDING, "padding going outside of entity"); return false; } z->value.ptr = src + headersize + padding; z->length = (z->size - headersize - padding) / subsize[z->type]; z->content_start += padding; } } } } if(keyval){ if(z->type < ZSON_STRING || z->type > ZSON_STRING12){ zson_set_error( zd, ZSON_ERROR_INVALID_KEY, "key value pairs must start with a string" ); return false; } if(!_decode(zd, z, origin, start+size, maxsize-size, false, bit64 )){ return false; } z->key = src + headersize; z->size += size; z->content_start += size; z->start = start; } return z->type; }
void GameplayOptionsMenu (void) { static int choice = 0; CMenu m; int i; int optSmartWeaponSwitch = -1, optHeadlightBuiltIn = -1, optHeadlightPowerDrain = -1, optNoThief = -1; int optReorderPrim, optReorderSec; char szSlider [50]; pszAggressivities [0] = TXT_STANDARD; pszAggressivities [1] = TXT_MODERATE; pszAggressivities [2] = TXT_MEDIUM; pszAggressivities [3] = TXT_HIGH; pszAggressivities [4] = TXT_VERY_HIGH; pszAggressivities [5] = TXT_EXTREME; pszWeaponSwitch [0] = TXT_NEVER; pszWeaponSwitch [1] = TXT_WHEN_EMPTY; pszWeaponSwitch [2] = TXT_CHOSE_BEST; nAIAggressivity = (gameOpts->gameplay.nAIAggressivity && gameOpts->gameplay.nAIAwareness) ? 5 : gameOpts->gameplay.nAIAggressivity; do { m.Destroy (); m.Create (20); sprintf (szSlider + 1, TXT_DIFFICULTY2, MENU_DIFFICULTY_TEXT (gameStates.app.nDifficultyLevel)); *szSlider = *(TXT_DIFFICULTY2 - 1); gplayOpts.nDifficulty = m.AddSlider (szSlider + 1, gameStates.app.nDifficultyLevel, 0, 4, KEY_D, HTX_GPLAY_DIFFICULTY); sprintf (szSlider + 1, TXT_AI_AGGRESSIVITY, pszAggressivities [nAIAggressivity]); *szSlider = *(TXT_AI_AGGRESSIVITY - 1); gplayOpts.nAIAggressivity = m.AddSlider (szSlider + 1, nAIAggressivity, 0, 5, KEY_A, HTX_AI_AGGRESSIVITY); sprintf (szSlider + 1, TXT_WEAPON_SWITCH, pszWeaponSwitch [gameOpts->gameplay.nAutoSelectWeapon]); *szSlider = *(TXT_WEAPON_SWITCH - 1); gplayOpts.nWeaponSwitch = m.AddSlider (szSlider + 1, gameOpts->gameplay.nAutoSelectWeapon, 0, 2, KEY_W, HTX_WEAPON_SWITCH); m.AddText ("", 0); optSmartWeaponSwitch = m.AddCheck (TXT_SMART_WPNSWITCH, extraGameInfo [0].bSmartWeaponSwitch, KEY_S, HTX_GPLAY_SMARTSWITCH); optHeadlightBuiltIn = m.AddCheck (TXT_HEADLIGHT_BUILTIN, extraGameInfo [0].headlight.bBuiltIn, KEY_B, HTX_HEADLIGHT_BUILTIN); optHeadlightPowerDrain = m.AddCheck (TXT_HEADLIGHT_POWERDRAIN, extraGameInfo [0].headlight.bDrainPower, KEY_H, HTX_HEADLIGHT_POWERDRAIN); optNoThief = m.AddCheck (TXT_SUPPRESS_THIEF, gameOpts->gameplay.bNoThief, KEY_T, HTX_SUPPRESS_THIEF); m.AddText (""); optReorderPrim = m.AddMenu (TXT_PRIMARY_PRIO, KEY_P, HTX_OPTIONS_PRIMPRIO); optReorderSec = m.AddMenu (TXT_SECONDARY_PRIO, KEY_E, HTX_OPTIONS_SECPRIO); for (;;) { if (0 > (i = m.Menu (NULL, TXT_GAMEPLAY_OPTS, GameplayOptionsCallback, &choice))) break; if (choice == optReorderPrim) ReorderPrimary (); else if (choice == optReorderSec) ReorderSecondary (); }; } while (i == -2); if (nAIAggressivity == 5) { gameOpts->gameplay.nAIAwareness = 1; gameOpts->gameplay.nAIAggressivity = nAIAggressivity - 1; } else { gameOpts->gameplay.nAIAwareness = 0; gameOpts->gameplay.nAIAggressivity = nAIAggressivity; } extraGameInfo [0].headlight.bAvailable = m [gplayOpts.nHeadlightAvailable].m_value; extraGameInfo [0].bSmartWeaponSwitch = m [optSmartWeaponSwitch].m_value; GET_VAL (gameOpts->gameplay.bNoThief, optNoThief); GET_VAL (extraGameInfo [0].headlight.bDrainPower, optHeadlightPowerDrain); GET_VAL (extraGameInfo [0].headlight.bBuiltIn, optHeadlightBuiltIn); DefaultGameplaySettings (); if (IsMultiGame && !COMPETITION && EGI_FLAG (bSmokeGrenades, 0, 0, 0)) LOCALPLAYER.secondaryAmmo [PROXMINE_INDEX] = 4; if (IsMultiGame) NetworkSendExtraGameInfo (NULL); }
void* test(void* thread) { size_t num_retry_cas1 = 0, num_retry_cas2 = 0, num_retry_cas3 = 0 , num_retry_cas4 = 0, num_retry_cas5 = 0; thread_data_t* td = (thread_data_t*) thread; uint8_t ID = td->id; phys_id = the_cores[ID % (NUMBER_OF_SOCKETS * CORES_PER_SOCKET)]; set_cpu(phys_id); ssmem_allocator_t* alloc = (ssmem_allocator_t*) memalign(CACHE_LINE_SIZE, sizeof(ssmem_allocator_t)); assert(alloc != NULL); ssmem_alloc_init(alloc, SSMEM_DEFAULT_MEM_SIZE, ID); ssmem_gc_thread_init(alloc, ID); PF_INIT(3, SSPFD_NUM_ENTRIES, ID); #if defined(COMPUTE_LATENCY) volatile ticks my_putting_succ = 0; volatile ticks my_putting_fail = 0; volatile ticks my_getting_succ = 0; volatile ticks my_getting_fail = 0; volatile ticks my_removing_succ = 0; volatile ticks my_removing_fail = 0; #endif uint64_t my_putting_count = 0; uint64_t my_getting_count = 0; uint64_t my_removing_count = 0; uint64_t my_putting_count_succ = 0; uint64_t my_getting_count_succ = 0; uint64_t my_removing_count_succ = 0; #if defined(COMPUTE_LATENCY) && PFD_TYPE == 0 volatile ticks start_acq, end_acq; volatile ticks correction = getticks_correction_calc(); #endif seeds = seed_rand(); MEM_BARRIER; barrier_cross(&barrier); barrier_cross(&barrier_global); size_t obj_size_bytes = obj_size * sizeof(size_t); volatile size_t* dat = (size_t*) malloc(obj_size_bytes); assert(dat != NULL); size_t* obj = NULL; while (stop == 0) { size_t rand = (my_random(&(seeds[0]), &(seeds[1]), &(seeds[2]))); size_t k = (rand & 1) + 2; rand &= 1023; /* search baby! */ int i; for (i = 0; i < KEY_BUCKT; i++) { volatile uintptr_t v = val[i]; if (snap->map[i] == MAP_VALID && key[i] == k) { if (val[i] == v) { if (GET_VAL(v) != k) { printf("[%02d] :get: key != val for %zu\n", ID, k); } break; } } } if (rand > 513) { my_putting_count++; if (obj != NULL) { ssmem_free(alloc, (void*) obj); } obj = ssmem_alloc(alloc, 8); *obj = k; int empty_index = -2; clht_snapshot_t s; retry: s.snapshot = snap->snapshot; int i; for (i = 0; i < KEY_BUCKT; i++) { volatile uintptr_t v = val[i]; if (snap->map[i] == MAP_VALID && key[i] == k) { if (val[i] == v) { if (empty_index > 0) { snap->map[empty_index] = MAP_INVLD; } goto end; } } } clht_snapshot_all_t s1; if (empty_index < 0) { empty_index = snap_get_empty_index(s.snapshot); if (empty_index < 0) { num_retry_cas1++; goto end; } s1 = snap_set_map(s.snapshot, empty_index, MAP_INSRT); if (CAS_U64(&snap->snapshot, s.snapshot, s1) != s.snapshot) { empty_index = -2; num_retry_cas2++; goto retry; } val[empty_index] = (uintptr_t) obj; key[empty_index] = k; } else { s1 = snap_set_map(s.snapshot, empty_index, MAP_INSRT); } clht_snapshot_all_t s2 = snap_set_map_and_inc_version(s1, empty_index, MAP_VALID); if (CAS_U64(&snap->snapshot, s1, s2) != s1) { num_retry_cas3++; /* key[empty_index] = 0; */ /* val[empty_index] = 0; */ goto retry; } obj = NULL; my_putting_count_succ++; end: ; } else { my_removing_count++; clht_snapshot_t s; retry_rem: s.snapshot = snap->snapshot; volatile uintptr_t v; int i, removed = 0; for (i = 0; i < KEY_BUCKT && !removed; i++) { if (key[i] == k && s.map[i] == MAP_VALID) { v = val[i]; clht_snapshot_all_t s1 = snap_set_map(s.snapshot, i, MAP_INVLD); if (CAS_U64(&snap->snapshot, s.snapshot, s1) == s.snapshot) { /* snap->map[i] = MAP_INVLD; */ removed = 1; } else { num_retry_cas4++; goto retry_rem; } } } if (removed) { ssmem_free(alloc, (void*) v); my_removing_count_succ++; } } } free((void*) dat); #if defined(DEBUG) if (put_num_restarts | put_num_failed_expand | put_num_failed_on_new) { /* printf("put_num_restarts = %3u / put_num_failed_expand = %3u / put_num_failed_on_new = %3u \n", */ /* put_num_restarts, put_num_failed_expand, put_num_failed_on_new); */ } #endif if (ID < 2) { printf("#retry-stats-thread-%d: #cas1: %-8zu / #cas2: %-8zu /" "#cas3: %-8zu / #cas4: %-8zu / #cas5: %-8zu\n", ID, num_retry_cas1, num_retry_cas2, num_retry_cas3, num_retry_cas4, num_retry_cas5); } /* printf("gets: %-10llu / succ: %llu\n", num_get, num_get_succ); */ /* printf("rems: %-10llu / succ: %llu\n", num_rem, num_rem_succ); */ barrier_cross(&barrier); #if defined(COMPUTE_LATENCY) putting_succ[ID] += my_putting_succ; putting_fail[ID] += my_putting_fail; getting_succ[ID] += my_getting_succ; getting_fail[ID] += my_getting_fail; removing_succ[ID] += my_removing_succ; removing_fail[ID] += my_removing_fail; #endif putting_count[ID] += my_putting_count; getting_count[ID] += my_getting_count; removing_count[ID]+= my_removing_count; putting_count_succ[ID] += my_putting_count_succ; getting_count_succ[ID] += my_getting_count_succ; removing_count_succ[ID]+= my_removing_count_succ; #if (PFD_TYPE == 1) && defined(COMPUTE_LATENCY) if (ID == 0) { printf("get ----------------------------------------------------\n"); SSPFDPN(0, SSPFD_NUM_ENTRIES, print_vals_num); printf("put ----------------------------------------------------\n"); SSPFDPN(1, SSPFD_NUM_ENTRIES, print_vals_num); printf("rem ----------------------------------------------------\n"); SSPFDPN(2, SSPFD_NUM_ENTRIES, print_vals_num); } #endif /* SSPFDTERM(); */ pthread_exit(NULL); }