minor patches

This commit is contained in:
Vitor Santos Costa 2017-10-27 23:06:23 +01:00
parent 978e8e9788
commit 3789f69cf1
6 changed files with 29 additions and 27 deletions

View File

@ -323,11 +323,11 @@ X_API Int YAP_IntOfTerm(Term t) {
} }
} }
X_API Term YAP_MkBigNumTerm(void *big) { X_API Term YAP_MkBigNumTerm(void*big) {
#if USE_GMP #if USE_GMP
Term I; Term I;
BACKUP_H(); BACKUP_H();
I = Yap_MkBigIntTerm((MP_INT *) big); I = Yap_MkBigIntTerm(big);
RECOVER_H(); RECOVER_H();
return I; return I;
#else #else
@ -2433,7 +2433,7 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
#endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */ #endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */
if (!yap_init->Embedded) { if (!yap_init->Embedded) {
GLOBAL_PrologShouldHandleInterrupts = GLOBAL_PrologShouldHandleInterrupts =
~yap_init->PrologCannotHandleInterrupts; !yap_init->PrologCannotHandleInterrupts;
Yap_InitSysbits(0); /* init signal handling and time, required by later Yap_InitSysbits(0); /* init signal handling and time, required by later
functions */ functions */
GLOBAL_argv = yap_init->Argv; GLOBAL_argv = yap_init->Argv;

View File

@ -205,7 +205,7 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name,
} }
#ifdef __osf__ #ifdef __osf__
if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY)) == 0) if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY)) == 0)
#else #elseö
if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY | RTLD_GLOBAL)) == 0) if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY | RTLD_GLOBAL)) == 0)
#endif #endif
{ {
@ -224,8 +224,8 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name,
} }
if (!*init_proc && LOCAL_ErrorMessage == NULL) { if (!*init_proc && LOCAL_ErrorMessage == NULL) {
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); char *buf = malloc(1058);
snprintf(LOCAL_ErrorMessage,MAX_ERROR_MSG_SIZE-1, snprintf(buf,1058-1,
"Could not locate routine %s in %s: %s\n", "Could not locate routine %s in %s: %s\n",
proc_name, LOCAL_FileNameBuf, dlerror()); proc_name, LOCAL_FileNameBuf, dlerror());
return LOAD_FAILLED; return LOAD_FAILLED;

View File

@ -164,19 +164,19 @@ static Int
do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg) do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg)
{ {
CACHE_REGS CACHE_REGS
LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE+1); char *buf = malloc(1043);
#if HAVE_SNPRINTF #if HAVE_SNPRINTF
#if HAVE_STRERROR #if HAVE_STRERROR
snprintf(LOCAL_ErrorMessage,MAX_ERROR_MSG_SIZE,"%s (%s when reading %s)", msg, snprintf(buf,1043-1,"%s (%s when reading %s)", msg,
strerror(errno), LOCAL_FileNameBuf); strerror(errno), LOCAL_FileNameBuf);
#else #else
snprintf(LOCAL_ErrorSay,MAX_ERROR_MSG_SIZE,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf); snprintf(buf,1024-1,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
#endif #endif
#else #else
#if HAVE_STRERROR #if HAVE_STRERROR
sprintf(LOCAL_ErrorSay,"%s, (%s when reading %s)",msg,strerror(errno),LOCAL_FileNameBuf); snprintf(buf,1024-1,"%s, (%s when reading %s)",msg,strerror(errno),LOCAL_FileNameBuf);
#else #else
sprintf(LOCAL_ErrorSay,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf); snprintf(buf,1024-1,"%s, (system error %d when reading %s)",msg,errno,LOCAL_FileNameBuf);
#endif #endif
#endif #endif
LOCAL_Error_TYPE = etype; LOCAL_Error_TYPE = etype;
@ -203,7 +203,7 @@ inline static
Int Int
mywrite(FILE *fd, char *buff, Int len) { mywrite(FILE *fd, char *buff, Int len) {
size_t nwritten; size_t nwritten;
while (len > 0) { while (len > 0) {
nwritten = fwrite(buff, 1, (size_t)len, fd); nwritten = fwrite(buff, 1, (size_t)len, fd);
if ((long int)nwritten < 0) { if ((long int)nwritten < 0) {
@ -1376,7 +1376,7 @@ ShowAtoms()
static int static int
commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) { commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) {
CACHE_REGS CACHE_REGS
int mode; int mode;
if ((mode = check_header(Astate,ATrail,AStack,AHeap PASS_REGS)) == FAIL_RESTORE) if ((mode = check_header(Astate,ATrail,AStack,AHeap PASS_REGS)) == FAIL_RESTORE)
@ -1422,7 +1422,7 @@ static int
OpenRestore(const char *inpf, const char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, FILE **streamp) OpenRestore(const char *inpf, const char *YapLibDir, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap, FILE **streamp)
{ {
CACHE_REGS CACHE_REGS
int mode; int mode;
char fname[YAP_FILENAME_MAX +1]; char fname[YAP_FILENAME_MAX +1];

View File

@ -521,7 +521,6 @@ set_property(DIRECTORY PROPERTY CXX_STANDARD 11)
# rpath stuff, hopefully it works # rpath stuff, hopefully it works
# use, i.e. don't skip the full RPATH for the build tree # use, i.e. don't skip the full RPATH for the build tree
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE) SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already # when building, don't use the install RPATH already
@ -596,6 +595,8 @@ set_target_properties(libYap
PROPERTIES OUTPUT_NAME Yap PROPERTIES OUTPUT_NAME Yap
) )
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py)
if (PYTHONLIBS_FOUND AND SWIG_FOUND) if (PYTHONLIBS_FOUND AND SWIG_FOUND)
add_subdirectory(packages/python/swig) add_subdirectory(packages/python/swig)
@ -640,7 +641,7 @@ OPTION (WITH_CPLINT " Enable the cplint probabilistic language" ON)
OPTION (WITH_HORUS " Enable the CLPBN and PFL probabilistic languages" ON) OPTION (WITH_HORUS " Enable the CLPBN and PFL probabilistic languages" ON)
OPTION (WITH_HORUS " Enable documentation, requires doxygen-yap" ON) OPTION (WITH_DOCS " Enable documentation, requires doxygen-yap" ON)
IF (WITH_CLPBN) IF (WITH_CLPBN)
add_subDIRECTORY (packages/CLPBN) add_subDIRECTORY (packages/CLPBN)

View File

@ -8,9 +8,9 @@
switch (op) { switch (op) {
#ifdef YAP_JIT #ifdef YAP_JIT
case _jit_handler: case _jit_handler:
#endif
cl = NEXTOP(cl,J); cl = NEXTOP(cl,J);
break; break;
#endif
case _ensure_space: case _ensure_space:
cl = NEXTOP(cl,Osbpa); cl = NEXTOP(cl,Osbpa);
break; break;
@ -215,13 +215,13 @@
} else { } else {
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl); LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl);
Term t = lcl->lusl.ClSource->Entry; Term t = lcl->lusl.ClSource->Entry;
if (!(lcl->ClFlags & FactMask)) { if (!(lcl->ClFlags & FactMask)) {
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
} else if (IsApplTerm(t)) { } else if (IsApplTerm(t)) {
CELL *pt = RepAppl(t); CELL *pt = RepAppl(t);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
if (IsExtensionFunctor(FunctorOfTerm(t))) { if (IsExtensionFunctor(FunctorOfTerm(t))) {
clause->ucd.t_ptr = t; clause->ucd.t_ptr = t;
@ -250,13 +250,13 @@
} else { } else {
LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl); LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl);
Term t = lcl->lusl.ClSource->Entry; Term t = lcl->lusl.ClSource->Entry;
if (!(lcl->ClFlags & FactMask)) { if (!(lcl->ClFlags & FactMask)) {
if (IsVarTerm(t)) { if (IsVarTerm(t)) {
clause->Tag = (CELL)NULL; clause->Tag = (CELL)NULL;
} else if (IsApplTerm(t)) { } else if (IsApplTerm(t)) {
CELL *pt = RepAppl(t); CELL *pt = RepAppl(t);
clause->Tag = AbsAppl((CELL *)pt[0]); clause->Tag = AbsAppl((CELL *)pt[0]);
if (IsExtensionFunctor(FunctorOfTerm(t))) { if (IsExtensionFunctor(FunctorOfTerm(t))) {
clause->ucd.t_ptr = t; clause->ucd.t_ptr = t;

View File

@ -1,6 +1,12 @@
# This is a CMake example for Python # This is a CMake example for Python
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/include)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl)
INCLUDE(UseSWIG) INCLUDE(UseSWIG)
include(FindPythonModule) include(FindPythonModule)
@ -24,7 +30,7 @@ INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/i
DEPENDS ${SWIG_SOURCES} YAP++ DEPENDS ${SWIG_SOURCES} YAP++
) )
SWIG_ADD_LIBRARY(Py2YAP LANGUAGE python SHARED SOURCES ../../swig/yap.i ) SWIG_ADD_LIBRARY(Py2YAP LANGUAGE python SHARED SOURCES ../../swig/yap.i )
if (WIN32) if (WIN32)
@ -57,11 +63,6 @@ else()
# ) # )
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/include)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/os)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl)
add_custom_command( OUTPUT yap.i add_custom_command( OUTPUT yap.i
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i . COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i .