STATUS semQInit( Q_HEAD *pQHead, int options ) { STATUS status; /* Initilaize queue according to options */ switch (options & SEM_Q_MASK) { case SEM_Q_FIFO: qInit(pQHead, qFifoClassId, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); status = OK; break; case SEM_Q_PRIORITY: qInit(pQHead, qPrioClassId, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); status = OK; break; default: errnoSet(S_semLib_INVALID_Q_TYPE); status = ERROR; } return status; }
int my_usrInit(int startType) { sysHwInit0(); bzero(&bss_begin, (&bss_begin - &bss_end)); sysStartType = startType; intVecBaseSet(0); cacheLibInit(1, 2); excVecInit(); sysHwInit(); cacheEnable(0); cacheEnable(1); classLibInit(); taskLibInit(); qInit(&readyQHead, qPriBMapClassId, &readyQBMap, 0x100); qInit(&activeQHead, qFifoClassId); qInit(&tickQHead, qPriListClassId); workQInit(); /* sysMemTop() - returns the LogBuffer address, the buffer is 1.5mb */ kernelInit(my_usrRoot, 0x4000, &bss_end, sysMemTop(), 0xC00, 0); return 0; }
STATUS msgQInit(FAST MSG_Q* pMsgQ, int maxMsgs, int maxMsgLength, int options, void* pMsgPool) { FAST int nodeSize = MSG_NODE_SIZE(maxMsgLength); FAST int ix; FAST QUEUE_ID msgQType; if ((!msgQLibInstalled) && (msgQLibInit () != OK)) { return (ERROR); /* package init problem */ } memset((char*)pMsgQ, 0, sizeof(*pMsgQ)); switch(options & MSG_Q_TYPE_MASK) { case MSG_Q_FIFO: msgQType = Q_FIFO; break; case MSG_Q_PRIORITY: msgQType = Q_PRI_LIST; break; default: msgQType = Q_FIFO; break; } if((qInit(&pMsgQ->msgQ, qJobClassId, msgQType, 2,3,4,5) != OK) || (qInit(&pMsgQ->freeQ, qJobClassId, msgQType, 2,3,4,5) != OK)) { return (ERROR); } for(ix = 0; ix < maxMsgs; ix++) { qJobPut(pMsgQ, &pMsgQ->freeQ, (Q_JOB_NODE*)pMsgPool, Q_JOB_PRI_DONT_CARE); pMsgPool = (void*)((char*)pMsgPool + nodeSize); } /*printf("pMsgQ->freeQ.first:0x%x\n", pMsgQ->freeQ.first);*/ pMsgQ->options = options; pMsgQ->maxMsgs = maxMsgs; pMsgQ->maxMsgLength = maxMsgLength; objCoreInit(&pMsgQ->objCore, msgQClassId); return (OK); }
Q_HEAD *qCreate ( Q_CLASS *pQClass, /* pointer to queue class */ ... /* optional arguments to create routine */ ) { va_list pArg; /* traverses argument list */ Q_HEAD *pQHead; /* pointer to queue head */ int ix; /* handy index */ int arg[MAX_ARGS]; /* indigenous variables */ if (Q_CLASS_VERIFY (pQClass) != OK) { errno = S_qLib_Q_CLASS_ID_ERROR; return (NULL); } va_start (pArg, pQClass); for (ix = 0; ix < MAX_ARGS; ++ix) arg[ix] = va_arg (pArg, int); /* put args in local vars */ va_end (pArg); pQHead = (Q_HEAD *) malloc (sizeof (Q_HEAD)); if ((pQHead != NULL) && qInit (pQHead, pQClass, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7], arg[8], arg[9]) != OK) { /* XXX MAX_ARGS */ free ((char *) pQHead); return (NULL); } return (pQHead); }
STATUS semQInit(SEMAPHORE* pSemaphore, int options) { STATUS status = OK; switch(options & SEM_Q_MASK) { case SEM_Q_FIFO: qInit(&pSemaphore->qHead, Q_FIFO, 1,2,3,4,5); break; case SEM_Q_PRI: qInit(&pSemaphore->qHead, Q_PRI_LIST, 1,2,3,4,5); break; default: status = ERROR; break; } return status; }
Q_HEAD* qCreate( Q_CLASS *pQClass, ... ) { va_list pArg; Q_HEAD *pQHead; int i; ARG arg[10]; /* Verify class */ if (Q_CLASS_VERIFY(pQClass) != OK) { pQHead = NULL; } else { /* Read args into array */ va_start(pArg, pQClass); for (i = 0; i < 10; i++) { arg[i] = va_arg(pArg, ARG); } va_end(pArg); /* Allocate buffer */ pQHead = malloc(sizeof(Q_HEAD)); if (pQHead != NULL) { /* Call initializer function below */ if (qInit( pQHead, pQClass, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7], arg[8], arg[9] ) != OK) { free(pQHead); pQHead = NULL; } } } return pQHead; }
LOCAL STATUS qMsgInit( Q_MSG_HEAD *pQHead, Q_CLASS_ID pendQType ) { STATUS status; pQHead->first = NULL; pQHead->last = NULL; pQHead->count = 0; if (qInit(&pQHead->pendQ, pendQType, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) != OK) { status = ERROR; } else { status = OK; } return status; }
void hcpInit() { host_rec *myrec; hcp = (HelloConfp)malloc(sizeof(HelloConf)); /* Hello Protocol Initialization */ time(&hcp->start_time); hcp->HPeriod = hello_interval; hcp->DeadInt = hello_interval * hello_dead_factor; hcp->nsm_list = listInit(); hcp->curmsg.pktp = NULL; hcp->curmsg.sa = malloc(sizeof(struct sockaddr_in)); hcp->hrecs = listInit(); myrec = (host_rec *)malloc(sizeof(host_rec)); myrec->host = GetIpAddr(hello_ifname); myrec->primary = htonl(0); Pthread_mutex_lock(&(host_dbrev.mutex)); myrec->prio.dbrev = htonl(host_dbrev.value); Pthread_mutex_unlock(&(host_dbrev.mutex)); myrec->prio.group = htons(hello_group); myrec->prio.self = htons(hello_priority); myrec->prio.start_time_c = htonl(~(hcp->start_time)); myrec->HPeriod = htonl(hello_interval); myrec->DeadInt = htonl(hello_interval*hello_dead_factor); listAddItem(hcp->hrecs, myrec); hcp->reg = Malloc(sizeof(default_reg)); hcp->state = HSM_STATE_DOWN; memcpy(hcp->reg, &default_reg, sizeof(default_reg)); NetFdsInit(&(hcp->nfs)); HelloCreateLocks(); hcp->lockid = 0; // LockGetLock(hcp_lock, 0, 0); hcp->pri_sa = NULL; // LockReleaseLock(hcp_lock); qInit(&hcp->eventq, HELLO_EVENT_SIZE, HELLO_EVENTQ_LEN); }
STATUS taskInit( TCB_ID tcbId, const char *name, unsigned priority, int options, char *pStackBase, unsigned stackSize, FUNCPTR func, ARG arg0, ARG arg1, ARG arg2, ARG arg3, ARG arg4, ARG arg5, ARG arg6, ARG arg7, ARG arg8, ARG arg9 ) { static unsigned new_id; STATUS status; int i; int len; char *taskName; ARG args[MAX_TASK_ARGS]; if (INT_RESTRICT() != OK) { errnoSet(S_intLib_NOT_ISR_CALLABLE); status = ERROR; } else { /* Check if task lib is installed */ if (taskLibInstalled != TRUE) { errnoSet(S_taskLib_NOT_INSTALLED); status = ERROR; } else { /* Copy args to array */ args[0] = arg0; args[1] = arg1; args[2] = arg2; args[3] = arg3; args[4] = arg4; args[5] = arg5; args[6] = arg6; args[7] = arg7; args[8] = arg8; args[9] = arg9; /* Task entry point */ tcbId->entry = func; /* Setup errno */ tcbId->errno = 0; /* Set unique id */ tcbId->id = new_id++; /* Set initial status as suspended */ tcbId->status = TASK_SUSPEND; tcbId->lockCount = 0; /* Zero swap mask */ tcbId->swapInMask = 0; tcbId->swapOutMask = 0; /* Name and options */ tcbId->priority = priority; tcbId->options = options; /* Round robin time slice */ tcbId->timeSlice = 0; /* Pending queue, used by semaphores */ tcbId->pPendQ = NULL; /* Zero unpend callback */ tcbId->objUnpendHandler = NULL; tcbId->pObj = NULL; tcbId->objInfo = 0; /* Initialize safety */ tcbId->safeCount = 0; qInit( &tcbId->safetyQ, qPrioClassId, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0, (ARG) 0); /* Setup error status and exit code */ tcbId->errorStatus = OK; tcbId->exitCode = 0; /* Task variables */ tcbId->pTaskVar = NULL; /* Exception info */ tcbId->pExcRegSet = NULL; tcbId->excInfo.valid = 0; /* Setup stack */ tcbId->pStackBase = pStackBase; tcbId->pStackLimit = tcbId->pStackBase + stackSize * _STACK_DIR; tcbId->pStackEnd = tcbId->pStackLimit; if ((options & TASK_OPTIONS_NO_STACK_FILL) == 0) { #if (_STACK_DIR == _STACK_GROWS_DOWN) memset(tcbId->pStackLimit, 0xee, stackSize); #else /* _STACK_GROWS_UP */ memset(tcbId->stackBase, 0xee, stackSize); #endif /* _STACK_DIR */ } /* Initialize standard file desriptors */ for (i = 0; i < 3; i++) { tcbId->taskStd[i] = i; tcbId->taskStdFp[i] = NULL; } /* Initialize posix related fields */ tcbId->pSignalInfo = NULL; tcbId->selectContextId = NULL; /* Environment */ tcbId->ppEnviron = NULL; /* Initialize architecutre depedent stuff */ taskRegsInit(tcbId, pStackBase); /* Push args on task stack */ taskArgSet(tcbId, pStackBase, args); /* Object core */ objCoreInit(&tcbId->objCore, taskClassId); /* Copy name if not unnamed */ if (name != NULL) { len = strlen(name) + 1; taskName = (char *) taskStackAllot((int) tcbId, len); if (taskName != NULL) { strcpy(taskName, name); } tcbId->name = taskName; } else { tcbId->name = NULL; } /* Run create hooks */ for (i = 0; i < MAX_TASK_CREATE_HOOKS; i++) { if (taskCreateHooks[i] != NULL) { (*taskCreateHooks[i])(tcbId); } } /* Set task as active */ vmxSpawn(tcbId); status = OK; } } return status; }
QSqlQuery::QSqlQuery(QSqlDatabase db) { d = QSqlQueryPrivate::shared_null(); qInit(this, QString(), db); }
/*! Constructs a QSqlQuery object using the SQL \a query and the database \a db. If \a db is not specified, or is invalid, the application's default database is used. If \a query is not an empty string, it will be executed. \sa QSqlDatabase */ QSqlQuery::QSqlQuery(const QString& query, QSqlDatabase db) { d = QSqlQueryPrivate::shared_null(); qInit(this, query, db); }