int main(int argc, char ** argv) { cv::Mat inputimage; #if defined(WIN32) || defined(__APPLE__) cv::VideoCapture VC; #else V4L2C VC; #endif VC.open(0); VC.set(CV_CAP_PROP_FRAME_WIDTH, VIDEO_WIDTH); VC.set(CV_CAP_PROP_FRAME_HEIGHT, VIDEO_HEIGHT); VC.set(CV_CAP_PROP_FPS, 30); VC.mV4L2WImgParam.pix_fmt = V4L2_PIX_FMT_MJPEG; while (1) { VC.read(inputimage); cv::imshow("Input Image", inputimage); if (check_break()) break; } VC.release(); return 0; }
static int check_word(Word *word) { int len = word->len; int ok, i; int chg = FALSE; /* tracef("Checking %s", word->chars);*/ for (i=len-1; i>=0; i--) { if (ISBREAK(word, i)) { ok = check_break(word, i); if (!ok) { CLRBREAK(word, i); chg = TRUE; } } } return chg; }
void ft_command(t_list **l, char buf[4], struct termios *term) { int ret; t_list *cursor; cursor = (*l)->next; while (!check_break(buf, cursor)) { buf[0] = 0; buf[1] = 0; buf[2] = 0; tputs(tgetstr("cl", NULL), 1, tty_putchar); ft_underline(cursor, l); ret = read(0, buf, 3); buf[ret] = '\0'; ft_space(&cursor, buf); ft_up(&cursor, buf); ft_down(&cursor, buf); ft_check_esc(buf, term); ft_delete(cursor, buf, &cursor); } }
int check_stmt(is_stmt* node) { int errors = 0; /* ; empty statement */ if (!node) return 0; switch (node->type) { case t_stmt_stmt_list: node->data.stmt_list.scope = scope_new(NULL, false); scope_push(node->data.stmt_list.scope); errors += check_stmt_list(node->data.stmt_list.list); scope_pop(); if (errors == 0) node->terminates = node->data.stmt_list.list->terminated; break; case t_stmt_var_stmt: errors += check_var_stmt(node->data.var, false); break; case t_stmt_assign: errors += check_assign_op(node->data.assign); break; case t_stmt_incr: errors += check_incr_op(node->data.incr); break; case t_stmt_if: errors += check_if(node->data.if_stmt); if (errors == 0) node->terminates = node->data.if_stmt->terminates; break; case t_stmt_loop: errors += check_loop_stmt(node->data.loop); if (errors == 0) node->terminates = node->data.loop->terminates; break; case t_stmt_func_call: errors += check_func_call(node->data.func_call); break; case t_stmt_switch: errors += check_switch(node->data.switch_stmt); if (errors == 0) node->terminates = node->data.switch_stmt->terminates; break; case t_stmt_break: errors += check_break(node->data.break_stmt); node->terminates = true; break; case t_stmt_continue: errors += check_continue(node->data.continue_stmt); node->terminates = true; break; case t_stmt_return: errors += check_return(node->data.return_stmt); node->terminates = true; break; } return errors; }
/* * wait for I/O completion for a device */ LOCAL ID waitcomplete( ID dd, ID reqid, W *asize, ER *ioer, TMO_U tmout, enum ReqType syncreq ) { ATR drvatr; OpnCB *opncb; DevCB *devcb; ReqCB *reqcb; DEVREQ *devreq; INT reqno, nreq; ID tskid; BOOL abort; ER ercd; tskid = tk_get_tid(); LockDM(); ercd = check_devdesc(dd, 0, &opncb); if ( ercd < E_OK ) { goto err_ret1; } /* Check whether there is a break request */ abort = FALSE; ercd = check_break(); if ( ercd < E_OK ) { if ( syncreq == AsyncReq ) goto err_ret1; abort = TRUE; } devcb = opncb->devcb; drvatr = devcb->ddev.drvatr; if ( reqid == 0 ) { /* When waiting for completion of any of requests for 'dd' */ if ( opncb->nwaireq > 0 || opncb->waitone > 0 || opncb->syncreq > 0 ) { ercd = E_OBJ; goto err_ret1; } if ( isQueEmpty(&opncb->requestq) ) { ercd = E_NOEXS; goto err_ret1; } /* Create wait request list */ reqcb = (ReqCB*)opncb->requestq.next; for ( nreq = 1;; nreq++ ) { reqcb->tskid = tskid; devreq = &reqcb->req; reqcb = (ReqCB*)reqcb->q.next; if ( reqcb == (ReqCB*)&opncb->requestq ) { break; } devreq->c.next = &reqcb->req; } devreq->c.next = NULL; devreq = &((ReqCB*)opncb->requestq.next)->req; opncb->waireqlst = devreq; opncb->nwaireq = nreq; } else { /* Wait for completion of abort request processing */ reqcb = check_reqid(reqid, opncb); if ( reqcb == NULL ) { ercd = E_ID; goto err_ret1; } if ( opncb->nwaireq > 0 || reqcb->tskid > 0 ) { ercd = E_OBJ; goto err_ret1; } /* Create waiting request list */ reqcb->tskid = tskid; devreq = &reqcb->req; devreq->c.next = NULL; if ( abort ) devreq->c.abort = TRUE; nreq = 1; opncb->waitone++; } /* Device driver call */ UnlockDM(); reqno = call_waitfn(devcb, devreq, nreq, tmout); LockDM(); if ( reqno < E_OK ) { ercd = reqno; } else if ( reqno >= nreq ) { ercd = E_SYS; } LockDAbort(); /* Free wait processing */ if ( reqid == 0 ) { opncb->nwaireq = 0; } else { opncb->waitone--; } /* If there is an abort completion wait task, notify abort completion */ if ( opncb->abort_tskid > 0 && --opncb->abort_cnt == 0 ) { SyncSignalDM(opncb->abort_tskid); } /* Get processing result */ while ( devreq != NULL ) { reqcb = DEVREQ_REQCB(devreq); if ( reqno-- == 0 ) { reqid = REQID(reqcb); if ( (drvatr & TDA_DEV_D) == 0 ) { *asize = devreq->s.asize; *ioer = devreq->s.error; } else { *asize = devreq->l.asize; *ioer = devreq->l.error; } } reqcb->tskid = 0; devreq = devreq->c.next; } UnlockDAbort(); if ( ercd < E_OK ) { goto err_ret1; } if ( syncreq == SyncReq ) { opncb->syncreq--; } /* Unregister completed request */ delReqCB(REQCB(reqid)); UnlockDM(); return reqid; err_ret1: if ( syncreq == SyncReq ) { opncb->syncreq--; } UnlockDM(); DEBUG_PRINT(("waitcomplete ercd = %d\n", ercd)); return ercd; }
/* * Request for starting input/output to device */ LOCAL ID request( ID dd, D start, void *buf, INT size, TMO_U tmout, INT cmd, enum ReqType syncreq ) { ATR drvatr; OpnCB *opncb; DevCB *devcb; ReqCB *reqcb; UINT m; ER ercd; LockDM(); /* Check whether there is a break request */ ercd = check_break(); if ( ercd < E_OK ) { goto err_ret1; } m = ( cmd == TDC_READ )? TD_READ: TD_WRITE; ercd = check_devdesc(dd, m, &opncb); if ( ercd < E_OK ) { goto err_ret1; } if ( syncreq == SyncReq ) { /* synchronous I/O is prohibited while there are pending I/O requests for completion */ if ( opncb->nwaireq > 0 ) { ercd = E_OBJ; goto err_ret1; } opncb->syncreq++; } devcb = opncb->devcb; drvatr = devcb->ddev.drvatr; /* check the range of parameter value */ if ( (drvatr & TDA_DEV_D) == 0 ) { if ( start > 0x7fffffff || start < (-0x7fffffff-1) ) { ercd = E_PAR; goto err_ret2; } } /* Get request management block */ reqcb = newReqCB(opncb); if ( reqcb == NULL ) { ercd = E_LIMIT; goto err_ret2; } /* Set request packet */ MEMSET(&reqcb->req, 0, sizeof(DEVREQ)); reqcb->req.c.devid = DEVID(devcb, opncb->unitno); reqcb->req.c.cmd = cmd; if ( (opncb->omode & TD_NOLOCK) != 0 ) { reqcb->req.c.nolock = TRUE; } if ( (drvatr & TDA_DEV_D) == 0 ) { reqcb->req.s.start = start; reqcb->req.s.size = size; reqcb->req.s.buf = buf; } else { reqcb->req.l.start_d = start; reqcb->req.l.size = size; reqcb->req.l.buf = buf; } ercd = tk_get_tsp(TSK_SELF, &reqcb->req.c.tskspc); if ( ercd < E_OK ) { goto err_ret3; } /* Indicate that it is during processing */ reqcb->tskid = tk_get_tid(); /* Device driver call */ UnlockDM(); ercd = call_execfn(devcb, &reqcb->req, tmout); LockDM(); LockDAbort(); /* Indicate that it is not during processing */ reqcb->tskid = 0; /* If there is an abort completion wait task, notify abort completion */ if ( opncb->abort_tskid > 0 && --opncb->abort_cnt == 0 ) { SyncSignalDM(opncb->abort_tskid); } UnlockDAbort(); if ( ercd < E_OK ) { goto err_ret3; } UnlockDM(); return REQID(reqcb); err_ret3: delReqCB(reqcb); err_ret2: if ( syncreq == SyncReq ) { opncb->syncreq--; } err_ret1: UnlockDM(); DEBUG_PRINT(("request ercd = %d\n", ercd)); return ercd; }
int calc_run_tstates(LPCALC lpCalc, time_t tstates) { uint64_t time_end = tc_tstates(&lpCalc->timer_c) + tstates - lpCalc->time_error; while (lpCalc->running) { if (check_break(&lpCalc->mem_c, addr_to_waddr(&lpCalc->mem_c, lpCalc->cpu.pc)) & 1) { #ifdef WINVER lpCalc->running = FALSE; bank_t *bank = &lpCalc->mem_c.banks[mc_bank(lpCalc->cpu.pc)]; Z80_info_t z[2]; disassemble(lpCalc, REGULAR, addr_to_waddr(lpCalc->cpu.mem_c, lpCalc->cpu.pc), 1, z); if (lpCalc->pCalcNotify != NULL) { bank_t *bank = &lpCalc->mem_c.banks[mc_bank(lpCalc->cpu.pc)]; CCalcAddress *pCalcAddress = new CComObject<CCalcAddress>(); pCalcAddress->Initialize(lpCalc->pWabbitemu, bank->ram, bank->page, lpCalc->cpu.pc); pCalcAddress->AddRef(); lpCalc->pCalcNotify->Breakpoint(pCalcAddress); } else { #endif #ifndef MACVER lpCalc->breakpoint_callback(lpCalc); #else printf("hit a breakpoint in run tstates\n"); lpCalc->running = FALSE; lpCalc->breakpoint_callback(lpCalc,lpCalc->breakpoint_owner); #endif #ifdef WINVER } #endif return 0; } uint64_t oldTStates; uint16_t oldPC; if (lpCalc->profiler.running) { oldTStates = tc_tstates(&lpCalc->timer_c); oldPC = lpCalc->cpu.pc % PAGE_SIZE; } if (link_hub_count > 1) { CPU_connected_step(&lpCalc->cpu); if (lpCalc->cpu.is_link_instruction) { lpCalc->time_error = (time_t)(tc_tstates((&lpCalc->timer_c)) - time_end); calc_waiting_link++; break; } } else { CPU_step(&lpCalc->cpu); } if (lpCalc->profiler.running) { uint64_t time = tc_tstates(&lpCalc->timer_c) - oldTStates; lpCalc->profiler.totalTime += time; bank_t bank = lpCalc->cpu.mem_c->banks[mc_bank(oldPC)]; if (bank.ram) { lpCalc->profiler.ram_data[bank.page][oldPC / lpCalc->profiler.blockSize] += (long) time; } else { lpCalc->profiler.flash_data[bank.page][oldPC / lpCalc->profiler.blockSize] += (long) time; } } if (tc_tstates((&lpCalc->timer_c)) >= time_end) { lpCalc->time_error = (time_t)(tc_tstates((&lpCalc->timer_c)) - time_end); break; } } return 0; }