int main() { int value; int i = 0; value = setjmp(jumper); /* 设置jump点,初始化jumper,返回值0赋给value, */ i++; printf("执行第[%d]次:value = [%d]: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",i,value); if(value == 0) { printf("[1]About to call subroutine.....\n"); subroutine(); /* 调转到subroutine()函数 */ printf("Never go this....\n"); } else if(value == 1) { printf("[2]About to call subroutine.....\n"); subroutine_2(); /* 调转到subroutine_2()函数 */ printf("Never go this....\n"); } else { printf("[3]Never go this....\n"); } return 0; }
int main() { pthread_mutexattr_t attr; pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_t mutex; pthread_mutex_init(&mutex, &attr); pthread_mutex_lock(&mutex); subroutine(&mutex); pthread_mutex_unlock(&mutex); return 0; }
int main() { int a, b; scanf("%d", &a); scanf("%d", &b); printf("%d", subroutine(a, b)); return(0); }
int main () { fn subroutine; FILE* fp = fopen("inject.profile", "r"); fread(buffer, 1, sizeof(buffer), fp); fclose(fp); subroutine = (fn)buffer; subroutine(); printf("Execution fell through.\n"); return 1; }
int main(void) { int value; value = setjmp(jumper); if (value != 0) { printf("Longjmp with value %d\n", value); exit(value); } printf("About to call subroutine ... \n"); subroutine(); return 0; }
void efficiency( Int_t chan_low = 245, Int_t chan_high = 269, Double_t open_cut = 10.0) { UInt_t tbin; TString name; gROOT->ProcessLine( ".L ReadParams.C"); ReadTagEng( "xs/tageng855.dat"); ReadDetEff( "compton"); ReadTagEff( "xs/tag_eff/TaggEff.out"); for ( UInt_t chan = chan_low; chan <= chan_high; chan++) { name = Form( "xs/compton/eff/DetEff_chan_%d.out", chan); ofstream outFile( name); if ( !outFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } name = Form( "Egamma = %3.1f MeV", tcd[chan].energy); cout << name << endl; for ( tbin = 0; tbin <= 9; tbin++) { subroutine( chan, tbin, msep_cut[chan][tbin], open_cut); name = Form( "%3d %6.4f %6.4f", th[tbin], efficiency, contamination); outFile << name << endl; name = Form( " %3d %3.0f %6.4f %6.4f", th[tbin], msep_cut[chan][tbin], efficiency, contamination); cout << name << endl; } outFile.close(); } }
int second() { return subroutine(); }
void msepcreator( Int_t chan_low = 245, Int_t chan_high = 269, Double_t contthresh = 0.1, Double_t open_cut = 10.0) { UInt_t chan, tbin, nchan, msep, msep1, msep2, msepbest, whichmsep; Double_t ratio, ratiobest, contout; TString name; nchan = chan_high - chan_low; name = Form( "xs/msep_cuts_chan.h"); ofstream outFile(name); if ( !outFile.is_open()) { cout << "Error opening file "; cout << name; cout << endl; break; } name = Form("// This msep_cuts array was created with a maximum pi0 contribution in each channel of (%3.2f)*100 percent and an opening angle of %3.1f degrees", contthresh, open_cut); cout << name << endl; outFile << name << endl; name = Form(" "); cout << name << endl; outFile << name << endl; name = Form( " Double_t msep_cut[351][10];"); cout << name << endl; outFile << name << endl; name = Form(" "); cout << name << endl; outFile << name << endl; for ( chan = chan_low; chan <= chan_high ; chan++) { for ( tbin = 0; tbin <= 9 ; tbin++) { msepbest = 0; contout = 0.0; msep1 = 0; msep2 = 0; for ( msep = 920; msep <= 980; msep++) { subroutine( chan, tbin, msep, open_cut); if (efficiency != 0.0) { ratio = contamination/efficiency; } else { ratio = -1.0; } if (ratio == 0.0) { msep2 = msep; } if ((ratio > 0.0) && (ratio <= 1.0) && (contamination <= contthresh)) { msep1 = msep; contout = contamination; } if (msep1 > msep2) { msepbest = msep1; whichmsep = 1; } else { msepbest = msep2; whichmsep = 2; } } //ends for loop over msep name = Form( " msep_cut[%d][%d] = %d;", chan, tbin, msepbest); cout << name << endl; outFile << name << endl; } // ends angle bin loop name = Form(" "); cout << name << endl; outFile << name << endl; } // ends energy bin loop }
void handler(int sig) { subroutine(sig); }