bool FileBasedIpc::Close() { std::auto_ptr<Semaphore> temp0(sems[0]); std::auto_ptr<Semaphore> temp1(sems[1]); std::auto_ptr<Semaphore> temp2(sems[2]); std::auto_ptr<Semaphore> temp3(sems[3]); bool result = true; for(size_t i = 0; i < 4; i++) { if(sems[i] != NULL) { if(status_ == PARENT) { if(!sems[i]->Destroy()) { result &= false; } } sems[i] = NULL; } } for(size_t i = 0; i < 2; i++) { if(files_[i] != NULL) { if(fclose(files_[i]) != 0) { result &= false; } files_[i] = NULL; } } return result; }
constexpr bool will_overflow_impl( const TIn& x, std::false_type, std::false_type) noexcept { if(x > std::numeric_limits<TOut>::max() || x < std::numeric_limits<TOut>::lowest()) { return true; } std::feclearexcept(FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID); TOut temp0(x); TIn temp1(x); temp0 = temp1; (void)temp0; (void)temp1; if(std::fetestexcept(FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID)) { return true; } // Sanity check. if(static_cast<TIn>(static_cast<TOut>(x)) != x) { return true; } return false; }
void MainWindow::showdata(){ Mips exec_data=instrutions; exec_data.firstprase(); exec_data.secondprase(); showMips(exec_data); QString code; int cnt=0; QString temp; for (auto i=exec_data.data_store.begin();i!=exec_data.data_store.end();++i,++cnt){ if (cnt%4==0) { code+=QString::number(i->first,16); code+=" "; } temp=QString::number(i->second,2); if (temp.size()<8){ QString temp0(8-temp.size(),'0'); temp=temp0+temp; } code+=temp+" "; if (cnt%4==3) code+='\n'; qDebug()<<temp; } if (cnt%4!=0){ code+=temp+'\n'; } qDebug()<<cnt; ui->textBrowser->setText(code); }
TranslationAnm::TranslationAnm(gkScene* scene,gkGameObject* pObj,const gkString& str,gkVector3 flyoffset,gkVector3 posoffset): m_scene(scene),m_pGameObj(pObj),m_pAnmState(NULL),m_pAnm(NULL),m_pAnmTrack(NULL),m_AnmEnable(false),m_sAnmName(str), m_AnmFlyOffset(flyoffset),m_AnmPosOffset(posoffset),m_pAnmListener(NULL) { gkVector3 temp(0,0,0); gkVector3 temp0(1,1,1); m_ToPos = m_FromPos = temp; m_ToScale = m_FromScale = temp0; setCurrentSecne(); }
/* This is a very simple main function used here for testing. It * instantiates 2 processing objects. The parameters are then changed * in the observable parameter object. The processing objects should * then update themselves and so the last "cout" calls should reveal the * new parameters. At least, this is what I would like to happen!*/ int main(int argc, char *argv[]) { kPublisher Publisher; kSubscriber temp0(Publisher, 0); kSubscriber temp1(Publisher, 1); std::cout << "Processing unit " << 0 << " param = " << temp0.getParam() << std::endl; std::cout << "Processing unit " << 1 << " param = " << temp1.getParam() << std::endl; Publisher.changePars(); std::cout << "Processing unit " << 0 << " param = " << temp0.getParam() << std::endl; std::cout << "Processing unit " << 1 << " param = " << temp1.getParam() << std::endl; std::cin.get(); }
//Main method int32 main () { //enabling the audio interface ulk_proc_audio_init(); ulk_proc_get_dflt_config(&ulk_audio_config); ulk_cpanel_printf("default(init) settings used for microphone\r\n"); ulk_cpanel_printf("SAMPLE_RATE=%dkhz\r\nBOOST_EFFECT=%d\r\nMIC_L_GAIN=%ddb\r\n", ulk_audio_config.SAMPLE_RATE,ulk_audio_config.BOOST_EFFECT, ulk_audio_config.MIC_L_GAIN); ulk_cpanel_printf("MIC_R_GAIN=%ddb\r\nSPK_L_GAIN=%ddb\r\n", ulk_audio_config.MIC_R_GAIN,ulk_audio_config.SPK_L_GAIN); ulk_cpanel_printf("SPK_R_GAIN=%ddb\r\nOUT_MODE=%s\r\n", ulk_audio_config.SPK_R_GAIN,(ulk_audio_config.OUT_MODE=='S')?"Stereo":"Mono"); ulk_cpanel_printf("\r\nconfiguring new settings used for line in\r\n"); //new audio settings ulk_audio_config.SAMPLE_RATE=44.1; ulk_audio_config.BOOST_EFFECT=3; ulk_audio_config.MIC_L_GAIN=-6; ulk_audio_config.MIC_R_GAIN=-6; ulk_audio_config.SPK_L_GAIN=10; ulk_audio_config.SPK_R_GAIN=10; ulk_audio_config.OUT_MODE='M'; ulk_proc_audio_set_config(&ulk_audio_config); ulk_proc_audio_get_config(&ulk_audio_config); ulk_cpanel_printf("SAMPLE_RATE=%dkhz\r\nBOOST_EFFECT=%d\r\nMIC_L_GAIN=%ddb\r\n", ulk_audio_config.SAMPLE_RATE,ulk_audio_config.BOOST_EFFECT, ulk_audio_config.MIC_L_GAIN); ulk_cpanel_printf("MIC_R_GAIN=%ddb\r\nSPK_L_GAIN=%ddb\r\n", ulk_audio_config.MIC_R_GAIN,ulk_audio_config.SPK_L_GAIN); ulk_cpanel_printf("SPK_R_GAIN=%ddb\r\nOUT_MODE=%s\r\n", ulk_audio_config.SPK_R_GAIN,(ulk_audio_config.OUT_MODE=='S')?"Stereo":"Mono"); //PCM audio settings ulk_audio_pcm.pcm_type='D'; ulk_audio_pcm.pcm_data_p=(uint8* )buf; ulk_audio_pcm.pcm_size=(ulk_audio_config.SAMPLE_RATE)*1000*10; ulk_cpanel_printf("record: %d-samples, %s-line\r\n",ulk_audio_pcm.pcm_size, (ulk_audio_pcm.pcm_type=='D')?"Default":((ulk_audio_pcm.pcm_type=='R')?"Right":"Left")); //Record audio from input ulk_proc_audio_record (&ulk_audio_pcm); ulk_cpanel_printf("recording completed"); //LCD int i,j; int s=0x00; //To make the complete screen painted white for(i=0; i < GLCD_COLUMNS*GLCD_ROWS; i++) { *(ptr+i)= WHITE_COLOR; } //Draw grid of touch panel virtual keys on the white screen //of GLCD for touch panel draw_grid(GRID_ROWS, GRID_COLUMNS); //Enables the touch panel ulk_proc_touch_spi_enable(); // variables to hold touch co-ordinates int valx,valy; int boxnum; while(1) { int column = 64;//each grid width int row = 49;//each grid height valx=0;valy=0;boxnum=0; pixel = ulk_proc_touch_spi_poll(); //To find box number if a touch is made if((pixel.x != 0) && (pixel.y != 0)) { valx=pixel.x; valy=pixel.y -240; valx=valx/64+1; valy=-(valy)/48+1; boxnum=((valy-1)*5)+valx; ulk_cpanel_printf("x pos = %d \n",valx); ulk_cpanel_printf("y pos = %d \n",valy); ulk_cpanel_printf("Box_no = %d \n",boxnum); column=column*(valx-1); row=row*(valy-1); draw_fillbox_black(column,row); draw_grid(GRID_ROWS, GRID_COLUMNS); //ulk_cpanel_printf("col = %d \n",column); //ulk_cpanel_printf("row = %d \n",row); //match the box number to the respective effect if(boxnum==5) echo0(); if(boxnum==10) echo25(); if(boxnum==15) echo35(); if(boxnum==25) echo55(); if(boxnum==2) temp0(); if(boxnum==7) temp0_8(); if(boxnum==12) temp2(); } } return 0; }
Polynom Polynom::substitution(Polynom value) { //cout<<" ot "<< *this << " pods " << value <<endl; if (coefI && value.coefI) { Complex<int> temp0(0,0); Complex<int> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefI[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefI && value.coefB) { Complex<BigInt> temp0(0,0); Complex<BigInt> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefI[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefI && value.coefR) { Complex<Rational> temp0(0,0); Complex<Rational> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefI[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefI && value.coefD) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefI[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefB && value.coefI) { Complex<BigInt> temp0(0,0); Complex<BigInt> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefB[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefB && value.coefB) { Complex<BigInt> temp0(0,0); Complex<BigInt> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefB[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefB && value.coefR) { Complex<Rational> temp0(0,0); Complex<Rational> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefB[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefB && value.coefD) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefB[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefR && value.coefI) { Complex<Rational> temp0(0,0); Complex<Rational> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefR[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefR && value.coefB) { Complex<Rational> temp0(0,0); Complex<Rational> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefR[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefR && value.coefR) { Complex<Rational> temp0(0,0); Complex<Rational> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefR[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefR && value.coefD) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefR[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefD && value.coefI) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefD[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefD && value.coefB) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefD[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefD && value.coefR) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefD[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } if (coefD && value.coefD) { Complex<double> temp0(0,0); Complex<double> temp1(1,0); Polynom temp(temp1,0); Polynom answer(temp0,0); for (int i = 0; i <= degree; i++) { Polynom curr(coefD[i], 0); answer = answer + temp * curr; temp = temp * value; } *this = answer; return answer; } }