diff --git a/C/absmi.c b/C/absmi.c index 705fee6f4..50a9d993f 100644 --- a/C/absmi.c +++ b/C/absmi.c @@ -10,8 +10,13 @@ * * * File: absmi.c * * comments: Portable abstract machine interpreter * -* Last rev: $Date: 2006-01-02 02:16:17 $,$Author: vsc $ * +* Last rev: $Date: 2006-01-17 14:10:40 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.191 2006/01/02 02:16:17 vsc +* support new interface between YAP and GMP, so that we don't rely on our own +* allocation routines. +* Several big fixes. +* * Revision 1.190 2005/12/23 00:20:13 vsc * updates to gprof * support for __POWER__ @@ -7364,6 +7369,8 @@ Yap_absmi(int inp) #endif /* LOW_LEVEL_TRACE */ } JMPNext(); + ENDBOp(); + /************************************************************************\ * Try / Retry / Trust for main indexing blocks * diff --git a/C/attvar.c b/C/attvar.c index bb0d8eb8d..170b57205 100644 --- a/C/attvar.c +++ b/C/attvar.c @@ -910,6 +910,18 @@ p_attvar_bound(void) !IsUnboundVar(&((attvar_record *)VarOfTerm(t))->Done)); } +static Int +p_void_term(void) +{ + return Yap_unify(ARG1,TermVoidAtt); +} + +static Int +p_free_term(void) +{ + return Yap_unify(ARG1,TermFreeTerm); +} + #else static Int @@ -932,18 +944,6 @@ p_attvar_bound(void) #endif /* COROUTINING */ -static Int -p_void_term(void) -{ - return Yap_unify(ARG1,TermVoidAtt); -} - -static Int -p_free_term(void) -{ - return Yap_unify(ARG1,TermFreeTerm); -} - void Yap_InitAttVarPreds(void) { Term OldCurrentModule = CurrentModule; @@ -966,9 +966,9 @@ void Yap_InitAttVarPreds(void) Yap_InitCPred("del_all_module_atts", 2, p_del_atts, 0); Yap_InitCPred("rm_att", 4, p_rm_att, 0); Yap_InitCPred("bind_attvar", 1, p_bind_attvar, SafePredFlag); + Yap_InitCPred("modules_with_attributes", 2, p_modules_with_atts, SafePredFlag); Yap_InitCPred("void_term", 1, p_void_term, SafePredFlag); Yap_InitCPred("free_term", 1, p_free_term, SafePredFlag); - Yap_InitCPred("modules_with_attributes", 2, p_modules_with_atts, SafePredFlag); #endif /* COROUTINING */ Yap_InitCPred("all_attvars", 1, p_all_attvars, 0); CurrentModule = OldCurrentModule; diff --git a/C/dlmalloc.c b/C/dlmalloc.c index cb549ac2b..1c41c0986 100755 --- a/C/dlmalloc.c +++ b/C/dlmalloc.c @@ -2544,6 +2544,9 @@ struct mallinfo mALLINFo() mi.fsmblks = fastavail; mi.keepcost = chunksize(av->top); mi.usmblks = av->max_total_mem; + /* YAP doesn't have special mmapped regions */ + mi.hblkhd = 0L; + mi.hblks = 0L; return mi; } diff --git a/C/gprof.c b/C/gprof.c index e6c7c689f..56a1da1d5 100644 --- a/C/gprof.c +++ b/C/gprof.c @@ -11,8 +11,13 @@ * File: gprof.c * * comments: Interrupt Driven Profiler * * * -* Last rev: $Date: 2005-12-23 00:20:13 $,$Author: vsc $ * +* Last rev: $Date: 2006-01-17 14:10:40 $,$Author: vsc $ * * $Log: not supported by cvs2svn $ +* Revision 1.2 2005/12/23 00:20:13 vsc +* updates to gprof +* support for __POWER__ +* Try to saveregs before longjmp. +* * Revision 1.1 2005/12/17 03:26:38 vsc * move event profiler outside from stdpreds.c * * @@ -43,320 +48,6 @@ static Int ProfCalls, ProfGCs, ProfHGrows, ProfSGrows, ProfMallocs, ProfOn, Prof static char *DIRNAME=NULL; -char *set_profile_dir(char *); -char *set_profile_dir(char *name){ -int size=0; - - if (name!=NULL) { - size=strlen(name)+1; - if (DIRNAME!=NULL) free(DIRNAME); - DIRNAME=malloc(size); - if (DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); } - strcpy(DIRNAME,name); - } - if (DIRNAME==NULL) { - do { - if (DIRNAME!=NULL) free(DIRNAME); - size+=20; - DIRNAME=malloc(size); - if (DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); } - } while (getcwd(DIRNAME, size-15)==NULL); - } - -return DIRNAME; -} - -char *profile_names(int); -char *profile_names(int k) { -static char *FNAME=NULL; -int size=200; - - if (DIRNAME==NULL) set_profile_dir(NULL); - size=strlen(DIRNAME)+40; - if (FNAME!=NULL) free(FNAME); - FNAME=malloc(size); - if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); } - strcpy(FNAME,DIRNAME); - - if (k==PROFILING_FILE) { - sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid()); - } else { - sprintf(FNAME,"%s/PROFPREDS_%d",FNAME,getpid()); - } - - // printf("%s\n",FNAME); - return FNAME; -} - -void del_profile_files(void); -void del_profile_files() { - if (DIRNAME!=NULL) { - remove(profile_names(PROFPREDS_FILE)); - remove(profile_names(PROFILING_FILE)); - } -} - -void -Yap_inform_profiler_of_clause(yamop *code_start, yamop *code_end, PredEntry *pe,int index_code) { -static Int order=0; - - ProfPreds++; - ProfOn = TRUE; - if (FPreds != NULL) { - Int temp; - order++; - if (index_code) temp=-order; else temp=order; - fprintf(FPreds,"+%p %p %p %ld",code_start,code_end, pe, (long int)temp); -#if MORE_INFO_FILE - if (pe->FunctorOfPred->KindOfPE==47872) { - if (pe->ArityOfPE) { - fprintf(FPreds," %s/%d", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE); - } else { - fprintf(FPreds," %s",RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE); - } - } -#endif - fprintf(FPreds,"\n"); - } - ProfOn = FALSE; -} - -typedef struct clause_entry { - yamop *beg, *end; - PredEntry *pp; - UInt pcs; /* counter with total for each clause */ - UInt pca; /* counter with total for each predicate (repeated for each clause)*/ - int ts; /* start end timestamp towards retracts, eventually */ -} clauseentry; - -static int -cl_cmp(const void *c1, const void *c2) -{ - const clauseentry *cl1 = (const clauseentry *)c1; - const clauseentry *cl2 = (const clauseentry *)c2; - if (cl1->beg > cl2->beg) return 1; - if (cl1->beg < cl2->beg) return -1; - return 0; -} - -static int -p_cmp(const void *c1, const void *c2) -{ - const clauseentry *cl1 = (const clauseentry *)c1; - const clauseentry *cl2 = (const clauseentry *)c2; - if (cl1->pp > cl2->pp) return 1; - if (cl1->pp < cl2->pp) return -1; - - /* else same pp, but they are always different on the ts */ - if (cl1->ts > cl2->ts) return 1; - else return -1; -} - -static clauseentry * -search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) { - Int i, j, f, l; - f = 0; l = (end-beg); - i = l/2; - while (TRUE) { - if (beg[i].beg > pc_ptr) { - l = i-1; - if (l < f) { - return NULL; - } - j = i; - i = (f+l)/2; - } else if (beg[i].end < pc_ptr) { - f = i+1; - if (f > l) { - return NULL; - } - i = (f+l)/2; - } else if (beg[i].beg <= pc_ptr && beg[i].end >= pc_ptr) { - return (&beg[i]); - } else { - return NULL; - } - } -} - -extern void Yap_InitAbsmi(void); -extern int rational_tree_loop(CELL *pt0, CELL *pt0_end, CELL **to_visit0); - -static Int profend(void); - -static int -showprofres(UInt type) { - clauseentry *pr, *t, *t2; - UInt count=0, ProfCalls=0, InGrowHeap=0, InGrowStack=0, InGC=0, InError=0, InUnify=0, InCCall=0; - yamop *pc_ptr,*y; void *oldpc; - - profend(); /* Make sure profiler has ended */ - - /* First part: Read information about predicates and store it on yap trail */ - - FPreds=fopen(profile_names(PROFPREDS_FILE),"r"); - - if (FPreds == NULL) { printf("Sorry, profiler couldn't find PROFPREDS file. \n"); return FALSE; } - - ProfPreds=0; - pr=(clauseentry *) TR; - while (fscanf(FPreds,"+%p %p %p %d",&(pr->beg),&(pr->end),&(pr->pp),&(pr->ts)) > 0){ - int c; - pr->pcs = 0L; - pr++; - if (pr > (clauseentry *)Yap_TrailTop - 1024) { - Yap_growtrail(64 * 1024L, FALSE); - } - ProfPreds++; - - do { - c=fgetc(FPreds); - } while(c!=EOF && c!='\n'); - } - fclose(FPreds); - if (ProfPreds==0) return(TRUE); - - qsort((void *)TR, ProfPreds, sizeof(clauseentry), cl_cmp); - - /* Second part: Read Profiling to know how many times each predicate has been profiled */ - - FProf=fopen(profile_names(PROFILING_FILE),"r"); - if (FProf==NULL) { printf("Sorry, profiler couldn't find PROFILING file. \n"); return FALSE; } - - t2=NULL; - ProfCalls=0; - while(fscanf(FProf,"%p %p\n",&oldpc, &pc_ptr) >0){ - if (type<10) ProfCalls++; - - if (oldpc!=0 && type<=2) { - if ((unsigned long)oldpc< 70000) { - if ((unsigned long) oldpc & GrowHeapMode) { InGrowHeap++; continue; } - if ((unsigned long)oldpc & GrowStackMode) { InGrowStack++; continue; } - if ((unsigned long)oldpc & GCMode) { InGC++; continue; } - if ((unsigned long)oldpc & (ErrorHandlingMode | InErrorMode)) { InError++; continue; } - } - if (oldpc>(void *) rational_tree_loop && oldpc<(void *) Yap_InitAbsmi) { InUnify++; continue; } - y=(yamop *) ((long) pc_ptr-20); - if (y->opc==Yap_opcode(_call_cpred) || y->opc==Yap_opcode(_call_usercpred)) { - InCCall++; /* I Was in a C Call */ - pc_ptr=y; - /* - printf("Aqui está um call_cpred(%p) \n",y->u.sla.sla_u.p->cs.f_code); - for(i=0;i<_std_top && pc_ptr->opc!=Yap_ABSMI_OPCODES[i];i++); - printf("Outro syscall diferente %s\n", Yap_op_names[i]); - */ - continue; - } - /* I should never get here, but since I'm, it is certanly Unknown Code, so - continue running to try to count it as Prolog Code */ - } - - t=search_pc_pred(pc_ptr,(clauseentry *)TR,pr); - if (t!=NULL) { /* pc was found */ - if (type<10) t->pcs++; - else { - if (t->pp==(PredEntry *)type) { - ProfCalls++; - if (t2!=NULL) t2->pcs++; - } - } - t2=t; - } - - } - - fclose(FProf); - if (ProfCalls==0) return(TRUE); - - /*I have the counting by clauses, but we also need them by predicate */ - qsort((void *)TR, ProfPreds, sizeof(clauseentry), p_cmp); - t = (clauseentry *)TR; - while (t < pr) { - UInt calls=t->pcs; - - t2=t+1; - while(t2pp==t->pp) { - calls+=t2->pcs; - t2++; - } - while(tpca=calls; - t++; - } - } - - /* counting done: now it is time to present the results */ - fflush(stdout); - - /* - if (type>10) { - PredEntry *myp = (PredEntry *)type; - if (myp->FunctorOfPred->KindOfPE==47872) { - printf("Details on predicate:"); - printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE); - printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE); - if (myp->ArityOfPE) printf("/%d\n",myp->ArityOfPE); - } - type=1; - } - */ - - if (type==0 || type==1 || type==3) { /* Results by predicate */ - t = (clauseentry *)TR; - while (t < pr) { - UInt calls=t->pca; - PredEntry *myp = t->pp; - - if (calls && myp->FunctorOfPred->KindOfPE==47872) { - count+=calls; - printf("%p",myp); - printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE); - printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE); - if (myp->ArityOfPE) printf("/%d",myp->ArityOfPE); - printf(" -> %lu (%3.1f%c)\n",(unsigned long int)calls,(float) calls*100/ProfCalls,'%'); - } - while (tpp == myp) t++; - } - } else { /* Results by clauses */ - t = (clauseentry *)TR; - while (t < pr) { - if (t->pca!=0 && (t->ts>=0 || t->pcs!=0) && t->pp->FunctorOfPred->KindOfPE==47872) { - UInt calls=t->pcs; - if (t->ts<0) { /* join all index entries */ - t2=t+1; - while(t2pp==t->pp && t2->ts<0) { - t++; - calls+=t->pcs; - t2++; - } - printf("IDX"); - } else { - printf(" "); - } - count+=calls; - // printf("%p %p",t->pp, t->beg); - printf(" %s",RepAtom(AtomOfTerm(t->pp->ModuleOfPred))->StrOfAE); - printf(":%s",RepAtom(NameOfFunctor(t->pp->FunctorOfPred))->StrOfAE); - if (t->pp->ArityOfPE) printf("/%d",t->pp->ArityOfPE); - printf(" -> %lu (%3.1f%c)\n",(unsigned long int)calls,(float) calls*100/ProfCalls,'%'); - } - t++; - } - } - count=ProfCalls-(count+InGrowHeap+InGrowStack+InGC+InError+InUnify+InCCall); // Falta +InCCall - if (InGrowHeap>0) printf("%p sys: GrowHeap -> %lu (%3.1f%c)\n",(void *) GrowHeapMode,(unsigned long int)InGrowHeap,(float) InGrowHeap*100/ProfCalls,'%'); - if (InGrowStack>0) printf("%p sys: GrowStack -> %lu (%3.1f%c)\n",(void *) GrowStackMode,(unsigned long int)InGrowStack,(float) InGrowStack*100/ProfCalls,'%'); - if (InGC>0) printf("%p sys: GC -> %lu (%3.1f%c)\n",(void *) GCMode,(unsigned long int)InGC,(float) InGC*100/ProfCalls,'%'); - if (InError>0) printf("%p sys: ErrorHandling -> %lu (%3.1f%c)\n",(void *) ErrorHandlingMode,(unsigned long int)InError,(float) InError*100/ProfCalls,'%'); - if (InUnify>0) printf("%p sys: Unify -> %lu (%3.1f%c)\n",(void *) UnifyMode,(unsigned long int)InUnify,(float) InUnify*100/ProfCalls,'%'); - if (InCCall>0) printf("%p sys: C Code -> %lu (%3.1f%c)\n",(void *) CCallMode,(unsigned long int)InCCall,(float) InCCall*100/ProfCalls,'%'); - if (count>0) printf("Unknown:Unknown -> %lu (%3.1f%c)\n",(unsigned long int)count,(float) count*100/ProfCalls,'%'); - printf("Total of Calls=%lu \n",(unsigned long int)ProfCalls); - - return TRUE; -} - - typedef struct RB_red_blk_node { yamop *key; /* first address */ yamop *lim; /* end address */ @@ -871,14 +562,330 @@ RBDelete(rb_red_blk_node* z){ #endif } +char *set_profile_dir(char *); +char *set_profile_dir(char *name){ +int size=0; + + if (name!=NULL) { + size=strlen(name)+1; + if (DIRNAME!=NULL) free(DIRNAME); + DIRNAME=malloc(size); + if (DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); } + strcpy(DIRNAME,name); + } + if (DIRNAME==NULL) { + do { + if (DIRNAME!=NULL) free(DIRNAME); + size+=20; + DIRNAME=malloc(size); + if (DIRNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); } + } while (getcwd(DIRNAME, size-15)==NULL); + } + +return DIRNAME; +} + +char *profile_names(int); +char *profile_names(int k) { +static char *FNAME=NULL; +int size=200; + + if (DIRNAME==NULL) set_profile_dir(NULL); + size=strlen(DIRNAME)+40; + if (FNAME!=NULL) free(FNAME); + FNAME=malloc(size); + if (FNAME==NULL) { printf("Profiler Out of Mem\n"); exit(1); } + strcpy(FNAME,DIRNAME); + + if (k==PROFILING_FILE) { + sprintf(FNAME,"%s/PROFILING_%d",FNAME,getpid()); + } else { + sprintf(FNAME,"%s/PROFPREDS_%d",FNAME,getpid()); + } + + // printf("%s\n",FNAME); + return FNAME; +} + +void del_profile_files(void); +void del_profile_files() { + if (DIRNAME!=NULL) { + remove(profile_names(PROFPREDS_FILE)); + remove(profile_names(PROFILING_FILE)); + } +} + +void +Yap_inform_profiler_of_clause(yamop *code_start, yamop *code_end, PredEntry *pe,int index_code) { +static Int order=0; + + ProfPreds++; + ProfOn = TRUE; + if (FPreds != NULL) { + Int temp; + order++; + if (index_code) temp=-order; else temp=order; + fprintf(FPreds,"+%p %p %p %ld",code_start,code_end, pe, (long int)temp); +#if MORE_INFO_FILE + if (pe->FunctorOfPred->KindOfPE==47872) { + if (pe->ArityOfPE) { + fprintf(FPreds," %s/%d", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE); + } else { + fprintf(FPreds," %s",RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE); + } + } +#endif + fprintf(FPreds,"\n"); + } + ProfOn = FALSE; +} + +typedef struct clause_entry { + yamop *beg, *end; + PredEntry *pp; + UInt pcs; /* counter with total for each clause */ + UInt pca; /* counter with total for each predicate (repeated for each clause)*/ + int ts; /* start end timestamp towards retracts, eventually */ +} clauseentry; + +static int +cl_cmp(const void *c1, const void *c2) +{ + const clauseentry *cl1 = (const clauseentry *)c1; + const clauseentry *cl2 = (const clauseentry *)c2; + if (cl1->beg > cl2->beg) return 1; + if (cl1->beg < cl2->beg) return -1; + return 0; +} + +static int +p_cmp(const void *c1, const void *c2) +{ + const clauseentry *cl1 = (const clauseentry *)c1; + const clauseentry *cl2 = (const clauseentry *)c2; + if (cl1->pp > cl2->pp) return 1; + if (cl1->pp < cl2->pp) return -1; + + /* else same pp, but they are always different on the ts */ + if (cl1->ts > cl2->ts) return 1; + else return -1; +} + +static clauseentry * +search_pc_pred(yamop *pc_ptr,clauseentry *beg, clauseentry *end) { + Int i, j, f, l; + f = 0; l = (end-beg); + i = l/2; + while (TRUE) { + if (beg[i].beg > pc_ptr) { + l = i-1; + if (l < f) { + return NULL; + } + j = i; + i = (f+l)/2; + } else if (beg[i].end < pc_ptr) { + f = i+1; + if (f > l) { + return NULL; + } + i = (f+l)/2; + } else if (beg[i].beg <= pc_ptr && beg[i].end >= pc_ptr) { + return (&beg[i]); + } else { + return NULL; + } + } +} + +extern void Yap_InitAbsmi(void); +extern int rational_tree_loop(CELL *pt0, CELL *pt0_end, CELL **to_visit0); + +static Int profend(void); + +static int +showprofres(UInt type) { + clauseentry *pr, *t, *t2; + UInt count=0, ProfCalls=0, InGrowHeap=0, InGrowStack=0, InGC=0, InError=0, InUnify=0, InCCall=0; + yamop *pc_ptr,*y; void *oldpc; + + profend(); /* Make sure profiler has ended */ + + /* First part: Read information about predicates and store it on yap trail */ + + FPreds=fopen(profile_names(PROFPREDS_FILE),"r"); + + if (FPreds == NULL) { printf("Sorry, profiler couldn't find PROFPREDS file. \n"); return FALSE; } + + ProfPreds=0; + pr=(clauseentry *) TR; + while (fscanf(FPreds,"+%p %p %p %d",&(pr->beg),&(pr->end),&(pr->pp),&(pr->ts)) > 0){ + int c; + pr->pcs = 0L; + pr++; + if (pr > (clauseentry *)Yap_TrailTop - 1024) { + Yap_growtrail(64 * 1024L, FALSE); + } + ProfPreds++; + + do { + c=fgetc(FPreds); + } while(c!=EOF && c!='\n'); + } + fclose(FPreds); + if (ProfPreds==0) return(TRUE); + + qsort((void *)TR, ProfPreds, sizeof(clauseentry), cl_cmp); + + /* Second part: Read Profiling to know how many times each predicate has been profiled */ + + FProf=fopen(profile_names(PROFILING_FILE),"r"); + if (FProf==NULL) { printf("Sorry, profiler couldn't find PROFILING file. \n"); return FALSE; } + + t2=NULL; + ProfCalls=0; + while(fscanf(FProf,"%p %p\n",&oldpc, &pc_ptr) >0){ + if (type<10) ProfCalls++; + + if (oldpc!=0 && type<=2) { + if ((unsigned long)oldpc< 70000) { + if ((unsigned long) oldpc & GrowHeapMode) { InGrowHeap++; continue; } + if ((unsigned long)oldpc & GrowStackMode) { InGrowStack++; continue; } + if ((unsigned long)oldpc & GCMode) { InGC++; continue; } + if ((unsigned long)oldpc & (ErrorHandlingMode | InErrorMode)) { InError++; continue; } + } + if (oldpc>(void *) rational_tree_loop && oldpc<(void *) Yap_InitAbsmi) { InUnify++; continue; } + y=(yamop *) ((long) pc_ptr-20); + if (y->opc==Yap_opcode(_call_cpred) || y->opc==Yap_opcode(_call_usercpred)) { + InCCall++; /* I Was in a C Call */ + pc_ptr=y; + /* + printf("Aqui está um call_cpred(%p) \n",y->u.sla.sla_u.p->cs.f_code); + for(i=0;i<_std_top && pc_ptr->opc!=Yap_ABSMI_OPCODES[i];i++); + printf("Outro syscall diferente %s\n", Yap_op_names[i]); + */ + continue; + } + /* I should never get here, but since I'm, it is certanly Unknown Code, so + continue running to try to count it as Prolog Code */ + } + + t=search_pc_pred(pc_ptr,(clauseentry *)TR,pr); + if (t!=NULL) { /* pc was found */ + if (type<10) t->pcs++; + else { + if (t->pp==(PredEntry *)type) { + ProfCalls++; + if (t2!=NULL) t2->pcs++; + } + } + t2=t; + } + + } + + fclose(FProf); + if (ProfCalls==0) return(TRUE); + + /*I have the counting by clauses, but we also need them by predicate */ + qsort((void *)TR, ProfPreds, sizeof(clauseentry), p_cmp); + t = (clauseentry *)TR; + while (t < pr) { + UInt calls=t->pcs; + + t2=t+1; + while(t2pp==t->pp) { + calls+=t2->pcs; + t2++; + } + while(tpca=calls; + t++; + } + } + + /* counting done: now it is time to present the results */ + fflush(stdout); + + /* + if (type>10) { + PredEntry *myp = (PredEntry *)type; + if (myp->FunctorOfPred->KindOfPE==47872) { + printf("Details on predicate:"); + printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE); + printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE); + if (myp->ArityOfPE) printf("/%d\n",myp->ArityOfPE); + } + type=1; + } + */ + + if (type==0 || type==1 || type==3) { /* Results by predicate */ + t = (clauseentry *)TR; + while (t < pr) { + UInt calls=t->pca; + PredEntry *myp = t->pp; + + if (calls && myp->FunctorOfPred->KindOfPE==47872) { + count+=calls; + printf("%p",myp); + printf(" %s",RepAtom(AtomOfTerm(myp->ModuleOfPred))->StrOfAE); + printf(":%s",RepAtom(NameOfFunctor(myp->FunctorOfPred))->StrOfAE); + if (myp->ArityOfPE) printf("/%d",myp->ArityOfPE); + printf(" -> %lu (%3.1f%c)\n",(unsigned long int)calls,(float) calls*100/ProfCalls,'%'); + } + while (tpp == myp) t++; + } + } else { /* Results by clauses */ + t = (clauseentry *)TR; + while (t < pr) { + if (t->pca!=0 && (t->ts>=0 || t->pcs!=0) && t->pp->FunctorOfPred->KindOfPE==47872) { + UInt calls=t->pcs; + if (t->ts<0) { /* join all index entries */ + t2=t+1; + while(t2pp==t->pp && t2->ts<0) { + t++; + calls+=t->pcs; + t2++; + } + printf("IDX"); + } else { + printf(" "); + } + count+=calls; + // printf("%p %p",t->pp, t->beg); + printf(" %s",RepAtom(AtomOfTerm(t->pp->ModuleOfPred))->StrOfAE); + printf(":%s",RepAtom(NameOfFunctor(t->pp->FunctorOfPred))->StrOfAE); + if (t->pp->ArityOfPE) printf("/%d",t->pp->ArityOfPE); + printf(" -> %lu (%3.1f%c)\n",(unsigned long int)calls,(float) calls*100/ProfCalls,'%'); + } + t++; + } + } + count=ProfCalls-(count+InGrowHeap+InGrowStack+InGC+InError+InUnify+InCCall); // Falta +InCCall + if (InGrowHeap>0) printf("%p sys: GrowHeap -> %lu (%3.1f%c)\n",(void *) GrowHeapMode,(unsigned long int)InGrowHeap,(float) InGrowHeap*100/ProfCalls,'%'); + if (InGrowStack>0) printf("%p sys: GrowStack -> %lu (%3.1f%c)\n",(void *) GrowStackMode,(unsigned long int)InGrowStack,(float) InGrowStack*100/ProfCalls,'%'); + if (InGC>0) printf("%p sys: GC -> %lu (%3.1f%c)\n",(void *) GCMode,(unsigned long int)InGC,(float) InGC*100/ProfCalls,'%'); + if (InError>0) printf("%p sys: ErrorHandling -> %lu (%3.1f%c)\n",(void *) ErrorHandlingMode,(unsigned long int)InError,(float) InError*100/ProfCalls,'%'); + if (InUnify>0) printf("%p sys: Unify -> %lu (%3.1f%c)\n",(void *) UnifyMode,(unsigned long int)InUnify,(float) InUnify*100/ProfCalls,'%'); + if (InCCall>0) printf("%p sys: C Code -> %lu (%3.1f%c)\n",(void *) CCallMode,(unsigned long int)InCCall,(float) InCCall*100/ProfCalls,'%'); + if (count>0) printf("Unknown:Unknown -> %lu (%3.1f%c)\n",(unsigned long int)count,(float) count*100/ProfCalls,'%'); + printf("Total of Calls=%lu \n",(unsigned long int)ProfCalls); + + return TRUE; +} + + #define TestMode (GCMode | GrowHeapMode | GrowStackMode | ErrorHandlingMode | InErrorMode | AbortMode | MallocMode) extern int Yap_absmiEND(void); static void -prof_alrm(int signo, siginfo_t *si, ucontext_t *sc) +prof_alrm(int signo, siginfo_t *si, void *scv) { + #if __linux__ + ucontext_t *sc = (ucontext_t *)scv; #if (defined(i386) || defined(__amd64__)) void * oldpc=(void *) sc->uc_mcontext.gregs[14]; /* 14= REG_EIP */ #else @@ -886,6 +893,7 @@ prof_alrm(int signo, siginfo_t *si, ucontext_t *sc) #endif #else #if __POWERPC__ || _POWER + ucontext_t *sc = (ucontext_t *)scv; void * oldpc=(void *) sc->uc_mcontext->ss.srr0; /* 14= POWER PC */ #else void *NULL; diff --git a/CLPBN/Makefile.in b/CLPBN/Makefile.in index 3e9bdb65a..45476b1d3 100644 --- a/CLPBN/Makefile.in +++ b/CLPBN/Makefile.in @@ -25,28 +25,41 @@ srcdir=@srcdir@ CLPBN_TOP= $(srcdir)/clpbn.yap +CLPBN_SRCDIR = $(srcdir)/clpbn + +CLPBN_EXDIR = $(srcdir)/clpbn/examples + CLPBN_PROGRAMS= \ - $(srcdir)/clpbn/aggregates.yap \ - $(srcdir)/clpbn/bnt.yap \ - $(srcdir)/clpbn/discrete_utils.yap \ - $(srcdir)/clpbn/evidence.yap \ - $(srcdir)/clpbn/gibbs.yap \ - $(srcdir)/clpbn/graphs.yap \ - $(srcdir)/clpbn/graphviz.yap \ - $(srcdir)/clpbn/hmm.yap \ - $(srcdir)/clpbn/topsort.yap \ - $(srcdir)/clpbn/utils.yap \ - $(srcdir)/clpbn/vel.yap \ - $(srcdir)/clpbn/viterbi.yap \ - $(srcdir)/clpbn/xbif.yap + $(CLPBN_SRCDIR)/aggregates.yap \ + $(CLPBN_SRCDIR)/bnt.yap \ + $(CLPBN_SRCDIR)/discrete_utils.yap \ + $(CLPBN_SRCDIR)/evidence.yap \ + $(CLPBN_SRCDIR)/gibbs.yap \ + $(CLPBN_SRCDIR)/graphs.yap \ + $(CLPBN_SRCDIR)/graphviz.yap \ + $(CLPBN_SRCDIR)/hmm.yap \ + $(CLPBN_SRCDIR)/topsort.yap \ + $(CLPBN_SRCDIR)/utils.yap \ + $(CLPBN_SRCDIR)/vel.yap \ + $(CLPBN_SRCDIR)/viterbi.yap \ + $(CLPBN_SRCDIR)/xbif.yap CLPBN_EXAMPLES= + $(CLPBN_EXDIR)/cg.yap \ + $(CLPBN_EXDIR)/School/README \ + $(CLPBN_EXDIR)/School/evidence_128.yap \ + $(CLPBN_EXDIR)/School/schema.yap \ + $(CLPBN_EXDIR)/School/school_128.yap \ + $(CLPBN_EXDIR)/School/school_32.yap \ + $(CLPBN_EXDIR)/School/school_64.yap \ + $(CLPBN_EXDIR)/School/tables.yap \ install: $(CLBN_TOP) $(CLBN_PROGRAMS) $(CLPBN_PROGRAMS) mkdir -p $(DESTDIR)$(SHAREDIR)/clpbn - mkdir -p $(DESTDIR)$(SHAREDIR)/clpbn/examples + mkdir -p $(DESTDIR)$(SHAREDIR)/examples + mkdir -p $(DESTDIR)$(SHAREDIR)/clpbn/examples/School for h in $(CLPBN_TOP); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR); done for h in $(CLPBN_PROGRAMS); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpbn; done -# for h in $(CLPBN_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/clpbn/examples; done + for h in $(CLPBN_EXAMPLES); do $(INSTALL_DATA) $$h $(DESTDIR)$(SHAREDIR)/examples; done diff --git a/H/Regs.h b/H/Regs.h index 9b91703f1..3d2c0d2c8 100644 --- a/H/Regs.h +++ b/H/Regs.h @@ -10,7 +10,7 @@ * File: Regs.h * * mods: * * comments: YAP abstract machine registers * -* version: $Id: Regs.h,v 1.32 2005-12-23 00:20:14 vsc Exp $ * +* version: $Id: Regs.h,v 1.33 2006-01-17 14:10:40 vsc Exp $ * *************************************************************************/ @@ -185,6 +185,10 @@ extern int Yap_stack_overflows; #define H0 Yap_REGS.H0_ /* base of heap (global) stack */ #define LCL0 Yap_REGS.LCL0_ /* local stack base */ +#define YENV2MEM +#define YENV_ADDRESS (&(YENV)) +#define MEM2YENV + #if defined(__GNUC__) && defined(sparc) && !defined(__NetBSD__) && !defined(THREADS) #define P Yap_REGS.P_ /* prolog machine program counter */ @@ -540,6 +544,16 @@ register CELL *YENV asm ("r19"); register tr_fr_ptr TR asm ("r20"); #define P Yap_REGS.P_ /* prolog machine program counter */ +#undef YENV2MEM +#undef YENV_ADDRESS (&(YENV)) +#undef MEM2YENV + +#define YENV2MEM { CELL *YENV_MEM = YENV +#define YENV_ADDRESS (&YENV_MEM) +#define MEM2YENV YENV = YENV_MEM; } + + + EXTERN inline void save_machine_regs(void) { Yap_REGS.CreepFlag_ = CreepFlag; Yap_REGS.H_ = H; diff --git a/H/absmi.h b/H/absmi.h index 05df08f52..377c1e89d 100644 --- a/H/absmi.h +++ b/H/absmi.h @@ -453,15 +453,15 @@ restore_absmi_regs(REGSTORE * old_regs) #endif /* USE_PREFETCH */ -#define Op(Label,Type) Label: START_PREFETCH(Type) +#define Op(Label,Type) Label:{ START_PREFETCH(Type) -#define OpW(Label,Type) Label: START_PREFETCH_W(Type) +#define OpW(Label,Type) Label: { START_PREFETCH_W(Type) -#define BOp(Label,Type) Label: +#define BOp(Label,Type) Label: { -#define PBOp(Label,Type) Label: INIT_PREFETCH() +#define PBOp(Label,Type) Label: { INIT_PREFETCH() -#define OpRW(Label,Type) Label: +#define OpRW(Label,Type) Label: { #else /* do not use threaded code */ @@ -477,27 +477,27 @@ restore_absmi_regs(REGSTORE * old_regs) #define ALWAYS_GONextW() GONextW() -#define Op(Label,Type) case _##Label: START_PREFETCH(Type) +#define Op(Label,Type) case _##Label: { START_PREFETCH(Type) -#define OpW(Label,Type) case _##Label: START_PREFETCH_W(Type) +#define OpW(Label,Type) case _##Label: { START_PREFETCH_W(Type) -#define BOp(Label,Type) case _##Label: +#define BOp(Label,Type) case _##Label: { -#define PBOp(Label,Type) case _##Label: INIT_PREFETCH() +#define PBOp(Label,Type) case _##Label: { INIT_PREFETCH() -#define OpRW(Label,Type) case _##Label: +#define OpRW(Label,Type) case _##Label: { #endif -#define ENDOp() END_PREFETCH() +#define ENDOp() END_PREFETCH() } -#define ENDOpW() END_PREFETCH_W() +#define ENDOpW() END_PREFETCH_W() } -#define ENDOpRW() +#define ENDOpRW() } -#define ENDBOp() +#define ENDBOp() } -#define ENDPBOp() END_PREFETCH() +#define ENDPBOp() END_PREFETCH() } /********************************************************************** * * diff --git a/OPTYap/tab.insts.i b/OPTYap/tab.insts.i index fc55cd9de..927b9e0e4 100644 --- a/OPTYap/tab.insts.i +++ b/OPTYap/tab.insts.i @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.insts.i - version: $Id: tab.insts.i,v 1.21 2005-11-15 00:50:49 vsc Exp $ + version: $Id: tab.insts.i,v 1.22 2006-01-17 14:10:41 vsc Exp $ **********************************************************************/ @@ -342,6 +342,7 @@ code_ap = PREG->u.ld.d; PREG = NEXTOP(PREG,ld); } + PREFETCH_OP(PREG); restore_generator_node(SgFr_arity(sg_fr), code_ap); YENV = (CELL *) PROTECT_FROZEN_B(B); set_cut(YENV, B->cp_b); @@ -349,6 +350,10 @@ allocate_environment(); GONext(); } +#else + PREG = PREG->u.ld.d; + PREFETCH_OP(PREG); + GONext(); #endif /* INCOMPLETE_TABLING */ ENDPBOp(); @@ -357,10 +362,13 @@ PBOp(table_try_single, ld) tab_ent_ptr tab_ent; sg_fr_ptr sg_fr; + check_trail(TR); tab_ent = PREG->u.ld.te; - sg_fr = subgoal_search(PREG, &YENV); + YENV2MEM; + sg_fr = subgoal_search(PREG, YENV_ADDRESS); + MEM2YENV; LOCK(SgFr_lock(sg_fr)); if (SgFr_state(sg_fr) == ready) { /* subgoal new */ @@ -470,7 +478,9 @@ check_trail(TR); tab_ent = PREG->u.ld.te; - sg_fr = subgoal_search(PREG, &YENV); + YENV2MEM; + sg_fr = subgoal_search(PREG, YENV_ADDRESS); + MEM2YENV; LOCK(SgFr_lock(sg_fr)); if (SgFr_state(sg_fr) == ready) { /* subgoal new */ @@ -580,7 +590,9 @@ check_trail(TR); tab_ent = PREG->u.ld.te; - sg_fr = subgoal_search(PREG, &YENV); + YENV2MEM; + sg_fr = subgoal_search(PREG, YENV_ADDRESS); + MEM2YENV; LOCK(SgFr_lock(sg_fr)); if (SgFr_state(sg_fr) == ready) { /* subgoal new */ diff --git a/OPTYap/tab.tries.insts.i b/OPTYap/tab.tries.insts.i index 3ae4bd1ef..8ba038e1e 100644 --- a/OPTYap/tab.tries.insts.i +++ b/OPTYap/tab.tries.insts.i @@ -5,7 +5,7 @@ Copyright: R. Rocha and NCC - University of Porto, Portugal File: tab.tries.insts.i - version: $Id: tab.tries.insts.i,v 1.10 2005-07-06 19:34:11 ricroc Exp $ + version: $Id: tab.tries.insts.i,v 1.11 2006-01-17 14:10:41 vsc Exp $ **********************************************************************/ @@ -996,19 +996,19 @@ ENDPBOp(); - PBOp(trie_try_float, e) - Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_try_float)"); - ENDPBOp(); + BOp(trie_try_float, e) + Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_try_float)"); + ENDBOp(); - PBOp(trie_retry_float, e) + BOp(trie_retry_float, e) Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_retry_float)"); - ENDPBOp(); + ENDBOp(); - PBOp(trie_trust_float, e) + BOp(trie_trust_float, e) Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_trust_float)"); - ENDPBOp(); + ENDBOp(); PBOp(trie_do_long, e) @@ -1024,16 +1024,16 @@ ENDPBOp(); - PBOp(trie_try_long, e) + BOp(trie_try_long, e) Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_try_long)"); - ENDPBOp(); + ENDBOp(); - PBOp(trie_retry_long, e) + BOp(trie_retry_long, e) Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_retry_long)"); - ENDPBOp(); + ENDBOp(); - PBOp(trie_trust_long, e) + BOp(trie_trust_long, e) Yap_Error(INTERNAL_ERROR, TermNil, "invalid instruction (trie_trust_long)"); - ENDPBOp(); + ENDBOp(); diff --git a/README b/README index d94cfa74f..57104edd6 100644 --- a/README +++ b/README @@ -1,34 +1,32 @@ - - README for Yap 5.0 + README for Yap 5.1 -This directory contains a release of the Yap 5.t Prolog system, +This directory contains a release of the Yap 5.1.* Prolog system, originally developed at the Universidade do Porto by Luis Damas and Vitor Santos Costa, with contributions from the Edinburgh Prolog -library, the C-Prolog manual authors, Ricardo Rocha, and many -others. You should read the rest of this file for information on what -Yap is and for instructions on how to build it. +library, the C-Prolog manual authors, Ricardo Lopes, Ricardo Rocha, +and many others. You should read the rest of this file for information +on what Yap is and for instructions on how to build it. YAP 52 is known to build with many versions of gcc (<= gcc-2.7.2, >= gcc-2.8.1, >= egcs-1.0.1, gcc-2.95.*) and on a variety of Unix'es: SunOS 4.1, Solaris 2.*, Irix 5.2, HP-UX 10.20, Dec Alpha Unix, Linux 1.2 and Linux 2.* (RedHat 4.0 through 5.2, Debian 2.*) in both the x86 and -alpha platforms. It has been built on Windows NT 4.0 using Cygwin from -Cygnus Solutions (see README.cygwin) and using Visual C++ 6.0. +alpha platforms. It has been built on Windows XP using cygwin/mingw from +Cygnus Solutions. -The overall copyright and permission notice for Yap4.5 can be found in -the Artistic file in this directory. Yap follows the Perl Artistic -license 2. YAP can also be distributed under the LGPL. +Yap is now distributed under two licenses. YAP can also be distributed +under the FSF's LGPL (see the file COPYING). Also, all the components +of Yap not in the LGPL directory can be distributed under the Perl +Artistic license 2. -The Yap distribution contains copylefted free software under the LGPL -from Universidade Politecnica de Madrid, software from the Austrian -Research Institute for Artificial Intelligence (OFAI) under the OFAI -license, and software from Ludwig-Maximilians-Universitaet Muenchen -(LMU) under the LMU license. We would like to take the opportunity to -thank the developers of these packages for their kindness in allowing -YAP to distribute these packages. +The Yap distribution includes several packages ported to Yap, such as +Pillow, JPL, CLP(R) and CHR. We would like to take +the opportunity to thank the developers of these packages for their +generosity in allowing YAP to distribute these packages. Any bugs in +these packages are probably our fault. If you have a question about this software, desire to add code, found a bug, want to request a feature, or wonder how to get further @@ -134,12 +132,12 @@ Prolog. You can tune Yap to use extra functionality by using the following options to configure: o --enable-rational-trees=yes gives you support for infinite rational -trees. +trees (enabled by default). o --enable-coroutining=yes gives you support for coroutining, including freezing of goals, attributed variables, and constraints. This will also enable support for infinite rational -trees. +trees (enabled by default). o --enable-depth-limit=yes allows depth limited evaluation, say for implementing iterative deepening. @@ -149,7 +147,7 @@ retries, and backtracks in the system. This can help in debugging your application, but results in performance loss. o --enable-wam-profile=yes allows profiling of abstract machine -instructions. This is useful when developing YAP, should not be so +instructions. This is useful when developing YAP, should not be very useful for normal users. o --enable-parallelism={env-copy,sba,a-cow} allows or-parallelism diff --git a/changes-5.1.html b/changes-5.1.html index 134edade2..e8e77591c 100644 --- a/changes-5.1.html +++ b/changes-5.1.html @@ -16,6 +16,10 @@

