more Android fixes

merge trueFileName so that we don;t redo code
support rand48 and srand48
drop support for odbc and prolite, too much work.
This commit is contained in:
Vítor Santos Costa 2015-04-15 11:21:15 +01:00
parent b14dc43bc9
commit bf8beba466
25 changed files with 435 additions and 562 deletions

View File

@ -2196,8 +2196,7 @@ YAP_EnterGoal(PredEntry *pe, yhandle_t ptr, YAP_dogoalinfo *dgi)
Yap_PrepGoal(pe->ArityOfPE, Yap_AddressFromSlot( ptr ), B PASS_REGS);
P = pe->CodeOfPred;
__android_log_print(ANDROID_LOG_INFO, "YAP ", "ap=%p %d %x %x args=%x,%x slot=%d",
pe, pe->CodeOfPred->opc, FAILCODE, Deref(ARG1), Deref(ARG2), LOCAL_CurSlot);
// __android_log_print(ANDROID_LOG_INFO, "YAP ", "ap=%p %d %x %x args=%x,%x slot=%d", pe, pe->CodeOfPred->opc, FAILCODE, Deref(ARG1), Deref(ARG2), LOCAL_CurSlot);
dgi->b = LCL0-(CELL*)B;
out = run_emulator(PASS_REGS1);
RECOVER_MACHINE_REGS();
@ -2869,11 +2868,7 @@ construct_init_file(char *boot_file, char *BootFile)
/* this routine is supposed to be called from an external program
that wants to control Yap */
#if defined(USE_SYSTEM_MALLOC) && FALSE
#define BOOT_FROM_SAVED_STATE FALSE
#else
#define BOOT_FROM_SAVED_STATE TRUE
#endif
X_API Int
YAP_Init(YAP_init_args *yap_init)
@ -2898,14 +2893,19 @@ YAP_Init(YAP_init_args *yap_init)
Yap_InitSysbits(); /* init signal handling and time, required by later functions */
GLOBAL_argv = yap_init->Argv;
GLOBAL_argc = yap_init->Argc;
#if !BOOT_FROM_SAVED_STATE
#if BOOT_FROM_SAVED_STATE
if (!yap_init->SavedState) {
yap_init->SavedState = YAP_STARTUP;
}
#else
if (yap_init->SavedState) {
fprintf(stderr,"[ WARNING: threaded YAP will ignore saved state %s ]\n",yap_init->SavedState);
yap_init->SavedState = NULL;
}
#endif
if (FALSE && BOOT_FROM_SAVED_STATE && !do_bootstrap) {
if (Yap_SavedInfo (yap_init->SavedState, yap_init->YapLibDir, &Trail, &Stack, &Heap)) {
if (BOOT_FROM_SAVED_STATE && !do_bootstrap) {
if (!Yap_SavedInfo (yap_init->SavedState, yap_init->YapLibDir, &Trail, &Stack, &Heap)) {
yap_init->ErrorNo = LOCAL_Error_TYPE;
yap_init->ErrorCause = LOCAL_ErrorMessage;
return YAP_BOOT_ERROR;
@ -3055,10 +3055,12 @@ YAP_Init(YAP_init_args *yap_init)
if (restore_result == DO_ONLY_CODE) {
/* first, initialise the saved state */
Term t_goal = MkAtomTerm(AtomInitProlog);
YAP_RunGoalOnce(t_goal);
YAP_RunGoalOnce(t_goal);
Yap_InitYaamRegs( 0 );
CurrentModule = LOCAL_SourceModule = USER_MODULE;
return YAP_BOOT_FROM_SAVED_CODE;
} else {
CurrentModule = LOCAL_SourceModule = USER_MODULE;
return YAP_BOOT_FROM_SAVED_STACKS;
}
} else {

379
C/save.c
View File

@ -1,19 +1,19 @@
/*************************************************************************
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: save.c *
* Last rev: *
* mods: *
* comments: saving and restoring a Prolog computation *
* *
*************************************************************************/
* *
* YAP Prolog *
* *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: save.c *
* Last rev: *
* mods: *
* comments: saving and restoring a Prolog computation *
* *
*************************************************************************/
#ifdef SCCS
static char SccsId[] = "@(#)save.c 1.3 3/15/90";
#endif
@ -61,8 +61,6 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90";
/********* hack for accesing several kinds of terms. Should be cleaned **/
static char StartUpFile[] = "startup.yss";
static char end_msg[256] ="*** End of YAP saved state *****";
/* SWI IO, must be restarted after restore */
@ -71,7 +69,7 @@ void initIO(void);
#ifdef DEBUG
/*
*
*
#FOR DEBUGGING define DEBUG_RESTORE0 to check the file stuff,
#define DEBUG_RESTORE1 to see if it is able to prepare the chain,
#define DEBUG_RESTORE2 to see how things are going,
@ -80,11 +78,11 @@ void initIO(void);
* particular file,
* define DEBUG_RESTORE5 if you want to see how the stacks are being
* cleaned up,
* define DEBUG_RESTORE6 if you want to follow the execution in
* define DEBUG_RESTORE6 if you want to follow the execution in
*
* Also a file is defined where you can write things, by default stderr
* Also a file is defined where you can write things, by default stderr
*
* Good Luck
* Good Luck
*/
#endif
@ -152,12 +150,12 @@ extern int DefVol;
#include <unix.h>
#include <strings.h>
void
void
LightBug(char *);
static void
static void
LightBug(s)
char *s;
char *s;
{
}
@ -169,15 +167,15 @@ do_system_error(yap_error_number etype, const char *msg)
CACHE_REGS
#if HAVE_SNPRINTF
#if HAVE_STRERROR
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, strerror(errno), LOCAL_FileNameBuf);
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, strerror(errno), LOCAL_FileNameBuf);
#else
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
#endif
#else
#if HAVE_STRERROR
sprintf(LOCAL_ErrorSay,"%s, (%s when reading %s)",msg,strerror(errno),LOCAL_FileNameBuf);
#else
sprintf(LOCAL_ErrorSay,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
sprintf(LOCAL_ErrorSay,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
#endif
#endif
LOCAL_ErrorMessage = LOCAL_ErrorSay;
@ -274,7 +272,7 @@ open_file(char *my_file, int flag)
return splfild;
}
static int
static int
close_file(void)
{
if (splfild == 0)
@ -286,21 +284,21 @@ close_file(void)
}
/* stores a cell in a file */
static Int
static Int
putout(CELL l)
{
return mywrite(splfild, (char *) &l, sizeof(CELL));
}
/* stores a pointer to a cell in a file */
static Int
static Int
putcellptr(CELL *l)
{
return mywrite(splfild, (char *) &l, sizeof(CELLPOINTER));
}
/* gets a cell from a file */
static CELL
static CELL
get_cell(void)
{
CELL l;
@ -309,7 +307,7 @@ get_cell(void)
}
/* gets a cell from a file */
static CELL
static CELL
get_header_cell(void)
{
CELL l;
@ -338,9 +336,9 @@ get_cellptr(void)
/*
* writes the header (at the moment YAPV*), info about what kind of saved
* set, the work size, and the space ocuppied
* set, the work size, and the space ocuppied
*/
static int
static int
put_info(int info, int mode USES_REGS)
{
char msg[256];
@ -383,7 +381,7 @@ save_regs(int mode USES_REGS)
{
/* save all registers */
if (putout((CELL)compile_arrays) < 0)
return -1;
return -1;
if (mode == DO_EVERYTHING) {
if (putcellptr((CELL *)CP) < 0)
return -1;
@ -527,7 +525,7 @@ static int
save_stacks(int mode USES_REGS)
{
int j;
switch (mode) {
case DO_EVERYTHING:
/* Now, go and save the state */
@ -546,7 +544,7 @@ save_stacks(int mode USES_REGS)
break;
case DO_ONLY_CODE:
{
tr_fr_ptr tr_ptr = TR;
tr_fr_ptr tr_ptr = TR;
while (tr_ptr != (tr_fr_ptr)LOCAL_TrailBase) {
CELL val = TrailTerm(tr_ptr-1);
if (IsVarTerm(val)) {
@ -560,7 +558,7 @@ save_stacks(int mode USES_REGS)
if (d1 < (CELL *)HeapTop) {
if (putout(val) < 0)
return -1;
}
}
}
tr_ptr--;
}
@ -597,7 +595,7 @@ do_save(int mode USES_REGS) {
Yap_CloseStreams(TRUE);
if ((splfild = open_file(LOCAL_FileNameBuf, O_WRONLY | O_CREAT)) < 0) {
Yap_Error(SYSTEM_ERROR,MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)),
"restore/1, open(%s)", strerror(errno));
"restore/1, open(%s)", strerror(errno));
return(FALSE);
}
if (put_info(FullSaved, mode PASS_REGS) < 0)
@ -617,7 +615,7 @@ do_save(int mode USES_REGS) {
}
/* Saves a complete prolog environment */
static Int
static Int
p_save2( USES_REGS1 )
{
Int res;
@ -627,14 +625,14 @@ p_save2( USES_REGS1 )
#ifdef YAPOR
if (GLOBAL_number_workers != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running");
"cannot perform save: more than a worker/thread running");
return(FALSE);
}
#endif /* YAPOR */
#ifdef THREADS
if (GLOBAL_NOfThreads != 1) {
Yap_Error(SYSTEM_ERROR,TermNil,
"cannot perform save: more than a worker/thread running");
"cannot perform save: more than a worker/thread running");
return(FALSE);
}
#endif /* THREADS */
@ -651,7 +649,7 @@ p_save2( USES_REGS1 )
}
/* Just save the program, not the stacks */
static Int
static Int
p_save_program( USES_REGS1 )
{
which_save = 0;
@ -661,7 +659,7 @@ p_save_program( USES_REGS1 )
/* Now, to restore the saved code */
/* First check out if we are dealing with a valid file */
static int
static int
check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
{
char pp[256];
@ -702,32 +700,32 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
/* ignore info on saved state */
*info = get_header_cell();
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
return FAIL_RESTORE;
/* check the restore mode */
mode = get_header_cell();
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
return FAIL_RESTORE;
if (mode != DO_EVERYTHING && mode != DO_ONLY_CODE) {
return FAIL_RESTORE;
}
/* ignore info on stacks size */
*AHeap = get_header_cell();
if (LOCAL_ErrorMessage) {
return FAIL_RESTORE;
return FAIL_RESTORE;
}
*AStack = get_header_cell();
if (LOCAL_ErrorMessage) {
return FAIL_RESTORE;
return FAIL_RESTORE;
}
*ATrail = get_header_cell();
if (LOCAL_ErrorMessage) {
return FAIL_RESTORE;
return FAIL_RESTORE;
}
/* now, check whether we got enough enough space to load the
saved space */
hp_size = get_cell();
if (LOCAL_ErrorMessage)
return FAIL_RESTORE;
return FAIL_RESTORE;
while (Yap_HeapBase != NULL &&
hp_size > Unsigned(HeapLim) - Unsigned(Yap_HeapBase)) {
if(!Yap_growheap(FALSE, hp_size, NULL)) {
@ -767,40 +765,40 @@ check_header(CELL *info, CELL *ATrail, CELL *AStack, CELL *AHeap USES_REGS)
}
/* Gets the state of the heap, and evaluates the related variables */
static int
static int
get_heap_info(USES_REGS1)
{
LOCAL_OldHeapBase = (ADDR) get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
LOCAL_OldHeapTop = (ADDR) get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
OldHeapUsed = (Int) get_cell();
if (LOCAL_ErrorMessage)
return -1;
return -1;
FreeBlocks = (BlockHeader *) get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
AuxBase = (ADDR)get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
AuxSp = get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
AuxTop = (ADDR)get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
LOCAL_ScratchPad.ptr = (ADDR)get_cellptr();
if (LOCAL_ErrorMessage)
return -1;
return -1;
LOCAL_ScratchPad.sz = get_cell();
if (LOCAL_ErrorMessage)
return -1;
return -1;
LOCAL_ScratchPad.msz = get_cell();
if (LOCAL_ErrorMessage)
return -1;
return -1;
LOCAL_HDiff = Unsigned(Yap_HeapBase) - Unsigned(LOCAL_OldHeapBase);
return 1;
}
@ -808,7 +806,7 @@ get_heap_info(USES_REGS1)
/* Gets the register array */
/* Saves the old bases for the work areas */
/* and evaluates the difference from the old areas to the new ones */
static int
static int
get_regs(int flag USES_REGS)
{
CELL *NewGlobalBase = (CELL *)LOCAL_GlobalBase;
@ -818,7 +816,7 @@ get_regs(int flag USES_REGS)
/* Get regs */
compile_arrays = (int)get_cell();
if (LOCAL_ErrorMessage)
return -1;
return -1;
if (flag == DO_EVERYTHING) {
CP = (yamop *)get_cellptr();
if (LOCAL_ErrorMessage)
@ -879,8 +877,8 @@ get_regs(int flag USES_REGS)
#endif /* YAPOR_SBA || TABLING */
}
CurrentModule = get_cell();
if (LOCAL_ErrorMessage)
return -1;
if (LOCAL_ErrorMessage)
return -1;
if (flag == DO_EVERYTHING) {
#ifdef COROUTINING
LOCAL_WokenGoals = get_cell();
@ -944,21 +942,21 @@ get_regs(int flag USES_REGS)
}
/* Get the old opcodes and place them in a hash table */
static int
static int
get_insts(OPCODE old_ops[])
{
return myread(splfild, (char *)old_ops, sizeof(OPCODE)*(_std_top+1));
}
/* Get the old atoms hash table */
static int
static int
get_hash(void)
{
return myread(splfild, Yap_chtype , NUMBER_OF_CHARS);
}
/* Copy all of the old code to the new Heap */
static int
static int
CopyCode( USES_REGS1 )
{
if (myread(splfild, (char *) Yap_HeapBase, (Unsigned(LOCAL_OldHeapTop) - Unsigned(LOCAL_OldHeapBase))) < 0) {
@ -969,7 +967,7 @@ CopyCode( USES_REGS1 )
/* Copy the local and global stack and also the trail to their new home */
/* In REGS we still have nonadjusted values !! */
static int
static int
CopyStacks( USES_REGS1 )
{
Int j;
@ -1005,11 +1003,11 @@ CopyTrailEntries( USES_REGS1 )
}
/* get things which are saved in the file */
static int
static int
get_coded(int flag, OPCODE old_ops[] USES_REGS)
{
char my_end_msg[256];
if (get_regs(flag PASS_REGS) < 0)
return -1;
if (get_insts(old_ops) < 0)
@ -1039,7 +1037,7 @@ get_coded(int flag, OPCODE old_ops[] USES_REGS)
}
/* restore some heap registers */
static void
static void
restore_heap_regs( USES_REGS1 )
{
if (HeapTop) {
@ -1051,7 +1049,7 @@ restore_heap_regs( USES_REGS1 )
}
/* adjust abstract machine registers */
static void
static void
restore_regs(int flag USES_REGS)
{
restore_heap_regs( PASS_REGS1 );
@ -1099,7 +1097,7 @@ recompute_mask(DBRef dbr)
tp = (CELL *)(tbase + (CELL) RepPair(dbr->DBT.Entry));
} else {
Functor f;
tp = (CELL *)(tbase + (CELL) RepAppl(dbr->DBT.Entry));
f = (Functor)(*tp++);
out = AbsAppl(x);
@ -1136,9 +1134,9 @@ recompute_mask(DBRef dbr)
* This is used to make an hash table correct, after displacing its elements,
* HCEnd should point to an area of free space, usually in the heap. The
* routine is very dependent on the hash function used, and it destroys the
* previous "hit" order
* previous "hit" order
*/
static void
static void
rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS)
{
register CELL *savep, *basep;
@ -1150,14 +1148,14 @@ rehash(CELL *oldcode, int NOfE, int KindOfEntries USES_REGS)
CELL *Base = oldcode;
if (LOCAL_HDiff == 0)
return;
return;
basep = HR;
if (HR + (NOfE*2) > ASP) {
basep = (CELL *)TR;
if (basep + (NOfE*2) > (CELL *)LOCAL_TrailTop) {
if (!Yap_growtrail((ADDR)(basep + (NOfE*2))-LOCAL_TrailTop, TRUE)) {
Yap_Error(OUT_OF_TRAIL_ERROR, TermNil,
"not enough space to restore hash tables for indexing");
"not enough space to restore hash tables for indexing");
Yap_exit(1);
}
}
@ -1215,13 +1213,13 @@ RestoreSWIHash(void)
#include "rheap.h"
/* restore the atom entries which are invisible for the user */
static void
static void
RestoreIOStructures(void)
{
Yap_InitStdStreams();
}
static void
static void
RestoreFreeSpace( USES_REGS1 )
{
#if USE_DL_MALLOC
@ -1254,11 +1252,11 @@ RestoreFreeSpace( USES_REGS1 )
if (bpt->b_next != NULL) {
bsz = bpt->b_next = BlockAdjust(bpt->b_next);
while (bsz != NULL) {
if (bsz->b_next_size != NULL)
if (bsz->b_next_size != NULL)
bsz->b_next_size = BlockAdjust(bsz->b_next_size);
if (bsz->b_next != NULL)
if (bsz->b_next != NULL)
bsz->b_next = BlockAdjust(bsz->b_next);
bsz = bsz->b_next;
bsz = bsz->b_next;
}
}
if (bpt->b_next_size != NULL)
@ -1296,9 +1294,9 @@ RestoreHashPreds( USES_REGS1 )
np = (PredEntry **) Yap_AllocAtomSpace(sizeof(PredEntry *)*size);
if (!np) {
if (!(np = (PredEntry **) malloc(sizeof(PredEntry *)*size))) {
Yap_Error(FATAL_ERROR,TermNil,"Could not allocate space for pred table");
return;
}
Yap_Error(FATAL_ERROR,TermNil,"Could not allocate space for pred table");
return;
}
malloced = TRUE;
}
for (i = 0; i < size; i++) {
@ -1312,7 +1310,7 @@ RestoreHashPreds( USES_REGS1 )
while (p) {
Prop nextp;
UInt hsh;
if (p->NextOfPE)
p->NextOfPE = PropAdjust(p->NextOfPE);
nextp = p->NextOfPE;
@ -1333,9 +1331,9 @@ RestoreHashPreds( USES_REGS1 )
}
/*
* This is the really tough part, to restore the whole of the heap
* This is the really tough part, to restore the whole of the heap
*/
static void
static void
restore_heap(void)
{
restore_codes();
@ -1344,9 +1342,9 @@ restore_heap(void)
#ifdef DEBUG_RESTORE3
static void
static void
ShowEntries(pp)
PropEntry *pp;
PropEntry *pp;
{
while (!EndOfPAEntr(pp)) {
fprintf(GLOBAL_stderr,"Estou a ver a prop %x em %x\n", pp->KindOfPE, pp);
@ -1354,7 +1352,7 @@ ShowEntries(pp)
}
}
static void
static void
ShowAtoms()
{
AtomHashEntry *HashPtr = HashChain;
@ -1390,8 +1388,8 @@ ShowAtoms()
static int
commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) {
CACHE_REGS
int mode;
CACHE_REGS
int mode;
if ((mode = check_header(Astate,ATrail,AStack,AHeap PASS_REGS)) == FAIL_RESTORE)
return(FAIL_RESTORE);
@ -1407,26 +1405,14 @@ commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *A
}
#ifdef DEBUG_RESTORE4
/*
* This should be another file, like the log file
* This should be another file, like the log file
*/
errout = GLOBAL_stderr;
#endif
return mode;
}
static void
cat_file_name(char *s, const char *prefix, char *name, unsigned int max_length)
{
strncpy(s, prefix, max_length);
#if _MSC_VER || defined(__MINGW32__)
strncat(s,"\\", max_length);
#else
strncat(s,"/", max_length);
#endif
strncat(s, name, max_length-1);
}
static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, char *buf, IOSTREAM **streamp) {
static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, IOSTREAM **streamp) {
int mode;
if (streamp) {
@ -1438,153 +1424,40 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
if ((splfild = open_file(inpf, O_RDONLY)) < 0) {
return FAIL_RESTORE;
}
if (buf[0] == '\0')
strncpy(buf, inpf, YAP_FILENAME_MAX);
if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) {
CACHE_REGS
LOCAL_ErrorMessage = NULL;
LOCAL_ErrorMessage = NULL;
return mode;
}
return mode;
}
static int
static int
OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, IOSTREAM **streamp)
{
CACHE_REGS
int mode = FAIL_RESTORE;
char save_buffer[YAP_FILENAME_MAX+1];
#if __ANDROID__
if (!inpf)
inpf = YAPSTARTUP;
#endif
save_buffer[0] = '\0';
// LOCAL_ErrorMessage = NULL;
if (inpf == NULL) {
inpf = StartUpFile;
int mode;
char fname[PATH_MAX+1];
if (!Yap_trueFileName( inpf, YAP_STARTUP, YapLibDir, fname, true, YAP_SAVED_STATE, true, true))
return false;
if (fname != NULL &&
(mode = try_open(fname,Astate,ATrail,AStack,AHeap,streamp)) != FAIL_RESTORE) {
return mode;
}
/* careful it starts from the root */
if (inpf[0] != '/') {
#if __simplescalar__
/* does not implement getcwd */
strncpy(LOCAL_FileNameBuf,GLOBAL_pwd,YAP_FILENAME_MAX);
#elif HAVE_GETCWD
if (getcwd (LOCAL_FileNameBuf, YAP_FILENAME_MAX) == NULL)
LOCAL_FileNameBuf[0] = '\0';
#else
if (getwd (LOCAL_FileNameBuf) == NULL)
LOCAL_FileNameBuf[0] = '\0';
#endif
strncat(LOCAL_FileNameBuf, "/", YAP_FILENAME_MAX-1);
strncat(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
} else {
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
}
if (inpf != NULL &&
!((splfild = open_file(inpf, O_RDONLY)) < 0))
{
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
}
if (!Yap_dir_separator(inpf[0]) && !Yap_volume_header(inpf)) {
/*
we have a relative path for the file, try to do somewhat better
using YAPLIBDIR or friends.
*/
if (YapLibDir != NULL) {
cat_file_name(LOCAL_FileNameBuf, Yap_LibDir, inpf, YAP_FILENAME_MAX);
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
} else {
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
}
#if HAVE_GETENV
{
const char *yap_env = getenv("YAPLIBDIR");
if (yap_env != NULL) {
cat_file_name(LOCAL_FileNameBuf, yap_env, inpf, YAP_FILENAME_MAX);
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
}
}
#endif
if (YAP_LIBDIR != NULL) {
cat_file_name(LOCAL_FileNameBuf, YAP_LIBDIR, inpf, YAP_FILENAME_MAX);
if (!((splfild = open_file(LOCAL_FileNameBuf, O_RDONLY)) < 0)) {
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
}
}
}
#if __WINDOWS__
if ((inpf = Yap_RegistryGetString("startup"))) {
if (!((splfild = Sopen_file(inpf, "r")) < 0)) {
if ((mode = try_open(inpf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
}
}
{
DWORD fatts;
int buflen;
char *pt;
/* try to get it from current executable */
if ((fatts = GetFileAttributes(LOCAL_FileNameBuf)) == 0xFFFFFFFFL ||
!(fatts & FILE_ATTRIBUTE_DIRECTORY)) {
/* couldn't find it where it was supposed to be,
let's try using the executable */
if (!GetModuleFileName( NULL, LOCAL_FileNameBuf, YAP_FILENAME_MAX)) {
/* do nothing */
goto end;
}
buflen = strlen(LOCAL_FileNameBuf);
pt = LOCAL_FileNameBuf+buflen;
while (*--pt != '\\') {
/* skip executable */
if (pt == LOCAL_FileNameBuf) {
/* do nothing */
goto end;
}
}
while (*--pt != '\\') {
/* skip parent directory "bin\\" */
if (pt == LOCAL_FileNameBuf) {
goto end;
}
}
/* now, this is a possible location for the ROOT_DIR, let's look for a share directory here */
pt[1] = '\0';
strncat(LOCAL_FileNameBuf,"lib/Yap/startup.yss",YAP_FILENAME_MAX);
}
if ((mode = try_open(LOCAL_FileNameBuf,Astate,ATrail,AStack,AHeap,save_buffer,streamp)) != FAIL_RESTORE) {
return mode;
}
}
end:
#endif
/* try to open from current directory */
/* could not open file */
if (LOCAL_ErrorMessage == NULL) {
if (save_buffer[0]) {
strncpy(LOCAL_FileNameBuf, save_buffer, YAP_FILENAME_MAX-1);
do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state");
} else {
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"could not open saved state");
}
do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state");
} else {
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1);
do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"could not open saved state");
}
return FAIL_RESTORE;
}
IOSTREAM *
IOSTREAM *
Yap_OpenRestore(char *inpf, char *YapLibDir)
{
IOSTREAM *stream = NULL;
@ -1593,19 +1466,19 @@ Yap_OpenRestore(char *inpf, char *YapLibDir)
return stream;
}
static void
static void
CloseRestore(void)
{
CACHE_REGS
CACHE_REGS
#ifdef DEBUG_RESTORE3
ShowAtoms();
ShowAtoms();
#endif
close_file();
LOCAL_PrologMode = UserMode;
}
#if !defined(_WIN32)
static int
static int
check_opcodes(OPCODE old_ops[])
{
#if USE_THREADED_CODE
@ -1625,17 +1498,17 @@ check_opcodes(OPCODE old_ops[])
}
#endif
static void
static void
RestoreHeap(OPCODE old_ops[] USES_REGS)
{
bool heap_moved = (LOCAL_OldHeapBase != Yap_HeapBase ||
LOCAL_XDiff), opcodes_moved;
LOCAL_XDiff), opcodes_moved;
Term mod = CurrentModule;
CurrentModule = PROLOG_MODULE;
#if defined(_WIN32)
/* It seems that under WIN32 opcodes may not have moved but the
remaining code may have bmoved */
remaining code may have bmoved */
opcodes_moved = TRUE;
#else
opcodes_moved = check_opcodes(old_ops);
@ -1667,9 +1540,9 @@ RestoreHeap(OPCODE old_ops[] USES_REGS)
/*
* This function is called to know about the parameters of the last saved
* state
* state
*/
int
int
Yap_SavedInfo(char *FileName, char *YapLibDir, CELL *ATrail, CELL *AStack, CELL *AHeap)
{
return DO_ONLY_CODE;
@ -1758,9 +1631,9 @@ FreeRecords(void) {
/*
* This function is called when wanting only to restore the heap and
* associated registers
* associated registers
*/
static int
static int
Restore(char *s, char *lib_dir USES_REGS)
{
int restore_mode;
@ -1773,7 +1646,7 @@ Restore(char *s, char *lib_dir USES_REGS)
Yap_ShutdownLoadForeign();
in_limbo = TRUE;
if (get_coded(restore_mode, old_ops PASS_REGS) < 0)
return FAIL_RESTORE;
return FAIL_RESTORE;
restore_regs(restore_mode PASS_REGS);
in_limbo = FALSE;
/*#endif*/
@ -1820,14 +1693,14 @@ Restore(char *s, char *lib_dir USES_REGS)
return restore_mode;
}
int
int
Yap_SavedStateRestore(char *s, char *lib_dir)
{
CACHE_REGS
return Restore(s, lib_dir PASS_REGS);
return Restore(s, lib_dir PASS_REGS);
}
static Int
static Int
p_restore( USES_REGS1 )
{
int mode;
@ -1856,7 +1729,7 @@ p_restore( USES_REGS1 )
return(mode != FAIL_RESTORE);
}
void
void
Yap_InitSavePreds(void)
{
Yap_InitCPred("$save", 2, p_save2, SyncPredFlag);

View File

@ -171,9 +171,6 @@ AAssetManager * Yap_assetManager;
void *
Yap_openAssetFile( const char *path ) {
AAssetDir *d;
LOG("openA %s %p", path, path);
const char * p = path+8;
AAsset* asset = AAssetManager_open(Yap_assetManager, p, AASSET_MODE_UNKNOWN);
return asset;
@ -182,6 +179,8 @@ Yap_openAssetFile( const char *path ) {
bool
Yap_isAsset( const char *path )
{
if (Yap_assetManager == NULL)
return false;
return path[0] == '/'&&
path[1] == 'a'&&
path[2] == 's'&&
@ -197,12 +196,13 @@ Yap_AccessAsset( const char *name, int mode )
{
AAssetManager* mgr = Yap_assetManager;
const char *bufp=name+7;
if (bufp[0] == '/')
bufp++;
bufp++;
if ((mode & W_OK) == W_OK) {
return false;
}
// check if file is a directory.
// directory works if file exists
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) {
AAssetDir_close(assetDir);
@ -327,7 +327,7 @@ exists( const char *f)
return has_access( f, F_OK );
}
static int
static int
dir_separator (int ch)
{
#ifdef MAC
@ -1690,9 +1690,11 @@ static void
InitRandom (void)
{
current_seed = (unsigned int) time (NULL);
#if HAVE_RANDOM
#if HAVE_SRAND48
srand48 (current_seed);
#elif HAVE_SRANDOM
srandom (current_seed);
#elif HAVE_RAND
#elif HAVE_SRAND
srand (current_seed);
#endif
}
@ -1703,8 +1705,10 @@ extern int rand(void);
double
Yap_random (void)
{
#if HAVE_RANDOM
/* extern long random (); */
#if HAVE_DRAND48
return drand48();
#elif HAVE_RANDOM
/* extern long random (); */
return (((double) random ()) / 0x7fffffffL /* 2**31-1 */);
#elif HAVE_RAND
return (((double) (rand ()) / RAND_MAX));
@ -1790,9 +1794,11 @@ p_srandom ( USES_REGS1 )
current_seed = (unsigned int) FloatOfTerm (t0);
else
current_seed = (unsigned int) LongIntOfTerm (t0);
#if HAVE_RANDOM
srandom(current_seed);
#elif HAVE_RAND
#if HAVE_SRAND48
srand48(current_seed);
#elif HAVE_SRANDOM
srandom(current_seed);
#elif HAVE_SRAND
srand(current_seed);
#endif
@ -2365,52 +2371,144 @@ Yap_volume_header(char *file)
}
}
static bool
TrueFileName (char *isource, char *root, char *result, int in_lib, int expand_root)
/** Yap_trueFileName: tries to generate the true name of file
*
*
* @param isource the proper file
* @param idef the default name fo rthe file, ie, startup.yss
* @param root the prefix
* @param result the output
* @param access verify whether the file has access permission
* @param ftype saved state, object, saved file, prolog file
* @param expand_root expand $ ~, etc
* @param in_lib library file
*
* @return
*/
bool
Yap_trueFileName (const char *isource, const char * idef, const char *iroot, char *result, bool access, file_type_t ftype, bool expand_root, bool in_lib)
{
CACHE_REGS
char save_buffer[YAP_FILENAME_MAX+1];
const char *root, *source = isource;
int rc = FAIL_RESTORE;
int try = 0;
char *work;
const char *source = isource;
// expand names in case you have
// to add a prefix
if (!expand_root)
root = NULL;
if (exists((work = expandWithPrefix( source, root, result ))))
return true; // done
if (in_lib) {
if (Yap_LibDir != NULL) {
strncpy(LOCAL_FileNameBuf, Yap_LibDir, YAP_FILENAME_MAX);
}
while ( rc == FAIL_RESTORE) {
bool done = false;
// { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "try=%d %s %s", try, isource, iroot) ; }
switch (try++) {
case 0: // path or file name is given;
root = iroot;
if (iroot || isource) {
source = ( isource ? isource : idef ) ;
} else {
done = true;
}
break;
case 1: // library directory is given in command line
if ( in_lib && ftype == YAP_SAVED_STATE) {
root = iroot;
source = ( isource ? isource : idef ) ;
} else
done = true;
break;
case 2: // use environment variable YAPLIBDIR
#if HAVE_GETENV
{
char *yap_env = getenv("YAPLIBDIR");
if (yap_env && exists((work = expandWithPrefix( source, yap_env, result ))))
return true; // done
}
if ( in_lib) {
if (ftype == YAP_SAVED_STATE || ftype == YAP_OBJ) {
root = getenv("YAPLIBDIR");
} else {
root = getenv("YAPSHAREDIR");
}
source = ( isource ? isource : idef ) ;
} else
done = true;
break;
#else
done = true;
#endif
break;
case 3: // use compilation variable YAPLIBDIR
if ( in_lib) {
source = ( isource ? isource : idef ) ;
if (ftype == YAP_PL || ftype == YAP_QLY) {
root = YAP_SHAREDIR;
} else {
root = YAP_LIBDIR;
}
} else
done = true;
break;
case 4: // WIN stuff: registry
#if __WINDOWS__
{
if (Yap_LibDir &&
exists((work = expandWithPrefix( source, Yap_LibDir, result ))))
return true; // done
}
if ( in_lib) {
source = ( ftype == YAP_PL || ftype == YAP_QLY ? "library" : "startup" ) ;
source = Yap_RegistryGetString( source );
root = NULL;
} else
#endif
if (YAP_LIBDIR &&
exists((work = expandWithPrefix( source, YAP_LIBDIR, result ))))
return true; // done
done = true;
break;
case 5: // search from the binary
{
#ifndef __ANDROID__
done = true;
break;
#endif
const char *pt = Yap_FindExecutable();
if (pt) {
source = ( ftype == YAP_SAVED_STATE || ftype == YAP_OBJ ? "../../lib/Yap" : "../../share/Yap" ) ;
if (Yap_trueFileName(source, NULL, pt, save_buffer, access, ftype, expand_root, in_lib) )
root = save_buffer;
else
done = true;
} else {
done = true;
}
source = ( isource ? isource : idef ) ;
}
break;
case 6: // default, try current directory
if (!isource && ftype == YAP_SAVED_STATE)
source = idef;
root = NULL;
break;
default:
return false;
}
if (done)
continue;
if (expand_root && root) {
root = expandWithPrefix( root, NULL, save_buffer );
}
// { CACHE_REGS __android_log_print(ANDROID_LOG_ERROR, __FUNCTION__, "root= %s %s ", root, source) ; }
char *work = expandWithPrefix( source, root, result );
// expand names in case you have
// to add a prefix
if ( !access || exists( work ) )
return true; // done
}
return false;
}
int
Yap_TrueFileName (char *source, char *result, int in_lib)
Yap_TrueFileName (const char *source, char *result, int in_lib)
{
return TrueFileName (source, NULL, result, in_lib, TRUE);
return Yap_trueFileName (source, NULL, NULL, result, true, YAP_PL, true, in_lib);
}
int
Yap_TruePrefixedFileName (const char *source, const char *root, char *result, int in_lib)
{
return Yap_trueFileName (source, NULL, root, result, true, YAP_PL, true, in_lib);
}
static Int
p_true_file_name ( USES_REGS1 )
{
@ -2424,7 +2522,8 @@ p_true_file_name ( USES_REGS1 )
Yap_Error(TYPE_ERROR_ATOM,t,"argument to true_file_name");
return FALSE;
}
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, LOCAL_FileNameBuf, FALSE, TRUE);
if (!Yap_trueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, NULL, LOCAL_FileNameBuf, true, YAP_PL, false, false))
return FALSE;
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
@ -2441,7 +2540,8 @@ p_expand_file_name ( USES_REGS1 )
Yap_Error(TYPE_ERROR_ATOM,t,"argument to true_file_name");
return FALSE;
}
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, LOCAL_FileNameBuf, FALSE, FALSE);
if (!Yap_trueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, NULL, LOCAL_FileNameBuf, true, YAP_PL, true, false))
return false;
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
@ -2466,7 +2566,8 @@ p_true_file_name3 ( USES_REGS1 )
}
root = RepAtom(AtomOfTerm(t2))->StrOfAE;
}
TrueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, root, LOCAL_FileNameBuf, FALSE, FALSE);
if (!Yap_trueFileName (RepAtom(AtomOfTerm(t))->StrOfAE, NULL, root, LOCAL_FileNameBuf, true, YAP_PL, false, false))
return FALSE;
return Yap_unify(ARG3, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
}
@ -2683,7 +2784,7 @@ p_system ( USES_REGS1 )
/* Rename a file */
/** @pred rename(+ _F_,+ _G_)
Renames file _F_ to _G_.
Renames file _F_ to _G_.
*/
static Int
p_mv ( USES_REGS1 )
@ -2703,8 +2804,10 @@ p_mv ( USES_REGS1 )
} else if (!IsAtomTerm(t2)) {
Yap_Error(TYPE_ERROR_ATOM, t2, "second argument to rename/2 not atom");
}
TrueFileName (RepAtom(AtomOfTerm(t1))->StrOfAE, NULL, oldname, FALSE, TRUE);
TrueFileName (RepAtom(AtomOfTerm(t2))->StrOfAE, NULL, newname, FALSE, TRUE);
if (!Yap_trueFileName (RepAtom(AtomOfTerm(t1))->StrOfAE, NULL, NULL, oldname, true, YAP_STD, true, false))
return FALSE;
if (!Yap_trueFileName (RepAtom(AtomOfTerm(t2))->StrOfAE, NULL, NULL, oldname, true, YAP_STD, true, false))
return FALSE;
if ((r = link (oldname, newname)) == 0 && (r = unlink (oldname)) != 0)
unlink (newname);
if (r != 0) {

View File

@ -144,7 +144,7 @@ low_level_trace(yap_low_level_port port, PredEntry *pred, CELL *args)
Int arity;
/* extern int gc_calls; */
vsc_count++;
#if __ANDROID__
#if __ANDROID__ && 0
PredEntry *ap = pred;
if (pred && port == enter_pred) {
UInt flags = ap->PredFlags;

View File

@ -21,15 +21,6 @@ class YAPError;
class YAPModule;
extern "C" {
static inline Term
Yap_CurrentModule( void )
{
CACHE_REGS
return CurrentModule;
}
}
/**
* @brief YAPModule
* A YAPModule describes a bare module, which in YAP is just a name.
@ -41,9 +32,10 @@ class YAPModule : protected YAPAtomTerm {
friend class YAPPredicate;
YAPModule( Term t ): YAPAtomTerm( t ) {};
Term t() { return gt(); }
Term curModule() {CACHE_REGS return Yap_CurrentModule(); }
public:
~YAPModule( ) {};
YAPModule( ): YAPAtomTerm( Yap_CurrentModule() ) {};
YAPModule( ): YAPAtomTerm( curModule() ) {};
YAPModule( YAPAtom t ): YAPAtomTerm( t ) {};
};
@ -59,7 +51,7 @@ class YAPModuleProp: public YAPProp {
YAPModuleProp(ModEntry *mod) {m = mod;};
YAPModuleProp(Term tmod) { m = Yap_GetModuleEntry(tmod); };
public:
YAPModuleProp() { m = Yap_GetModuleEntry(Yap_CurrentModule()); };
YAPModuleProp() { CACHE_REGS m = Yap_GetModuleEntry(Yap_CurrentModule()); };
YAPModuleProp(YAPModule tmod) ;
virtual YAPModule module() { return YAPModule(m->AtomOfME); };
};
@ -129,13 +121,9 @@ protected:
CACHE_REGS
BACKUP_MACHINE_REGS();
Term *outp;
char ns[strlen(s)+1];
memcpy(ns, s, strlen(s)+1);
LOG("iPP=%d %d %d", strlen(s), s[0], s[1]);
LOG("iPP=%s", s);
vnames = Yap_NewSlots(1);
out = Yap_StringToTerm(ns, strlen(s)+1, vnames ) ;
LOG("iP2=%s", s);
vnames = Yap_NewSlots(1);
out = Yap_StringToTerm(s, strlen(s)+1, vnames ) ;
//extern char *s0;
//fprintf(stderr,"ap=%p arity=%d text=%s", ap, ap->ArityOfPE, s);
// Yap_DebugPlWrite(out);
@ -169,6 +157,7 @@ public:
///
/// Asssumes that we use the current module.
YAPPredicate(YAPFunctor f) {
CACHE_REGS
ap = RepPredProp(PredPropByFunc(f.f,Yap_CurrentModule()));
};

View File

@ -401,14 +401,10 @@ YAPQuery::initQuery( Term t )
{
CACHE_REGS
BACKUP_MACHINE_REGS();
size_t arity = ap->ArityOfPE;
LOG("iQ=%d", arity);
arity_t arity = ap->ArityOfPE;
goal = YAPTerm( t );
if (arity) {
q_g = Yap_NewSlots( arity );
for (size_t i=0; i < arity; i++) {
Yap_PutInSlot(q_g+i, ArgOfTerm(i+1, t) PASS_REGS);
}
q_g = Yap_InitSlots( arity, RepAppl(t) + 1);
} else {
q_g = 0;
}
@ -424,7 +420,7 @@ YAPQuery::initQuery( YAPTerm ts[], arity_t arity )
BACKUP_MACHINE_REGS();
if (arity) {
q_g = Yap_NewSlots( arity );
for (size_t i=0; i < arity; i++) {
for (arity_t i=0; i < arity; i++) {
Yap_PutInSlot(q_g+i, ts[i].term() PASS_REGS);
}
Term t = Yap_MkApplTerm(ap->FunctorOfPred, ap->ArityOfPE, Yap_AddressFromSlot(q_g));
@ -612,48 +608,49 @@ YAPEngine::YAPEngine( char *savedState,
delYAPCallback();
if (cb) setYAPCallback(cb);
curren = this;
YAP_Init( &init_args );
if (YAP_Init( &init_args ) == YAP_BOOT_ERROR)
throw(YAPError::YAP_OTHER_ERROR);
}
YAPPredicate::YAPPredicate(YAPAtom at) {
CACHE_REGS
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
ap = RepPredProp(PredPropByAtom(at.a,Yap_CurrentModule()));
}
YAPPredicate::YAPPredicate(YAPAtom at, arity_t arity) {
CACHE_REGS
if (arity) {
Functor f = Yap_MkFunctor(at.a, arity);
ap = RepPredProp(PredPropByFunc(f,CurrentModule));
ap = RepPredProp(PredPropByFunc(f,Yap_CurrentModule()));
} else {
ap = RepPredProp(PredPropByAtom(at.a,CurrentModule));
ap = RepPredProp(PredPropByAtom(at.a,Yap_CurrentModule()));
}
}
/// auxiliary routine to find a predicate in the current module.
PredEntry *YAPPredicate::getPred( Term &t, Term* &outp ) {
CACHE_REGS
Term m = CurrentModule ;
Term m = Yap_CurrentModule() ;
t = Yap_StripModule(t, &m);
if (IsVarTerm(t) || IsNumTerm(t)) {
ap = (PredEntry *)NULL;
outp = (Term *)NULL;
return ap;
throw YAPError::YAP_TYPE_ERROR;
}
if (IsAtomTerm(t)) {
ap = RepPredProp(PredPropByAtom(AtomOfTerm(t), m));
outp = (Term *)NULL;
return ap;
} else if (IsPairTerm(t)) {
Term ts[1];
Term ts[2];
ts[0] = t;
t = Yap_MkApplTerm(FunctorCsult, 1, ts);
ts[1] = m;
t = Yap_MkApplTerm(FunctorCsult, 2, ts);
Yap_DebugPlWrite(m);
Yap_DebugPlWrite(t);
}
Functor f = FunctorOfTerm(t);
if (IsExtensionFunctor(f)) {
ap = (PredEntry *)NULL;
outp = (Term *)NULL;
throw YAPError::YAP_TYPE_ERROR;
} else {
ap = RepPredProp(PredPropByFunc(f, m));
outp = RepAppl(t)+1;
@ -737,7 +734,7 @@ void *YAPPrologPredicate::assertClause( YAPTerm clause, bool last, YAPTerm sourc
RECOVER_MACHINE_REGS();
Term tt = clause.gt();
Term sourcet = source.gt();
yamop *codeaddr = Yap_cclause(tt, PP->ArityOfPE, CurrentModule, sourcet); /* vsc: give the number of arguments
yamop *codeaddr = Yap_cclause(tt, PP->ArityOfPE, Yap_CurrentModule(), sourcet); /* vsc: give the number of arguments
to cclause in case there is overflow */
Term ntt = clause.gt();
if (LOCAL_ErrorMessage) {
@ -745,7 +742,7 @@ void *YAPPrologPredicate::assertClause( YAPTerm clause, bool last, YAPTerm sourc
return 0;
}
Term *tref = &ntt;
if (Yap_addclause(ntt, codeaddr, (last ? 0 : 2), CurrentModule, tref)) {
if (Yap_addclause(ntt, codeaddr, (last ? 0 : 2), Yap_CurrentModule(), tref)) {
RECOVER_MACHINE_REGS();
}
return tref;

View File

@ -5,8 +5,6 @@
Queries and engines
*/
static const char *s0;
/**
* @brief Queries
*
@ -116,8 +114,7 @@ public:
YAPError hasError( ) { return yerror; }
/// build a query on the engine
YAPQuery *query( const char *s ) {
s0=s;
return new YAPQuery( s );
return new YAPQuery( s );
};
/// current module for the engine
YAPModule currentModule( ) { return YAPModule( ) ; }

19
H/Yap.h
View File

@ -878,17 +878,22 @@ LOG0(const char *f, int l, const char *fmt, ...)
vfprintf(stderr, fmt, ap);
va_end(ap);
}
#else
#define LOG0( ... )
#endif
#ifndef __ANDROID__
#define __android_log_print( ... )
#endif
#define LOG( ... ) LOG0( __FILE__, __LINE__, __VA_ARGS__ )
#define REGS_LOG( ... ) CACHE_REGS LOG0( __FILE__, __LINE__, __VA_ARGS__ )
#else
#define LOG( ... )
#define REGS_LOG( ... )
#endif
#ifndef __ANDROID__
#define __android_log_print( ... )
#endif
#endif /* YAP_H */

View File

@ -154,7 +154,7 @@ typedef struct thandle {
//typedef int (*Agc_hook)(Atom);
/*******************
this is the data base: everything here should be possible to restore
this is the data base: everything here should be possible to restore
********************/
typedef struct various_codes {
/* memory allocation and management */
@ -182,7 +182,7 @@ extern struct worker_local *Yap_local[MAX_THREADS];
#elif defined(YAPOR)
extern struct worker_local *Yap_local;
#define REMOTE(wid) (Yap_local + wid)
#else
#else
extern struct worker_local Yap_local;
#define REMOTE(wid) (&Yap_local)
#endif
@ -198,6 +198,24 @@ extern struct various_codes *Yap_heap_regs;
//#include "dglobals.h"
//#include "dlocals.h"
/**
Yap_CurrentModule: access the current module for looking
up predicates
*/
#define Yap_CurrentModule() Yap_CurrentModule__ (PASS_REGS1)
INLINE_ONLY inline EXTERN Term Yap_CurrentModule__ (USES_REGS1) ;
INLINE_ONLY inline EXTERN Term
Yap_CurrentModule__ (USES_REGS1)
{
if (CurrentModule) return CurrentModule;
return TermProlog;
}
/*******************
these are the global variables: they need not be restored...
********************/
@ -227,7 +245,7 @@ INLINE_ONLY EXTERN inline ADDR
Yap_PreAllocCodeSpace(void);
INLINE_ONLY EXTERN inline ADDR
Yap_PreAllocCodeSpace(void)
Yap_PreAllocCodeSpace(void)
{
CACHE_REGS
return AuxBase;

View File

@ -54,7 +54,7 @@ typedef uintptr_t UInt;
/* typedef long int Int;*/
/* typedef unsigned long int UInt; */
#if _WIN32
#if _WIN32 || __ANDROID__
#define Int_FORMAT "%d"
#define UInt_FORMAT "%u"
#else

View File

@ -384,13 +384,25 @@ void Yap_walltime_interval(Int *,Int *);
void Yap_InitSysbits(void);
void Yap_InitSysPreds(void);
void Yap_InitTime(int);
int Yap_TrueFileName(char *, char *, int);
int Yap_TrueFileName(const char *, char *, int);
int Yap_TruePrefixedFileName(const char *,const char *, char *, int);
double Yap_random(void);
#ifdef _WIN32
char *Yap_RegistryGetString(char *);
void Yap_WinError(char *);
#endif
typedef enum {
YAP_STD,
YAP_SAVED_STATE,
YAP_OBJ,
YAP_PL,
YAP_QLY
} file_type_t;
bool
Yap_trueFileName (const char *isource, const char * idef, const char *root, char *result, bool access, file_type_t ftype, bool expand_root, bool in_lib);
/* threads.c */
void Yap_InitThreadPreds(void);
void Yap_InitFirstWorkerThreadHandle(void);

View File

@ -306,14 +306,18 @@ CELL Yap_NextExo(choiceptr cpt, struct index_t *it);
#define OP_HASH_SIZE 2048
static inline int
INLINE_ONLY inline EXTERN int rtable_hash_op(OPCODE opc, int hash_mask);
INLINE_ONLY inline EXTERN int
rtable_hash_op(OPCODE opc, int hash_mask) {
return((((CELL)opc) >> 3) & hash_mask);
}
INLINE_ONLY inline EXTERN op_numbers Yap_op_from_opcode(OPCODE opc);
/* given an opcode find the corresponding opnumber. This should make
switches on ops a much easier operation */
static inline op_numbers
INLINE_ONLY inline EXTERN op_numbers
Yap_op_from_opcode(OPCODE opc)
{
int j = rtable_hash_op(opc,OP_HASH_SIZE-1);

View File

@ -469,14 +469,9 @@ PLCONS_OBJECTS = \
pl-ntmain.o \
yapres.o
all: "$(STARTUP_ANDROID)android-setup startup.yss windowsi
all: startup.yss windowsi
xandroid-setup:
( cd packages/swig && make android/jni/Android.mk )
android-setup:
windowsi:
windowsi:
@WINDOWS@ yap-win@EXEC_SUFFIX@
Makefile: Makefile.in
@ -596,14 +591,12 @@ INSTALLED_PACKAGES= \
@PKG_MPI@ \
@PKG_MYDDAS@ \
@PKG_PRISM@ \
@PKG_PROSQLITE@ \
@PKG_PYTHON@ \
@PKG_RAPTOR@ \
@PKG_CLIB@ \
@PKG_CHR@ \
@PKG_JPL@ \
@PKG_LIBARCHIVE@ \
@PKG_ODBC@ \
@PKG_PLUNIT@ \
@PKG_REAL@ \
@PKG_RDF@ \
@ -652,6 +645,7 @@ libYap.a: $(LIB_OBJECTS) yapi.o
done
@STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ @DYNYAPLIB@ $(PL_SOURCES) $(SWI_LIB_SOURCES)
( cd packages/myddas && make myddas-yap )
\rm -rf data/yap
mkdir -p data/yap/packages
mkdir -p data/yap/swi
@ -665,16 +659,26 @@ libYap.a: $(LIB_OBJECTS) yapi.o
cp -a $(srcdir)/pl data/yap
cp -a $(srcdir)/library data/yap
cp -a $(srcdir)/swi/library data/yap/swi
cp -a $(srcdir)/packages/clib data/yap/packages
cp -a $(srcdir)/packages/chr data/yap/packages
cp -a $(srcdir)/packages/myddas data/yap/packages
\rm -rf data/yap/packages/*/.git
mkdir -p data/yap/packages/chr
mkdir -p data/yap/packages/clib
mkdir -p data/yap/packages/myddas
for i in $(srcdir)/packages/clib/*; do cp -a $$i data/yap/packages/chr; done
for i in $(srcdir)/packages/chr/*; do cp -a $$i data/yap/packages/chr; done
for i in packages/chr/*; do cp -a $$i data/yap/packages/chr; done
cp -a $(srcdir)/packages/myddas/pl/parameters.yap data/yap/packages/myddas
cp -a $(srcdir)/library/lists.yap data/yap/packages/myddas/
cp -a $(srcdir)/swi/library/error.pl data/yap/packages/myddas/
adb push data/yap /data/yap >/dev/null 2>&1
adb shell "echo \"bootstrap('/data/yap/pl/init.yap'). module(user). qsave_program('/data/yap/startup.yss').\" | LD_LIBRARY_PATH=/data/yap /data/yap/yap@EXEC_SUFFIX@ -b /data/yap/pl/boot.yap"
adb shell "echo \"bootstrap('/data/yap/pl/init.yap'). module(user). ensure_loaded('/data/yap/packages/myddas/myddas'), qsave_program('/data/yap/startup.yss').\" | LD_LIBRARY_PATH=/data/yap /data/yap/yap@EXEC_SUFFIX@ -b /data/yap/pl/boot.yap"
adb pull /data/yap/startup.yss
install: @INSTALL_COMMAND@ install_startup install_common
install: @STARTUP_DEFAULT@@INSTALL_COMMAND@ install_startup install_common
xinstall_unix: android/jni/Android.mk install_unix
android/jni/Android.mk:
( cd packages/swig && make android/jni/Android.mk )
install_unix: @YAPLIB@ yap@EXEC_SUFFIX@
mkdir -p $(DESTDIR)$(BINDIR)

View File

@ -252,6 +252,7 @@ check_function_exists( isnan HAVE_ISNAN )
check_function_exists( kill HAVE_KILL )
check_function_exists( labs HAVE_LABS )
check_function_exists( lgamma HAVE_LGAMMA )
check_function_exists( drand48 HAVE_DRAND48 )
check_function_exists( rand HAVE_RAND )
check_function_exists( random HAVE_RANDOM )
check_function_exists( readlink HAVE_READLINK )
@ -285,6 +286,7 @@ check_function_exists( socklen_t HAVE_SOCKLEN_T )
check_function_exists( sqllen HAVE_SQLLEN )
check_function_exists( sqlulen HAVE_SQLULEN )
check_function_exists( srand HAVE_SRAND )
check_function_exists( srand HAVE_SRAND48 )
check_function_exists( srandom HAVE_SRANDOM )
check_function_exists( ssize_t HAVE_SSIZE_T )
check_function_exists( stat HAVE_STAT )

View File

@ -202,6 +202,9 @@
/* Define to 1 if you have the `dlopen' function. */
#undef HAVE_DLOPEN
/* Define to 1 if you have the `drand48' function. */
#undef HAVE_DRAND48
/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2
@ -740,6 +743,9 @@
/* Define to 1 if you have the `srand' function. */
#undef HAVE_SRAND
/* Define to 1 if you have the `srand48' function. */
#undef HAVE_SRAND48
/* Define to 1 if you have the `srandom' function. */
#undef HAVE_SRANDOM

167
configure vendored
View File

@ -621,14 +621,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='PKG_ODBC
PKG_LIBARCHIVE
PROSQLITE_LIBS
PROSQLITE_LDFLAGS
PROSQLITE_CPPFLAGS
PROSQLITE_PLTARGETS
PROSQLITE_TARGETS
PKG_PROSQLITE
ac_subst_vars='PKG_LIBARCHIVE
GECODE_MAJOR
GECODE_VERSION
GECODE_INCLUDES
@ -929,7 +922,6 @@ with_python
with_swig
with_cuda
with_gecode
with_prosqlite
'
ac_precious_vars='build_alias
host_alias
@ -1622,7 +1614,6 @@ Optional Packages:
--with-swig=DIR swig interface generator
--with-cuda use minisat interface
--with-gecode install gecode library
--with-prosqlite(=location) interface to sqlite
Some influential environment variables:
CC C compiler command
@ -10038,7 +10029,7 @@ _ACEOF
fi
done
for ac_func in putenv rand random
for ac_func in putenv rand random drand48
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@ -10098,7 +10089,7 @@ _ACEOF
fi
done
for ac_func in signal sigprocmask socket srand srandom stat
for ac_func in signal sigprocmask socket srand srand48 srandom stat
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@ -11211,7 +11202,7 @@ OBJECTS_MYDDAS="#"
if test x"$ENABLE_MYDDAS" = x -a x"$STARTUP_ANDROID" = x
then
#in Android we have to actually include myddas in the binary
OBJECTS_MYDDAS="$(ALL_MYDDAS_OBJECTS)"
OBJECTS_MYDDAS="$ALL_MYDDAS_OBJECTS"
fi
@ -12383,7 +12374,6 @@ fi
fi
dl to be installed in various places.
# brew in OSX
if test -d /usr/local/opt/ossp-uuid; then
@ -14142,7 +14132,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 14145 "configure" */
/* #line 14135 "configure" */
public class Test {
}
EOF
@ -14318,7 +14308,7 @@ EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: 14321: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: 14311: uudecode had trouble decoding base 64 file 'Test.uue'" >&5
echo "configure: failed file was:" >&5
cat Test.uue >&5
ac_cv_prog_uudecode_base64=no
@ -14449,7 +14439,7 @@ else
JAVA_TEST=Test.java
CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST
/* #line 14452 "configure" */
/* #line 14442 "configure" */
public class Test {
}
EOF
@ -14484,7 +14474,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
cat << \EOF > $JAVA_TEST
/* [#]line 14487 "configure" */
/* [#]line 14477 "configure" */
public class Test {
public static void main (String args[]) {
System.exit (0);
@ -17151,8 +17141,6 @@ fi
if test "$PKG_SWIG" != ""; then
mkdir -p packages/swig/android
mkdir -p packages/swig/android/usr
mkdir -p packages/swig/python
mkdir -p packages/swig/R
mkdir -p packages/swig/java
@ -17488,133 +17476,6 @@ CPPFLAGS="$saved_CPPFLAGS"
PKG_PROSQLITE="packages/prosqlite"
yap_cv_prosqlite=yes
# Check whether --with-prosqlite was given.
if test "${with_prosqlite+set}" = set; then :
withval=$with_prosqlite; if test "$withval" = yes; then
PROSQLITE_DIR=/usr
elif test "$withval" = no; then
yap_cv_prosqlite=no
else
PROSQLITE_DIR="$withval"
fi
else
PROSQLITE_DIR=/usr
fi
havelib=no
if test $yap_cv_prosqlite = yes; then
OCPPFLAGS="${CPPFLAGS}"
OCPPFLAGS="${CPPFLAGS}"
OCIFLAGS="${CIFLAGS}"
OLDFLAGS="${LDFLAGS}"
if test ! -z "$PROSQLITE_DIR"; then
PROSQLITE_CPPFLAGS="-I${PROSQLITE_DIR}/include"
PROSQLITE_LDFLAGS="-L${PROSQLITE_DIR}/lib"
CPPFLAGS="-I${PROSQLITE_DIR}/include ${CPPFLAGS}"
CIFLAGS="-I${PROSQLITE_DIR}/include ${CIFLAGS}"
LDFLAGS="-L${PROSQLITE_DIR}/lib ${LDFLAGS}"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_open in -lsqlite3" >&5
$as_echo_n "checking for sqlite3_open in -lsqlite3... " >&6; }
if ${ac_cv_lib_sqlite3_sqlite3_open+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lsqlite3 $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char sqlite3_open ();
int
main ()
{
return sqlite3_open ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_sqlite3_sqlite3_open=yes
else
ac_cv_lib_sqlite3_sqlite3_open=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_open" >&5
$as_echo "$ac_cv_lib_sqlite3_sqlite3_open" >&6; }
if test "x$ac_cv_lib_sqlite3_sqlite3_open" = xyes; then :
PROSQLITE_LIBS="-lsqlite3 $LIBS"
havelib=yes
fi
for ac_header in sqlite3.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "sqlite3.h" "ac_cv_header_sqlite3_h" "$ac_includes_default"
if test "x$ac_cv_header_sqlite3_h" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_SQLITE3_H 1
_ACEOF
fi
done
CPPFLAGS="${OCPPFLAGS}"
CPPFLAGS="${OCPPFLAGS}"
CIFLAGS="${OCIFLAGS}"
LDFLAGS="${OLDFLAGS}"
fi
if test "$yap_cv_prosqlite" != no &&
test "$havelib" = yes &&
test "$ac_cv_header_sqlite3_h" = yes; then
PROSQLITE_TARGETS="prosqlite.$SO"
PROSQLITE_PLTARGETS="prolog/prosqlite.pl"
else
echo "ERROR: Cannot find sqlite3 library and/or the header sqlite3.h"
echo "WARNING: PROSQLITE interface will not be built"
PROSQLITE_TARGETS=""
fi
yap_timestamp=`date`
yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION`
yap_startup=startup.yss
@ -17624,11 +17485,6 @@ DATAROOTDIR="$prefix"/share
BINDIR="$bindir"
cat >>confdefs.h <<_ACEOF
#define YAP_STARTUP "$yap_startup"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define C_CC "$CC"
_ACEOF
@ -17680,7 +17536,12 @@ _ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_LIBDIR "$LIBDIR/Yap"
#define YAP_LIBDIR "$prefix/lib/Yap"
_ACEOF
cat >>confdefs.h <<_ACEOF
#define YAP_STARTUP "$yap_startup"
_ACEOF

View File

@ -1762,12 +1762,12 @@ AC_CHECK_FUNCS(mbscasecoll)
AC_CHECK_FUNCS(mbsnrtowcs)
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp)
AC_CHECK_FUNCS(nanosleep mktime opendir)
AC_CHECK_FUNCS(putenv rand random)
AC_CHECK_FUNCS(putenv rand random drand48)
AC_CHECK_FUNCS(readlink realpath regexec)
AC_CHECK_FUNCS(rename rint sbrk select setbuf setlinebuf)
AC_CHECK_FUNCS(setitimer setsid setlinebuf sigaction)
AC_CHECK_FUNCS(siggetmask siginterrupt)
AC_CHECK_FUNCS(signal sigprocmask socket srand srandom stat)
AC_CHECK_FUNCS(signal sigprocmask socket srand srand48 srandom stat)
AC_CHECK_FUNCS(strchr strerror stricmp)
AC_CHECK_FUNCS(strnlen strlwr strncat strncpy strtod)
AC_CHECK_FUNCS(time times tmpnam usleep utime vsnprintf)
@ -2099,12 +2099,8 @@ m4_include([packages/cuda/configure.in])
m4_include([packages/gecode/configure.in])
m4_include([packages/prosqlite/configure.in])
AC_SUBST(PKG_LIBARCHIVE)
AC_SUBST(PKG_ODBC)
yap_timestamp=`date`
yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION`
yap_startup=startup.yss
@ -2113,7 +2109,6 @@ BINDIR=$bindir
DATAROOTDIR="$prefix"/share
BINDIR="$bindir"
AC_DEFINE_UNQUOTED(YAP_STARTUP, [ "$yap_startup" ], [saved state file])
AC_DEFINE_UNQUOTED( C_CC, [ "$CC" ], [c-compiler used])
AC_DEFINE_UNQUOTED( C_CFLAGS, ["$CFLAGS $YAP_EXTRAS $ -D_YAP_NOT_INSTALLED_=1 $CPPFLAGS -I. -I$srcdir/H -I$srcdir/include -I$srcdir/os -I$srcdir/OPTYap -I$srcdir/BEAM" ], [compilation flags])
AC_DEFINE_UNQUOTED( C_LDFLAGS, [ "$LDFLAGS" ], [linking flags])
@ -2124,7 +2119,8 @@ AC_DEFINE_UNQUOTED( SO_PATH, [ "$SOPATH" ], [library search variable])
AC_DEFINE_UNQUOTED( YAP_ARCH, [ "$ARCH" ], [architecture])
AC_DEFINE_UNQUOTED( YAP_BINDIR, [ "$BINDIR" ], [where the yap executable lives])
AC_DEFINE_UNQUOTED( YAP_FULL_VERSION, [ "YAP $YAP_VERSION ($ARCH): $yap_timestamp" ], [YAP version string])
AC_DEFINE_UNQUOTED( YAP_LIBDIR, [ "$LIBDIR/Yap" ], [where to look for shared libraries])
AC_DEFINE_UNQUOTED( YAP_LIBDIR, [ "$prefix/lib/Yap" ], [where to look for shared libraries])
AC_DEFINE_UNQUOTED(YAP_STARTUP, [ "$yap_startup" ], [saved state file])
AC_DEFINE_UNQUOTED( YAP_NUMERIC_VERSION, [ $yap_nversion ], [numerical version])
AC_DEFINE_UNQUOTED( YAP_ROOTDIR, [ "$prefix" ], [where YAP lives])
AC_DEFINE_UNQUOTED( YAP_SHAREDIR, [ "$DATAROOTDIR" ], [where YAP lives])

View File

@ -734,15 +734,14 @@ PRED_IMPL("size_file", 2, size_file, 0)
return FALSE;
}
static
PRED_IMPL("access_file", 2, access_file, 0)
/** @pred access_file(+ _F_,+ _M_)
Is the file accessible?
Is the file accessible?
*/
static
PRED_IMPL("access_file", 2, access_file, 0)
{ PRED_LD
char *n;
int md;

View File

@ -62,7 +62,7 @@ MYDDAS_PROLOG= \
myddas_assert_predicates.ypp \
myddas_mysql.ypp \
myddas_sqlite3.ypp \
myddas_top_level.ypp \
myddas_top_level.ypp \
myddas_errors.ypp \
myddas_postgres.ypp \
myddas_prolog2sql.ypp \
@ -77,7 +77,9 @@ SOBJS= myddas.@SO@
#in some systems we just create a single object, in others we need to
# create a libray
all: $(SOBJS) $(MYDDAS_YAP)
all: $(SOBJS) myddas-yap
myddas-yap: $(MYDDAS_YAP)
.PRECIOUS: %.o %.yap

View File

@ -199,7 +199,7 @@ OBJECTS_MYDDAS="#"
if test x"$ENABLE_MYDDAS" = x -a x"$STARTUP_ANDROID" = x
then
#in Android we have to actually include myddas in the binary
OBJECTS_MYDDAS="$(ALL_MYDDAS_OBJECTS)"
OBJECTS_MYDDAS="$ALL_MYDDAS_OBJECTS"
fi
AC_SUBST(PKG_MYDDAS)

View File

@ -759,6 +759,7 @@ init_myddas(void)
#undef _stringify
Yap_MYDDAS_delete_all_myddas_structs();
#endif
c_db_initialize_myddas( PASS_REGS1 );
}
#ifdef _WIN32

View File

@ -17,10 +17,11 @@
#if USE_MYDDAS
#ifndef __ANDROID__
:- load_foreign_files([myddas], [], init_myddas).
/* Initialize MYDDAS GLOBAL STRUCTURES */
:- c_db_initialize_myddas.
:- .
#endif
#ifdef DEBUG
:- yap_flag(single_var_warnings,on).

View File

@ -107,6 +107,7 @@ android/AndroidManifest.xml: $(ANDROID_PKG)
mkdir -p android/assets/lib
mkdir -p android/assets/lib/Yap
mkdir -p android/jni
mkdir -p android/usr
android/jni/yap_wrap.cpp: $(YAP_SWIG_INTERFACE) android/AndroidManifest.xml
$(SWIG) -c++ -java -I$(srcdir)/../../CXX -package pt.up.fc.dcc.yap -outdir android/src/pt/up/fc/dcc/yap -o $@ $<

View File

@ -21,8 +21,6 @@ fi
if test "$PKG_SWIG" != ""; then
mkdir -p packages/swig/android
mkdir -p packages/swig/android/usr
mkdir -p packages/swig/python
mkdir -p packages/swig/R
mkdir -p packages/swig/java

View File

@ -250,10 +250,12 @@ load_files(Files,Opts) :-
'$load_files'(Files, Opts, Call) :-
( '$nb_getval'('$lf_status', OldTOpts, fail), nonvar(OldTOpts) ->
'$lf_opt'(silent, OldTOpts, OldVerbosity),
'$lf_opt'(autoload, OldTOpts, OldAutoload),
'$lf_opt'('$context_module', OldTOpts, user)
'$lf_opt'(autoload, OldTOpts, OldAutoload)
;
true ),
'$lf_option'(last_opt, LastOpt),
functor( OldTOpts, opt, LastOpt ),
'$lf_opt'('$context_module', OldTOpts, user)
),
'$check_files'(Files,load_files(Files,Opts)),
'$lf_option'(last_opt, LastOpt),
functor( TOpts, opt, LastOpt ),