RELTIM tmevt_lefttim(TEVTCB *p_tevtcb, TMEVTB *p_tmevtb) { EVTTIM time; time = TMEVT_NODE(p_tevtcb, p_tmevtb->index).time; if (EVTTIM_LE(p_tevtcb, time, p_tevtcb->next_time)) { /* * 次のタイムティックで処理される場合には0を返す. */ return(0U); } else { return((RELTIM)(time - base_time(p_tevtcb))); } }
ER mig_tsk(ID tskid, ID prcid) { TCB *p_tcb; ER ercd = E_OK; PCB *t_p_pcb; PCB *f_p_pcb; bool_t dspreq = false; PCB *my_p_pcb; #ifdef TOPPERS_SYSTIM_LOCAL EVTTIM left_time; #endif /* TOPPERS_SYSTIM_LOCAL */ LOG_MIG_TSK_ENTER(tskid, prcid); CHECK_TSKCTX_UNL(); CHECK_TSKID_SELF(tskid); CHECK_PRCID_INI(prcid); t_lock_cpu(); p_tcb = get_tcb_self(tskid, get_my_p_pcb()); prcid = (prcid == TPRC_INI)? p_tcb->p_tinib->iaffinity : prcid; T_CHECK_MIG(p_tcb->p_tinib->affinity_mask, prcid); /* 現在割り付けられているプロセッサと移動先のプロセッサのタスクロックを取得 */ t_acquire_dual_tsk_lock(p_tcb, prcid, &f_p_pcb, &t_p_pcb); my_p_pcb = get_my_p_pcb(); if (f_p_pcb != my_p_pcb) { /* * 自タスクと同じプロセッサに割り付けられているタスクでなけれ * ばエラー. mig_tsk を呼び出したタスクがシステムコール呼出し後, * マイグレートされた場合にも,ここでエラーとなる */ ercd = E_OBJ; } else if (TSTAT_RUNNABLE(p_tcb->tstat)){ /* 実行可能状態 */ if(p_tcb == my_p_pcb->p_runtsk) { /* 自タスクに対して発行 */ if (!(my_p_pcb->dspflg)) { /* ディスパッチ禁止中ならエラー */ ercd = E_CTX; } else if (t_p_pcb == my_p_pcb) { /* 同一プロセッサを指定 */ /* 優先順位を同一優先度のタスクの中で最低とする */ dspreq = set_lowest_precedence(p_tcb, my_p_pcb); ercd = E_OK; } else { /* マイグレーション要求を処理 */ LOG_TSKMIG(p_tcb, my_p_pcb->prcid, prcid); dispatch_and_migrate(prcid); /* ここに戻ってくる時にはロックは解放されている */ ercd = E_OK; t_unlock_cpu(); goto error_exit; } } else { /* 他タスクの場合 */ if (t_p_pcb == my_p_pcb) { /* 同一プロセッサを指定 */ /* * 優先順位を同一優先度のタスクの中で最低とする. * 対象のタスクは最高優先順位のタスクでないため,タ * スク切り替えは発生しない */ (void)set_lowest_precedence(p_tcb, my_p_pcb); ercd = E_OK; } else { /* 異なるプロセッサを指定 */ /* レディーキューから外す */ make_non_runnable(p_tcb); /* pcb の書き換え */ p_tcb->p_pcb = t_p_pcb; LOG_TSKMIG(p_tcb, my_p_pcb->prcid, prcid); /* 移行先のプロセッサでmake_runnable する*/ if (make_runnable(p_tcb)) { dispatch_request(t_p_pcb); } ercd = E_OK; } } } else if (TSTAT_DORMANT(p_tcb->tstat)) { /* 休止状態 */ LOG_TSKMIG(p_tcb, my_p_pcb->prcid, prcid); p_tcb->p_pcb = t_p_pcb; ercd = E_OK; } else { /* 待ち状態 */ if ((p_tcb->tmevtb).callback == NULL) { /* 時間待ちでない場合 */ LOG_TSKMIG(p_tcb, my_p_pcb->prcid, prcid); p_tcb->p_pcb = t_p_pcb; ercd = E_OK; } else { /* * 時間待ちの場合 グローバルタイマ方式 なら必要なし */ #ifdef TOPPERS_SYSTIM_LOCAL /* キューから削除 */ left_time = tmevtb_dequeue(f_p_pcb->p_tevtcb, &(p_tcb->tmevtb)); LOG_TSKMIG(p_tcb, my_p_pcb->prcid, prcid); /* 移動先のプロセッサのキューに挿入 */ tmevtb_insert(t_p_pcb->p_tevtcb, &(p_tcb->tmevtb), base_time(t_p_pcb->p_tevtcb) + left_time); #else /* TOPPERS_SYSTIM_GLOBAL */ LOG_TSKMIG(p_tcb, my_p_pcb->prcid, prcid); #endif /* TOPPERS_SYSTIM_GLOBAL */ p_tcb->p_pcb = t_p_pcb; ercd = E_OK; } } release_dual_tsk_lock(f_p_pcb, t_p_pcb); if (dspreq) { dispatch(); } t_unlock_cpu(); error_exit: LOG_MIG_TSK_LEAVE(ercd); return(ercd); }
/* Get certificate info from CX509Certificate. */ static void get_cert_info(pj_pool_t *pool, pj_ssl_cert_info *ci, const CX509Certificate *x) { enum { tmp_buf_len = 512 }; char *tmp_buf; unsigned len; pj_assert(pool && ci && x); /* Init */ tmp_buf = new char[tmp_buf_len]; pj_bzero(ci, sizeof(*ci)); /* Version */ ci->version = x->Version(); /* Serial number */ len = x->SerialNumber().Length(); if (len > sizeof(ci->serial_no)) len = sizeof(ci->serial_no); pj_memcpy(ci->serial_no + sizeof(ci->serial_no) - len, x->SerialNumber().Ptr(), len); /* Subject */ { HBufC *subject = NULL; TRAPD(err, subject = x->SubjectL()); if (err == KErrNone) { TPtr16 ptr16(subject->Des()); len = ptr16.Length(); TPtr8 ptr8((TUint8*)pj_pool_alloc(pool, len), len); ptr8.Copy(ptr16); pj_strset(&ci->subject.cn, (char*)ptr8.Ptr(), ptr8.Length()); } pj_str_t tmp = get_cert_name(tmp_buf, tmp_buf_len, x->SubjectName()); pj_strdup(pool, &ci->subject.info, &tmp); } /* Issuer */ { HBufC *issuer = NULL; TRAPD(err, issuer = x->IssuerL()); if (err == KErrNone) { TPtr16 ptr16(issuer->Des()); len = ptr16.Length(); TPtr8 ptr8((TUint8*)pj_pool_alloc(pool, len), len); ptr8.Copy(ptr16); pj_strset(&ci->issuer.cn, (char*)ptr8.Ptr(), ptr8.Length()); } pj_str_t tmp = get_cert_name(tmp_buf, tmp_buf_len, x->IssuerName()); pj_strdup(pool, &ci->issuer.info, &tmp); } /* Validity */ const CValidityPeriod &valid_period = x->ValidityPeriod(); TTime base_time(TDateTime(1970, EJanuary, 0, 0, 0, 0, 0)); TTimeIntervalSeconds tmp_sec; valid_period.Start().SecondsFrom(base_time, tmp_sec); ci->validity.start.sec = tmp_sec.Int(); valid_period.Finish().SecondsFrom(base_time, tmp_sec); ci->validity.end.sec = tmp_sec.Int(); /* Deinit */ delete [] tmp_buf; }
void CStatboard::RenderScoreboard(float x, float y, float w, int Team, const char *pTitle) { //float ystart = y; float h = 750.0f; Graphics()->BlendNormal(); Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(0,0,0,0.5f); if(Team!=-1) RenderTools()->DrawRoundRect(x-10.f, y-10.f, w+200.0f, h, 17.0f); if(Team==-1) RenderTools()->DrawRoundRect(x-10.f, y-10.f, w, 200.0f, 17.0f); Graphics()->QuadsEnd(); // render title if(!pTitle) { if(m_pClient->m_Snap.m_pGameobj->m_GameOver) pTitle = Localize("Game over"); else pTitle = Localize("Score board"); } float tw = TextRender()->TextWidth(0, 48, pTitle, -1); if(Team == -1) { //TextRender()->Text(0, x+w/2-tw/2, y, 48, pTitle, -1); } else { TextRender()->Text(0, x+10, y, 48, pTitle, -1); if(m_pClient->m_Snap.m_pGameobj) { char aaBuf[128]; int Score = Team ? m_pClient->m_Snap.m_pGameobj->m_TeamscoreBlue : m_pClient->m_Snap.m_pGameobj->m_TeamscoreRed; str_format(aaBuf, sizeof(aaBuf), "%d", Score); tw = TextRender()->TextWidth(0, 48, aaBuf, -1); TextRender()->Text(0, x+w-tw-30, y, 48, aaBuf, -1); } } if(Team != -1) y += 54.0f; // find players const CNetObj_PlayerInfo *paPlayers[MAX_CLIENTS] = {0}; int NumPlayers = 0; for(int i = 0; i < Client()->SnapNumItems(IClient::SNAP_CURRENT); i++) { IClient::CSnapItem Item; const void *pData = Client()->SnapGetItem(IClient::SNAP_CURRENT, i, &Item); if(Item.m_Type == NETOBJTYPE_PLAYERINFO) { const CNetObj_PlayerInfo *pInfo = (const CNetObj_PlayerInfo *)pData; if(pInfo->m_Team == Team) { paPlayers[NumPlayers] = pInfo; if(++NumPlayers == MAX_CLIENTS) break; } } } // sort players for(int k = 0; k < NumPlayers-1; k++) // ffs, bubblesort { for(int i = 0; i < NumPlayers-k-1; i++) { if(paPlayers[i]->m_Score < paPlayers[i+1]->m_Score) { const CNetObj_PlayerInfo *pTmp = paPlayers[i]; paPlayers[i] = paPlayers[i+1]; paPlayers[i+1] = pTmp; } } } // render headlines /*TextRender()->Text(0, x+10, y, 24.0f, Localize("Score"), -1); TextRender()->Text(0, x+125, y, 24.0f, Localize("Name"), -1); TextRender()->Text(0, x+w-70, y, 24.0f, Localize("Ping"), -1);*/ if(Team == -1){ // Don't render Headlines } if(Team != -1){ TextRender()->Text(0, x+20, y, 24.0f, "Score", -1); TextRender()->Text(0, x+100, y, 24.0f, "Ping", -1); TextRender()->Text(0, x+170, y, 24.0f, "Time", -1); TextRender()->Text(0, x+250, y, 24.0f, "ID", -1); TextRender()->Text(0, x+300, y, 24.0f, "FPM", -1); TextRender()->Text(0, x+370, y, 24.0f, "Ratio", -1); TextRender()->Text(0, x+450, y, 24.0f, "Flags", -1); TextRender()->Text(0, x+w-80, y, 24.0f, "Name", -1);} if(Team != -1) y += 29.0f; float FontSize = 35.0f; float LineHeight = 50.0f; float TeeSizeMod = 1.0f; float TeeOffset = 0.0f; if(Team == -1){ FontSize = 30.0f; LineHeight = 40.0f; TeeSizeMod = 0.5f; TeeOffset = -5.0f; } if(Team != -1){ FontSize = 35.0f; LineHeight = 50.0f; TeeSizeMod = 1.0f; } if(NumPlayers > 13) { if(Team != -1){ FontSize = 30.0f; LineHeight = 40.0f; TeeSizeMod = 0.8f; TeeOffset = -5.0f;} if(Team == -1){ FontSize = 30.0f; LineHeight = 40.0f; TeeSizeMod = 0.5f; TeeOffset = -5.0f; } } // render player scores for(int i = 0; i < NumPlayers; i++) { const CNetObj_PlayerInfo *pInfo = paPlayers[i]; // make sure that we render the correct team char aaBuf[128]; if(!m_pClient->m_Snap.m_Spectate){ if(pInfo->m_Local) { Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(1,1,1,0.25f); //RenderTools()->DrawRoundRect(x, y, w-20, LineHeight*0.95f, 17.0f); default rect if(Team != -1) RenderTools()->DrawRoundRect(x, y, w+190.0f, LineHeight*0.95f, 17.0f); if(Team == -1) RenderTools()->DrawRoundRect(x, y, w-20, LineHeight*0.95f, 17.0f); Graphics()->QuadsEnd(); // background so it's easy to find the local player } } else{ if(pInfo->m_ClientId == m_pClient->spectate_cid && !m_pClient->freeview){ Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(1,1,1,0.25f); RenderTools()->DrawRoundRect(x, y, w+190, LineHeight*0.95f, 17.0f); Graphics()->QuadsEnd(); } } str_format(aaBuf, sizeof(aaBuf), "%4d", pInfo->m_Score); TextRender()->Text(0, x+60-TextRender()->TextWidth(0, FontSize,aaBuf,-1), y, FontSize, aaBuf, -1); /** NAME // spec **/ if(Team == -1) TextRender()->Text(0, x+128, y, FontSize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1); //TextRender()->Text(0, x+128, y, FontSize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1); default name render str_format(aaBuf, sizeof(aaBuf), "%4d", pInfo->m_Latency); float tw = TextRender()->TextWidth(0, FontSize, aaBuf, -1); /** NAME // nonpec **/ if(Team != -1) TextRender()->Text(0, x+w-tw-55, y, FontSize, m_pClient->m_aClients[pInfo->m_ClientId].m_aName, -1); if(Team != -1){ TextRender()->Text(0, x+90, y, FontSize, aaBuf, -1); } if(Team == -1){ TextRender()->Text(0, x+w-tw-20, y-10, FontSize-11.0f, aaBuf, -1); } if(Team == -1){ TextRender()->TextColor(0,1,0,1.0f); /** TIME spec **/ //str_format(aBuf, sizeof(aBuf), "%i:%02i", ((-1*(gameclient.clients[info->cid].time-base_time())/60)), ((-1*(gameclient.clients[info->cid].time-base_time()))%60)); str_format(aaBuf, sizeof(aaBuf), "%i:%02i", ((-1*(m_pClient->m_aClients[pInfo->m_ClientId].m_JoinTime-base_time())/60)), ((-1*(m_pClient->m_aClients[pInfo->m_ClientId].m_JoinTime-base_time()))%60)); TextRender()->Text(0, x+w-tw-20, y+10, FontSize-11.0f, aaBuf, -1); TextRender()->TextColor(1,1,1,1.0f); } if(Team != -1){ /** TIME nonspec **/ str_format(aaBuf, sizeof(aaBuf), "%i:%02i", ((-1*(m_pClient->m_aClients[pInfo->m_ClientId].m_JoinTime-base_time())/60)), ((-1*(m_pClient->m_aClients[pInfo->m_ClientId].m_JoinTime-base_time()))%60)); TextRender()->Text(0, x+175, y, FontSize, aaBuf, -1); } if(Team != -1){ /** ID nonspec **/ str_format(aaBuf, sizeof(aaBuf), "%i", pInfo->m_ClientId); TextRender()->Text(0, x+255, y, FontSize, aaBuf, -1); // TODO: FPM, Ratio, Flags TextRender()->Text(0, x+255, y, FontSize, aaBuf, -1); str_format(aaBuf, sizeof(aaBuf), "%.1f", (float)(m_pClient->m_aClients[pInfo->m_ClientId].m_Frags*60)/((float)(base_time()-m_pClient->m_aClients[pInfo->m_ClientId].m_JoinTime))); TextRender()->Text(0, x+300, y, FontSize, aaBuf, -1); if(m_pClient->m_aClients[pInfo->m_ClientId].m_Deaths != 0){ str_format(aaBuf, sizeof(aaBuf), "%.1f", (float)(m_pClient->m_aClients[pInfo->m_ClientId].m_Frags/m_pClient->m_aClients[pInfo->m_ClientId].m_Deaths));} if(m_pClient->m_aClients[pInfo->m_ClientId].m_Deaths == 0){ str_format(aaBuf, sizeof(aaBuf), "---"); } TextRender()->Text(0, x+370, y, FontSize, aaBuf, -1); str_format(aaBuf, sizeof(aaBuf), "%i", m_pClient->m_aClients[pInfo->m_ClientId].m_FlagCaptures); TextRender()->Text(0, x+450, y, FontSize, aaBuf, -1); } // render avatar if((m_pClient->m_Snap.m_paFlags[0] && m_pClient->m_Snap.m_paFlags[0]->m_CarriedBy == pInfo->m_ClientId) || (m_pClient->m_Snap.m_paFlags[1] && m_pClient->m_Snap.m_paFlags[1]->m_CarriedBy == pInfo->m_ClientId)) { Graphics()->BlendNormal(); if(g_Config.m_tc_colored_flags) Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME_GRAY].m_Id); else Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); Graphics()->QuadsBegin(); if(pInfo->m_Team == 0) RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); if(g_Config.m_tc_colored_flags) { vec3 col = TeecompUtils::getTeamColor(1-pInfo->m_Team, m_pClient->m_Snap.m_paPlayerInfos[m_pClient->m_Snap.m_LocalCid]->m_Team, g_Config.m_tc_colored_tees_team1, g_Config.m_tc_colored_tees_team2, g_Config.m_tc_colored_tees_method); Graphics()->SetColor(col.r, col.g, col.b, 1.0f); } float size = 64.0f; IGraphics::CQuadItem QuadItem(x-25, y-15, size/2, size); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); } CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientId].m_RenderInfo; TeeInfo.m_Size *= TeeSizeMod; RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1,0), vec2(x+10, y+28+TeeOffset)); y += LineHeight; } }