Merge branch 'master' of gitosis@yap.dcc.fc.up.pt:yap-6

This commit is contained in:
Vítor Santos Costa 2010-02-26 00:17:39 +00:00
commit 01b801e753
3 changed files with 65 additions and 78 deletions

View File

@ -123,13 +123,13 @@ double my_rint(double x)
if (x >= 0) { if (x >= 0) {
y = x + 0.5; y = x + 0.5;
z = floor(y); z = floor(y);
n = (int) z; n = (Int) z;
if (y == z && n % 2) if (y == z && n % 2)
return(z-1); return(z-1);
} else { } else {
y = x - 0.5; y = x - 0.5;
z = ceil(y); z = ceil(y);
n = (int) z; n = (Int) z;
if (y == z && n % 2) if (y == z && n % 2)
return(z+1); return(z+1);
} }
@ -463,11 +463,7 @@ eval1(Int fi, Term t) {
case db_ref_e: case db_ref_e:
RERROR(); RERROR();
} }
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */ RBIG_FL(floor(dbl));
RBIG_FL(floor(dbl));
} else {
RFLOAT(floor(dbl));
}
} }
case op_ceiling: case op_ceiling:
{ {
@ -494,11 +490,7 @@ eval1(Int fi, Term t) {
case db_ref_e: case db_ref_e:
RERROR(); RERROR();
} }
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */ RBIG_FL(ceil(dbl));
RBIG_FL(ceil(dbl));
} else {
RFLOAT(ceil(dbl));
}
} }
case op_round: case op_round:
{ {
@ -507,9 +499,9 @@ eval1(Int fi, Term t) {
switch (ETypeOfTerm(t)) { switch (ETypeOfTerm(t)) {
case long_int_e: case long_int_e:
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */ if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
return Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is round(%f)", IntegerOfTerm(t)); return Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is round(%ld)", IntegerOfTerm(t));
} else { } else {
RFLOAT(IntegerOfTerm(t)); return t;
} }
case double_e: case double_e:
dbl = FloatOfTerm(t); dbl = FloatOfTerm(t);
@ -518,21 +510,14 @@ eval1(Int fi, Term t) {
#ifdef USE_GMP #ifdef USE_GMP
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { if (yap_flags[LANGUAGE_MODE_FLAG] == 1) {
return process_iso_error(Yap_BigIntOfTerm(t), t, "round"); return process_iso_error(Yap_BigIntOfTerm(t), t, "round");
} else {
dbl = mpz_get_d(Yap_BigIntOfTerm(t));
} }
return t;
break; break;
#endif
case db_ref_e: case db_ref_e:
#endif
RERROR(); RERROR();
} }
if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */ RBIG_FL(my_rint(dbl));
double vl = my_rint(dbl);
RBIG_FL(vl);
} else {
double vl = my_rint(dbl);
RFLOAT(vl);
}
} }
case op_truncate: case op_truncate:
case op_integer: case op_integer:
@ -540,19 +525,21 @@ eval1(Int fi, Term t) {
Float dbl; Float dbl;
switch (ETypeOfTerm(t)) { switch (ETypeOfTerm(t)) {
case long_int_e: case long_int_e:
RINT(IntegerOfTerm(t)); if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
return Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is round(%ld)", IntegerOfTerm(t));
}
return t;
case double_e: case double_e:
dbl = FloatOfTerm(t); dbl = FloatOfTerm(t);
break; break;
case big_int_e:
#ifdef USE_GMP #ifdef USE_GMP
{ case big_int_e:
MP_INT new; if (yap_flags[LANGUAGE_MODE_FLAG] == 1) { /* iso */
mpz_init_set(&new, Yap_BigIntOfTerm(t)); return Yap_ArithError(TYPE_ERROR_FLOAT, t, "X is round(BIGNUM)");
RBIG(&new);
} }
#endif return t;
case db_ref_e: case db_ref_e:
#endif
RERROR(); RERROR();
} }
#if HAVE_ISNAN #if HAVE_ISNAN

