Merge ../../yap-6.3
This commit is contained in:
commit
69e0c739e8
@ -1731,7 +1731,7 @@ void Yap_InitFlags(bool bootstrap) {
|
||||
|
||||
Obtain the value for a YAP Prolog flag, same as current_prolog_flag/2.
|
||||
*/
|
||||
Yap_InitCPredBack("prolog_flag", 3, 1, current_prolog_flag, cont_yap_flag,
|
||||
Yap_InitCPredBack("prolog_flag", 3, 1, prolog_flag, cont_yap_flag,
|
||||
0);
|
||||
Yap_InitCPredBack("yap_flag", 3, 1, yap_flag, cont_yap_flag, 0);
|
||||
Yap_InitCPredBack("prolog_flag", 2, 1, current_prolog_flag2,
|
||||
|
@ -283,3 +283,7 @@ void Yap_ReOpenLoadForeign(void) {
|
||||
}
|
||||
CurrentModule = OldModule;
|
||||
}
|
||||
|
||||
X_API bool load_none(void)
|
||||
{
|
||||
}
|
||||
|
@ -557,7 +557,8 @@ option(WITH_R
|
||||
"Use R Interface" ON)
|
||||
|
||||
IF (WITH_R)
|
||||
include_directories(packages/real )
|
||||
find_host_package(LibR)
|
||||
add_subDIRECTORY(packages/real)
|
||||
ENDIF (WITH_R)
|
||||
|
||||
|
||||
@ -776,7 +777,6 @@ if (WITH_GECODE)
|
||||
add_subDIRECTORY(packages/gecode)
|
||||
endif ()
|
||||
|
||||
add_subDIRECTORY(packages/real)
|
||||
|
||||
|
||||
|
||||
@ -795,17 +795,16 @@ if (Java_Development_FOUND)
|
||||
|
||||
set (STD_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
|
||||
set (CMAKE_FIND_FRAMEWORK LAST) # CMake will find the Java returned by /usr/libexec/java_home.
|
||||
find_package(JNI)
|
||||
|
||||
macro_optional_find_package(JNI ON)
|
||||
|
||||
|
||||
set (CMAKE_FIND_FRAMEWORK ${STD_CMAKE_FIND_FRAMEWORK})
|
||||
|
||||
if (NOT JNI_FOUND)
|
||||
|
||||
set (JAVA_HOME ${JAVA_INCLUDE_PATH}/..)
|
||||
|
||||
endif()
|
||||
|
||||
if (JNI_FOUND)
|
||||
|
||||
get_filename_component(JAVA_HOME ${JAVA_INCLUDE_PATH} DIRECTORY)
|
||||
|
||||
include(UseJava)
|
||||
|
||||
#
|
||||
@ -826,7 +825,8 @@ endif()
|
||||
# The Java_ADDITIONAL_VERSIONS variable can be used to specify a list
|
||||
# of version numbers that should be taken into account when searching
|
||||
# for Java. You need to set this variable before calling
|
||||
# find_package(JavaLibs).
|
||||
|
||||
|
||||
#
|
||||
#macro_optional_find_package(JNI ON)
|
||||
# JNI_INCLUDE_DIRS = the include dirs to use
|
||||
@ -838,6 +838,7 @@ endif()
|
||||
# JAVA_INCLUDE_PATH2 = the include path to jni_md.h
|
||||
# JAVA_AWT_INCLUDE_PATH = the include path to jawt.h
|
||||
|
||||
|
||||
endif (JNI_FOUND)
|
||||
|
||||
|
||||
|
@ -129,4 +129,10 @@ void Yap_ShutdownLoadForeign(void);
|
||||
#define EAGER_LOADING 1
|
||||
#define GLOBAL_LOADING 2
|
||||
|
||||
/**
|
||||
* stub can always be called at DLL loading.
|
||||
*
|
||||
*/
|
||||
X_API bool load_none(void);
|
||||
|
||||
#endif
|
||||
|
@ -50,7 +50,6 @@
|
||||
shell/0,
|
||||
shell/1,
|
||||
shell/2,
|
||||
sleep/1,
|
||||
system/0,
|
||||
system/1,
|
||||
system/2,
|
||||
@ -205,18 +204,6 @@ WIN32 environment YAP will use `COMSPEC` if `SHELL` is
|
||||
undefined, in this case with the option `" /c "`.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred sleep(+ _Time_)
|
||||
|
||||
|
||||
Block the current thread for _Time_ seconds. When YAP is compiled
|
||||
without multi-threading support, this predicate blocks the YAP process.
|
||||
The number of seconds must be a positive number, and it may an integer
|
||||
or a float. The Unix implementation uses `usleep` if the number of
|
||||
seconds is below one, and `sleep` if it is over a second. The WIN32
|
||||
implementation uses `Sleep` for both cases.
|
||||
|
||||
|
||||
*/
|
||||
/** @pred system
|
||||
|
||||
|
@ -852,73 +852,6 @@ static YAP_Bool plwait(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static YAP_Bool p_sleep(void) {
|
||||
YAP_Term ts = YAP_ARG1;
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
{
|
||||
unsigned long int secs = 0, usecs = 0, msecs, out;
|
||||
if (YAP_IsIntTerm(ts)) {
|
||||
secs = YAP_IntOfTerm(ts);
|
||||
} else if (YAP_IsFloatTerm(ts)) {
|
||||
double tfl = YAP_FloatOfTerm(ts);
|
||||
if (tfl > 1.0)
|
||||
secs = tfl;
|
||||
else
|
||||
usecs = tfl * 1000000;
|
||||
}
|
||||
msecs = secs * 1000 + usecs / 1000;
|
||||
Sleep(msecs);
|
||||
/* no errors possible */
|
||||
out = 0;
|
||||
return (YAP_Unify(YAP_ARG2, YAP_MkIntTerm(out)));
|
||||
}
|
||||
#elif HAVE_NANOSLEEP
|
||||
{
|
||||
struct timespec req;
|
||||
int out;
|
||||
|
||||
if (YAP_IsFloatTerm(ts)) {
|
||||
double tfl = YAP_FloatOfTerm(ts);
|
||||
|
||||
req.tv_nsec = (tfl - floor(tfl)) * 1000000000;
|
||||
req.tv_sec = rint(tfl);
|
||||
} else {
|
||||
req.tv_nsec = 0;
|
||||
req.tv_sec = YAP_IntOfTerm(ts);
|
||||
}
|
||||
out = nanosleep(&req, NULL);
|
||||
return (YAP_Unify(YAP_ARG2, YAP_MkIntTerm(out)));
|
||||
}
|
||||
#elif HAVE_USLEEP
|
||||
{
|
||||
useconds_t usecs;
|
||||
if (YAP_IsFloatTerm(ts)) {
|
||||
double tfl = YAP_FloatOfTerm(ts);
|
||||
|
||||
usecs = rint(tfl * 1000000);
|
||||
} else {
|
||||
usecs = YAP_IntOfTerm(ts) * 1000000;
|
||||
}
|
||||
out = usleep(usecs);
|
||||
return (YAP_Unify(YAP_ARG2, YAP_MkIntTerm(out)));
|
||||
}
|
||||
#elif HAVE_SLEEP
|
||||
{
|
||||
unsigned int secs, out;
|
||||
if (YAP_IsFloatTerm(ts)) {
|
||||
secs = rint(YAP_FloatOfTerm(ts));
|
||||
} else {
|
||||
secs = YAP_IntOfTerm(ts);
|
||||
}
|
||||
out = sleep(secs);
|
||||
return (YAP_Unify(YAP_ARG2, YAP_MkIntTerm(out)));
|
||||
}
|
||||
#else
|
||||
YAP_Error(0, 0L, "sleep not available in this configuration");
|
||||
return FALSE:
|
||||
#endif
|
||||
}
|
||||
|
||||
/* host info */
|
||||
|
||||
static YAP_Bool host_name(void) {
|
||||
@ -1066,7 +999,6 @@ X_API void init_sys(void) {
|
||||
YAP_UserCPredicate("tmpnam", p_tmpnam, 2);
|
||||
YAP_UserCPredicate("tmpdir", p_tmpdir, 2);
|
||||
YAP_UserCPredicate("rename_file", rename_file, 3);
|
||||
YAP_UserCPredicate("sleep", p_sleep, 2);
|
||||
YAP_UserCPredicate("read_link", read_link, 2);
|
||||
YAP_UserCPredicate("error_message", error_message, 2);
|
||||
YAP_UserCPredicate("win", win, 0);
|
||||
|
10
os/files.c
10
os/files.c
@ -47,7 +47,13 @@ const char *Yap_GetFileName(Term t USES_REGS) {
|
||||
char *buf = Malloc(YAP_FILENAME_MAX + 1);
|
||||
if (IsApplTerm(t) && FunctorOfTerm(t) == FunctorSlash) {
|
||||
snprintf(buf, YAP_FILENAME_MAX, "%s/%s", Yap_GetFileName(ArgOfTerm(1, t)),
|
||||
Yap_GetFileName(ArgOfTerm(1, t)));
|
||||
Yap_GetFileName(ArgOfTerm(2, t)));
|
||||
}
|
||||
if (IsAtomTerm(t)) {
|
||||
return RepAtom(AtomOfTerm(t))->StrOfAE;
|
||||
}
|
||||
if (IsStringTerm(t)) {
|
||||
return StringOfTerm(t);
|
||||
}
|
||||
return Yap_TextTermToText(t PASS_REGS);
|
||||
}
|
||||
@ -90,7 +96,7 @@ static Int file_name_extension(USES_REGS1) {
|
||||
size_t len_b = strlen(f), lenb_b;
|
||||
char *candidate = strrchr(f, '.');
|
||||
char *file = strrchr(f, '/');
|
||||
if (candidate && file && candidate > file) {
|
||||
if (candidate && candidate > file) {
|
||||
lenb_b = candidate - f;
|
||||
ext = candidate + 1;
|
||||
} else {
|
||||
|
70
os/sysbits.c
70
os/sysbits.c
@ -1827,6 +1827,7 @@ static Int p_win_registry_get_value(USES_REGS1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
char *Yap_RegistryGetString(char *name) {
|
||||
DWORD type;
|
||||
BYTE data[MAXREGSTRLEN];
|
||||
@ -1865,6 +1866,74 @@ char *Yap_RegistryGetString(char *name) {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
static Int p_sleep(USES_REGS1) {
|
||||
Term ts = ARG1;
|
||||
#if defined(__MINGW32__) || _MSC_VER
|
||||
{
|
||||
unsigned long int secs = 0, usecs = 0, msecs, out;
|
||||
if (IsIntegerTerm(ts)) {
|
||||
secs = IntegerOfTerm(ts);
|
||||
} else if (IsFloatTerm(ts)) {
|
||||
double tfl = FloatOfTerm(ts);
|
||||
if (tfl > 1.0)
|
||||
secs = tfl;
|
||||
else
|
||||
usecs = tfl * 1000000;
|
||||
}
|
||||
msecs = secs * 1000 + usecs / 1000;
|
||||
Sleep(msecs);
|
||||
/* no ers possible */
|
||||
return true;
|
||||
}
|
||||
#elif HAVE_NANOSLEEP
|
||||
{
|
||||
struct timespec req;
|
||||
int out;
|
||||
|
||||
if (IsFloatTerm(ts)) {
|
||||
double tfl = FloatOfTerm(ts);
|
||||
|
||||
req.tv_nsec = (tfl - floor(tfl)) * 1000000000;
|
||||
req.tv_sec = rint(tfl);
|
||||
} else {
|
||||
req.tv_nsec = 0;
|
||||
req.tv_sec = IntOfTerm(ts);
|
||||
}
|
||||
out = nanosleep(&req, NULL);
|
||||
return true;
|
||||
}
|
||||
#elif HAVE_USLEEP
|
||||
{
|
||||
useconds_t usecs;
|
||||
if (IsFloatTerm(ts)) {
|
||||
double tfl = FloatOfTerm(ts);
|
||||
|
||||
usecs = rint(tfl * 1000000);
|
||||
} else {
|
||||
usecs = IntegrOfTerm(ts) * 1000000;
|
||||
}
|
||||
out = usleep(usecs);
|
||||
return;
|
||||
}
|
||||
#elif HAVE_SLEEP
|
||||
{
|
||||
unsigned int secs, out;
|
||||
if (IsFloatTerm(ts)) {
|
||||
secs = rint(FloatOfTerm(ts));
|
||||
} else {
|
||||
secs = IntOfTerm(ts);
|
||||
}
|
||||
out = sleep(secs);
|
||||
return (Yap_unify(ARG2, MkIntTerm(out)));
|
||||
}
|
||||
#else
|
||||
YAP_Error(SYSTEM_ERROR, 0L, "sleep not available in this configuration");
|
||||
return FALSE:
|
||||
#endif
|
||||
}
|
||||
|
||||
void Yap_InitSysPreds(void) {
|
||||
Yap_InitCPred("log_event", 1, p_log_event, SafePredFlag | SyncPredFlag);
|
||||
Yap_InitCPred("sh", 0, p_sh, SafePredFlag | SyncPredFlag);
|
||||
@ -1901,5 +1970,6 @@ void Yap_InitSysPreds(void) {
|
||||
Yap_InitCPred("win_registry_get_value", 3, p_win_registry_get_value, 0);
|
||||
#endif
|
||||
Yap_InitCPred("rmdir", 2, p_rmdir, SyncPredFlag);
|
||||
Yap_InitCPred("sleep", 1, p_sleep, SyncPredFlag);
|
||||
Yap_InitCPred("make_directory", 1, make_directory, SyncPredFlag);
|
||||
}
|
||||
|
@ -640,7 +640,7 @@ static JNIEnv*
|
||||
jni_env(void) /* economically gets a JNIEnv pointer, valid for this thread */
|
||||
{ JNIEnv *env;
|
||||
|
||||
switch( (*jvm)->GetEnv(jvm, (void**)&env, JNI_VERSION_1_2) )
|
||||
switch( (*jvm)->GetEnv(jvm, (void**)&env, JNI_VERSION_1_8) )
|
||||
{ case JNI_OK:
|
||||
return env;
|
||||
case JNI_EDETACHED:
|
||||
|
@ -3,31 +3,36 @@
|
||||
|
||||
|
||||
|
||||
set(REAL_SOURCES real.c)
|
||||
|
||||
# LIBR_FOUND
|
||||
# LIBR_HOME
|
||||
# LIBR_INCLUDE_DIRS
|
||||
# LIBLIBR_INCLUDE_DIRSS
|
||||
# LIBR_DOC_DIR
|
||||
# LIBR_LIBRARIES
|
||||
|
||||
if (R_LIBRARIES AND R_INCLUDE_DIR)
|
||||
if (LIBR_LIBRARIES AND LIBR_INCLUDE_DIRS)
|
||||
set_package_properties(R PROPERTIES
|
||||
DESCRIPTION "The R Project for Statistical Computing."
|
||||
|
||||
URL "https://www.r-project.org/")
|
||||
add_lib(real ${REAL_SOURCES})
|
||||
target_link_libraries (real ${R_LIBRARIES} libYap)
|
||||
target_link_libraries (real ${LIBR_LIBRARIES} libYap)
|
||||
include_directories (
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${R_INCLUDE_DIR}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${LIBR_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
list (APPEND CMAKE_REQUIRED_INCLUDES
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${R_INCLUDE_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${LIBR_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
check_include_files( "stdio.h;R.h" HAVE_R_H )
|
||||
check_include_files( "R.h,;Rembedded.h" HAVE_R_EMBEDDED_H )
|
||||
check_include_files( "R.h,;Rembeddred.h" HAVE_R_EMBEDDED_H )
|
||||
check_include_files( "Rembedded.h;Rinterface.h" HAVE_R_INTERFACE_H )
|
||||
|
||||
configure_file ("rconfig.h.cmake" "rconfig.h" )
|
||||
|
@ -66,6 +66,7 @@
|
||||
:- use_module(library(readutil)).
|
||||
:- use_module(library(debug)).
|
||||
:- use_module(library(system)).
|
||||
:- use_module(library(readutil)).
|
||||
|
||||
:- dynamic( real:r_started/1 ).
|
||||
|
||||
@ -111,6 +112,15 @@ init_r_env :-
|
||||
install_in_ms_windows(ToR).
|
||||
:- endif.
|
||||
|
||||
init_r_env :-
|
||||
current_prolog_flag(unix, true),
|
||||
open(popen('R RHOME'),read,S),
|
||||
read_line_to_codes(S,Lc),
|
||||
close(S),
|
||||
Lc \= end_of_file,
|
||||
!,
|
||||
atom_codes(RH,Lc),
|
||||
setenv('R_HOME',RH).
|
||||
init_r_env :-
|
||||
current_prolog_flag(unix, true),
|
||||
% typical Linux 64 bit setup (fedora)
|
||||
|
@ -333,8 +333,8 @@ X_API extern Term YAP_MkCharPTerm( char *n);
|
||||
%template(TermVector) vector<Term>;
|
||||
%feature("novaluewrapper") vector<Term>;
|
||||
|
||||
//%template(YAPTermVector) vector<YAPTerm>;
|
||||
//%feature("novaluewrapper") vector<YAPTerm>;
|
||||
%template(YAPTermVector) vector<YAPTerm>;
|
||||
%feature("novaluewrapper") vector<YAPTerm>;
|
||||
|
||||
|
||||
|
||||
|
@ -39,11 +39,6 @@
|
||||
|
||||
*/
|
||||
|
||||
maplist_(_, [], []).
|
||||
maplist_(Pred, [A1|L1], [A2|L2]) :-
|
||||
call(Pred, A1, A2),
|
||||
maplist_(Pred, L1, L2).
|
||||
|
||||
/** @pred load_foreign_files( _Files_, _Libs_, _InitRoutine_)
|
||||
|
||||
should be used, from inside YAP, to load object files produced by the C
|
||||
@ -74,8 +69,8 @@ load_foreign_files(Objs,Libs,Entry) :-
|
||||
access(read),
|
||||
expand(true),
|
||||
file_errors(fail)], NewObjs),
|
||||
maplist_( '$load_lib', Libs, NewLibs),
|
||||
'$load_foreign_files'(NewObjs,NewLibs,Entry),
|
||||
'$load_libs'( Libs ),
|
||||
'$load_foreign_files'(NewObjs,[],Entry),
|
||||
!,
|
||||
prolog_load_context(file, F),
|
||||
ignore( recordzifnot( '$load_foreign_done', [F, M], _) ).
|
||||
@ -95,7 +90,10 @@ load_foreign_files(Objs,Libs,Entry) :-
|
||||
'$name_object'(I, P, O) :-
|
||||
absolute_file_name(I, O, P).
|
||||
|
||||
'$load_lib'(_,L,L).
|
||||
'$load_libs'([]).
|
||||
'$load_libs'([File|Files]) :-
|
||||
open_shared_object(File, _Handle),
|
||||
'$load_libs'(Files).
|
||||
|
||||
/** @pred load_absolute_foreign_files( Files, Libs, InitRoutine)
|
||||
|
||||
|
Reference in New Issue
Block a user