added -y/--side-by-side option
[dfdiff.git] / sys / boot / ficl / ia64 / sysdep.h
blob94f3ac1c1185da85fcdded45ce0bbfd8433f0877
1 /*******************************************************************
2 s y s d e p . h
3 ** Forth Inspired Command Language
4 ** Author: John Sadler (john_sadler@alum.mit.edu)
5 ** Created: 16 Oct 1997
6 ** Ficl system dependent types and prototypes...
7 **
8 ** Note: Ficl also depends on the use of "assert" when
9 ** FICL_ROBUST is enabled. This may require some consideration
10 ** in firmware systems since assert often
11 ** assumes stderr/stdout.
12 ** $Id: sysdep.h,v 1.11 2001/12/05 07:21:34 jsadler Exp $
13 *******************************************************************/
15 ** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu)
16 ** All rights reserved.
18 ** Get the latest Ficl release at http://ficl.sourceforge.net
20 ** I am interested in hearing from anyone who uses ficl. If you have
21 ** a problem, a success story, a defect, an enhancement request, or
22 ** if you would like to contribute to the ficl release, please
23 ** contact me by email at the address above.
25 ** L I C E N S E and D I S C L A I M E R
26 **
27 ** Redistribution and use in source and binary forms, with or without
28 ** modification, are permitted provided that the following conditions
29 ** are met:
30 ** 1. Redistributions of source code must retain the above copyright
31 ** notice, this list of conditions and the following disclaimer.
32 ** 2. Redistributions in binary form must reproduce the above copyright
33 ** notice, this list of conditions and the following disclaimer in the
34 ** documentation and/or other materials provided with the distribution.
36 ** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
37 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 ** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
39 ** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
40 ** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
41 ** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
42 ** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 ** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
44 ** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
45 ** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 ** SUCH DAMAGE.
48 ** $Id: sysdep.h,v 1.6 2001-04-26 21:41:55-07 jsadler Exp jsadler $
52 * $FreeBSD: src/sys/boot/ficl/ia64/sysdep.h,v 1.3 2002/05/16 21:21:57 trhodes Exp $
53 * $DragonFly: src/sys/boot/ficl/ia64/sysdep.h,v 1.1 2003/11/10 06:08:34 dillon Exp $
56 #if !defined (__SYSDEP_H__)
57 #define __SYSDEP_H__
59 #include <sys/types.h>
61 #include <stddef.h> /* size_t, NULL */
62 #include <setjmp.h>
63 #include <assert.h>
65 #if !defined IGNORE /* Macro to silence unused param warnings */
66 #define IGNORE(x) &x
67 #endif
70 ** TRUE and FALSE for C boolean operations, and
71 ** portable 32 bit types for CELLs
72 **
74 #if !defined TRUE
75 #define TRUE 1
76 #endif
77 #if !defined FALSE
78 #define FALSE 0
79 #endif
82 ** System dependent data type declarations...
84 #if !defined INT32
85 #define INT32 int
86 #endif
88 #if !defined UNS32
89 #define UNS32 unsigned int
90 #endif
92 #if !defined UNS16
93 #define UNS16 unsigned short
94 #endif
96 #if !defined UNS8
97 #define UNS8 unsigned char
98 #endif
100 #if !defined NULL
101 #define NULL ((void *)0)
102 #endif
105 ** FICL_UNS and FICL_INT must have the same size as a void* on
106 ** the target system. A CELL is a union of void*, FICL_UNS, and
107 ** FICL_INT.
108 ** (11/2000: same for FICL_FLOAT)
110 #if !defined FICL_INT
111 #define FICL_INT long
112 #endif
114 #if !defined FICL_UNS
115 #define FICL_UNS unsigned long
116 #endif
118 #if !defined FICL_FLOAT
119 #define FICL_FLOAT float
120 #endif
123 ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL
125 #if !defined BITS_PER_CELL
126 #define BITS_PER_CELL 64
127 #endif
129 #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64))
130 Error!
131 #endif
133 typedef struct
135 FICL_UNS hi;
136 FICL_UNS lo;
137 } DPUNS;
139 typedef struct
141 FICL_UNS quot;
142 FICL_UNS rem;
143 } UNSQR;
145 typedef struct
147 FICL_INT hi;
148 FICL_INT lo;
149 } DPINT;
151 typedef struct
153 FICL_INT quot;
154 FICL_INT rem;
155 } INTQR;
159 ** B U I L D C O N T R O L S
162 #if !defined (FICL_MINIMAL)
163 #define FICL_MINIMAL 0
164 #endif
165 #if (FICL_MINIMAL)
166 #define FICL_WANT_SOFTWORDS 0
167 #define FICL_WANT_FILE 0
168 #define FICL_WANT_FLOAT 0
169 #define FICL_WANT_USER 0
170 #define FICL_WANT_LOCALS 0
171 #define FICL_WANT_DEBUGGER 0
172 #define FICL_WANT_OOP 0
173 #define FICL_PLATFORM_EXTEND 0
174 #define FICL_MULTITHREAD 0
175 #define FICL_ROBUST 0
176 #define FICL_EXTENDED_PREFIX 0
177 #endif
180 ** FICL_PLATFORM_EXTEND
181 ** Includes words defined in ficlCompilePlatform
183 #if !defined (FICL_PLATFORM_EXTEND)
184 #define FICL_PLATFORM_EXTEND 1
185 #endif
189 ** FICL_WANT_FILE
190 ** Includes the FILE and FILE-EXT wordset and associated code. Turn this off if you do not
191 ** have a filesystem!
192 ** Contributed by Larry Hastings
194 #if !defined (FICL_WANT_FILE)
195 #define FICL_WANT_FILE 0
196 #endif
199 ** FICL_WANT_FLOAT
200 ** Includes a floating point stack for the VM, and words to do float operations.
201 ** Contributed by Guy Carver
203 #if !defined (FICL_WANT_FLOAT)
204 #define FICL_WANT_FLOAT 0
205 #endif
208 ** FICL_WANT_DEBUGGER
209 ** Inludes a simple source level debugger
211 #if !defined (FICL_WANT_DEBUGGER)
212 #define FICL_WANT_DEBUGGER 1
213 #endif
216 ** FICL_EXTENDED_PREFIX enables a bunch of extra prefixes in prefix.c and prefix.fr (if
217 ** included as part of softcore.c)
219 #if !defined FICL_EXTENDED_PREFIX
220 #define FICL_EXTENDED_PREFIX 0
221 #endif
224 ** User variables: per-instance variables bound to the VM.
225 ** Kinda like thread-local storage. Could be implemented in a
226 ** VM private dictionary, but I've chosen the lower overhead
227 ** approach of an array of CELLs instead.
229 #if !defined FICL_WANT_USER
230 #define FICL_WANT_USER 1
231 #endif
233 #if !defined FICL_USER_CELLS
234 #define FICL_USER_CELLS 16
235 #endif
238 ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and
239 ** a private dictionary for local variable compilation.
241 #if !defined FICL_WANT_LOCALS
242 #define FICL_WANT_LOCALS 1
243 #endif
245 /* Max number of local variables per definition */
246 #if !defined FICL_MAX_LOCALS
247 #define FICL_MAX_LOCALS 16
248 #endif
251 ** FICL_WANT_OOP
252 ** Inludes object oriented programming support (in softwords)
253 ** OOP support requires locals and user variables!
255 #if !(FICL_WANT_LOCALS) || !(FICL_WANT_USER)
256 #if !defined (FICL_WANT_OOP)
257 #define FICL_WANT_OOP 0
258 #endif
259 #endif
261 #if !defined (FICL_WANT_OOP)
262 #define FICL_WANT_OOP 1
263 #endif
266 ** FICL_WANT_SOFTWORDS
267 ** Controls inclusion of all softwords in softcore.c
269 #if !defined (FICL_WANT_SOFTWORDS)
270 #define FICL_WANT_SOFTWORDS 1
271 #endif
274 ** FICL_MULTITHREAD enables dictionary mutual exclusion
275 ** wia the ficlLockDictionary system dependent function.
276 ** Note: this implementation is experimental and poorly
277 ** tested. Further, it's unnecessary unless you really
278 ** intend to have multiple SESSIONS (poor choice of name
279 ** on my part) - that is, threads that modify the dictionary
280 ** at the same time.
282 #if !defined FICL_MULTITHREAD
283 #define FICL_MULTITHREAD 0
284 #endif
287 ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be
288 ** defined in C in sysdep.c. Use this if you cannot easily
289 ** generate an inline asm definition
291 #if !defined (PORTABLE_LONGMULDIV)
292 #define PORTABLE_LONGMULDIV 0
293 #endif
296 ** INLINE_INNER_LOOP causes the inner interpreter to be inline code
297 ** instead of a function call. This is mainly because MS VC++ 5
298 ** chokes with an internal compiler error on the function version.
299 ** in release mode. Sheesh.
301 #if !defined INLINE_INNER_LOOP
302 #if defined _DEBUG
303 #define INLINE_INNER_LOOP 0
304 #else
305 #define INLINE_INNER_LOOP 1
306 #endif
307 #endif
310 ** FICL_ROBUST enables bounds checking of stacks and the dictionary.
311 ** This will detect stack over and underflows and dictionary overflows.
312 ** Any exceptional condition will result in an assertion failure.
313 ** (As generated by the ANSI assert macro)
314 ** FICL_ROBUST == 1 --> stack checking in the outer interpreter
315 ** FICL_ROBUST == 2 also enables checking in many primitives
318 #if !defined FICL_ROBUST
319 #define FICL_ROBUST 2
320 #endif
323 ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of
324 ** a new virtual machine's stacks, unless overridden at
325 ** create time.
327 #if !defined FICL_DEFAULT_STACK
328 #define FICL_DEFAULT_STACK 128
329 #endif
332 ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate
333 ** for the system dictionary by default. The value
334 ** can be overridden at startup time as well.
335 ** FICL_DEFAULT_ENV specifies the number of cells to allot
336 ** for the environment-query dictionary.
338 #if !defined FICL_DEFAULT_DICT
339 #define FICL_DEFAULT_DICT 12288
340 #endif
342 #if !defined FICL_DEFAULT_ENV
343 #define FICL_DEFAULT_ENV 260
344 #endif
347 ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in
348 ** the dictionary search order. See Forth DPANS sec 16.3.3
349 ** (file://dpans16.htm#16.3.3)
351 #if !defined FICL_DEFAULT_VOCS
352 #define FICL_DEFAULT_VOCS 16
353 #endif
356 ** FICL_MAX_PARSE_STEPS controls the size of an array in the FICL_SYSTEM structure
357 ** that stores pointers to parser extension functions. I would never expect to have
358 ** more than 8 of these, so that's the default limit. Too many of these functions
359 ** will probably exact a nasty performance penalty.
361 #if !defined FICL_MAX_PARSE_STEPS
362 #define FICL_MAX_PARSE_STEPS 8
363 #endif
366 ** FICL_ALIGN is the power of two to which the dictionary
367 ** pointer address must be aligned. This value is usually
368 ** either 1 or 2, depending on the memory architecture
369 ** of the target system; 2 is safe on any 16 or 32 bit
370 ** machine. 3 would be appropriate for a 64 bit machine.
372 #if !defined FICL_ALIGN
373 #define FICL_ALIGN 3
374 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1)
375 #endif
378 ** System dependent routines --
379 ** edit the implementations in sysdep.c to be compatible
380 ** with your runtime environment...
381 ** ficlTextOut sends a NULL terminated string to the
382 ** default output device - used for system error messages
383 ** ficlMalloc and ficlFree have the same semantics as malloc and free
384 ** in standard C
385 ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned
386 ** product
387 ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient
388 ** and remainder
390 struct vm;
391 void ficlTextOut(struct vm *pVM, char *msg, int fNewline);
392 void *ficlMalloc (size_t size);
393 void ficlFree (void *p);
394 void *ficlRealloc(void *p, size_t size);
396 ** Stub function for dictionary access control - does nothing
397 ** by default, user can redefine to guarantee exclusive dict
398 ** access to a single thread for updates. All dict update code
399 ** must be bracketed as follows:
400 ** ficlLockDictionary(TRUE);
401 ** <code that updates dictionary>
402 ** ficlLockDictionary(FALSE);
404 ** Returns zero if successful, nonzero if unable to acquire lock
405 ** before timeout (optional - could also block forever)
407 ** NOTE: this function must be implemented with lock counting
408 ** semantics: nested calls must behave properly.
410 #if FICL_MULTITHREAD
411 int ficlLockDictionary(short fLock);
412 #else
413 #define ficlLockDictionary(x) 0 /* ignore */
414 #endif
417 ** 64 bit integer math support routines: multiply two UNS32s
418 ** to get a 64 bit product, & divide the product by an UNS32
419 ** to get an UNS32 quotient and remainder. Much easier in asm
420 ** on a 32 bit CPU than in C, which usually doesn't support
421 ** the double length result (but it should).
423 DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y);
424 UNSQR ficlLongDiv(DPUNS q, FICL_UNS y);
428 ** FICL_HAVE_FTRUNCATE indicates whether the current OS supports
429 ** the ftruncate() function (available on most UNIXes). This
430 ** function is necessary to provide the complete File-Access wordset.
432 #if !defined (FICL_HAVE_FTRUNCATE)
433 #define FICL_HAVE_FTRUNCATE 0
434 #endif
437 #endif /*__SYSDEP_H__*/