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

141
C/save.c
View File

@ -61,8 +61,6 @@ static char SccsId[] = "@(#)save.c 1.3 3/15/90";
/********* hack for accesing several kinds of terms. Should be cleaned **/ /********* 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 *****"; static char end_msg[256] ="*** End of YAP saved state *****";
/* SWI IO, must be restarted after restore */ /* SWI IO, must be restarted after restore */
@ -1414,19 +1412,7 @@ commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *A
return mode; return mode;
} }
static void static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, IOSTREAM **streamp) {
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) {
int mode; int mode;
if (streamp) { if (streamp) {
@ -1438,8 +1424,6 @@ static int try_open(char *inpf, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *
if ((splfild = open_file(inpf, O_RDONLY)) < 0) { if ((splfild = open_file(inpf, O_RDONLY)) < 0) {
return FAIL_RESTORE; 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) { if ((mode = commit_to_saved_state(inpf,Astate,ATrail,AStack,AHeap)) != FAIL_RESTORE) {
CACHE_REGS CACHE_REGS
LOCAL_ErrorMessage = NULL; LOCAL_ErrorMessage = NULL;
@ -1452,135 +1436,24 @@ static int
OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, IOSTREAM **streamp) OpenRestore(char *inpf, char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, IOSTREAM **streamp)
{ {
CACHE_REGS CACHE_REGS
int mode = FAIL_RESTORE;
char save_buffer[YAP_FILENAME_MAX+1];
#if __ANDROID__ int mode;
if (!inpf) char fname[PATH_MAX+1];
inpf = YAPSTARTUP;
#endif
save_buffer[0] = '\0';
// LOCAL_ErrorMessage = NULL;
if (inpf == NULL) {
inpf = StartUpFile;
}
/* 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 (!Yap_trueFileName( inpf, YAP_STARTUP, YapLibDir, fname, true, YAP_SAVED_STATE, true, true))
if ((fatts = GetFileAttributes(LOCAL_FileNameBuf)) == 0xFFFFFFFFL || return false;
!(fatts & FILE_ATTRIBUTE_DIRECTORY)) { if (fname != NULL &&
/* couldn't find it where it was supposed to be, (mode = try_open(fname,Astate,ATrail,AStack,AHeap,streamp)) != FAIL_RESTORE) {
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; return mode;
} }
}
end:
#endif
/* try to open from current directory */ /* try to open from current directory */
/* could not open file */ /* could not open file */
if (LOCAL_ErrorMessage == NULL) { 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"); do_system_error(PERMISSION_ERROR_OPEN_SOURCE_SINK,"incorrect saved state");
} else { } else {
strncpy(LOCAL_FileNameBuf, inpf, YAP_FILENAME_MAX-1); 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,"could not open saved state");
} }
}
return FAIL_RESTORE; return FAIL_RESTORE;
} }

View File

@ -171,9 +171,6 @@ AAssetManager * Yap_assetManager;
void * void *
Yap_openAssetFile( const char *path ) { Yap_openAssetFile( const char *path ) {
AAssetDir *d;
LOG("openA %s %p", path, path);
const char * p = path+8; const char * p = path+8;
AAsset* asset = AAssetManager_open(Yap_assetManager, p, AASSET_MODE_UNKNOWN); AAsset* asset = AAssetManager_open(Yap_assetManager, p, AASSET_MODE_UNKNOWN);
return asset; return asset;
@ -182,6 +179,8 @@ Yap_openAssetFile( const char *path ) {
bool bool
Yap_isAsset( const char *path ) Yap_isAsset( const char *path )
{ {
if (Yap_assetManager == NULL)
return false;
return path[0] == '/'&& return path[0] == '/'&&
path[1] == 'a'&& path[1] == 'a'&&
path[2] == 's'&& path[2] == 's'&&
@ -197,12 +196,13 @@ Yap_AccessAsset( const char *name, int mode )
{ {
AAssetManager* mgr = Yap_assetManager; AAssetManager* mgr = Yap_assetManager;
const char *bufp=name+7; const char *bufp=name+7;
if (bufp[0] == '/') if (bufp[0] == '/')
bufp++; bufp++;
if ((mode & W_OK) == W_OK) { if ((mode & W_OK) == W_OK) {
return false; return false;
} }
// check if file is a directory. // directory works if file exists
AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp); AAssetDir *assetDir = AAssetManager_openDir(mgr, bufp);
if (assetDir) { if (assetDir) {
AAssetDir_close(assetDir); AAssetDir_close(assetDir);
@ -1690,9 +1690,11 @@ static void
InitRandom (void) InitRandom (void)
{ {
current_seed = (unsigned int) time (NULL); current_seed = (unsigned int) time (NULL);
#if HAVE_RANDOM #if HAVE_SRAND48
srand48 (current_seed);
#elif HAVE_SRANDOM
srandom (current_seed); srandom (current_seed);
#elif HAVE_RAND #elif HAVE_SRAND
srand (current_seed); srand (current_seed);
#endif #endif
} }
@ -1703,7 +1705,9 @@ extern int rand(void);
double double
Yap_random (void) Yap_random (void)
{ {
#if HAVE_RANDOM #if HAVE_DRAND48
return drand48();
#elif HAVE_RANDOM
/* extern long random (); */ /* extern long random (); */
return (((double) random ()) / 0x7fffffffL /* 2**31-1 */); return (((double) random ()) / 0x7fffffffL /* 2**31-1 */);
#elif HAVE_RAND #elif HAVE_RAND
@ -1790,9 +1794,11 @@ p_srandom ( USES_REGS1 )
current_seed = (unsigned int) FloatOfTerm (t0); current_seed = (unsigned int) FloatOfTerm (t0);
else else
current_seed = (unsigned int) LongIntOfTerm (t0); current_seed = (unsigned int) LongIntOfTerm (t0);
#if HAVE_RANDOM #if HAVE_SRAND48
srand48(current_seed);
#elif HAVE_SRANDOM
srandom(current_seed); srandom(current_seed);
#elif HAVE_RAND #elif HAVE_SRAND
srand(current_seed); srand(current_seed);
#endif #endif
@ -2365,50 +2371,142 @@ Yap_volume_header(char *file)
} }
} }
/** Yap_trueFileName: tries to generate the true name of file
static bool *
TrueFileName (char *isource, char *root, char *result, int in_lib, int expand_root) *
* @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 *work; char save_buffer[YAP_FILENAME_MAX+1];
const char *source = isource; const char *root, *source = isource;
int rc = FAIL_RESTORE;
int try = 0;
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
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 ( in_lib) {
source = ( ftype == YAP_PL || ftype == YAP_QLY ? "library" : "startup" ) ;
source = Yap_RegistryGetString( source );
root = NULL;
} else
#endif
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 // expand names in case you have
// to add a prefix // to add a prefix
if (!expand_root) if ( !access || exists( work ) )
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);
}
#if HAVE_GETENV
{
char *yap_env = getenv("YAPLIBDIR");
if (yap_env && exists((work = expandWithPrefix( source, yap_env, result ))))
return true; // done
}
#endif
#if __WINDOWS__
{
if (Yap_LibDir &&
exists((work = expandWithPrefix( source, Yap_LibDir, result ))))
return true; // done
}
#endif
if (YAP_LIBDIR &&
exists((work = expandWithPrefix( source, YAP_LIBDIR, result ))))
return true; // done return true; // done
} }
return false; return false;
} }
int 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 static Int
@ -2424,7 +2522,8 @@ p_true_file_name ( USES_REGS1 )
Yap_Error(TYPE_ERROR_ATOM,t,"argument to true_file_name"); Yap_Error(TYPE_ERROR_ATOM,t,"argument to true_file_name");
return FALSE; 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))); 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"); Yap_Error(TYPE_ERROR_ATOM,t,"argument to true_file_name");
return FALSE; 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))); return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
} }
@ -2466,7 +2566,8 @@ p_true_file_name3 ( USES_REGS1 )
} }
root = RepAtom(AtomOfTerm(t2))->StrOfAE; 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))); return Yap_unify(ARG3, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
} }
@ -2703,8 +2804,10 @@ p_mv ( USES_REGS1 )
} else if (!IsAtomTerm(t2)) { } else if (!IsAtomTerm(t2)) {
Yap_Error(TYPE_ERROR_ATOM, t2, "second argument to rename/2 not atom"); Yap_Error(TYPE_ERROR_ATOM, t2, "second argument to rename/2 not atom");
} }
TrueFileName (RepAtom(AtomOfTerm(t1))->StrOfAE, NULL, oldname, FALSE, TRUE); if (!Yap_trueFileName (RepAtom(AtomOfTerm(t1))->StrOfAE, NULL, NULL, oldname, true, YAP_STD, true, false))
TrueFileName (RepAtom(AtomOfTerm(t2))->StrOfAE, NULL, newname, FALSE, TRUE); 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) if ((r = link (oldname, newname)) == 0 && (r = unlink (oldname)) != 0)
unlink (newname); unlink (newname);
if (r != 0) { if (r != 0) {

View File

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

View File

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

View File

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

View File

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

11
H/Yap.h
View File

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

View File

@ -198,6 +198,24 @@ extern struct various_codes *Yap_heap_regs;
//#include "dglobals.h" //#include "dglobals.h"
//#include "dlocals.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... these are the global variables: they need not be restored...
********************/ ********************/

View File

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

View File

@ -384,13 +384,25 @@ void Yap_walltime_interval(Int *,Int *);
void Yap_InitSysbits(void); void Yap_InitSysbits(void);
void Yap_InitSysPreds(void); void Yap_InitSysPreds(void);
void Yap_InitTime(int); 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); double Yap_random(void);
#ifdef _WIN32 #ifdef _WIN32
char *Yap_RegistryGetString(char *); char *Yap_RegistryGetString(char *);
void Yap_WinError(char *); void Yap_WinError(char *);
#endif #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 */ /* threads.c */
void Yap_InitThreadPreds(void); void Yap_InitThreadPreds(void);
void Yap_InitFirstWorkerThreadHandle(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 #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) { rtable_hash_op(OPCODE opc, int hash_mask) {
return((((CELL)opc) >> 3) & 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 /* given an opcode find the corresponding opnumber. This should make
switches on ops a much easier operation */ switches on ops a much easier operation */
static inline op_numbers INLINE_ONLY inline EXTERN op_numbers
Yap_op_from_opcode(OPCODE opc) Yap_op_from_opcode(OPCODE opc)
{ {
int j = rtable_hash_op(opc,OP_HASH_SIZE-1); int j = rtable_hash_op(opc,OP_HASH_SIZE-1);

View File

@ -469,12 +469,7 @@ PLCONS_OBJECTS = \
pl-ntmain.o \ pl-ntmain.o \
yapres.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@ @WINDOWS@ yap-win@EXEC_SUFFIX@
@ -596,14 +591,12 @@ INSTALLED_PACKAGES= \
@PKG_MPI@ \ @PKG_MPI@ \
@PKG_MYDDAS@ \ @PKG_MYDDAS@ \
@PKG_PRISM@ \ @PKG_PRISM@ \
@PKG_PROSQLITE@ \
@PKG_PYTHON@ \ @PKG_PYTHON@ \
@PKG_RAPTOR@ \ @PKG_RAPTOR@ \
@PKG_CLIB@ \ @PKG_CLIB@ \
@PKG_CHR@ \ @PKG_CHR@ \
@PKG_JPL@ \ @PKG_JPL@ \
@PKG_LIBARCHIVE@ \ @PKG_LIBARCHIVE@ \
@PKG_ODBC@ \
@PKG_PLUNIT@ \ @PKG_PLUNIT@ \
@PKG_REAL@ \ @PKG_REAL@ \
@PKG_RDF@ \ @PKG_RDF@ \
@ -652,6 +645,7 @@ libYap.a: $(LIB_OBJECTS) yapi.o
done done
@STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ @DYNYAPLIB@ $(PL_SOURCES) $(SWI_LIB_SOURCES) @STARTUP_ANDROID@startup.yss: yap@EXEC_SUFFIX@ @DYNYAPLIB@ $(PL_SOURCES) $(SWI_LIB_SOURCES)
( cd packages/myddas && make myddas-yap )
\rm -rf data/yap \rm -rf data/yap
mkdir -p data/yap/packages mkdir -p data/yap/packages
mkdir -p data/yap/swi mkdir -p data/yap/swi
@ -665,16 +659,26 @@ libYap.a: $(LIB_OBJECTS) yapi.o
cp -a $(srcdir)/pl data/yap cp -a $(srcdir)/pl data/yap
cp -a $(srcdir)/library data/yap cp -a $(srcdir)/library data/yap
cp -a $(srcdir)/swi/library data/yap/swi cp -a $(srcdir)/swi/library data/yap/swi
cp -a $(srcdir)/packages/clib data/yap/packages mkdir -p data/yap/packages/chr
cp -a $(srcdir)/packages/chr data/yap/packages mkdir -p data/yap/packages/clib
cp -a $(srcdir)/packages/myddas data/yap/packages mkdir -p data/yap/packages/myddas
\rm -rf data/yap/packages/*/.git 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 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 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@ install_unix: @YAPLIB@ yap@EXEC_SUFFIX@
mkdir -p $(DESTDIR)$(BINDIR) 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( kill HAVE_KILL )
check_function_exists( labs HAVE_LABS ) check_function_exists( labs HAVE_LABS )
check_function_exists( lgamma HAVE_LGAMMA ) check_function_exists( lgamma HAVE_LGAMMA )
check_function_exists( drand48 HAVE_DRAND48 )
check_function_exists( rand HAVE_RAND ) check_function_exists( rand HAVE_RAND )
check_function_exists( random HAVE_RANDOM ) check_function_exists( random HAVE_RANDOM )
check_function_exists( readlink HAVE_READLINK ) 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( sqllen HAVE_SQLLEN )
check_function_exists( sqlulen HAVE_SQLULEN ) check_function_exists( sqlulen HAVE_SQLULEN )
check_function_exists( srand HAVE_SRAND ) check_function_exists( srand HAVE_SRAND )
check_function_exists( srand HAVE_SRAND48 )
check_function_exists( srandom HAVE_SRANDOM ) check_function_exists( srandom HAVE_SRANDOM )
check_function_exists( ssize_t HAVE_SSIZE_T ) check_function_exists( ssize_t HAVE_SSIZE_T )
check_function_exists( stat HAVE_STAT ) check_function_exists( stat HAVE_STAT )

View File

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

167
configure vendored
View File

@ -621,14 +621,7 @@ ac_includes_default="\
# include <unistd.h> # include <unistd.h>
#endif" #endif"
ac_subst_vars='PKG_ODBC ac_subst_vars='PKG_LIBARCHIVE
PKG_LIBARCHIVE
PROSQLITE_LIBS
PROSQLITE_LDFLAGS
PROSQLITE_CPPFLAGS
PROSQLITE_PLTARGETS
PROSQLITE_TARGETS
PKG_PROSQLITE
GECODE_MAJOR GECODE_MAJOR
GECODE_VERSION GECODE_VERSION
GECODE_INCLUDES GECODE_INCLUDES
@ -929,7 +922,6 @@ with_python
with_swig with_swig
with_cuda with_cuda
with_gecode with_gecode
with_prosqlite
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
host_alias host_alias
@ -1622,7 +1614,6 @@ Optional Packages:
--with-swig=DIR swig interface generator --with-swig=DIR swig interface generator
--with-cuda use minisat interface --with-cuda use minisat interface
--with-gecode install gecode library --with-gecode install gecode library
--with-prosqlite(=location) interface to sqlite
Some influential environment variables: Some influential environment variables:
CC C compiler command CC C compiler command
@ -10038,7 +10029,7 @@ _ACEOF
fi fi
done done
for ac_func in putenv rand random for ac_func in putenv rand random drand48
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
@ -10098,7 +10089,7 @@ _ACEOF
fi fi
done done
for ac_func in signal sigprocmask socket srand srandom stat for ac_func in signal sigprocmask socket srand srand48 srandom stat
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" 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 if test x"$ENABLE_MYDDAS" = x -a x"$STARTUP_ANDROID" = x
then then
#in Android we have to actually include myddas in the binary #in Android we have to actually include myddas in the binary
OBJECTS_MYDDAS="$(ALL_MYDDAS_OBJECTS)" OBJECTS_MYDDAS="$ALL_MYDDAS_OBJECTS"
fi fi
@ -12383,7 +12374,6 @@ fi
fi fi
dl to be installed in various places.
# brew in OSX # brew in OSX
if test -d /usr/local/opt/ossp-uuid; then if test -d /usr/local/opt/ossp-uuid; then
@ -14142,7 +14132,7 @@ else
JAVA_TEST=Test.java JAVA_TEST=Test.java
CLASS_TEST=Test.class CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST cat << \EOF > $JAVA_TEST
/* #line 14145 "configure" */ /* #line 14135 "configure" */
public class Test { public class Test {
} }
EOF EOF
@ -14318,7 +14308,7 @@ EOF
if uudecode$EXEEXT Test.uue; then if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes ac_cv_prog_uudecode_base64=yes
else 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 echo "configure: failed file was:" >&5
cat Test.uue >&5 cat Test.uue >&5
ac_cv_prog_uudecode_base64=no ac_cv_prog_uudecode_base64=no
@ -14449,7 +14439,7 @@ else
JAVA_TEST=Test.java JAVA_TEST=Test.java
CLASS_TEST=Test.class CLASS_TEST=Test.class
cat << \EOF > $JAVA_TEST cat << \EOF > $JAVA_TEST
/* #line 14452 "configure" */ /* #line 14442 "configure" */
public class Test { public class Test {
} }
EOF EOF
@ -14484,7 +14474,7 @@ JAVA_TEST=Test.java
CLASS_TEST=Test.class CLASS_TEST=Test.class
TEST=Test TEST=Test
cat << \EOF > $JAVA_TEST cat << \EOF > $JAVA_TEST
/* [#]line 14487 "configure" */ /* [#]line 14477 "configure" */
public class Test { public class Test {
public static void main (String args[]) { public static void main (String args[]) {
System.exit (0); System.exit (0);
@ -17151,8 +17141,6 @@ fi
if test "$PKG_SWIG" != ""; then 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/python
mkdir -p packages/swig/R mkdir -p packages/swig/R
mkdir -p packages/swig/java 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_timestamp=`date`
yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION` yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION`
yap_startup=startup.yss yap_startup=startup.yss
@ -17624,11 +17485,6 @@ DATAROOTDIR="$prefix"/share
BINDIR="$bindir" BINDIR="$bindir"
cat >>confdefs.h <<_ACEOF
#define YAP_STARTUP "$yap_startup"
_ACEOF
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define C_CC "$CC" #define C_CC "$CC"
_ACEOF _ACEOF
@ -17680,7 +17536,12 @@ _ACEOF
cat >>confdefs.h <<_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 _ACEOF

View File

@ -1762,12 +1762,12 @@ AC_CHECK_FUNCS(mbscasecoll)
AC_CHECK_FUNCS(mbsnrtowcs) AC_CHECK_FUNCS(mbsnrtowcs)
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp) AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp)
AC_CHECK_FUNCS(nanosleep mktime opendir) 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(readlink realpath regexec)
AC_CHECK_FUNCS(rename rint sbrk select setbuf setlinebuf) AC_CHECK_FUNCS(rename rint sbrk select setbuf setlinebuf)
AC_CHECK_FUNCS(setitimer setsid setlinebuf sigaction) AC_CHECK_FUNCS(setitimer setsid setlinebuf sigaction)
AC_CHECK_FUNCS(siggetmask siginterrupt) 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(strchr strerror stricmp)
AC_CHECK_FUNCS(strnlen strlwr strncat strncpy strtod) AC_CHECK_FUNCS(strnlen strlwr strncat strncpy strtod)
AC_CHECK_FUNCS(time times tmpnam usleep utime vsnprintf) 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/gecode/configure.in])
m4_include([packages/prosqlite/configure.in])
AC_SUBST(PKG_LIBARCHIVE) AC_SUBST(PKG_LIBARCHIVE)
AC_SUBST(PKG_ODBC)
yap_timestamp=`date` yap_timestamp=`date`
yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION` yap_nversion=`expr $YAP_MAJOR_VERSION \* 10000 + $YAP_MINOR_VERSION \* 100 + $YAP_POINT_VERSION`
yap_startup=startup.yss yap_startup=startup.yss
@ -2113,7 +2109,6 @@ BINDIR=$bindir
DATAROOTDIR="$prefix"/share DATAROOTDIR="$prefix"/share
BINDIR="$bindir" 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_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_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]) 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_ARCH, [ "$ARCH" ], [architecture])
AC_DEFINE_UNQUOTED( YAP_BINDIR, [ "$BINDIR" ], [where the yap executable lives]) 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_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_NUMERIC_VERSION, [ $yap_nversion ], [numerical version])
AC_DEFINE_UNQUOTED( YAP_ROOTDIR, [ "$prefix" ], [where YAP lives]) AC_DEFINE_UNQUOTED( YAP_ROOTDIR, [ "$prefix" ], [where YAP lives])
AC_DEFINE_UNQUOTED( YAP_SHAREDIR, [ "$DATAROOTDIR" ], [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; return FALSE;
} }
static
PRED_IMPL("access_file", 2, access_file, 0)
/** @pred access_file(+ _F_,+ _M_) /** @pred access_file(+ _F_,+ _M_)
Is the file accessible? Is the file accessible?
*/ */
static
PRED_IMPL("access_file", 2, access_file, 0)
{ PRED_LD { PRED_LD
char *n; char *n;
int md; int md;

View File

@ -77,7 +77,9 @@ SOBJS= myddas.@SO@
#in some systems we just create a single object, in others we need to #in some systems we just create a single object, in others we need to
# create a libray # create a libray
all: $(SOBJS) $(MYDDAS_YAP) all: $(SOBJS) myddas-yap
myddas-yap: $(MYDDAS_YAP)
.PRECIOUS: %.o %.yap .PRECIOUS: %.o %.yap

View File

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

View File

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

View File

@ -17,10 +17,11 @@
#if USE_MYDDAS #if USE_MYDDAS
#ifndef __ANDROID__
:- load_foreign_files([myddas], [], init_myddas). :- load_foreign_files([myddas], [], init_myddas).
/* Initialize MYDDAS GLOBAL STRUCTURES */ /* Initialize MYDDAS GLOBAL STRUCTURES */
:- c_db_initialize_myddas. :- .
#endif
#ifdef DEBUG #ifdef DEBUG
:- yap_flag(single_var_warnings,on). :- 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
mkdir -p android/assets/lib/Yap mkdir -p android/assets/lib/Yap
mkdir -p android/jni mkdir -p android/jni
mkdir -p android/usr
android/jni/yap_wrap.cpp: $(YAP_SWIG_INTERFACE) android/AndroidManifest.xml 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 $@ $< $(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 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/python
mkdir -p packages/swig/R mkdir -p packages/swig/R
mkdir -p packages/swig/java mkdir -p packages/swig/java

View File

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