memory leaks with _output_
improve configure
This commit is contained in:
Vitor Santos Costa 2018-10-19 14:56:49 +01:00
parent 3786de19de
commit 8fcf3eb008
15 changed files with 731 additions and 660 deletions

View File

@ -12,11 +12,15 @@ WITH_VARS="swig|yes|WITH_SWIG \
mpi|yes|WITH_MPI \
gecode|yes|WITH_GECODE \
docs|yes|WITH_DOCS \
r|yes|WITH_REAL \
r|yes|WITH_R \
myddas|yes|WITH_MYDDAS \
cudd|yes|WITH_CUDD \
xml2|yes|WITH_XML2 \
raptor|yes|WITH_RAPTOR \
python|yes|WITH_PYTHON \
openssl|yes|WITH_OPENSSL\
java|yes|WITH_JAVA
lbfgs|yes|WITH_LBFGS
extensions|yes|WITH_EXTENSIONS
readline|yes|WITH_READLINE \
gmp|yes|WITH_GMP"

View File

@ -1811,27 +1811,6 @@ X_API bool YAP_RetryGoal(YAP_dogoalinfo *dgi) {
return out;
}
static void completeInnerCall(bool on_cut, yamop *old_CP, yamop *old_P) {
if (on_cut) {
P = old_P;
ENV = (CELL *)ENV[E_E];
CP = old_CP;
LOCAL_AllowRestart = TRUE;
// we are back to user code again, need slots */
} else {
P = old_P;
ENV = B->cp_env;
ENV = (CELL *)ENV[E_E];
CP = old_CP;
HR = B->cp_h;
TR = B->cp_tr;
B = B->cp_b;
LOCAL_AllowRestart = FALSE;
SET_ASP(ENV, E_CB * sizeof(CELL));
// make sure the slots are ok.
}
}
X_API bool YAP_LeaveGoal(bool successful, YAP_dogoalinfo *dgi) {
CACHE_REGS
choiceptr myB, handler;

View File

@ -25,7 +25,7 @@ static char SccsId[] = "%W% %G%";
*
* @brief record and other forms of storing terms.
*
* /
*/
/** @defgroup Internal_Database Internal Data Base

119
C/text.c
View File

@ -59,54 +59,6 @@ typedef struct TextBuffer_manager {
} text_buffer_t;
int AllocLevel(void) { return LOCAL_TextBuffer->lvl; }
int push_text_stack__(USES_REGS1) {
int i = LOCAL_TextBuffer->lvl;
i++;
LOCAL_TextBuffer->lvl = i;
return i;
}
int pop_text_stack__(int i) {
int lvl = LOCAL_TextBuffer->lvl;
while (lvl >= i) {
struct mblock *p = LOCAL_TextBuffer->first[lvl];
while (p) {
struct mblock *np = p->next;
free(p);
p = np;
}
LOCAL_TextBuffer->first[lvl] = NULL;
LOCAL_TextBuffer->last[lvl] = NULL;
lvl--;
}
LOCAL_TextBuffer->lvl = lvl;
return lvl;
}
void *pop_output_text_stack__(int i, const void *export) {
int lvl = LOCAL_TextBuffer->lvl;
while (lvl >= i) {
struct mblock *p = LOCAL_TextBuffer->first[lvl];
while (p) {
struct mblock *np = p->next;
if (p + 1 == export) {
size_t sz = p->sz - sizeof(struct mblock);
memmove(p, p + 1, sz);
export = p;
} else {
free(p);
}
p = np;
}
LOCAL_TextBuffer->first[lvl] = NULL;
LOCAL_TextBuffer->last[lvl] = NULL;
lvl--;
}
LOCAL_TextBuffer->lvl = lvl;
return (void *)export;
}
// void pop_text_stack(int i) { LOCAL_TextBuffer->lvl = i; }
void insert_block(struct mblock *o) {
int lvl = o->lvl;
@ -138,6 +90,68 @@ void release_block(struct mblock *o) {
o->next->prev = o->prev;
}
int push_text_stack__(USES_REGS1) {
int i = LOCAL_TextBuffer->lvl;
i++;
LOCAL_TextBuffer->lvl = i;
return i;
}
int pop_text_stack__(int i) {
int lvl = LOCAL_TextBuffer->lvl;
while (lvl >= i) {
struct mblock *p = LOCAL_TextBuffer->first[lvl];
while (p) {
struct mblock *np = p->next;
free(p);
p = np;
}
LOCAL_TextBuffer->first[lvl] = NULL;
LOCAL_TextBuffer->last[lvl] = NULL;
lvl--;
}
LOCAL_TextBuffer->lvl = lvl;
return lvl;
}
void *pop_output_text_stack__(int i, const void *export) {
int lvl = LOCAL_TextBuffer->lvl;
bool found = false;
while (lvl >= i) {
struct mblock *p = LOCAL_TextBuffer->first[lvl];
while (p) {
struct mblock *np = p->next;
if (p + 1 == export) {
found = true;
} else {
free(p);
}
p = np;
}
LOCAL_TextBuffer->first[lvl] = NULL;
LOCAL_TextBuffer->last[lvl] = NULL;
lvl--;
}
LOCAL_TextBuffer->lvl = lvl;
if (found) {
if (lvl) {
struct mblock *o = (struct mblock *)export-1;
o->lvl = lvl;
o->prev = o->next = 0;
insert_block(o);
} else {
struct mblock *p = (struct mblock *)export-1;
size_t sz = p->sz - sizeof(struct mblock);
memmove(p, p + 1, sz);
export = p;
}
}
return (void *)export;
}
void *Malloc(size_t sz USES_REGS) {
int lvl = LOCAL_TextBuffer->lvl;
if (sz == 0)
@ -1027,10 +1041,11 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
void **bufv;
unsigned char *buf;
int i, j;
// int lvl = push_text_stack();
int lvl = push_text_stack();
bufv = Malloc(tot * sizeof(unsigned char *));
if (!bufv) {
// pop_text_stack(lvl);
pop_text_stack(lvl);
return NULL;
}
for (i = 0, j = 0; i < tot; i++) {
@ -1038,7 +1053,7 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
unsigned char *nbuf = Yap_readText(inp + i PASS_REGS);
if (!nbuf) {
// pop_text_stack(lvl);
pop_text_stack(lvl);
return NULL;
}
// if (!nbuf[0])
@ -1054,7 +1069,7 @@ bool Yap_Concat_Text(int tot, seq_tv_t inp[], seq_tv_t *out USES_REGS) {
buf = concat(tot, bufv PASS_REGS);
}
bool rc = write_Text(buf, out PASS_REGS);
// pop_text_stack( lvl );
pop_text_stack( lvl );
return rc;
}

File diff suppressed because it is too large Load Diff

12
configure vendored
View File

@ -165,7 +165,7 @@ print_help() {
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME]
--generator=Generator Specify the tool used to send callss
--generator=GENERATOR Specify the tool used to send callss
EOF
first=y
@ -220,6 +220,8 @@ EOF
exit 0
}
while [ $# != 0 ]; do
case "$1" in
"--cmake="*)
@ -291,10 +293,10 @@ while [ $# != 0 ]; do
"--docdir")
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;;
"-G="|"--generator="*)
CMAKE_ARGS+="-G"${1#*=};;
"-G"|"--generator")
CMAKE_ARGS+="-G$"$2; shift;;
"--generator="*)
CMAKE_ARGS="$CMAKE_ARGS -G ${1#*=}";;
"-G")
CMAKE_ARGS="$CMAKE_ARGS -G $2"; shift;;
"CC="*)
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";;

View File

@ -769,11 +769,11 @@ static Int real_path(USES_REGS1) {
int lvl = push_text_stack();
rc0 = myrealpath(cmd PASS_REGS);
if (!rc0) {
pop_text_stack(lvl);
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, NULL);
}
bool out = Yap_unify(MkAtomTerm(Yap_LookupAtom(rc0)), ARG2);
pop_output_text_stack(lvl, rc0);
pop_text_stack(lvl);
return out;
}

View File

@ -24,6 +24,7 @@ problog_low_lbdd(_, _, Prob, ok, bdd(Dir, Tree, MapList)) :-
bind_maplist(MapList, BoundVars),
bdd_tree(BDD, bdd(Dir, Tree, _Vars)),
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
bdd_close(BDD),
(problog_flag(verbose, true)->
problog_statistics
;
@ -37,7 +38,8 @@ problog_low_lbdd(_, _, Prob, ok, bdd(Dir, Tree, MapList)) :-
problog_kbest_bdd(Goal, K, Prob, ok) :-
problog_kbest_to_bdd(Goal, K, BDD, MapList),
bind_maplist(MapList, BoundVars),
bdd_to_probability_sum_product(BDD, BoundVars, Prob).
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
bdd_close(BDD).
problog_kbest_as_bdd(Goal, K, bdd(Dir, Tree, MapList)) :-
problog_kbest_to_bdd(Goal, K, BDD, MapList),
@ -70,6 +72,7 @@ problog_fl_bdd(_,Prob) :-
bind_maplist(MapList, BoundVars),
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
(problog_flag(retain_tables, true) -> retain_tabling; true),
bdd_close(BDD),
clear_tabling.
problog_full_bdd(Goal,_K, _) :-
@ -86,6 +89,7 @@ problog_full_bdd(_,Prob) :-
tabled_trie_to_bdd(Trie_Completed_Proofs, BDD, MapList),
bind_maplist(MapList, BoundVars),
bdd_to_probability_sum_product(BDD, BoundVars, Prob),
bdd_close(BDD),
(problog_flag(retain_tables, true) -> retain_tabling; true),
clear_tabling.

View File

@ -431,7 +431,7 @@ do_learning_intern(Iterations,Epsilon) :-
true
),
% update_values,
update_values,
(
last_mse(Last_MSE)
@ -450,15 +450,11 @@ do_learning_intern(Iterations,Epsilon) :-
),
(
(problog_flag(rebuild_bdds,BDDFreq),BDDFreq>0,0 =:= CurrentIteration mod BDDFreq)
->
(
retractall(values_correct),
retractall(query_is_similar(_,_)),
retractall(query_md5(_,_,_)),
empty_bdd_directory,
init_queries
); true
),
@ -491,10 +487,47 @@ init_learning :-
init_learning :-
check_examples,
retractall(current_iteration(_)),
assert(current_iteration(0)),
% empty_output_directory,
logger_write_header,
format_learning(1,'Initializing everything~n',[]),
succeeds_n_times(user:test_example(_,_,_,_),TestExampleCount),
format_learning(3,'~q test examples~n',[TestExampleCount]),
succeeds_n_times(user:example(_,_,_,_),TrainingExampleCount),
assertz(example_count(TrainingExampleCount)),
format_learning(3,'~q training examples~n',[TrainingExampleCount]),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% build BDD script for every example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
once(init_queries),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% done
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
assertz(current_iteration(-1)),
assertz(learning_initialized),
format_learning(1,'~n',[]).
%========================================================================
%= Updates all values of query_probability/2 and query_gradient/4
%= should be called always before these predicates are accessed
%= if the old values are still valid, nothing happens
%========================================================================
update_values :-
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% delete old values
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
retractall(query_probability_intern(_,_)),
retractall(query_gradient_intern(_,_,_,_)).
@ -502,8 +535,8 @@ init_learning :-
% Check, if continuous facts are used.
% if yes, switch to problog_exact
% continuous facts are not supported yet.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set_default_gradient_method,
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
set_default_gradient_method :-
( problog_flag(continuous_facts, true )
->
problog_flag(init_method,(_,_,_,_,OldCall)),
@ -527,31 +560,11 @@ init_learning :-
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile)))
);
true
),
succeeds_n_times(user:test_example(_,_,_,_),TestExampleCount),
format_learning(3,'~q test examples~n',[TestExampleCount]),
succeeds_n_times(user:example(_,_,_,_),TrainingExampleCount),
assertz(example_count(TrainingExampleCount)),
format_learning(3,'~q training examples~n',[TrainingExampleCount]),
).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% build BDD script for every example
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
once(init_queries),
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% done
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
assertz(current_iteration(0)),
assertz(learning_initialized),
format_learning(1,'~n',[]).
empty_bdd_directory :-
empty_bdd_directory :-
current_key(_,I),
integer(I),
recorded(I,bdd(_,_,_),R),
@ -560,21 +573,6 @@ init_learning :-
empty_bdd_directory.
set_default_gradient_method :-
problog_flag(continuous_facts, true),
!,
% problog_flag(init_method,OldMethod),
format_learning(2,'Theory uses continuous facts.~nWill use problog_exact/3 as initalization method.~2n',[]),
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile))).
set_default_gradient_method :-
problog_tabled(_), problog_flag(fast_proofs,false),
!,
format_learning(2,'Theory uses tabling.~nWill use problog_exact/3 as initalization method.~2n',[]),
set_problog_flag(init_method,(Query,Probability,BDDFile,ProbFile,problog_exact_save(Query,Probability,_Status,BDDFile,ProbFile))).
%set_default_gradient_method :-
% problog_flag(init_method,(gene(X,Y),N,Bdd,graph2bdd(X,Y,N,Bdd))),
% !.
set_default_gradient_method.
%========================================================================
%= This predicate goes over all training and test examples,
@ -584,6 +582,7 @@ set_default_gradient_method.
init_queries :-
empty_bdd_directory,
format_learning(2,'Build BDDs for examples~n',[]),
forall(user:test_example(ID,Query,_Prob,_),init_one_query(ID,Query,test)),
forall(user:example(ID,Query,_Prob,_),init_one_query(ID,Query,training)).
@ -703,28 +702,56 @@ ground_truth_difference :-
%= -Float
%========================================================================
mse_trainingset_only_for_linesearch(MSE, FX) :-
mse_trainingset :-
current_iteration(Iteration),
create_training_predictions_file_name(Iteration,File_Name),
open(File_Name, write,Handle),
format_learning(2,'MSE_Training ',[]),
update_values,
findall(t(LogCurrentProb,SquaredError),
(user:training_example(QueryID,Query,TrueQueryProb,_Type),
once(update_query(QueryID,'+',probability)),
query_probability(QueryID,CurrentProb),
format(Handle,'ex(~q,training,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
example_count(Example_Count),
once(update_query_cleanup(QueryID)),
SquaredError is (CurrentProb-TrueQueryProb)**2,
LogCurrentProb is log(CurrentProb)
),
All),
maplist(tuple, All, AllLogs, AllSquaredErrors),
sum_list( AllLogs, LLH_Training_Queries),
close(Handle),
bb_put(error_train_line_search,0.0),
forall(user:example(QueryID,_Query,QueryProb,Type),
(
once(update_query(QueryID,'.',probability)),
once(update_query_cleanup(QueryID)),
),
format_learning(3,' (~8f)~n',[MSE]),
retractall(values_correct).
length(AllSquaredErrors,Length),
(
Length>0
->
(
sum_list(AllSquaredErrors,SumAllSquaredErrors),
min_list(AllSquaredErrors,MinError),
max_list(AllSquaredErrors,MaxError),
MSE is SumAllSquaredErrors/Length
);(
MSE=0.0,
MinError=0.0,
MaxError=0.0
)
),
logger_set_variable(mse_trainingset,MSE),
logger_set_variable(mse_min_trainingset,MinError),
logger_set_variable(mse_max_trainingset,MaxError),
logger_set_variable(llh_training_queries,LLH_Training_Queries),
format_learning(2,' (~8f)~n',[MSE]).
tuple(t(X,Y),X,Y).
mse_testset :-
current_iteration(Iteration),
create_test_predictions_file_name(Iteration,File_Name),
open(File_Name,'write',Handle),
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
format(Handle,"% Iteration, train/test, QueryID, Query, GroundTruth, Prediction %~n",[]),
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
open(File_Name, write,Handle),
format_learning(2,'MSE_Test ',[]),
update_values,
bb_put(llh_test_queries,0.0),
@ -732,7 +759,7 @@ mse_testset :-
(user:test_example(QueryID,Query,TrueQueryProb,Type),
once(update_query(QueryID,'+',probability)),
query_probability(QueryID,CurrentProb),
format(Handle,'ex(~q,test,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
format(Handle,'ex(~q,test,~q,~q,~10f,~10f).~n',[Iteration,QueryID,Query,TrueQueryProb,CurrentProb]),
once(update_query_cleanup(QueryID)),
(
@ -808,11 +835,6 @@ save_old_probabilities :-
gradient_descent :-
problog_flag(sigmoid_slope,Slope),
% current_iteration(Iteration),
% create_training_predictions_file_name(Iteration,File_Name),
Handle = user_error,
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
format(Handle,"% Iteration, train/test, QueryID, Query, GroundTruth, Prediction %~n",[]),
format(Handle,"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%~n",[]),
findall(FactID,tunable_fact(FactID,GroundTruth),L), length(L,N),
% leash(0),trace,
lbfgs_initialize(N,X,0,Solver),
@ -839,20 +861,20 @@ user:evaluate(LLH_Training_Queries, X,Grad,N,_,_) :-
N1 is N-1,
forall(between(0,N1,I),
(Grad[I] <== 0.0, S <== X[I], sigmoid(S,Slope, P), Probs[I] <== P)
), nl,
),
forall(
full_example(QueryID,QueryProb,BDD),
compute_grad(QueryID, BDD, QueryProb,Grad, Probs, Slope,LLs)
),
LLH_Training_Queries <== sum(LLs),
writeln(LLH_Training_Queries).
LLH_Training_QueriesSum <== sum(LLs),
LLH_Training_Queries is LLH_Training_QueriesSum/TrainingExampleCount .
%wrap(X, Grad, GradCount).
full_example(QueryID,QueryProb,BDD) :-
user:example(QueryID,_Query,QueryProb,_),
recorded(QueryID,BDD,_),
BDD = bdd(_Dir, _GradTree, MapList),
MapList = [_|_].
BDD = bdd(_Dir, _GradTree, MapList),
MapList = [_|_].
compute_grad(QueryID,BDD,QueryProb, Grad, Probs, Slope, LLs) :-
BDD = bdd(_Dir, _GradTree, MapList),
@ -863,7 +885,7 @@ compute_grad(QueryID,BDD,QueryProb, Grad, Probs, Slope, LLs) :-
LLs[QueryID] <== LL,
%writeln( qprobability(BDD,Slope,BDDProb) ),
forall(
member(I-_, MapList),
member(I-_, MapList),
gradientpair(I, BDD,Slope,BDDProb, QueryProb, Grad, Probs)
).
@ -971,7 +993,7 @@ user:progress(FX,X,_G,X_Norm,G_Norm,Step,_N,Iteration,Ls,0) :-
NextIteration is CurrentIteration+1,
assertz(current_iteration(NextIteration)),
save_model,
set_problog_flag(mse_trainingset, FX),
logger_set_variable(mse_trainingset, FX),
X0 <== X[0], sigmoid(X0,Slope,P0),
X1 <== X[1], sigmoid(X1,Slope,P1),
format('~d. Iteration : (x0,x1)=(~4f,~4f) f(X)=~4f |X|=~4f |X\'|=~4f Step=~4f Ls=~4f~n',[Iteration,P0 ,P1,FX,X_Norm,G_Norm,Step,Ls]).

View File

@ -863,6 +863,9 @@ static YAP_Bool p_cudd_print_with_names(void) {
static YAP_Bool p_cudd_die(void) {
DdManager *manager = (DdManager *)YAP_IntOfTerm(YAP_ARG1);
//Cudd_FreeTree(manager);
//cuddFreeTable(manager);
Cudd_CheckZeroRef(manager);
Cudd_Quit(manager);
return TRUE;
}

View File

@ -1,4 +1,6 @@
if (WITH_MYSQL)
set(MYSQL_SOURCES
myddas_mysql.c
myddas_util.c
@ -51,3 +53,5 @@
"enable the MYDDAS top-level (REPL) support for MySQL" OFF
'USE_MYDDAS AND MYSQL_FOUND' OFF)
#TODO:
endif()

View File

@ -1,39 +1,42 @@
set( YAPODBC_SOURCES
myddas_odbc.c
)
set(SO_MAJOR 1)
set(SO_MINOR 0)
set(SO_PATCH 0)
macro_optional_find_package(ODBC ON)
if (ODBC_FOUND)
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires Odbc.
add_lib(YAPodbc ${YAPODBC_SOURCES})
target_link_libraries(YAPodbc libYap ${ODBC_LIBRARIES})
include_directories (${ODBC_INCLUDE_DIRECTORIES} ..)
set_target_properties (YAPodbc PROPERTIES
POSITION_INDEPENDENT_CODE ON
PREFIX ""
)
list (APPEND MYDDAS_FLAGS -DMYDDAS_ODBC=1)
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
-DMYDDAS_ODBC=1)
install(TARGETS YAPodbc
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
if (WITH_ODBC)
set( YAPODBC_SOURCES
myddas_odbc.c
)
else()
add_definitions (-DMYDDAS_ODBC=0)
set(SO_MAJOR 1)
set(SO_MINOR 0)
set(SO_PATCH 0)
macro_optional_find_package(ODBC ON)
if (ODBC_FOUND)
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires Odbc.
add_lib(YAPodbc ${YAPODBC_SOURCES})
target_link_libraries(YAPodbc libYap ${ODBC_LIBRARIES})
include_directories (${ODBC_INCLUDE_DIRECTORIES} ..)
set_target_properties (YAPodbc PROPERTIES
POSITION_INDEPENDENT_CODE ON
PREFIX ""
)
list (APPEND MYDDAS_FLAGS -DMYDDAS_ODBC=1)
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
-DMYDDAS_ODBC=1)
install(TARGETS YAPodbc
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
)
else()
add_definitions (-DMYDDAS_ODBC=0)
endif (ODBC_FOUND)
endif()

View File

@ -1,35 +1,39 @@
set( YAPPOSTGRES_SOURCES
myddas_postgres.c
)
if (WITH_POSTGRES)
set(SO_MAJOR 1)
set(SO_MINOR 0)
set(SO_PATCH 0)
macro_optional_find_package(PostgreSQL ON)
if (PostgreSQL_FOUND)
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
add_lib(YAPpostgres ${YAPPOSTGRES_SOURCES})
target_link_libraries(YAPpostgres libYap ${PostgreSQL_LIBRARIES})
include_directories (${PostgreSQL_INCLUDE_DIRS} ..)
set_target_properties (YAPpostgres PROPERTIES
POSITION_INDEPENDENT_CODE ON
PREFIX ""
)
list (APPEND MYDDAS_FLAGS -DMYDDAS_POSTGRES=1)
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
-DMYDDAS_POSTGRES=1)
install(TARGETS YAPpostgres
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
set( YAPPOSTGRES_SOURCES
myddas_postgres.c
)
endif (PostgreSQL_FOUND)
set(SO_MAJOR 1)
set(SO_MINOR 0)
set(SO_PATCH 0)
macro_optional_find_package(PostgreSQL ON)
if (PostgreSQL_FOUND)
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
add_lib(YAPpostgres ${YAPPOSTGRES_SOURCES})
target_link_libraries(YAPpostgres libYap ${PostgreSQL_LIBRARIES})
include_directories (${PostgreSQL_INCLUDE_DIRS} ..)
set_target_properties (YAPpostgres PROPERTIES
POSITION_INDEPENDENT_CODE ON
PREFIX ""
)
list (APPEND MYDDAS_FLAGS -DMYDDAS_POSTGRES=1)
set (MYDDAS_FLAGS ${MYDDAS_FLAGS} ON PARENT_SCOPE)
set_property(GLOBAL APPEND PROPERTY COMPILE_DEFINITIONS
-DMYDDAS_POSTGRES=1)
install(TARGETS YAPpostgres
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
)
endif (PostgreSQL_FOUND)
endif()

View File

@ -1,68 +1,72 @@
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
if (WITH_SQLITE3)
set (SQLITE_EXTRA
chinook.db
sqlitest.yap)
message( " * Sqlite3 Data-Base (http://www.sqlite3.org), distributed with MYDDAS" )
set( YAPSQLITE3_SOURCES
myddas_sqlite3.c
src/sqlite3.h
src/sqlite3ext.h
)
set (SQLITE_EXTRA
chinook.db
sqlitest.yap)
set( YAPSQLITE3_SOURCES
myddas_sqlite3.c
src/sqlite3.h
src/sqlite3ext.h
)
#sqlite3 is now in the system
#sqlite3 is now in the system
set (SQLITE3_FOUND ON CACHE PRIVATE "")
set (SQLITE3_FOUND ON CACHE PRIVATE "")
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/..)
if (ANDROID)
add_definitions(-DSQLITE_FCNTL_MMAP_SIZE=0 )
if (ANDROID)
add_definitions(-DSQLITE_FCNTL_MMAP_SIZE=0 )
endif()
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA=1 )
add_definitions(-DSQLITE_ENABLE_JSON1=1 )
add_definitions(-DSQLITE_ENABLE_RBU=1 )
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
if (ANDROID )
add_library( YAPsqlite3 OBJECT
${YAPSQLITE3_SOURCES} )
else()
list(APPEND YAPSQLITE3_SOURCES src/sqlite3.c)
add_library( YAPsqlite3 SHARED
${YAPSQLITE3_SOURCES})
target_link_libraries(YAPsqlite3 libYap )
set_target_properties(YAPsqlite3
PROPERTIES
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
POSITION_INDEPENDENT_CODE ON
PREFIX ""
)
install(TARGETS YAPsqlite3
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
)
endif()
install(FILES ${SQLITE_EXTRA}
DESTINATION ${libpl}
)
endif()
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA=1 )
add_definitions(-DSQLITE_ENABLE_JSON1=1 )
add_definitions(-DSQLITE_ENABLE_RBU=1 )
add_definitions(-DSQLITE_ENABLE_RTREE=1 )
add_definitions(-DSQLITE_ENABLE_FTS5=1 )
SET_PROPERTY(DIRECTORY PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1 )
if (ANDROID )
add_library( YAPsqlite3 OBJECT
${YAPSQLITE3_SOURCES} )
else()
list(APPEND YAPSQLITE3_SOURCES src/sqlite3.c)
add_library( YAPsqlite3 SHARED
${YAPSQLITE3_SOURCES})
target_link_libraries(YAPsqlite3 libYap )
set_target_properties(YAPsqlite3
PROPERTIES
# RPATH ${libdir} VERSION ${LIBYAPTAI_FULL_VERSION}
# SOVERSION ${LIBYAPTAI_MAJOR_VERSION}.${LIBYAPTAI_MINOR_VERSION}
POSITION_INDEPENDENT_CODE ON
PREFIX ""
)
install(TARGETS YAPsqlite3
RUNTIME DESTINATION ${YAP_INSTALL_DLLDIR}
ARCHIVE DESTINATION ${YAP_INSTALL_DLLDIR}
LIBRARY DESTINATION ${YAP_INSTALL_DLLDIR}
)
endif()
install(FILES ${SQLITE_EXTRA}
DESTINATION ${libpl}
)

View File

@ -591,7 +591,8 @@ static long get_len_of_range(long lo, long hi, long step) {
}
#if PY_MAJOR_VERSION >= 3
static PyStructSequence_Field pnull[] = {
/*
static PyStructSequence_Field pnull[] = {
{"A1", NULL}, {"A2", NULL}, {"A3", NULL}, {"A4", NULL}, {"A5", NULL},
{"A6", NULL}, {"A7", NULL}, {"A8", NULL}, {"A9", NULL}, {"A9", NULL},
{"A10", NULL}, {"A11", NULL}, {"A12", NULL}, {"A13", NULL}, {"A14", NULL},
@ -600,7 +601,8 @@ static PyStructSequence_Field pnull[] = {
{"A24", NULL}, {"A25", NULL}, {"A26", NULL}, {"A27", NULL}, {"A28", NULL},
{"A29", NULL}, {"A29", NULL}, {"A30", NULL}, {"A31", NULL}, {"A32", NULL},
{NULL, NULL}};
*/
static PyObject *structseq_str(PyObject *iobj) {
/* buffer and type size were chosen well considered. */
@ -763,7 +765,7 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
PyStructSequence_Desc *desc = calloc(sizeof(PyStructSequence_Desc), 1);
desc->name = PyMem_Malloc(strlen(s) + 1);
desc->doc = "YAPTerm";
desc->fields = pnull;
desc->fields = NULL;
desc->n_in_sequence = arity;
if (PyStructSequence_InitType2(typp, desc) < 0)
return NULL;