cmake and jit

This commit is contained in:
Vítor Santos Costa 2015-01-26 04:02:46 +00:00
parent 9d4b59f7d6
commit bc1e70758e
49 changed files with 1397 additions and 1311 deletions

View File

@ -532,6 +532,7 @@ Term Yap_XREGS[MaxTemps]; /* 29 */
#include "arith2.h" #include "arith2.h"
// #include "print_preg.h" // #include "print_preg.h"
//#include "sprint_op.hpp" //#include "sprint_op.hpp"
//#include "print_op.hpp" //#include "print_op.hpp"
@ -540,11 +541,27 @@ Term Yap_XREGS[MaxTemps]; /* 29 */
#include "IsGround.h" #include "IsGround.h"
#include "yaam_macros.hpp" #include "yaam_macros.hpp"
#include "fprintblock.h" #include "fprintblock.h"
#endif /* YAP_JIT */
#if YAP_DBG_PREDS #if YAP_DBG_PREDS
#include "debug_printers.h" #include "debug_printers.h"
#endif #endif
struct JIT_Compiler *J;
NativeContext *NativeArea;
IntermediatecodeContext *IntermediatecodeArea;
void shutdown_llvm(void);
CELL l;
short global;
CELL nnexec;
yamop* HEADPREG;
CELL BLOCK;
CELL BLOCKADDRESS;
CELL FAILED;
#endif /* YAP_JIT */
#ifdef COROUTINING #ifdef COROUTINING
/* /*
Imagine we are interrupting the execution, say, because we have a spy Imagine we are interrupting the execution, say, because we have a spy

View File

@ -329,12 +329,9 @@
@file c_interface.c @file c_interface.c
*/ */
#ifndef C_INTERFACE_C
#define Bool int #define C_INTERFACE_C 1
#define flt double
#define C_INTERFACE 1
#define _yap_c_interface_h 1
#include <stdlib.h> #include <stdlib.h>
#include "Yap.h" #include "Yap.h"
@ -355,7 +352,6 @@
// we cannot consult YapInterface.h, that conflicts with what we declare, though // we cannot consult YapInterface.h, that conflicts with what we declare, though
// it shouldn't // it shouldn't
#include "YapInterface.h" #include "YapInterface.h"
#define _yap_c_interface_h 1
#include "pl-shared.h" #include "pl-shared.h"
#include "YapText.h" #include "YapText.h"
#include "pl-read.h" #include "pl-read.h"
@ -371,6 +367,9 @@
#include <malloc.h> #include <malloc.h>
#endif #endif
X_API int
YAP_Reset(yap_reset_t mode);
#if !HAVE_STRNCPY #if !HAVE_STRNCPY
#define strncpy(X,Y,Z) strcpy(X,Y) #define strncpy(X,Y,Z) strcpy(X,Y)
#endif #endif
@ -490,33 +489,33 @@ doexpand(UInt sz)
return TRUE; return TRUE;
} }
X_API Term X_API YAP_Term
YAP_A(int i) YAP_A(int i)
{ {
CACHE_REGS CACHE_REGS
return(Deref(XREGS[i])); return(Deref(XREGS[i]));
} }
X_API Bool X_API YAP_Bool
YAP_IsIntTerm(Term t) YAP_IsIntTerm(YAP_Term t)
{ {
return IsIntegerTerm(t); return IsIntegerTerm(t);
} }
X_API Bool X_API YAP_Bool
YAP_IsNumberTerm(Term t) YAP_IsNumberTerm(YAP_Term t)
{ {
return IsIntegerTerm(t) || IsIntTerm(t) || IsFloatTerm(t) || IsBigIntTerm(t); return IsIntegerTerm(t) || IsIntTerm(t) || IsFloatTerm(t) || IsBigIntTerm(t);
} }
X_API Bool X_API YAP_Bool
YAP_IsLongIntTerm(Term t) YAP_IsLongIntTerm(YAP_Term t)
{ {
return IsLongIntTerm(t); return IsLongIntTerm( t );
} }
X_API Bool X_API YAP_Bool
YAP_IsBigNumTerm(Term t) YAP_IsBigNumTerm(YAP_Term t)
{ {
#if USE_GMP #if USE_GMP
CELL *pt; CELL *pt;
@ -531,8 +530,8 @@ YAP_IsBigNumTerm(Term t)
#endif #endif
} }
X_API Bool X_API YAP_Bool
YAP_IsRationalTerm(Term t) YAP_IsRationalTerm(YAP_Term t)
{ {
#if USE_GMP #if USE_GMP
CELL *pt; CELL *pt;
@ -547,56 +546,55 @@ YAP_IsRationalTerm(Term t)
#endif #endif
} }
X_API Bool X_API YAP_Bool
YAP_IsVarTerm(Term t) YAP_IsVarTerm(YAP_Term t)
{ {
return (IsVarTerm(t)); return (IsVarTerm(t));
} }
X_API Bool X_API YAP_Bool
YAP_IsNonVarTerm(Term t) YAP_IsNonVarTerm(YAP_Term t)
{ {
return (IsNonVarTerm(t)); return (IsNonVarTerm(t));
} }
X_API Bool X_API YAP_Bool
YAP_IsFloatTerm(Term t) YAP_IsFloatTerm(Term t)
{ {
return (IsFloatTerm(t)); return (IsFloatTerm(t));
} }
X_API Bool X_API YAP_Bool
YAP_IsDbRefTerm(Term t) YAP_IsDbRefTerm(Term t)
{ {
return (IsDBRefTerm(t)); return (IsDBRefTerm(t));
} }
X_API Bool X_API YAP_Bool
YAP_IsAtomTerm(Term t) YAP_IsAtomTerm(Term t)
{ {
return (IsAtomTerm(t)); return (IsAtomTerm(t));
} }
X_API Bool X_API YAP_Bool
YAP_IsPairTerm(Term t) YAP_IsPairTerm(Term t)
{ {
return (IsPairTerm(t)); return (IsPairTerm(t));
} }
X_API Bool X_API YAP_Bool
YAP_IsApplTerm(Term t) YAP_IsApplTerm(Term t)
{ {
return (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t))); return (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t)));
} }
X_API Bool X_API YAP_Bool
YAP_IsCompoundTerm(Term t) YAP_IsCompoundTerm(Term t)
{ {
return (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t))) || return (IsApplTerm(t) && !IsExtensionFunctor(FunctorOfTerm(t))) ||
IsPairTerm(t); IsPairTerm(t);
} }
X_API Term X_API Term
YAP_MkIntTerm(Int n) YAP_MkIntTerm(Int n)
{ {
@ -633,7 +631,7 @@ YAP_MkBigNumTerm(void *big)
#endif /* USE_GMP */ #endif /* USE_GMP */
} }
X_API int X_API YAP_Bool
YAP_BigNumOfTerm(Term t, void *b) YAP_BigNumOfTerm(Term t, void *b)
{ {
#if USE_GMP #if USE_GMP
@ -663,7 +661,7 @@ YAP_MkRationalTerm(void *big)
#endif /* USE_GMP */ #endif /* USE_GMP */
} }
X_API int X_API YAP_Bool
YAP_RationalOfTerm(Term t, void *b) YAP_RationalOfTerm(Term t, void *b)
{ {
#if USE_GMP #if USE_GMP
@ -733,8 +731,8 @@ YAP_MkFloatTerm(double n)
return t; return t;
} }
X_API flt X_API YAP_Float
YAP_FloatOfTerm(Term t) YAP_FloatOfTerm(YAP_Term t)
{ {
return (FloatOfTerm(t)); return (FloatOfTerm(t));
} }
@ -755,7 +753,7 @@ YAP_AtomOfTerm(Term t)
} }
X_API int X_API bool
YAP_IsWideAtom(Atom a) YAP_IsWideAtom(Atom a)
{ {
return IsWideAtom(a); return IsWideAtom(a);
@ -1129,7 +1127,7 @@ YAP_cut_up(void)
RECOVER_B(); RECOVER_B();
} }
X_API int X_API bool
YAP_Unify(Term t1, Term t2) YAP_Unify(Term t1, Term t2)
{ {
Int out; Int out;
@ -2280,11 +2278,11 @@ run_emulator(YAP_dogoalinfo *dgi USES_REGS)
return out; return out;
} }
X_API int X_API bool
YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi) YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
{ {
CACHE_REGS CACHE_REGS
int out; bool out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
LOCAL_PrologMode = UserMode; LOCAL_PrologMode = UserMode;
@ -2307,12 +2305,12 @@ YAP_EnterGoal(PredEntry *pe, Term *ptr, YAP_dogoalinfo *dgi)
return out; return out;
} }
X_API int X_API bool
YAP_RetryGoal(YAP_dogoalinfo *dgi) YAP_RetryGoal(YAP_dogoalinfo *dgi)
{ {
CACHE_REGS CACHE_REGS
choiceptr myB; choiceptr myB;
int out; bool out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
myB = (choiceptr)(LCL0-dgi->b); myB = (choiceptr)(LCL0-dgi->b);
@ -2334,7 +2332,7 @@ YAP_RetryGoal(YAP_dogoalinfo *dgi)
return out; return out;
} }
X_API int X_API bool
YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi) YAP_LeaveGoal(int backtrack, YAP_dogoalinfo *dgi)
{ {
CACHE_REGS CACHE_REGS
@ -2438,7 +2436,7 @@ YAP_AllocExternalDataInStack(size_t bytes)
return t; return t;
} }
X_API Bool X_API YAP_Bool
YAP_IsExternalDataInStackTerm(Term t) YAP_IsExternalDataInStackTerm(Term t)
{ {
return IsExternalBlobTerm(t, EXTERNAL_BLOB); return IsExternalBlobTerm(t, EXTERNAL_BLOB);
@ -2477,7 +2475,7 @@ Term YAP_NewOpaqueObject(YAP_opaque_tag_t tag, size_t bytes)
return t; return t;
} }
X_API Bool X_API YAP_Bool
YAP_IsOpaqueObjectTerm(Term t, YAP_opaque_tag_t tag) YAP_IsOpaqueObjectTerm(Term t, YAP_opaque_tag_t tag)
{ {
return IsExternalBlobTerm(t, (CELL)tag); return IsExternalBlobTerm(t, (CELL)tag);
@ -2549,11 +2547,11 @@ YAP_RunGoalOnce(Term t)
return out; return out;
} }
X_API int X_API bool
YAP_RestartGoal(void) YAP_RestartGoal(void)
{ {
CACHE_REGS CACHE_REGS
int out; bool out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
if (LOCAL_AllowRestart) { if (LOCAL_AllowRestart) {
P = (yamop *)FAILCODE; P = (yamop *)FAILCODE;
@ -2572,7 +2570,7 @@ YAP_RestartGoal(void)
return(out); return(out);
} }
X_API int X_API bool
YAP_ShutdownGoal(int backtrack) YAP_ShutdownGoal(int backtrack)
{ {
CACHE_REGS CACHE_REGS
@ -2616,11 +2614,11 @@ YAP_ShutdownGoal(int backtrack)
return TRUE; return TRUE;
} }
X_API int X_API bool
YAP_ContinueGoal(void) YAP_ContinueGoal(void)
{ {
CACHE_REGS CACHE_REGS
int out; bool out;
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
LOCAL_PrologMode = UserMode; LOCAL_PrologMode = UserMode;
@ -2653,7 +2651,7 @@ YAP_PruneGoal(YAP_dogoalinfo *gi)
RECOVER_B(); RECOVER_B();
} }
X_API int X_API bool
YAP_GoalHasException(Term *t) YAP_GoalHasException(Term *t)
{ {
CACHE_REGS CACHE_REGS
@ -4189,7 +4187,9 @@ YAP_IntToAtom(Int i)
{ {
return SWI_Atoms[i]; return SWI_Atoms[i];
} }
#endif // C_INTERFACE_C
/** /**
@} @}
*/ */

View File

@ -2181,6 +2181,22 @@ c_head(Term t, compiler_struct *cglobs)
Yap_emit(native_op, 0, 0, &cglobs->cint); Yap_emit(native_op, 0, 0, &cglobs->cint);
Yap_emit(ensure_space_op, Zero , Zero, &cglobs->cint); Yap_emit(ensure_space_op, Zero , Zero, &cglobs->cint);
cglobs->space_op = cglobs->cint.cpc; cglobs->space_op = cglobs->cint.cpc;
#ifdef BEAM
if (EAM) {
Yap_emit(run_op,Zero,(UInt) cglobs->cint.CurrentPred,&cglobs->cint);
}
#endif
if (Yap_ExecutionMode == MIXED_MODE || Yap_ExecutionMode == COMPILED)
#if YAP_JIT
Yap_emit(native_op, 0, 0, &cglobs->cint);
#else
{
if (Yap_ExecutionMode == MIXED_MODE)
Yap_NilError(NOJIT_ERROR, "mixed");
else /* Yap_ExecutionMode == COMPILED */
Yap_NilError(NOJIT_ERROR, "just compiled");
}
#endif
c_args(t, 0, cglobs); c_args(t, 0, cglobs);
} }

View File

@ -76,13 +76,13 @@ Yap_PrintPredName( PredEntry *ap )
int Yap_HandleError( const char *s, ... ) { int Yap_HandleError( const char *s, ... ) {
CACHE_REGS CACHE_REGS
yap_error_number err = LOCAL_Error_TYPE; yap_error_number err = LOCAL_Error_TYPE;
char *serr; const char *serr;
LOCAL_Error_TYPE = YAP_NO_ERROR; LOCAL_Error_TYPE = YAP_NO_ERROR;
if (LOCAL_ErrorMessage) { if (LOCAL_ErrorMessage) {
serr = LOCAL_ErrorMessage; serr = LOCAL_ErrorMessage;
} else { } else {
serr = (char *)s; serr = s;
} }
switch (err) { switch (err) {
case OUT_OF_STACK_ERROR: case OUT_OF_STACK_ERROR:
@ -530,7 +530,7 @@ Yap_bug_location(yamop *pc)
static char tmpbuf[YAP_BUF_SIZE]; static char tmpbuf[YAP_BUF_SIZE];
yamop * yamop *
Yap_NilError(yap_error_number type, char *format,...) Yap_NilError(yap_error_number type, const char *format,...)
{ {
va_list ap; va_list ap;
yamop *res; yamop *res;
@ -544,7 +544,7 @@ Yap_NilError(yap_error_number type, char *format,...)
} }
yamop * yamop *
Yap_Error(yap_error_number type, Term where, char *format,...) Yap_Error(yap_error_number type, Term where, const char *format,...)
{ {
CACHE_REGS CACHE_REGS
va_list ap; va_list ap;

View File

@ -936,7 +936,7 @@ static void
InitStdPreds(void) InitStdPreds(void)
{ {
void initIO(void); void initIO(void);
Yap_InitCPreds(); Yap_InitCPreds();
Yap_InitBackCPreds(); Yap_InitBackCPreds();
BACKUP_MACHINE_REGS(); BACKUP_MACHINE_REGS();
@ -1474,4 +1474,3 @@ Yap_exit (int value)
closeFiles(TRUE); closeFiles(TRUE);
exit(value); exit(value);
} }

View File

@ -77,9 +77,7 @@ p_load_foreign( USES_REGS1 )
/* get the initialization function name */ /* get the initialization function name */
t1 = Deref(ARG3); t1 = Deref(ARG3);
InitProcName = RepAtom(AtomOfTerm(t1))->StrOfAE; InitProcName = RepAtom(AtomOfTerm(t1))->StrOfAE;
/* call the OS specific function for dynamic loading */ /* call the OS specific function for dynamic loading */
if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) { if(Yap_LoadForeign(ofiles,libs,InitProcName,&InitProc)==LOAD_SUCCEEDED) {

View File

@ -283,6 +283,7 @@ static char SccsId[] = "%W% %G%";
#include "eval.h" #include "eval.h"
#include "yapio.h" #include "yapio.h"
#include "pl-shared.h" #include "pl-shared.h"
#include "Foreign.h"
#ifdef TABLING #ifdef TABLING
#include "tab.macros.h" #include "tab.macros.h"
#endif /* TABLING */ #endif /* TABLING */
@ -293,7 +294,11 @@ static char SccsId[] = "%W% %G%";
#if HAVE_MALLOC_H #if HAVE_MALLOC_H
#include <malloc.h> #include <malloc.h>
#endif #endif
#if YAP_JIT
#include <JIT_Compiler.hpp>
#endif
#include <wchar.h> #include <wchar.h>
#include <fcntl.h>
static Int p_setval(USES_REGS1); static Int p_setval(USES_REGS1);
static Int p_value(USES_REGS1); static Int p_value(USES_REGS1);
@ -336,6 +341,25 @@ static Int p_access_yap_flags(USES_REGS1);
static Int p_set_yap_flags(USES_REGS1); static Int p_set_yap_flags(USES_REGS1);
static Int p_break(USES_REGS1); static Int p_break(USES_REGS1);
#if YAP_JIT
void* (*Yap_JitCall)(struct JIT_Compiler* jc, yamop* p);
void (* Yap_llvmShutdown)(void ) ;
Environment ExpEnv;
static Int p_jit(USES_REGS1) { /* '$set_value'(+Atom,+Atomic) */
void *jit_handle;
if ( (jit_handle = Yap_LoadForeignFile( YAP_YAPJITLIB, 0 ) ) ) {
if (!Yap_CallForeignFile(jit_handle, "init_jit") )
fprintf(stderr, "Could not load JIT\n" );
return FALSE;
}
return TRUE;
}
#endif /* YAP_JIT */
#ifdef BEAM #ifdef BEAM
Int use_eam(USES_REGS1); Int use_eam(USES_REGS1);
Int eager_split(USES_REGS1); Int eager_split(USES_REGS1);
@ -814,6 +838,38 @@ static Int
return (FALSE); return (FALSE);
} }
out = IntegerOfTerm(t); out = IntegerOfTerm(t);
#if YAP_JIT
if (ExpEnv.analysis_struc.stats_enabled || ExpEnv.analysis_struc.time_pass_enabled) {
if (strcmp(((char*)ExpEnv.analysis_struc.outfile), "STDERR")) {
int stderrcopy = dup(2);
if (strcmp(((char*)ExpEnv.analysis_struc.outfile), "STDOUT") == 0) {
dup2(1, 2);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
shutdown_llvm();
#pragma GCC diagnostic pop
dup2(stderrcopy, 2);
}
else {
int Outputfile = open(((char*)ExpEnv.analysis_struc.outfile), O_CREAT | O_APPEND | O_WRONLY, 0777);
if (Outputfile < 0) {
fprintf(stderr, "Error:: I can not write analysis passes's output on %s...\n", ((char*)ExpEnv.analysis_struc.outfile));
fprintf(stderr, " %s...\n", strerror(errno));
errno = 0;
exit(1);
}
dup2(Outputfile, 2);
shutdown_llvm();
close(Outputfile);
dup2(stderrcopy, 2);
}
close(stderrcopy);
}
else
shutdown_llvm();
}
#endif
Yap_exit(out); Yap_exit(out);
return TRUE; return TRUE;
} }
@ -1946,6 +2002,7 @@ static Int p_parallel_mode(USES_REGS1) { return FALSE; }
static Int p_yapor_workers(USES_REGS1) { return FALSE; } static Int p_yapor_workers(USES_REGS1) { return FALSE; }
#endif /* YAPOR */ #endif /* YAPOR */
void Yap_InitCPreds(void) { void Yap_InitCPreds(void) {
/* numerical comparison */ /* numerical comparison */
Yap_InitCPred("set_value", 2, p_setval, SafePredFlag | SyncPredFlag); Yap_InitCPred("set_value", 2, p_setval, SafePredFlag | SyncPredFlag);
@ -2027,12 +2084,18 @@ void Yap_InitCPreds(void) {
Yap_InitCPred("$set_flag", 4, p_set_flag, SyncPredFlag); Yap_InitCPred("$set_flag", 4, p_set_flag, SyncPredFlag);
Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag | SyncPredFlag); Yap_InitCPred("$has_yap_or", 0, p_has_yap_or, SafePredFlag | SyncPredFlag);
Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag | SyncPredFlag); Yap_InitCPred("$has_eam", 0, p_has_eam, SafePredFlag | SyncPredFlag);
#ifndef YAPOR #ifdef YAPOR
Yap_InitCPred("parallel_mode", 1, p_parallel_mode, Yap_InitCPred("parallel_mode", 1, p_parallel_mode,
SafePredFlag | SyncPredFlag); SafePredFlag | SyncPredFlag);
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers, Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers,
SafePredFlag | SyncPredFlag); SafePredFlag | SyncPredFlag);
#endif /* YAPOR */ #endif /* YAPOR */
#ifdef YAP_JIT
Yap_InitCPred("init", 1, p_parallel_mode,
SafePredFlag | SyncPredFlag);
Yap_InitCPred("$c_yapor_workers", 1, p_yapor_workers,
SafePredFlag | SyncPredFlag);
#endif /* YAPOR */
#ifdef INES #ifdef INES
Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag); Yap_InitCPred("euc_dist", 3, p_euc_dist, SafePredFlag);
Yap_InitCPred("loop", 0, p_loop, SafePredFlag); Yap_InitCPred("loop", 0, p_loop, SafePredFlag);
@ -2089,6 +2152,10 @@ void Yap_InitCPreds(void) {
#if defined(YAPOR) || defined(TABLING) #if defined(YAPOR) || defined(TABLING)
Yap_init_optyap_preds(); Yap_init_optyap_preds();
#endif /* YAPOR || TABLING */ #endif /* YAPOR || TABLING */
#if YAP_JIT
Yap_InitCPred("jit", 0, p_jit,
SafePredFlag | SyncPredFlag);
#endif
Yap_InitThreadPreds(); Yap_InitThreadPreds();
{ {
void (*(*(p)))(void) = E_Modules; void (*(*(p)))(void) = E_Modules;

View File

@ -63,10 +63,10 @@ set(YAP_ROOTDIR ${prefix})
# erootdir -> rootdir # erootdir -> rootdir
# bindir defined above # bindir defined above
# libdir defined above # libdir defined above
set(YAP_LIBDIR "${dlls}") set(YAP_LIBDIR "${dlls}")
set(YAP_SHAREDIR "${datarootdir}") set(YAP_SHAREDIR "${datarootdir}")
set(YAP_BINDIR "${bindir}") set(YAP_BINDIR "${bindir}")
set(YAP_ROOTDIR "${prefix}") set(YAP_ROOTDIR "${prefix}")
set(YAP_YAPLIB libYap${CMAKE_SHARED_LIBRARY_SUFFIX}) set(YAP_YAPLIB libYap${CMAKE_SHARED_LIBRARY_SUFFIX})
set(YAP_STARTUP startup.yss) set(YAP_STARTUP startup.yss)
@ -97,18 +97,18 @@ set ( DEF_STACKSPACE 0 )
set ( DEF_HEAPSPACE 0 ) set ( DEF_HEAPSPACE 0 )
set ( DEF_TRAILSPACE 0 ) set ( DEF_TRAILSPACE 0 )
# option (WITH_RATIONAL_TREES "support infinite rational trees" ON) # option (RATIONAL_TREES "support infinite rational trees" ON)
add_definitions (-DRATIONAL_TREES=1) add_definitions (-DRATIONAL_TREES=1)
# option (WITH_COROUTINING # option (COROUTINING
# "support co-routining, attributed variables and constraints" ON) # "support co-routining, attributed variables and constraints" ON)
add_definitions (-DCOROUTINING=1) add_definitions (-DCOROUTINING=1)
# if (WITH_RATIONAL_TREES and WITH_COROUTINING) # if (RATIONAL_TREES and COROUTINING)
#TODO: install (cd LGPL/clp ; $(MAKE) install) #TODO: install (cd LGPL/clp ; $(MAKE) install)
# endif (WITH_RATIONAL_TREES and WITH_COROUTINING) # endif (RATIONAL_TREES and COROUTINING)
# option (WITH_DEPTH_LIMIT # option (DEPTH_LIMIT
# "support depth-bound computation" ON) # "support depth-bound computation" ON)
add_definitions (-DDEPTH_LIMIT=1) add_definitions (-DDEPTH_LIMIT=1)
@ -133,15 +133,31 @@ if ( ${C_COMPILER} MATCHES "Intel")
set (HAVE_GCC 1) set (HAVE_GCC 1)
endif() endif()
add_definitions( -Wall -Wstrict-prototypes -Wmissing-prototypes)
add_definitions(-D_YAP_NOT_INSTALLED_=1 -DHAVE_CONFIG_H)
add_definitions(-D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700)
message(STATUS "Original CMAKE_C_FLAGS ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DLOW_LEVEL_TRACER=1 -DDEBUG=1 ")
# Compilation Flags
if (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -fstrict-aliasing -freorder-blocks -fsched-interblock")
endif()
message(STATUS "Running with CMAKE_C_FLAGS ${CMAKE_C_FLAGS}")
if (HAVE_GCC) if (HAVE_GCC)
# replace instructions codes by the address of their code # replace instructions codes by the address of their code
option (WITH_THREADED_CODE "Use threaded code" ON) option (THREADED_CODE "threaded code" ON)
if (WITH_THREADED_CODE) if (THREADED_CODE)
set (USE_THREADED_CODE 1) set (USE_THREADED_CODE 1)
endif (WITH_THREADED_CODE) add_definitions(-DTHREADEAD_CODE=1)
endif (THREADED_CODE)
endif (HAVE_GCC) endif (HAVE_GCC)
# #
set (BUILD_SHARED_LIBS ON) set (BUILD_SHARED_LIBS ON)
# #
@ -149,35 +165,33 @@ set (BUILD_SHARED_LIBS ON)
# #
add_subdirectory (os/libtai) add_subdirectory (os/libtai)
add_subdirectory (CXX) option (TABLING "Support tabling" ON)
if (TABLING)
option (WITH_TABLING "Support tabling" ON)
if (WITH_TABLING)
#this depends on DEPTH_LIMIT define it after #this depends on DEPTH_LIMIT define it after
#this macro should realy be in config.h or other like it #this macro should realy be in config.h or other like it
#and it is used across several files outside OPTYap #and it is used across several files outside OPTYap
add_definitions (-DTABLING=1) add_definitions (-DTABLING=1)
include_directories (OPTYap) include_directories (OPTYap)
add_subdirectory (OPTYap) add_subdirectory (OPTYap)
endif(WITH_TABLING) endif(TABLING)
option (WITH_EAM "enable EAM (Extended Andorra Model)" OFF) option (EAM "enable EAM (Extended Andorra Model)" OFF)
if (WITH_EAM) if (EAM)
#this macro should realy be in config.h or other like it #this macro should realy be in config.h or other like it
add_definitions (-DBEAM=1) add_definitions (-DBEAM=1)
include_directories (BEAM) include_directories (BEAM)
add_subdirectory (BEAM) add_subdirectory (BEAM)
set (EXTRALIBS ${EXTRALIBS} beam) set (EXTRALIBS ${EXTRALIBS} beam)
endif (WITH_EAM) endif (EAM)
#TODO: option (or-parallelism) #TODO: option (or-parallelism)
# option (WITH_WAM_Profile # option (WAM_Profile
# "support low level profiling of abstract machine" OFF) # "support low level profiling of abstract machine" OFF)
option (WITH_Low_Level_Tracer option (Low_Level_Tracer
"support for procedure-call tracing" OFF) "support for procedure-call tracing" OFF)
#TODO: #TODO:
@ -190,29 +204,29 @@ option (System_Threads
# #
set(IOLIB_SOURCES set(IOLIB_SOURCES
os/pl-buffer.c os/pl-buffer.c
os/pl-codelist.c os/pl-codelist.c
os/pl-ctype.c os/pl-ctype.c
os/pl-dtoa.c os/pl-dtoa.c
os/pl-error.c os/pl-error.c
os/pl-file.c os/pl-file.c
os/pl-files.c os/pl-files.c
os/pl-fmt.c os/pl-fmt.c
os/pl-glob.c os/pl-glob.c
os/pl-option.c os/pl-option.c
os/pl-nt.c os/pl-nt.c
os/pl-os.c os/pl-os.c
os/pl-privitf.c os/pl-privitf.c
os/pl-prologflag.c os/pl-prologflag.c
os/pl-read.c os/pl-read.c
os/pl-rl.c os/pl-rl.c
os/pl-stream.c os/pl-stream.c
os/pl-string.c os/pl-string.c
os/pl-table.c os/pl-table.c
os/pl-tai.c os/pl-tai.c
os/pl-text.c os/pl-text.c
os/pl-utf8.c os/pl-utf8.c
os/pl-write.c os/pl-write.c
C/pl-yap.c C/pl-yap.c
) )
@ -240,47 +254,47 @@ set (ABSMI_SOURCES
set (ENGINE_SOURCES set (ENGINE_SOURCES
${ABSMI_SOURCES} ${ABSMI_SOURCES}
C/agc.c C/agc.c
C/adtdefs.c C/adtdefs.c
C/alloc.c C/alloc.c
C/amasm.c C/amasm.c
C/analyst.c C/analyst.c
C/arrays.c C/arrays.c
C/arith0.c C/arith0.c
C/arith1.c C/arith1.c
C/arith2.c C/arith2.c
C/atomic.c C/atomic.c
C/attvar.c C/attvar.c
C/bignum.c C/bignum.c
C/bb.c C/bb.c
C/cdmgr.c C/cdmgr.c
C/cmppreds.c C/cmppreds.c
C/compiler.c C/compiler.c
C/computils.c C/computils.c
C/corout.c C/corout.c
C/cut_c.c C/cut_c.c
C/dbase.c C/dbase.c
C/dlmalloc.c C/dlmalloc.c
C/errors.c C/errors.c
C/eval.c C/eval.c
C/exec.c C/exec.c
C/exo.c C/exo.c
C/exo_udi.c C/exo_udi.c
C/globals.c C/globals.c
C/gmp_support.c C/gmp_support.c
C/gprof.c C/gprof.c
C/grow.c C/grow.c
C/heapgc.c C/heapgc.c
C/index.c C/index.c
C/init.c C/init.c
C/inlines.c C/inlines.c
C/iopreds.c C/iopreds.c
C/depth_bound.c C/depth_bound.c
C/mavar.c C/mavar.c
C/modules.c C/modules.c
C/other.c C/other.c
C/parser.c C/parser.c
C/qlyr.c C/qlyr.c
C/qlyw.c C/qlyw.c
C/range.c C/range.c
C/save.c C/save.c
@ -290,48 +304,48 @@ set (ENGINE_SOURCES
C/stdpreds.c C/stdpreds.c
C/sysbits.c C/sysbits.c
C/text.c C/text.c
C/threads.c C/threads.c
C/tracer.c C/tracer.c
C/unify.c C/unify.c
C/userpreds.c C/userpreds.c
C/utilpreds.c C/utilpreds.c
C/yap-args.c C/yap-args.c
C/write.c C/write.c
C/ypstdio.c C/ypstdio.c
library/dialect/swi/fli/swi.c library/dialect/swi/fli/swi.c
library/dialect/swi/fli/blobs.c library/dialect/swi/fli/blobs.c
C/udi.c C/udi.c
#packages/udi/rtree.c #packages/udi/rtree.c
#packages/udi/rtree_udi.c #packages/udi/rtree_udi.c
# ${IOLIB_SOURCES} # ${IOLIB_SOURCES}
# MPI_SOURCES # MPI_SOURCES
) )
set(C_INTERFACE_SOURCES set(C_INTERFACE_SOURCES
C/load_foreign.c C/load_foreign.c
C/load_dl.c C/load_dl.c
C/load_dld.c C/load_dld.c
C/load_dyld.c C/load_dyld.c
C/load_none.c C/load_none.c
C/load_aout.c C/load_aout.c
C/load_aix.c C/load_aix.c
C/load_dll.c C/load_dll.c
C/load_shl.c C/load_shl.c
C/c_interface.c C/c_interface.c
C/clause_list.c C/clause_list.c
) )
SET(OPTYAP_SOURCES SET(OPTYAP_SOURCES
OPTYap/or.memory.c OPTYap/or.memory.c
OPTYap/opt.init.c OPTYap/opt.init.c
OPTYap/opt.preds.c OPTYap/opt.preds.c
OPTYap/or.copy_engine.c OPTYap/or.copy_engine.c
OPTYap/or.cow_engine.c OPTYap/or.cow_engine.c
OPTYap/or.sba_engine.c OPTYap/or.sba_engine.c
OPTYap/or.thread_engine.c OPTYap/or.thread_engine.c
OPTYap/or.scheduler.c OPTYap/or.scheduler.c
OPTYap/or.cut.c OPTYap/or.cut.c
OPTYap/tab.tries.c OPTYap/tab.tries.c
OPTYap/tab.completion.c OPTYap/tab.completion.c
) )
@ -342,28 +356,28 @@ set(STATIC_SOURCES
#NOT INCLUDED FOR NOW #NOT INCLUDED FOR NOW
) )
set(CONSOLE_SOURCES console/yap.c) set(CONSOLE_SOURCES console/yap.c)
#MPI STUFF #MPI STUFF
# library/mpi/mpi.c library/mpi/mpe.c # library/mpi/mpi.c library/mpi/mpe.c
# library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c # library/lammpi/yap_mpi.c library/lammpi/hash.c library/lammpi/prologterms2c.c
# ) # )
#WIN STUFF #WIN STUFF
# SET(PLCONS_SOURCES # SET(PLCONS_SOURCES
# console/LGPL/pl-nt.c # console/LGPL/pl-nt.c
# console/LGPL/pl-ntcon.c # console/LGPL/pl-ntcon.c
# console/LGPL/pl-ntconsole.c # console/LGPL/pl-ntconsole.c
# console/LGPL/pl-ntmain.c # console/LGPL/pl-ntmain.c
# ) # )
## define system ## define system
add_library(libYap SHARED add_library(libYap SHARED
${ENGINE_SOURCES} ${ENGINE_SOURCES}
${IOLIB_SOURCES} ${IOLIB_SOURCES}
${C_INTERFACE_SOURCES} ${C_INTERFACE_SOURCES}
${STATIC_SOURCES} ${STATIC_SOURCES}
${OPTYAP_SOURCES} ${OPTYAP_SOURCES}
$<TARGET_OBJECTS:libyaptai> $<TARGET_OBJECTS:libyaptai>
) )
@ -377,7 +391,7 @@ set_target_properties(libYap
OUTPUT_NAME Yap OUTPUT_NAME Yap
) )
option (WITH_Dynamic_BDD option (Dynamic_BDD
"dynamic bdd library" OFF) "dynamic bdd library" OFF)
#TODO: #TODO:
@ -390,51 +404,51 @@ option (WITH_Dynamic_BDD
include (Config) include (Config)
macro_optional_find_package (GMP ON) macro_optional_find_package (GMP ON)
macro_log_feature (GMP_FOUND "libgmp" macro_log_feature (GMP_FOUND "libgmp"
"GNU Multiple Precision" "GNU Multiple Precision"
"http://gmplib.org") "http://gmplib.org")
if (GMP_FOUND) if (GMP_FOUND)
include_directories (${GMP_INCLUDE_DIR}) include_directories (${GMP_INCLUDE_DIR})
target_link_libraries(libYap ${GMP_LIBRARIES}) target_link_libraries(libYap ${GMP_LIBRARIES})
#config.h needs this (TODO: change in code latter) #config.h needs this (TODO: change in code latter)
set (USE_GMP 1) set (USE_GMP 1)
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIR} ) # set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIR} )
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GMP_LIBRARIES} ) # set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GMP_LIBRARIES} )
endif (GMP_FOUND) endif (GMP_FOUND)
macro_optional_find_package (Readline ON) macro_optional_find_package (Readline ON)
macro_log_feature (READLINE_FOUND "libreadline" macro_log_feature (READLINE_FOUND "libreadline"
"GNU Readline Library (or similar)" "GNU Readline Library (or similar)"
"http://www.gnu.org/software/readline") "http://www.gnu.org/software/readline")
if (READLINE_FOUND) if (READLINE_FOUND)
include_directories (${READLINE_INCLUDE_DIR}) include_directories (${READLINE_INCLUDE_DIR})
target_link_libraries(libYap ${READLINE_LIBRARIES}) target_link_libraries(libYap ${READLINE_LIBRARIES})
set (HAVE_READLINE_READLINE_H 1) set (HAVE_READLINE_READLINE_H 1)
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${READLINE_INCLUDE_DIR} ) # set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${READLINE_INCLUDE_DIR} )
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${READLINE_LIBRARIES} ) # set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${READLINE_LIBRARIES} )
check_function_exists( add_history HAVE_ADD_HISTORY ) check_function_exists( add_history HAVE_ADD_HISTORY )
check_function_exists( rl_begin_undo_group HAVE_RL_BEGIN_UNDO_GROUP) check_function_exists( rl_begin_undo_group HAVE_RL_BEGIN_UNDO_GROUP)
check_function_exists( rl_clear_pending_input HAVE_RL_CLEAR_PENDING_INPUT) check_function_exists( rl_clear_pending_input HAVE_RL_CLEAR_PENDING_INPUT)
check_function_exists( rl_discard_argument HAVE_RL_DISCARD_ARGUMENT) check_function_exists( rl_discard_argument HAVE_RL_DISCARD_ARGUMENT)
check_function_exists( rl_filename_completion_function HAVE_RL_FILENAME_COMPLETION_FUNCTION) check_function_exists( rl_filename_completion_function HAVE_RL_FILENAME_COMPLETION_FUNCTION)
check_function_exists( rl_free_line_state HAVE_RL_FREE_LINE_STATE ) check_function_exists( rl_free_line_state HAVE_RL_FREE_LINE_STATE )
check_function_exists( rl_insert_close HAVE_RL_INSERT_CLOSE ) check_function_exists( rl_insert_close HAVE_RL_INSERT_CLOSE )
check_function_exists( rl_reset_after_signal HAVE_RL_RESET_AFTER_SIGNAL ) check_function_exists( rl_reset_after_signal HAVE_RL_RESET_AFTER_SIGNAL )
check_function_exists( rl_set_keyboard_input_timeout HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT ) check_function_exists( rl_set_keyboard_input_timeout HAVE_RL_SET_KEYBOARD_INPUT_TIMEOUT )
check_function_exists( rl_set_prompt HAVE_RL_SET_PROMPT) check_function_exists( rl_set_prompt HAVE_RL_SET_PROMPT)
check_symbol_exists( rl_catch_signals stdio.h;readline/readline.h HAVE_DECL_RL_CATCH_SIGNALS ) check_symbol_exists( rl_catch_signals stdio.h;readline/readline.h HAVE_DECL_RL_CATCH_SIGNALS )
check_symbol_exists( rl_completion_func_t stdio.h;readline/readline.h HAVE_DECL_RL_COMPLETION_FUNC_T ) check_symbol_exists( rl_completion_func_t stdio.h;readline/readline.h HAVE_DECL_RL_COMPLETION_FUNC_T )
check_symbol_exists( rl_done stdio.h;readline/readline.h HAVE_DECL_RL_DONE ) check_symbol_exists( rl_done stdio.h;readline/readline.h HAVE_DECL_RL_DONE )
check_symbol_exists( rl_hook_func_t stdio.h;readline/readline.h HAVE_DECL_RL_HOOK_FUNC_T ) check_symbol_exists( rl_hook_func_t stdio.h;readline/readline.h HAVE_DECL_RL_HOOK_FUNC_T )
check_symbol_exists( rl_event_hook stdio.h;readline/readline.h HAVE_DECL_RL_EVENT_HOOK ) check_symbol_exists( rl_event_hook stdio.h;readline/readline.h HAVE_DECL_RL_EVENT_HOOK )
check_symbol_exists( rl_readline_state stdio.h;readline/readline.h HAVE_DECL_RL_READLINE_STATE ) check_symbol_exists( rl_readline_state stdio.h;readline/readline.h HAVE_DECL_RL_READLINE_STATE )
endif (READLINE_FOUND) endif (READLINE_FOUND)
macro_optional_find_package (Threads OFF) macro_optional_find_package (Threads OFF)
macro_log_feature (THREADS_FOUND "Threads Support" macro_log_feature (THREADS_FOUND "Threads Support"
"GNU Threads Library (or similar)" "GNU Threads Library (or similar)"
"http://www.gnu.org/software/threads") "http://www.gnu.org/software/threads")
if (THREADS_FOUND) if (THREADS_FOUND)
# #
@ -462,14 +476,14 @@ if (THREADS_FOUND)
# :: # ::
# #
set( THREADS_PREFER_PTHREAD_FLAG ON) set( THREADS_PREFER_PTHREAD_FLAG ON)
if (CMAKE_USE_PTHREADS_INIT) if (CMAKE_USE_PTHREADS_INIT)
target_link_libraries(libYap pthread) target_link_libraries(libYap pthread)
set (HAVE_READLINE_READLINE_H 1) set (HAVE_READLINE_READLINE_H 1)
set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )
check_function_exists( pthread_mutexattr_setkind_np HAVE_PTHREAD_MUTEXATTR_SETKIND_NP ) check_function_exists( pthread_mutexattr_setkind_np HAVE_PTHREAD_MUTEXATTR_SETKIND_NP )
check_function_exists( pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE ) check_function_exists( pthread_mutexattr_settype HAVE_PTHREAD_MUTEXATTR_SETTYPE )
check_function_exists( pthread_setconcurrency HAVE_PTHREAD_SETCONCURRENCY ) check_function_exists( pthread_setconcurrency HAVE_PTHREAD_SETCONCURRENCY )
endif (CMAKE_USE_PTHREADS_INIT) endif (CMAKE_USE_PTHREADS_INIT)
# #
# Please note that the compiler flag can only be used with the imported # Please note that the compiler flag can only be used with the imported
@ -477,44 +491,44 @@ if (THREADS_FOUND)
# recommended for new code. # recommended for new code.
endif (THREADS_FOUND) endif (THREADS_FOUND)
cmake_dependent_option (WITH_PThreadLocking cmake_dependent_option (PThreadLocking
"use pthread locking primitives for internal locking" ON "use pthread locking primitives for internal locking" ON
System_Threads OFF) System_Threads OFF)
option (Use_JIT add_subdirectory (CXX)
"use just-in-time compilation (experimental)" OFF)
if (Use_JIT)
macro_optional_find_package (LLVM ON)
macro_log_feature (LLVM_FOUND "LLVM JIT generator"
"The LLVM Compiler Infrastructure"
"http://www.llvm.org")
if (LLVM_FOUND)
add_subdirectory (JIT)
include_directories (JIT/HPP)
add_definitions(-DYAP_JIT=1)
endif (LLVM_FOUND)
endif (Use_JIT)
ADD_SUBDIRECTORY(library) ADD_SUBDIRECTORY(library)
ADD_SUBDIRECTORY(swi/library) ADD_SUBDIRECTORY(swi/library)
# ADD_SUBDIRECTORY(os) # ADD_SUBDIRECTORY(os)
# ADD_SUBDIRECTORY(packages) # ADD_SUBDIRECTORY(packages)
# ADD_SUBDIRECTORY(packages)
ADD_SUBDIRECTORY(pl) ADD_SUBDIRECTORY(pl)
macro_optional_add_subdirectory (packages/cuda) option (JIT
"use just-in-time compilation (experimental)" ON)
if (JIT)
macro_optional_find_package (LLVM ON)
macro_log_feature (LLVM_FOUND "LLVM JIT generator"
"The LLVM Compiler Infrastructure" "http://www.llvm.org")
if (LLVM_FOUND)
INCLUDE_DIRECTORIES(JIT/HPP)
add_definitions (-DYAP_JIT=1)
add_subdirectory (JIT)
endif (LLVM_FOUND)
endif (JIT)
macro_optional_add_subdirectory (packages/real)
macro_optional_add_subdirectory (packages/python) macro_optional_add_subdirectory (packages/gecode)
macro_optional_add_subdirectory (packages/raptor) macro_optional_add_subdirectory (packages/cuda)
macro_optional_add_subdirectory (packages/real)
macro_optional_add_subdirectory (packages/python)
macro_optional_add_subdirectory (packages/raptor)
#macro_optional_add_subdirectory (packages/archive) #macro_optional_add_subdirectory (packages/archive)
#macro_optional_add_subdirectory (packages/jpl) macro_optional_add_subdirectory (packages/jpl)
#macro_optional_add_subdirectory (packages/prosqlite) #macro_optional_add_subdirectory (packages/prosqlite)
@ -536,21 +550,21 @@ macro_optional_add_subdirectory (packages/raptor)
# option (CYGWIN # option (CYGWIN
# "use cygwin library in WIN32" OFF) # "use cygwin library in WIN32" OFF)
option (WITH_PRISM option (PRISM
"use PRISM system in YAP" ON) "use PRISM system in YAP" ON)
#TODO: #TODO:
option (WITH_Dynamic_Loading option (Dynamic_Loading
"compile YAP as a DLL" ON) "compile YAP as a DLL" ON)
#TODO: #TODO:
option (WITH_Static_compilation option (Static_compilation
"compile YAP statically" OFF) "compile YAP statically" OFF)
#TODO: #TODO:
option (Use_MALLOC option (MALLOC
"use malloc to allocate memory" ON) "use malloc to allocate memory" ON)
if (Use_MALLOC) if (MALLOC)
# use default allocator # use default allocator
set ( USE_SYSTEM_MALLOC 1 ) set ( USE_SYSTEM_MALLOC 1 )
endif() endif()
@ -563,7 +577,7 @@ option(CONDOR
# OPTION(WIN64 # OPTION(WIN64
# "compile YAP for win64" OFF) # "compile YAP for win64" OFF)
# option (WITH_APRIL # option (APRIL
# "compile Yap to support April ILP system" OFF) # "compile Yap to support April ILP system" OFF)
# option (DLCOMPAT # option (DLCOMPAT
# "use dlcompat library for dynamic loading on Mac OS X" OFF) # "use dlcompat library for dynamic loading on Mac OS X" OFF)
@ -572,9 +586,7 @@ option(CONDOR
# if (R_FOUND) # if (R_FOUND)
# MESSAGE(STATUS "RFOUND ${R_LIBRARIES} ${R_DEFINITIONS} ${R_EXECUTABLE}") # MESSAGE(STATUS "RFOUND ${R_LIBRARIES} ${R_DEFINITIONS} ${R_EXECUTABLE}")
# endif (R_FOUND) # endif (R_FOUND)
#TODO: check REAL_TARGET ENABLE_REAL #TODO: check REAL_TARGET REAL#TODO: Switch to feature detection
#TODO: Switch to feature detection
# OPTION(CHR # OPTION(CHR
# "install chr library" ON) # "install chr library" ON)
# OPTION(CLPQR # OPTION(CLPQR
@ -583,7 +595,7 @@ option(CONDOR
# "enable the cplint library using the CUDD library in DIR/lib" OFF) # "enable the cplint library using the CUDD library in DIR/lib" OFF)
# OPTION(yap_cv_clpbn_bp # OPTION(yap_cv_clpbn_bp
# "enable belief propagation solver in CLPBN." OFF) # "enable belief propagation solver in CLPBN." OFF)
# OPTION( # OPTION(
# SHARED PACKAGES with SWI # SHARED PACKAGES with SWI
# swi packages have both Makefile.in which we will use and # swi packages have both Makefile.in which we will use and
@ -602,23 +614,6 @@ option(CONDOR
## after we have all functionality in ## after we have all functionality in
# #
# Compilation Flags
if (CMAKE_COMPILER_IS_GNUCC)
message(STATUS "Original CMAKE_C_FLAGS ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wstrict-prototypes -Wmissing-prototypes")
message(STATUS "Running with CMAKE_C_FLAGS ${CMAKE_C_FLAGS}")
message(STATUS "Original CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g ")
message(STATUS "Runing with CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}")
message(STATUS "Original CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -fomit-frame-pointer -fstrict-aliasing -freorder-blocks -fsched-interblock")
message(STATUS "Running with CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}")
endif()
add_definitions( -Wall)
add_definitions(-D_YAP_NOT_INSTALLED_=1 -DHAVE_CONFIG_H -DLOW_LEVEL_TRACER=1 -DDEBUG=1)
add_definitions(-DTHREADEAD_CODE=1)
add_definitions(-D_GNU_SOURCE=1 -D_XOPEN_SOURCE=700)
configure_file ("${PROJECT_SOURCE_DIR}/config.h.cmake" configure_file ("${PROJECT_SOURCE_DIR}/config.h.cmake"
"${PROJECT_BINARY_DIR}/config.h" ) "${PROJECT_BINARY_DIR}/config.h" )
configure_file ("${PROJECT_SOURCE_DIR}/YapTermConfig.h.cmake" configure_file ("${PROJECT_SOURCE_DIR}/YapTermConfig.h.cmake"
@ -630,6 +625,26 @@ set_target_properties (yap-bin PROPERTIES OUTPUT_NAME yap)
target_link_libraries(yap-bin libYap ) target_link_libraries(yap-bin libYap )
if (JIT)
endif(JIT)
if (MPI_C_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS} ")
include_directories(${MPI_C_INCLUDE_PATH})
target_link_libraries(yap-bin ${MPI_C_LIBRARIES} )
if(MPI_C_COMPILE_FLAGS)
set_target_properties(yap-bin PROPERTIES
COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}")
endif()
if(MPI_C_LINK_FLAGS)
set_target_properties(yap-bin PROPERTIES
LINK_FLAGS "${MPI_C_LINK_FLAGS}")
endif()
endif (MPI_C_FOUND)
add_custom_target (main ALL DEPENDS ${YAP_STARTUP} ) # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) add_custom_target (main ALL DEPENDS ${YAP_STARTUP} ) # WORKING_DIRECTORY ${CMAKE_BINARY_DIR} )
install ( install (
@ -640,4 +655,3 @@ install (
) )
macro_display_feature_log() macro_display_feature_log()

View File

@ -1,12 +1,14 @@
add_library (Yap++ SHARED yapi.cpp) add_library (Yap++ SHARED yapi.cpp)
include_directories (H include os ${CMAKE_BINARY_DIR} ${GMP_INCLUDE_DIR})
target_link_libraries(Yap++ libYap) target_link_libraries(Yap++ libYap)
install(TARGETS Yap++ install(TARGETS Yap++
LIBRARY DESTINATION ${libdir} ) LIBRARY DESTINATION ${libdir} )
include_directories (${GMP_INCLUDE_DIR}) set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${GMP_INCLUDE_DIR} )
#set( CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${GMP_LIBRARIES} )

View File

@ -110,9 +110,3 @@ void Yap_ShutdownLoadForeign(void);
#define EAGER_LOADING 1 #define EAGER_LOADING 1
#define GLOBAL_LOADING 2 #define GLOBAL_LOADING 2

View File

@ -174,6 +174,10 @@
#define DUMMY_FILLER_FOR_ABS_TYPE int dummy; #define DUMMY_FILLER_FOR_ABS_TYPE int dummy;
#endif /* HAVE_GCC */ #endif /* HAVE_GCC */
/* funcions that return a generic pointer */
typedef void * (*fptr_t)(void);
/************************************************************************************************* /*************************************************************************************************
main exports in YapInterface.h main exports in YapInterface.h
*************************************************************************************************/ *************************************************************************************************/

View File

@ -167,8 +167,8 @@ Yap_PrintPredName( struct pred_entry *ap );
#endif #endif
void Yap_RestartYap(int); void Yap_RestartYap(int);
void Yap_exit(int); void Yap_exit(int);
yamop *Yap_Error(yap_error_number,Term,char *msg, ...); yamop *Yap_Error(yap_error_number,Term,const char *msg, ...);
yamop *Yap_NilError(yap_error_number,char *msg, ...); yamop *Yap_NilError(yap_error_number,const char *msg, ...);
int Yap_HandleError( const char *msg, ... ); int Yap_HandleError( const char *msg, ... );
int Yap_SWIHandleError( const char *, ... ); int Yap_SWIHandleError( const char *, ... );

View File

@ -15,6 +15,10 @@
* * * *
*************************************************************************/ *************************************************************************/
#ifndef ABSMI_H
#define ABSMI_H 1
#ifdef SCCS #ifdef SCCS
static char SccsId[] = "%W% %G%"; static char SccsId[] = "%W% %G%";
@ -2200,28 +2204,23 @@ extern char fin[1024];
#if YAP_JIT #if YAP_JIT
#ifndef _NATIVE #ifndef _NATIVE
#ifndef __cplusplus
#include <math.h> #include <math.h>
#include "JIT_Compiler.hpp" #include "JIT_Compiler.hpp"
struct JIT_Compiler *J; extern struct JIT_Compiler *J;
NativeContext *NativeArea;
IntermediatecodeContext *IntermediatecodeArea;
void* call_JIT_Compiler(struct JIT_Compiler*, yamop*);
void shutdown_llvm(void);
CELL l; extern NativeContext *NativeArea;
short global; extern IntermediatecodeContext *IntermediatecodeArea;
CELL nnexec;
yamop* HEADPREG;
CELL BLOCK;
CELL BLOCKADDRESS;
CELL FAILED;
#endif extern CELL l;
#endif extern short global;
extern CELL nnexec;
extern yamop* HEADPREG;
extern CELL BLOCK;
extern CELL BLOCKADDRESS;
extern CELL FAILED;
TraceContext **curtrace; TraceContext **curtrace;
yamop *curpreg; yamop *curpreg;
@ -2229,6 +2228,8 @@ BlocksContext **globalcurblock;
COUNT ineedredefinedest; COUNT ineedredefinedest;
yamop* headoftrace; yamop* headoftrace;
#endif /* _NATIVE */
#endif /* YAP_JIT */ #endif /* YAP_JIT */
#ifdef SHADOW_S #ifdef SHADOW_S
@ -2256,3 +2257,6 @@ yamop* headoftrace;
JMPNext(); \ JMPNext(); \
ENDD(d0); ENDD(d0);
#endif #endif
#endif // ABSMI_H

View File

@ -63,7 +63,7 @@
#ifndef NULL #ifndef NULL
#include <stdio.h> #include <stdio.h>
#endif #endif
#if ALIGN_LONGS #if ALIGN_LONGS
/* */ typedef Int DISPREG; /* */ typedef Int DISPREG;
@ -110,9 +110,6 @@ typedef Int (*CmpPredicate)(Term, Term);
typedef OPREG wamreg; typedef OPREG wamreg;
typedef OPREG yslot; typedef OPREG yslot;
typedef OPREG COUNT; typedef OPREG COUNT;
#include "amijit.h"
/* /*
This is a table with the codes for YAP instructions This is a table with the codes for YAP instructions
*/ */
@ -223,6 +220,10 @@ typedef enum {
#endif #endif
#define OpCodeSize sizeof(OPCODE) #define OpCodeSize sizeof(OPCODE)
#include "amijit.h"
/* /*
Types of possible YAAM instructions. Types of possible YAAM instructions.
@ -375,7 +376,7 @@ typedef struct yami {
/* The first one, aLl, handles try_logical and retry_logical, */ /* The first one, aLl, handles try_logical and retry_logical, */
/* Ill handles trust_logical. */ /* Ill handles trust_logical. */
/* They must have the same fields. */ /* They must have the same fields. */
struct { struct {
#ifdef YAPOR #ifdef YAPOR
unsigned int or_arg; unsigned int or_arg;
@ -759,7 +760,7 @@ typedef struct yami {
struct yami *l1; struct yami *l1;
struct yami *l2; struct yami *l2;
CELL next; CELL next;
} xll; } xll;
struct { struct {
wamreg xl; wamreg xl;
wamreg xr; wamreg xr;
@ -897,7 +898,7 @@ typedef Term *tr_fr_ptr;
struct deterministic_choicept { struct deterministic_choicept {
yamop *cp_ap; yamop *cp_ap;
struct choicept *cp_b; struct choicept *cp_b;
tr_fr_ptr cp_tr; tr_fr_ptr cp_tr;
#ifdef DEPTH_LIMIT #ifdef DEPTH_LIMIT
CELL cp_depth; CELL cp_depth;
#endif /* DEPTH_LIMIT */ #endif /* DEPTH_LIMIT */
@ -911,7 +912,7 @@ struct deterministic_choicept {
typedef struct choicept { typedef struct choicept {
yamop *cp_ap; yamop *cp_ap;
struct choicept *cp_b; struct choicept *cp_b;
tr_fr_ptr cp_tr; tr_fr_ptr cp_tr;
#ifdef DEPTH_LIMIT #ifdef DEPTH_LIMIT
CELL cp_depth; CELL cp_depth;
#endif /* DEPTH_LIMIT */ #endif /* DEPTH_LIMIT */
@ -1045,37 +1046,37 @@ CELL *ENV_Parent(CELL *env)
return (CELL *)env[E_E]; return (CELL *)env[E_E];
} }
static inline static inline
UInt ENV_Size(yamop *cp) UInt ENV_Size(yamop *cp)
{ {
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.s); return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.s);
} }
static inline static inline
struct pred_entry *ENV_ToP(yamop *cp) struct pred_entry *ENV_ToP(yamop *cp)
{ {
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p); return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p);
} }
static inline static inline
OPCODE ENV_ToOp(yamop *cp) OPCODE ENV_ToOp(yamop *cp)
{ {
return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->opc); return (((yamop *)((CODEADDR)(cp) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->opc);
} }
static inline static inline
UInt EnvSize(yamop *cp) UInt EnvSize(yamop *cp)
{ {
return ((-ENV_Size(cp))/(OPREG)sizeof(CELL)); return ((-ENV_Size(cp))/(OPREG)sizeof(CELL));
} }
static inline static inline
CELL *EnvBMap(yamop *p) CELL *EnvBMap(yamop *p)
{ {
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap); return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.bmap);
} }
static inline static inline
struct pred_entry *EnvPreg(yamop *p) struct pred_entry *EnvPreg(yamop *p)
{ {
return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p0); return (((yamop *)((CODEADDR)(p) - (CELL)NEXTOP((yamop *)NULL,Osbpp)))->y_u.Osbpp.p0);
@ -1098,10 +1099,8 @@ extern void **Yap_ABSMI_OPCODES;
/* /*
Make this into an even number so that the system will know Make this into an even number so that the system will know
it should ignore the depth limit it should ignore the depth limit
*/ */
#define RESET_DEPTH() MkIntTerm(MAX_ABS_INT-1) #define RESET_DEPTH() MkIntTerm(MAX_ABS_INT-1)
#else #else
#endif #endif

View File

@ -26,6 +26,7 @@
#define GLOBAL_PL_Argv Yap_global->PL_Argv_ #define GLOBAL_PL_Argv Yap_global->PL_Argv_
#define GLOBAL_HaltHooks Yap_global->HaltHooks_ #define GLOBAL_HaltHooks Yap_global->HaltHooks_
#define GLOBAL_JIT_finalizer Yap_global->JIT_finalizer_
#define GLOBAL_AllowLocalExpansion Yap_global->AllowLocalExpansion_ #define GLOBAL_AllowLocalExpansion Yap_global->AllowLocalExpansion_
#define GLOBAL_AllowGlobalExpansion Yap_global->AllowGlobalExpansion_ #define GLOBAL_AllowGlobalExpansion Yap_global->AllowGlobalExpansion_

View File

@ -26,6 +26,7 @@ typedef struct global_data {
char** PL_Argv_; char** PL_Argv_;
struct halt_hook* HaltHooks_; struct halt_hook* HaltHooks_;
fptr_t JIT_finalizer_;
int AllowLocalExpansion_; int AllowLocalExpansion_;
int AllowGlobalExpansion_; int AllowGlobalExpansion_;

View File

@ -26,6 +26,7 @@ static void InitGlobal(void) {
GLOBAL_PL_Argv = NULL; GLOBAL_PL_Argv = NULL;
GLOBAL_HaltHooks = NULL; GLOBAL_HaltHooks = NULL;
GLOBAL_JIT_finalizer = NULL;
GLOBAL_AllowLocalExpansion = TRUE; GLOBAL_AllowLocalExpansion = TRUE;
GLOBAL_AllowGlobalExpansion = TRUE; GLOBAL_AllowGlobalExpansion = TRUE;

View File

@ -34,6 +34,7 @@ static void RestoreGlobal(void) {
#if __ANDROID__ #if __ANDROID__

View File

@ -1,10 +1,9 @@
set(LIBJIT_MAJOR_VERSION 0) set(LIBJIT_MAJOR_VERSION 0)
set(LIBJIT_MINOR_VERSION 2) set(LIBJIT_MINOR_VERSION 1)
set(LIBJIT_PATCH_VERSION 1) set(LIBJIT_PATCH_VERSION 0)
set(LIBJIT_FULL_VERSION set(LIBJIT_FULL_VERSION
${LIBJIT_MAJOR_VERSION}.${LIBJIT_MINOR_VERSION}.${LIBJIT_PATCH_VERSION}) ${LIBJIT_MAJOR_VERSION}.${LIBJIT_MINOR_VERSION}.${LIBJIT_PATCH_VERSION})
set(LIBJIT_SOURCES set(LIBJIT_SOURCES
jit_analysispreds.c jit_analysispreds.c
jit_configpreds.c jit_configpreds.c
@ -13,6 +12,7 @@ set(LIBJIT_SOURCES
jit_debugpreds.c jit_debugpreds.c
jit_transformpreds.c jit_transformpreds.c
JIT_Compiler.cpp JIT_Compiler.cpp
JIT_Init.cpp
) )
# The following variables are defined: # The following variables are defined:
@ -51,12 +51,11 @@ add_library (libyapjit SHARED
set_target_properties(libyapjit set_target_properties(libyapjit
PROPERTIES PROPERTIES
# RPATH ${libdir} VERSION ${LIBJIT_FULL_VERSION} # RPATH ${libdir} VERSION ${LIBJIT_FULL_VERSION}
# SOVERSION ${LIBJIT_MAJOR_VERSION}.${LIBJIT_MINOR_VERSION} SOVERSION ${LIBJIT_MAJOR_VERSION}.${LIBJIT_MINOR_VERSION}
POSITION_INDEPENDENT_CODE TRUE POSITION_INDEPENDENT_CODE TRUE
OUTPUT_NAME YapJIT OUTPUT_NAME YapJIT
) )
target_link_libraries(libyapjit libYap ${LLVM_LIBRARIES}) target_link_libraries(libyapjit libYap ${LLVM_LIBRARIES} )
set ( YAP_YAPJITLIB $<TARGET_FILE_NAME:libyapjit> )

View File

@ -12,24 +12,25 @@
extern Environment ExpEnv; extern Environment ExpEnv;
extern Environment ExpEnv;
#if YAP_JIT #if YAP_JIT
Int STD_PROTO(Get_N_Cores,(void)); Int Get_N_Cores(void);
X_API Int STD_PROTO(Init_Analysis_Struc,(void)); X_API Int Init_Analysis_Struc(void);
X_API Int STD_PROTO(Init_Transform_Struc,(void)); X_API Int Init_Transform_Struc(void);
X_API Int STD_PROTO(Init_Codegen_Struc,(void)); X_API Int Init_Codegen_Struc(void);
X_API Int STD_PROTO(Init_Config_Struc,(void)); X_API Int Init_Config_Struc(void);
#if YAP_STAT_PREDS #if YAP_STAT_PREDS
X_API Int STD_PROTO(Init_Stats_Struc, (void)); X_API Int Init_Stats_Struc(void);
#endif #endif
#endif /* YAP_JIT */ #endif /* YAP_JIT */
#if YAP_DBG_PREDS #if YAP_DBG_PREDS
X_API Int STD_PROTO(Init_Debug_Struc,(void)); X_API Int Init_Debug_Struc(void);
#endif #endif
X_API Int STD_PROTO(YAP_Init_ExpEnv,(void)); X_API Int YAP_Init_ExpEnv(void);
#if YAP_JIT #if YAP_JIT
Int IntGet_N_Cores() {
Get_N_Cores() {
#ifdef WIN32 #ifdef WIN32
SYSTEM_INFO sysinfo; SYSTEM_INFO sysinfo;
GetSystemInfo(&sysinfo); GetSystemInfo(&sysinfo);
@ -39,11 +40,11 @@ Get_N_Cores() {
size_t len = 4; size_t len = 4;
uint32_t count; uint32_t count;
nm[0] = CTL_HW; nm[1] = HRW_AVAILCPU; nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
sysctl(nm, 2, &count, &len, NULL, 0); sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) { if(count < 1) {
nm[1] = HRW_NCPU; nm[1] = HW_NCPU;
sysctl(nm, 2, &count, &len, NULL, 0); sysctl(nm, 2, &count, &len, NULL, 0);
if(count < 1) { count = 1; } if(count < 1) { count = 1; }
} }
@ -74,7 +75,7 @@ Init_Transform_Struc()
ExpEnv.transform_struc.act_tr = NULL; ExpEnv.transform_struc.act_tr = NULL;
ExpEnv.transform_struc.opt_args.arg_promotion_max_elements = 3; ExpEnv.transform_struc.opt_args.arg_promotion_max_elements = 3;
ExpEnv.transform_struc.opt_args.strip_symbols_pass_type = 0; ExpEnv.transform_struc.opt_args.strip_symbols_pass_type = 0;
ExpEnv.transform_struc.opt_args.scalar_replace_aggregates_threshold = -1; ExpEnv.transform_struc.opt_args.scalar_replace_aggregates_threshold = -1;
ExpEnv.transform_struc.opt_args.loop_unswitch_optimize_for_size = 0; ExpEnv.transform_struc.opt_args.loop_unswitch_optimize_for_size = 0;
ExpEnv.transform_struc.opt_args.loop_unroll_threshold = -1; ExpEnv.transform_struc.opt_args.loop_unroll_threshold = -1;
ExpEnv.transform_struc.opt_args.inline_threshold = 225; ExpEnv.transform_struc.opt_args.inline_threshold = 225;
@ -102,7 +103,7 @@ Init_Codegen_Struc()
ExpEnv.codegen_struc.struc_targetopt.disabletailcalls = 0; ExpEnv.codegen_struc.struc_targetopt.disabletailcalls = 0;
ExpEnv.codegen_struc.struc_targetopt.fastisel = 0; ExpEnv.codegen_struc.struc_targetopt.fastisel = 0;
ExpEnv.codegen_struc.struc_targetopt.floatabitype = 0; ExpEnv.codegen_struc.struc_targetopt.floatabitype = 0;
ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = 3; ExpEnv.codegen_struc.struc_enginebuilder.engineoptlevel = 3;
ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = 0; ExpEnv.codegen_struc.struc_enginebuilder.relocmodel = 0;
ExpEnv.codegen_struc.struc_enginebuilder.codemodel = 1; ExpEnv.codegen_struc.struc_enginebuilder.codemodel = 1;
@ -174,15 +175,15 @@ Init_Debug_Struc()
ExpEnv.debug_struc.pmainclause_on_head.print = (Int)NO_PLACE; ExpEnv.debug_struc.pmainclause_on_head.print = (Int)NO_PLACE;
ExpEnv.debug_struc.pmainclause_on_head.msg_before = 0; ExpEnv.debug_struc.pmainclause_on_head.msg_before = 0;
ExpEnv.debug_struc.pmainclause_on_head.msg_after = 0; ExpEnv.debug_struc.pmainclause_on_head.msg_after = 0;
ExpEnv.debug_struc.pprint_intermediate.print_to_std = 0; ExpEnv.debug_struc.pprint_intermediate.print_to_std = 0;
ExpEnv.debug_struc.pprint_intermediate.print_to_file = 0; ExpEnv.debug_struc.pprint_intermediate.print_to_file = 0;
ExpEnv.debug_struc.pprint_intermediate.std_name = 0; ExpEnv.debug_struc.pprint_intermediate.std_name = 0;
ExpEnv.debug_struc.pprint_intermediate.file_name = 0; ExpEnv.debug_struc.pprint_intermediate.file_name = 0;
ExpEnv.debug_struc.pprint_llva.print_llva_before = 0; ExpEnv.debug_struc.pprint_llva.print_llva_before = 0;
ExpEnv.debug_struc.pprint_llva.print_llva_after = 0; ExpEnv.debug_struc.pprint_llva.print_llva_after = 0;
ExpEnv.debug_struc.pprint_me.interpreted_backtrack = 0; ExpEnv.debug_struc.pprint_me.interpreted_backtrack = 0;
ExpEnv.debug_struc.pprint_me.profiled_interpreted_backtrack = 0; ExpEnv.debug_struc.pprint_me.profiled_interpreted_backtrack = 0;
ExpEnv.debug_struc.pprint_me.native_backtrack = 0; ExpEnv.debug_struc.pprint_me.native_backtrack = 0;
@ -196,16 +197,16 @@ Init_Debug_Struc()
ExpEnv.debug_struc.pprint_me.nativerun_init = 0; ExpEnv.debug_struc.pprint_me.nativerun_init = 0;
ExpEnv.debug_struc.pprint_me.nativerun_exit_by_success = 0; ExpEnv.debug_struc.pprint_me.nativerun_exit_by_success = 0;
ExpEnv.debug_struc.pprint_me.nativerun_exit_by_fail = 0; ExpEnv.debug_struc.pprint_me.nativerun_exit_by_fail = 0;
ExpEnv.debug_struc.act_predicate_msgs.info_msgs = 0; ExpEnv.debug_struc.act_predicate_msgs.info_msgs = 0;
ExpEnv.debug_struc.act_predicate_msgs.success_msgs = 0; ExpEnv.debug_struc.act_predicate_msgs.success_msgs = 0;
ExpEnv.debug_struc.act_predicate_msgs.warning_msgs = 1; ExpEnv.debug_struc.act_predicate_msgs.warning_msgs = 1;
ExpEnv.debug_struc.act_predicate_msgs.error_msgs = 1; ExpEnv.debug_struc.act_predicate_msgs.error_msgs = 1;
ExpEnv.debug_struc.act_predicate_actions.exit_on_warning = 0; ExpEnv.debug_struc.act_predicate_actions.exit_on_warning = 0;
ExpEnv.debug_struc.act_predicate_actions.disable_on_warning = 1; ExpEnv.debug_struc.act_predicate_actions.disable_on_warning = 1;
ExpEnv.debug_struc.act_predicate_actions.exit_on_error = 1; ExpEnv.debug_struc.act_predicate_actions.exit_on_error = 1;
return TRUE; return TRUE;
} }
#endif #endif

View File

@ -1,24 +0,0 @@
#ifndef JIT_HPP
#define JIT_HPP
#ifdef __cplusplus
#include <vector>
#include <string>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <time.h>
#include <dlfcn.h>
#include "config.h"
#include "absmi.h"
using namespace std;
#else
#define LIMIT_COUNT 4096
#endif
#endif

View File

@ -1,3 +1,4 @@
#ifndef JIT_HPP #ifndef JIT_HPP
#define JIT_HPP #define JIT_HPP

View File

@ -1,104 +0,0 @@
#ifndef JIT_COMPILER_HPP
#define JIT_COMPILER_HPP
#ifdef __cplusplus
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/Linker.h"
#include "llvm/PassManager.h"
#include "llvm/CallGraphSCCPass.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/MachineCodeInfo.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_os_ostream.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/PathV1.h"
#include "llvm/Support/TypeBuilder.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/IVUsers.h"
#include "llvm/Analysis/Lint.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/CFGPrinter.h"
#include "llvm/Analysis/DomPrinter.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/RegionPrinter.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/system_error.h"
#include "llvm/Support/Process.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Vectorize.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
using namespace llvm;
#include <fcntl.h>
#include <errno.h>
#include "JIT.hpp"
using namespace std;
extern short global;
extern Environment ExpEnv;
extern NativeContext *NativeArea;
class JIT_Compiler {
private:
/* main method of JIT Compiler: compiles by clang, analyzes, optimizs and generates code accordingly the user choices */
void* compile_all(LLVMContext* &Context, yamop* p);
/* aid method to 'compile_all': adds register allocator pass to be used.
WARNING: don't use! For some reasons llvm crashes when I use it */
void set_regalloc_pass(PassManager &PM);
/* aid method to 'compile_all': optimizes module by individual transform passes or transform level */
void optimize_module(llvm::Module* &M);
/* aid method to 'compile_all': analyzes module by individual analysis passes */
void analyze_module(llvm::Module* &M);
public:
/* method invoked by wrapper 'call_JIT_Compiler' */
void* compile(yamop*);
};
#else
struct JIT_Compiler{}; // Doing this, I can call class 'JIT_Compiler' from C code
#endif
#ifdef __cplusplus
extern "C" void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { return jc->compile(p); }
extern "C" void shutdown_llvm() { llvm_shutdown(); }
#endif //#ifdef __cplusplus
#endif

View File

@ -72,38 +72,50 @@ extern Environment ExpEnv;
extern NativeContext *NativeArea; extern NativeContext *NativeArea;
class JIT_Compiler { class JIT_Compiler {
private: private:
/* main method of JIT Compiler: compiles by clang, analyzes, optimizs and generates code accordingly the user choices */ /* main method of JIT Compiler: compiles by clang, analyzes, optimizs and generates code accordingly the user choices */
void* compile_all(LLVMContext* &Context, yamop* p); void* compile_all(LLVMContext* &Context, yamop* p);
/* aid method to 'compile_all': adds register allocator pass to be used. /* aid method to 'compile_all': adds register allocator pass to be used.
WARNING: don't use! For some reasons llvm crashes when I use it */ WARNING: don't use! For some reasons llvm crashes when I use it */
void set_regalloc_pass(PassManager &PM); void set_regalloc_pass(PassManager &PM);
/* aid method to 'compile_all': optimizes module by individual transform passes or transform level */ /* aid method to 'compile_all': optimizes module by individual transform passes or transform level */
void optimize_module(llvm::Module* &M); void optimize_module(llvm::Module* &M);
/* aid method to 'compile_all': analyzes module by individual analysis passes */ /* aid method to 'compile_all': analyzes module by individual analysis passes */
void analyze_module(llvm::Module* &M); void analyze_module(llvm::Module* &M);
public: public:
/* method invoked by wrapper 'call_JIT_Compiler' */ /* method invoked by wrapper 'call_JIT_Compiler' */
void* compile(yamop*); void* compile(yamop*);
}; };
#else #else
struct JIT_Compiler{}; // Doing this, I can call class 'JIT_Compiler' from C code struct JIT_Compiler{}; // Doing this, I can call class 'JIT_Compiler' from C code
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p);
extern "C" void shutdown_llvm();
extern "C" void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { return jc->compile(p); } extern "C" void* call_JIT_Compiler(JIT_Compiler* jc, yamop* p) { return jc->compile(p); }
extern "C" void shutdown_llvm() { llvm_shutdown(); } extern "C" void shutdown_llvm() { llvm_shutdown(); }
#else
INLINE_ONLY inline EXTERN void* call_JIT_Compiler(struct JIT_Compiler* jc, yamop* p);
extern void* (*Yap_JitCall)(struct JIT_Compiler* jc, yamop* p);
INLINE_ONLY inline EXTERN void* call_JIT_Compiler(struct JIT_Compiler* jc, yamop* p) { return Yap_JitCall (jc,p); }
INLINE_ONLY inline EXTERN void shutdown_llvm(void ) ;
EXTERN void (* Yap_llvmShutdown)(void ) ;
INLINE_ONLY inline EXTERN void shutdown_llvm(void ) { Yap_llvmShutdown (); }
#endif //#ifdef __cplusplus #endif //#ifdef __cplusplus
#endif #endif

View File

@ -1,45 +0,0 @@
#include "Yap.h"
#include "clause.h"
#include "eval.h"
#if HRAVE_ERRNO_H
#include <errno.h>
#else
extern int errno;
#endif
#include <string.h>
#include <ctype.h>
#define UPPER_ENTRY(S) \
tmp = (char*)malloc((strlen(S)+1)*sizeof(char)); \
while (S[i]) { \
if (S[i] != '-' && S[i] != '_' && S[i] != ' ') { \
if ((S[i] >= '0' && S[i] <= '9') || (S[i] == '.')) \
tmp[j] = S[i]; \
else \
tmp[j] = toupper(S[i]); \
j++; \
} \
i++; \
} \
tmp[j] = 0; \
strcpy(S, tmp); \
free(tmp);
#if YAP_JIT
void Yap_InitJitAnalysisPreds( void );
void Yap_InitJitCodegenPreds( void );
void Yap_InitJitConfigPreds( void );
void Yap_InitJitTransformPreds( void );
#if YAP_STAT_PREDS
void Yap_InitJitStatisticPreds( void );
#endif
#endif /* YAP_JIT */
#if YAP_DBG_PREDS
void Yap_InitJitDebugPreds( void );
#endif
Environment ExpEnv;
#if YAP_JIT
extern NativeContext *NativeArea;
extern IntermediatecodeContext *IntermediatecodeArea;
#endif

View File

@ -2,12 +2,11 @@
#include <unistd.h> #include <unistd.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <fcntl.h> #include <fcntl.h>
using namespace std; using namespace std;
#define FREE_ALLOCATED() \ #define FREE_ALLOCATED() \
free(buffer); \ free(buffer); \
free(p->u.jhc.jh->cmd); \ free(p->y_u.J.jh->cmd); \
free(outputfilename); \ free(outputfilename); \
free(optoutputfilename); \ free(optoutputfilename); \
free(cmd1); \ free(cmd1); \
@ -39,7 +38,8 @@ using namespace std;
PInfo = PassRegistry::getPassRegistry()->getPassInfo(PASS->getPassID()); \ PInfo = PassRegistry::getPassRegistry()->getPassInfo(PASS->getPassID()); \
Kind = PASS->getPassKind(); \ Kind = PASS->getPassKind(); \
ADD_PASS_ACCORDING_TO_KIND(); ADD_PASS_ACCORDING_TO_KIND();
#include "PassPrinters.hpp"
#include "PassPrinters.hh"
void JIT_Compiler::analyze_module(llvm::Module* &M) void JIT_Compiler::analyze_module(llvm::Module* &M)
{ {
@ -48,9 +48,9 @@ void JIT_Compiler::analyze_module(llvm::Module* &M)
const PassInfo *PInfo; const PassInfo *PInfo;
PassKind Kind; PassKind Kind;
Pass.add(TLI); // First, I add on 'Pass' the Target Info of Module Pass.add(TLI); // First, I add on 'Pass' the Target Info of Module
Pass.add(new TargetData(M)); // Second, I must add Target Data on 'Pass' Pass.add(new DataLayoutPass(M)); // Second, I must add Target Data on 'Pass'
for (int i = 0; i < ExpEnv.analysis_struc.n; i++) { for (int i = 0; i < ExpEnv.analysis_struc.n; i++) {
/* /*
* 'ExpEnv.analysis_struc.act_an' contains sorted analysis passes * * 'ExpEnv.analysis_struc.act_an' contains sorted analysis passes *
@ -83,8 +83,9 @@ void JIT_Compiler::analyze_module(llvm::Module* &M)
case e_createLazyValueInfoPass: case e_createLazyValueInfoPass:
TREAT_CASE_FOR(createLazyValueInfoPass()); TREAT_CASE_FOR(createLazyValueInfoPass());
break; break;
//CHANGED FOR LLVM 3.5
case e_createLoopDependenceAnalysisPass: case e_createLoopDependenceAnalysisPass:
TREAT_CASE_FOR(createLoopDependenceAnalysisPass()); TREAT_CASE_FOR(createDependenceAnalysisPass());
break; break;
case e_createLibCallAliasAnalysisPass: case e_createLibCallAliasAnalysisPass:
TREAT_CASE_FOR(createLibCallAliasAnalysisPass(NULL)); TREAT_CASE_FOR(createLibCallAliasAnalysisPass(NULL));
@ -101,24 +102,29 @@ void JIT_Compiler::analyze_module(llvm::Module* &M)
case e_createNoAAPass: case e_createNoAAPass:
TREAT_CASE_FOR(createNoAAPass()); TREAT_CASE_FOR(createNoAAPass());
break; break;
case e_createNoPathProfileInfoPass: //NOT IN LLVM 3.5
TREAT_CASE_FOR(createNoPathProfileInfoPass()); //case e_createNoPathProfileInfoPass:
break; // TREAT_CASE_FOR(createNoPathProfileInfoPass());
case e_createNoProfileInfoPass: // break;
TREAT_CASE_FOR(createNoProfileInfoPass()); //NOT IN LLVM 3.5
break; //case e_createNoProfileInfoPass:
// TREAT_CASE_FOR(createNoProfileInfoPass());
// break;
case e_createObjCARCAliasAnalysisPass: case e_createObjCARCAliasAnalysisPass:
TREAT_CASE_FOR(createObjCARCAliasAnalysisPass()); TREAT_CASE_FOR(createObjCARCAliasAnalysisPass());
break; break;
case e_createProfileEstimatorPass: //NOT IN LLVM 3.5
TREAT_CASE_FOR(createProfileEstimatorPass()); //case e_createProfileEstimatorPass:
break; // TREAT_CASE_FOR(createProfileEstimatorPass());
// break;
//CHANGED FOR LLVM 3.5
case e_createProfileLoaderPass: case e_createProfileLoaderPass:
TREAT_CASE_FOR(createProfileLoaderPass()); TREAT_CASE_FOR(createSampleProfileLoaderPass());
break;
case e_createProfileVerifierPass:
TREAT_CASE_FOR(createProfileVerifierPass());
break; break;
//NOT IN LLVM 3.5
//case e_createProfileVerifierPass:
// TREAT_CASE_FOR(createProfileVerifierPass());
// break;
case e_createRegionInfoPass: case e_createRegionInfoPass:
TREAT_CASE_FOR(createRegionInfoPass()); TREAT_CASE_FOR(createRegionInfoPass());
break; break;
@ -128,8 +134,9 @@ void JIT_Compiler::analyze_module(llvm::Module* &M)
case e_createTypeBasedAliasAnalysisPass: case e_createTypeBasedAliasAnalysisPass:
TREAT_CASE_FOR(createTypeBasedAliasAnalysisPass()); TREAT_CASE_FOR(createTypeBasedAliasAnalysisPass());
break; break;
//CHANGED FOR LLVM 3.5
case e_createDbgInfoPrinterPass: case e_createDbgInfoPrinterPass:
TREAT_CASE_FOR(createDbgInfoPrinterPass()); TREAT_CASE_FOR(createDebugInfoVerifierPass());
break; break;
case e_createCFGPrinterPass: case e_createCFGPrinterPass:
TREAT_CASE_FOR(createCFGPrinterPass()); TREAT_CASE_FOR(createCFGPrinterPass());
@ -155,21 +162,23 @@ void JIT_Compiler::analyze_module(llvm::Module* &M)
case e_createRegionOnlyPrinterPass: case e_createRegionOnlyPrinterPass:
TREAT_CASE_FOR(createRegionOnlyPrinterPass()); TREAT_CASE_FOR(createRegionOnlyPrinterPass());
break; break;
case e_createPathProfileLoaderPass: //NOT IN LLVM 3.5
TREAT_CASE_FOR(createPathProfileLoaderPass()); //case e_createPathProfileLoaderPass:
break; // TREAT_CASE_FOR(createPathProfileLoaderPass());
case e_createPathProfileVerifierPass: // break;
TREAT_CASE_FOR(createPathProfileVerifierPass()); //NOT IN LLVM 3.5
break; //case e_createPathProfileVerifierPass:
// TREAT_CASE_FOR(createPathProfileVerifierPass());
// break;
default:; default:;
} }
} }
/* if 'llvm::TimePassesIsEnabled' is 'true', llvm time passes are printed on 'shutdown_llvm()' (p_halt -- stdpreds.c) */ /* if 'llvm::TimePassesIsEnabled' is 'true', llvm time passes are printed on 'shutdown_llvm()' (p_halt -- stdpreds.c) */
llvm::TimePassesIsEnabled = ExpEnv.analysis_struc.time_pass_enabled; llvm::TimePassesIsEnabled = ExpEnv.analysis_struc.time_pass_enabled;
/* Use 'llvm::EnableStatistics()' so that llvm stats are printed on 'shutdown_llvm()' (p_halt -- stdpreds.c) */ /* Use 'llvm::EnableStatistics()' so that llvm stats are printed on 'shutdown_llvm()' (p_halt -- stdpreds.c) */
if (ExpEnv.analysis_struc.stats_enabled) llvm::EnableStatistics(); if (ExpEnv.analysis_struc.stats_enabled) llvm::EnableStatistics();
/* /*
* Here, I configure resulting analysis output -- default: stderr * * Here, I configure resulting analysis output -- default: stderr *
* Use analysis_output_file/1 to change * * Use analysis_output_file/1 to change *
@ -207,21 +216,22 @@ void JIT_Compiler::optimize_module(llvm::Module* &M)
/* Yes, I do, so... */ /* Yes, I do, so... */
/* Initializes PassManager for Function */ /* Initializes PassManager for Function */
OwningPtr<FunctionPassManager> FPM; std::shared_ptr<FunctionPassManager> FPM;
FPM.reset(new FunctionPassManager(M)); FPM.reset(new FunctionPassManager(M));
FPM->add(new TargetData(M)); FPM->add(new DataLayoutPass(M));
PassManagerBuilder Builder; // aid to 'FPM' and 'MPM' PassManagerBuilder Builder; // aid to 'FPM' and 'MPM'
/* Initializes PassManager for Function */ /* Initializes PassManager for Function */
PassManager MPM; PassManager MPM;
TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple())); TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
MPM.add(TLI); MPM.add(TLI);
MPM.add(new TargetData(M)); MPM.add(new DataLayoutPass(M));
/* Populates 'Builder' */ /* Populates 'Builder' */
Builder.OptLevel = ExpEnv.transform_struc.optlevel; Builder.OptLevel = ExpEnv.transform_struc.optlevel;
Builder.DisableUnitAtATime = !ExpEnv.transform_struc.unit_at_time_enabled; Builder.DisableUnitAtATime = !ExpEnv.transform_struc.unit_at_time_enabled;
Builder.DisableSimplifyLibCalls = !ExpEnv.transform_struc.simplify_libcalls_enabled; //NOT IN LLVM 3.5
//Builder.DisableSimplifyLibCalls = !ExpEnv.transform_struc.simplify_libcalls_enabled;
/* inline and unrool only be enabled if 'ExpEnv.transform_struc.optlevel' > 0 */ /* inline and unrool only be enabled if 'ExpEnv.transform_struc.optlevel' > 0 */
if (ExpEnv.transform_struc.optlevel) Builder.Inliner = if (ExpEnv.transform_struc.optlevel) Builder.Inliner =
createFunctionInliningPass(ExpEnv.transform_struc.opt_args.inline_threshold); createFunctionInliningPass(ExpEnv.transform_struc.opt_args.inline_threshold);
@ -233,7 +243,7 @@ void JIT_Compiler::optimize_module(llvm::Module* &M)
Builder.populateFunctionPassManager(*FPM); Builder.populateFunctionPassManager(*FPM);
/* Populates 'MPM' from 'Builder' */ /* Populates 'MPM' from 'Builder' */
Builder.populateModulePassManager(MPM); Builder.populateModulePassManager(MPM);
/* /*
* Enabling link-time optimizations -- default is no * * Enabling link-time optimizations -- default is no *
* Use 'link_time_opt/1', 'link_time_opt/3', 'enable_link_time_opt/0', or 'enable_link_time_opt/2' to change * * Use 'link_time_opt/1', 'link_time_opt/3', 'enable_link_time_opt/0', or 'enable_link_time_opt/2' to change *
@ -261,7 +271,7 @@ void JIT_Compiler::optimize_module(llvm::Module* &M)
PassManager Pass; // 'Pass' stores transform passes to be applied PassManager Pass; // 'Pass' stores transform passes to be applied
TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple())); TargetLibraryInfo *TLI = new TargetLibraryInfo(Triple(M->getTargetTriple()));
Pass.add(TLI); // First, I add on 'Pass' the Target Info of Module Pass.add(TLI); // First, I add on 'Pass' the Target Info of Module
Pass.add(new TargetData(M)); // Second, I must add Target Data on 'Pass' Pass.add(new DataLayoutPass(M)); // Second, I must add Target Data on 'Pass'
for (int i = 0; i < ExpEnv.transform_struc.n; i++) { for (int i = 0; i < ExpEnv.transform_struc.n; i++) {
/* /*
* 'ExpEnv.transform_struc.act_tr' contains sorted transform passes * * 'ExpEnv.transform_struc.act_tr' contains sorted transform passes *
@ -283,9 +293,10 @@ void JIT_Compiler::optimize_module(llvm::Module* &M)
case t_createBlockExtractorPass: case t_createBlockExtractorPass:
Pass.add(createBlockExtractorPass()); Pass.add(createBlockExtractorPass());
break; break;
case t_createBlockPlacementPass: //NOT IN LLVM 3.5
Pass.add(createBlockPlacementPass()); //case t_createBlockPlacementPass:
break; // Pass.add(createBlockPlacementPass());
// break;
case t_createBreakCriticalEdgesPass: case t_createBreakCriticalEdgesPass:
Pass.add(createBreakCriticalEdgesPass()); Pass.add(createBreakCriticalEdgesPass());
break; break;
@ -356,7 +367,7 @@ void JIT_Compiler::optimize_module(llvm::Module* &M)
Pass.add(createInstructionSimplifierPass()); Pass.add(createInstructionSimplifierPass());
break; break;
case t_createInternalizePass: case t_createInternalizePass:
Pass.add(createInternalizePass(true)); Pass.add(createInternalizePass());
break; break;
case t_createIPConstantPropagationPass: case t_createIPConstantPropagationPass:
Pass.add(createIPConstantPropagationPass()); Pass.add(createIPConstantPropagationPass());
@ -448,9 +459,10 @@ void JIT_Compiler::optimize_module(llvm::Module* &M)
case t_createSCCPPass: case t_createSCCPPass:
Pass.add(createSCCPPass()); Pass.add(createSCCPPass());
break; break;
case t_createSimplifyLibCallsPass: //NOT IN LLVM 3.5
Pass.add(createSimplifyLibCallsPass()); //case t_createSimplifyLibCallsPass:
break; // Pass.add(createSimplifyLibCallsPass());
// break;
case t_createSingleLoopExtractorPass: case t_createSingleLoopExtractorPass:
Pass.add(createSingleLoopExtractorPass()); Pass.add(createSingleLoopExtractorPass());
break; break;
@ -557,26 +569,25 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
"-DYAP_JIT", "-D_NATIVE=1", "-I.", "-I./H", "-I./include", "-I./os", "-I./OPTYap", "-I./BEAM", "-I./MYDDAS", "-I./HPP", "-xc", "-c", "-", "-o", "-", "-emit-llvm", NULL "-DYAP_JIT", "-D_NATIVE=1", "-I.", "-I./H", "-I./include", "-I./os", "-I./OPTYap", "-I./BEAM", "-I./MYDDAS", "-I./HPP", "-xc", "-c", "-", "-o", "-", "-emit-llvm", NULL
}; };
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
std::string errStr; std::string errStr;
llvm::error_code e; error_code e;
OwningPtr<MemoryBuffer> bf;
/* Pipe to communicate 'echo' with 'clang' */ /* Pipe to communicate 'echo' with 'clang' */
int pipe1[2]; int pipe1[2];
int pid_echo, pid_clang ; int pid_echo, pid_clang ;
/* 'clang' out file */ /* 'clang' out file */
char* outputfilename = (char*)malloc(33*sizeof(char)); char* outputfilename = (char*)malloc(33*sizeof(char));
sprintf(outputfilename, "%lx.bc", (CELL)p); sprintf(outputfilename, "%lx.bc", (CELL)p);
int Output = open(outputfilename, O_CREAT | O_RDWR, 0644); int Output = open(outputfilename, O_CREAT | O_RDWR, 0644);
/* Creating pipes */ /* Creating pipes */
if (pipe(pipe1)<0) { if (pipe(pipe1)<0) {
perror(" ERROR!!\n ERROR") ; perror(" ERROR!!\n ERROR") ;
exit(1); exit(1);
} }
/* Calls echo. */ /* Calls echo. */
pid_echo = fork() ; pid_echo = fork() ;
if (pid_echo < 0) { if (pid_echo < 0) {
@ -586,12 +597,12 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
if (!pid_echo) { if (!pid_echo) {
/* Setting echo's output to 1st pipe */ /* Setting echo's output to 1st pipe */
dup2(pipe1[1], 1); dup2(pipe1[1], 1);
/* Closing pipes */ /* Closing pipes */
close(pipe1[0]); close(pipe1[0]);
close(pipe1[1]); close(pipe1[1]);
execlp("echo", "echo", p->u.jhc.jh->tcc.cmd, NULL); execlp("echo", "echo", p->y_u.J.jh->tcc.cmd, NULL);
} }
else { else {
/* Calls clang. */ /* Calls clang. */
@ -606,11 +617,11 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
/* Setting clang's output to Output */ /* Setting clang's output to Output */
dup2(Output, 1) ; dup2(Output, 1) ;
/* Closing pipes */ /* Closing pipes */
close(pipe1[0]); close(pipe1[0]);
close(pipe1[1]); close(pipe1[1]);
execvp(*clang_args, clang_args); execvp(*clang_args, clang_args);
} }
} }
@ -624,14 +635,15 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
// 2 means two processes: 'echo' and 'clang' // 2 means two processes: 'echo' and 'clang'
for (i = 0; i < 2; i++) wait(status); for (i = 0; i < 2; i++) wait(status);
/***/ /***/
/* /*
* At this point, the compiled code (O0) is on 'Output' * * At this point, the compiled code (O0) is on 'Output' *
* I need to read it to main memory * * I need to read it to main memory *
* for this, I'll use 'MemoryBuffer::getOpenFile' * * for this, I'll use 'MemoryBuffer::getOpenFile' *
*/ */
lseek(Output, 0, SEEK_SET); lseek(Output, 0, SEEK_SET);
e = MemoryBuffer::getOpenFile(Output, outputfilename, bf); ErrorOr<std::unique_ptr<MemoryBuffer>> em = MemoryBuffer::getOpenFile(Output, outputfilename, -1);
e = em.getError();
if (e) { if (e) {
errs() << "ERROR::Unable to MemoryBuffer from " << outputfilename << " -- " << e.message() << "\n"; errs() << "ERROR::Unable to MemoryBuffer from " << outputfilename << " -- " << e.message() << "\n";
exit(1); exit(1);
@ -640,9 +652,9 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
/* /*
* At this point, the compiled code (O0) is on main memory * * At this point, the compiled code (O0) is on main memory *
* I need to read it to Module * * I need to read it to Module *
* for this, I'll use 'ParseBitcodeFile' * * for this, I'll use 'parseBitcodeFile' *
*/ */
Module *Mod = ParseBitcodeFile(bf.get(), *Context); Module *Mod = *parseBitcodeFile(em->get(), *Context);
/* /*
* verify module correctness * * verify module correctness *
@ -669,41 +681,41 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
analyze_module(Mod); analyze_module(Mod);
/* Optimize module -- transform predicates */ /* Optimize module -- transform predicates */
optimize_module(Mod); optimize_module(Mod);
/* Computing size of optimized module */ /* Computing size of optimized module */
{ {
/* Open file 'tmp.bc' which will be filled by optimized Module */ /* Open file 'tmp.bc' which will be filled by optimized Module */
OwningPtr<tool_output_file> Out; std::shared_ptr<tool_output_file> Out;
std::string ErrorInfo; std::string ErrorInfo;
Out.reset(new tool_output_file("tmp.bc", ErrorInfo, raw_fd_ostream::F_Binary)); Out.reset(new tool_output_file("tmp.bc", ErrorInfo, llvm::sys::fs::F_None));
if (!ErrorInfo.empty()) { if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n'; errs() << ErrorInfo << '\n';
exit(1); exit(1);
} }
/* 'createPrintModulePass(arg)' will print Module (now optimized) to on file represented by 'arg' */ /* 'createPrintModulePass(arg)' will print Module (now optimized) to on file represented by 'arg' */
PassManager Pass; PassManager Pass;
Pass.add(createPrintModulePass(&Out->os())); Pass.add(createPrintModulePass(Out->os()));
Pass.run(*Mod); Pass.run(*Mod);
/* 'Out->keep()' will keep printed module to file and will close file */ /* 'Out->keep()' will keep printed module to file and will close file */
Out->keep(); Out->keep();
/* Open file 'tmp.bc' */ /* Open file 'tmp.bc' */
int Outtmp = open("tmp.bc", O_CREAT | O_RDWR, 0644); int Outtmp = open("tmp.bc", O_CREAT | O_RDWR, 0644);
#if YAP_STAT_PREDS #if YAP_STAT_PREDS
/* for statistics... compute file size and store value on 'NativeArea->area.native_size_bytes' */ /* for statistics... compute file size and store value on 'NativeArea->area.native_size_bytes' */
NativeArea->area.native_size_bytes[p->u.jhc.jh->caa.naddress][NativeArea->area.nrecomp[p->u.jhc.jh->caa.naddress]-1] = lseek(Outtmp, 0, SEEK_END); NativeArea->area.native_size_bytes[p->y_u.jhc.jh->caa.naddress][NativeArea->area.nrecomp[p->y_u.jhc.jh->caa.naddress]-1] = lseek(Outtmp, 0, SEEK_END);
#endif #endif
close(Outtmp); close(Outtmp);
remove("tmp.bc"); remove("tmp.bc");
} }
/***/ /***/
#if YAP_DBG_PREDS #if YAP_DBG_PREDS
/* for debug... print module after optimizing it */ /* for debug... print module after optimizing it */
if (ExpEnv.debug_struc.pprint_llva.print_llva_after) if (ExpEnv.debug_struc.pprint_llva.print_llva_after)
errs() << "Module after optimization::\n" << *Mod; errs() << "Module after optimization::\n" << *Mod;
#endif #endif
/* /*
* verify module correctness * * verify module correctness *
* predicates: * * predicates: *
@ -719,10 +731,11 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
} }
} }
/***/ /***/
// MaterializeAllPermanently -- Make sure all GlobalValues in this Module are fully read // materializeAllPermanently -- Make sure all GlobalValues in this Module are fully read
if (Mod->MaterializeAllPermanently(&errStr)) { error_code materialize_error = Mod->materializeAllPermanently();
errs() <<"Error:: bitcode didn't read correctly. -- " << errStr << "\n"; if (materialize_error.value() != 0) {
errs() <<"Error:: bitcode didn't read correctly. -- " << materialize_error.message() << "\n";
exit(1); exit(1);
} }
@ -789,12 +802,14 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
{ {
/* codegen predicates 'enable_framepointer_elimination/0' or 'disable_framepointer_elimination/0' */ /* codegen predicates 'enable_framepointer_elimination/0' or 'disable_framepointer_elimination/0' */
Options.NoFramePointerElim = (bool)ExpEnv.codegen_struc.struc_targetopt.noframepointerelim; Options.NoFramePointerElim = (bool)ExpEnv.codegen_struc.struc_targetopt.noframepointerelim;
Options.NoFramePointerElimNonLeaf = (bool)ExpEnv.codegen_struc.struc_targetopt.noframepointerelim; //NOT IN LLVM 3.5
//Options.NoFramePointerElimNonLeaf = (bool)ExpEnv.codegen_struc.struc_targetopt.noframepointerelim;
/***/ /***/
// codegen predicates 'less_precise_fp_mad_option/0' or 'more_precise_fp_mad_option/0' // codegen predicates 'less_precise_fp_mad_option/0' or 'more_precise_fp_mad_option/0'
Options.LessPreciseFPMADOption = (bool)ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption; Options.LessPreciseFPMADOption = (bool)ExpEnv.codegen_struc.struc_targetopt.lessprecisefpmadoption;
// codegen predicates 'no_excess_fp_precision/0' or 'excess_fp_precision/0' // codegen predicates 'no_excess_fp_precision/0' or 'excess_fp_precision/0'
Options.NoExcessFPPrecision = (bool)ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision; //NOT IN LLVM 3.5
//Options.NoExcessFPPrecision = (bool)ExpEnv.codegen_struc.struc_targetopt.noexcessfpprecision;
// codegen predicates 'unsafe_fp_math/0' or 'safe_fp_math/0' // codegen predicates 'unsafe_fp_math/0' or 'safe_fp_math/0'
Options.UnsafeFPMath = (bool)ExpEnv.codegen_struc.struc_targetopt.unsafefpmath; Options.UnsafeFPMath = (bool)ExpEnv.codegen_struc.struc_targetopt.unsafefpmath;
// codegen predicates 'rounding_mode_dynamically_changed/0' or 'rounding_mode_not_changed/0' // codegen predicates 'rounding_mode_dynamically_changed/0' or 'rounding_mode_not_changed/0'
@ -803,7 +818,8 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
// codegen predicates 'no_use_soft_float/0' or 'use_soft_float/0' // codegen predicates 'no_use_soft_float/0' or 'use_soft_float/0'
Options.UseSoftFloat = (bool)ExpEnv.codegen_struc.struc_targetopt.usesoftfloat; Options.UseSoftFloat = (bool)ExpEnv.codegen_struc.struc_targetopt.usesoftfloat;
// codegen predicates 'enable_jit_exception_handling/0' or 'disable_jit_exception_handling/0' // codegen predicates 'enable_jit_exception_handling/0' or 'disable_jit_exception_handling/0'
Options.JITExceptionHandling = (bool)ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling; //NOT IN LLVM 3.5
//Options.JITExceptionHandling = (bool)ExpEnv.codegen_struc.struc_targetopt.jitexceptionhandling;
// codegen predicates 'enable_jit_emit_debug_info/0' or 'disable_jit_emit_debug_info/0' // codegen predicates 'enable_jit_emit_debug_info/0' or 'disable_jit_emit_debug_info/0'
Options.JITEmitDebugInfo = (bool)ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo; Options.JITEmitDebugInfo = (bool)ExpEnv.codegen_struc.struc_targetopt.jitemitdebuginfo;
// codegen predicates 'enable_jit_emit_debug_info_to_disk/0' or 'disable_jit_emit_debug_info_to_disk/0' // codegen predicates 'enable_jit_emit_debug_info_to_disk/0' or 'disable_jit_emit_debug_info_to_disk/0'
@ -850,7 +866,7 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
*/ */
close(Output); close(Output);
remove(outputfilename); remove(outputfilename);
free(p->u.jhc.jh->tcc.cmd); free(p->y_u.J.jh->tcc.cmd);
free(outputfilename); free(outputfilename);
return NULL; return NULL;
} }
@ -861,7 +877,7 @@ void* JIT_Compiler::compile_all(LLVMContext* &Context, yamop* p)
// global++; what is this? // global++; what is this?
close(Output); close(Output);
remove(outputfilename); remove(outputfilename);
free(p->u.jhc.jh->tcc.cmd); free(p->y_u.J.jh->tcc.cmd);
free(outputfilename); free(outputfilename);
// 2. get native pointer from 'clause' (our function within Module) and return it // 2. get native pointer from 'clause' (our function within Module) and return it
return EE->getPointerToFunction(EntryFn); return EE->getPointerToFunction(EntryFn);

View File

@ -101,7 +101,7 @@ p_disable_analysis_pass( USES_REGS1 )
int i = 0, j = 0; int i = 0, j = 0;
char *tmp; char *tmp;
// gets string from atom and stores it on 'str' // gets string from atom and stores it on 'str'
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char) char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(t))*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(t))); strcpy(str, AtomName(AtomOfTerm(t)));
// Makes upper characters of 'str' (for comparison) // Makes upper characters of 'str' (for comparison)
UPPER_ENTRY(str); UPPER_ENTRY(str);
@ -590,7 +590,7 @@ p_analysis_output_file( USES_REGS1 )
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
void void
Yap_InitJitAnalysisPreds(void) Yap_InitJitAnalysisPreds(void)
{ {
Yap_InitCPred("disable_analysis_pass", 1, p_disable_analysis_pass, SafePredFlag); Yap_InitCPred("disable_analysis_pass", 1, p_disable_analysis_pass, SafePredFlag);

View File

@ -707,6 +707,7 @@ p_noonly_profiled_interpreter( USES_REGS1 )
ExpEnv.config_struc.useonlypi = 0; ExpEnv.config_struc.useonlypi = 0;
return TRUE; return TRUE;
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
void void
@ -728,3 +729,4 @@ Yap_InitJitConfigPreds( void )
Yap_InitCPred("only_profiled_interpreter", 0, p_only_profiled_interpreter, SafePredFlag); Yap_InitCPred("only_profiled_interpreter", 0, p_only_profiled_interpreter, SafePredFlag);
Yap_InitCPred("noonly_profiled_interpreter", 0, p_noonly_profiled_interpreter, SafePredFlag); Yap_InitCPred("noonly_profiled_interpreter", 0, p_noonly_profiled_interpreter, SafePredFlag);
} }

View File

@ -15,7 +15,9 @@
* Last rev: 2013-10-18 * * Last rev: 2013-10-18 *
*************************************************************************/ *************************************************************************/
#include "jit_predicates.hh" #include "jit_predicates.hpp"
#if YAP_DBG_PREDS
static Int p_no_print_instruction( USES_REGS1 ); static Int p_no_print_instruction( USES_REGS1 );
static Int p_no_print_basic_instruction( USES_REGS1 ); static Int p_no_print_basic_instruction( USES_REGS1 );
@ -117,6 +119,7 @@ static Int p_no_exit_on_warning( USES_REGS1 );
static Int p_enable_on_warning( USES_REGS1 ); static Int p_enable_on_warning( USES_REGS1 );
static Int p_no_exit_on_error( USES_REGS1 ); static Int p_no_exit_on_error( USES_REGS1 );
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-function-declaration" #pragma GCC diagnostic ignored "-Wimplicit-function-declaration"
@ -131,7 +134,7 @@ p_no_print_instruction( USES_REGS1 )
if (IsAtomTerm(u)) { if (IsAtomTerm(u)) {
int i = 0, j = 0; int i = 0, j = 0;
char *tmp; char *tmp;
char *str = (char*)malloc(YAP_AtomNameLength(AtomOfTerm(u))*sizeof(char)); char *str = (char*)malloc((YAP_AtomNameLength(AtomOfTerm(u))+1)*sizeof(char));
strcpy(str, AtomName(AtomOfTerm(u))); strcpy(str, AtomName(AtomOfTerm(u)));
UPPER_ENTRY(str); UPPER_ENTRY(str);
char *strop = (char*)malloc(100*sizeof(char)); char *strop = (char*)malloc(100*sizeof(char));
@ -145,7 +148,7 @@ p_no_print_instruction( USES_REGS1 )
ExpEnv.debug_struc.pyaam_##OP.msg_before = 0; \ ExpEnv.debug_struc.pyaam_##OP.msg_before = 0; \
ExpEnv.debug_struc.pyaam_##OP.msg_after = 0; \ ExpEnv.debug_struc.pyaam_##OP.msg_after = 0; \
} }
#include "YapAppliedOpcodes.h" #include "YapOpcodes.h"
#undef OPCODE #undef OPCODE
else { else {
Yap_Error(OUT_OF_KNOWNRANGE_ERROR,u,""); Yap_Error(OUT_OF_KNOWNRANGE_ERROR,u,"");
@ -2371,9 +2374,12 @@ p_no_exit_on_error( USES_REGS1 )
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
void void
Yap_InitJitDebugPreds( USES_REGS1 ) Yap_InitJitDebugPreds( USES_REGS1 )
{ {
#if YAP_DBG_PREDS
Yap_InitCPred("no_print_instruction", 1, p_no_print_instruction, SafePredFlag); Yap_InitCPred("no_print_instruction", 1, p_no_print_instruction, SafePredFlag);
Yap_InitCPred("no_print_basic_instruction", 1, p_no_print_basic_instruction, SafePredFlag); Yap_InitCPred("no_print_basic_instruction", 1, p_no_print_basic_instruction, SafePredFlag);
Yap_InitCPred("no_print_std_instruction", 1, p_no_print_std_instruction, SafePredFlag); Yap_InitCPred("no_print_std_instruction", 1, p_no_print_std_instruction, SafePredFlag);
@ -2473,4 +2479,6 @@ Yap_InitJitDebugPreds( USES_REGS1 )
Yap_InitCPred("no_exit_on_warning", 0, p_no_exit_on_warning, SafePredFlag); Yap_InitCPred("no_exit_on_warning", 0, p_no_exit_on_warning, SafePredFlag);
Yap_InitCPred("enable_on_warning", 0, p_enable_on_warning, SafePredFlag); Yap_InitCPred("enable_on_warning", 0, p_enable_on_warning, SafePredFlag);
Yap_InitCPred("no_exit_on_error", 0, p_no_exit_on_error, SafePredFlag); Yap_InitCPred("no_exit_on_error", 0, p_no_exit_on_error, SafePredFlag);
#endif
} }

View File

@ -15,7 +15,10 @@
* Last rev: 2013-10-18 * * Last rev: 2013-10-18 *
*************************************************************************/ *************************************************************************/
#include "jit_predicates.hh" #include "jit_predicates.hpp"
#if YAP_STAT_PREDS
#include <papi.h> #include <papi.h>
static Int p_init_low_level_stats( USES_REGS1 ); static Int p_init_low_level_stats( USES_REGS1 );
@ -555,6 +558,7 @@ p_statistics_jit( USES_REGS1 )
fprintf(stderr, "------------------------------\n"); fprintf(stderr, "------------------------------\n");
} }
#if YAP_STAT_PREDS
// From this point until the end we do: // From this point until the end we do:
// 1. We verify if PAPI was initialized (ExpEnv.stats_struc.papi_initialized). If yes, we do: // 1. We verify if PAPI was initialized (ExpEnv.stats_struc.papi_initialized). If yes, we do:
// 2. We verify what event type was used. Based on this, we alloc memory for 'ExpEnv.stats_struc.papi_values' // 2. We verify what event type was used. Based on this, we alloc memory for 'ExpEnv.stats_struc.papi_values'
@ -823,6 +827,7 @@ p_statistics_jit( USES_REGS1 )
} }
fprintf(stderr, "------------------------------\n"); fprintf(stderr, "------------------------------\n");
#endif
} }
return TRUE; return TRUE;
@ -830,9 +835,13 @@ p_statistics_jit( USES_REGS1 )
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
void void
Yap_InitJitStatisticPreds(void) Yap_InitJitStatisticPreds(void)
{ {
#if YAP_STAT_PREDS
Yap_InitCPred("init_low_level_stats", 1, p_init_low_level_stats, SafePredFlag); Yap_InitCPred("init_low_level_stats", 1, p_init_low_level_stats, SafePredFlag);
Yap_InitCPred("statistics_jit", 0, p_statistics_jit, SafePredFlag); Yap_InitCPred("statistics_jit", 0, p_statistics_jit, SafePredFlag);
#endif
} }

View File

@ -1942,6 +1942,11 @@ significant byte first (like Motorola and SPARC, unlike Intel). */
#define YAP_YAPLIB "${YAP_YAPLIB}" #define YAP_YAPLIB "${YAP_YAPLIB}"
#endif #endif
/* name of YAP JIT library */
#ifndef YAP_YAPJITLIB
#define YAP_YAPJITLIB "${YAP_YAPJITLIB}"
#endif
/* HP-UX old socket stuff */ /* HP-UX old socket stuff */
#ifndef _XOPEN_SOURCE #ifndef _XOPEN_SOURCE
#cmakedefine _XOPEN_SOURCE "${_XOPEN_SOURCE}" #cmakedefine _XOPEN_SOURCE "${_XOPEN_SOURCE}"

View File

@ -287,10 +287,10 @@ typedef void (*YAP_halt_hook)(int exit_code, void *closure);
typedef YAP_Int YAP_opaque_tag_t; typedef YAP_Int YAP_opaque_tag_t;
typedef int (*YAP_Opaque_CallOnFail)(void *); typedef YAP_Bool (*YAP_Opaque_CallOnFail)(void *);
typedef int (*YAP_Opaque_CallOnWrite)(void *, YAP_opaque_tag_t, void *, int); typedef YAP_Bool (*YAP_Opaque_CallOnWrite)(void *, YAP_opaque_tag_t, void *, int);
typedef YAP_Int (*YAP_Opaque_CallOnGCMark)(YAP_opaque_tag_t, void *, YAP_Term *, YAP_Int); typedef YAP_Int (*YAP_Opaque_CallOnGCMark)(YAP_opaque_tag_t, void *, YAP_Term *, YAP_Int);
typedef int (*YAP_Opaque_CallOnGCRelocate)(YAP_opaque_tag_t, void *, YAP_Term *, YAP_Int); typedef YAP_Bool (*YAP_Opaque_CallOnGCRelocate)(YAP_opaque_tag_t, void *, YAP_Term *, YAP_Int);
typedef struct YAP_opaque_handler_struct { typedef struct YAP_opaque_handler_struct {
YAP_Opaque_CallOnFail fail_handler; YAP_Opaque_CallOnFail fail_handler;

View File

@ -1577,6 +1577,10 @@ the future we plan to split this library into several smaller libraries
#include <stdarg.h> #include <stdarg.h>
#endif #endif
#if HAVE_STDBOOL_H
#include <stdbool.h>
#endif
#include <wchar.h> #include <wchar.h>
/* /*

View File

@ -24,7 +24,7 @@
#ifndef Bool #ifndef Bool
#define Bool YAP_Bool #define Bool YAP_Bool
#endif #endif11
#define Int long int #define Int long int

View File

@ -59,6 +59,7 @@ set (LIBRARY_PL
) )
add_subdirectory(clp) add_subdirectory(clp)
add_subdirectory(dialect)
add_subdirectory(lammpi) add_subdirectory(lammpi)
add_subdirectory(matlab) add_subdirectory(matlab)
add_subdirectory(matrix) add_subdirectory(matrix)

View File

@ -0,0 +1,12 @@
set (DIALECTS_PL
bprolog.yap
commons.yap
hprolog.yap
swi.yap
)
add_subdirectory(swi)
install(FILES ${DIALECTS_PL}
DESTINATION ${libpl}/dialect
)

View File

@ -1,8 +1,15 @@
macro_optional_find_package (MPI OFF)
macro_log_feature (MPI_C_FOUND "mpi" set (MPI_SOURCES
"MPI Distributed Parallel Programming" hash.c prologterms2c.c yap_mpi.c)
"http://gmplib.org")
if (MPI_C_FOUND) macro_optional_find_package(MPI ON)
macro_log_feature (MPI_C_FOUND "Mpi"
"Use Mpi System"
"http://www.mpi.org" FALSE)
if (MPI_C_FOUND)
# === Variables ===
#
# This module will set the following variables per language in your # This module will set the following variables per language in your
# project, where <lang> is one of C, CXX, or Fortran: # project, where <lang> is one of C, CXX, or Fortran:
# #
@ -27,5 +34,52 @@ if (MPI_C_FOUND)
# before the executable to run. # before the executable to run.
# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags # MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags
# #
endif (MPI_C_FOUND) # === Usage ===
#
# To use this module, simply call FindMPI from a CMakeLists.txt file, or
# run find_package(MPI), then run CMake. If you are happy with the
# auto- detected configuration for your language, then you're done. If
# not, you have two options:
#
# ::
#
# 1. Set MPI_<lang>_COMPILER to the MPI wrapper (mpicc, etc.) of your
# choice and reconfigure. FindMPI will attempt to determine all the
# necessary variables using THAT compiler's compile and link flags.
# 2. If this fails, or if your MPI implementation does not come with
# a compiler wrapper, then set both MPI_<lang>_LIBRARIES and
# MPI_<lang>_INCLUDE_PATH. You may also set any other variables
# listed above, but these two are required. This will circumvent
# autodetection entirely.
#
# When configuration is successful, MPI_<lang>_COMPILER will be set to
# the compiler wrapper for <lang>, if it was found. MPI_<lang>_FOUND
# and other variables above will be set if any MPI implementation was
# found for <lang>, regardless of whether a compiler was found.
#
# When using MPIEXEC to execute MPI applications, you should typically
# use all of the MPIEXEC flags as follows:
#
# ::
#
# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS
# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
#
# where PROCS is the number of processors on which to execute the
# program, EXECUTABLE is the MPI program, and ARGS are the arguments to
# pass to the MPI program.
#
add_library (yap_mpi SHARED ${MPI_SOURCES})
target_link_libraries(yap_mpi libYap ${MPI_LIBRARIES})
set_target_properties (yap_mpi PROPERTIES PREFIX "")
include_directories (${MPI_INCLUDE_DIRS})
install(TARGETS yap_mpi
LIBRARY DESTINATION ${dlls}
)
endif (MPI_C_FOUND)

View File

@ -197,7 +197,7 @@ new_float_matrix(int ndims, int dims[], double data[])
return blob; return blob;
} }
static int static YAP_Bool
scan_dims(int ndims, YAP_Term tl, int dims[MAX_DIMS]) scan_dims(int ndims, YAP_Term tl, int dims[MAX_DIMS])
{ {
int i; int i;
@ -229,7 +229,7 @@ scan_dims(int ndims, YAP_Term tl, int dims[MAX_DIMS])
return TRUE; return TRUE;
} }
static int static YAP_Bool
scan_dims_args(int ndims, YAP_Term tl, int dims[MAX_DIMS]) scan_dims_args(int ndims, YAP_Term tl, int dims[MAX_DIMS])
{ {
int i; int i;
@ -253,7 +253,7 @@ scan_dims_args(int ndims, YAP_Term tl, int dims[MAX_DIMS])
return TRUE; return TRUE;
} }
static int static YAP_Bool
cp_int_matrix(YAP_Term tl,YAP_Term matrix) cp_int_matrix(YAP_Term tl,YAP_Term matrix)
{ {
int *mat = (int *)YAP_BlobOfTerm(matrix); int *mat = (int *)YAP_BlobOfTerm(matrix);
@ -283,7 +283,7 @@ cp_int_matrix(YAP_Term tl,YAP_Term matrix)
return TRUE; return TRUE;
} }
static int static YAP_Bool
cp_float_matrix(YAP_Term tl,YAP_Term matrix) cp_float_matrix(YAP_Term tl,YAP_Term matrix)
{ {
int *mat = (int *)YAP_BlobOfTerm(matrix); int *mat = (int *)YAP_BlobOfTerm(matrix);
@ -317,7 +317,7 @@ cp_float_matrix(YAP_Term tl,YAP_Term matrix)
} }
static int static YAP_Bool
set_int_matrix(YAP_Term matrix,long int set) set_int_matrix(YAP_Term matrix,long int set)
{ {
int *mat = (int *)YAP_BlobOfTerm(matrix); int *mat = (int *)YAP_BlobOfTerm(matrix);
@ -330,7 +330,7 @@ set_int_matrix(YAP_Term matrix,long int set)
return TRUE; return TRUE;
} }
static int static YAP_Bool
set_float_matrix(YAP_Term matrix,double set) set_float_matrix(YAP_Term matrix,double set)
{ {
int *mat = (int *)YAP_BlobOfTerm(matrix); int *mat = (int *)YAP_BlobOfTerm(matrix);
@ -343,7 +343,7 @@ set_float_matrix(YAP_Term matrix,double set)
return TRUE; return TRUE;
} }
static int static YAP_Bool
new_ints_matrix(void) new_ints_matrix(void)
{ {
int ndims = YAP_IntOfTerm(YAP_ARG1); int ndims = YAP_IntOfTerm(YAP_ARG1);
@ -360,7 +360,7 @@ new_ints_matrix(void)
return YAP_Unify(YAP_ARG4, out); return YAP_Unify(YAP_ARG4, out);
} }
static int static YAP_Bool
new_ints_matrix_set(void) new_ints_matrix_set(void)
{ {
int ndims = YAP_IntOfTerm(YAP_ARG1); int ndims = YAP_IntOfTerm(YAP_ARG1);
@ -380,7 +380,7 @@ new_ints_matrix_set(void)
return YAP_Unify(YAP_ARG4, out); return YAP_Unify(YAP_ARG4, out);
} }
static int static YAP_Bool
new_floats_matrix(void) new_floats_matrix(void)
{ {
int ndims = YAP_IntOfTerm(YAP_ARG1); int ndims = YAP_IntOfTerm(YAP_ARG1);
@ -396,7 +396,7 @@ new_floats_matrix(void)
return YAP_Unify(YAP_ARG4, out); return YAP_Unify(YAP_ARG4, out);
} }
static int static YAP_Bool
new_floats_matrix_set(void) new_floats_matrix_set(void)
{ {
int ndims = YAP_IntOfTerm(YAP_ARG1); int ndims = YAP_IntOfTerm(YAP_ARG1);
@ -636,7 +636,7 @@ matrix_dec2(int *mat, int *indx)
} }
static int static YAP_Bool
matrix_set(void) matrix_set(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -674,7 +674,7 @@ matrix_set(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_set2(void) matrix_set2(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -712,7 +712,7 @@ matrix_set2(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_set_all(void) matrix_set_all(void)
{ {
int *mat; int *mat;
@ -746,7 +746,7 @@ matrix_set_all(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_add(void) matrix_add(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -784,7 +784,7 @@ matrix_add(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
do_matrix_access(void) do_matrix_access(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -803,7 +803,7 @@ do_matrix_access(void)
return YAP_Unify(tf, YAP_ARG3); return YAP_Unify(tf, YAP_ARG3);
} }
static int static YAP_Bool
do_matrix_access2(void) do_matrix_access2(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -822,7 +822,7 @@ do_matrix_access2(void)
return YAP_Unify(tf, YAP_ARG2); return YAP_Unify(tf, YAP_ARG2);
} }
static int static YAP_Bool
do_matrix_inc(void) do_matrix_inc(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -840,7 +840,7 @@ do_matrix_inc(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
do_matrix_dec(void) do_matrix_dec(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -858,7 +858,7 @@ do_matrix_dec(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
do_matrix_inc2(void) do_matrix_inc2(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -876,7 +876,7 @@ do_matrix_inc2(void)
YAP_Unify(matrix_inc2(mat, dims), YAP_ARG3); YAP_Unify(matrix_inc2(mat, dims), YAP_ARG3);
} }
static int static YAP_Bool
do_matrix_dec2(void) do_matrix_dec2(void)
{ {
int dims[MAX_DIMS], *mat; int dims[MAX_DIMS], *mat;
@ -894,7 +894,7 @@ do_matrix_dec2(void)
YAP_Unify(matrix_dec2(mat, dims), YAP_ARG3); YAP_Unify(matrix_dec2(mat, dims), YAP_ARG3);
} }
static int static YAP_Bool
matrix_to_list(void) matrix_to_list(void)
{ {
int *mat; int *mat;
@ -912,7 +912,7 @@ matrix_to_list(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_set_base(void) matrix_set_base(void)
{ {
int *mat; int *mat;
@ -927,7 +927,7 @@ matrix_set_base(void)
} }
static int static YAP_Bool
matrix_dims(void) matrix_dims(void)
{ {
int *mat; int *mat;
@ -942,7 +942,7 @@ matrix_dims(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_dims3(void) matrix_dims3(void)
{ {
int *mat; int *mat;
@ -958,7 +958,7 @@ matrix_dims3(void)
return YAP_Unify(YAP_ARG2, tf) && YAP_Unify(YAP_ARG3, tof); return YAP_Unify(YAP_ARG2, tf) && YAP_Unify(YAP_ARG3, tof);
} }
static int static YAP_Bool
matrix_size(void) matrix_size(void)
{ {
int *mat; int *mat;
@ -971,7 +971,7 @@ matrix_size(void)
return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(mat[MAT_SIZE])); return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(mat[MAT_SIZE]));
} }
static int static YAP_Bool
matrix_ndims(void) matrix_ndims(void)
{ {
int *mat; int *mat;
@ -984,7 +984,7 @@ matrix_ndims(void)
return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(mat[MAT_NDIMS])); return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(mat[MAT_NDIMS]));
} }
static int static YAP_Bool
matrix_type(void) matrix_type(void)
{ {
int *mat; int *mat;
@ -1003,7 +1003,7 @@ matrix_type(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_arg_to_offset(void) matrix_arg_to_offset(void)
{ {
int indx[MAX_DIMS], *mat; int indx[MAX_DIMS], *mat;
@ -1023,7 +1023,7 @@ matrix_arg_to_offset(void)
return YAP_Unify(YAP_ARG3, YAP_MkIntTerm(off)); return YAP_Unify(YAP_ARG3, YAP_MkIntTerm(off));
} }
static int static YAP_Bool
matrix_offset_to_arg(void) matrix_offset_to_arg(void)
{ {
int indx[MAX_DIMS], *mat; int indx[MAX_DIMS], *mat;
@ -1101,7 +1101,7 @@ scan_min_float(int sz, double *data)
return off; return off;
} }
static int static YAP_Bool
matrix_max(void) matrix_max(void)
{ {
int *mat; int *mat;
@ -1125,7 +1125,7 @@ matrix_max(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_maxarg(void) matrix_maxarg(void)
{ {
int indx[MAX_DIMS], *mat; int indx[MAX_DIMS], *mat;
@ -1149,7 +1149,7 @@ matrix_maxarg(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_min(void) matrix_min(void)
{ {
int *mat; int *mat;
@ -1173,7 +1173,7 @@ matrix_min(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_log_all(void) matrix_log_all(void)
{ {
int *mat; int *mat;
@ -1196,7 +1196,7 @@ matrix_log_all(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_log_all2(void) matrix_log_all2(void)
{ {
int *mat; int *mat;
@ -1253,7 +1253,7 @@ matrix_log_all2(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_exp_all(void) matrix_exp_all(void)
{ {
int *mat; int *mat;
@ -1276,7 +1276,7 @@ matrix_exp_all(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_exp2_all(void) matrix_exp2_all(void)
{ {
int *mat; int *mat;
@ -1304,7 +1304,7 @@ matrix_exp2_all(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_exp_all2(void) matrix_exp_all2(void)
{ {
int *mat; int *mat;
@ -1361,7 +1361,7 @@ matrix_exp_all2(void)
return TRUE; return TRUE;
} }
static int static YAP_Bool
matrix_minarg(void) matrix_minarg(void)
{ {
int indx[MAX_DIMS], *mat; int indx[MAX_DIMS], *mat;
@ -1385,7 +1385,7 @@ matrix_minarg(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
matrix_sum(void) matrix_sum(void)
{ {
int *mat; int *mat;
@ -1448,7 +1448,7 @@ add_double_lines(int total,int nlines,double *mat0,double *matf)
} }
} }
static int static YAP_Bool
matrix_agg_lines(void) matrix_agg_lines(void)
{ {
int *mat; int *mat;
@ -1531,7 +1531,7 @@ add_double_cols(int total,int nlines,double *mat0,double *matf)
} }
} }
static int static YAP_Bool
matrix_agg_cols(void) matrix_agg_cols(void)
{ {
int *mat; int *mat;
@ -1620,7 +1620,7 @@ div_float_by_lines(int total,int nlines,double *mat1,double *mat2,double *ndata)
} }
} }
static int static YAP_Bool
matrix_op_to_lines(void) matrix_op_to_lines(void)
{ {
int *mat1, *mat2; int *mat1, *mat2;
@ -1906,7 +1906,7 @@ matrix_double_zdiv_data(double *nmat, int siz, double mat1[], double mat2[])
} }
} }
static int static YAP_Bool
matrix_op(void) matrix_op(void)
{ {
int *mat1, *mat2; int *mat1, *mat2;
@ -2127,7 +2127,7 @@ add_double_by_cols(int total,int nlines,double *mat1,double *mat2,double *ndata)
} }
} }
static int static YAP_Bool
matrix_op_to_cols(void) matrix_op_to_cols(void)
{ {
int *mat1, *mat2; int *mat1, *mat2;
@ -2208,7 +2208,7 @@ matrix_op_to_cols(void)
return YAP_Unify(YAP_ARG4,tf); return YAP_Unify(YAP_ARG4,tf);
} }
static int static YAP_Bool
matrix_op_to_all(void) matrix_op_to_all(void)
{ {
int *mat; int *mat;
@ -2387,7 +2387,7 @@ matrix_op_to_all(void)
/* given a matrix M and a set of dims, build a new reordered matrix to follow /* given a matrix M and a set of dims, build a new reordered matrix to follow
the new order the new order
*/ */
static int static YAP_Bool
matrix_transpose(void) matrix_transpose(void)
{ {
int ndims, i, *dims, *dimsn; int ndims, i, *dims, *dimsn;
@ -2469,7 +2469,7 @@ matrix_transpose(void)
/* given a matrix M and a set of dims, fold one of the dimensions of the /* given a matrix M and a set of dims, fold one of the dimensions of the
matrix on one of the elements matrix on one of the elements
*/ */
static int static YAP_Bool
matrix_select(void) matrix_select(void)
{ {
int ndims, i, j, newdims, prdim, leftarg, *dims, indx[MAX_DIMS]; int ndims, i, j, newdims, prdim, leftarg, *dims, indx[MAX_DIMS];
@ -2570,7 +2570,7 @@ matrix_select(void)
/* given a matrix M and a set of N-1 dims, get the first dimension /* given a matrix M and a set of N-1 dims, get the first dimension
*/ */
static int static YAP_Bool
matrix_column(void) matrix_column(void)
{ {
int size, i, ndims, newdims[1]; int size, i, ndims, newdims[1];
@ -2639,7 +2639,7 @@ matrix_column(void)
/* given a matrix M and a set of dims, sum out one of the dimensions /* given a matrix M and a set of dims, sum out one of the dimensions
*/ */
static int static YAP_Bool
matrix_sum_out(void) matrix_sum_out(void)
{ {
int ndims, i, j, newdims, prdim; int ndims, i, j, newdims, prdim;
@ -2728,7 +2728,7 @@ matrix_sum_out(void)
/* given a matrix M and a set of dims, sum out one of the dimensions /* given a matrix M and a set of dims, sum out one of the dimensions
*/ */
static int static YAP_Bool
matrix_sum_out_several(void) matrix_sum_out_several(void)
{ {
int ndims, i, *dims, newdims; int ndims, i, *dims, newdims;
@ -2821,7 +2821,7 @@ matrix_sum_out_several(void)
/* given a matrix M and a set of dims, sum out one of the dimensions /* given a matrix M and a set of dims, sum out one of the dimensions
*/ */
static int static YAP_Bool
matrix_sum_out_logs(void) matrix_sum_out_logs(void)
{ {
int ndims, i, j, *dims, newdims, prdim; int ndims, i, j, *dims, newdims, prdim;
@ -2910,7 +2910,7 @@ matrix_sum_out_logs(void)
/* given a matrix M and a set of dims, sum out one of the dimensions /* given a matrix M and a set of dims, sum out one of the dimensions
*/ */
static int static YAP_Bool
matrix_sum_out_logs_several(void) matrix_sum_out_logs_several(void)
{ {
int ndims, i, *dims, newdims; int ndims, i, *dims, newdims;
@ -3008,7 +3008,7 @@ matrix_sum_out_logs_several(void)
/* given a matrix M and a set of dims, build a matrix to follow /* given a matrix M and a set of dims, build a matrix to follow
the new order the new order
*/ */
static int static YAP_Bool
matrix_expand(void) matrix_expand(void)
{ {
int ndims, i, *dims, newdims=0, olddims = 0; int ndims, i, *dims, newdims=0, olddims = 0;
@ -3110,7 +3110,7 @@ matrix_expand(void)
/* given a matrix M and a set of dims, build contract a matrix to follow /* given a matrix M and a set of dims, build contract a matrix to follow
the new order the new order
*/ */
static int static YAP_Bool
matrix_set_all_that_disagree(void) matrix_set_all_that_disagree(void)
{ {
int ndims, i, *dims; int ndims, i, *dims;
@ -3189,7 +3189,7 @@ matrix_set_all_that_disagree(void)
return YAP_Unify(YAP_ARG5, tf); return YAP_Unify(YAP_ARG5, tf);
} }
static int static YAP_Bool
matrix_m(void) matrix_m(void)
{ {
int ndims, i, size; int ndims, i, size;
@ -3231,7 +3231,7 @@ matrix_m(void)
return YAP_Unify(YAP_ARG2, tm); return YAP_Unify(YAP_ARG2, tm);
} }
static int static YAP_Bool
is_matrix(void) is_matrix(void)
{ {
YAP_Term t = YAP_ARG1; YAP_Term t = YAP_ARG1;

View File

@ -26,7 +26,7 @@ void init_random( void );
static short a1 = 27314, b1 = 9213, c1 = 17773; static short a1 = 27314, b1 = 9213, c1 = 17773;
static int static YAP_Bool
p_random(void) p_random(void)
{ {
double fli; double fli;
@ -42,7 +42,7 @@ p_random(void)
return(YAP_Unify(YAP_ARG1, YAP_MkFloatTerm(fli-(int)(fli)))); return(YAP_Unify(YAP_ARG1, YAP_MkFloatTerm(fli-(int)(fli))));
} }
static int static YAP_Bool
p_setrand(void) p_setrand(void)
{ {
a1 = YAP_IntOfTerm(YAP_ARG1); a1 = YAP_IntOfTerm(YAP_ARG1);
@ -51,7 +51,7 @@ p_setrand(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
p_getrand(void) p_getrand(void)
{ {
return(YAP_Unify(YAP_ARG1,YAP_MkIntTerm(a1)) && return(YAP_Unify(YAP_ARG1,YAP_MkIntTerm(a1)) &&

View File

@ -34,7 +34,7 @@
void init_regexp( void ); void init_regexp( void );
static int check_regexp(void) static YAP_Bool check_regexp(void)
{ {
unsigned int buflen = (unsigned int)YAP_IntOfTerm(YAP_ARG2)+1; unsigned int buflen = (unsigned int)YAP_IntOfTerm(YAP_ARG2)+1;
unsigned int sbuflen = (unsigned int)YAP_IntOfTerm(YAP_ARG4)+1; unsigned int sbuflen = (unsigned int)YAP_IntOfTerm(YAP_ARG4)+1;
@ -81,7 +81,7 @@ static int check_regexp(void)
return(out == 0); return(out == 0);
} }
static int regexp(void) static YAP_Bool regexp(void)
{ {
unsigned int buflen = (unsigned int)YAP_IntOfTerm(YAP_ARG2)+1; unsigned int buflen = (unsigned int)YAP_IntOfTerm(YAP_ARG2)+1;
unsigned int sbuflen = (unsigned int)YAP_IntOfTerm(YAP_ARG4)+1; unsigned int sbuflen = (unsigned int)YAP_IntOfTerm(YAP_ARG4)+1;

View File

@ -44,7 +44,7 @@ unsigned long int tree_mem=0;
/* /*
*/ */
static static
int YAP_Bool
p_rl_new(void) { p_rl_new(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
YAP_Term t2=YAP_Deref(YAP_ARG2); YAP_Term t2=YAP_Deref(YAP_ARG2);
@ -75,7 +75,7 @@ p_rl_new(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_copy(void) { p_rl_copy(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); // src YAP_Term t1=YAP_Deref(YAP_ARG1); // src
YAP_Term t2=YAP_Deref(YAP_ARG2); // dest YAP_Term t2=YAP_Deref(YAP_ARG2); // dest
@ -113,7 +113,7 @@ p_rl_copy(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_size(void) { p_rl_size(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1),t_size; YAP_Term t1=YAP_Deref(YAP_ARG1),t_size;
@ -139,7 +139,7 @@ p_rl_size(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_mem_usage(void) { p_rl_mem_usage(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -153,7 +153,7 @@ p_rl_mem_usage(void) {
/* /*
*/ */
static static
int YAP_Bool
p_rl_free(void) { p_rl_free(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -180,7 +180,7 @@ p_rl_free(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_set_in(void) { p_rl_set_in(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -214,7 +214,7 @@ p_rl_set_in(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_in(void) { p_rl_in(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -243,7 +243,7 @@ p_rl_in(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_set_out(void) { p_rl_set_out(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -274,7 +274,7 @@ p_rl_set_out(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_freeze(void) { p_rl_freeze(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -304,7 +304,7 @@ p_rl_freeze(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_set_all_in(void) { p_rl_set_all_in(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -336,7 +336,7 @@ p_rl_set_all_in(void) {
* *
*/ */
static static
int YAP_Bool
p_rl_print(void) { p_rl_print(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -372,7 +372,7 @@ yap_back_data_type *back_data;
* *
*/ */
static static
int YAP_Bool
p_rl_b_in2(void) { p_rl_b_in2(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);
@ -393,7 +393,7 @@ p_rl_b_in2(void) {
return (FALSE); return (FALSE);
} }
static static
int YAP_Bool
p_rl_b_in1(void) { p_rl_b_in1(void) {
YAP_Term t1=YAP_Deref(YAP_ARG1); YAP_Term t1=YAP_Deref(YAP_ARG1);

View File

@ -162,7 +162,7 @@ WinError(void)
#endif #endif
/* Return time in a structure */ /* Return time in a structure */
static int static YAP_Bool
sysmktime(void) sysmktime(void)
{ {
@ -223,7 +223,7 @@ sysmktime(void)
} }
/* Return time in a structure */ /* Return time in a structure */
static int static YAP_Bool
datime(void) datime(void)
{ {
YAP_Term tf, out[6]; YAP_Term tf, out[6];
@ -268,7 +268,7 @@ datime(void)
#define BUF_SIZE 1024 #define BUF_SIZE 1024
/* Return a list of files for a directory */ /* Return a list of files for a directory */
static int static YAP_Bool
list_directory(void) list_directory(void)
{ {
YAP_Term tf = YAP_MkAtomTerm(YAP_LookupAtom("[]")); YAP_Term tf = YAP_MkAtomTerm(YAP_LookupAtom("[]"));
@ -339,7 +339,7 @@ list_directory(void)
return YAP_Unify(YAP_ARG2, tf); return YAP_Unify(YAP_ARG2, tf);
} }
static int static YAP_Bool
p_unlink(void) p_unlink(void)
{ {
char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
@ -355,7 +355,7 @@ p_unlink(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
p_mkdir(void) p_mkdir(void)
{ {
char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
@ -370,7 +370,7 @@ p_mkdir(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
p_rmdir(void) p_rmdir(void)
{ {
char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); char *fd = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
@ -385,7 +385,7 @@ p_rmdir(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
rename_file(void) rename_file(void)
{ {
char *s1 = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); char *s1 = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
@ -399,13 +399,13 @@ rename_file(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
dir_separator(void) dir_separator(void)
{ {
return(YAP_Unify(YAP_ARG1,YAP_MkAtomTerm(YAP_LookupAtom("/")))); return(YAP_Unify(YAP_ARG1,YAP_MkAtomTerm(YAP_LookupAtom("/"))));
} }
static int static YAP_Bool
file_property(void) file_property(void)
{ {
const char *fd; const char *fd;
@ -486,7 +486,7 @@ file_property(void)
/* temporary files */ /* temporary files */
static int static YAP_Bool
p_mktemp(void) p_mktemp(void)
{ {
#if HAVE_MKSTEMP || HAVE_MKTEMP || defined(__MINGW32__) || _MSC_VER #if HAVE_MKSTEMP || HAVE_MKTEMP || defined(__MINGW32__) || _MSC_VER
@ -523,7 +523,7 @@ p_mktemp(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
p_tmpnam(void) p_tmpnam(void)
{ {
#if HAVE_MKSTEMP #if HAVE_MKSTEMP
@ -547,7 +547,7 @@ p_tmpnam(void)
#endif #endif
} }
static int static YAP_Bool
p_tmpdir(void) p_tmpdir(void)
{ {
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
@ -579,7 +579,7 @@ p_tmpdir(void)
} }
/* return YAP's environment */ /* return YAP's environment */
static int static YAP_Bool
p_environ(void) p_environ(void)
{ {
#if HAVE_ENVIRON && 0 #if HAVE_ENVIRON && 0
@ -646,7 +646,7 @@ close_handle(YAP_Term ti, HANDLE h)
#endif #endif
/* execute a command as a detached process */ /* execute a command as a detached process */
static int static YAP_Bool
execute_command(void) execute_command(void)
{ {
YAP_Term ti = YAP_ARG2, to = YAP_ARG3, te = YAP_ARG4; YAP_Term ti = YAP_ARG2, to = YAP_ARG3, te = YAP_ARG4;
@ -802,7 +802,7 @@ execute_command(void)
} }
/* execute a command as a detached process */ /* execute a command as a detached process */
static int static YAP_Bool
do_system(void) do_system(void)
{ {
char *command = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1)); char *command = (char *)YAP_AtomName(YAP_AtomOfTerm(YAP_ARG1));
@ -821,7 +821,7 @@ do_system(void)
/* execute a command as a detached process */ /* execute a command as a detached process */
static int static YAP_Bool
do_shell(void) do_shell(void)
{ {
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
@ -881,7 +881,7 @@ do_shell(void)
} }
/* execute a command as a detached process */ /* execute a command as a detached process */
static int static YAP_Bool
p_wait(void) p_wait(void)
{ {
long int pid = YAP_IntOfTerm(YAP_ARG1); long int pid = YAP_IntOfTerm(YAP_ARG1);
@ -915,7 +915,7 @@ p_wait(void)
#endif #endif
} }
static int static YAP_Bool
p_sleep(void) p_sleep(void)
{ {
YAP_Term ts = YAP_ARG1; YAP_Term ts = YAP_ARG1;
@ -986,7 +986,7 @@ p_sleep(void)
/* host info */ /* host info */
static int static YAP_Bool
host_name(void) host_name(void)
{ {
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
@ -1007,7 +1007,7 @@ host_name(void)
return(YAP_Unify(YAP_ARG1, YAP_MkAtomTerm(YAP_LookupAtom(name)))); return(YAP_Unify(YAP_ARG1, YAP_MkAtomTerm(YAP_LookupAtom(name))));
} }
static int static YAP_Bool
host_id(void) host_id(void)
{ {
#if HAVE_GETHOSTID #if HAVE_GETHOSTID
@ -1017,7 +1017,7 @@ host_id(void)
#endif #endif
} }
static int static YAP_Bool
pid(void) pid(void)
{ {
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
@ -1027,7 +1027,7 @@ pid(void)
#endif #endif
} }
static int static YAP_Bool
win(void) win(void)
{ {
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
@ -1037,7 +1037,7 @@ win(void)
#endif #endif
} }
static int static YAP_Bool
p_kill(void) p_kill(void)
{ {
#if defined(__MINGW32__) || _MSC_VER #if defined(__MINGW32__) || _MSC_VER
@ -1061,7 +1061,7 @@ p_kill(void)
return(TRUE); return(TRUE);
} }
static int static YAP_Bool
error_message(void) error_message(void)
{ {
#if HAVE_STRERROR #if HAVE_STRERROR

View File

@ -24,35 +24,35 @@
/* -------------------------- */ /* -------------------------- */
void init_itries(void); void init_itries(void);
static int p_itrie_open(void); static YAP_Bool p_itrie_open(void);
static int p_itrie_close(void); static YAP_Bool p_itrie_close(void);
static int p_itrie_close_all(void); static YAP_Bool p_itrie_close_all(void);
static int p_itrie_mode(void); static YAP_Bool p_itrie_mode(void);
static int p_itrie_timestamp(void); static YAP_Bool p_itrie_timestamp(void);
static int p_itrie_put_entry(void); static YAP_Bool p_itrie_put_entry(void);
static int p_itrie_update_entry(void); static YAP_Bool p_itrie_update_entry(void);
static int p_itrie_check_entry(void); static YAP_Bool p_itrie_check_entry(void);
static int p_itrie_get_entry(void); static YAP_Bool p_itrie_get_entry(void);
static int p_itrie_get_data(void); static YAP_Bool p_itrie_get_data(void);
static int p_itrie_traverse_init(void); static YAP_Bool p_itrie_traverse_init(void);
static int p_itrie_traverse_cont(void); static YAP_Bool p_itrie_traverse_cont(void);
static int p_itrie_remove_entry(void); static YAP_Bool p_itrie_remove_entry(void);
static int p_itrie_remove_subtree(void); static YAP_Bool p_itrie_remove_subtree(void);
static int p_itrie_add(void); static YAP_Bool p_itrie_add(void);
static int p_itrie_subtract(void); static YAP_Bool p_itrie_subtract(void);
static int p_itrie_join(void); static YAP_Bool p_itrie_join(void);
static int p_itrie_intersect(void); static YAP_Bool p_itrie_intersect(void);
static int p_itrie_count_join(void); static YAP_Bool p_itrie_count_join(void);
static int p_itrie_count_intersect(void); static YAP_Bool p_itrie_count_intersect(void);
static int p_itrie_save(void); static YAP_Bool p_itrie_save(void);
static int p_itrie_save_as_trie(void); static YAP_Bool p_itrie_save_as_trie(void);
static int p_itrie_load(void); static YAP_Bool p_itrie_load(void);
static int p_itrie_save2stream(void); static YAP_Bool p_itrie_save2stream(void);
static int p_itrie_loadFromStream(void); static YAP_Bool p_itrie_loadFromStream(void);
static int p_itrie_stats(void); static YAP_Bool p_itrie_stats(void);
static int p_itrie_max_stats(void); static YAP_Bool p_itrie_max_stats(void);
static int p_itrie_usage(void); static YAP_Bool p_itrie_usage(void);
static int p_itrie_print(void); static YAP_Bool p_itrie_print(void);
@ -102,7 +102,7 @@ void init_itries(void) {
/* itrie_open(-Itrie) */ /* itrie_open(-Itrie) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
static int p_itrie_open(void) { static YAP_Bool p_itrie_open(void) {
TrEntry itrie; TrEntry itrie;
/* check arg */ /* check arg */
@ -118,7 +118,7 @@ static int p_itrie_open(void) {
/* itrie_close(+Itrie) */ /* itrie_close(+Itrie) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
static int p_itrie_close(void) { static YAP_Bool p_itrie_close(void) {
/* check arg */ /* check arg */
if (!YAP_IsIntTerm(arg_itrie)) if (!YAP_IsIntTerm(arg_itrie))
return FALSE; return FALSE;
@ -131,7 +131,7 @@ static int p_itrie_close(void) {
/* itrie_close_all() */ /* itrie_close_all() */
static int p_itrie_close_all(void) { static YAP_Bool p_itrie_close_all(void) {
itrie_close_all(); itrie_close_all();
return TRUE; return TRUE;
} }
@ -140,7 +140,7 @@ static int p_itrie_close_all(void) {
/* itrie_mode(+Itrie,?Mode) */ /* itrie_mode(+Itrie,?Mode) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_mode YAP_ARG2 #define arg_mode YAP_ARG2
static int p_itrie_mode(void) { static YAP_Bool p_itrie_mode(void) {
YAP_Term mode_term; YAP_Term mode_term;
const char *mode_str; const char *mode_str;
YAP_Int mode; YAP_Int mode;
@ -191,7 +191,7 @@ static int p_itrie_mode(void) {
/* itrie_timestamp(+Itrie,?Time) */ /* itrie_timestamp(+Itrie,?Time) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_time YAP_ARG2 #define arg_time YAP_ARG2
static int p_itrie_timestamp(void) { static YAP_Bool p_itrie_timestamp(void) {
YAP_Int time; YAP_Int time;
/* check arg */ /* check arg */
@ -220,7 +220,7 @@ static int p_itrie_timestamp(void) {
/* itrie_put_entry(+Itrie,+Entry) */ /* itrie_put_entry(+Itrie,+Entry) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_entry YAP_ARG2 #define arg_entry YAP_ARG2
static int p_itrie_put_entry(void) { static YAP_Bool p_itrie_put_entry(void) {
/* check arg */ /* check arg */
if (!YAP_IsIntTerm(arg_itrie)) if (!YAP_IsIntTerm(arg_itrie))
return FALSE; return FALSE;
@ -236,7 +236,7 @@ static int p_itrie_put_entry(void) {
/* itrie_update_entry(+Itrie,+Entry) */ /* itrie_update_entry(+Itrie,+Entry) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_entry YAP_ARG2 #define arg_entry YAP_ARG2
static int p_itrie_update_entry(void) { static YAP_Bool p_itrie_update_entry(void) {
/* check arg */ /* check arg */
if (!YAP_IsIntTerm(arg_itrie)) if (!YAP_IsIntTerm(arg_itrie))
return FALSE; return FALSE;
@ -253,7 +253,7 @@ static int p_itrie_update_entry(void) {
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_entry YAP_ARG2 #define arg_entry YAP_ARG2
#define arg_ref YAP_ARG3 #define arg_ref YAP_ARG3
static int p_itrie_check_entry(void) { static YAP_Bool p_itrie_check_entry(void) {
TrData data; TrData data;
/* check arg */ /* check arg */
@ -273,7 +273,7 @@ static int p_itrie_check_entry(void) {
/* itrie_get_entry(+Ref,-Entry) */ /* itrie_get_entry(+Ref,-Entry) */
#define arg_ref YAP_ARG1 #define arg_ref YAP_ARG1
#define arg_entry YAP_ARG2 #define arg_entry YAP_ARG2
static int p_itrie_get_entry(void) { static YAP_Bool p_itrie_get_entry(void) {
YAP_Term entry; YAP_Term entry;
/* check arg */ /* check arg */
@ -291,7 +291,7 @@ static int p_itrie_get_entry(void) {
/* itrie_get_data(+Ref,-Data) */ /* itrie_get_data(+Ref,-Data) */
#define arg_ref YAP_ARG1 #define arg_ref YAP_ARG1
#define arg_data YAP_ARG2 #define arg_data YAP_ARG2
static int p_itrie_get_data(void) { static YAP_Bool p_itrie_get_data(void) {
YAP_Term list; YAP_Term list;
YAP_Term item; YAP_Term item;
YAP_Functor f; YAP_Functor f;
@ -325,7 +325,7 @@ static int p_itrie_get_data(void) {
/* itrie_traverse(+Itrie,-Ref) */ /* itrie_traverse(+Itrie,-Ref) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_ref YAP_ARG2 #define arg_ref YAP_ARG2
static int p_itrie_traverse_init(void) { static YAP_Bool p_itrie_traverse_init(void) {
TrData data; TrData data;
/* check arg */ /* check arg */
@ -346,7 +346,7 @@ static int p_itrie_traverse_init(void) {
/* itrie_traverse(+Itrie,-Ref) */ /* itrie_traverse(+Itrie,-Ref) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_ref YAP_ARG2 #define arg_ref YAP_ARG2
static int p_itrie_traverse_cont(void) { static YAP_Bool p_itrie_traverse_cont(void) {
TrData data; TrData data;
/* traverse itrie */ /* traverse itrie */
@ -362,7 +362,7 @@ static int p_itrie_traverse_cont(void) {
/* itrie_remove_entry(+Ref) */ /* itrie_remove_entry(+Ref) */
#define arg_ref YAP_ARG1 #define arg_ref YAP_ARG1
static int p_itrie_remove_entry(void) { static YAP_Bool p_itrie_remove_entry(void) {
/* check arg */ /* check arg */
if (!YAP_IsIntTerm(arg_ref)) if (!YAP_IsIntTerm(arg_ref))
return FALSE; return FALSE;
@ -376,7 +376,7 @@ static int p_itrie_remove_entry(void) {
/* itrie_remove_subtree(+Ref) */ /* itrie_remove_subtree(+Ref) */
#define arg_ref YAP_ARG1 #define arg_ref YAP_ARG1
static int p_itrie_remove_subtree(void) { static YAP_Bool p_itrie_remove_subtree(void) {
/* check arg */ /* check arg */
if (!YAP_IsIntTerm(arg_ref)) if (!YAP_IsIntTerm(arg_ref))
return FALSE; return FALSE;
@ -391,7 +391,7 @@ static int p_itrie_remove_subtree(void) {
/* itrie_add(+ItrieDest,+ItrieSource) */ /* itrie_add(+ItrieDest,+ItrieSource) */
#define arg_itrie_dest YAP_ARG1 #define arg_itrie_dest YAP_ARG1
#define arg_itrie_source YAP_ARG2 #define arg_itrie_source YAP_ARG2
static int p_itrie_add(void) { static YAP_Bool p_itrie_add(void) {
/* check args */ /* check args */
if (!YAP_IsIntTerm(arg_itrie_dest)) if (!YAP_IsIntTerm(arg_itrie_dest))
return FALSE; return FALSE;
@ -409,7 +409,7 @@ static int p_itrie_add(void) {
/* itrie_subtract(+ItrieDest,+ItrieSource) */ /* itrie_subtract(+ItrieDest,+ItrieSource) */
#define arg_itrie_dest YAP_ARG1 #define arg_itrie_dest YAP_ARG1
#define arg_itrie_source YAP_ARG2 #define arg_itrie_source YAP_ARG2
static int p_itrie_subtract(void) { static YAP_Bool p_itrie_subtract(void) {
/* check args */ /* check args */
if (!YAP_IsIntTerm(arg_itrie_dest)) if (!YAP_IsIntTerm(arg_itrie_dest))
return FALSE; return FALSE;
@ -427,7 +427,7 @@ static int p_itrie_subtract(void) {
/* itrie_join(+ItrieDest,+ItrieSource) */ /* itrie_join(+ItrieDest,+ItrieSource) */
#define arg_itrie_dest YAP_ARG1 #define arg_itrie_dest YAP_ARG1
#define arg_itrie_source YAP_ARG2 #define arg_itrie_source YAP_ARG2
static int p_itrie_join(void) { static YAP_Bool p_itrie_join(void) {
/* check args */ /* check args */
if (!YAP_IsIntTerm(arg_itrie_dest)) if (!YAP_IsIntTerm(arg_itrie_dest))
return FALSE; return FALSE;
@ -445,7 +445,7 @@ static int p_itrie_join(void) {
/* itrie_intersect(+ItrieDest,+ItrieSource) */ /* itrie_intersect(+ItrieDest,+ItrieSource) */
#define arg_itrie_dest YAP_ARG1 #define arg_itrie_dest YAP_ARG1
#define arg_itrie_source YAP_ARG2 #define arg_itrie_source YAP_ARG2
static int p_itrie_intersect(void) { static YAP_Bool p_itrie_intersect(void) {
/* check args */ /* check args */
if (!YAP_IsIntTerm(arg_itrie_dest)) if (!YAP_IsIntTerm(arg_itrie_dest))
return FALSE; return FALSE;
@ -464,7 +464,7 @@ static int p_itrie_intersect(void) {
#define arg_itrie1 YAP_ARG1 #define arg_itrie1 YAP_ARG1
#define arg_itrie2 YAP_ARG2 #define arg_itrie2 YAP_ARG2
#define arg_entries YAP_ARG3 #define arg_entries YAP_ARG3
static int p_itrie_count_join(void) { static YAP_Bool p_itrie_count_join(void) {
YAP_Int entries; YAP_Int entries;
/* check args */ /* check args */
@ -486,7 +486,7 @@ static int p_itrie_count_join(void) {
#define arg_itrie1 YAP_ARG1 #define arg_itrie1 YAP_ARG1
#define arg_itrie2 YAP_ARG2 #define arg_itrie2 YAP_ARG2
#define arg_entries YAP_ARG3 #define arg_entries YAP_ARG3
static int p_itrie_count_intersect(void) { static YAP_Bool p_itrie_count_intersect(void) {
YAP_Int entries; YAP_Int entries;
/* check args */ /* check args */
@ -507,7 +507,7 @@ static int p_itrie_count_intersect(void) {
/* itrie_save(+Itrie,+FileName) */ /* itrie_save(+Itrie,+FileName) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_file YAP_ARG2 #define arg_file YAP_ARG2
static int p_itrie_save(void) { static YAP_Bool p_itrie_save(void) {
const char *file_str; const char *file_str;
FILE *file; FILE *file;
@ -535,7 +535,7 @@ static int p_itrie_save(void) {
/* itrie_save_as_trie(+Itrie,+FileName) */ /* itrie_save_as_trie(+Itrie,+FileName) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_file YAP_ARG2 #define arg_file YAP_ARG2
static int p_itrie_save_as_trie(void) { static YAP_Bool p_itrie_save_as_trie(void) {
const char *file_str; const char *file_str;
FILE *file; FILE *file;
@ -563,7 +563,7 @@ static int p_itrie_save_as_trie(void) {
/* itrie_load(-Itrie,+FileName) */ /* itrie_load(-Itrie,+FileName) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_file YAP_ARG2 #define arg_file YAP_ARG2
static int p_itrie_load(void) { static YAP_Bool p_itrie_load(void) {
TrEntry itrie; TrEntry itrie;
const char *file_str; const char *file_str;
FILE *file; FILE *file;
@ -593,7 +593,7 @@ static int p_itrie_load(void) {
/* itrie_save2stream(+Itrie,+Stream) */ /* itrie_save2stream(+Itrie,+Stream) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_stream YAP_ARG2 #define arg_stream YAP_ARG2
static int p_itrie_save2stream(void) { static YAP_Bool p_itrie_save2stream(void) {
FILE *file; FILE *file;
/* check args */ /* check args */
@ -613,7 +613,7 @@ static int p_itrie_save2stream(void) {
/* itrie_loadFromStream(-Itrie,+Stream) */ /* itrie_loadFromStream(-Itrie,+Stream) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
#define arg_stream YAP_ARG2 #define arg_stream YAP_ARG2
static int p_itrie_loadFromStream(void) { static YAP_Bool p_itrie_loadFromStream(void) {
TrEntry itrie; TrEntry itrie;
FILE *file; FILE *file;
@ -637,7 +637,7 @@ static int p_itrie_loadFromStream(void) {
#define arg_tries YAP_ARG2 #define arg_tries YAP_ARG2
#define arg_entries YAP_ARG3 #define arg_entries YAP_ARG3
#define arg_nodes YAP_ARG4 #define arg_nodes YAP_ARG4
static int p_itrie_stats(void) { static YAP_Bool p_itrie_stats(void) {
YAP_Int memory, tries, entries, nodes; YAP_Int memory, tries, entries, nodes;
/* get stats */ /* get stats */
@ -663,7 +663,7 @@ static int p_itrie_stats(void) {
#define arg_tries YAP_ARG2 #define arg_tries YAP_ARG2
#define arg_entries YAP_ARG3 #define arg_entries YAP_ARG3
#define arg_nodes YAP_ARG4 #define arg_nodes YAP_ARG4
static int p_itrie_max_stats(void) { static YAP_Bool p_itrie_max_stats(void) {
YAP_Int memory, tries, entries, nodes; YAP_Int memory, tries, entries, nodes;
/* get stats */ /* get stats */
@ -689,7 +689,7 @@ static int p_itrie_max_stats(void) {
#define arg_entries YAP_ARG2 #define arg_entries YAP_ARG2
#define arg_nodes YAP_ARG3 #define arg_nodes YAP_ARG3
#define arg_virtualnodes YAP_ARG4 #define arg_virtualnodes YAP_ARG4
static int p_itrie_usage(void) { static YAP_Bool p_itrie_usage(void) {
YAP_Int entries, nodes, virtualnodes; YAP_Int entries, nodes, virtualnodes;
/* check arg */ /* check arg */
@ -714,7 +714,7 @@ static int p_itrie_usage(void) {
/* itrie_print(+Itrie) */ /* itrie_print(+Itrie) */
#define arg_itrie YAP_ARG1 #define arg_itrie YAP_ARG1
static int p_itrie_print(void) { static YAP_Bool p_itrie_print(void) {
/* check arg */ /* check arg */
if (!YAP_IsIntTerm(arg_itrie)) if (!YAP_IsIntTerm(arg_itrie))
return FALSE; return FALSE;

View File

@ -25,6 +25,7 @@ char** PL_Argv =NULL
// halt hooks // halt hooks
struct halt_hook* HaltHooks =NULL struct halt_hook* HaltHooks =NULL
fptr_t JIT_finalizer =NULL
// stack overflow expansion/gc control // stack overflow expansion/gc control
int AllowLocalExpansion =TRUE int AllowLocalExpansion =TRUE

View File

@ -48,5 +48,7 @@ if (CUDA_FOUND)
# CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library. # CUDA_nvcuvid_LIBRARY -- CUDA Video Decoder library.
# Only available for CUDA version 3.2+. # Only available for CUDA version 3.2+.
# Windows only. # Windows only.
endif (CUDA_FOUND) endif (CUDA_FOUND)

File diff suppressed because it is too large Load Diff

View File

@ -613,7 +613,7 @@ class CCDescriptor(object):
self.api = api self.api = api
def generate_impl(self): def generate_impl(self):
print "static int gecode_constraint_%s(void)" % self.api print "static YAP_Bool gecode_constraint_%s(void)" % self.api
print "{" print "{"
i = 1 i = 1
args = [] args = []

View File

@ -68,13 +68,13 @@ extern "C"
static YAP_opaque_tag_t gecode_space_tag; static YAP_opaque_tag_t gecode_space_tag;
static YAP_opaque_handler_t gecode_space_handler; static YAP_opaque_handler_t gecode_space_handler;
static int gecode_space_fail_handler(void* p) static YAP_Bool gecode_space_fail_handler(void* p)
{ {
delete *(GenericSpace**)p; delete *(GenericSpace**)p;
return TRUE; return TRUE;
} }
static int static YAP_Bool
gecode_space_write_handler gecode_space_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -93,7 +93,7 @@ extern "C"
return term; return term;
} }
static int gecode_new_space(void) static YAP_Bool gecode_new_space(void)
{ {
YAP_Term term = gecode_term_from_space(new GenericSpace); YAP_Term term = gecode_term_from_space(new GenericSpace);
return YAP_Unify(YAP_ARG1, term); return YAP_Unify(YAP_ARG1, term);
@ -468,7 +468,7 @@ extern "C"
static RestartMode gecode_RestartMode_from_term(YAP_Term t); static RestartMode gecode_RestartMode_from_term(YAP_Term t);
static int gecode_new_engine(void) static YAP_Bool gecode_new_engine(void)
{ {
YAP_Term arg1 = YAP_ARG1; YAP_Term arg1 = YAP_ARG1;
YAP_Term arg2 = YAP_ARG2; YAP_Term arg2 = YAP_ARG2;
@ -557,13 +557,13 @@ extern "C"
return * (GenericEngine**) YAP_OpaqueObjectFromTerm(t); return * (GenericEngine**) YAP_OpaqueObjectFromTerm(t);
} }
static int gecode_engine_fail_handler(void* p) static YAP_Bool gecode_engine_fail_handler(void* p)
{ {
delete *(GenericEngine**)p; delete *(GenericEngine**)p;
return TRUE; return TRUE;
} }
static int static YAP_Bool
gecode_engine_write_handler gecode_engine_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -572,7 +572,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_engine_search(void) static YAP_Bool gecode_engine_search(void)
{ {
GenericEngine* engine = gecode_engine_from_term(YAP_ARG1); GenericEngine* engine = gecode_engine_from_term(YAP_ARG1);
GenericSpace* space = engine->next(); GenericSpace* space = engine->next();
@ -585,7 +585,7 @@ extern "C"
} }
#ifdef DISJUNCTOR #ifdef DISJUNCTOR
static int gecode_new_disjunctor(void) static YAP_Bool gecode_new_disjunctor(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -595,7 +595,7 @@ extern "C"
return YAP_Unify(result, term); return YAP_Unify(result, term);
} }
static int static YAP_Bool
gecode_disjunctor_write_handler gecode_disjunctor_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -604,7 +604,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_new_clause(void) static YAP_Bool gecode_new_clause(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
YapDisjunctor& disj = gecode_YapDisjunctor_from_term(YAP_ARG2); YapDisjunctor& disj = gecode_YapDisjunctor_from_term(YAP_ARG2);
@ -614,7 +614,7 @@ extern "C"
return YAP_Unify(result, term); return YAP_Unify(result, term);
} }
static int static YAP_Bool
gecode_clause_write_handler gecode_clause_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -628,7 +628,7 @@ extern "C"
static FloatVar gecode_FloatVar_from_term(GenericSpace*,YAP_Term); static FloatVar gecode_FloatVar_from_term(GenericSpace*,YAP_Term);
static SetVar gecode_SetVar_from_term(GenericSpace*,YAP_Term); static SetVar gecode_SetVar_from_term(GenericSpace*,YAP_Term);
static int gecode_clause_intvar_forward(void) static YAP_Bool gecode_clause_intvar_forward(void)
{ {
Clause& clause = gecode_Clause_from_term(YAP_ARG1); Clause& clause = gecode_Clause_from_term(YAP_ARG1);
GenericSpace* outer = clause.generic_parent(); GenericSpace* outer = clause.generic_parent();
@ -639,7 +639,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_clause_boolvar_forward(void) static YAP_Bool gecode_clause_boolvar_forward(void)
{ {
Clause& clause = gecode_Clause_from_term(YAP_ARG1); Clause& clause = gecode_Clause_from_term(YAP_ARG1);
GenericSpace* outer = clause.generic_parent(); GenericSpace* outer = clause.generic_parent();
@ -650,7 +650,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_clause_setvar_forward(void) static YAP_Bool gecode_clause_setvar_forward(void)
{ {
Clause& clause = gecode_Clause_from_term(YAP_ARG1); Clause& clause = gecode_Clause_from_term(YAP_ARG1);
GenericSpace* outer = clause.generic_parent(); GenericSpace* outer = clause.generic_parent();
@ -662,7 +662,7 @@ extern "C"
} }
#endif #endif
static int gecode_new_intvar_from_bounds(void) static YAP_Bool gecode_new_intvar_from_bounds(void)
{ {
YAP_Term ivar = YAP_ARG1; YAP_Term ivar = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -673,7 +673,7 @@ extern "C"
return YAP_Unify(ivar, y_i); return YAP_Unify(ivar, y_i);
} }
static int gecode_new_floatvar_from_bounds(void) static YAP_Bool gecode_new_floatvar_from_bounds(void)
{ {
YAP_Term ivar = YAP_ARG1; YAP_Term ivar = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -713,7 +713,7 @@ extern "C"
return IntSet(SPECARRAYDEREF(r), n); return IntSet(SPECARRAYDEREF(r), n);
} }
static int gecode_new_intvar_from_intset(void) static YAP_Bool gecode_new_intvar_from_intset(void)
{ {
YAP_Term ivar = YAP_ARG1; YAP_Term ivar = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -723,7 +723,7 @@ extern "C"
return YAP_Unify(ivar, YAP_MkIntTerm(i)); return YAP_Unify(ivar, YAP_MkIntTerm(i));
} }
static int gecode_new_boolvar(void) static YAP_Bool gecode_new_boolvar(void)
{ {
YAP_Term bvar = YAP_ARG1; YAP_Term bvar = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -731,7 +731,7 @@ extern "C"
return YAP_Unify(bvar, YAP_MkIntTerm(i)); return YAP_Unify(bvar, YAP_MkIntTerm(i));
} }
static int gecode_new_setvar_1(void) static YAP_Bool gecode_new_setvar_1(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -745,7 +745,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_2(void) static YAP_Bool gecode_new_setvar_2(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -758,7 +758,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_3(void) static YAP_Bool gecode_new_setvar_3(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -770,7 +770,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_4(void) static YAP_Bool gecode_new_setvar_4(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -783,7 +783,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_5(void) static YAP_Bool gecode_new_setvar_5(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -795,7 +795,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_6(void) static YAP_Bool gecode_new_setvar_6(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -806,7 +806,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_7(void) static YAP_Bool gecode_new_setvar_7(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -819,7 +819,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_8(void) static YAP_Bool gecode_new_setvar_8(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -831,7 +831,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_9(void) static YAP_Bool gecode_new_setvar_9(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -842,7 +842,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_10(void) static YAP_Bool gecode_new_setvar_10(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -854,7 +854,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_11(void) static YAP_Bool gecode_new_setvar_11(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -865,7 +865,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_new_setvar_12(void) static YAP_Bool gecode_new_setvar_12(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -875,7 +875,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(idx)); return YAP_Unify(result, YAP_MkIntTerm(idx));
} }
static int gecode_space_minimize(void) static YAP_Bool gecode_space_minimize(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
int i = YAP_IntOfTerm(YAP_ARG2); int i = YAP_IntOfTerm(YAP_ARG2);
@ -883,7 +883,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_space_maximize(void) static YAP_Bool gecode_space_maximize(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
int i = YAP_IntOfTerm(YAP_ARG2); int i = YAP_IntOfTerm(YAP_ARG2);
@ -891,7 +891,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_space_minimize_ratio(void) static YAP_Bool gecode_space_minimize_ratio(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
int i = YAP_IntOfTerm(YAP_ARG2); int i = YAP_IntOfTerm(YAP_ARG2);
@ -900,7 +900,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_space_maximize_ratio(void) static YAP_Bool gecode_space_maximize_ratio(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
int i = YAP_IntOfTerm(YAP_ARG2); int i = YAP_IntOfTerm(YAP_ARG2);
@ -1078,7 +1078,7 @@ extern "C"
cerr << "this should never happen" << endl; exit(1); cerr << "this should never happen" << endl; exit(1);
} }
static int gecode_space_use_keep_index(void) static YAP_Bool gecode_space_use_keep_index(void)
{ {
YAP_Term arg1 = YAP_ARG1; YAP_Term arg1 = YAP_ARG1;
YAP_Term arg2 = YAP_ARG2; YAP_Term arg2 = YAP_ARG2;
@ -1087,7 +1087,7 @@ extern "C"
?gecode_TRUE:gecode_FALSE)); ?gecode_TRUE:gecode_FALSE));
} }
static int gecode_intvar_keep(void) static YAP_Bool gecode_intvar_keep(void)
{ {
YAP_Term arg1 = YAP_ARG1; YAP_Term arg1 = YAP_ARG1;
YAP_Term arg2 = YAP_ARG2; YAP_Term arg2 = YAP_ARG2;
@ -1098,7 +1098,7 @@ extern "C"
return YAP_Unify(arg3,YAP_MkIntTerm(kidx)); return YAP_Unify(arg3,YAP_MkIntTerm(kidx));
} }
static int gecode_boolvar_keep(void) static YAP_Bool gecode_boolvar_keep(void)
{ {
YAP_Term arg1 = YAP_ARG1; YAP_Term arg1 = YAP_ARG1;
YAP_Term arg2 = YAP_ARG2; YAP_Term arg2 = YAP_ARG2;
@ -1109,7 +1109,7 @@ extern "C"
return YAP_Unify(arg3,YAP_MkIntTerm(kidx)); return YAP_Unify(arg3,YAP_MkIntTerm(kidx));
} }
static int gecode_setvar_keep(void) static YAP_Bool gecode_setvar_keep(void)
{ {
YAP_Term arg1 = YAP_ARG1; YAP_Term arg1 = YAP_ARG1;
YAP_Term arg2 = YAP_ARG2; YAP_Term arg2 = YAP_ARG2;
@ -1121,14 +1121,14 @@ extern "C"
} }
// INFO ON INTVARS // INFO ON INTVARS
static int gecode_intvar_assigned(void) static YAP_Bool gecode_intvar_assigned(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
IntVar x = gecode_IntVar_from_term(space, YAP_ARG2); IntVar x = gecode_IntVar_from_term(space, YAP_ARG2);
return (x.assigned()) ? TRUE : FALSE; return (x.assigned()) ? TRUE : FALSE;
} }
static int gecode_intvar_min(void) static YAP_Bool gecode_intvar_min(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1136,7 +1136,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.min())); return YAP_Unify(result, YAP_MkIntTerm(x.min()));
} }
static int gecode_intvar_max(void) static YAP_Bool gecode_intvar_max(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1144,7 +1144,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.max())); return YAP_Unify(result, YAP_MkIntTerm(x.max()));
} }
static int gecode_intvar_med(void) static YAP_Bool gecode_intvar_med(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1152,7 +1152,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.med())); return YAP_Unify(result, YAP_MkIntTerm(x.med()));
} }
static int gecode_intvar_val(void) static YAP_Bool gecode_intvar_val(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1160,7 +1160,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.val())); return YAP_Unify(result, YAP_MkIntTerm(x.val()));
} }
static int gecode_intvar_size(void) static YAP_Bool gecode_intvar_size(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1168,7 +1168,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.size())); return YAP_Unify(result, YAP_MkIntTerm(x.size()));
} }
static int gecode_intvar_width(void) static YAP_Bool gecode_intvar_width(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1176,7 +1176,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.width())); return YAP_Unify(result, YAP_MkIntTerm(x.width()));
} }
static int gecode_intvar_regret_min(void) static YAP_Bool gecode_intvar_regret_min(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1184,7 +1184,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.regret_min())); return YAP_Unify(result, YAP_MkIntTerm(x.regret_min()));
} }
static int gecode_intvar_regret_max(void) static YAP_Bool gecode_intvar_regret_max(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1194,7 +1194,7 @@ extern "C"
static YAP_Functor gecode_COMMA2; static YAP_Functor gecode_COMMA2;
static int gecode_intvar_ranges(void) static YAP_Bool gecode_intvar_ranges(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1217,7 +1217,7 @@ extern "C"
return YAP_Unify(result,lst); return YAP_Unify(result,lst);
} }
static int gecode_intvar_values(void) static YAP_Bool gecode_intvar_values(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1235,14 +1235,14 @@ extern "C"
} }
// INFO ON BOOLVARS // INFO ON BOOLVARS
static int gecode_boolvar_assigned(void) static YAP_Bool gecode_boolvar_assigned(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG2); BoolVar x = gecode_BoolVar_from_term(space, YAP_ARG2);
return (x.assigned()) ? TRUE : FALSE; return (x.assigned()) ? TRUE : FALSE;
} }
static int gecode_boolvar_min(void) static YAP_Bool gecode_boolvar_min(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1250,7 +1250,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.min())); return YAP_Unify(result, YAP_MkIntTerm(x.min()));
} }
static int gecode_boolvar_max(void) static YAP_Bool gecode_boolvar_max(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1258,7 +1258,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.max())); return YAP_Unify(result, YAP_MkIntTerm(x.max()));
} }
static int gecode_boolvar_med(void) static YAP_Bool gecode_boolvar_med(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1266,7 +1266,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.med())); return YAP_Unify(result, YAP_MkIntTerm(x.med()));
} }
static int gecode_boolvar_val(void) static YAP_Bool gecode_boolvar_val(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1274,7 +1274,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.val())); return YAP_Unify(result, YAP_MkIntTerm(x.val()));
} }
static int gecode_boolvar_size(void) static YAP_Bool gecode_boolvar_size(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1282,7 +1282,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.size())); return YAP_Unify(result, YAP_MkIntTerm(x.size()));
} }
static int gecode_boolvar_width(void) static YAP_Bool gecode_boolvar_width(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1290,7 +1290,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.width())); return YAP_Unify(result, YAP_MkIntTerm(x.width()));
} }
static int gecode_boolvar_regret_min(void) static YAP_Bool gecode_boolvar_regret_min(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1298,7 +1298,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.regret_min())); return YAP_Unify(result, YAP_MkIntTerm(x.regret_min()));
} }
static int gecode_boolvar_regret_max(void) static YAP_Bool gecode_boolvar_regret_max(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1307,14 +1307,14 @@ extern "C"
} }
// INFO ON SETVARS // INFO ON SETVARS
static int gecode_setvar_assigned(void) static YAP_Bool gecode_setvar_assigned(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
SetVar x = gecode_SetVar_from_term(space, YAP_ARG2); SetVar x = gecode_SetVar_from_term(space, YAP_ARG2);
return (x.assigned()) ? TRUE : FALSE; return (x.assigned()) ? TRUE : FALSE;
} }
static int gecode_setvar_glbSize(void) static YAP_Bool gecode_setvar_glbSize(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1322,7 +1322,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.glbSize())); return YAP_Unify(result, YAP_MkIntTerm(x.glbSize()));
} }
static int gecode_setvar_lubSize(void) static YAP_Bool gecode_setvar_lubSize(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1330,7 +1330,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.lubSize())); return YAP_Unify(result, YAP_MkIntTerm(x.lubSize()));
} }
static int gecode_setvar_unknownSize(void) static YAP_Bool gecode_setvar_unknownSize(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1338,7 +1338,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.unknownSize())); return YAP_Unify(result, YAP_MkIntTerm(x.unknownSize()));
} }
static int gecode_setvar_cardMin(void) static YAP_Bool gecode_setvar_cardMin(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1346,7 +1346,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.cardMin())); return YAP_Unify(result, YAP_MkIntTerm(x.cardMin()));
} }
static int gecode_setvar_cardMax(void) static YAP_Bool gecode_setvar_cardMax(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1354,7 +1354,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.cardMax())); return YAP_Unify(result, YAP_MkIntTerm(x.cardMax()));
} }
static int gecode_setvar_lubMin(void) static YAP_Bool gecode_setvar_lubMin(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1362,7 +1362,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.lubMin())); return YAP_Unify(result, YAP_MkIntTerm(x.lubMin()));
} }
static int gecode_setvar_lubMax(void) static YAP_Bool gecode_setvar_lubMax(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1370,7 +1370,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.lubMax())); return YAP_Unify(result, YAP_MkIntTerm(x.lubMax()));
} }
static int gecode_setvar_glbMin(void) static YAP_Bool gecode_setvar_glbMin(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1378,7 +1378,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.glbMin())); return YAP_Unify(result, YAP_MkIntTerm(x.glbMin()));
} }
static int gecode_setvar_glbMax(void) static YAP_Bool gecode_setvar_glbMax(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1386,7 +1386,7 @@ extern "C"
return YAP_Unify(result, YAP_MkIntTerm(x.glbMax())); return YAP_Unify(result, YAP_MkIntTerm(x.glbMax()));
} }
static int gecode_setvar_glb_ranges(void) static YAP_Bool gecode_setvar_glb_ranges(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1409,7 +1409,7 @@ extern "C"
return YAP_Unify(result,lst); return YAP_Unify(result,lst);
} }
static int gecode_setvar_lub_ranges(void) static YAP_Bool gecode_setvar_lub_ranges(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1432,7 +1432,7 @@ extern "C"
return YAP_Unify(result,lst); return YAP_Unify(result,lst);
} }
static int gecode_setvar_unknown_ranges(void) static YAP_Bool gecode_setvar_unknown_ranges(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1455,7 +1455,7 @@ extern "C"
return YAP_Unify(result,lst); return YAP_Unify(result,lst);
} }
static int gecode_setvar_glb_values(void) static YAP_Bool gecode_setvar_glb_values(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1469,7 +1469,7 @@ extern "C"
return YAP_Unify(result,lst); return YAP_Unify(result,lst);
} }
static int gecode_setvar_lub_values(void) static YAP_Bool gecode_setvar_lub_values(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1483,7 +1483,7 @@ extern "C"
return YAP_Unify(result,lst); return YAP_Unify(result,lst);
} }
static int gecode_setvar_unknown_values(void) static YAP_Bool gecode_setvar_unknown_values(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1498,14 +1498,14 @@ extern "C"
} }
// INFO ON FLOATVARS // INFO ON FLOATVARS
static int gecode_floatvar_assigned(void) static YAP_Bool gecode_floatvar_assigned(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
FloatVar x = gecode_FloatVar_from_term(space, YAP_ARG2); FloatVar x = gecode_FloatVar_from_term(space, YAP_ARG2);
return (x.assigned()) ? TRUE : FALSE; return (x.assigned()) ? TRUE : FALSE;
} }
static int gecode_floatvar_min(void) static YAP_Bool gecode_floatvar_min(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1513,7 +1513,7 @@ extern "C"
return YAP_Unify(result, YAP_MkFloatTerm(x.min())); return YAP_Unify(result, YAP_MkFloatTerm(x.min()));
} }
static int gecode_floatvar_max(void) static YAP_Bool gecode_floatvar_max(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1521,7 +1521,7 @@ extern "C"
return YAP_Unify(result, YAP_MkFloatTerm(x.max())); return YAP_Unify(result, YAP_MkFloatTerm(x.max()));
} }
static int gecode_floatvar_med(void) static YAP_Bool gecode_floatvar_med(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1529,7 +1529,7 @@ extern "C"
return YAP_Unify(result, YAP_MkFloatTerm(x.med())); return YAP_Unify(result, YAP_MkFloatTerm(x.med()));
} }
static int gecode_floatvar_size(void) static YAP_Bool gecode_floatvar_size(void)
{ {
YAP_Term result = YAP_ARG1; YAP_Term result = YAP_ARG1;
GenericSpace* space = gecode_Space_from_term(YAP_ARG2); GenericSpace* space = gecode_Space_from_term(YAP_ARG2);
@ -1551,7 +1551,7 @@ extern "C"
static YAP_opaque_tag_t gecode_reify_tag; static YAP_opaque_tag_t gecode_reify_tag;
static YAP_opaque_handler_t gecode_reify_handler; static YAP_opaque_handler_t gecode_reify_handler;
static int static YAP_Bool
gecode_reify_write_handler gecode_reify_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -1570,7 +1570,7 @@ extern "C"
return term; return term;
} }
static int gecode_new_reify(void) static YAP_Bool gecode_new_reify(void)
{ {
GenericSpace* space = gecode_Space_from_term(YAP_ARG1); GenericSpace* space = gecode_Space_from_term(YAP_ARG1);
BoolVar b = gecode_BoolVar_from_term(space, YAP_ARG2); BoolVar b = gecode_BoolVar_from_term(space, YAP_ARG2);
@ -1584,12 +1584,12 @@ extern "C"
static YAP_opaque_tag_t gecode_tupleset_tag; static YAP_opaque_tag_t gecode_tupleset_tag;
static YAP_opaque_handler_t gecode_tupleset_handler; static YAP_opaque_handler_t gecode_tupleset_handler;
static int gecode_tupleset_fail_handler(void* p) static YAP_Bool gecode_tupleset_fail_handler(void* p)
{ {
return TRUE; return TRUE;
} }
static int static YAP_Bool
gecode_tupleset_write_handler gecode_tupleset_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -1598,7 +1598,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_new_tupleset(void) static YAP_Bool gecode_new_tupleset(void)
{ {
YAP_Term term = YAP_Term term =
YAP_NewOpaqueObject(gecode_tupleset_tag, sizeof(TupleSet)); YAP_NewOpaqueObject(gecode_tupleset_tag, sizeof(TupleSet));
@ -1633,12 +1633,12 @@ extern "C"
static YAP_opaque_tag_t gecode_dfa_tag; static YAP_opaque_tag_t gecode_dfa_tag;
static YAP_opaque_handler_t gecode_dfa_handler; static YAP_opaque_handler_t gecode_dfa_handler;
static int gecode_dfa_fail_handler(void* p) static YAP_Bool gecode_dfa_fail_handler(void* p)
{ {
return TRUE; return TRUE;
} }
static int static YAP_Bool
gecode_dfa_write_handler gecode_dfa_write_handler
(void *stream_, YAP_opaque_tag_t type, void *p, int flags) (void *stream_, YAP_opaque_tag_t type, void *p, int flags)
{ {
@ -1647,7 +1647,7 @@ extern "C"
return TRUE; return TRUE;
} }
static int gecode_new_dfa(void) static YAP_Bool gecode_new_dfa(void)
{ {
YAP_Term term = YAP_Term term =
YAP_NewOpaqueObject(gecode_dfa_tag, sizeof(DFA)); YAP_NewOpaqueObject(gecode_dfa_tag, sizeof(DFA));

View File

@ -16,7 +16,7 @@ set( MYDDAS_PROLOG
pl/myddas_top_level.ypp pl/myddas_top_level.ypp
pl/myddas_errors.ypp pl/myddas_errors.ypp
pl/myddas_prolog2sql.ypp pl/myddas_prolog2sql.ypp
pl/myddas_util_predicates.ypp pl/myddas_util_predicates.ypp
pl/myddas_prolog2sql_optimizer.ypp ) pl/myddas_prolog2sql_optimizer.ypp )
function(cpp_compile filename) function(cpp_compile filename)
@ -38,31 +38,46 @@ source_group(generated FILES ${GENERATED_SOURCES})
macro_optional_find_package(ODBC ON) macro_optional_find_package(ODBC ON)
macro_optional_find_package(MySQL ON) macro_optional_find_package(MySQL ON)
macro_optional_find_package(Sqlite3 ON)
if (ODBC_FOUND OR MYSQL_FOUND) if (ODBC_FOUND OR MYSQL_FOUND or SQLITE3_FOUND)
add_library (myddas SHARED ${MYDDAS_SOURCES}) add_library (myddas SHARED ${MYDDAS_SOURCES})
target_link_libraries(myddas libYap) target_link_libraries(myddas libYap)
if (ODBC_FOUND) if (ODBC_FOUND)
# ODBC_INCLUDE_DIRECTORIES, where to find sql.h # ODBC_INCLUDE_DIRECTORIES, where to find sql.h
# ODBC_LIBRARIES, the libraries to link against to use ODBC # ODBC_LIBRARIES, the libraries to link against to use ODBC
# ODBC_FOUND. If false, you cannot build anything that requires MySQL. # ODBC_FOUND. If false, you cannot build anything that requires MySQL.
macro_log_feature (ODBC_FOUND "ODBC" macro_log_feature (ODBC_FOUND "ODBC"
"Use ODBC Data-Base Interface " "Use ODBC Data-Base Interface "
"http://www.unixodbc.org" FALSE) "http://www.unixodbc.org" FALSE)
add_definitions (-DMYDDAS_ODBC=1) add_definitions (-DMYDDAS_ODBC=1)
target_link_libraries(myddas ${ODBC_LIBRARIES}) target_link_libraries(myddas ${ODBC_LIBRARIES})
include_directories (${ODBC_INCLUDE_DIRECTORIES}) include_directories (${ODBC_INCLUDE_DIRECTORIES})
endif (ODBC_FOUND) endif (ODBC_FOUND)
if (SQLITE3_FOUND)
# SQLITE3_INCLUDE_DIR - Where to find Sqlite 3 header files (directory)
# SQLITE3_LIBRARIES - Sqlite 3 libraries
# SQLITE3_LIBRARY_RELEASE - Where the release library is
# SQLITE3_LIBRARY_DEBUG - Where the debug library is
# SQLITE3_FOUND - Set to TRUE if we found everything (library, includes and executable)
macro_log_feature (SQLITE3_FOUND "SQLite3"
"SQL Light Data-Base "
"http://www.sqlite3.org" FALSE)
add_definitions (-DMYDDAS_SQLITE3=1)
target_link_libraries(myddas ${SQLITE3_LIBRARIES})
include_directories (${SQLITE3_INCLUDE_DIR})
endif (SQLITE3_FOUND)
if (MYSQL_FOUND) if (MYSQL_FOUND)
# MYSQL_INCLUDE_DIR - where to find mysql.h, etc. # MYSQL_INCLUDE_DIR - where to find mysql.h, etc.
# MYSQL_LIBRARIES - List of libraries when using MySQL. # MYSQL_LIBRARIES - List of libraries when using MySQL.
# MYSQL_FOUND - True if MySQL found. # MYSQL_FOUND - True if MySQL found.
macro_log_feature (MYSQL_FOUND "MySQL" macro_log_feature (MYSQL_FOUND "MySQL"
"Use MYSQL Data-Base Interface " "Use MYSQL Data-Base Interface "
"http://www.mysql.org" FALSE) "http://www.mysql.org" FALSE)
add_definitions (-DMYDDAS_MYSQL=1) add_definitions (-DMYDDAS_MYSQL=1)
target_link_libraries(myddas ${MYSQL_LIBRARIES}) target_link_libraries(myddas ${MYSQL_LIBRARIES})
include_directories (${MYSQL_INCLUDE_DIR}) include_directories (${MYSQL_INCLUDE_DIR})
endif (MYSQL_FOUND) endif (MYSQL_FOUND)
@ -78,4 +93,3 @@ cmake_dependent_option (WITH_MYDDAS_top_level
"enable the MYDDAS top-level support to MySQL" OFF "enable the MYDDAS top-level support to MySQL" OFF
'WITH_MYDDAS AND MYSQL_FOUND' OFF) 'WITH_MYDDAS AND MYSQL_FOUND' OFF)
#TODO: #TODO: