This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/include/YapDefs.h

313 lines
8.3 KiB
C
Raw Normal View History

/*************************************************************************
* *
* YAP Prolog @(#)c_interface.h 2.2 *
* Yap Prolog was developed at NCCUP - Universidade do Porto *
* *
* Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997 *
* *
**************************************************************************
* *
* File: yap_structs.h *
* Last rev: 15/5/2000 *
* mods: *
* comments: Data structures and defines used in the Interface *
* *
*************************************************************************/
2014-05-25 20:48:06 +01:00
#ifndef _YAPDEFS_H
2014-05-25 20:48:06 +01:00
#define _YAPDEFS_H 1
2014-05-25 20:48:06 +01:00
#include <stdlib.h>
2011-03-02 23:19:39 +00:00
#ifdef YAP_H
/* if Yap.h is available, just reexport */
2014-05-25 20:48:06 +01:00
#define YAP_CELL CELL
2011-03-02 23:19:39 +00:00
2014-05-25 20:48:06 +01:00
#define YAP_Term Term
2011-03-02 23:19:39 +00:00
2014-05-25 20:48:06 +01:00
typedef UInt YAP_Arity;
2011-03-02 23:19:39 +00:00
typedef Term YAP_Module;
2014-05-25 20:48:06 +01:00
#define YAP_Functor Functor
2011-03-02 23:19:39 +00:00
2014-05-25 20:48:06 +01:00
#define YAP_Atom Atom
2011-03-02 23:19:39 +00:00
2014-05-25 20:48:06 +01:00
#define YAP_Int Int
2011-03-02 23:19:39 +00:00
2014-05-25 20:48:06 +01:00
#define YAP_UInt UInt
2011-03-02 23:19:39 +00:00
2014-05-25 20:48:06 +01:00
#define YAP_Float Float
2011-03-02 23:19:39 +00:00
typedef int YAP_Bool;
typedef yhandle_t YAP_handle_t;
2014-06-11 19:36:50 +01:00
2014-05-25 20:48:06 +01:00
#define YAP_PredEntryPtr struct pred_entry *
#define YAP_UserCPred CPredicate
#define YAP_agc_hook Agc_hook
2011-03-02 23:19:39 +00:00
#else
/* Type definitions */
2010-05-06 16:32:41 +01:00
#if _WIN64
typedef unsigned long long YAP_CELL;
#else
typedef unsigned long YAP_CELL;
#endif
typedef int YAP_Bool;
typedef YAP_CELL YAP_Term;
2010-05-10 10:22:18 +01:00
typedef YAP_CELL YAP_Arity;
typedef YAP_Term YAP_Module;
typedef struct FunctorEntry *YAP_Functor;
typedef struct AtomEntry *YAP_Atom;
2010-05-06 16:35:53 +01:00
#if _WIN64
2010-05-06 16:37:44 +01:00
typedef long long int YAP_Int;
2010-05-06 16:35:53 +01:00
2010-05-06 16:37:44 +01:00
typedef unsigned long long int YAP_UInt;
2010-05-06 16:35:53 +01:00
#else
typedef long int YAP_Int;
typedef unsigned long int YAP_UInt;
2010-05-06 16:35:53 +01:00
#endif
typedef double YAP_Float;
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
2014-06-11 19:36:50 +01:00
typedef YAP_Int YAP_handle_t;
2014-05-25 20:48:06 +01:00
typedef struct YAP_pred_entry *YAP_PredEntryPtr;
typedef YAP_Bool (* YAP_UserCPred)(void);
typedef int (*YAP_agc_hook)(void *_Atom);
2013-10-03 11:25:56 +01:00
#include "YapError.h"
#endif
2014-05-25 20:48:06 +01:00
typedef struct YAP_thread_attr_struct {
size_t ssize;
size_t tsize;
size_t sysize;
int (*cancel)(int thread);
YAP_Term egoal, alias;
} YAP_thread_attr;
2014-06-11 19:36:50 +01:00
#ifdef YAP_H
#include <threads.h>
#endif
2014-05-25 20:48:06 +01:00
2011-10-27 11:38:22 +01:00
typedef enum {
YAP_TAG_ATT = 0x1,
YAP_TAG_UNBOUND = 0x2,
YAP_TAG_REF = 0x4,
YAP_TAG_PAIR = 0x8,
YAP_TAG_ATOM = 0x10,
YAP_TAG_INT = 0x20,
YAP_TAG_LONG_INT = 0x40,
YAP_TAG_BIG_INT = 0x80,
YAP_TAG_RATIONAL = 0x100,
YAP_TAG_FLOAT = 0x200,
YAP_TAG_OPAQUE = 0x400,
YAP_TAG_APPL = 0x800,
YAP_TAG_DBREF = 0x1000
} YAP_tag_t;
#define YAP_BOOT_FROM_PROLOG 0
#define YAP_BOOT_FROM_SAVED_CODE 1
#define YAP_BOOT_FROM_SAVED_STACKS 2
#define YAP_FULL_BOOT_FROM_PROLOG 4
#define YAP_BOOT_DONE_BEFOREHAND 8
#define YAP_BOOT_ERROR -1
#define YAP_WRITE_QUOTED 1
#define YAP_WRITE_IGNORE_OPS 2
2013-01-18 15:23:59 +00:00
#define YAP_WRITE_HANDLE_VARS 4
#define YAP_WRITE_USE_PORTRAY 8
2013-01-18 15:23:59 +00:00
#define YAP_WRITE_HANDLE_CYCLES 0x20
#define YAP_WRITE_BACKQUOTE_STRING 0x80
#define YAP_WRITE_ATTVAR_NONE 0x100
#define YAP_WRITE_ATTVAR_DOTS 0x200
#define YAP_WRITE_ATTVAR_PORTRAY 0x400
#define YAP_WRITE_BLOB_PORTRAY 0x800
#define YAP_CONSULT_MODE 0
#define YAP_RECONSULT_MODE 1
2014-04-29 18:17:23 +01:00
typedef struct yap_boot_params {
/* if NON-NULL, path where we can find the saved state */
char *SavedState;
/* if NON-0, minimal size for Heap or Code Area */
unsigned long int HeapSize;
/* if NON-0, maximal size for Heap or Code Area */
unsigned long int MaxHeapSize;
/* if NON-0, minimal size for Local+Global Stack */
unsigned long int StackSize;
/* if NON-0, maximal size for Local+Global Stack */
unsigned long int MaxStackSize;
unsigned long int MaxGlobalSize;
/* if NON-0, minimal size for Trail */
unsigned long int TrailSize;
/* if NON-0, maximal size for Trail */
unsigned long int MaxTrailSize;
/* if NON-0, minimal size for AttributeVarStack */
unsigned long int AttsSize;
/* if NON-0, maximal size for AttributeVarStack */
unsigned long int MaxAttsSize;
/* if NON-NULL, value for YAPLIBDIR */
char *YapLibDir;
/* if NON-NULL, name for a Prolog file to use when booting */
char *YapPrologBootFile;
/* if NON-NULL, name for a Prolog file to use when initialising */
char *YapPrologInitFile;
/* if NON-NULL, name for a Prolog file to consult before entering top-level */
char *YapPrologRCFile;
/* if NON-NULL, a goal to run before top-level */
char *YapPrologGoal;
/* if NON-NULL, a goal to run as top-level */
char *YapPrologTopLevelGoal;
/* if NON-NULL, a path to extend file-search-path */
char *YapPrologAddPath;
/* if previous NON-NULL and TRUE, halt after consulting that file */
int HaltAfterConsult;
/* ignore .yaprc, .prolog.ini, etc. files. */
int FastBoot;
/* the next field only interest YAPTAB */
/* if NON-0, maximum size for Table Space */
unsigned long int MaxTableSpaceSize;
/* the next three fields only interest YAPOR, but we keep them so that
users don't need to recompile DLL in order to use YAPOR */
/* if NON-0, number of workers we want to have (default=1) */
2009-08-20 02:23:52 +01:00
unsigned long int NumberWorkers;
/* if NON-0, manage the inner scheduler loop (default = 10) */
2009-08-20 02:23:52 +01:00
unsigned long int SchedulerLoop;
/* if NON-0, say how long to keep nodes (default = 3) */
2009-08-20 02:23:52 +01:00
unsigned long int DelayedReleaseLoad;
/* end of YAPOR fields */
/* whether Prolog should handle interrupts */
int PrologShouldHandleInterrupts;
2009-04-08 00:46:34 +01:00
/* flag for JIT mode */
int ExecutionMode;
/* number of arguments that Prolog will see */
int Argc;
/* array of arguments as seen by Prolog */
char **Argv;
/* QuietMode */
int QuietMode;
2012-06-22 09:56:01 +01:00
/* nf: Begin ypp preprocessor code */
#define YAP_MAX_YPP_DEFS 100
char *def_var[YAP_MAX_YPP_DEFS];
char *def_value[YAP_MAX_YPP_DEFS];
int def_c;
/* End preprocessor code */
#ifdef MYDDAS_MYSQL
/* If any myddas option was given */
short myddas;
/* MYDDAS Fields */
char *myddas_user;
char *myddas_pass;
char *myddas_db;
char *myddas_host;
#endif
/* errornumber */
int ErrorNo;
/* errorstring */
char *ErrorCause;
} YAP_init_args;
2014-04-29 18:43:17 +01:00
#ifdef YAP_H
2014-04-29 18:17:23 +01:00
Int Yap_InitDefaults( YAP_init_args *init_args, char saved_state[] );
2014-04-29 18:43:17 +01:00
#endif
/* this should be opaque to the user */
typedef struct {
2014-07-16 17:56:09 +01:00
unsigned long b; //> choice-point at entry
YAP_Int CurSlot; //> variables at entry
YAP_Int EndSlot; //> variables at successful execution
struct yami *p; //> Program Counter at entry
struct yami *cp; //> Continuation PC at entry
} YAP_dogoalinfo;
typedef void (*YAP_halt_hook)(int exit_code, void *closure);
2011-07-27 16:50:14 +01:00
typedef YAP_Int YAP_opaque_tag_t;
typedef int (*YAP_Opaque_CallOnFail)(void *);
2011-07-27 16:50:14 +01:00
typedef int (*YAP_Opaque_CallOnWrite)(void *, YAP_opaque_tag_t, void *, int);
typedef YAP_Int (*YAP_Opaque_CallOnGCMark)(YAP_opaque_tag_t, void *, YAP_Term *, YAP_Int);
2011-12-13 18:14:33 +00:00
typedef int (*YAP_Opaque_CallOnGCRelocate)(YAP_opaque_tag_t, void *, YAP_Term *, YAP_Int);
typedef struct YAP_opaque_handler_struct {
2011-07-27 16:50:14 +01:00
YAP_Opaque_CallOnFail fail_handler;
YAP_Opaque_CallOnWrite write_handler;
YAP_Opaque_CallOnGCMark mark_handler;
2011-12-13 18:14:33 +00:00
YAP_Opaque_CallOnGCRelocate relocate_handler;
} YAP_opaque_handler_t;
2009-04-08 00:46:34 +01:00
/********* execution mode ***********************/
typedef enum
{
YAPC_INTERPRETED, /* interpreted */
YAPC_MIXED_MODE_USER, /* mixed mode only for user predicates */
YAPC_MIXED_MODE_ALL, /* mixed mode for all predicates */
YAPC_COMPILE_USER, /* compile all user predicates*/
YAPC_COMPILE_ALL /* compile all predicates */
} yapc_exec_mode;
/********* encoding ***********************/
typedef enum
{ PL_ENC_UNKNOWN = 0, /* invalid/unknown */
PL_ENC_OCTET, /* raw 8 bit input */
PL_ENC_ASCII, /* US-ASCII (0..127) */
PL_ENC_ISO_LATIN_1, /* ISO Latin-1 (0..256) */
PL_ENC_ANSI, /* default (multibyte) codepage */
PL_ENC_UTF8,
PL_ENC_UNICODE_BE, /* big endian unicode file */
PL_ENC_UNICODE_LE, /* little endian unicode file */
PL_ENC_WCHAR /* pl_wchar_t */
} PL_IOENC;
2010-08-31 04:25:56 +01:00
/********* YAP C-Flags ***********************/
typedef enum
{
YAPC_ENABLE_GC, /* enable or disable garbage collection */
YAPC_ENABLE_AGC /* enable or disable atom garbage collection */
} yap_flag_t;
2014-09-22 18:13:35 +01:00
typedef enum yap_enum_reset_t {
YAP_EXEC_ABSMI = 0,
YAP_FULL_RESET = 1,
YAP_RESET_FROM_RESTORE = 3
} yap_reset_t;
\
2014-06-11 19:36:50 +01:00
2014-05-25 20:48:06 +01:00
#endif /* _YAPDEFS_H */