fix WIN stuff

This commit is contained in:
Vitor Santos Costa 2016-04-18 16:41:30 +01:00
parent 49699f52e9
commit 96f03e26e8
13 changed files with 168 additions and 151 deletions

View File

@ -124,7 +124,21 @@ endif()
set(WITH_CUDD YES CACHE FILEPATH "Try to use Cudd (currently Cudd 3)")
if (WITH_CUDD)
include(cudd)
#detect cudd setup, as it is shared between different installations.
find_package(CUDD)
# CUDD_FOUND - system has CUDD
# CUDD_LIBRARIES - Link these to use CUDD
# CUDD_INCLUDE_DIR - Include directory for using CUDD
#
set( CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${CUDD_INCLUDE_DIR} )
check_include_files( cudd.h HAVE_CUDD_H )
check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( cuddInt.h HAVE_CUDDINT_H )
check_include_files( "stdio.h;cudd/cudd.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )
endif(WITH_CUDD)
set(WITH_JAVA YES CACHE FILEPATH "Try to use Java (currently Java 6,7,8)")

View File

@ -2,9 +2,7 @@
#ifndef YAPT_HH
#define YAPT_HH 1
class YAPAtomTerm;
extern "C" X_API Term YAP_ReadBuffer(const char *s, Term *tp);
extern "C" Term YAP_ReadBuffer(const char *s, Term *tp);
/**
* @brief Generic Prolog Term

View File

@ -115,11 +115,18 @@ find_library(CUDD_EPD_LIBRARY
set(CUDD_LIBRARIES
${CUDD_LIBRARIES} ${CUDD_ST_LIBRARY} ${CUDD_UTIL_LIBRARY}
${CUDD_MTR_LIBRARY} ${CUDD_EPD_LIBRARY} ${CUDD_DDDMP_LIBRARY} )
${CUDD_MTR_LIBRARY} ${CUDD_EPD_LIBRARY} ${CUDD_DDDMP_LIBRARY} PARENT_SCOPE )
endif () # Check for cudd 2.
SET( CUDD_FOUND "NO" )
IF(CUDD_INCLUDE_DIR AND CUDD_LIBRARIES)
SET( CUDD_FOUND "YES" )
ENDIF()
mark_as_advanced (CUDD_FOUND)
find_package_handle_standard_args(R DEFAULT_MSG CUDD_LIBRARIES CUDD_INCLUDE_DIR )

View File

@ -10,9 +10,5 @@ macro_log_feature (CUDD_FOUND "CUDD"
"Use CUDD Library"
"http://vlsi.colorado.edu/~fabio/CUDD/" FALSE)
check_include_files( cudd.h HAVE_CUDD_H )
check_include_files( "stdio.h;cudd/cudd.h" HAVE_CUDD_CUDD_H )
check_include_files( cuddInt.h HAVE_CUDDINT_H )
check_include_files( "stdio.h;cudd/cudd.h;cudd/cuddInt.h" HAVE_CUDD_CUDDINT_H )

View File

@ -72,20 +72,14 @@ long _stksize = 32000;
static void do_top_goal(YAP_Term Goal) { YAP_RunGoalOnce(Goal); }
static int init_standard_system(int argc, char *argv[], YAP_init_args *iap) {
int BootMode;
int
BootMode = YAP_parse_yap_arguments(argc, argv, iap);
Mode;
int BootMode = YAP_parse_yap_arguments(argc, argv, iap);
/* init memory */
if (BootMode == YAP_BOOT_FROM_PROLOG ||
BootMode == YAP_FULL_BOOT_FROM_PROLOG) {
int NewBootMode = YAP_Init(iap);
if (NewBootMode != YAP_BOOT_FROM_PROLOG &&
BootMode != YAP_FULL_BOOT_FROM_PROLOG)
BootMode = NewBootMode;
} else {
BootMode = YAP_Init(iap);
}
BootMode = YAP_Init(iap);
if (iap->ErrorNo) {
/* boot failed */
YAP_Error(iap->ErrorNo, 0L, iap->ErrorCause);

View File

@ -44,6 +44,10 @@
* of code.
*/
#include "config.h"
#ifndef HAVE_REGEXEC
#ifdef SNAMES
#define matcher smatcher
#define fast sfast
@ -1090,3 +1094,5 @@ int ch;
#undef print
#undef at
#undef match
#endif

View File

@ -49,6 +49,9 @@ static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
* representations for state sets.
*/
#include "config.h"
#ifndef HAVE_REGEXEC
#include "c_interface.h"
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
@ -65,87 +68,94 @@ static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94";
#include <limits.h>
#endif
#include "yapregex.h"
#include "utils.h"
#include "regex2.h"
#include "utils.h"
#include "yapregex.h"
#if used
static int nope = 0; /* for use in asserts; shuts lint up */
static int nope = 0; /* for use in asserts; shuts lint up */
#endif
/* macros for manipulating states, small version */
#define states long
#define states1 states /* for later use in regexec() decision */
#define CLEAR(v) ((v) = 0)
#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n)))
#define SET1(v, n) ((v) |= (unsigned long)1 << (n))
#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0)
#define ASSIGN(d, s) ((d) = (s))
#define EQ(a, b) ((a) == (b))
#define STATEVARS long dummy /* dummy version */
#define STATESETUP(m, n) /* nothing */
#define STATETEARDOWN(m) /* nothing */
#define SETUP(v) ((v) = 0)
#define onestate long
#define INIT(o, n) ((o) = (unsigned long)1 << (n))
#define INC(o) ((o) <<= 1)
#define ISSTATEIN(v, o) (((v) & (o)) != 0)
#define states long
#define states1 states /* for later use in regexec() decision */
#define CLEAR(v) ((v) = 0)
#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n)))
#define SET1(v, n) ((v) |= (unsigned long)1 << (n))
#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0)
#define ASSIGN(d, s) ((d) = (s))
#define EQ(a, b) ((a) == (b))
#define STATEVARS long dummy /* dummy version */
#define STATESETUP(m, n) /* nothing */
#define STATETEARDOWN(m) /* nothing */
#define SETUP(v) ((v) = 0)
#define onestate long
#define INIT(o, n) ((o) = (unsigned long)1 << (n))
#define INC(o) ((o) <<= 1)
#define ISSTATEIN(v, o) (((v) & (o)) != 0)
/* some abbreviations; note that some of these know variable names! */
/* do "if I'm here, I can also be there" etc without branches */
#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n))
#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n))
#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0)
#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src) & (here)) << (n))
#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src) & (here)) >> (n))
#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0)
/* function names */
#define SNAMES /* engine.c looks after details */
#define SNAMES /* engine.c looks after details */
#include "engine.c"
/* now undo things */
#undef states
#undef CLEAR
#undef SET0
#undef SET1
#undef ISSET
#undef ASSIGN
#undef EQ
#undef STATEVARS
#undef STATESETUP
#undef STATETEARDOWN
#undef SETUP
#undef onestate
#undef INIT
#undef INC
#undef ISSTATEIN
#undef FWD
#undef BACK
#undef ISSETBACK
#undef SNAMES
#undef states
#undef CLEAR
#undef SET0
#undef SET1
#undef ISSET
#undef ASSIGN
#undef EQ
#undef STATEVARS
#undef STATESETUP
#undef STATETEARDOWN
#undef SETUP
#undef onestate
#undef INIT
#undef INC
#undef ISSTATEIN
#undef FWD
#undef BACK
#undef ISSETBACK
#undef SNAMES
/* macros for manipulating states, large version */
#define states char *
#define CLEAR(v) memset(v, 0, m->g->nstates)
#define SET0(v, n) ((v)[n] = 0)
#define SET1(v, n) ((v)[n] = 1)
#define ISSET(v, n) ((v)[n])
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
#define STATEVARS long vn; char *space
#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
if ((m)->space == NULL) return(REG_ESPACE); \
(m)->vn = 0; }
#define STATETEARDOWN(m) { free((m)->space); }
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define onestate long
#define INIT(o, n) ((o) = (n))
#define INC(o) ((o)++)
#define ISSTATEIN(v, o) ((v)[o])
#define states char *
#define CLEAR(v) memset(v, 0, m->g->nstates)
#define SET0(v, n) ((v)[n] = 0)
#define SET1(v, n) ((v)[n] = 1)
#define ISSET(v, n) ((v)[n])
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
#define STATEVARS \
long vn; \
char *space
#define STATESETUP(m, nv) \
{ \
(m)->space = malloc((nv) * (m)->g->nstates); \
if ((m)->space == NULL) \
return (REG_ESPACE); \
(m)->vn = 0; \
}
#define STATETEARDOWN(m) \
{ free((m)->space); }
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define onestate long
#define INIT(o, n) ((o) = (n))
#define INC(o) ((o)++)
#define ISSTATEIN(v, o) ((v)[o])
/* some abbreviations; note that some of these know variable names! */
/* do "if I'm here, I can also be there" etc without branches */
#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
#define ISSETBACK(v, n) ((v)[here - (n)])
#define FWD(dst, src, n) ((dst)[here + (n)] |= (src)[here])
#define BACK(dst, src, n) ((dst)[here - (n)] |= (src)[here])
#define ISSETBACK(v, n) ((v)[here - (n)])
/* function names */
#define LNAMES /* flag */
#define LNAMES /* flag */
#include "engine.c"
@ -164,30 +174,31 @@ static int nope = 0; /* for use in asserts; shuts lint up */
* when choosing which matcher to call. Also, by this point the matchers
* have been prototyped.
*/
int /* 0 success, REG_NOMATCH failure */
yap_regexec(preg, string, nmatch, pmatch, eflags)
const regex_t *preg;
int /* 0 success, REG_NOMATCH failure */
yap_regexec(preg, string, nmatch, pmatch, eflags) const regex_t *preg;
const char *string;
size_t nmatch;
regmatch_t pmatch[];
int eflags;
{
register struct re_guts *g = preg->re_g;
register struct re_guts *g = preg->re_g;
#ifdef REDEBUG
# define GOODFLAGS(f) (f)
#define GOODFLAGS(f) (f)
#else
# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
#define GOODFLAGS(f) ((f) & (REG_NOTBOL | REG_NOTEOL | REG_STARTEND))
#endif
if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
return(REG_BADPAT);
assert(!(g->iflags&BAD));
if (g->iflags&BAD) /* backstop for no-debug case */
return(REG_BADPAT);
eflags = GOODFLAGS(eflags);
if (preg->re_magic != MAGIC1 || g->magic != MAGIC2)
return (REG_BADPAT);
assert(!(g->iflags & BAD));
if (g->iflags & BAD) /* backstop for no-debug case */
return (REG_BADPAT);
eflags = GOODFLAGS(eflags);
if (g->nstates <= CHAR_BIT*sizeof(states1) && !(eflags&REG_LARGE))
return(smatcher(g, (char *)string, nmatch, pmatch, eflags));
else
return(lmatcher(g, (char *)string, nmatch, pmatch, eflags));
if (g->nstates <= CHAR_BIT * sizeof(states1) && !(eflags & REG_LARGE))
return (smatcher(g, (char *)string, nmatch, pmatch, eflags));
else
return (lmatcher(g, (char *)string, nmatch, pmatch, eflags));
}
#endif

View File

@ -557,7 +557,7 @@ file_property(File, Type, Size, Date, Permissions, LinkName) :-
file_property(File, Type, Size, Date, Permissions, LinkName, Error),
handle_system_internal(Error, off, file_property(File)).
%
% environment manipulation.
%
@ -681,7 +681,7 @@ shell :-
exec_command(FullCommand, 0, 1, 2, PID, Error),
handle_system_internal(Error, off, G),
wait(PID, _Status, Error, Id),
handle_system_internal(Error, Id, off, G).
handle_system_internal(Error, got(FullCommand, Id), off, G).
shell(Command) :-
G = shell(Command),

View File

@ -841,7 +841,7 @@ plwait(void)
if (WIFEXITED( status ) ) {
return YAP_Unify(YAP_ARG2, YAP_MkIntTerm(WEXITSTATUS(status)) );
} else if (WIFSIGNALED( status )) {
return YAP_Unify(YAP_ARG3, YAP_MkAtomTerm(YAP_LookupAtom("signal")) ) &&
return YAP_Unify(YAP_ARG3, YAP_MkAtomTerm(YAP_LookupAtom("signalled")) ) &&
YAP_Unify(YAP_ARG4, YAP_MkIntTerm( WTERMSIG(status)) );
} else /* WIFSTOPPED(status) */ {
return YAP_Unify(YAP_ARG3, YAP_MkAtomTerm(YAP_LookupAtom("stopped")) ) &&

View File

@ -76,7 +76,7 @@ If _S_ is a currently opened stream for output, it becomes the
current output stream. If _S_ is an atom it is taken to be a
filename. If there is no output stream currently associated with it,
then it is opened for output, and the new output stream created becomes
the current output stream. Existing files are clobbered, use append/1 to extend a file.
the current output stream. Existing files are clobbered, use append/1 to ext end a file.
If it is not possible to open the file, an
error occurs. If there is a single opened output stream currently
associated with the file, then it becomes the current output stream; if

View File

@ -192,7 +192,7 @@ bool Yap_Exists(const char *f) {
}
return false;
#elif HAVE_ACCESS
if (access(FileName, F_OK) == 0)
if (access(f, F_OK) == 0)
return true;
if (errno == EINVAL) {
Yap_Error(SYSTEM_ERROR_INTERNAL, TermNil, "bad flags to access");
@ -448,8 +448,7 @@ static bool ChDir(const char *path) {
#endif
#if _WIN32
rc = true;
if (qpath != NULL &&
qpath[0] &&
if (qpath != NULL && qpath[0] &&
(rc = (SetCurrentDirectory(qpath) != 0)) == 0) {
Yap_WinError("SetCurrentDirectory failed");
}
@ -483,20 +482,19 @@ static const char *myrealpath(const char *path, char *out) {
}
// rc = NULL;
if (errno == ENOENT || errno == EACCES) {
char base[YAP_FILENAME_MAX+1];
char base[YAP_FILENAME_MAX + 1];
strncpy(base, path, YAP_FILENAME_MAX - 1);
rc = realpath(dirname(base), NULL);
rc = realpath(dirname(base), out);
if (rc) {
// base may haave been destroyed
const char *b = basename(path);
// base may haave been destroyed
const char *b = basename((char *)path);
size_t e = strlen(rc);
size_t bs = strlen(b);
if (rc != out &&
rc != base) {
rc = realloc(rc, e + bs + 2);
}
if (rc != out && rc != base) {
rc = realloc(rc, e + bs + 2);
}
#if _WIN32
if (rc[e - 1] != '\\' && rc[e - 1] != '/') {
rc[e] = '\\';
@ -551,18 +549,17 @@ const char *Yap_AbsoluteFile(const char *spec, char *rc0, bool ok) {
const char *rc;
const char *spec1;
const char *spec2;
char rc1[YAP_FILENAME_MAX+1];
char rc1[YAP_FILENAME_MAX + 1];
/// spec gothe original spec;
/// rc0 may be an outout buffer
/// rc1 the internal buffer
///
/// PlExpandVars
/// spec gothe original spec;
/// rc0 may be an outout buffer
/// rc1 the internal buffer
///
/// PlExpandVars
#if _WIN32
char rc2[YAP_FILENAME_MAX];
if (( rc = unix2win(spec, rc2, YAP_FILENAME_MAX)) == NULL) {
if ((rc = unix2win(spec, rc2, YAP_FILENAME_MAX)) == NULL) {
return NULL;
}
spec1 = rc;
@ -585,8 +582,8 @@ const char *Yap_AbsoluteFile(const char *spec, char *rc0, bool ok) {
}
static Term
/* Expand the string for the program to run. */
do_glob(const char *spec, bool glob_vs_wordexp) {
/* Expand the string for the program to run. */
do_glob(const char *spec, bool glob_vs_wordexp) {
CACHE_REGS
char u[YAP_FILENAME_MAX + 1];
const char *espec = u;
@ -604,8 +601,8 @@ do_glob(const char *spec, bool glob_vs_wordexp) {
char fname[_MAX_FNAME];
char ext[_MAX_EXT];
_splitpath( spec, drive, dir, fname, ext );
_makepath( u, drive, dir, fname, ext );
_splitpath(spec, drive, dir, fname, ext);
_makepath(u, drive, dir, fname, ext);
// first pass, remove Unix style stuff
hFind = FindFirstFile(u, &find);
@ -613,15 +610,15 @@ do_glob(const char *spec, bool glob_vs_wordexp) {
return TermNil;
} else {
tf = AbsPair(HR);
_makepath( u, drive, dir, find.cFileName, NULL );
_makepath(u, drive, dir, find.cFileName, NULL);
HR[0] = MkAtomTerm(Yap_LookupAtom(u));
HR[1] = TermNil;
dest = HR + 1;
HR += 2;
while (FindNextFile(hFind, &find)) {
*dest = AbsPair(HR);
_makepath( u, drive, dir, find.cFileName, NULL );
HR[0] = MkAtomTerm(Yap_LookupAtom(u));
_makepath(u, drive, dir, find.cFileName, NULL);
HR[0] = MkAtomTerm(Yap_LookupAtom(u));
HR[1] = TermNil;
dest = HR + 1;
HR += 2;
@ -752,7 +749,6 @@ do_glob(const char *spec, bool glob_vs_wordexp) {
static Int real_path(USES_REGS1) {
Term t1 = Deref(ARG1);
const char *cmd, *rc0;
char *rc;
if (IsAtomTerm(t1)) {
cmd = RepAtom(AtomOfTerm(t1))->StrOfAE;
@ -762,14 +758,14 @@ static Int real_path(USES_REGS1) {
return false;
}
#if _WIN32
char cmd2[YAP_FILENAME_MAX+1];
if (( rc = unix2win(cmd, cmd2, YAP_FILENAME_MAX)) == NULL) {
char cmd2[YAP_FILENAME_MAX + 1];
if ((rc = unix2win(cmd, cmd2, YAP_FILENAME_MAX)) == NULL) {
return false;
}
cmd = rc;
#endif
rc0 = myrealpath(cmd, NULL);
if (!rc0) {
PlIOError(SYSTEM_ERROR_OPERATING_SYSTEM, ARG1, NULL);
@ -818,15 +814,15 @@ static Term do_expand_file_name(Term t1, Term opts USES_REGS) {
#if _WIN32
{
char *rc;
char cmd2[YAP_FILENAME_MAX+1];
if (( rc = unix2win(spec, cmd2, YAP_FILENAME_MAX)) == NULL) {
char cmd2[YAP_FILENAME_MAX + 1];
if ((rc = unix2win(spec, cmd2, YAP_FILENAME_MAX)) == NULL) {
return false;
}
spec = rc;
}
#endif
args = Yap_ArgListToVector(opts, expand_filename_defs, EXPAND_FILENAME_END);
if (args == NULL) {
return TermNil;
@ -869,8 +865,7 @@ static Term do_expand_file_name(Term t1, Term opts USES_REGS) {
const char *o = expandVars(spec, NULL);
if (!o)
return false;
return MkPairTerm(MkAtomTerm(Yap_LookupAtom(o)),
TermNil);
return MkPairTerm(MkAtomTerm(Yap_LookupAtom(o)), TermNil);
}
tf = do_glob(spec, true);
return tf;
@ -1383,10 +1378,9 @@ static Int true_file_name(USES_REGS1) {
Yap_Error(TYPE_ERROR_ATOM, t, "argument to true_file_name");
return FALSE;
}
if (!Yap_AbsoluteFile(s,
LOCAL_FileNameBuf, true))
return true;
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(LOCAL_FileNameBuf)));
if (!(s = Yap_AbsoluteFile(s, LOCAL_FileNameBuf, true)))
return false;
return Yap_unify(ARG2, MkAtomTerm(Yap_LookupAtom(s)));
}
static Int p_expand_file_name(USES_REGS1) {

View File

@ -353,8 +353,6 @@ do_learning_intern(Iterations,Epsilon) :-
format_learning(1,'~nIteration ~d of ~d~n',[CurrentIteration,EndIteration]),
logger_set_variable(iteration,CurrentIteration),
leash(none),
% trace,
write_probabilities_file,
once(llh_testset),

View File

@ -856,9 +856,8 @@ int my_index_calc(int varstart, DdNode *node) {
}
void AddNode(hisqueue *HisQueue, int varstart, DdNode *node, double dvalue,
int ivalue, void *dynvalue) {
// int index = GetIndex(node) - varstart;
// fprintf(stderr,"----- node added: %p <-> %i <->
// %e\n",node,GetIndex(node),dvalue);
//int index = GetIndex(node) - varstart;
//fprintf(stderr,"----- node added: %p <-> %i <-> %e\n",node,GetIndex(node),dvalue);
int index = my_index_calc(varstart, node);
HisQueue[index].thenode = (hisnode *)realloc(
HisQueue[index].thenode,
@ -876,8 +875,8 @@ hisnode *GetNode(hisqueue *HisQueue, int varstart, DdNode *node) {
// int index = GetIndex(node) - varstart;
int index = -1;
index = my_index_calc(varstart, node);
// fprintf(stderr,"----- node retuned: %p <-> %i <-> %i
// \n",node,GetIndex(node),index);
// fprintf(stderr,"----- node retuned: %p <-> %i <-> %i
// \n",node,GetIndex(node),index);
// TODO: this must be check think not initialzied. Null check fails?
// if (Cudd_IsConstant(node) ){
// fprintf(stderr,"----- node retuned: %p <-> %i \n",node,GetIndex(node));