View File

@ -314,140 +314,140 @@ parms.h: Makefile
#special rule for this one: we cannot use -fomit-frame-pointer because this will #special rule for this one: we cannot use -fomit-frame-pointer because this will
# interface with the outside world. # interface with the outside world.
c_interface.o: $(srcdir)/C/c_interface.c $(srcdir)/include/c_interface.h c_interface.o: $(srcdir)/C/c_interface.c $(srcdir)/include/c_interface.h config.h
$(CC) $(C_INTERF_FLAGS) -c $(srcdir)/C/c_interface.c -o c_interface.o $(CC) $(C_INTERF_FLAGS) -c $(srcdir)/C/c_interface.c -o c_interface.o
clause_list.o: $(srcdir)/C/clause_list.c $(srcdir)/include/clause_list.h clause_list.o: $(srcdir)/C/clause_list.c $(srcdir)/include/clause_list.h config.h
$(CC) $(C_INTERF_FLAGS) -c $(srcdir)/C/clause_list.c -o clause_list.o $(CC) $(C_INTERF_FLAGS) -c $(srcdir)/C/clause_list.c -o clause_list.o
init.o: $(srcdir)/C/init.c init.o: $(srcdir)/C/init.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/init.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/init.c -o $@
load_foreign.o: $(srcdir)/C/load_foreign.c load_foreign.o: $(srcdir)/C/load_foreign.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/load_foreign.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/load_foreign.c -o $@
save.o: $(srcdir)/C/save.c save.o: $(srcdir)/C/save.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/save.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/save.c -o $@
sysbits.o: $(srcdir)/C/sysbits.c sysbits.o: $(srcdir)/C/sysbits.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/C/sysbits.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/C/sysbits.c -o $@
udi.o: $(srcdir)/C/udi.c udi.o: $(srcdir)/C/udi.c config.h
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/C/udi.c -o $@ $(CC) -c $(C_INTERF_FLAGS) $(srcdir)/C/udi.c -o $@
rtree.o: $(srcdir)/packages/udi/rtree.c rtree.o: $(srcdir)/packages/udi/rtree.c config.h
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree.c -o $@ $(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree.c -o $@
rtree_udi.o: $(srcdir)/packages/udi/rtree_udi.c rtree_udi.o: $(srcdir)/packages/udi/rtree_udi.c config.h
$(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree_udi.c -o $@ $(CC) -c $(C_INTERF_FLAGS) $(srcdir)/packages/udi/rtree_udi.c -o $@
yap.o: $(srcdir)/console/yap.c parms.h yap.o: $(srcdir)/console/yap.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/console/yap.c -o $@ $(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/console/yap.c -o $@
mpi.o: $(srcdir)/library/mpi/mpi.c mpi.o: $(srcdir)/library/mpi/mpi.c config.h
$(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpi.c -o $@ $(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpi.c -o $@
mpe.o: $(srcdir)/library/mpi/mpe.c mpe.o: $(srcdir)/library/mpi/mpe.c config.h
$(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpe.c -o $@ $(MPI_CC) -c $(CFLAGS) $(srcdir)/library/mpi/mpe.c -o $@
myddas_mysql.o: $(srcdir)/MYDDAS/myddas_mysql.c myddas_mysql.o: $(srcdir)/MYDDAS/myddas_mysql.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_mysql.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_mysql.c -o $@
myddas_odbc.o: $(srcdir)/MYDDAS/myddas_odbc.c myddas_odbc.o: $(srcdir)/MYDDAS/myddas_odbc.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_odbc.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_odbc.c -o $@
myddas_shared.o: $(srcdir)/MYDDAS/myddas_shared.c myddas_shared.o: $(srcdir)/MYDDAS/myddas_shared.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_shared.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_shared.c -o $@
myddas_util.o: $(srcdir)/MYDDAS/myddas_util.c myddas_util.o: $(srcdir)/MYDDAS/myddas_util.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_util.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_util.c -o $@
myddas_initialization.o: $(srcdir)/MYDDAS/myddas_initialization.c myddas_initialization.o: $(srcdir)/MYDDAS/myddas_initialization.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_initialization.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_initialization.c -o $@
myddas_top_level.o: $(srcdir)/MYDDAS/myddas_top_level.c myddas_top_level.o: $(srcdir)/MYDDAS/myddas_top_level.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_top_level.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_top_level.c -o $@
myddas_wkb2prolog.o: $(srcdir)/MYDDAS/myddas_wkb2prolog.c myddas_wkb2prolog.o: $(srcdir)/MYDDAS/myddas_wkb2prolog.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_wkb2prolog.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_wkb2prolog.c -o $@
myddas_statistics.o: $(srcdir)/MYDDAS/myddas_statistics.c myddas_statistics.o: $(srcdir)/MYDDAS/myddas_statistics.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_statistics.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/MYDDAS/myddas_statistics.c -o $@
opt.memory.o: $(srcdir)/OPTYap/opt.memory.c opt.memory.o: $(srcdir)/OPTYap/opt.memory.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.memory.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.memory.c -o $@
opt.misc.o: $(srcdir)/OPTYap/opt.misc.c opt.misc.o: $(srcdir)/OPTYap/opt.misc.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.misc.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.misc.c -o $@
opt.init.o: $(srcdir)/OPTYap/opt.init.c opt.init.o: $(srcdir)/OPTYap/opt.init.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.init.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.init.c -o $@
opt.preds.o: $(srcdir)/OPTYap/opt.preds.c opt.preds.o: $(srcdir)/OPTYap/opt.preds.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.preds.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/opt.preds.c -o $@
or.cut.o: $(srcdir)/OPTYap/or.cut.c or.cut.o: $(srcdir)/OPTYap/or.cut.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.cut.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.cut.c -o $@
or.engine.o: $(srcdir)/OPTYap/or.engine.c or.engine.o: $(srcdir)/OPTYap/or.engine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.engine.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.engine.c -o $@
or.cowengine.o: $(srcdir)/OPTYap/or.cowengine.c or.cowengine.o: $(srcdir)/OPTYap/or.cowengine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.cowengine.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.cowengine.c -o $@
or.sbaengine.o: $(srcdir)/OPTYap/or.sbaengine.c or.sbaengine.o: $(srcdir)/OPTYap/or.sbaengine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.sbaengine.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.sbaengine.c -o $@
or.threadengine.o: $(srcdir)/OPTYap/or.threadengine.c or.threadengine.o: $(srcdir)/OPTYap/or.threadengine.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.threadengine.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.threadengine.c -o $@
or.scheduler.o: $(srcdir)/OPTYap/or.scheduler.c or.scheduler.o: $(srcdir)/OPTYap/or.scheduler.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.scheduler.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/or.scheduler.c -o $@
tab.tries.o: $(srcdir)/OPTYap/tab.tries.c tab.tries.o: $(srcdir)/OPTYap/tab.tries.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.tries.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.tries.c -o $@
tab.suspend.o: $(srcdir)/OPTYap/tab.suspend.c tab.suspend.o: $(srcdir)/OPTYap/tab.suspend.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.suspend.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/OPTYap/tab.suspend.c -o $@
eam_showcode.o: $(srcdir)/BEAM/eam_showcode.c eam_showcode.o: $(srcdir)/BEAM/eam_showcode.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eam_showcode.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/BEAM/eam_showcode.c -o $@
eam_am.o: $(srcdir)/BEAM/eam_am.c eam_am.o: $(srcdir)/BEAM/eam_am.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eam_am.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/BEAM/eam_am.c -o $@
eamamasm.o: $(srcdir)/BEAM/eamamasm.c eamamasm.o: $(srcdir)/BEAM/eamamasm.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eamamasm.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/BEAM/eamamasm.c -o $@
eamindex.o: $(srcdir)/BEAM/eamindex.c eamindex.o: $(srcdir)/BEAM/eamindex.c config.h
$(CC) -c $(CFLAGS) $(srcdir)/BEAM/eamindex.c -o $@ $(CC) -c $(CFLAGS) $(srcdir)/BEAM/eamindex.c -o $@
sys.o: $(srcdir)/library/system/sys.c sys.o: $(srcdir)/library/system/sys.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/system/sys.c -o $@ $(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/system/sys.c -o $@
yap2swi.o: $(srcdir)/library/yap2swi/yap2swi.c yap2swi.o: $(srcdir)/library/yap2swi/yap2swi.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/yap2swi/yap2swi.c -o $@ $(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/yap2swi/yap2swi.c -o $@
random.o: $(srcdir)/library/random/random.c random.o: $(srcdir)/library/random/random.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/random/random.c -o $@ $(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/random/random.c -o $@
regexp.o: $(srcdir)/library/regex/regexp.c @NO_BUILTIN_REGEXP@ $(srcdir)/library/regex/regex2.h $(srcdir)/library/regex/engine.c regexp.o: $(srcdir)/library/regex/regexp.c @NO_BUILTIN_REGEXP@ $(srcdir)/library/regex/regex2.h $(srcdir)/library/regex/engine.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regexp.c -o regexp.o $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regexp.c -o regexp.o
regcomp.o: $(srcdir)/library/regex/regcomp.c $(srcdir)/library/regex/regex2.h regcomp.o: $(srcdir)/library/regex/regcomp.c $(srcdir)/library/regex/regex2.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regcomp.c -o regcomp.o $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regcomp.c -o regcomp.o
regerror.o: $(srcdir)/library/regex/regerror.c regerror.o: $(srcdir)/library/regex/regerror.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regerror.c -o regerror.o $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regerror.c -o regerror.o
regfree.o: $(srcdir)/library/regex/regfree.c $(srcdir)/library/regex/regex2.h regfree.o: $(srcdir)/library/regex/regfree.c $(srcdir)/library/regex/regex2.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regfree.c -o regfree.o $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regfree.c -o regfree.o
regexec.o: $(srcdir)/library/regex/regexec.c regexec.o: $(srcdir)/library/regex/regexec.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regexec.c -o regexec.o $(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/regex $(srcdir)/library/regex/regexec.c -o regexec.o
# default rule # default rule
%.o : $(srcdir)/C/%.c %.o : $(srcdir)/C/%.c config.h
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
@ -484,7 +484,7 @@ all: startup.yss
@ENABLE_CPLINT@ (cd cplint; $(MAKE)) @ENABLE_CPLINT@ (cd cplint; $(MAKE))
@USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE)) @USE_CUDD@ (cd packages/ProbLog/simplecudd; $(MAKE))
startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES) parms.h startup.yss: yap@EXEC_SUFFIX@ $(PL_SOURCES)
-rm -f startup.yss -rm -f startup.yss
echo "bootstrap('$(srcdir)/pl/init.yap'). module(user). save_program('startup.yss')." | @PRE_DYNLOADER_PATH@ ./yap -b $(srcdir)/pl/boot.yap echo "bootstrap('$(srcdir)/pl/init.yap'). module(user). save_program('startup.yss')." | @PRE_DYNLOADER_PATH@ ./yap -b $(srcdir)/pl/boot.yap

View File

@ -944,7 +944,7 @@ ord_list_to_rbtree(List, t(Nil,Tree)) :-
Nil = black('', _, _, ''), Nil = black('', _, _, ''),
Ar =.. [seq|List], Ar =.. [seq|List],
functor(Ar,_,L), functor(Ar,_,L),
Height is integer(log(L)/log(2)), Height is truncate(log(L)/log(2)),
construct_rbtree(1, L, Ar, Height, Nil, Tree). construct_rbtree(1, L, Ar, Height, Nil, Tree).
construct_rbtree(L, M, _, _, Nil, Nil) :- M < L, !. construct_rbtree(L, M, _, _, Nil, Nil) :- M < L, !.