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