Merge branch 'master' of gitosis@yap.dcc.fc.up.pt:yap-6

This commit is contained in:
Theofrastos Mantadelis 2010-12-02 14:48:39 +01:00
commit d3cdc8d2b9
14 changed files with 303 additions and 369 deletions

View File

@ -148,11 +148,11 @@ p_close_shared_object(void) {
void *handle;
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
Yap_Error(INSTANTIATION_ERROR,t,"close_shared_object/1");
return FALSE;
}
if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"open_shared_object/3");
Yap_Error(TYPE_ERROR_INTEGER,t,"close_shared_object/1");
return FALSE;
}
handle = (char *)IntegerOfTerm(t);
@ -164,27 +164,48 @@ static Int
p_call_shared_object_function(void) {
Term t = Deref(ARG1);
Term tfunc = Deref(ARG2);
Term tmod;
void *handle;
Term OldCurrentModule = CurrentModule;
Int res;
tmod = CurrentModule;
restart:
if (IsVarTerm(t)) {
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
return FALSE;
}
if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"open_shared_object/3");
} else if (IsApplTerm(t)) {
Functor fun = FunctorOfTerm(t);
if (fun == FunctorModule) {
tmod = ArgOfTerm(1, t);
if (IsVarTerm(tmod) ) {
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
return FALSE;
}
if (!IsAtomTerm(tmod) ) {
Yap_Error(TYPE_ERROR_ATOM,ARG1,"call_shared_object_function/2");
return FALSE;
}
t = ArgOfTerm(2, t);
goto restart;
}
} else if (!IsIntegerTerm(t)) {
Yap_Error(TYPE_ERROR_INTEGER,t,"call_shared_object_function/2");
return FALSE;
}
handle = (void *)IntegerOfTerm(t);
if (IsVarTerm(tfunc)) {
Yap_Error(INSTANTIATION_ERROR,t,"open_shared_object/3");
Yap_Error(INSTANTIATION_ERROR,t,"call_shared_object_function/2");
return FALSE;
}
if (!IsAtomTerm(tfunc)) {
Yap_Error(TYPE_ERROR_ATOM,t,"open_shared_object/3");
Yap_Error(TYPE_ERROR_ATOM,t,"call_shared_object_function/2/3");
return FALSE;
}
return Yap_CallForeignFile(handle, RepAtom(AtomOfTerm(tfunc))->StrOfAE);
CurrentModule = tmod;
res = Yap_CallForeignFile(handle, RepAtom(AtomOfTerm(tfunc))->StrOfAE);
CurrentModule = OldCurrentModule;
return res;
}
static Int

View File

@ -27,6 +27,11 @@
#include <wchar.h>
typedef struct atom_blob {
size_t length;
char data[MIN_ARRAY];
} atom_blob_t;
/********* operations for atoms ****************************************/
/* Atoms are assumed to be uniquely represented by an OFFSET and to have
@ -55,10 +60,7 @@ typedef struct AtomEntryStruct
union {
char uStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
wchar_t uWStrOfAE[MIN_ARRAY]; /* representation of atom as a string */
struct {
size_t length; /* size of blob */
char data[MIN_ARRAY]; /* data */
} blob;
struct atom_blob blob[MIN_ARRAY];
} rep;
}
AtomEntry;

View File

@ -1604,3 +1604,4 @@ PredPropByAtom (Atom at, Term cur_mod)
#endif
#endif

View File

