xref: /freebsd/stand/ficl/arm/sysdep.c (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*******************************************************************
2 ** s y s d e p . c
3 ** Forth Inspired Command Language
4 ** Author: John Sadler (john_sadler@alum.mit.edu)
5 ** Created: 16 Oct 1997
6 ** Implementations of FICL external interface functions...
7 **
8 *******************************************************************/
9 
10 
11 #ifdef TESTMAIN
12 #include <stdio.h>
13 #include <stdlib.h>
14 #else
15 #include <stand.h>
16 #endif
17 #include "ficl.h"
18 
19 /*
20 *******************  FreeBSD  P O R T   B E G I N S   H E R E ******************** Michael Smith
21 */
22 
23 #if PORTABLE_LONGMULDIV == 0
24 DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)
25 {
26     DPUNS q;
27     uint64_t qx;
28 
29     qx = (uint64_t)x * (uint64_t) y;
30 
31     q.hi = (uint32_t)( qx >> 32 );
32     q.lo = (uint32_t)( qx & 0xFFFFFFFFL);
33 
34     return q;
35 }
36 
37 UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)
38 {
39     UNSQR result;
40     uint64_t qx, qh;
41 
42     qh = q.hi;
43     qx = (qh << 32) | q.lo;
44 
45     result.quot = qx / y;
46     result.rem  = qx % y;
47 
48     return result;
49 }
50 #endif
51 
52 void  ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)
53 {
54     IGNORE(pVM);
55 
56     while(*msg != 0)
57 	putchar(*(msg++));
58     if (fNewline)
59 	putchar('\n');
60 
61    return;
62 }
63 
64 void *ficlMalloc (size_t size)
65 {
66     return malloc(size);
67 }
68 
69 void *ficlRealloc (void *p, size_t size)
70 {
71     return realloc(p, size);
72 }
73 
74 void  ficlFree   (void *p)
75 {
76     free(p);
77 }
78 
79 
80 /*
81 ** Stub function for dictionary access control - does nothing
82 ** by default, user can redefine to guarantee exclusive dict
83 ** access to a single thread for updates. All dict update code
84 ** is guaranteed to be bracketed as follows:
85 ** ficlLockDictionary(TRUE);
86 ** <code that updates dictionary>
87 ** ficlLockDictionary(FALSE);
88 **
89 ** Returns zero if successful, nonzero if unable to acquire lock
90 ** befor timeout (optional - could also block forever)
91 */
92 #if FICL_MULTITHREAD
93 int ficlLockDictionary(short fLock)
94 {
95 	IGNORE(fLock);
96 	return 0;
97 }
98 #endif /* FICL_MULTITHREAD */
99