void SVC_Handler() { saveContext(); //Call ISR_yield(). Name is a C++ mangled name. asm volatile("bl _ZN14miosix_private9ISR_yieldEv"); restoreContext(); }
void TIM3_IRQHandler() { saveContext(); //Call ISR_auxTimer(). Name is a C++ mangled name. asm volatile("bl _ZN14miosix_private12ISR_auxTimerEv"); restoreContext(); }
int mlock (mmutex_t *mutex) { Tcb *execThread; initialize(); if (mutex) { execThread = getExecutingThread(); // While the thread doesn't get the lock, it will keep blocking and // trying again while (mutex->flag != Free) { setYielding(TRUE); addToWaitingQueue(mutex, &execThread->id); saveContext(); schedule(); } setFlag(mutex, Locked); mutex->ownerThread = execThread->id; return 0; } return -1; }
void SysTick_Handler() { saveContext(); //Call ISR_preempt(). Name is a C++ mangled name. asm volatile("bl _ZN14miosix_private11ISR_preemptEv"); restoreContext(); }
int mjoin(int thr) { Tcb *threadToWaitFor; boolean successBlocking; initialize(); setYielding(TRUE); // search thread by id, if found, then block the current and schedule. if ((threadToWaitFor = getThreadById(thr))) { successBlocking = changeStateToWaiting(threadToWaitFor); if (successBlocking) { saveContext(); // When the thread will be unblocked, it will continue executing HERE // but the scheduler won't schedule, hence this following call will do nothing schedule(); return 0; } } // return 0 in case of success, or -1 otherwise return -1; }
int main(int argc, char *argv[]) { extern const char* resstr[]; bool res; if (argc == 2) { pushStream(argv[1]); saveContext(); s_ctx oLocalCtx = {{NULL, 0}, NULL}; /*res = rule(csv, csv);*/ /*res = rule(ini, ini, &oLocalCtx) && readEOF();*/ // res = rule(debug, debug, &oLocalCtx); printf("%d\n", getPos()); /*res = rule(lisp, s_expression, &oLocalCtx);*/ /*double i = 1; while (i < 10000000) { */ res = rule(expression, expression, &oLocalCtx); /*i = i + 1; }*/ printf("[%s]\n", resstr[getPos() == (int)strlen(argv[1])]); /* popStream(); pushStream(argv[2]); res = rule(debug, debug); printf("[%s]\n", resstr[getPos() == (int)strlen(argv[2])]); */ } return 0; }
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, SkXfermode::Mode compositeOp, RespectImageOrientationEnum shouldRespectImageOrientation) { TRACE_EVENT0("skia", "BitmapImage::draw"); SkBitmap bitmap; if (!bitmapForCurrentFrame(&bitmap)) return; // It's too early and we don't have an image yet. FloatRect normDstRect = adjustForNegativeSize(dstRect); FloatRect normSrcRect = adjustForNegativeSize(srcRect); normSrcRect.intersect(FloatRect(0, 0, bitmap.width(), bitmap.height())); if (normSrcRect.isEmpty() || normDstRect.isEmpty()) return; // Nothing to draw. ImageOrientation orientation = DefaultImageOrientation; if (shouldRespectImageOrientation == RespectImageOrientation) orientation = frameOrientationAtIndex(m_currentFrame); GraphicsContextStateSaver saveContext(*ctxt, false); if (orientation != DefaultImageOrientation) { saveContext.save(); // ImageOrientation expects the origin to be at (0, 0) ctxt->translate(normDstRect.x(), normDstRect.y()); normDstRect.setLocation(FloatPoint()); ctxt->concatCTM(orientation.transformFromDefault(normDstRect.size())); if (orientation.usesWidthAsHeight()) { // The destination rect will have it's width and height already reversed for the orientation of // the image, as it was needed for page layout, so we need to reverse it back here. normDstRect = FloatRect(normDstRect.x(), normDstRect.y(), normDstRect.height(), normDstRect.width()); } } bool isLazyDecoded = DeferredImageDecoder::isLazyDecoded(bitmap); bool isOpaque = bitmap.isOpaque(); { SkPaint paint; SkRect skSrcRect = normSrcRect; int initialSaveCount = ctxt->preparePaintForDrawRectToRect(&paint, skSrcRect, normDstRect, compositeOp, !isOpaque, isLazyDecoded, bitmap.isImmutable()); // We want to filter it if we decided to do interpolation above, or if // there is something interesting going on with the matrix (like a rotation). // Note: for serialization, we will want to subset the bitmap first so we // don't send extra pixels. ctxt->drawBitmapRect(bitmap, &skSrcRect, normDstRect, &paint); ctxt->canvas()->restoreToCount(initialSaveCount); } if (isLazyDecoded) PlatformInstrumentation::didDrawLazyPixelRef(bitmap.getGenerationID()); if (ImageObserver* observer = imageObserver()) observer->didDraw(this); startAnimation(); }
void PlyOpenDlg::applyAll() { if (isValid()) { saveContext(&s_lastContext); s_lastContext.applyAll = true; emit fullyAccepted(); } }
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect, const FloatRect& srcRect, ColorSpace colorSpace, CompositeOperator compositeOp, RespectImageOrientationEnum shouldRespectImageOrientation) { if (!m_source.initialized()) return; // Spin the animation to the correct frame before we try to draw it, so we // don't draw an old frame and then immediately need to draw a newer one, // causing flicker and wasting CPU. startAnimation(); NativeImageSkia* bm = nativeImageForCurrentFrame(); if (!bm) return; // It's too early and we don't have an image yet. FloatRect normDstRect = normalizeRect(dstRect); FloatRect normSrcRect = normalizeRect(srcRect); normSrcRect.intersect(FloatRect(0, 0, bm->bitmap().width(), bm->bitmap().height())); if (normSrcRect.isEmpty() || normDstRect.isEmpty()) return; // Nothing to draw. ImageOrientation orientation = DefaultImageOrientation; if (shouldRespectImageOrientation == RespectImageOrientation) orientation = frameOrientationAtIndex(m_currentFrame); GraphicsContextStateSaver saveContext(*ctxt, false); if (orientation != DefaultImageOrientation) { saveContext.save(); // ImageOrientation expects the origin to be at (0, 0) ctxt->translate(normDstRect.x(), normDstRect.y()); normDstRect.setLocation(FloatPoint()); ctxt->concatCTM(orientation.transformFromDefault(normDstRect.size())); if (orientation.usesWidthAsHeight()) { // The destination rect will have it's width and height already reversed for the orientation of // the image, as it was needed for page layout, so we need to reverse it back here. normDstRect = FloatRect(normDstRect.x(), normDstRect.y(), normDstRect.height(), normDstRect.width()); } } paintSkBitmap(ctxt->platformContext(), *bm, normSrcRect, normDstRect, WebCoreCompositeToSkiaComposite(compositeOp)); if (ImageObserver* observer = imageObserver()) observer->didDraw(this); }
static void sleepCurrentContext() { // Grab the current core and context information auto core = cpu::this_core::state(); auto context = sCurrentContext[core->id]; if (context) { // Save all our registers to the context saveContext(context); context->nia = core->nia; context->cia = core->cia; } else { // We save the idle context's register information as well // mainly so that it doesn't complain about core state loss. saveContext(&sIdleContext[core->id]); } // Some things to help us when debugging... core->nia = 0xFFFFFFFF; core->cia = 0xFFFFFFFF; cpu::this_core::setTracer(nullptr); }
int myield(void) { initialize(); setYielding(TRUE); changeStateToReady(NULL); saveContext(); schedule(); return 0; }
void scheduler(node *head){ //load context //get signal or interrupt if(head->TCB.taskState == 0x00 || head->TCB.taskState == 0x01 || head->TCB.taskState == 0x03){ // ready, running or terminated loadContext(head); return; } //save context //get signal or interrupt else saveContext(head); }
inline bool ConsumerParser::readRange(char begin, char end) { saveContext(); if (_skipBlank) skipBlanks(); if (_rwHeader == _inputData.end() && !addData()) { restoreContext(); // std::cerr << "No more data" << std::endl; return (false); } // std::cout << "rwHeader pos : {" << *_rwHeader << "}" << std::endl; if (*_rwHeader >= begin && *_rwHeader <= end) { _rwHeader++; return (true); } restoreContext(); return (false); }
void USART1_IRQHandler() { saveContext(); asm volatile("bl _ZN6miosix13serialIrqImplEv"); restoreContext(); }
/*----------------------------------------------------------------------*/ static long dsetRead_devSiSyncChrono(stringinRecord *psi) { CONTEXT *p_myContext; long mySeconds, myMinutes, myHours, myDays; char p_time[BUFLEN]; int i; time_t myLastResetTimestamp; time_t myLastUpdatedTimestamp; time_t myCurrentTime; time_t myStopTime; time_t myUptime; int myStopFlag; int myFreezeFlag; dsetLog(3, __FILE__ "[%d] -> %s(%s)\n", __LINE__, __func__, psi->name); p_myContext = (CONTEXT *)psi->dpvt; myStopFlag=p_myContext->stopFlag; myFreezeFlag=p_myContext->freezeFlag; if (strcmp(psi->val, "RESET")==0) { p_myContext->resetFlag=1; p_myContext->stopTime=0; p_myContext->lastResetTimestamp=time((time_t *)0); p_myContext->lastUpdatedTimestamp=time((time_t *)0); /* beware no updated if oval = val */ strcpy(psi->oval, "00:00:00 (R)"); strcpy(psi->val, "00:00:00"); saveContext(psi); } if (strcmp(psi->val, "FREEZE")==0 ) { myFreezeFlag=1; p_myContext->freezeFlag=myFreezeFlag; strncpy(psi->val, psi->oval, strlen(psi->oval)); } if (strcmp(psi->val, "UPDATE")==0 ) { myFreezeFlag=0; p_myContext->freezeFlag=myFreezeFlag; } /* Because of this condition there is a design issue if you freeze and stop */ /* if (strcmp(psi->val, "STOP")==0 && myStopFlag!=0 && myFreezeFlag==0) { */ if (strcmp(psi->val, "STOP")==0 ) { p_myContext->stopFlag=1; /* doesn't work if stop at init */ strcpy(psi->val, psi->oval); saveContext(psi); } if (strcmp(psi->val, "RESTART")==0 ) { p_myContext->stopFlag=0; /* update stopTime */ myStopTime=p_myContext->stopTime; myLastUpdatedTimestamp=p_myContext->lastUpdatedTimestamp; myCurrentTime=time((time_t *)0); myStopTime=myStopTime+(myCurrentTime-myLastUpdatedTimestamp); p_myContext->stopTime=myStopTime; saveContext(psi); } /* get the new flag values */ myStopFlag=p_myContext->stopFlag; myFreezeFlag=p_myContext->freezeFlag; if ((myStopFlag==0) && (myFreezeFlag==0)){ myLastResetTimestamp=p_myContext->lastResetTimestamp; myLastUpdatedTimestamp=p_myContext->lastUpdatedTimestamp; myStopTime=p_myContext->stopTime; myCurrentTime=time((time_t *)0); p_myContext->lastUpdatedTimestamp=myCurrentTime; dsetLog(7, __FILE__ "[%d] currentTime = %d\n", __LINE__, myCurrentTime); dsetLog(7, __FILE__ "[%d] lastResetTimestamp= %d\n", __LINE__, myLastResetTimestamp); dsetLog(7, __FILE__ "[%d] lastUpdatedTimestamp= %d\n", __LINE__, myLastUpdatedTimestamp); dsetLog(7, __FILE__ "[%d] stopTime = %d\n", __LINE__, myStopTime); myUptime=myCurrentTime-myLastResetTimestamp-myStopTime; mySeconds= myUptime % 60; myUptime = myUptime / 60; myMinutes= myUptime % 60; myUptime = myUptime / 60; myHours= myUptime % 24; myDays = myUptime / 24; i = 0; if (myDays > 0) { if (myDays == 1) { i = sprintf(p_time, "1 day, "); } else { i = sprintf(p_time, "%ld days, ", myDays); } } sprintf(&p_time[i], "%02ld:%02ld:%02ld", myHours, myMinutes, mySeconds); dsetLog(7, __FILE__ "[%d] Uptime = >%s<\n", __LINE__, p_time); strncpy(psi->val, p_time, BUFLEN); } dsetLog(7, __FILE__ "[%d] Time = >%s<\n", __LINE__, psi->val); dsetLog(3, __FILE__ "[%d] <- %s\n", __LINE__, __func__ ); return(SUCCESS); }
bool MaterialLayer::beginPass(IRenderSystem *pRenderSystem) { PP_BY_NAME("MaterialLayer::beginPass"); if(!m_pTexture)return false; PP_BY_NAME_START("MaterialLayer::beginPass::saveContext"); saveContext(pRenderSystem); PP_BY_NAME_STOP(); pRenderSystem->setTexture(0,m_pTexture); if(m_bClampS) { pRenderSystem->setTextureWrapS(0,TAM_CLAMP_TO_EDGE); } if(m_bClampT) { pRenderSystem->setTextureWrapT(0,TAM_CLAMP_TO_EDGE); } if(m_bTwoSide) { pRenderSystem->setCullingMode(CULL_NONE); } pRenderSystem->setSurfaceDiffuse(m_fullDiffuse); if(m_bUnshaded) { pRenderSystem->setLightingEnabled(false); } else { pRenderSystem->setLightingEnabled(true); } if(m_bUnfogged) { pRenderSystem->enableFog(false); } if(m_SphereEnvironmentMap) { pRenderSystem->setTextureCoordCalculation(0,TEXCALC_ENVIRONMENT_MAP); } BlendMode bm = m_blendMode; if((bm == BM_OPAQUE || bm == BM_TRANSPARENT || bm == BM_MODULATE2X || bm == BM_TRANSPARENT) && m_fullDiffuse.a < 1.0f) bm = BM_ALPHA_BLEND; switch(bm) { case BM_OPAQUE: { pRenderSystem->setSceneBlending(SBF_ONE,SBF_ZERO); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(true); break; } case BM_TRANSPARENT: { pRenderSystem->setSceneBlending(SBF_ONE,SBF_ZERO); pRenderSystem->setAlphaCheckEnabled(true); pRenderSystem->setAlphaFunction(CMPF_GREATER_EQUAL,0.7f); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(true); break; } case BM_ALPHA_BLEND: { pRenderSystem->setDepthBufferFunction(CMPF_LESS_EQUAL); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setSceneBlending(SBF_SOURCE_ALPHA,SBF_ONE_MINUS_SOURCE_ALPHA); pRenderSystem->setDepthBufferCheckEnabled(true); if(m_fullDiffuse.a < 1.0f) pRenderSystem->setDepthBufferWriteEnabled(true); else pRenderSystem->setDepthBufferWriteEnabled(false); break; } case BM_ADDITIVE: { pRenderSystem->setSceneBlending(SBF_SOURCE_COLOR,SBF_ONE); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(false); break; } case BM_ADDITIVE_ALPHA: { pRenderSystem->setSceneBlending(SBF_SOURCE_ALPHA,SBF_ONE); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(false); break; } case BM_MODULATE: { pRenderSystem->setSceneBlending(SBF_DEST_COLOR,SBF_SOURCE_COLOR); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(false); break; } case BM_MODULATE2X: { pRenderSystem->setSceneBlending(SBF_DEST_COLOR,SBF_SOURCE_COLOR); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(false); break; } case BM_OPAQUE_NOWRITEDEPTH: { pRenderSystem->setSceneBlending(SBF_ONE,SBF_ZERO); pRenderSystem->setAlphaCheckEnabled(false); pRenderSystem->setDepthBufferCheckEnabled(true); pRenderSystem->setDepthBufferWriteEnabled(false); break; } } if(m_bNoDepthTest) { pRenderSystem->setDepthBufferCheckEnabled(false); } if(m_bNoDepthSet) { pRenderSystem->setDepthBufferWriteEnabled(false); } return true; }
View::~View() { saveContext(); }
void View::slotCurrentChanged( int index ) { actionViewList->setEnabled( index != 0 ); actionViewGantt->setEnabled( index != 1 ); saveContext(); }