@ -171,6 +171,7 @@ HEADERS = \
$(srcdir)/OPTYap/locks_pthread.h \
$(srcdir)/H/cut_c.h \
$(srcdir)/H/iatoms.h $(srcdir)/H/ratoms.h $(srcdir)/H/tatoms.h \
$(srcdir)/library/dialect/swi/fli/swi.h \
$(srcdir)/MYDDAS/myddas.h $(srcdir)/MYDDAS/myddas_structs.h \
$(srcdir)/MYDDAS/myddas_statistics.h \
$(srcdir)/MYDDAS/myddas_statistics_structs.h \
@ -223,8 +224,8 @@ C_SOURCES= \
$(srcdir)/library/mpi/mpi.c $(srcdir)/library/mpi/mpe.c \
$(srcdir)/library/lammpi/yap_mpi.c $(srcdir)/library/lammpi/hash.c $(srcdir)/library/lammpi/prologterms2c.c \
$(srcdir)/C/cut_c.c \
$(srcdir)/library/yap2swi/yap2swi.c \
$(srcdir)/library/yap2swi/blobs.c \
$(srcdir)/library/dialect/swi/fli/swi.c \
$(srcdir)/library/dialect/swi/fli/blobs.c \
$(srcdir)/MYDDAS/myddas_mysql.c \
$(srcdir)/MYDDAS/myddas_odbc.c \
$(srcdir)/MYDDAS/myddas_util.c \
@ -293,7 +294,7 @@ ENGINE_OBJECTS = \
udi.o rtree.o rtree_udi.o\
unify.o userpreds.o utilpreds.o \
write.o \
blobs.o yap2swi.o ypsocks.o ypstdio.o @MPI_OBJS@
blobs.o swi.o ypsocks.o ypstdio.o @MPI_OBJS@
C_INTERFACE_OBJECTS = \
load_foreign.o load_dl.o load_dld.o load_dyld.o \
@ -457,11 +458,11 @@ eamindex.o: $(srcdir)/BEAM/eamindex.c config.h
sys.o: $(srcdir)/library/system/sys.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/system/sys.c -o $@
yap2swi.o: $(srcdir)/library/yap2swi/yap2swi.c $(srcdir)/library/yap2swi/swi.h $(srcdir)/include/SWI-Prolog.h $(srcdir)/include/SWI-Stream.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/yap2swi $(srcdir)/library/yap2swi/yap2swi.c -o $@
swi.o: $(srcdir)/library/dialect/swi/fli/swi.c $(srcdir)/library/dialect/swi/fli/swi.h $(srcdir)/include/SWI-Prolog.h $(srcdir)/include/SWI-Stream.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/dialect/swi/fli $(srcdir)/library/dialect/swi/fli/swi.c -o $@
blobs.o: $(srcdir)/library/yap2swi/blobs.c $(srcdir)/library/yap2swi/swi.h $(srcdir)/include/SWI-Prolog.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/yap2swi $(srcdir)/library/yap2swi/blobs.c -o $@
blobs.o: $(srcdir)/library/dialect/swi/fli/blobs.c $(srcdir)/library/dialect/swi/fli/swi.h $(srcdir)/include/SWI-Prolog.h config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include -I$(srcdir)/library/dialect/swi/fli $(srcdir)/library/dialect/swi/fli/blobs.c -o $@
yap_random.o: $(srcdir)/library/random/yap_random.c config.h
$(CC) -c $(CFLAGS) -I$(srcdir)/include $(srcdir)/library/random/yap_random.c -o $@

4
configure vendored
View File

@ -9562,7 +9562,6 @@ mkdir -p library/regex
mkdir -p library/system
mkdir -p library/tries
mkdir -p library/rltree
mkdir -p library/yap2swi
mkdir -p LGPL/clp
mkdir -p LGPL/swi_console
mkdir -p GPL
@ -9620,8 +9619,6 @@ ac_config_files="$ac_config_files library/system/Makefile"
ac_config_files="$ac_config_files library/tries/Makefile"
ac_config_files="$ac_config_files library/yap2swi/Makefile"
ac_config_files="$ac_config_files LGPL/Makefile"
ac_config_files="$ac_config_files LGPL/clp/Makefile"
@ -10404,7 +10401,6 @@ do
"library/rltree/Makefile") CONFIG_FILES="$CONFIG_FILES library/rltree/Makefile" ;;
"library/system/Makefile") CONFIG_FILES="$CONFIG_FILES library/system/Makefile" ;;
"library/tries/Makefile") CONFIG_FILES="$CONFIG_FILES library/tries/Makefile" ;;
"library/yap2swi/Makefile") CONFIG_FILES="$CONFIG_FILES library/yap2swi/Makefile" ;;
"LGPL/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/Makefile" ;;
"LGPL/clp/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/clp/Makefile" ;;
"LGPL/swi_console/Makefile") CONFIG_FILES="$CONFIG_FILES LGPL/swi_console/Makefile" ;;

View File

