1 /*******************************************************************
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...
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.
13 *******************************************************************/
15 ** N O T I C E -- DISCLAIMER OF WARRANTY
17 ** Ficl is freeware. Use it in any way that you like, with
18 ** the understanding that the code is not supported.
20 ** Any third party may reproduce, distribute, or modify the ficl
21 ** software code or any derivative works thereof without any
22 ** compensation or license, provided that the author information
23 ** and this disclaimer text are retained in the source code files.
24 ** The ficl software code is provided on an "as is" basis without
25 ** warranty of any kind, including, without limitation, the implied
26 ** warranties of merchantability and fitness for a particular purpose
27 ** and their equivalents under the laws of any jurisdiction.
29 ** I am interested in hearing from anyone who uses ficl. If you have
30 ** a problem, a success story, a defect, an enhancement request, or
31 ** if you would like to contribute to the ficl release (yay!), please
32 ** send me email at the address above.
35 /* $FreeBSD: src/sys/boot/ficl/i386/sysdep.h,v 1.5 1999/11/23 15:24:30 dcs Exp $ */
36 /* $DragonFly: src/sys/boot/ficl/i386/sysdep.h,v 1.2 2003/06/17 04:28:18 dillon Exp $ */
38 #if !defined (__SYSDEP_H__)
41 #include <sys/types.h>
43 #include <stddef.h> /* size_t, NULL */
48 #if !defined IGNORE /* Macro to silence unused param warnings */
54 ** TRUE and FALSE for C boolean operations, and
55 ** portable 32 bit types for CELLs
67 ** System dependent data type declarations...
74 #define UNS32 unsigned long
78 #define UNS16 unsigned short
82 #define UNS8 unsigned char
86 #define NULL ((void *)0)
90 ** FICL_UNS and FICL_INT must have the same size as a void* on
91 ** the target system. A CELL is a union of void*, FICL_UNS, and
95 #define FICL_INT INT32
99 #define FICL_UNS UNS32
103 ** Ficl presently supports values of 32 and 64 for BITS_PER_CELL
105 #if !defined BITS_PER_CELL
106 #define BITS_PER_CELL 32
109 #if ((BITS_PER_CELL != 32) && (BITS_PER_CELL != 64))
140 ** FICL_MULTITHREAD enables dictionary mutual exclusion
141 ** wia the ficlLockDictionary system dependent function.
143 #if !defined FICL_MULTITHREAD
144 #define FICL_MULTITHREAD 0
148 ** PORTABLE_LONGMULDIV causes ficlLongMul and ficlLongDiv to be
149 ** defined in C in sysdep.c. Use this if you cannot easily
150 ** generate an inline asm definition
152 #if !defined (PORTABLE_LONGMULDIV)
153 #define PORTABLE_LONGMULDIV 0
158 ** INLINE_INNER_LOOP causes the inner interpreter to be inline code
159 ** instead of a function call. This is mainly because MS VC++ 5
160 ** chokes with an internal compiler error on the function version.
161 ** in release mode. Sheesh.
163 #if !defined INLINE_INNER_LOOP
165 #define INLINE_INNER_LOOP 0
167 #define INLINE_INNER_LOOP 1
172 ** FICL_ROBUST enables bounds checking of stacks and the dictionary.
173 ** This will detect stack over and underflows and dictionary overflows.
174 ** Any exceptional condition will result in an assertion failure.
175 ** (As generated by the ANSI assert macro)
176 ** FICL_ROBUST == 1 --> stack checking in the outer interpreter
177 ** FICL_ROBUST == 2 also enables checking in many primitives
180 #if !defined FICL_ROBUST
181 #define FICL_ROBUST 2
185 ** FICL_DEFAULT_STACK Specifies the default size (in CELLs) of
186 ** a new virtual machine's stacks, unless overridden at
189 #if !defined FICL_DEFAULT_STACK
190 #define FICL_DEFAULT_STACK 128
194 ** FICL_DEFAULT_DICT specifies the number of CELLs to allocate
195 ** for the system dictionary by default. The value
196 ** can be overridden at startup time as well.
197 ** FICL_DEFAULT_ENV specifies the number of cells to allot
198 ** for the environment-query dictionary.
200 #if !defined FICL_DEFAULT_DICT
201 #define FICL_DEFAULT_DICT 12288
204 #if !defined FICL_DEFAULT_ENV
205 #define FICL_DEFAULT_ENV 260
209 ** FICL_DEFAULT_VOCS specifies the maximum number of wordlists in
210 ** the dictionary search order. See Forth DPANS sec 16.3.3
211 ** (file://dpans16.htm#16.3.3)
213 #if !defined FICL_DEFAULT_VOCS
214 #define FICL_DEFAULT_VOCS 16
218 ** User variables: per-instance variables bound to the VM.
219 ** Kinda like thread-local storage. Could be implemented in a
220 ** VM private dictionary, but I've chosen the lower overhead
221 ** approach of an array of CELLs instead.
223 #if !defined FICL_WANT_USER
224 #define FICL_WANT_USER 1
227 #if !defined FICL_USER_CELLS
228 #define FICL_USER_CELLS 16
232 ** FICL_WANT_LOCALS controls the creation of the LOCALS wordset and
233 ** a private dictionary for local variable compilation.
235 #if !defined FICL_WANT_LOCALS
236 #define FICL_WANT_LOCALS 1
239 /* Max number of local variables per definition */
240 #if !defined FICL_MAX_LOCALS
241 #define FICL_MAX_LOCALS 16
245 ** FICL_ALIGN is the power of two to which the dictionary
246 ** pointer address must be aligned. This value is usually
247 ** either 1 or 2, depending on the memory architecture
248 ** of the target system; 2 is safe on any 16 or 32 bit
249 ** machine. 3 would be appropriate for a 64 bit machine.
251 #if !defined FICL_ALIGN
253 #define FICL_ALIGN_ADD ((1 << FICL_ALIGN) - 1)
257 ** System dependent routines --
258 ** edit the implementations in sysdep.c to be compatible
259 ** with your runtime environment...
260 ** ficlTextOut sends a NULL terminated string to the
261 ** default output device - used for system error messages
262 ** ficlMalloc and ficlFree have the same semantics as malloc and free
264 ** ficlLongMul multiplies two UNS32s and returns a 64 bit unsigned
266 ** ficlLongDiv divides an UNS64 by an UNS32 and returns UNS32 quotient
270 void ficlTextOut(struct vm *pVM, char *msg, int fNewline);
271 void *ficlMalloc (size_t size);
272 void ficlFree (void *p);
273 void *ficlRealloc(void *p, size_t size);
275 ** Stub function for dictionary access control - does nothing
276 ** by default, user can redefine to guarantee exclusive dict
277 ** access to a single thread for updates. All dict update code
278 ** must be bracketed as follows:
279 ** ficlLockDictionary(TRUE);
280 ** <code that updates dictionary>
281 ** ficlLockDictionary(FALSE);
283 ** Returns zero if successful, nonzero if unable to acquire lock
284 ** before timeout (optional - could also block forever)
286 ** NOTE: this function must be implemented with lock counting
287 ** semantics: nested calls must behave properly.
290 int ficlLockDictionary(short fLock);
292 #define ficlLockDictionary(x) 0 /* ignore */
296 ** 64 bit integer math support routines: multiply two UNS32s
297 ** to get a 64 bit product, & divide the product by an UNS32
298 ** to get an UNS32 quotient and remainder. Much easier in asm
299 ** on a 32 bit CPU than in C, which usually doesn't support
300 ** the double length result (but it should).
302 DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y);
303 UNSQR ficlLongDiv(DPUNS q, FICL_UNS y);
305 #endif /*__SYSDEP_H__*/