static void wakeCurrentContext() { // Clean up any dead fibers checkDeadContext(); // Grab the current core and context information auto core = cpu::this_core::state(); auto context = sCurrentContext[core->id]; // If we switched into a new context, we need to restore it back // to how it was configured before we suspended it. if (context) { // Restore our context from the OSContext restoreContext(context); core->nia = context->nia; core->cia = context->cia; // Some things to help us when debugging... cpu::this_core::setTracer(context->fiber->tracer); } else { // Restore the idle context information stored earlier restoreContext(&sIdleContext[core->id]); // These are the 'defacto' idle-thread values core->nia = 0xFFFFFFFF; core->cia = 0xFFFFFFFF; } }
void TIM3_IRQHandler() { saveContext(); //Call ISR_auxTimer(). Name is a C++ mangled name. asm volatile("bl _ZN14miosix_private12ISR_auxTimerEv"); restoreContext(); }
void SVC_Handler() { saveContext(); //Call ISR_yield(). Name is a C++ mangled name. asm volatile("bl _ZN14miosix_private9ISR_yieldEv"); restoreContext(); }
void SysTick_Handler() { saveContext(); //Call ISR_preempt(). Name is a C++ mangled name. asm volatile("bl _ZN14miosix_private11ISR_preemptEv"); restoreContext(); }
void PAlgebraModDerived<type>::genMaskTable() const { if (maskTable.size() > 0) return; RBak bak; bak.save(); restoreContext(); // strip const vector< vector< RX > >& mtab = (vector< vector< RX > >&) maskTable; RX tmp1; mtab.resize(zMStar.numOfGens()); for (long i = 0; i < (long)zMStar.numOfGens(); i++) { // if (i==0 && zMStar.SameOrd(i)) continue;//SHAI: need these masks for shift1D long ord = zMStar.OrderOf(i); mtab[i].resize(ord+1); mtab[i][ord] = 0; for (long j = ord-1; j >= 1; j--) { // initialize mask that is 1 whenever the ith coordinate is at least j // Note: mtab[i][0] = constant 1, mtab[i][ord] = constant 0 mtab[i][j] = mtab[i][j+1]; for (long k = 0; k < (long)zMStar.getNSlots(); k++) { if (zMStar.coordinate(i, k) == j) { div(tmp1, PhimXMod, factors[k]); mul(tmp1, tmp1, crtCoeffs[k]); add(mtab[i][j], mtab[i][j], tmp1); } } } mtab[i][0] = 1; } }
template<class type> void EncryptedArrayDerived<type>::buildLinPolyCoeffs(vector<RX>& C, const vector<RX>& L) const { FHE_TIMER_START; RBak bak; bak.save(); restoreContext(); // the NTL context for mod p^r REBak ebak; ebak.save(); restoreContextForG(); // The NTL context for mod G do { typename Lazy< Mat<RE> >::Builder builder(linPolyMatrix); if (!builder()) break; long p = tab.getZMStar().getP(); long r = tab.getR(); Mat<RE> M1; // build d x d matrix, d is taken from the surrent NTL context for G buildLinPolyMatrix(M1, p); Mat<RE> M2; ppInvert(M2, M1, p, r); // invert modulo prime-power p^r UniquePtr< Mat<RE> > ptr; ptr.make(M2); builder.move(ptr); } while (0); Vec<RE> CC, LL; convert(LL, L); mul(CC, LL, *linPolyMatrix); convert(C, CC); }
void YKDispatcher(int first){ if(first == 1){ restoreContext(); } else if (first == 2) { saveAndFirstRestoreContext(); } else { saveAndRestoreContext(); } }
// Linearized polynomials. // L describes a linear map M by describing its action on the standard // power basis: M(x^j mod G) = (L[j] mod G), for j = 0..d-1. // The result is a coefficient vector C for the linearized polynomial // representing M: a polynoamial h in Z/(p^r)[X] of degree < d is sent to // // M(h(X) \bmod G)= \sum_{i=0}^{d-1}(C[j] \cdot h(X^{p^j}))\bmod G). template<class type> void EncryptedArrayDerived<type>::buildLinPolyCoeffs(vector<ZZX>& C, const vector<ZZX>& L) const { RBak bak; bak.save(); restoreContext(); vector<RX> CC, LL; convert(LL, L); buildLinPolyCoeffs(CC, LL); convert(C, CC); }
void EncryptedArrayDerived<type>::initNormalBasisMatrix() const { do { typename Lazy< Pair< Mat<R>, Mat<R> > >::Builder builder(normalBasisMatrices); if (!builder()) break; RBak bak; bak.save(); restoreContext(); REBak ebak; ebak.save(); restoreContextForG(); long d = RE::degree(); long p = tab.getZMStar().getP(); long r = tab.getR(); // compute change of basis matrix CB mat_R CB; CB.SetDims(d, d); RE normal_element; RE H; bool got_it = false; H = power(conv<RE>(RX(1, 1)), p); do { NTL::random(normal_element); RE pow; pow = normal_element; VectorCopy(CB[0], rep(pow), d); for (long i = 1; i < d; i++) { pow = eval(rep(pow), H); VectorCopy(CB[i], rep(pow), d); } Mat<ZZ> CB1; conv(CB1, CB); { zz_pBak bak1; bak1.save(); zz_p::init(p); Mat<zz_p> CB2; conv(CB2, CB1); got_it = determinant(CB2) != 0; } } while (!got_it); Mat<R> CBi; ppInvert(CBi, CB, p, r); UniquePtr< Pair< Mat<R>, Mat<R> > > ptr; ptr.make(CB, CBi); builder.move(ptr); } while(0); }
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); }
bool PlyOpenDlg::restorePreviousContext(bool& hasAPreviousContext) { hasAPreviousContext = s_lastContext.valid; if (!hasAPreviousContext) return false; int unassignedProps = 0; int mismatchProps = 0; bool restored = restoreContext(&s_lastContext, unassignedProps, mismatchProps); //auto-stop: we can't keep 'apply all' if something has changed if (!restored || mismatchProps != 0/* || unassignedProps > 0*/) { s_lastContext.applyAll = false; return false; } return true; }
void USART1_IRQHandler() { saveContext(); asm volatile("bl _ZN6miosix13serialIrqImplEv"); restoreContext(); }