From 3789f69cf1c96cb30f9e0dac651d128afa212c0c Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Fri, 27 Oct 2017 23:06:23 +0100 Subject: [PATCH] minor patches --- C/c_interface.c | 6 +++--- C/load_dl.c | 6 +++--- C/save.c | 16 ++++++++-------- CMakeLists.txt | 5 +++-- H/headclause.h | 10 +++++----- packages/python/swig/CMakeLists.txt | 13 +++++++------ 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/C/c_interface.c b/C/c_interface.c index 72f51dc3b..22c0e2043 100755 --- a/C/c_interface.c +++ b/C/c_interface.c @@ -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 Term I; BACKUP_H(); - I = Yap_MkBigIntTerm((MP_INT *) big); + I = Yap_MkBigIntTerm(big); RECOVER_H(); return I; #else @@ -2433,7 +2433,7 @@ static void do_bootfile(const char *bootfilename USES_REGS) { #endif /* YAPOR_COPY || YAPOR_COW || YAPOR_SBA */ if (!yap_init->Embedded) { GLOBAL_PrologShouldHandleInterrupts = - ~yap_init->PrologCannotHandleInterrupts; + !yap_init->PrologCannotHandleInterrupts; Yap_InitSysbits(0); /* init signal handling and time, required by later functions */ GLOBAL_argv = yap_init->Argv; diff --git a/C/load_dl.c b/C/load_dl.c index 01da66384..cd37af45d 100755 --- a/C/load_dl.c +++ b/C/load_dl.c @@ -205,7 +205,7 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name, } #ifdef __osf__ if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY)) == 0) -#else +#elseƶ if ((handle = dlopen(LOCAL_FileNameBuf, RTLD_LAZY | RTLD_GLOBAL)) == 0) #endif { @@ -224,8 +224,8 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name, } if (!*init_proc && LOCAL_ErrorMessage == NULL) { - LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE); - snprintf(LOCAL_ErrorMessage,MAX_ERROR_MSG_SIZE-1, + char *buf = malloc(1058); + snprintf(buf,1058-1, "Could not locate routine %s in %s: %s\n", proc_name, LOCAL_FileNameBuf, dlerror()); return LOAD_FAILLED; diff --git a/C/save.c b/C/save.c index 3e04c8052..08d89722e 100755 --- a/C/save.c +++ b/C/save.c @@ -164,19 +164,19 @@ static Int do_SYSTEM_ERROR_INTERNAL(yap_error_number etype, const char *msg) { CACHE_REGS - LOCAL_ErrorMessage = malloc(MAX_ERROR_MSG_SIZE+1); + char *buf = malloc(1043); #if HAVE_SNPRINTF #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); #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 #else #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 - 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 LOCAL_Error_TYPE = etype; @@ -203,7 +203,7 @@ inline static Int mywrite(FILE *fd, char *buff, Int len) { size_t nwritten; - + while (len > 0) { nwritten = fwrite(buff, 1, (size_t)len, fd); if ((long int)nwritten < 0) { @@ -1376,7 +1376,7 @@ ShowAtoms() static int commit_to_saved_state(char *s, CELL *Astate, CELL *ATrail, CELL *AStack, CELL *AHeap) { - CACHE_REGS + CACHE_REGS int mode; 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) { CACHE_REGS - + int mode; char fname[YAP_FILENAME_MAX +1]; diff --git a/CMakeLists.txt b/CMakeLists.txt index 6baa578c4..d794a35fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -521,7 +521,6 @@ set_property(DIRECTORY PROPERTY CXX_STANDARD 11) # 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 SET(CMAKE_SKIP_BUILD_RPATH FALSE) # when building, don't use the install RPATH already @@ -596,6 +595,8 @@ set_target_properties(libYap PROPERTIES OUTPUT_NAME Yap ) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/packages/python/swig/yap4py) + if (PYTHONLIBS_FOUND AND SWIG_FOUND) 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 documentation, requires doxygen-yap" ON) +OPTION (WITH_DOCS " Enable documentation, requires doxygen-yap" ON) IF (WITH_CLPBN) add_subDIRECTORY (packages/CLPBN) diff --git a/H/headclause.h b/H/headclause.h index d6ef01a0e..7ae2a5920 100644 --- a/H/headclause.h +++ b/H/headclause.h @@ -8,9 +8,9 @@ switch (op) { #ifdef YAP_JIT case _jit_handler: -#endif cl = NEXTOP(cl,J); break; + #endif case _ensure_space: cl = NEXTOP(cl,Osbpa); break; @@ -215,13 +215,13 @@ } else { LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl); Term t = lcl->lusl.ClSource->Entry; - + if (!(lcl->ClFlags & FactMask)) { if (IsVarTerm(t)) { clause->Tag = (CELL)NULL; } else if (IsApplTerm(t)) { CELL *pt = RepAppl(t); - + clause->Tag = AbsAppl((CELL *)pt[0]); if (IsExtensionFunctor(FunctorOfTerm(t))) { clause->ucd.t_ptr = t; @@ -250,13 +250,13 @@ } else { LogUpdClause *lcl = ClauseCodeToLogUpdClause(cl); Term t = lcl->lusl.ClSource->Entry; - + if (!(lcl->ClFlags & FactMask)) { if (IsVarTerm(t)) { clause->Tag = (CELL)NULL; } else if (IsApplTerm(t)) { CELL *pt = RepAppl(t); - + clause->Tag = AbsAppl((CELL *)pt[0]); if (IsExtensionFunctor(FunctorOfTerm(t))) { clause->ucd.t_ptr = t; diff --git a/packages/python/swig/CMakeLists.txt b/packages/python/swig/CMakeLists.txt index 90b3fc75c..a16a2385b 100644 --- a/packages/python/swig/CMakeLists.txt +++ b/packages/python/swig/CMakeLists.txt @@ -1,6 +1,12 @@ # 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(FindPythonModule) @@ -24,7 +30,7 @@ INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/i DEPENDS ${SWIG_SOURCES} YAP++ ) - + SWIG_ADD_LIBRARY(Py2YAP LANGUAGE python SHARED SOURCES ../../swig/yap.i ) 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 COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i .