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