@ -1929,7 +1929,6 @@ mkdir -p library/regex
mkdir -p library/system
mkdir -p library/tries
mkdir -p library/rltree
mkdir -p library/yap2swi
mkdir -p LGPL/clp
mkdir -p LGPL/swi_console
mkdir -p GPL
@ -1975,7 +1974,6 @@ AC_CONFIG_FILES([library/regex/Makefile])
AC_CONFIG_FILES([library/rltree/Makefile])
AC_CONFIG_FILES([library/system/Makefile])
AC_CONFIG_FILES([library/tries/Makefile])
AC_CONFIG_FILES([library/yap2swi/Makefile])
AC_CONFIG_FILES([LGPL/Makefile])
AC_CONFIG_FILES([LGPL/clp/Makefile])
AC_CONFIG_FILES([LGPL/swi_console/Makefile])

View File

@ -0,0 +1,119 @@
/*************************************************************************
* *
* YAP Prolog *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright V.Santos Costa and Universidade do Porto 1985-- *
* *
**************************************************************************
* *
* File: blobs.c *
* comments: support blobs in YAP definition *
* *
* Last rev: $Date: $,$Author: vsc $ *
* *
* *
*************************************************************************/
#include <Yap.h>
#include <Yatom.h>
#include <string.h>
#include <SWI-Prolog.h>
#include "swi.h"
PL_EXPORT(int)
PL_is_blob(term_t t, PL_blob_t **type)
{
Term yt = Yap_GetFromSlot(t);
Atom a;
BlobPropEntry *b;
if (IsVarTerm(yt))
return FALSE;
if (!IsAtomTerm(yt))
return FALSE;
a = AtomOfTerm(yt);
if (!IsBlob(a))
return FALSE;
b = RepBlobProp(a->PropsOfAE);
*type = b->blob_t;
return TRUE;
}
PL_EXPORT(int)
PL_unify_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
{
fprintf(stderr,"PL_unify_blob not implemented yet\n");
return FALSE;
}
PL_EXPORT(int)
PL_put_blob(term_t t, void *blob, size_t len, PL_blob_t *type)
{
fprintf(stderr,"PL_put_blob not implemented yet\n");
return FALSE;
}
PL_EXPORT(int)
PL_get_blob(term_t t, void **blob, size_t *len, PL_blob_t **type)
{
fprintf(stderr,"PL_get_blob not implemented yet\n");
return FALSE;
}
PL_EXPORT(void*)
PL_blob_data(atom_t a, size_t *len, struct PL_blob_t **type)
{
Atom x = SWIAtomToAtom(a);
if (!IsBlob(x)) {
if (IsWideAtom(x)) {
if ( len )
*len = wcslen(x->WStrOfAE);
if ( type )
*type = SWI_Blobs;
return x->WStrOfAE;
}
if ( len )
*len = strlen(x->StrOfAE);
if ( type )
*type = SWI_Blobs;
return x->StrOfAE;
}
if ( len )
*len = x->rep.blob[0].length;
if ( type )
*type = RepBlobProp(x->PropsOfAE)->blob_t;
return x->rep.blob[0].data;
}
PL_EXPORT(void)
PL_register_blob_type(PL_blob_t *type)
{
fprintf(stderr,"PL_register_blob_type not implemented yet\n");
}
PL_EXPORT(PL_blob_t*)
PL_find_blob_type(const char* name)
{
fprintf(stderr,"PL_find_blob_type not implemented yet\n");
return NULL;
}
PL_EXPORT(int)
PL_unregister_blob_type(PL_blob_t *type)
{
fprintf(stderr,"PL_unregister_blob_type not implemented yet\n");
return FALSE;
}
void
Yap_install_blobs(void)
{
}

View File

