/****************************************************************************** * 函数名称 : RemovePage * 函数描述 : 移除一个page * 输入 : * 输出 : * 返回值 : 0 - 成功!0 -失败 * 作者 : jin.shaohua *******************************************************************************/ int TMdbTableCtrl::RemovePage(TMdbPage * pPageToRemove,int & iHeadPageId) { TADD_FUNC("Start.iHeadPageId=[%d],page:pre[%d] next[%d]",iHeadPageId,pPageToRemove->m_iPrePageID,pPageToRemove->m_iNextPageID); int iRet = 0; CHECK_OBJ(pPageToRemove); if(pPageToRemove->m_iPrePageID <= 0) {//头节点 iHeadPageId = pPageToRemove->m_iNextPageID; } else {//非头节点 TMdbPage * pPrePage = m_tTSCtrl.GetPage(pPageToRemove->m_iPrePageID); CHECK_OBJ(pPrePage); pPrePage->m_iNextPageID = pPageToRemove->m_iNextPageID; } if(pPageToRemove->m_iNextPageID > 0) {//非尾节点 TMdbPage * pNextPage = m_tTSCtrl.GetPage(pPageToRemove->m_iNextPageID); CHECK_OBJ(pNextPage); pNextPage->m_iPrePageID = pPageToRemove->m_iPrePageID; } //清理该page pPageToRemove->m_iPrePageID = -1; pPageToRemove->m_iNextPageID = -1; TADD_FUNC("Finish."); return iRet; }
obj_t make_cont3(cont_proc_t proc, obj_t cont, obj_t env) { CHECK_OBJ(cont); CHECK_OBJ(env); if (!cont3_ops.mo_super) mem_mixvec_create_ops(&cont3_ops, L"continuation", 1, 2); return make_mixvec_1_2(&cont3_ops, (word_t)proc, cont, env); }
obj_t make_cont4(cont_proc_t proc, obj_t cont, obj_t env, obj_t arg) { CHECK_OBJ(cont); CHECK_OBJ(env); CHECK_OBJ(arg); if (!cont4_ops.mo_super) mem_mixvec_create_ops(&cont4_ops, L"continuation", 1, 3); return make_mixvec_1_3(&cont4_ops, (word_t)proc, cont, env, arg); }
obj_t make_procedure(obj_t body, obj_t arglist, obj_t env) { CHECK_OBJ(body); CHECK_OBJ(arglist); CHECK_OBJ(env); return make_proc(PF_ARGS_EVALUATED, body, make_uninitialized(), arglist, env); }
obj_t make_special_form_procedure(obj_t body, obj_t env) { CHECK_OBJ(body); CHECK_OBJ(env); proc_flags_t flags = 0; return make_proc(flags, body, make_uninitialized(), make_uninitialized(), env); }
obj_t make_cont6(cont_proc_t proc, obj_t cont, obj_t env, obj_t arg1, obj_t arg2, obj_t arg3) { CHECK_OBJ(cont); CHECK_OBJ(env); CHECK_OBJ(arg1); CHECK_OBJ(arg2); CHECK_OBJ(arg3); if (!cont6_ops.mo_super) mem_mixvec_create_ops(&cont6_ops, L"continuation", 1, 5); return make_mixvec_1_5(&cont6_ops, (word_t)proc, cont, env, arg1, arg2, arg3); }
/****************************************************************************** * 函数名称 : Init * 函数描述 : 初始化 * 输入 : * 输出 : * 返回值 : 0 - 成功!0 -失败 * 作者 : jin.shaohua *******************************************************************************/ int TMdbTableCtrl::Init(const char * sDsn,const char * sTablename) { int iRet = 0; CHECK_OBJ(sDsn); m_pShmDsn = TMdbShmMgr::GetShmDSN(sDsn); CHECK_OBJ(m_pShmDsn); if(NULL != sTablename) { m_pTable = m_pShmDsn->GetTable(sTablename); CHECK_OBJ(m_pTable); CHECK_RET(m_tTSCtrl.Init(sDsn,m_pTable->m_sTablespaceName),"init failed."); } return iRet; }
ER ista_ovr(ID tskid, OVRTIM ovrtim) { TCB *p_tcb; ER ercd; LOG_ISTA_OVR_ENTER(tskid, ovrtim); CHECK_INTCTX_UNL(); CHECK_OBJ(ovrinib.ovrhdr != NULL); CHECK_TSKID(tskid); CHECK_PAR(0U < ovrtim && ovrtim <= TMAX_OVRTIM); p_tcb = get_tcb(tskid); i_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else { p_tcb->leftotm = ovrtim; ercd = E_OK; } i_unlock_cpu(); error_exit: LOG_ISTA_OVR_LEAVE(ercd); return(ercd); }
ER stp_ovr(ID tskid) { TCB *p_tcb; ER ercd; LOG_STP_OVR_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_OBJ(ovrinib.ovrhdr != NULL); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->leftotm > 0U) { if (p_tcb == p_runtsk) { (void) target_ovrtimer_stop(); ovrtimer_flag = false; } p_tcb->leftotm = 0U; } ercd = E_OK; t_unlock_cpu(); error_exit: LOG_STP_OVR_LEAVE(ercd); return(ercd); }
ER sta_ovr(ID tskid, OVRTIM ovrtim) { TCB *p_tcb; ER ercd; LOG_STA_OVR_ENTER(tskid, ovrtim); CHECK_TSKCTX_UNL(); CHECK_OBJ(ovrinib.ovrhdr != NULL); CHECK_TSKID_SELF(tskid); CHECK_PAR(0U < ovrtim && ovrtim <= TMAX_OVRTIM); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb == p_runtsk) { if (p_tcb->leftotm > 0U) { (void) target_ovrtimer_stop(); } target_ovrtimer_start(ovrtim); ovrtimer_flag = true; } p_tcb->leftotm = ovrtim; ercd = E_OK; t_unlock_cpu(); error_exit: LOG_STA_OVR_LEAVE(ercd); return(ercd); }
obj_t symbol_name(obj_t symbol) { CHECK_OBJ(symbol); CHECK(is_symbol(symbol), "must be symbol", symbol); obj_t name = fixvec1_get_ptr(symbol, 0); if (is_uninitialized(name)) { size_t max_len = 12; ssize_t name_len; wchar_t name_buf[max_len]; while (true) { name_len = swprintf(name_buf, max_len, L"g%04d", ++gen_name_counter); assert(0 <= name_len && name_len < max_len); name = make_string_from_chars(name_buf, name_len); if (!is_null(find_symbol(name))) continue; /* with lock */ { /* verify symbol still absent */ fixvec1_set_ptr(symbol, 0, name); all_symbols_list = make_pair(symbol, all_symbols_list); } break; } } return name; }
unsigned vdir_remove_backend(struct vdir *vd, VCL_BACKEND be) { unsigned u, n; CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); if (be == NULL) return (vd->n_backend); CHECK_OBJ(be, DIRECTOR_MAGIC); vdir_wrlock(vd); for (u = 0; u < vd->n_backend; u++) if (vd->backend[u] == be) break; if (u == vd->n_backend) { vdir_unlock(vd); return (vd->n_backend); } vd->total_weight -= vd->weight[u]; n = (vd->n_backend - u) - 1; memmove(&vd->backend[u], &vd->backend[u+1], n * sizeof(vd->backend[0])); memmove(&vd->weight[u], &vd->weight[u+1], n * sizeof(vd->weight[0])); vd->n_backend--; vdir_unlock(vd); return (vd->n_backend); }
ER istp_ovr(ID tskid) { TCB *p_tcb; ER ercd; LOG_ISTP_OVR_ENTER(tskid); CHECK_INTCTX_UNL(); CHECK_OBJ(ovrinib.ovrhdr != NULL); CHECK_TSKID(tskid); p_tcb = get_tcb(tskid); i_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else { p_tcb->leftotm = 0U; ercd = E_OK; } i_unlock_cpu(); error_exit: LOG_ISTP_OVR_LEAVE(ercd); return(ercd); }
ER stp_ovr(ID tskid) { TCB *p_tcb; ER ercd; LOG_STP_OVR_ENTER(tskid); CHECK_TSKCTX_UNL(); CHECK_OBJ(ovrinib.ovrhdr != NULL); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->p_tinib->tskatr == TA_NOEXS) { ercd = E_NOEXS; } else if (VIOLATE_ACPTN(p_tcb->p_tinib->acvct.acptn2)) { ercd = E_OACV; } else { if (p_tcb->leftotm > 0U) { if (p_tcb == p_runtsk) { (void) target_ovrtimer_stop(); ovrtimer_flag = false; } p_tcb->leftotm = 0U; } ercd = E_OK; } t_unlock_cpu(); error_exit: LOG_STP_OVR_LEAVE(ercd); return(ercd); }
void vdir_remove_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, unsigned *cur) { unsigned u, n; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); if (be == NULL) { VRT_fail(ctx, "%s: NULL backend cannot be removed", VRT_BACKEND_string(vd->dir)); return; } CHECK_OBJ(be, DIRECTOR_MAGIC); vdir_wrlock(vd); for (u = 0; u < vd->n_backend; u++) if (vd->backend[u] == be) break; if (u == vd->n_backend) { vdir_unlock(vd); return; } n = (vd->n_backend - u) - 1; memmove(&vd->backend[u], &vd->backend[u+1], n * sizeof(vd->backend[0])); memmove(&vd->weight[u], &vd->weight[u+1], n * sizeof(vd->weight[0])); vd->n_backend--; if (cur) { assert(*cur <= vd->n_backend); if (u < *cur) (*cur)--; else if (*cur == vd->n_backend) *cur = 0; } vdir_unlock(vd); }
ER ref_ovr(ID tskid, T_ROVR *pk_rovr) { TCB *p_tcb; ER ercd; LOG_REF_OVR_ENTER(tskid, pk_rovr); CHECK_TSKCTX_UNL(); CHECK_OBJ(ovrinib.ovrhdr != NULL); CHECK_TSKID_SELF(tskid); p_tcb = get_tcb_self(tskid); t_lock_cpu(); if (p_tcb->leftotm > 0U) { pk_rovr->ovrstat = TOVR_STA; if (p_tcb == p_runtsk) { pk_rovr->leftotm = target_ovrtimer_get_current(); } else { pk_rovr->leftotm = p_tcb->leftotm; } } else { pk_rovr->ovrstat = TOVR_STP; } ercd = E_OK; t_unlock_cpu(); error_exit: LOG_REF_OVR_LEAVE(ercd, pk_rovr); return(ercd); }
/****************************************************************************** * 函数名称 : GetFreePage * 函数描述 : 获取自由页 * 输入 : * 输出 : * 返回值 : 0 - 成功!0 -失败 * 作者 : jin.shaohua *******************************************************************************/ int TMdbTableCtrl::GetFreePage(TMdbPage * & pFreePage) { TADD_FUNC("Start,"); int iRet = 0; CHECK_OBJ(m_pTable); pFreePage = NULL; //TODO:加锁 int iFreePageID = m_pTable->m_iFreePageID; TADD_DETAIL("iFreePageID=[%d]",iFreePageID); do{ if(iFreePageID > 0) {//有自由页 if((pFreePage = m_tTSCtrl.GetPage(iFreePageID)) == NULL) { CHECK_RET_BREAK(ERR_OS_NO_MEMROY,"GetPage[%d] failed",iFreePageID); } } else {//没有自由页了 TADD_DETAIL("no free pages"); CHECK_RET_BREAK(m_tTSCtrl.GetEmptyPage(pFreePage),"GetEmptyPage failed"); if(NULL != pFreePage) { CHECK_RET_BREAK(AddPageToTop(pFreePage,m_pTable->m_iFreePageID),"AddPageToTop failed."); SAFESTRCPY(pFreePage->m_sState,sizeof(pFreePage->m_sState),"free");//修改状态 pFreePage->m_iRecordSize = 0;//TODO:从表空间获取页的时候才确定这个页中记录大小 m_pTable->m_iFreePages ++; pFreePage->m_iNextPageID = m_pTable->m_iTablePageID; m_pTable->m_iTablePageID = pFreePage->m_iPageID; } } }while(0); return iRet; }
/****************************************************************************** * 函数名称 : CreateTable * 函数描述 : 创建表 * 输入 : * 输出 : * 返回值 : 0 - 成功!0 -失败 * 作者 : jin.shaohua *******************************************************************************/ int TMdbTableCtrl::CreateTable(TMdbTable * pTable) { int iRet = 0; TADD_FUNC("Start."); CHECK_OBJ(m_pShmDsn);CHECK_OBJ(pTable); if(m_pShmDsn->GetTable(pTable->m_sTableName) != NULL) {//已存在 CHECK_RET(ERR_DB_TABLE_IS_EXIST,"table=[%s]",pTable->m_sTableName); } CHECK_RET(m_pShmDsn->AddTable(pTable),"add table[%s] failed.",pTable->m_sTableName); //TODO:寻找适配的表空间 //TODO:向表空间申请预留数据 TADD_FUNC("Finish"); return iRet; }
ER _start_i2c_transaction(int port, uint_t addr, const uint8_t *writebuf, uint_t writelen, uint_t readlen, ID cdmid) { if(!PROBE_MEM_READ_SIZE(writebuf, writelen)) return E_MACV; ER ercd; CHECK_SENSOR_PORT(port); CHECK_PAR(writelen <= MAX_DEVICE_DATALENGTH); CHECK_PAR(readlen <= MAX_DEVICE_DATALENGTH); struct IIC_data_package *datapkg = &(IicCtrl.data_package[port]); CHECK_OBJ(datapkg->transfer_state == TRANSFER_IDLE); datapkg->addr = addr; memcpy(datapkg->data, writebuf, writelen); datapkg->write_length = writelen; datapkg->read_length = readlen; datapkg->port = port; datapkg->nacked = 0; datapkg->clock_state = 1; datapkg->transfer_state = TRANSFER_START; iic_fiq_start_transfer(50,1); // TODO: check this, use cyclic instead ercd = E_OK; error_exit: return(ercd); }
obj_t vector_ref(obj_t obj, size_t index) { CHECK_OBJ(obj); CHECK(is_vector(obj), "must be vector", obj); vector_obj_t *vec = (vector_obj_t *)obj; CHECK(index < vec->v_size, "index out of range", obj, make_fixnum(index)); return *elem_addr(vec, index); }
obj_t make_C_procedure(C_procedure_t code, obj_t name, interval_t arg_range, obj_t env) { CHECK_OBJ(env); proc_flags_t flags = PF_COMPILED_C | PF_ARGS_EVALUATED; return make_proc(flags, (obj_t)code, name, make_fixnum(arg_range), env); }
void vector_set_nc(obj_t obj, size_t index, obj_t elem) { CHECK_OBJ(obj); assert(is_vector(obj)); vector_obj_t *vec = (vector_obj_t *)obj; assert(index < vec->v_size); MUTATE(obj); *elem_addr(vec, index) = elem; }
void VRE_free(vre_t **vv) { vre_t *v = *vv; *vv = NULL; CHECK_OBJ(v, VRE_MAGIC); pcre_free(v->re); FREE_OBJ(v); }
void vector_set(obj_t obj, size_t index, obj_t elem) { CHECK_OBJ(obj); CHECK(is_vector(obj), "must be vector", obj); vector_obj_t *vec = (vector_obj_t *)obj; //XXX CHECK(is_mutable(obj), "must be mutable", pair); CHECK(index < vec->v_size, "index out of range", obj, make_fixnum(index)); MUTATE(obj); *elem_addr(vec, index) = elem; }
int CheckParam(const char* pDsn,int iCounts, int iPos) { int iRet = 0; CHECK_OBJ(pDsn); TMdbConfig * pConfig = TMdbConfigMgr::GetMdbConfig(pDsn); CHECK_OBJ(pConfig); if(iCounts != pConfig->GetDSN()->iOraRepCounts) { TADD_ERROR(ERR_APP_INVALID_PARAM,"Process startup parameter[%d] illegal,it must be %d.",\ iCounts,pConfig->GetDSN()->iOraRepCounts); return ERR_APP_INVALID_PARAM; } if(iPos < -1 || iPos > iCounts -1) { TADD_ERROR(ERR_APP_INVALID_PARAM,"Process startup parameter[%d] illegal,it must be -1~%d.",\ iPos,iCounts -1); return ERR_APP_INVALID_PARAM; } return iRet; }
obj_t make_vector_fill(size_t size, obj_t fill) { size_t i; CHECK_OBJ(fill); obj_t obj = make_vector_uninitialized(size); vector_obj_t *vec = (vector_obj_t *)obj; for (i = 0; i < size; i++) *elem_addr(vec, i) = fill; return obj; }
int NS(SendEND_AND_CALLBACK) (NS_ARGS) { SETUP_mqctx MQ_STR token; Tcl_Obj *callback; CHECK_C(token) CHECK_OBJ(callback) CHECK_NOARGS Tcl_IncrRefCount(callback); ErrorMqToTclWithCheck(MqSendEND_AND_CALLBACK(mqctx, token, NS(ProcCall), callback, NS(ProcFree))); RETURN_TCL }
int TMdbOnlineRepQueue::Init(TMdbOnlineRepMemQueue * pOnlineRepMemQueue,TMdbDSN * pDsn, const bool bWriteErrorData) { int iRet = 0; if(m_pszRecord == NULL) { m_pszRecord = new char[MAX_VALUE_LEN]; CHECK_OBJ(m_pszRecord); memset(m_pszRecord,0,MAX_VALUE_LEN); } if(m_pszErrorRecord == NULL) { m_pszErrorRecord = new char[MAX_VALUE_LEN]; CHECK_OBJ(m_pszErrorRecord); memset(m_pszErrorRecord,0,MAX_VALUE_LEN); } m_bWriteErrorData = bWriteErrorData; m_pOnlineRepQueueShm = pOnlineRepMemQueue; m_pDsn = pDsn; CHECK_OBJ(m_pOnlineRepQueueShm); CHECK_OBJ(m_pDsn); //对于REP和ORACLE同步区需要记录异常文件 char sErrorLogPath[MAX_PATH_NAME_LEN] = {0}; memset(sErrorLogPath, 0, sizeof(sErrorLogPath)); char sDsnName[MAX_NAME_LEN] = {0}; SAFESTRCPY(sDsnName, sizeof(sDsnName), m_pDsn->sName); TMdbNtcStrFunc::ToLower(sDsnName); #ifdef WIN32 snprintf(sErrorLogPath, sizeof(sErrorLogPath), "%s\\log\\%s\\", getenv("QuickMDB_HOME"), sDsnName); #else snprintf(sErrorLogPath, sizeof(sErrorLogPath), "%s/log/%s/", getenv("QuickMDB_HOME"), sDsnName); #endif if(!TMdbNtcDirOper::IsExist(sErrorLogPath)) { TMdbNtcDirOper::MakeFullDir(sErrorLogPath); } snprintf(m_sFileName,sizeof(m_sFileName),"%sRep_Error_Info_%d.log",\ sErrorLogPath,TMdbOS::GetPID()); TADD_DETAIL("ERROR_LOG=[%s].",m_sFileName); return iRet; }
xyzzy_dyn_uds__fini(struct xyzzy_debug_dyn_uds **udsp) { struct xyzzy_debug_dyn_uds *uds; if (udsp == NULL || *udsp == NULL) return; CHECK_OBJ(*udsp, VMOD_DEBUG_UDS_MAGIC); uds = *udsp; free(uds->vcl_name); AZ(pthread_mutex_destroy(&uds->mtx)); FREE_OBJ(uds); *udsp = NULL; }
ER_UINT acre_isr(const T_CISR *pk_cisr) { ISRCB *p_isrcb; ISRINIB *p_isrinib; QUEUE *p_isr_queue; ER ercd; LOG_ACRE_ISR_ENTER(pk_cisr); CHECK_TSKCTX_UNL(); CHECK_MACV_READ(pk_cisr, T_CISR); CHECK_RSATR(pk_cisr->isratr, TARGET_ISRATR|TA_DOMMASK); CHECK_ATRDOMID_KERNEL(get_atrdomid(pk_cisr->isratr)); CHECK_INTNO_CREISR(pk_cisr->intno); CHECK_ALIGN_FUNC(pk_cisr->isr); CHECK_NONNULL_FUNC(pk_cisr->isr); CHECK_ISRPRI(pk_cisr->isrpri); CHECK_ACPTN(sysstat_acvct.acptn3); p_isr_queue = search_isr_queue(pk_cisr->intno); CHECK_OBJ(p_isr_queue != NULL); t_lock_cpu(); if (tnum_isr == 0 || queue_empty(&free_isrcb)) { ercd = E_NOID; } else { p_isrcb = ((ISRCB *) queue_delete_next(&free_isrcb)); p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib); p_isrinib->isratr = pk_cisr->isratr; p_isrinib->exinf = pk_cisr->exinf; p_isrinib->intno = pk_cisr->intno; p_isrinib->p_isr_queue = p_isr_queue; p_isrinib->isr = pk_cisr->isr; p_isrinib->isrpri = pk_cisr->isrpri; p_isrinib->acvct.acptn1 = TACP_KERNEL; p_isrinib->acvct.acptn2 = TACP_KERNEL; p_isrinib->acvct.acptn3 = TACP_KERNEL | rundom; p_isrinib->acvct.acptn4 = TACP_KERNEL; enqueue_isr(p_isr_queue, p_isrcb); ercd = ISRID(p_isrcb); } t_unlock_cpu(); error_exit: LOG_ACRE_ISR_LEAVE(ercd); return(ercd); }