Yap-5.1.0:

    +
  • FIXED: YENV may be an HW register (breaks some tabling code)
  • +
  • FIXED: All YAAM instructions are now brackedted, so Op introduced an { and EndOp intr +oduces an }. This is because Ricardo assumes that.
  • +
  • Fix attvars when COROUTING is undefined.
  • FIXED: scanner would convert LONG_MIN to bigint, but it can be represent as a LONG; fixed by using mpz_fits_slong_p (Roberto Bagnara).
  • FIXED: indexing cut should stop looking after a cut!!!! (Paulo Moura). diff --git a/library/Tries/yap_tries.c b/library/Tries/yap_tries.c index d8796f877..e79103768 100644 --- a/library/Tries/yap_tries.c +++ b/library/Tries/yap_tries.c @@ -124,7 +124,7 @@ static int p_put_trie_entry(void) { int mode; /* check args */ - mode_str = YAP_AtomName(YAP_AtomOfTerm(arg_mode)); + mode_str = (char *)YAP_AtomName(YAP_AtomOfTerm(arg_mode)); if (!strcmp(mode_str, "std")) { mode = MODE_STANDARD; } else if (!strcmp(mode_str, "rev")) { @@ -152,7 +152,7 @@ static int p_get_trie_entry(void) { int mode; /* check args */ - mode_str = YAP_AtomName(YAP_AtomOfTerm(arg_mode)); + mode_str = (char *)YAP_AtomName(YAP_AtomOfTerm(arg_mode)); if (!strcmp(mode_str, "std")) { mode = MODE_STANDARD; } else if (!strcmp(mode_str, "rev")) { diff --git a/library/system/sys.c b/library/system/sys.c index 3ae721527..69f868845 100644 --- a/library/system/sys.c +++ b/library/system/sys.c @@ -8,8 +8,11 @@ * * ************************************************************************** * * -* $Id: sys.c,v 1.24 2006-01-08 23:01:48 vsc Exp $ * +* $Id: sys.c,v 1.25 2006-01-17 14:10:42 vsc Exp $ * * mods: $Log: not supported by cvs2svn $ +* mods: Revision 1.24 2006/01/08 23:01:48 vsc +* mods: *** empty log message *** +* mods: * mods: Revision 1.23 2005/10/21 16:09:03 vsc * mods: SWI compatible module only operators * mods: @@ -227,7 +230,7 @@ list_directory(void) YAP_Term tf = YAP_MkAtomTerm(YAP_LookupAtom("[]")); long sl = YAP_InitSlot(tf); - char *buf = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *buf = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); #if defined(__MINGW32__) || _MSC_VER struct _finddata_t c_file; char bs[BUF_SIZE]; @@ -275,7 +278,7 @@ list_directory(void) static int p_unlink(void) { - char *fd = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); #if defined(__MINGW32__) || _MSC_VER if (_unlink(fd) == -1) #else @@ -291,7 +294,7 @@ p_unlink(void) static int p_mkdir(void) { - char *fd = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); #if defined(__MINGW32__) || _MSC_VER if (_mkdir(fd) == -1) { #else @@ -306,7 +309,7 @@ p_mkdir(void) static int p_rmdir(void) { - char *fd = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); #if defined(__MINGW32__) || _MSC_VER if (_rmdir(fd) == -1) { #else @@ -321,8 +324,8 @@ p_rmdir(void) static int rename_file(void) { - char *s1 = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); - char *s2 = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)); + char *s1 = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *s2 = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)); #if HAVE_RENAME if (rename(s1, s2) == -1) { /* return an error number */ @@ -345,7 +348,7 @@ file_property(void) #if HAVE_LSTAT struct stat buf; - fd = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); if (lstat(fd, &buf) == -1) { /* return an error number */ return(YAP_Unify(YAP_ARG7, YAP_MkIntTerm(errno))); @@ -424,7 +427,7 @@ p_mktemp(void) { #if HAVE_MKTEMP || defined(__MINGW32__) || _MSC_VER char *s, tmp[BUF_SIZE]; - s = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + s = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); #if HAVE_STRNCPY strncpy(tmp, s, BUF_SIZE); #else @@ -662,7 +665,7 @@ execute_command(void) close(errf); argv[0] = "sh"; argv[1] = "-c"; - argv[2] = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + argv[2] = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); argv[3] = NULL; execv("/bin/sh", argv); exit(127); @@ -680,7 +683,7 @@ execute_command(void) static int do_system(void) { - char *command = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *command = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); #if HAVE_SYSTEM int sys = system(command); if (sys < 0) { @@ -736,9 +739,9 @@ do_shell(void) int t; int sys; - cptr[0]= YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); - cptr[1]= YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)); - cptr[2]= YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3)); + cptr[0]= (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + cptr[1]= (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG2)); + cptr[2]= (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG3)); cptr[3]= NULL; t = fork(); if (t < 0) { @@ -795,7 +798,7 @@ p_wait(void) static int p_popen(void) { - char *command = YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); + char *command = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); long int mode = YAP_IntOfTerm(YAP_ARG2); FILE *pfd; YAP_Term tsno; diff --git a/library/yap2swi/yap2swi.c b/library/yap2swi/yap2swi.c index e82b213e7..5ecea41d5 100644 --- a/library/yap2swi/yap2swi.c +++ b/library/yap2swi/yap2swi.c @@ -46,7 +46,7 @@ PL_agc_hook(PL_agc_hook_t entry) YAP: char* AtomName(Atom) */ X_API char* PL_atom_chars(atom_t a) /* SAM check type */ { - return YAP_AtomName((YAP_Atom)a); + return (char *)YAP_AtomName((YAP_Atom)a); } @@ -119,7 +119,7 @@ X_API int PL_get_atom_chars(term_t ts, char **a) /* SAM check type */ YAP_Term t = YAP_GetFromSlot(ts); if (!YAP_IsAtomTerm(t)) return 0; - *a = YAP_AtomName(YAP_AtomOfTerm(t)); + *a = (char *)YAP_AtomName(YAP_AtomOfTerm(t)); return 1; } @@ -206,7 +206,7 @@ X_API int PL_get_chars(term_t l, char **sp, unsigned flags) if (YAP_IsAtomTerm(t)) { if (!(flags & (CVT_ATOM|CVT_ATOMIC|CVT_ALL))) return 0; - *sp = YAP_AtomName(YAP_AtomOfTerm(t)); + *sp = (char *)YAP_AtomName(YAP_AtomOfTerm(t)); return 1; } else if (YAP_IsIntTerm(t)) { if (!(flags & (CVT_INTEGER|CVT_NUMBER|CVT_ATOMIC|CVT_ALL)))