2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
2009-04-20 22:22:47 +01:00
|
|
|
|
2011-02-10 21:14:38 +00:00
|
|
|
#if USE_GMP
|
|
|
|
#define O_GMP 1
|
|
|
|
#endif
|
|
|
|
|
2011-07-25 23:51:45 +01:00
|
|
|
#ifdef __WINDOWS__
|
|
|
|
#include <windows.h>
|
|
|
|
#include <uxnt.h>
|
|
|
|
#define O_HASDRIVES 1
|
2011-07-26 18:42:13 +01:00
|
|
|
#define O_HASSHARES 1
|
2011-07-25 23:51:45 +01:00
|
|
|
#endif
|
|
|
|
|
2011-06-06 19:03:20 +01:00
|
|
|
#ifndef PL_CONSOLE
|
2009-04-20 22:22:47 +01:00
|
|
|
#define PL_KERNEL 1
|
2011-06-06 19:03:20 +01:00
|
|
|
#endif
|
2009-04-20 22:22:47 +01:00
|
|
|
|
2009-07-21 04:56:16 +01:00
|
|
|
#ifdef __MINGW32__
|
|
|
|
#define O_XOS 1
|
|
|
|
#endif
|
|
|
|
|
2011-02-03 11:23:12 +00:00
|
|
|
#ifdef THREADS
|
|
|
|
#define O_PLMT 1
|
|
|
|
#endif
|
|
|
|
|
2011-03-01 10:26:25 +00:00
|
|
|
#include "Yap.h"
|
|
|
|
#include "YapHeap.h"
|
2011-07-26 18:42:13 +01:00
|
|
|
|
2011-03-01 10:26:25 +00:00
|
|
|
/* try not to pollute the SWI space */
|
|
|
|
#ifdef P
|
|
|
|
#undef P
|
|
|
|
#endif
|
|
|
|
#ifdef B
|
|
|
|
#undef B
|
|
|
|
#endif
|
|
|
|
#ifdef S
|
|
|
|
#undef S
|
|
|
|
#endif
|
|
|
|
#ifdef H
|
|
|
|
#undef H
|
|
|
|
#endif
|
2011-03-02 09:19:35 +00:00
|
|
|
/* vsc: needs defining before getting rid of YAP locks */
|
|
|
|
static inline int
|
|
|
|
do_startCritical(void) {
|
2011-03-07 16:02:55 +00:00
|
|
|
CACHE_REGS
|
2011-03-02 09:19:35 +00:00
|
|
|
YAPEnterCriticalSection();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
static inline int
|
|
|
|
do_endCritical(void) {
|
2011-05-25 16:40:36 +01:00
|
|
|
CACHE_REGS
|
2011-03-02 09:19:35 +00:00
|
|
|
YAPLeaveCriticalSection();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#define startCritical do_startCritical()
|
|
|
|
#define endCritical do_endCritical()
|
2011-03-01 10:26:25 +00:00
|
|
|
#ifdef LOCK
|
|
|
|
#undef LOCK
|
|
|
|
#endif
|
|
|
|
#ifdef UNLOCK
|
|
|
|
#undef UNLOCK
|
|
|
|
#endif
|
2011-02-03 11:23:12 +00:00
|
|
|
#include <SWI-Stream.h>
|
2008-12-22 12:02:22 +00:00
|
|
|
#include <SWI-Prolog.h>
|
2009-03-23 15:29:13 +00:00
|
|
|
typedef int bool;
|
2011-02-10 00:01:19 +00:00
|
|
|
typedef int Char; /* char that can pass EOF */
|
|
|
|
typedef uintptr_t word; /* Anonymous 4 byte object */
|
|
|
|
|
|
|
|
#if SIZE_DOUBLE==SIZEOF_INT_P
|
|
|
|
#define WORDS_PER_DOUBLE 1
|
|
|
|
#else
|
|
|
|
#define WORDS_PER_DOUBLE 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// numbers
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{ V_INTEGER, /* integer (64-bit) value */
|
|
|
|
#ifdef O_GMP
|
|
|
|
V_MPZ, /* mpz_t */
|
|
|
|
V_MPQ, /* mpq_t */
|
|
|
|
#endif
|
|
|
|
V_FLOAT /* Floating point number (double) */
|
|
|
|
} numtype;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{ numtype type; /* type of number */
|
|
|
|
union { double f; /* value as real */
|
|
|
|
int64_t i; /* value as integer */
|
|
|
|
word w[WORDS_PER_DOUBLE]; /* for packing/unpacking the double */
|
|
|
|
#ifdef O_GMP
|
|
|
|
mpz_t mpz; /* GMP integer */
|
|
|
|
mpq_t mpq; /* GMP rational */
|
|
|
|
#endif
|
|
|
|
} value;
|
|
|
|
} number, *Number;
|
2009-03-23 15:29:13 +00:00
|
|
|
|
2011-02-14 22:13:45 +00:00
|
|
|
#define TOINT_CONVERT_FLOAT 0x1 /* toIntegerNumber() */
|
|
|
|
#define TOINT_TRUNCATE 0x2
|
|
|
|
|
|
|
|
#ifdef O_GMP
|
|
|
|
#define intNumber(n) ((n)->type <= V_MPZ)
|
|
|
|
#else
|
|
|
|
#define intNumber(n) ((n)->type < V_FLOAT)
|
|
|
|
#endif
|
|
|
|
#define floatNumber(n) ((n)->type >= V_FLOAT)
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{ NUM_ERROR = FALSE, /* Syntax error */
|
|
|
|
NUM_OK = TRUE, /* Ok */
|
|
|
|
NUM_FUNDERFLOW = -1, /* Float underflow */
|
|
|
|
NUM_FOVERFLOW = -2, /* Float overflow */
|
|
|
|
NUM_IOVERFLOW = -3 /* Integer overflow */
|
|
|
|
} strnumstat;
|
|
|
|
|
|
|
|
|
2010-06-18 17:48:47 +01:00
|
|
|
#define Arg(N) (PL__t0+((n)-1))
|
|
|
|
#define A1 (PL__t0)
|
|
|
|
#define A2 (PL__t0+1)
|
|
|
|
#define A3 (PL__t0+2)
|
|
|
|
#define A3 (PL__t0+2)
|
|
|
|
#define A4 (PL__t0+3)
|
|
|
|
#define A5 (PL__t0+4)
|
|
|
|
#define A6 (PL__t0+5)
|
|
|
|
#define A7 (PL__t0+6)
|
|
|
|
#define A8 (PL__t0+7)
|
|
|
|
#define A9 (PL__t0+8)
|
|
|
|
#define A10 (PL__t0+9)
|
|
|
|
|
|
|
|
|
2008-12-22 13:49:44 +00:00
|
|
|
/* atom_t macro layer */
|
|
|
|
#define NULL_ATOM ((atom_t)0)
|
2010-05-03 14:26:56 +01:00
|
|
|
#if __YAP_PROLOG__
|
|
|
|
#include "dswiatoms.h"
|
|
|
|
#else
|
2008-12-22 13:49:44 +00:00
|
|
|
#include "atoms.h"
|
2010-05-03 14:26:56 +01:00
|
|
|
#endif
|
2008-12-22 12:02:22 +00:00
|
|
|
#if HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
#define COMMON(X) X
|
|
|
|
|
|
|
|
#ifdef HAVE_LOCALE_H
|
|
|
|
#include <locale.h>
|
|
|
|
#endif
|
|
|
|
#include <setjmp.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#if HAVE_SYS_PARAM_H
|
|
|
|
#include <sys/param.h> //MAXPATHLEN
|
|
|
|
#endif
|
|
|
|
#if __YAP_PROLOG__
|
|
|
|
#include "pl-yap.h"
|
2011-02-03 11:23:12 +00:00
|
|
|
#if _WIN32
|
|
|
|
typedef int pthread_t;
|
|
|
|
#define __WINDOWS__ 1
|
|
|
|
#else
|
|
|
|
#include <pthread.h>
|
|
|
|
#endif
|
2008-12-22 12:02:22 +00:00
|
|
|
#endif
|
2011-02-10 00:01:19 +00:00
|
|
|
typedef uintptr_t PL_atomic_t; /* same a word */
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2011-02-03 11:23:12 +00:00
|
|
|
#define MAXSIGNAL 64
|
|
|
|
|
|
|
|
#define SIG_PROLOG_OFFSET 32 /* Start of Prolog signals */
|
|
|
|
|
|
|
|
#define SIG_EXCEPTION (SIG_PROLOG_OFFSET+0)
|
|
|
|
#ifdef O_ATOMGC
|
|
|
|
#define SIG_ATOM_GC (SIG_PROLOG_OFFSET+1)
|
|
|
|
#endif
|
|
|
|
#define SIG_GC (SIG_PROLOG_OFFSET+2)
|
|
|
|
#ifdef O_PLMT
|
|
|
|
#define SIG_THREAD_SIGNAL (SIG_PROLOG_OFFSET+3)
|
|
|
|
#endif
|
|
|
|
#define SIG_FREECLAUSES (SIG_PROLOG_OFFSET+4)
|
|
|
|
#define SIG_PLABORT (SIG_PROLOG_OFFSET+5)
|
|
|
|
|
2011-03-26 15:17:17 +00:00
|
|
|
#define LOCAL_OVERFLOW (-1)
|
|
|
|
#define GLOBAL_OVERFLOW (-2)
|
|
|
|
#define TRAIL_OVERFLOW (-3)
|
|
|
|
#define ARGUMENT_OVERFLOW (-4)
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
/********************************
|
|
|
|
* UTILITIES *
|
|
|
|
*********************************/
|
|
|
|
#define ROUND(p, n) ((((p) + (n) - 1) & ~((n) - 1)))
|
|
|
|
|
|
|
|
/********************************
|
|
|
|
* HASH TABLES *
|
|
|
|
*********************************/
|
|
|
|
|
|
|
|
#include "pl-table.h"
|
2011-02-10 00:01:19 +00:00
|
|
|
|
|
|
|
/********************************
|
|
|
|
* OS *
|
|
|
|
*********************************/
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
#include "pl-os.h"
|
2011-02-10 00:01:19 +00:00
|
|
|
|
|
|
|
/********************************
|
|
|
|
* Error *
|
|
|
|
*********************************/
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
#include "pl-error.h"
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
/********************************
|
|
|
|
* Files *
|
|
|
|
*********************************/
|
|
|
|
|
|
|
|
#include "pl-files.h"
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
/********************************
|
|
|
|
* BUFFERS *
|
|
|
|
*********************************/
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
#define BUFFER_RING_SIZE 16 /* foreign buffer ring (pl-fli.c) */
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
#include "pl-buffer.h"
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* OPTION LISTS *
|
|
|
|
*******************************/
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
#include "pl-option.h"
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* TEXT PROCESSING *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{ CVT_ok = 0, /* Conversion ok */
|
|
|
|
CVT_wide, /* Conversion needs wide characters */
|
|
|
|
CVT_partial, /* Input list is partial */
|
|
|
|
CVT_nolist, /* Input list is not a list */
|
|
|
|
CVT_nocode, /* List contains a non-code */
|
|
|
|
CVT_nochar /* List contains a non-char */
|
|
|
|
} CVT_status;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{ CVT_status status;
|
|
|
|
word culprit; /* for CVT_nocode/CVT_nochar */
|
|
|
|
} CVT_result;
|
|
|
|
|
2011-02-17 00:57:49 +00:00
|
|
|
#define MAXNEWLINES 5 /* maximum # of newlines in atom */
|
|
|
|
|
|
|
|
#define LONGATOM_CHECK 0x01 /* read/1: error on intptr_t atoms */
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
Operator types. NOTE: if you change OP_*, check operatorTypeToAtom()!
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
|
|
|
|
|
|
#define OP_MAXPRIORITY 1200 /* maximum operator priority */
|
|
|
|
|
|
|
|
#define OP_PREFIX 0
|
|
|
|
#define OP_INFIX 1
|
|
|
|
#define OP_POSTFIX 2
|
|
|
|
#define OP_MASK 0xf
|
|
|
|
|
|
|
|
#define OP_FX (0x10|OP_PREFIX)
|
|
|
|
#define OP_FY (0x20|OP_PREFIX)
|
|
|
|
#define OP_XF (0x30|OP_POSTFIX)
|
|
|
|
#define OP_YF (0x40|OP_POSTFIX)
|
|
|
|
#define OP_XFX (0x50|OP_INFIX)
|
|
|
|
#define OP_XFY (0x60|OP_INFIX)
|
|
|
|
#define OP_YFX (0x70|OP_INFIX)
|
|
|
|
|
|
|
|
#define CHARESCAPE (0x0004) /* module */
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* COMPARE *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
/* Results from comparison operations. Mostly used by compareStandard() */
|
|
|
|
|
|
|
|
#define CMP_ERROR -2 /* Error (out of memory) */
|
|
|
|
#define CMP_LESS -1 /* < */
|
|
|
|
#define CMP_EQUAL 0 /* == */
|
|
|
|
#define CMP_GREATER 1 /* > */
|
|
|
|
#define CMP_NOTEQ 2 /* \== */
|
|
|
|
|
|
|
|
/*******************************
|
|
|
|
* NUMBERVARS *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{ AV_BIND,
|
|
|
|
AV_SKIP,
|
|
|
|
AV_ERROR
|
|
|
|
} av_action;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{ functor_t functor; /* Functor to use ($VAR/1) */
|
|
|
|
av_action on_attvar; /* How to handle attvars */
|
|
|
|
int singletons; /* Write singletons as $VAR('_') */
|
|
|
|
} nv_options;
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2011-02-10 21:14:38 +00:00
|
|
|
/*******************************
|
|
|
|
* GET-PROCEDURE *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
#define GP_FIND 0 /* find anywhere */
|
|
|
|
#define GP_FINDHERE 1 /* find in this module */
|
|
|
|
#define GP_CREATE 2 /* create (in this module) */
|
|
|
|
#define GP_DEFINE 4 /* define a procedure */
|
|
|
|
#define GP_RESOLVE 5 /* find defenition */
|
|
|
|
|
|
|
|
#define GP_HOW_MASK 0x0ff
|
|
|
|
#define GP_NAMEARITY 0x100 /* or'ed mask */
|
|
|
|
#define GP_HIDESYSTEM 0x200 /* hide system module */
|
|
|
|
#define GP_TYPE_QUIET 0x400 /* don't throw errors on wrong types */
|
|
|
|
#define GP_EXISTENCE_ERROR 0x800 /* throw error if proc is not found */
|
|
|
|
#define GP_QUALIFY 0x1000 /* Always module-qualify */
|
|
|
|
|
|
|
|
/* get_functor() */
|
|
|
|
#define GF_EXISTING 1
|
|
|
|
#define GF_PROCEDURE 2 /* check for max arity */
|
|
|
|
|
|
|
|
|
2011-02-27 23:06:10 +00:00
|
|
|
#ifdef O_PLMT
|
|
|
|
|
|
|
|
typedef struct free_chunk *FreeChunk; /* left-over chunk */
|
|
|
|
|
|
|
|
struct free_chunk
|
|
|
|
{ FreeChunk next; /* next of chain */
|
|
|
|
size_t size; /* size of free bit */
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-06-01 21:55:31 +01:00
|
|
|
/*******************************
|
|
|
|
* LIST BUILDING *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
#include "pl-privitf.h"
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
typedef enum
|
|
|
|
{ CLN_NORMAL = 0, /* Normal mode */
|
|
|
|
CLN_ACTIVE, /* Started cleanup */
|
|
|
|
CLN_FOREIGN, /* Foreign hooks */
|
|
|
|
CLN_PROLOG, /* Prolog hooks */
|
|
|
|
CLN_SHARED, /* Unload shared objects */
|
|
|
|
CLN_DATA /* Remaining data */
|
|
|
|
} cleanup_status;
|
|
|
|
|
2011-02-03 11:23:12 +00:00
|
|
|
typedef struct
|
|
|
|
{ char *state; /* system's boot file */
|
|
|
|
char *startup; /* default user startup file */
|
|
|
|
int local; /* default local stack size (K) */
|
|
|
|
int global; /* default global stack size (K) */
|
|
|
|
int trail; /* default trail stack size (K) */
|
|
|
|
char *goal; /* default initialisation goal */
|
|
|
|
char *toplevel; /* default top level goal */
|
|
|
|
bool notty; /* use tty? */
|
|
|
|
char *arch; /* machine/OS we are using */
|
|
|
|
char *home; /* systems home directory */
|
|
|
|
} pl_defaults_t;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{ LDATA_IDLE = 0,
|
|
|
|
LDATA_SIGNALLED,
|
|
|
|
LDATA_ANSWERING,
|
|
|
|
LDATA_ANSWERED
|
|
|
|
} ldata_status_t;
|
|
|
|
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
typedef struct tempfile * TempFile; /* pl-os.c */
|
|
|
|
typedef struct canonical_dir * CanonicalDir; /* pl-os.c */
|
|
|
|
typedef struct on_halt * OnHalt; /* pl-os.c */
|
2010-06-17 00:33:57 +01:00
|
|
|
typedef struct extension_cell * ExtensionCell; /* pl-ext.c */
|
|
|
|
typedef struct initialise_handle * InitialiseHandle;
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2010-02-22 09:35:47 +00:00
|
|
|
|
2009-06-01 21:55:31 +01:00
|
|
|
typedef struct
|
|
|
|
{ unsigned long flags; /* Fast access to some boolean Prolog flags */
|
|
|
|
} pl_features_t;
|
|
|
|
|
|
|
|
#define truePrologFlag(flag) true(&LD->prolog_flag.mask, flag)
|
|
|
|
#define setPrologFlagMask(flag) set(&LD->prolog_flag.mask, flag)
|
|
|
|
#define clearPrologFlagMask(flag) clear(&LD->prolog_flag.mask, flag)
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
// LOCAL variables (heap will get this form LOCAL
|
|
|
|
|
2011-03-26 15:17:17 +00:00
|
|
|
#define FT_ATOM 0 /* atom feature */
|
|
|
|
#define FT_BOOL 1 /* boolean feature (true, false) */
|
|
|
|
#define FT_INTEGER 2 /* integer feature */
|
|
|
|
#define FT_FLOAT 3 /* float feature */
|
|
|
|
#define FT_TERM 4 /* term feature */
|
|
|
|
#define FT_INT64 5 /* passed as int64_t */
|
|
|
|
#define FT_FROM_VALUE 0x0f /* Determine type from value */
|
|
|
|
#define FT_MASK 0x0f /* mask to get type */
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
#define FF_READONLY 0x10 /* feature is read-only */
|
|
|
|
#define FF_KEEP 0x20 /* keep value it already set */
|
|
|
|
|
2009-06-01 21:55:31 +01:00
|
|
|
#define PLFLAG_CHARESCAPE 0x000001 /* handle \ in atoms */
|
|
|
|
#define PLFLAG_GC 0x000002 /* do GC */
|
|
|
|
#define PLFLAG_TRACE_GC 0x000004 /* verbose gc */
|
|
|
|
#define PLFLAG_TTY_CONTROL 0x000008 /* allow for tty control */
|
|
|
|
#define PLFLAG_READLINE 0x000010 /* readline is loaded */
|
|
|
|
#define PLFLAG_DEBUG_ON_ERROR 0x000020 /* start tracer on error */
|
|
|
|
#define PLFLAG_REPORT_ERROR 0x000040 /* print error message */
|
|
|
|
#define PLFLAG_FILE_CASE 0x000080 /* file names are case sensitive */
|
|
|
|
#define PLFLAG_FILE_CASE_PRESERVING 0x000100 /* case preserving file names */
|
|
|
|
#define PLFLAG_DOS_FILE_NAMES 0x000200 /* dos (8+3) file names */
|
|
|
|
#define ALLOW_VARNAME_FUNCTOR 0x000400 /* Read Foo(x) as 'Foo'(x) */
|
|
|
|
#define PLFLAG_ISO 0x000800 /* Strict ISO compliance */
|
|
|
|
#define PLFLAG_OPTIMISE 0x001000 /* -O: optimised compilation */
|
|
|
|
#define PLFLAG_FILEVARS 0x002000 /* Expand $var and ~ in filename */
|
|
|
|
#define PLFLAG_AUTOLOAD 0x004000 /* do autoloading */
|
|
|
|
#define PLFLAG_CHARCONVERSION 0x008000 /* do character-conversion */
|
|
|
|
#define PLFLAG_LASTCALL 0x010000 /* Last call optimization enabled? */
|
|
|
|
#define PLFLAG_EX_ABORT 0x020000 /* abort with exception */
|
|
|
|
#define PLFLAG_BACKQUOTED_STRING 0x040000 /* `a string` */
|
|
|
|
#define PLFLAG_SIGNALS 0x080000 /* Handle signals */
|
|
|
|
#define PLFLAG_DEBUGINFO 0x100000 /* generate debug info */
|
|
|
|
#define PLFLAG_FILEERRORS 0x200000 /* Edinburgh file errors */
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{ OCCURS_CHECK_FALSE = 0,
|
|
|
|
OCCURS_CHECK_TRUE,
|
|
|
|
OCCURS_CHECK_ERROR
|
|
|
|
} occurs_check_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{ atom_t file; /* current source file */
|
|
|
|
int line; /* current line */
|
|
|
|
int linepos; /* position in the line */
|
|
|
|
int64_t character; /* current character location */
|
|
|
|
} source_location;
|
|
|
|
|
|
|
|
typedef struct exception_frame /* PL_throw exception environments */
|
|
|
|
{ struct exception_frame *parent; /* parent frame */
|
|
|
|
jmp_buf exception_jmp_env; /* longjmp environment */
|
|
|
|
} exception_frame;
|
|
|
|
|
2011-03-01 10:26:25 +00:00
|
|
|
/* vsc: global variables */
|
|
|
|
#include "pl-global.h"
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
#define EXCEPTION_GUARDED(code, cleanup) \
|
|
|
|
{ exception_frame __throw_env; \
|
|
|
|
__throw_env.parent = LD->exception.throw_environment; \
|
|
|
|
if ( setjmp(__throw_env.exception_jmp_env) != 0 ) \
|
|
|
|
{ LD->exception.throw_environment = __throw_env.parent; \
|
|
|
|
cleanup; \
|
|
|
|
} else \
|
|
|
|
{ LD->exception.throw_environment = &__throw_env; \
|
|
|
|
code; \
|
|
|
|
LD->exception.throw_environment = __throw_env.parent; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
At times an abort is not allowed because the heap is inconsistent the
|
|
|
|
programmer should call startCritical to start such a code region and
|
|
|
|
endCritical to end it.
|
|
|
|
|
|
|
|
MT/TBD: how to handle this gracefully in the multi-threading case. Does
|
|
|
|
it mean anything?
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
|
|
|
|
|
|
#ifndef TRUE
|
|
|
|
#define TRUE 1
|
|
|
|
#define FALSE 0
|
|
|
|
#endif
|
|
|
|
#define succeed return TRUE
|
|
|
|
#define fail return FALSE
|
|
|
|
#define TRY(goal) if ((goal) == FALSE) fail
|
|
|
|
|
|
|
|
|
2009-02-16 12:25:03 +00:00
|
|
|
extern int fileerrors;
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2009-02-16 12:25:03 +00:00
|
|
|
extern int ttymode;
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
#define CHARESCAPE_FEATURE 0x00001 /* handle \ in atoms */
|
|
|
|
#define GC_FEATURE 0x00002 /* do GC */
|
|
|
|
#define TRACE_GC_FEATURE 0x00004 /* verbose gc */
|
|
|
|
#define TTY_CONTROL_FEATURE 0x00008 /* allow for tty control */
|
|
|
|
#define READLINE_FEATURE 0x00010 /* readline is loaded */
|
|
|
|
#define DEBUG_ON_ERROR_FEATURE 0x00020 /* start tracer on error */
|
|
|
|
#define REPORT_ERROR_FEATURE 0x00040 /* print error message */
|
|
|
|
#define FILE_CASE_FEATURE 0x00080 /* file names are case sensitive */
|
|
|
|
#define FILE_CASE_PRESERVING_FEATURE 0x0100 /* case preserving file names */
|
|
|
|
#define DOS_FILE_NAMES_FEATURE 0x00200 /* dos (8+3) file names */
|
|
|
|
#define ISO_FEATURE 0x00800 /* Strict ISO compliance */
|
|
|
|
#define OPTIMISE_FEATURE 0x01000 /* -O: optimised compilation */
|
|
|
|
#define FILEVARS_FEATURE 0x02000 /* Expand $var and ~ in filename */
|
|
|
|
#define AUTOLOAD_FEATURE 0x04000 /* do autoloading */
|
|
|
|
#define CHARCONVERSION_FEATURE 0x08000 /* do character-conversion */
|
|
|
|
#define LASTCALL_FEATURE 0x10000 /* Last call optimization enabled? */
|
|
|
|
#define EX_ABORT_FEATURE 0x20000 /* abort with exception */
|
|
|
|
#define BACKQUOTED_STRING_FEATURE 0x40000 /* `a string` */
|
|
|
|
#define SIGNALS_FEATURE 0x80000 /* Handle signals */
|
|
|
|
#define DEBUGINFO_FEATURE 0x100000 /* generate debug info */
|
|
|
|
|
|
|
|
int defFeature(const char *c, int f, ...);
|
|
|
|
|
|
|
|
int trueFeature(int f);
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
/*******************************
|
|
|
|
* WAKEUP *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
#define WAKEUP_STATE_WAKEUP 0x1
|
|
|
|
#define WAKEUP_STATE_EXCEPTION 0x2
|
|
|
|
#define WAKEUP_STATE_SKIP_EXCEPTION 0x4
|
|
|
|
|
|
|
|
typedef struct wakeup_state
|
|
|
|
{ fid_t fid; /* foreign frame reference */
|
|
|
|
int flags;
|
|
|
|
} wakeup_state;
|
|
|
|
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
/*******************************
|
|
|
|
* STREAM I/O *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
#define REDIR_MAGIC 0x23a9bef3
|
|
|
|
|
|
|
|
typedef struct redir_context
|
|
|
|
{ int magic; /* REDIR_MAGIC */
|
|
|
|
IOSTREAM *stream; /* temporary output */
|
|
|
|
int is_stream; /* redirect to stream */
|
|
|
|
int redirected; /* output is redirected */
|
|
|
|
term_t term; /* redirect target */
|
|
|
|
int out_format; /* output type */
|
|
|
|
int out_arity; /* 2 for difference-list versions */
|
|
|
|
size_t size; /* size of I/O buffer */
|
|
|
|
char *data; /* data written */
|
|
|
|
char buffer[1024]; /* fast temporary buffer */
|
|
|
|
} redir_context;
|
|
|
|
|
|
|
|
|
|
|
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
Defining built-in predicates using the new interface
|
|
|
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
|
|
|
|
|
|
#define EOS '\0'
|
|
|
|
#define ESC ((char) 27)
|
|
|
|
#define streq(s, q) ((strcmp((s), (q)) == 0))
|
|
|
|
|
|
|
|
#define CHAR_MODE 0 /* See PL_unify_char() */
|
|
|
|
#define CODE_MODE 1
|
|
|
|
#define BYTE_MODE 2
|
|
|
|
|
|
|
|
|
|
|
|
/* string stuff */
|
|
|
|
/*******************************
|
|
|
|
* STRING SUPPORT *
|
|
|
|
*******************************/
|
|
|
|
char * store_string(const char *s);
|
|
|
|
void remove_string(char *s);
|
|
|
|
|
|
|
|
|
|
|
|
/* from foreign interface */
|
|
|
|
/*******************************
|
|
|
|
* FILENAME SUPPORT *
|
|
|
|
*******************************/
|
|
|
|
|
|
|
|
#define PL_FILE_ABSOLUTE 0x01 /* return absolute path */
|
|
|
|
#define PL_FILE_OSPATH 0x02 /* return path in OS notation */
|
|
|
|
#define PL_FILE_SEARCH 0x04 /* use file_search_path */
|
|
|
|
#define PL_FILE_EXIST 0x08 /* demand file to exist */
|
|
|
|
#define PL_FILE_READ 0x10 /* demand read-access */
|
|
|
|
#define PL_FILE_WRITE 0x20 /* demand write-access */
|
|
|
|
#define PL_FILE_EXECUTE 0x40 /* demand execute-access */
|
|
|
|
#define PL_FILE_NOERRORS 0x80 /* do not raise exceptions */
|
|
|
|
|
|
|
|
|
|
|
|
#define PL_FA_ISO (0x20) /* Internal: ISO core predicate */
|
|
|
|
|
|
|
|
/********************************
|
|
|
|
* READ WARNINGS *
|
|
|
|
*********************************/
|
|
|
|
|
|
|
|
#define ReadingSource (source_line_no > 0 && \
|
|
|
|
source_file_name != NULL_ATOM)
|
|
|
|
|
|
|
|
|
|
|
|
#include <pl-text.h>
|
|
|
|
|
|
|
|
typedef double real;
|
|
|
|
|
|
|
|
#define true(s, a) ((s)->flags & (a))
|
|
|
|
#define false(s, a) (!true((s), (a)))
|
|
|
|
#define set(s, a) ((s)->flags |= (a))
|
|
|
|
#define clear(s, a) ((s)->flags &= ~(a))
|
2011-02-12 00:26:28 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
/* should have messages here */
|
|
|
|
#undef DEBUG
|
2008-12-22 12:02:22 +00:00
|
|
|
#define DEBUG(LEVEL, COMMAND)
|
2011-02-12 00:26:28 +00:00
|
|
|
#else
|
|
|
|
#define DEBUG(LEVEL, COMMAND)
|
|
|
|
#endif
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
#define forwards static /* forwards function declarations */
|
|
|
|
|
2009-04-20 22:22:47 +01:00
|
|
|
/* uxnt package interface */
|
|
|
|
#if defined(__YAP_PROLOG__) && defined(__MINGW32__)
|
2011-03-08 00:03:50 +00:00
|
|
|
|
2009-04-20 22:22:47 +01:00
|
|
|
#ifndef __WINDOWS__
|
|
|
|
#define __WINDOWS__ 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
extern int PL_unify_char(term_t chr, int c, int how);
|
|
|
|
extern int PL_get_char(term_t chr, int *c, int eof);
|
|
|
|
extern void PL_cleanup_fork(void);
|
|
|
|
extern int PL_rethrow(void);
|
|
|
|
extern void PL_get_number(term_t l, number *n);
|
|
|
|
extern int PL_unify_atomic(term_t t, PL_atomic_t a);
|
2011-03-11 23:21:23 +00:00
|
|
|
extern int _PL_unify_atomic(term_t t, PL_atomic_t a);
|
|
|
|
extern int _PL_unify_string(term_t t, word w);
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
#define _PL_get_arg(X,Y,Z) PL_get_arg(X,Y,Z)
|
2011-03-11 23:21:23 +00:00
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
extern IOSTREAM ** /* provide access to Suser_input, */
|
|
|
|
_PL_streams(void); /* Suser_output and Suser_error */
|
|
|
|
|
|
|
|
extern int get_atom_text(atom_t atom, PL_chars_t *text);
|
2011-03-03 11:41:21 +00:00
|
|
|
COMMON(int) get_string_text(atom_t atom, PL_chars_t *text ARG_LD);
|
2011-02-10 00:01:19 +00:00
|
|
|
extern char *format_float(double f, char *buf);
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2009-06-01 23:30:08 +01:00
|
|
|
/**** stuff from pl-ctype.c ****/
|
|
|
|
extern IOENC initEncoding(void);
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
/**** stuff from pl-error.c ****/
|
|
|
|
extern int PL_get_bool_ex(term_t t, int *i);
|
|
|
|
extern int PL_get_nchars_ex(term_t t, size_t *len, char **s, unsigned int flags);
|
|
|
|
extern int PL_get_chars_ex(term_t t, char **s, unsigned int flags);
|
|
|
|
extern int PL_get_integer_ex(term_t t, int *i);
|
|
|
|
extern int PL_get_long_ex(term_t t, long *i);
|
|
|
|
extern int PL_get_int64_ex(term_t t, int64_t *i);
|
|
|
|
extern int PL_get_intptr_ex(term_t t, intptr_t *i);
|
|
|
|
extern int PL_get_bool_ex(term_t t, int *i);
|
|
|
|
extern int PL_get_float_ex(term_t t, double *f);
|
|
|
|
extern int PL_get_char_ex(term_t t, int *p, int eof);
|
|
|
|
extern int PL_unify_list_ex(term_t l, term_t h, term_t t);
|
|
|
|
extern int PL_unify_nil_ex(term_t l);
|
|
|
|
extern int PL_get_list_ex(term_t l, term_t h, term_t t);
|
|
|
|
extern int PL_get_nil_ex(term_t l);
|
|
|
|
extern int PL_unify_bool_ex(term_t t, bool val);
|
|
|
|
extern int PL_unify_bool_ex(term_t t, bool val);
|
|
|
|
extern int PL_get_bool_ex(term_t t, int *i);
|
|
|
|
extern int PL_get_integer_ex(term_t t, int *i);
|
2011-02-10 00:01:19 +00:00
|
|
|
extern int PL_get_module_ex(term_t t, module_t *m);
|
2008-12-22 12:02:22 +00:00
|
|
|
|
|
|
|
/**** stuff from pl-file.c ****/
|
|
|
|
extern void initIO(void);
|
|
|
|
|
|
|
|
extern void dieIO(void);
|
|
|
|
extern void protocol(const char *str, size_t n);
|
|
|
|
extern bool readLine(IOSTREAM *in, IOSTREAM *out, char *buffer);
|
|
|
|
extern bool tellString(char **s, size_t *size, IOENC enc);
|
|
|
|
extern bool tellString(char **s, size_t *size, IOENC enc);
|
|
|
|
extern bool toldString(void);
|
|
|
|
|
|
|
|
extern int setupOutputRedirect(term_t to, redir_context *ctx, int redir);
|
|
|
|
extern void discardOutputRedirect(redir_context *ctx);
|
|
|
|
extern int closeOutputRedirect(redir_context *ctx);
|
|
|
|
|
|
|
|
extern IOENC atom_to_encoding(atom_t);
|
|
|
|
|
|
|
|
void closeFiles(int);
|
|
|
|
atom_t PrologPrompt(void);
|
|
|
|
word pl_current_input(term_t);
|
|
|
|
word pl_current_output(term_t);
|
|
|
|
word pl_exists_file(term_t name);
|
|
|
|
char *DirName(const char *f, char *dir);
|
|
|
|
void outOfCore(void);
|
|
|
|
|
|
|
|
word pl_noprotocol(void);
|
|
|
|
|
|
|
|
IOSTREAM *PL_current_input(void);
|
|
|
|
IOSTREAM *PL_current_output(void);
|
2009-04-22 17:33:49 +01:00
|
|
|
|
2011-03-02 23:19:39 +00:00
|
|
|
COMMON(int) stricmp(const char *s1, const char *s2);
|
|
|
|
|
|
|
|
COMMON(word) textToString(PL_chars_t *text);
|
|
|
|
|
|
|
|
COMMON(int) reportStreamError(IOSTREAM *s);
|
2011-02-17 00:57:49 +00:00
|
|
|
|
|
|
|
extern int digitValue(int b, int c);
|
2009-07-21 04:56:16 +01:00
|
|
|
|
2009-04-22 17:33:49 +01:00
|
|
|
PL_EXPORT(int) PL_unify_stream(term_t t, IOSTREAM *s);
|
|
|
|
PL_EXPORT(int) PL_unify_stream_or_alias(term_t t, IOSTREAM *s);
|
|
|
|
PL_EXPORT(int) PL_get_stream_handle(term_t t, IOSTREAM **s);
|
|
|
|
PL_EXPORT(void) PL_write_prompt(int);
|
|
|
|
PL_EXPORT(int) PL_release_stream(IOSTREAM *s);
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2011-02-17 00:57:49 +00:00
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
COMMON(atom_t) fileNameStream(IOSTREAM *s);
|
|
|
|
COMMON(int) streamStatus(IOSTREAM *s);
|
|
|
|
|
|
|
|
COMMON(int) getOutputStream(term_t t, IOSTREAM **s);
|
|
|
|
COMMON(void) pushOutputContext(void);
|
|
|
|
COMMON(void) popOutputContext(void);
|
|
|
|
COMMON(int) getSingleChar(IOSTREAM *s, int signals);
|
|
|
|
|
|
|
|
COMMON(void) prompt1(atom_t prompt);
|
|
|
|
COMMON(atom_t) encoding_to_atom(IOENC enc);
|
|
|
|
COMMON(int) pl_see(term_t f);
|
|
|
|
COMMON(int) pl_seen(void);
|
|
|
|
|
2011-02-17 00:57:49 +00:00
|
|
|
COMMON(int) unicode_separator(pl_wchar_t c);
|
|
|
|
COMMON(word) pl_raw_read(term_t term);
|
|
|
|
COMMON(word) pl_raw_read2(term_t stream, term_t term);
|
|
|
|
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
/**** stuff from pl-error.c ****/
|
|
|
|
extern void outOfCore(void);
|
|
|
|
extern void fatalError(const char *fm, ...);
|
|
|
|
extern int callProlog(void * module, term_t goal, int flags, term_t *ex);
|
|
|
|
extern word notImplemented(char *name, int arity);
|
|
|
|
|
|
|
|
/**** stuff from pl-ctype.c ****/
|
|
|
|
extern void initCharTypes(void);
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
/**** stuff from pl-fmt.c ****/
|
|
|
|
COMMON(word) pl_current_format_predicate(term_t chr, term_t descr,
|
|
|
|
control_t h);
|
|
|
|
COMMON(intptr_t) lengthList(term_t list, int errors);
|
|
|
|
COMMON(word) pl_format_predicate(term_t chr, term_t descr);
|
|
|
|
COMMON(word) pl_format(term_t fmt, term_t args);
|
|
|
|
COMMON(word) pl_format3(term_t s, term_t fmt, term_t args);
|
|
|
|
|
2010-05-04 15:17:08 +01:00
|
|
|
/**** stuff from pl-glob.c ****/
|
|
|
|
extern void initGlob(void);
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
/**** stuff from pl-os.c ****/
|
|
|
|
extern void cleanupOs(void);
|
2009-06-02 00:10:31 +01:00
|
|
|
extern void PL_clock_wait_ticks(long waited);
|
2008-12-22 12:02:22 +00:00
|
|
|
extern void setOSFeatures(void);
|
|
|
|
extern uintptr_t FreeMemory(void);
|
|
|
|
extern uint64_t _PL_Random(void);
|
|
|
|
extern void RemoveTemporaryFiles(void);
|
|
|
|
extern int Pause(real t);
|
|
|
|
char *findExecutable(const char *av0, char *buffer);
|
|
|
|
|
2011-03-08 00:03:50 +00:00
|
|
|
extern void setOSPrologFlags(void);
|
|
|
|
extern void setRandom(unsigned int *seedp);
|
|
|
|
extern char *canoniseFileName(char *path);
|
|
|
|
extern char *canonisePath(char *path);
|
|
|
|
extern void PL_changed_cwd(void);
|
|
|
|
extern struct tm *LocalTime(long *t, struct tm *r);
|
|
|
|
extern size_t getenv3(const char *name, char *buf, size_t len);
|
|
|
|
extern int Setenv(char *name, char *value);
|
|
|
|
extern int Unsetenv(char *name);
|
|
|
|
extern int System(char *cmd);
|
|
|
|
extern bool expandVars(const char *pattern, char *expanded, int maxlen);
|
2009-06-01 23:30:08 +01:00
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
/**** SWI stuff (emulated in pl-yap.c) ****/
|
|
|
|
extern int writeAtomToStream(IOSTREAM *so, atom_t at);
|
|
|
|
extern int valueExpression(term_t t, Number r ARG_LD);
|
|
|
|
extern word lookupAtom(const char *s, size_t len);
|
|
|
|
extern atom_t lookupUCSAtom(const pl_wchar_t *s, size_t len);
|
|
|
|
extern int toIntegerNumber(Number n, int flags);
|
|
|
|
extern int get_atom_ptr_text(Atom a, PL_chars_t *text);
|
2010-05-05 16:31:08 +01:00
|
|
|
extern int warning(const char *fm, ...);
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2009-07-21 04:56:16 +01:00
|
|
|
/**** stuff from pl-files.c ****/
|
|
|
|
void initFiles(void);
|
2010-02-22 09:35:47 +00:00
|
|
|
int RemoveFile(const char *path);
|
|
|
|
int PL_get_file_name(term_t n, char **namep, int flags);
|
2011-02-10 00:01:19 +00:00
|
|
|
PL_EXPORT(int) PL_get_file_nameW(term_t n, wchar_t **name, int flags);
|
|
|
|
|
|
|
|
COMMON(int) unifyTime(term_t t, time_t time);
|
2009-07-21 04:56:16 +01:00
|
|
|
|
2011-03-08 00:03:50 +00:00
|
|
|
COMMON(char) digitName(int n, int sm);
|
2011-02-15 19:24:15 +00:00
|
|
|
|
2010-08-04 11:37:12 +01:00
|
|
|
/**** stuff from pl-utf8.c ****/
|
|
|
|
size_t utf8_strlen(const char *s, size_t len);
|
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
/**** stuff from pl-write.c ****/
|
|
|
|
COMMON(char *) varName(term_t var, char *buf);
|
|
|
|
COMMON(int) writeUCSAtom(IOSTREAM *fd, atom_t atom, int flags);
|
|
|
|
COMMON(word) pl_nl1(term_t stream);
|
|
|
|
COMMON(word) pl_nl(void);
|
|
|
|
COMMON(int) writeAttributeMask(atom_t name);
|
|
|
|
COMMON(word) pl_write_term(term_t term, term_t options);
|
|
|
|
COMMON(word) pl_write_term3(term_t stream,
|
|
|
|
term_t term, term_t options);
|
|
|
|
COMMON(word) pl_print(term_t term);
|
|
|
|
COMMON(word) pl_write2(term_t stream, term_t term);
|
|
|
|
COMMON(word) pl_writeq2(term_t stream, term_t term);
|
|
|
|
COMMON(word) pl_print2(term_t stream, term_t term);
|
|
|
|
COMMON(word) pl_writeln(term_t term);
|
|
|
|
COMMON(word) pl_write_canonical2(term_t stream, term_t term);
|
|
|
|
|
|
|
|
|
2009-06-02 00:01:30 +01:00
|
|
|
/* empty stub */
|
2011-03-02 09:19:35 +00:00
|
|
|
extern void setPrologFlag(const char *name, int flags, ...);
|
2011-03-26 15:17:17 +00:00
|
|
|
extern int PL_set_prolog_flag(const char *name, int flags, ...);
|
2011-03-02 09:19:35 +00:00
|
|
|
|
|
|
|
extern install_t PL_install_readline(void);
|
2009-06-02 00:01:30 +01:00
|
|
|
|
2011-02-10 00:01:19 +00:00
|
|
|
COMMON(int) saveWakeup(wakeup_state *state, int forceframe ARG_LD);
|
|
|
|
COMMON(void) restoreWakeup(wakeup_state *state ARG_LD);
|
|
|
|
|
|
|
|
COMMON(int) priorityOperator(Module m, atom_t atom);
|
|
|
|
COMMON(int) currentOperator(Module m, atom_t name, int kind,
|
|
|
|
int *type, int *priority);
|
|
|
|
COMMON(int) numberVars(term_t t, nv_options *opts, int n ARG_LD);
|
|
|
|
|
|
|
|
COMMON(Buffer) codes_or_chars_to_buffer(term_t l, unsigned int flags,
|
|
|
|
int wide, CVT_result *status);
|
|
|
|
|
2011-03-02 09:19:35 +00:00
|
|
|
COMMON(bool) systemMode(bool accept);
|
|
|
|
|
2011-03-26 15:17:17 +00:00
|
|
|
|
|
|
|
COMMON(void) initPrologFlagTable(void);
|
|
|
|
COMMON(void) initPrologFlags(void);
|
|
|
|
COMMON(int) raiseStackOverflow(int overflow);
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
static inline word
|
|
|
|
setBoolean(int *flag, term_t old, term_t new)
|
|
|
|
{ if ( !PL_unify_bool_ex(old, *flag) ||
|
|
|
|
!PL_get_bool_ex(new, flag) )
|
|
|
|
fail;
|
|
|
|
|
|
|
|
succeed;
|
|
|
|
}
|
|
|
|
|
2011-03-03 11:41:21 +00:00
|
|
|
COMMON(int) getInputStream__LD(term_t t, IOSTREAM **s ARG_LD);
|
|
|
|
|
|
|
|
COMMON(int) PL_get_atom__LD(term_t t1, atom_t *a ARG_LD);
|
|
|
|
COMMON(int) PL_get_atom_ex__LD(term_t t, atom_t *a ARG_LD);
|
|
|
|
COMMON(int) PL_get_text__LD(term_t l, PL_chars_t *text, int flags ARG_LD);
|
|
|
|
COMMON(int) PL_is_variable__LD(term_t t ARG_LD);
|
|
|
|
COMMON(term_t) PL_new_term_ref__LD(ARG1_LD);
|
|
|
|
COMMON(void) PL_put_term__LD(term_t t1, term_t t2 ARG_LD);
|
|
|
|
COMMON(int) PL_unify_atom__LD(term_t t, atom_t a ARG_LD);
|
|
|
|
COMMON(int) PL_unify_integer__LD(term_t t1, intptr_t i ARG_LD);
|
|
|
|
|
2011-03-26 15:17:17 +00:00
|
|
|
COMMON(word) pl_get_prolog_flag(term_t key, term_t value);
|
|
|
|
COMMON(word) pl_prolog_flag5(term_t key, term_t value, word scope, word access, word type, control_t h);
|
|
|
|
COMMON(foreign_t) pl_prolog_flag(term_t name, term_t value, control_t h);
|
|
|
|
|
2011-03-03 11:41:21 +00:00
|
|
|
/* inlines that need ARG_LD */
|
|
|
|
static inline intptr_t
|
|
|
|
skip_list(Word l, Word *tailp ARG_LD) {
|
|
|
|
return (intptr_t)YAP_SkipList(l, tailp);
|
|
|
|
}
|
|
|
|
|
2008-12-22 12:02:22 +00:00
|
|
|
static inline word
|
2011-03-03 11:41:21 +00:00
|
|
|
valHandle__LD(term_t r ARG_LD)
|
|
|
|
{
|
|
|
|
return (word)YAP_GetFromSlot(r);
|
|
|
|
}
|
2008-12-22 12:02:22 +00:00
|
|
|
|
2011-03-03 11:41:21 +00:00
|
|
|
static inline void *allocHeap__LD(size_t n ARG_LD)
|
|
|
|
{
|
|
|
|
return YAP_AllocSpaceFromYap(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void freeHeap__LD(void *mem, size_t n ARG_LD)
|
|
|
|
{
|
|
|
|
YAP_FreeSpaceFromYap(mem);
|
2008-12-22 12:02:22 +00:00
|
|
|
}
|
|
|
|
|
2011-03-03 11:41:21 +00:00
|
|
|
|
2011-02-10 21:14:38 +00:00
|
|
|
extern const PL_extension PL_predicates_from_ctype[];
|
|
|
|
extern const PL_extension PL_predicates_from_file[];
|
|
|
|
extern const PL_extension PL_predicates_from_files[];
|
|
|
|
extern const PL_extension PL_predicates_from_glob[];
|
2011-02-12 18:42:44 +00:00
|
|
|
extern const PL_extension PL_predicates_from_read[];
|
2011-03-09 13:05:03 +00:00
|
|
|
extern const PL_extension PL_predicates_from_tai[];
|
|
|
|
extern const PL_extension PL_predicates_from_write[];
|
2011-03-26 15:17:17 +00:00
|
|
|
extern const PL_extension PL_predicates_from_prologflag[];
|
2011-02-10 21:14:38 +00:00
|
|
|
|