@ -50,12 +50,12 @@
extern X_API Int YAP_PLArityOfSWIFunctor(functor_t at);
X_API Int
YAP_PLArityOfSWIFunctor(functor_t at) {
if (IsAtomTerm(at))
YAP_PLArityOfSWIFunctor(functor_t f) {
if (IsAtomTerm(f))
return 0;
if ((CELL)(at) & 2)
return ArityOfFunctor(SWI_Functors[((CELL)at)/4]);
return ArityOfFunctor((Functor)at);
if ((CELL)f < N_SWI_FUNCTORS*(LowTagBits+1))
return ArityOfFunctor(SWI_Functors[(CELL)f/(LowTagBits+1)]);
return ArityOfFunctor((Functor)f);
}
void
@ -64,10 +64,10 @@ Yap_InitSWIHash(void)
int i, j;
memset(SWI_ReverseHash, 0, N_SWI_HASH*sizeof(swi_rev_hash));
for (i=0; i < N_SWI_ATOMS; i++) {
add_to_hash(i*2+1, (ADDR)SWI_Atoms[i]);
add_to_hash(i, (ADDR)SWI_Atoms[i]);
}
for (j=0; j < N_SWI_FUNCTORS; j++) {
add_to_hash((((CELL)(j))*4+2), (ADDR)SWI_Functors[j]);
add_to_hash(j, (ADDR)SWI_Functors[j]);
}
}
@ -1546,7 +1546,7 @@ X_API int PL_unify_atom_nchars(term_t t, size_t len, const char *s)
{
Atom catom;
YAP_Term cterm;
char *buf = (char *)YAP_AllocSpaceFromYap(len+1);
char *buf = (char *)malloc(len+1);
if (!buf)
return FALSE;

View File

@ -0,0 +1,126 @@
void Yap_swi_install(void);
void Yap_install_blobs(void);
/* Required by PL_error */
#define ERR_NO_ERROR 0
#define ERR_INSTANTIATION 1 /* void */
#define ERR_TYPE 2 /* atom_t expected, term_t value */
#define ERR_DOMAIN 3 /* atom_t domain, term_t value */
#define ERR_REPRESENTATION 4 /* atom_t what */
#define ERR_MODIFY_STATIC_PROC 5 /* predicate_t proc */
#define ERR_EVALUATION 6 /* atom_t what */
#define ERR_AR_TYPE 7 /* atom_t expected, Number value */
#define ERR_NOT_EVALUABLE 8 /* functor_t func */
#define ERR_DIV_BY_ZERO 9 /* void */
#define ERR_FAILED 10 /* predicate_t proc */
#define ERR_FILE_OPERATION 11 /* atom_t action, atom_t type, term_t */
#define ERR_PERMISSION 12 /* atom_t type, atom_t op, term_t obj*/
#define ERR_NOT_IMPLEMENTED 13 /* const char *what */
#define ERR_EXISTENCE 14 /* atom_t type, term_t obj */
#define ERR_STREAM_OP 15 /* atom_t action, term_t obj */
#define ERR_RESOURCE 16 /* atom_t resource */
#define ERR_NOMEM 17 /* void */
#define ERR_SYSCALL 18 /* void */
#define ERR_SHELL_FAILED 19 /* term_t command */
#define ERR_SHELL_SIGNALLED 20 /* term_t command, int signal */
#define ERR_AR_UNDEF 21 /* void */
#define ERR_AR_OVERFLOW 22 /* void */
#define ERR_AR_UNDERFLOW 23 /* void */
#define ERR_UNDEFINED_PROC 24 /* Definition def */
#define ERR_SIGNALLED 25 /* int sig, char *name */
#define ERR_CLOSED_STREAM 26 /* IOSTREAM * */
#define ERR_BUSY 27 /* mutexes */
#define ERR_PERMISSION_PROC 28 /* op, type, Definition */
#define ERR_DDE_OP 29 /* op, error */
#define ERR_SYNTAX 30 /* what */
#define ERR_SHARED_OBJECT_OP 31 /* op, error */
#define ERR_TIMEOUT 32 /* op, object */
#define ERR_NOT_IMPLEMENTED_PROC 33 /* name, arity */
#define ERR_FORMAT 34 /* message */
#define ERR_FORMAT_ARG 35 /* seq, term */
#define ERR_OCCURS_CHECK 36 /* Word, Word */
#define ERR_CHARS_TYPE 37 /* char *, term */
#define ERR_MUST_BE_VAR 38 /* int argn, term_t term */
typedef struct open_query_struct {
int open;
int state;
YAP_Term g;
yamop *p, *cp;
Int slots;
jmp_buf env;
struct open_query_struct *old;
} open_query;
#define addr_hash(V) (((CELL) (V)) >> 4 & (N_SWI_HASH-1))
static inline void
add_to_hash(Int i, ADDR key)
{
UInt h = addr_hash(key);
while (SWI_ReverseHash[h].key) {
h = (h+1)%N_SWI_HASH;
}
SWI_ReverseHash[h].key = key;
SWI_ReverseHash[h].pos = i;
}
static atom_t
in_hash(ADDR key)
{
UInt h = addr_hash(key);
while (SWI_ReverseHash[h].key) {
if (SWI_ReverseHash[h].key == key)
return SWI_ReverseHash[h].pos;
h = (h+1)%N_SWI_HASH;
}
return 0;
}
static inline atom_t
AtomToSWIAtom(Atom at)
{
atom_t ats;
if ((ats = in_hash((ADDR)at)))
return (atom_t)((CELL)at*(LowTagBits+1));
return (atom_t)at;
}
static inline Atom
SWIAtomToAtom(atom_t at)
{
if ((CELL)at < N_SWI_ATOMS*(LowTagBits+1))
return SWI_Atoms[((CELL)at)/(LowTagBits+1)];
return (Atom)at;
}
static inline Term
SWIModuleToModule(module_t m)
{
if (m)
return (CELL)m;
if (CurrentModule)
return CurrentModule;
return USER_MODULE;
}
static inline functor_t
FunctorToSWIFunctor(Functor at)
{
atom_t ats;
if ((ats = in_hash((ADDR)at)))
return (functor_t)((CELL)at*(LowTagBits+1));
return (functor_t)at;
}
static inline Functor
SWIFunctorToFunctor(functor_t f)
{
if (IsAtomTerm(f))
return (Functor)f;
if ((CELL)f < N_SWI_FUNCTORS*(LowTagBits+1))
return SWI_Functors[(CELL)f/(LowTagBits+1)];
return (Functor)f;
}

View File

@ -1,61 +0,0 @@
#
# default base directory for YAP installation
# (EROOT for architecture-dependent files)
#
prefix = @prefix@
ROOTDIR = $(prefix)
EROOTDIR = @exec_prefix@
abs_top_builddir = @abs_top_builddir@
#
# where the binary should be
#
BINDIR = $(EROOTDIR)/bin
#
# where YAP should look for libraries
#
LIBDIR=@libdir@/Yap
#
#
CC=@CC@
CFLAGS= @CFLAGS@ $(YAP_EXTRAS) $(DEFS) -I$(srcdir) -I../.. -I$(srcdir)/../../include
#
#
# You shouldn't need to change what follows.
#
INSTALL=@INSTALL@
INSTALL_DATA=@INSTALL_DATA@
INSTALL_PROGRAM=@INSTALL_PROGRAM@
SHELL=/bin/sh
RANLIB=@RANLIB@
srcdir=@srcdir@
SHLIB_CFLAGS=@SHLIB_CFLAGS@
SO=@SO@
#4.1VPATH=@srcdir@:@srcdir@/OPTYap
CWD=$(PWD)
#
OBJS=yap2swi.o
SOBJS=yap2swi.@SO@
#in some systems we just create a single object, in others we need to
# create a libray
# compile yap2swi as part of the main YAP
all:
yap2swi.o: $(srcdir)/yap2swi.c $(srcdir)/yap2swi.h
$(CC) -c $(CFLAGS) $(SHLIB_CFLAGS) $(srcdir)/yap2swi.c -o yap2swi.o
@DO_SECOND_LD@@DO_SECOND_LD@%.@SO@: %.o
@DO_SECOND_LD@ @SHLIB_LD@ -o $@ $<
@DO_SECOND_LD@yap2swi.@SO@: yap2swi.o
@DO_SECOND_LD@ @SHLIB_LD@ -o yap2swi.@SO@ yap2swi.o @
install:
$(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(LIBDIR)
clean:
rm -f *.o *~ $(OBJS) $(SOBJS) *.BAK

View File

@ -1,270 +0,0 @@
/* yap2swi.h */
/*
* Project: jpl for Yap Prolog
* Author: Steve Moyle and Vitor Santos Costa
* Email: steve.moyle@comlab.ox.ac.uk
* Date: 21 January 2002
* Copyright (c) 2002 Steve Moyle and Vitor Santos Costa. All rights reserved.
*/
#ifndef _FLI_H_INCLUDED
#define _FLI_H_INCLUDED
#ifndef __SWI_PROLOG__ /* use this to switch on Prolog dialect */
#define __SWI_PROLOG__ /* normally defined by the plld compiler driver */
#endif
//=== includes ===============================================================
#include "config.h"
#include <YapInterface.h>
#include <stdarg.h>
#include <wchar.h>
#if HAVE_TIME_H
#include <time.h>
#endif
#if USE_GMP
#include <gmp.h>
#endif
#if defined(_MSC_VER) && defined(YAP_EXPORTS)
#define X_API __declspec(dllexport)
#else
#define X_API
#endif
typedef unsigned long fid_t;
typedef unsigned long term_t;
typedef void *module_t;
typedef unsigned long atom_t;
typedef YAP_Term *predicate_t;
typedef struct open_query_struct *qid_t;
typedef long functor_t;
typedef int (*PL_agc_hook_t)(atom_t);
typedef unsigned long foreign_t; /* return type of foreign functions */
#ifdef WIN32
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <inttypes.h> /* more portable than stdint.h */
#endif
typedef void *function_t;
typedef struct _PL_extension
{ char *predicate_name; /* Name of the predicate */
short arity; /* Arity of the predicate */
function_t function; /* Implementing functions */
short flags; /* Or of PL_FA_... */
} PL_extension;
typedef struct
{ unsigned long local_size; /* Stack sizes */
unsigned long global_size;
unsigned long trail_size;
unsigned long argument_size;
char * alias; /* alias name */
int (*cancel)(int id); /* cancel function */
void * reserved[5]; /* reserved for extensions */
} PL_thread_attr_t;
typedef void *PL_engine_t;
#define PL_FA_NOTRACE (0x01) /* foreign cannot be traced */
#define PL_FA_TRANSPARENT (0x02) /* foreign is module transparent */
#define PL_FA_NONDETERMINISTIC (0x04) /* foreign is non-deterministic */
#define PL_FA_VARARGS (0x08) /* call using t0, ac, ctx */
/* begin from pl-itf.h */
#define PL_VARIABLE (1) /* nothing */
#define PL_ATOM (2) /* const char * */
#define PL_INTEGER (3) /* int */
#define PL_FLOAT (4) /* double */
#define PL_STRING (5) /* const char * */
#define PL_TERM (6)
/* PL_unify_term() */
#define PL_FUNCTOR (10) /* functor_t, arg ... */
#define PL_LIST (11) /* length, arg ... */
#define PL_CHARS (12) /* const char * */
#define PL_POINTER (13) /* void * */
/* PlArg::PlArg(text, type) */
#define PL_CODE_LIST (14) /* [ascii...] */
#define PL_CHAR_LIST (15) /* [h,e,l,l,o] */
#define PL_BOOL (16) /* PL_set_feature() */
#define PL_FUNCTOR_CHARS (17) /* PL_unify_term() */
#define PL_PREDICATE_INDICATOR (18) /* predicate_t (Procedure) */
#define PL_SHORT (19) /* short */
#define PL_INT (20) /* int */
#define PL_LONG (21) /* long */
#define PL_DOUBLE (22) /* double */
#define CVT_ATOM 0x0001
#define CVT_STRING 0x0002
#define CVT_LIST 0x0004
#define CVT_INTEGER 0x0008
#define CVT_FLOAT 0x0010
#define CVT_VARIABLE 0x0020
#define CVT_NUMBER (CVT_INTEGER|CVT_FLOAT)
#define CVT_ATOMIC (CVT_NUMBER|CVT_ATOM|CVT_STRING)
#define CVT_WRITE 0x0040 /* as of version 3.2.10 */
#define CVT_ALL (CVT_ATOMIC|CVT_LIST)
#define CVT_MASK 0x00ff
#define BUF_DISCARDABLE 0x0000
#define BUF_RING 0x0100
#define BUF_MALLOC 0x0200
#define PL_ENGINE_CURRENT ((PL_engine_t)-1)
#define PL_ENGINE_SET 0 /* engine set successfully */
#define PL_ENGINE_INVAL 2 /* engine doesn't exist */
#define PL_ENGINE_INUSE 3 /* engine is in use */
#define PL_ACTION_TRACE 1 /* switch to trace mode */
#define PL_ACTION_DEBUG 2 /* switch to debug mode */
#define PL_ACTION_BACKTRACE 3 /* show a backtrace (stack dump) */
#define PL_ACTION_BREAK 4 /* create a break environment */
#define PL_ACTION_HALT 5 /* halt Prolog execution */
#define PL_ACTION_ABORT 6 /* generate a Prolog abort */
/* 7: Obsolete PL_ACTION_SYMBOLFILE */
#define PL_ACTION_WRITE 8 /* write via Prolog i/o buffer */
#define PL_ACTION_FLUSH 9 /* Flush Prolog i/o buffer */
#define PL_ACTION_GUIAPP 10 /* Win32: set when this is a gui */
#define PL_ACTION_ATTACH_CONSOLE 11 /* MT: Attach a console */
/* end from pl-itf.h */
/* copied from old SICStus/SWI interface */
typedef void install_t;
extern X_API PL_agc_hook_t PL_agc_hook(PL_agc_hook_t);
extern X_API void PL_free(void *);
extern X_API char* PL_atom_chars(atom_t);
extern X_API term_t PL_copy_term_ref(term_t);
extern X_API term_t PL_new_term_ref(void);
extern X_API term_t PL_new_term_refs(int);
extern X_API void PL_reset_term_refs(term_t);
/* begin PL_get_* functions =============================*/
extern X_API int PL_get_arg(int, term_t, term_t);
extern X_API int PL_get_atom(term_t, atom_t *);
extern X_API int PL_get_atom_chars(term_t, char **);
extern X_API int PL_get_chars(term_t, char **, unsigned);
extern X_API int PL_get_nchars(term_t, size_t *, char **, unsigned);
extern X_API int PL_get_wchars(term_t, size_t *, wchar_t **, unsigned);
extern X_API int PL_get_functor(term_t, functor_t *);
extern X_API int PL_get_float(term_t, double *);
extern X_API int PL_get_head(term_t, term_t);
extern X_API int PL_get_int64(term_t, int64_t *);
extern X_API int PL_get_integer(term_t, int *);
extern X_API int PL_get_list(term_t, term_t, term_t);
extern X_API int PL_get_long(term_t, long *);
extern X_API int PL_get_list_chars(term_t, char **, unsigned);
extern X_API int PL_get_module(term_t, module_t *);
extern X_API atom_t PL_module_name(module_t);
extern X_API module_t PL_new_module(atom_t);
extern X_API int PL_get_name_arity(term_t, atom_t *, int *);
extern X_API int PL_get_nil(term_t);
extern X_API int PL_get_pointer(term_t, void **);
extern X_API int PL_get_string(term_t, char **, int *);
extern X_API int PL_get_tail(term_t, term_t);
/* end PL_get_* functions =============================*/
/* begin PL_new_* functions =============================*/
extern X_API atom_t PL_new_atom(const char *);
extern X_API atom_t PL_new_atom_wchars(int, const wchar_t *);
extern X_API char *PL_atom_nchars(atom_t, size_t *);
extern X_API wchar_t *PL_atom_wchars(atom_t, size_t *);
extern X_API functor_t PL_new_functor(atom_t, int);
extern X_API atom_t PL_functor_name(functor_t);
extern X_API int PL_functor_arity(functor_t);
/* end PL_new_* functions =============================*/
/* begin PL_put_* functions =============================*/
extern X_API void PL_cons_functor(term_t, functor_t,...);
extern X_API void PL_cons_functor_v(term_t, functor_t,term_t);
extern X_API void PL_cons_list(term_t, term_t, term_t);
extern X_API void PL_put_atom(term_t, atom_t);
extern X_API void PL_put_atom_chars(term_t, const char *);
extern X_API void PL_put_float(term_t, double);
extern X_API void PL_put_functor(term_t, functor_t t);
extern X_API void PL_put_int64(term_t, int64_t);
extern X_API void PL_put_integer(term_t, long);
extern X_API void PL_put_list(term_t);
extern X_API void PL_put_list_chars(term_t, const char *);
extern X_API void PL_put_nil(term_t);
extern X_API void PL_put_pointer(term_t, void *);
extern X_API void PL_put_string_chars(term_t, const char *);
extern X_API void PL_put_term(term_t, term_t);
extern X_API void PL_put_variable(term_t);
extern X_API int PL_compare(term_t, term_t);
/* end PL_put_* functions =============================*/
/* begin PL_unify_* functions =============================*/
extern X_API int PL_unify(term_t, term_t);
extern X_API int PL_unify_atom(term_t, atom_t);
extern X_API int PL_unify_atom_chars(term_t, const char *);
extern X_API int PL_unify_float(term_t, double);
extern X_API int PL_unify_int64(term_t, int64_t);
extern X_API int PL_unify_integer(term_t, long);
extern X_API int PL_unify_list(term_t, term_t, term_t);
extern X_API int PL_unify_list_chars(term_t, const char *);
extern X_API int PL_unify_nil(term_t);
extern X_API int PL_unify_pointer(term_t, void *);
extern X_API int PL_unify_string_chars(term_t, const char *);
extern X_API int PL_unify_term(term_t,...);
/* end PL_unify_* functions =============================*/
/* begin PL_is_* functions =============================*/
extern X_API int PL_is_atom(term_t);
extern X_API int PL_is_atomic(term_t);
extern X_API int PL_is_compound(term_t);
extern X_API int PL_is_float(term_t);
extern X_API int PL_is_functor(term_t, functor_t);
extern X_API int PL_is_integer(term_t);
extern X_API int PL_is_list(term_t);
extern X_API int PL_is_number(term_t);
extern X_API int PL_is_string(term_t);
extern X_API int PL_is_variable(term_t);
extern X_API int PL_term_type(term_t);
/* end PL_is_* functions =============================*/
extern X_API void PL_halt(int);
extern X_API int PL_initialise(int, char **);
extern X_API int PL_is_initialised(int *, char ***);
extern X_API void PL_close_foreign_frame(fid_t);
extern X_API void PL_discard_foreign_frame(fid_t);
extern X_API fid_t PL_open_foreign_frame(void);
extern X_API int PL_raise_exception(term_t);
extern X_API void PL_register_atom(atom_t);
extern X_API void PL_unregister_atom(atom_t);
extern X_API predicate_t PL_pred(functor_t, module_t);
extern X_API predicate_t PL_predicate(const char *, int, const char *);
extern X_API void PL_predicate_info(predicate_t, atom_t *, int *, module_t *);
extern X_API qid_t PL_open_query(module_t, int, predicate_t, term_t);
extern X_API int PL_next_solution(qid_t);
extern X_API void PL_cut_query(qid_t);
extern X_API void PL_close_query(qid_t);
extern X_API term_t PL_exception(qid_t);
extern X_API int PL_call_predicate(module_t, int, predicate_t, term_t);
extern X_API int PL_call(term_t, module_t);
extern X_API void PL_register_extensions(PL_extension *);
extern X_API void PL_load_extensions(PL_extension *);
extern X_API int PL_thread_self(void);
extern X_API int PL_thread_attach_engine(const PL_thread_attr_t *);
extern X_API int PL_thread_destroy_engine(void);
extern X_API int PL_thread_at_exit(void (*)(void *), void *, int);
extern X_API PL_engine_t PL_create_engine(const PL_thread_attr_t *);
extern X_API int PL_destroy_engine(PL_engine_t);
extern X_API int PL_set_engine(PL_engine_t,PL_engine_t *);
extern X_API int PL_get_string_chars(term_t, char **, int *);
extern X_API int PL_action(int,...);
#define IOSTREAM void
extern X_API int PL_get_stream_handle(term_t,IOSTREAM *);
extern X_API int Sprintf(char *,...);
extern X_API int Sdprintf(char *,...);
void swi_install(void);

View File

@ -1215,8 +1215,8 @@ rdf_load_stream(triples, Stream, Options) :- !,
%% report_loaded(+Action, +Source, +DB, +Triples, +StartCPU, +Options)
report_loaded(none, _, _, _, _, _) :- !.
report_loaded(Action, Source, DB, Triples, T0, Options) :-
statistics(cputime, T1),
report_loaded(Action, Source, DB, Triples, T0._, Options) :-
statistics(cputime, T1._),
Time is T1 - T0,
( option(silent(true), Options)
-> Level = silent
@ -1302,7 +1302,7 @@ modified_graph(SourceURL, Graph) :-
% Save triples belonging to DB in the file Cache.
save_cache(DB, Cache) :-
catch(open(Cache, write, CacheStream, [type(binary)]), _, fail), !,
catch(system:swi_open(Cache, write, CacheStream, [type(binary)]), _, fail), !,
call_cleanup(rdf_save_db_(CacheStream, DB),
close(CacheStream)).

View File

@ -565,6 +565,7 @@ source_module(Mod) :-
call_cleanup(0,?,0),
call_residue(0,?),
call_residue_vars(0,?),
call_shared_object_function(:,+),
catch(0,?,0),
clause(:,?),
clause(:,?,?),