ini_sContext *ini_CreateContext ( pwr_tStatus *status ) { ini_sContext *cp; pwr_dStatus(sts, status, INI__SUCCESS); cp = calloc(1, sizeof(*cp)); if (cp == NULL) return NULL; cp->nid_t = tree_CreateTable(sts, sizeof(pwr_tNodeId), offsetof(qini_sNode, nid), sizeof(qini_sNode), 10, tree_Comp_nid); cp->proc_t = tree_CreateTable(sts, sizeof(((ini_sProc *)0)->id), offsetof(ini_sProc, id), sizeof(ini_sProc), 10, tree_Comp_strncmp); lst_Init(NULL, &cp->proc_lh, NULL); co_GetOwnFormat(&cp->format); return cp; }
/*_* @aref cyclesup CycleSup */ lst_sEntry * csup_Init ( pwr_tStatus *status, pwr_tObjid tid, float scanTime ) { lst_sEntry *lh; pwr_tObjid cid; pwr_tObjid pid; csup_sObject *cp; int tv_sec; pwr_tFloat32 max_delay; pwr_dStatus(sts, status, CSUP__SUCCESS); lh = calloc(1, sizeof(*lh)); if (lh == NULL) pwr_Return(NULL, sts, CSUP__INSVIRMEM); lst_Init(NULL, lh, NULL); for ( *sts = gdh_GetClassList(pwr_cClass_CycleSup, &cid); ODD(*sts); *sts = gdh_GetNextObject(cid, &cid) ) { cp = calloc(1, sizeof(*cp)); cp->aref.Objid = cid; *sts = gdh_DLRefObjectInfoAttrref(&cp->aref, (void**)&cp->o, &cp->dlid); if (EVEN(*sts)) goto error; if ( ODD(gdh_GetParent( cid, &pid)) && cdh_ObjidIsEqual( pid, tid)) cp->is_owner = 1; lst_InsertSucc(NULL, lh, &cp->le, cp); max_delay = cp->o->MaxDelay; cp->o->DelayLimit.tv_sec = tv_sec = (int)max_delay; cp->o->DelayLimit.tv_nsec = (int)((max_delay - (float)tv_sec + FLT_EPSILON) * 1.0e9); // printf("maxdelay: %f, tv_sec: %d, tv_nsec: %d\n", cp->o->MaxDelay, cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec); errh_Info("maxdelay: %f, tv_sec: %d, tv_nsec: %d", cp->o->MaxDelay, cp->o->DelayLimit.tv_sec, cp->o->DelayLimit.tv_nsec); } if (lst_IsEmpty(NULL, lh)) goto error; return lh; error: csup_Exit(NULL, lh); return NULL; }
que_sQue * que_Create ( pwr_tStatus *status, que_sQue *qp ) { que_sQue *lqp = NULL; pwr_dStatus(sts, status, QUE__SUCCESS); if (qp == NULL) { lqp = qp = (que_sQue *) calloc(1, sizeof(*qp)); if (lqp == NULL) pwr_Return(lqp, sts, QUE__INSVIRMEM); } thread_CondInit(&qp->cond); thread_MutexInit(&qp->mutex); lst_Init(NULL, &qp->lh, NULL); return qp; }