static _ctx * _create_ctx(void) { _ctx *ctx; ctx = flget(flctx); if (!ctx) return NULL; ctx->cs = screate(100); if (!ctx->cs) return NULL; ctx->pits = htcreate(HT_PIT_SIZE); if (!ctx->pits) return NULL; ctx->sched_cnt = 0; ctx->id = 0; ctx->tid = 0; ctx->name = NULL; ctx->t0 = tickcount(); ctx->rec_levels = htcreate(HT_RLEVEL_SIZE); if (!ctx->rec_levels) return NULL; return ctx; }
static int _init_profiler(void) { // already initialized? only after clear_stats() and first time, this flag // will be unset. if (!yappinitialized) { contexts = htcreate(HT_CTX_SIZE); if (!contexts) goto error; flpit = flcreate(sizeof(_pit), FL_PIT_SIZE); if (!flpit) goto error; flctx = flcreate(sizeof(_ctx), FL_CTX_SIZE); if (!flctx) goto error; yappinitialized = 1; } return 1; error: if (contexts) { htdestroy(contexts); contexts = NULL; } if (flpit) { fldestroy(flpit); flpit = NULL; } if (flctx) { fldestroy(flctx); flctx = NULL; } return 0; }
int backend_sfcb(class_chain * cls_chain, class_chain * inst_chain, qual_chain * qual_chain, const char * outfile, const char * outdir, const char * ns, unsigned options, const char * extraopts) { hashentry * classes_done = htcreate("SFCB"); short test = 1; char *tp = (char*)&test; struct utsname uName; static int ix86=1,first=1; FILE * class_file = NULL;// = fopen(outfile, "w"); if(cls_chain && cls_chain->class_item) { class_file = fopen(outfile, "w"); } if(outdir) repfn = strdup(outdir); else repfn = strdup("./"); if (first) { uname(&uName); if (uName.machine[0]!='i' || strcmp(uName.machine+2,"86")!=0) ix86=0; first=0; } /*if (class_file == NULL) { return 1; }*/ sfcb_options = options; if (strchr(extraopts,'Q')) { sfcb_options |= BACKEND_SFCB_NO_QUALIFIERS; sfcb_options |= BACKEND_SFCB_REDUCED_QUALIFIERS; } else if (strchr(extraopts,'q')) { sfcb_options |= BACKEND_SFCB_REDUCED_QUALIFIERS; if (sfcb_options & BACKEND_VERBOSE) { fprintf(stderr," information: omitting selected qualifiers.\n"); } } if (tp[0]==1) endianMode = SFCB_LITTLE_ENDIAN; else if (tp[1]==1) endianMode = SFCB_BIG_ENDIAN; if (strstr(extraopts,"P32")) { if (ix86) { char libName[]="libsfcObjectImplSwapI32toP32.so"; char entryNameClass[]="swapI32toP32Class"; char entryNameInstance[]="swapI32toP32Instance"; char entryNameQualifier[]="swapI32toP32QualifierDeclaration"; char *error; endianMode=SFCB_BIG_ENDIAN; swapLib=dlopen(libName, RTLD_LAZY); if (swapLib==NULL) { fprintf (stderr, "--- swap library not found - %s\n", dlerror()); exit(16); } dlerror(); swapEntryClass = dlsym(swapLib, entryNameClass); swapEntryInstance = dlsym(swapLib, entryNameInstance); swapEntryQualifier = dlsym(swapLib, entryNameQualifier); if ((error = dlerror()) != NULL) { fprintf (stderr, "--- swap library entry not found - %s\n", error); exit(16); } swapMode=1; } else { fprintf(stderr,"--- backend_sfcb: P32 option can only be used on ix86 class machines\n"); exit(16); } } if(class_file) { int rep_type = (opt_reduced) ? ClTypeClassReducedRep : ClTypeClassRep; sfcb_add_version(class_file, rep_type, endianMode); } while (cls_chain && cls_chain->class_item) { if (sfcb_add_class(class_file, classes_done, cls_chain->class_item,endianMode)) { return 1; } cls_chain = cls_chain -> class_next; } while (inst_chain && inst_chain->class_item) { if (sfcb_add_instance(inst_chain->class_item, ns)) { return 1; } inst_chain = inst_chain -> class_next; } #ifdef HAVE_QUALREP while (qual_chain && qual_chain->qual_qual) { if(sfcb_add_qualifier(qual_chain->qual_qual, ns)) { return 1; } qual_chain = qual_chain -> qual_next; } #endif if(class_file) fclose(class_file); return 0; }