CUT_C and MYDDAS support for 64 bits architectures
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1564 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -27,21 +27,21 @@
|
||||
#include "myddas_statistics.h"
|
||||
#endif
|
||||
|
||||
//STATIC_PROTO(int c_db_get_new_table_name,(void));
|
||||
STATIC_PROTO(int c_db_connection_type,(void));
|
||||
STATIC_PROTO(int c_db_add_preds,(void));
|
||||
STATIC_PROTO(int c_db_preds_conn_start ,(void));
|
||||
STATIC_PROTO(int c_db_preds_conn_continue ,(void));
|
||||
STATIC_PROTO(int c_db_connection_start ,(void));
|
||||
STATIC_PROTO(int c_db_connection_continue ,(void));
|
||||
STATIC_PROTO(int c_db_check_if_exists_pred,(void));
|
||||
STATIC_PROTO(int c_db_delete_predicate,(void));
|
||||
STATIC_PROTO(int c_db_multi_queries_number,(void));
|
||||
//STATIC_PROTO(Int c_db_get_new_table_name,(void));
|
||||
STATIC_PROTO(Int c_db_connection_type,(void));
|
||||
STATIC_PROTO(Int c_db_add_preds,(void));
|
||||
STATIC_PROTO(Int c_db_preds_conn_start ,(void));
|
||||
STATIC_PROTO(Int c_db_preds_conn_continue ,(void));
|
||||
STATIC_PROTO(Int c_db_connection_start ,(void));
|
||||
STATIC_PROTO(Int c_db_connection_continue ,(void));
|
||||
STATIC_PROTO(Int c_db_check_if_exists_pred,(void));
|
||||
STATIC_PROTO(Int c_db_delete_predicate,(void));
|
||||
STATIC_PROTO(Int c_db_multi_queries_number,(void));
|
||||
#ifdef MYDDAS_STATS
|
||||
STATIC_PROTO(int c_db_stats,(void));
|
||||
STATIC_PROTO(Int c_db_stats,(void));
|
||||
#endif
|
||||
#ifdef DEBUG
|
||||
STATIC_PROTO(int c_db_check,(void));
|
||||
STATIC_PROTO(Int c_db_check,(void));
|
||||
#endif
|
||||
|
||||
void Yap_InitMYDDAS_SharedPreds(void)
|
||||
@@ -74,11 +74,11 @@ void Yap_InitMYDDAS_SharedPreds(void)
|
||||
void Yap_InitBackMYDDAS_SharedPreds(void)
|
||||
{
|
||||
/* Gives all the predicates associated to a given connection */
|
||||
Yap_InitCPredBack("c_db_preds_conn", 4, sizeof(int),
|
||||
Yap_InitCPredBack("c_db_preds_conn", 4, sizeof(Int),
|
||||
c_db_preds_conn_start,
|
||||
c_db_preds_conn_continue, 0);
|
||||
/* Gives all the connections stored on the MYDDAS Structure*/
|
||||
Yap_InitCPredBack("c_db_connection", 1, sizeof(int),
|
||||
Yap_InitCPredBack("c_db_connection", 1, sizeof(Int),
|
||||
c_db_connection_start,
|
||||
c_db_connection_continue, 0);
|
||||
|
||||
@@ -90,13 +90,13 @@ void Yap_InitBackMYDDAS_SharedPreds(void)
|
||||
|
||||
NOTE: In order to use this predicate, the connection*/
|
||||
/* c_db_connection_type: +Connection * ?Type */
|
||||
static int
|
||||
static Int
|
||||
c_db_connection_type (void){
|
||||
Term arg_con = Deref(ARG1);
|
||||
Term arg_type = Deref(ARG2);
|
||||
|
||||
int *con = (int *) IntegerOfTerm(arg_con);
|
||||
short int type = myddas_util_connection_type(con);
|
||||
Int *con = (Int *) IntegerOfTerm(arg_con);
|
||||
Int type = myddas_util_connection_type(con);
|
||||
|
||||
if (type == 1) /* MYSQL Connection */
|
||||
Yap_unify(arg_type, MkAtomTerm(Yap_LookupAtom("mysql")));
|
||||
@@ -109,7 +109,7 @@ c_db_connection_type (void){
|
||||
}
|
||||
|
||||
/* db_add_preds: PredName * Arity * Module * Connection*/
|
||||
static int
|
||||
static Int
|
||||
c_db_add_preds (void){
|
||||
Term arg_nome = Deref(ARG1);
|
||||
Term arg_aridade = Deref(ARG2);
|
||||
@@ -118,8 +118,8 @@ c_db_add_preds (void){
|
||||
|
||||
char *nome = AtomName(AtomOfTerm(arg_nome));
|
||||
char *module = AtomName(AtomOfTerm(arg_module));
|
||||
int aridade = IntegerOfTerm(arg_aridade);
|
||||
int *conn = (int *) IntegerOfTerm(arg_conn);
|
||||
Int aridade = IntegerOfTerm(arg_aridade);
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
|
||||
if (myddas_util_add_predicate(nome,aridade,module,conn) == NULL)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ c_db_add_preds (void){
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_check_if_exists_pred (void){
|
||||
Term arg_nome = Deref(ARG1);
|
||||
Term arg_aridade = Deref(ARG2);
|
||||
@@ -141,7 +141,7 @@ c_db_check_if_exists_pred (void){
|
||||
|
||||
char *nome = AtomName(AtomOfTerm(arg_nome));
|
||||
char *module = AtomName(AtomOfTerm(arg_module));
|
||||
int aridade = IntegerOfTerm(arg_aridade);
|
||||
Int aridade = IntegerOfTerm(arg_aridade);
|
||||
|
||||
if (myddas_util_search_predicate(nome,aridade,module) == NULL)
|
||||
return FALSE;
|
||||
@@ -150,7 +150,7 @@ c_db_check_if_exists_pred (void){
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_delete_predicate(void){
|
||||
Term arg_module = Deref(ARG1);
|
||||
Term arg_name = Deref(ARG2);
|
||||
@@ -158,7 +158,7 @@ c_db_delete_predicate(void){
|
||||
|
||||
char *module = AtomName(AtomOfTerm(arg_module));
|
||||
char *name = AtomName(AtomOfTerm(arg_name));
|
||||
int arity = IntegerOfTerm(arg_arity);
|
||||
Int arity = IntegerOfTerm(arg_arity);
|
||||
|
||||
MYDDAS_UTIL_PREDICATE predicate =
|
||||
myddas_util_search_predicate(name,arity,module);
|
||||
@@ -171,12 +171,12 @@ c_db_delete_predicate(void){
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_multi_queries_number(void){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_number = Deref(ARG2);
|
||||
|
||||
int *conn = (int *) IntegerOfTerm(arg_conn);
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
myddas_util_search_connection(conn);
|
||||
|
||||
@@ -184,10 +184,10 @@ c_db_multi_queries_number(void){
|
||||
return FALSE;
|
||||
|
||||
if (IsVarTerm(arg_number)){
|
||||
Yap_unify(arg_number,MkIntegerTerm(((int)myddas_util_get_total_multi_queries_number(node))+1));
|
||||
Yap_unify(arg_number,MkIntegerTerm(((Int)myddas_util_get_total_multi_queries_number(node))+1));
|
||||
}
|
||||
else {
|
||||
int number = IntegerOfTerm(arg_number);
|
||||
Int number = IntegerOfTerm(arg_number);
|
||||
number--;
|
||||
myddas_util_set_total_multi_queries_number(node,number);
|
||||
}
|
||||
@@ -196,18 +196,18 @@ c_db_multi_queries_number(void){
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_connection_start(void){
|
||||
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
Yap_regp->MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
Yap_REGS.MYDDAS_GLOBAL_POINTER->myddas_top_connections;
|
||||
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((int)node);
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)node);
|
||||
|
||||
return (c_db_connection_continue());
|
||||
}
|
||||
|
||||
static int
|
||||
static Int
|
||||
c_db_connection_continue(void){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
@@ -221,19 +221,19 @@ c_db_connection_continue(void){
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Yap_unify(arg_conn, MkIntegerTerm((int)(node->connection)));
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((int)(node->next));
|
||||
Yap_unify(arg_conn, MkIntegerTerm((Int)(node->connection)));
|
||||
EXTRA_CBACK_ARG(1,1)=(CELL) MkIntegerTerm((Int)(node->next));
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity */
|
||||
static int
|
||||
static Int
|
||||
c_db_preds_conn_start (void){
|
||||
Term arg_conn = Deref(ARG1);
|
||||
|
||||
int *conn = (int *) IntegerOfTerm(arg_conn);
|
||||
Int *conn = (Int *) IntegerOfTerm(arg_conn);
|
||||
MYDDAS_UTIL_CONNECTION node =
|
||||
myddas_util_search_connection(conn);
|
||||
|
||||
@@ -245,13 +245,13 @@ c_db_preds_conn_start (void){
|
||||
}
|
||||
|
||||
void *pointer = myddas_util_get_list_pred(node);
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((int)pointer);
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)pointer);
|
||||
|
||||
return (c_db_preds_conn_continue());
|
||||
}
|
||||
|
||||
/* db_preds_conn : Connection(+) * Pred_name(-) * Pred_arity*/
|
||||
static int
|
||||
static Int
|
||||
c_db_preds_conn_continue (void){
|
||||
Term module = Deref(ARG2);
|
||||
Term name = Deref(ARG3);
|
||||
@@ -262,7 +262,7 @@ c_db_preds_conn_continue (void){
|
||||
|
||||
if (pointer != NULL)
|
||||
{
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((int)myddas_util_get_pred_next(pointer));
|
||||
EXTRA_CBACK_ARG(4,1)=(CELL) MkIntegerTerm((Int)myddas_util_get_pred_next(pointer));
|
||||
|
||||
if (!Yap_unify(module, MkAtomTerm(Yap_LookupAtom(myddas_util_get_pred_module(pointer))))){
|
||||
return FALSE;
|
||||
@@ -270,7 +270,7 @@ c_db_preds_conn_continue (void){
|
||||
if (!Yap_unify(name,MkAtomTerm(Yap_LookupAtom(myddas_util_get_pred_name(pointer))))){
|
||||
return FALSE;
|
||||
}
|
||||
if (!Yap_unify(arity, MkIntegerTerm((int)myddas_util_get_pred_arity(pointer)))){
|
||||
if (!Yap_unify(arity, MkIntegerTerm((Int)myddas_util_get_pred_arity(pointer)))){
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -285,7 +285,7 @@ c_db_preds_conn_continue (void){
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
static int
|
||||
static Int
|
||||
c_db_check(void){
|
||||
check_int();
|
||||
return TRUE;
|
||||
@@ -294,12 +294,12 @@ c_db_check(void){
|
||||
|
||||
#ifdef MYDDAS_STATS
|
||||
//Returns the stats of this module in a list
|
||||
static int
|
||||
static Int
|
||||
c_db_stats(void) {
|
||||
Term arg_conn = Deref(ARG1);
|
||||
Term arg_list = Deref(ARG2);
|
||||
|
||||
int *conn = (int *) (IntegerOfTerm(arg_conn));
|
||||
Int *conn = (Int *) (IntegerOfTerm(arg_conn));
|
||||
|
||||
// TODO
|
||||
if (get_myddas_top() == 0 ){ /* We want all the statistics */
|
||||
@@ -312,7 +312,7 @@ c_db_stats(void) {
|
||||
list = arg_list;
|
||||
|
||||
MYDDAS_STATS_TIME time;
|
||||
unsigned long number;
|
||||
UInt number;
|
||||
|
||||
|
||||
//[Index 1] -> Total Number of Rows by connection
|
||||
@@ -324,7 +324,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Total Number of Rows returned from the Server\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
//[Index 2] -> Total of Time Spent by the DB Server
|
||||
@@ -332,7 +332,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_DBSERVER(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the Server, on all the SQL Querys\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@@ -344,7 +344,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_DBSERVER(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the Server, on the last SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@@ -356,7 +356,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_TOTAL_TIME_TRANSFERING(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Refence to time Spent by the Server, transfering all the results SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@@ -368,7 +368,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_CON_GET_LAST_TIME_TRANSFERING(node,time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the Server, transfering the result of the last SQL Query\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@@ -380,7 +380,7 @@ c_db_stats(void) {
|
||||
head = HeadOfTerm(list);
|
||||
list = TailOfTerm(list);
|
||||
MYDDAS_STATS_GET_DB_ROW_FUNCTION(time);
|
||||
Yap_unify(head, MkIntegerTerm((int)time));
|
||||
Yap_unify(head, MkIntegerTerm((Int)time));
|
||||
#ifdef DEBUG
|
||||
printf ("Reference to time Spent by the db_row_function\n");
|
||||
MYDDAS_STATS_PRINT_TIME_STRUCT(time);
|
||||
@@ -395,7 +395,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Bytes Transfered by the DB Server from all querys\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
//[Index 8] -> Total of Bytes Transfered by the
|
||||
@@ -406,7 +406,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Bytes Transfered by the DB Server on the last query\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
//[Index 9] -> Number of querys made to the DBserver
|
||||
@@ -416,7 +416,7 @@ c_db_stats(void) {
|
||||
Yap_unify(head, MkIntegerTerm(number));
|
||||
#ifdef DEBUG
|
||||
printf ("Number of Querys made to the server\n");
|
||||
printf ("%lu\n\n",number);
|
||||
printf ("%lu\n\n",(unsigned long)number);
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user