1 /*************************************************************************
2 *									 *
3 *	 YAP Prolog 	@(#)c_interface.h	2.2			 *
4 *	Yap Prolog was developed at NCCUP - Universidade do Porto	 *
5 *									 *
6 * Copyright L.Damas, V.S.Costa and Universidade do Porto 1985-1997	 *
7 *									 *
8 **************************************************************************
9 *									 *
10 * File:		yap_structs.h						 *
11 * Last rev:	15/5/2000						 *
12 * mods:									 *
13 * comments:	Data structures and defines used in the Interface	 *
14 *									 *
15 *************************************************************************/
16 
17 #if  defined(__STDC__) || defined(_MSC_VER)
18 
19 #define PROTO(X,ARGS) X ARGS
20 #define CONST const
21 
22 #else
23 
24 #define PROTO(X,ARGS) X()
25 #define CONST /* empty */
26 #endif
27 
28 #ifndef HAS_YAP_H
29 
30 /* Type definitions */
31 
32 #if _WIN64
33 typedef unsigned long long YAP_CELL;
34 #else
35 typedef unsigned long YAP_CELL;
36 #endif
37 
38 typedef int YAP_Bool;
39 
40 typedef YAP_CELL YAP_Term;
41 
42 typedef YAP_CELL YAP_Arity;
43 
44 typedef YAP_Term YAP_Module;
45 
46 typedef struct FunctorEntry *YAP_Functor;
47 
48 typedef struct AtomEntry *YAP_Atom;
49 
50 #if _WIN64
51 typedef long long int YAP_Int;
52 
53 typedef unsigned long long int  YAP_UInt;
54 
55 #else
56 typedef long int  YAP_Int;
57 
58 typedef unsigned long int  YAP_UInt;
59 #endif
60 
61 typedef double YAP_Float;
62 
63 #ifndef TRUE
64 #define TRUE	1
65 #endif
66 #ifndef FALSE
67 #define FALSE	0
68 #endif
69 
70 #endif
71 
72 #define YAP_BOOT_FROM_PROLOG       0
73 #define YAP_BOOT_FROM_SAVED_CODE   1
74 #define YAP_BOOT_FROM_SAVED_STACKS 2
75 #define YAP_FULL_BOOT_FROM_PROLOG  4
76 #define YAP_BOOT_ERROR            -1
77 
78 #define YAP_WRITE_QUOTED		0
79 #define YAP_WRITE_HANDLE_VARS		1
80 #define YAP_WRITE_IGNORE_OPS		2
81 
82 #define YAP_CONSULT_MODE           0
83 #define YAP_RECONSULT_MODE         1
84 
85 typedef struct {
86   /* if NON-NULL, path where we can find the saved state */
87   char *SavedState;
88   /* if NON-0, minimal size for Heap or Code Area */
89   unsigned long int HeapSize;
90   /* if NON-0, maximal size for Heap or Code Area */
91   unsigned long int MaxHeapSize;
92   /* if NON-0, minimal size for Local+Global Stack */
93   unsigned long int StackSize;
94   /* if NON-0, maximal size for Local+Global Stack */
95   unsigned long int MaxStackSize;
96   unsigned long int MaxGlobalSize;
97   /* if NON-0, minimal size for Trail */
98   unsigned long int TrailSize;
99   /* if NON-0, maximal size for Trail */
100   unsigned long int MaxTrailSize;
101   /* if NON-0, minimal size for AttributeVarStack */
102   unsigned long int AttsSize;
103   /* if NON-0, maximal size for AttributeVarStack */
104   unsigned long int MaxAttsSize;
105   /* if NON-NULL, value for YAPLIBDIR */
106   char *YapLibDir;
107   /* if NON-NULL, name for a Prolog file to use when booting  */
108   char *YapPrologBootFile;
109   /* if NON-NULL, name for a Prolog file to use when initialising  */
110   char *YapPrologInitFile;
111   /* if NON-NULL, name for a Prolog file to consult before entering top-level  */
112   char *YapPrologRCFile;
113   /* if NON-NULL, a goal to run before top-level  */
114   char *YapPrologGoal;
115   /* if NON-NULL, a goal to run as top-level  */
116   char *YapPrologTopLevelGoal;
117   /* if NON-NULL, a path to extend file-search-path   */
118   char *YapPrologAddPath;
119   /* if previous NON-NULL and TRUE, halt after consulting that file  */
120   int HaltAfterConsult;
121   /* ignore .yaprc, .prolog.ini, etc. files.  */
122   int FastBoot;
123   /* the next field only interest YAPTAB */
124   /* if NON-0, maximum size for Table Space */
125   unsigned long int MaxTableSpaceSize;
126   /* the next three fields only interest YAPOR, but we keep them so that
127      users don't need to recompile DLL in order to use YAPOR */
128   /* if NON-0, number of workers we want to have (default=1) */
129   unsigned long int NumberWorkers;
130   /* if NON-0, manage the inner scheduler loop (default = 10) */
131   unsigned long int SchedulerLoop;
132   /* if NON-0, say how long to keep nodes (default = 3) */
133   unsigned long int DelayedReleaseLoad;
134   /* end of YAPOR fields */
135   /* whether Prolog should handle interrupts */
136   int PrologShouldHandleInterrupts;
137   /* flag for JIT mode */
138   int ExecutionMode;
139   /* number of arguments that Prolog will see */
140   int Argc;
141   /* array of arguments as seen by Prolog */
142   char **Argv;
143   /* QuietMode */
144   int QuietMode;
145 #ifdef MYDDAS_MYSQL
146   /* If any myddas option was given */
147   short myddas;
148   /* MYDDAS Fields */
149   char *myddas_user;
150   char *myddas_pass;
151   char *myddas_db;
152   char *myddas_host;
153 #endif
154   /* errornumber */
155   int ErrorNo;
156   /* errorstring */
157   char *ErrorCause;
158 } YAP_init_args;
159 
160 
161 /* from thread.h */
162 typedef struct {
163   unsigned long int		    ssize;
164   unsigned long int		    tsize;
165   YAP_Term		   alias;
166   int		   (*cancel)(int);
167 } YAP_thread_attr;
168 
169 typedef struct YAP_pred_entry *YAP_PredEntryPtr;
170 
171 /* this should be opaque to the user */
172 typedef struct {
173   unsigned long  b;
174   struct yami *p;
175 } YAP_dogoalinfo;
176 
177 typedef int  (*YAP_agc_hook)(void *_Atom);
178 
179 typedef void  (*YAP_halt_hook)(int exit_code, void *closure);
180 
181 /********* execution mode ***********************/
182 
183 typedef enum
184   {
185     YAPC_INTERPRETED,         /* interpreted */
186     YAPC_MIXED_MODE_USER,       /* mixed mode only for user predicates */
187     YAPC_MIXED_MODE_ALL,        /* mixed mode for all predicates */
188     YAPC_COMPILE_USER,          /* compile all user predicates*/
189     YAPC_COMPILE_ALL          /* compile all predicates */
190   } yapc_exec_mode;
191 
192 /********* YAP C-Flags ***********************/
193 
194 typedef enum
195   {
196     YAPC_ENABLE_GC,                 /* enable or disable garbage collection */
197     YAPC_ENABLE_AGC                 /* enable or disable atom garbage collection */
198   } yap_flag_t;
199 
200