int PerfCounterMuninNodePlugin::GetValues(char *buffer, int len) { PDH_STATUS status; PDH_FMT_COUNTERVALUE counterValue; int printCount; status = PdhCollectQueryData(m_PerfQuery); if (status != ERROR_SUCCESS) return -1; for (size_t i = 0; i < m_Counters.size(); i++) { // Get the formatted counter value status = PdhGetFormattedCounterValue(m_Counters[i], m_dwCounterFormat, NULL, &counterValue); if (status != ERROR_SUCCESS) return -1; double value = 0; switch (m_dwCounterFormat) { case PDH_FMT_DOUBLE: value = counterValue.doubleValue * m_CounterMultiply; break; case PDH_FMT_LONG: value = counterValue.longValue * m_CounterMultiply; break; case PDH_FMT_LARGE: value = counterValue.largeValue * m_CounterMultiply; break; } printCount = printvalue(buffer, len, m_Name.c_str(), i, value, m_dwCounterFormat); len -= printCount; buffer += printCount; } strncat(buffer, ".\n", len); return 0; }
/* * Write all normal global variables to an output file. * Note: Currently only simple types are saved. * Returns nonzero on error. */ int writeglobals(char *name) { FILE *fp; GLOBAL **hp; /* hash table head address */ register GLOBAL *sp; /* current global symbol pointer */ int savemode; /* saved output mode */ E_FUNC void math_setfp(FILE *fp); fp = f_open(name, "w"); if (fp == NULL) return 1; math_setfp(fp); for (hp = &globalhash[HASHSIZE-1]; hp >= globalhash; hp--) { for (sp = *hp; sp; sp = sp->g_next) { switch (sp->g_value.v_type) { case V_NUM: case V_COM: case V_STR: break; default: continue; } math_fmt("%s = ", sp->g_name); savemode = math_setmode(MODE_HEX); printvalue(&sp->g_value, PRINT_UNAMBIG); math_setmode(savemode); math_str(";\n"); } } math_setfp(stdout); if (fclose(fp)) return 1; return 0; }
int main(){ printf("%s", "Letter(a-zA-z)=Number(0-9)\n"); struct listNode *head = NULL; char a[100]; while(1){ printf(">>>"); fgets(a,100,stdin); a[strlen(a)-1]=0; if(strcmp(a, "quit")==0){ break; } else if(strncmp(a, "print ", 6)==0){ char c = a[6]; printvalue(head,c); } else if(a[0] <= 'z' && a[0] >='a'){ if(a[1] == '='){ if(a[2] <= '9' && a[2] >= '0'){ if(a[3]==0){ struct listNode *node = malloc(sizeof(struct listNode)); node->var = a[0]; node->value = a[2]; node->next = NULL; if(head == NULL){ head = node; } else{ node->next = head; head = node; } } else printf("Error, only save 0-9\n"); } else printf("not such sytax\n"); } else printf("not such sytax\n"); } else printf("not such sytax\n"); } printList(head); return 0; }
// Function to print data before the run starts void Print2Memory::printinfo(const double data[], Parameters& params){ // Save the cosmological parameters printvalue("OmegaMh2", params.rhoM()); printvalue("OmegaBh2", params.rhoB()); printvalue("OmegaKh2", params.rhoK()); printvalue("OmegaRh2", params.rhoR()); printvalue("Tgamma", params.Tgamma()); printvalue("zinit", params.z0()); printvalue("Neff", params.Neff()); }
/*This function prints out a Dict, it takes as its arguments to print(void* item) functions, one to print the keys, and one to print the values. */ void dprint(Dict dictionary,void (*printkey)(void* item),void (*printvalue)(void* item)) { int i; printf("Length: %d\n",getLength(dictionary)); printf("Capacity: %d\n",dictionary->capacity); for(i=0;i<getLength(dictionary);i++) { printf("Key %d: <",i); printkey(gget(dictionary->keys,i)); printf(","); printvalue(gget(dictionary->values,i)); printf(">\n"); } }
/* * Print the elements of an object in short and unambiguous format. * This is the default routine if the user's is not defined. * * given: * op object being printed */ S_FUNC void objprint(OBJECT *op) { int count; /* number of elements */ int i; /* index */ count = op->o_actions->oa_count; math_fmt("obj %s {", namestr(&objectnames, op->o_actions->oa_index)); for (i = 0; i < count; i++) { if (i) math_str(", "); printvalue(&op->o_table[i], PRINT_SHORT | PRINT_UNAMBIG); } math_chr('}'); }
void printtypeinfo (struct rnntypeinfo *ti, char *prefix, int shift, char *file) { if (ti->shr) printdef (prefix, "SHR", 1, ti->shr, file); if (ti->minvalid) printdef (prefix, "MIN", 0, ti->min, file); if (ti->maxvalid) printdef (prefix, "MAX", 0, ti->max, file); if (ti->alignvalid) printdef (prefix, "ALIGN", 0, ti->align, file); int i; for (i = 0; i < ti->valsnum; i++) printvalue(ti->vals[i], shift); for (i = 0; i < ti->bitfieldsnum; i++) printbitfield(ti->bitfields[i], shift); }
static ssize_t format_devstat_counter(struct ieee80211_local *local, char __user *userbuf, size_t count, loff_t *ppos, int (*printvalue)(struct ieee80211_low_level_stats *stats, char *buf, int buflen)) { struct ieee80211_low_level_stats stats; char buf[20]; int res; rtnl_lock(); res = drv_get_stats(local, &stats); rtnl_unlock(); if (res) return res; res = printvalue(&stats, buf, sizeof(buf)); return simple_read_from_buffer(userbuf, count, ppos, buf, res); }
void cellp( double delta_t) #endif { int itype,iindex, cn,ismax=False; int cells_survived = 0; int PrintLoopVar=PrintGap; double bigEndT, jjj; int snow; double TotalCells; int SendCellCountOneTime; char stemp[255]; int ksumlevel; int GiveTimeCount; int envnowl = 0; extern void release_mem(); extern double rand01(int), ranmarm(int); #ifdef TEST time_t stime; #endif #ifndef DLL FILE *out;/* the pointer to s2.out, the interface file to Java */ #endif #ifdef TESTMPI extern int nrepetitions; #endif if (Cured == False) { SendCellCountOneTime = True; } else { SendCellCountOneTime = False; } /*_ASSERT(0);*/ /* This func call inits the nexttoxtime variable*/ Tblength = (long) (ntypes/Class[0].no_levels); InitNextToxTime(); SetBBForPatient(); snow = 0; if ((GiveTimeCount = 48 - (ntypes * 3)) < 0) GiveTimeCount = 0; /* Changes: 12 September 1996 * while((timevec[itime] <= StartT) && (itime <= nallts)) itime++; * <= changed to < . This ensures that itime is no increased when timevec[itime] = startT */ /* added by Qinshou 10/25/96 for test suites */ #ifdef TEST /* construct output file name */ if ( nrepetitions == 1 ) { if (numTest <= 9 ) sprintf(outName,"%s0%1d.%d.%d.0%d.out",outName,numTest,nrepetitions,(int)EndT,(int)(delta_t*1000)); else sprintf(outName,"%s%2d.%d.%d.0%d.out",outName,numTest,nrepetitions,(int)EndT,(int)(delta_t*1000)); out = fopen(outName,"w"); } else out = fopen(outName,"a"); if ( out==NULL ) { printf("Error opening %s\n",outName); Memory=False; return; } if ( nrepetitions ==1 ) printvalue(out); #endif t=StartT; UpdateTime = 0.0; cellpitime = 2; nowenv = 0; if (KineticsModel == IsGompertz ) { for ( iindex=1; iindex<=active_ntypes;iindex++) { /* Number_of_Gomp_Classes includes gomp class for whole body */ for ( cn=0; cn <Number_of_Gomp_Classes; cn++ ) { if ( LookUp[iindex].mark != NEG ) { ksumlevel = SumGompLevel(cn,iindex); if ( IsGompSumOverFlow(ksumlevel,cn)) { Memory = False; return; } NGomp(cn,ksumlevel) += CN[iindex]; /* GompRuleIndex=0 is for whole body */ } } /* micro class add VE and CA cells */ cn = Number_of_Gomp_Classes; ksumlevel = SumGompLevel(cn,iindex); if ( (iindex > pre_ntypes ) && IsGompSumOverFlow(ksumlevel,cn)){ Memory = false; return; } NGomp(cn,ksumlevel) += CN[iindex]; } } while((timevec[cellpitime] > t) && (timevec[cellpitime] < t + delta_t) && (cellpitime <= nallts)) cellpitime++; /* For each sample, the cell population is got at time EndT. */ bigEndT = EndT + delta_t / 2; while ( t < bigEndT ) { /*for speed sake, only update cell counts if patient isn't cured*/ if (Cured != True) { if (NextPBin(&envnowl) == False ) { release_mem(SIM); Memory=False; #ifdef DLL MessageBox(NULL,"Sorry. The total number of cell types has exceeded the memory limits, Please reduce the number of levels or number of classes. Try again.","treat.dll",MB_ICONEXCLAMATION | MB_OK); #else printf("Sorry. The total number of cell types has exceeded the memory limits\n"); #endif return; } if ((t >= timevec[cellpitime] ) && ( timevec[cellpitime] < t+delta_t) && (cellpitime <= nallts)) { for ( itype = 1; itype <= active_ntypes; itype++ ) { if ( timesurv(cellpitime,itype,envnowl) < 1.0 ) { jjj = timesurv(cellpitime,itype,envnowl); nDescOfItype(itype) = grand_b_n( CN[itype], timesurv(cellpitime,itype,envnowl) ) - CN[itype]; if (Update_CN_NGomp(itype,envnowl)== false ){ release_mem(SIM); Memory=False; #ifdef DLL MessageBox(NULL,"Sorry. The total number of cell types has exceeded the memory limits, Please reduce the number of levels or number of classes. Try again.","treat.dll",MB_ICONEXCLAMATION | MB_OK); #else printf("Sorry. The total number of cell types has exceeded the memory limits\n"); #endif return ; } //should send treatment event right here //also, send plot update event } } if (CheckForTreatment()) PlotHandler(); CheckForTox(); cellpitime++; } } /* check for any toxicity events */ /*#ifdef DLL*/ CheckForTox(); /* call here for CheckBBRules */ CheckBBRules(); ResetBBEveryDeltaT(); //do this in case the enviroment was changed by a rule. envnowl = nowenv; // CheckForTreatment(); if ((HasGuaranteeTimeChecked == False) && (nconds >0)) { CheckGuaranteeTime(); } if ( TrialSim == False || TSFirstTreatmentHappened == True ) check_events(); /*#endif */ if (( t >= BeginPlotTime) && (t <= EndPlotTime)) { if ( PrintLoopVar == PrintGap) { if (nrepetitions == 1) { if (Cured != True) { /*#ifdef DLL */ //AddToCellQ(); PlotHandler(); #ifdef DLL if (SleepTime != 0) { if (SleepTime != -1) Sleep(SleepTime); else while(SleepTime == -1) Sleep(0); } #endif /*#else*/ #ifdef TEST /* fprintf(out,"%5.3e",t);*/ fprintf(out,"%5.3e [%d]",t, active_ntypes); #endif for (itype = 1; itype <= active_ntypes; itype++ ) { #ifdef TEST /* fprintf(out," %5.2e",CN[itype]); */ fprintf(out," %5.2e (%d,%s)",CN[itype],LookUp[itype].LookUpId,cellname(itype)); fflush(out); #endif } #ifdef TEST fprintf(out,"\n"); #endif /*#endif*/ }/* close cured */ if ((Cured == True) && (SendCellCountOneTime == True)) { // AddToCellQ(); PlotHandler(); SendCellCountOneTime = False; } } /* close nrepetions */ PrintLoopVar = 1; }/* printloopvar */ else PrintLoopVar++; }/*begin and end plot time */ /*#ifdef DLL*/ /* if (nrepetitions == 1) { if (snow++ == GiveTimeCount) { snow = 0; Sleep(0); } } */ /* check to see if patient has died, if so end simulation */ if ((Dead == True) || (EndSim == True)) { release_mem(SIM); return; } /* #endif */ #ifdef TEST if ( nrepetitions == 1 ) { if (( t >= 5.0 && t < 5.0 + delta_t ) || ( t >= 10.0 && t < 10.0 + delta_t ) || ( t >= 15.0 && t < 15.0 + delta_t ) || ( t >= 20.0 && t < 20.0 + delta_t ) || ( t >= 25.0 && t < 25.0 + delta_t ) || ( t >= 30.0 && t < 30.0 + delta_t ) || ( t >= 31.0 && t < 31.0 + delta_t ) || ( t >= 32.0 && t < 32.0 + delta_t ) || ( t >= 33.0 && t < 33.0 + delta_t ) || ( t >= 34.0 && t < 34.0 + delta_t ) || ( t >= 35.0 && t < 35.0 + delta_t ) || ( t >= 36.0 && t < 36.0 + delta_t ) || ( t >= 37.0 && t < 37.0 + delta_t ) || ( t >= 38.0 && t < 38.0 + delta_t ) || ( t >= 39.0 && t < 39.0 + delta_t ) || ( t >= 40.0 && t < 40.0 + delta_t ) || ( t >= 41.0 && t < 41.0 + delta_t ) || ( t >= 42.0 && t < 42.0 + delta_t ) || ( t >= 43.0 && t < 43.0 + delta_t ) || ( t >= 44.0 && t < 44.0 + delta_t ) || ( t >= 45.0 && t < 45.0 + delta_t )) { printf("At time %lf cell types = %d systime %d\n",t,active_ntypes,time(&stime)-saitime); } } #endif t = t+delta_t; } #ifdef TEST if ((GuaranteeReset == false) && ( nrepetitions > 1 )) { if ( ntypes > 10 ) { for (iindex =1;iindex<= active_ntypes;iindex++) fprintf(out,"%e ",CN[iindex]); fprintf(out,"\n"); } else { /* for pgf test, get rearranged output including zero cell counts */ for (iindex =1;iindex<= active_ntypes;iindex++) { itype = iindex-1; do { itype++; if ((int)LookUp[iindex].LookUpId == itype ) fprintf(out,"%e ",CN[itype]); else fprintf(out,"%e ",ZERO); } while ((int)LookUp[iindex].LookUpId != itype); } for (iindex = LookUp[active_ntypes].LookUpId+1;iindex<=(int)ntypes ;iindex++) fprintf(out,"%e ",ZERO); fprintf(out,"\n"); } } fclose(out); #endif /*#ifdef DLL*/ /* if patient didn't die and has cells less than diagnosis, then NED event */ if (GuaranteeReset == False) { TotalCells = AllCells(); sprintf(stemp,"%e",TotalCells); /* if(TotalCells < diagnosis_threshold)*/ if (DiagnosedNow == False ) { /*if patient didn't die and has cells less than diagnosis, // then an end of followup with NED event */ AddToEventQ((t-delta_t),EFUNEDEVENT,stemp,".","."); } else { /* Patient didn't die, and had a diagnosable tumor // so add an end of follow up event with tumor */ AddToEventQ((t - delta_t),EFUTUMEVENT,stemp,".","."); } /*//if a CR or PR is pending, but the simulation ended before it couldn't //be checked after the TumorExamInterval is up, post it now.*/ if (CompleteResponse.checked == True) AddToEventQ(CompleteResponse.time,CREVENT,".",".","."); else if (PartialResponse.checked == True) AddToEventQ(PartialResponse.time,RESPONSEEVENT,".",".","."); } /* // else // AddToEventQ((t - delta_t),NORESPONSEEVENT,".",".",".");*/ /*#endif */ SimRunning = False; release_mem(SIM); return; }
int main(int argc, char **argv) { struct rnndb *db; int i, j; if (argc < 2) { fprintf(stderr, "Usage:\n\theadergen database-file\n"); exit(1); } rnn_init(); db = rnn_newdb(); rnn_parsefile (db, argv[1]); rnn_prepdb (db); for(i = 0; i < db->filesnum; ++i) { char *dstname = malloc(strlen(db->files[i]) + 3); char *pretty; strcpy(dstname, db->files[i]); strcat(dstname, ".h"); struct fout f = { db->files[i], fopen(dstname, "w") }; if (!f.file) { perror(dstname); exit(1); } free(dstname); pretty = strrchr(f.name, '/'); if (pretty) pretty += 1; else pretty = f.name; f.guard = strdup(pretty); for (j = 0; j < strlen(f.guard); j++) if (isalnum(f.guard[j])) f.guard[j] = toupper(f.guard[j]); else f.guard[j] = '_'; ADDARRAY(fouts, f); printhead(f, db); } for (i = 0; i < db->enumsnum; i++) { if (db->enums[i]->isinline) continue; int j; for (j = 0; j < db->enums[i]->valsnum; j++) printvalue (db->enums[i]->vals[j], 0); } for (i = 0; i < db->bitsetsnum; i++) { if (db->bitsets[i]->isinline) continue; int j; for (j = 0; j < db->bitsets[i]->bitfieldsnum; j++) printbitfield (db->bitsets[i]->bitfields[j], 0); } for (i = 0; i < db->domainsnum; i++) { if (db->domains[i]->size) printdef (db->domains[i]->fullname, "SIZE", 0, db->domains[i]->size, db->domains[i]->file); int j; for (j = 0; j < db->domains[i]->subelemsnum; j++) { printdelem(db->domains[i]->subelems[j], 0); } } for(i = 0; i < foutsnum; ++i) { fprintf (fouts[i].file, "\n#endif /* %s */\n", fouts[i].guard); } return db->estatus; }
void bcal_performance(const bcdesc_t* bcd){ bcdesc_t bc; memcpy_P(&bc, bcd, sizeof(bcdesc_t)); uint8_t ctx[bc.ctxsize_B]; uint8_t data[(bc.blocksize_b+7)/8]; uint16_t keysize = get_keysize(bc.valid_keysize_desc); uint8_t key[(keysize+7)/8]; uint64_t t; uint8_t i; if(bc.type!=BCDESC_TYPE_BLOCKCIPHER) return; calibrateTimer(); print_overhead(); cli_putstr_P(PSTR("\r\n\r\n === ")); cli_putstr_P(bc.name); cli_putstr_P(PSTR(" performance === " "\r\n type: blockcipher" "\r\n keysize (bits): ")); printvalue(keysize); cli_putstr_P(PSTR("\r\n ctxsize (bytes): ")); printvalue(bc.ctxsize_B); cli_putstr_P(PSTR("\r\n blocksize (bits): ")); printvalue(bc.blocksize_b); t=0; if(bc.init.init1){ if((bc.flags&BC_INIT_TYPE)==BC_INIT_TYPE_1){ for(i=0; i<32; ++i){ startTimer(0); START_TIMER; (bc.init.init1)(key, &ctx); STOP_TIMER; t += stopTimer(); if(i!=31 && bc.free){ bc.free(&ctx); } } } else { for(i=0; i<32; ++i){ startTimer(0); START_TIMER; (bc.init.init2)(key, keysize, &ctx); STOP_TIMER; t += stopTimer(); if(i!=31 && bc.free){ bc.free(&ctx); } } } t>>=5; cli_putstr_P(PSTR("\r\n init (cycles): ")); printvalue(t); } t=0; for(i=0; i<32; ++i){ startTimer(0); START_TIMER; bc.enc.enc1(data, &ctx); STOP_TIMER; t += stopTimer(); } t>>=5; cli_putstr_P(PSTR("\r\n encrypt (cycles): ")); printvalue(t); t=0; for(i=0; i<32; ++i){ startTimer(0); START_TIMER; bc.dec.dec1(data, &ctx); STOP_TIMER; t += stopTimer(); } t>>=5; cli_putstr_P(PSTR("\r\n decrypt (cycles): ")); printvalue(t); if(bc.free){ bc.free(&ctx); } }
void bcal_stacksize(const bcdesc_t* bcd){ bcdesc_t bc; stack_measuring_ctx_t smctx; memcpy_P(&bc, bcd, sizeof(bcdesc_t)); uint8_t ctx[bc.ctxsize_B]; uint8_t data[(bc.blocksize_b+7)/8]; uint16_t keysize = get_keysize(bc.valid_keysize_desc); uint8_t key[(keysize+7)/8]; uint16_t t1, t2; if(bc.type!=BCDESC_TYPE_BLOCKCIPHER) return; cli_putstr_P(PSTR("\r\n\r\n === ")); cli_putstr_P(bc.name); cli_putstr_P(PSTR(" stack-usage === ")); if(bc.init.init1){ if((bc.flags&BC_INIT_TYPE)==BC_INIT_TYPE_1){ cli(); stack_measure_init(&smctx, PATTERN_A); bc.init.init1(&ctx, key); t1 = stack_measure_final(&smctx); stack_measure_init(&smctx, PATTERN_B); bc.init.init1(&ctx, key); t2 = stack_measure_final(&smctx); sei(); } else { cli(); stack_measure_init(&smctx, PATTERN_A); bc.init.init2(&ctx, keysize, key); t1 = stack_measure_final(&smctx); stack_measure_init(&smctx, PATTERN_B); bc.init.init2(&ctx, keysize, key); t2 = stack_measure_final(&smctx); sei(); } t1 = (t1>t2)?t1:t2; cli_putstr_P(PSTR("\r\n init (bytes): ")); printvalue((unsigned long)t1); } cli(); stack_measure_init(&smctx, PATTERN_A); bc.enc.enc1(data, &ctx); t1 = stack_measure_final(&smctx); stack_measure_init(&smctx, PATTERN_B); bc.enc.enc1(data, &ctx); t2 = stack_measure_final(&smctx); sei(); t1 = (t1>t2)?t1:t2; cli_putstr_P(PSTR("\r\n encBlock (bytes): ")); printvalue((unsigned long)t1); cli(); stack_measure_init(&smctx, PATTERN_A); bc.dec.dec1(data, &ctx); t1 = stack_measure_final(&smctx); stack_measure_init(&smctx, PATTERN_B); bc.dec.dec1(data, &ctx); t2 = stack_measure_final(&smctx); sei(); t1 = (t1>t2)?t1:t2; cli_putstr_P(PSTR("\r\n decBlock (bytes): ")); printvalue((unsigned long)t1); if(bc.free){ bc.free(&ctx); } }