Merge from vendor branch READLINE:
[dragonfly.git] / sys / boot / ficl / alpha / sysdep.c
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  * $FreeBSD: src/sys/boot/ficl/alpha/sysdep.c,v 1.8 2000/06/02 20:07:55 dcs Exp $
12  * $DragonFly: src/sys/boot/ficl/alpha/Attic/sysdep.c,v 1.3 2003/11/10 06:08:33 dillon Exp $
13  */
14
15 #ifdef TESTMAIN
16 #include <stdio.h>
17 #include <stdlib.h>
18 #else
19 #include <stand.h>
20 #endif
21 #include "ficl.h"
22
23 /*
24 *******************  FreeBSD  P O R T   B E G I N S   H E R E ******************** Michael Smith
25 */
26
27 #if PORTABLE_LONGMULDIV == 0
28 DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)
29 {
30     DPUNS q;
31     u_int64_t qx;
32
33     qx = (u_int64_t)x * (u_int64_t) y;
34
35     q.hi = (u_int32_t)( qx >> 32 );
36     q.lo = (u_int32_t)( qx & 0xFFFFFFFFL);
37
38     return q;
39 }
40
41 UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)
42 {
43     UNSQR result;
44     u_int64_t qx, qh;
45
46     qh = q.hi;
47     qx = (qh << 32) | q.lo;
48
49     result.quot = qx / y;
50     result.rem  = qx % y;
51
52     return result;
53 }
54 #endif
55
56 void  ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)
57 {
58     IGNORE(pVM);
59
60     while(*msg != 0)
61         putchar(*(msg++));
62     if (fNewline)
63         putchar('\n');
64
65    return;
66 }
67
68 void *ficlMalloc (size_t size)
69 {
70     return malloc(size);
71 }
72
73 void *ficlRealloc (void *p, size_t size)
74 {
75     return realloc(p, size);
76 }
77
78 void  ficlFree   (void *p)
79 {
80     free(p);
81 }
82
83
84 /*
85 ** Stub function for dictionary access control - does nothing
86 ** by default, user can redefine to guarantee exclusive dict
87 ** access to a single thread for updates. All dict update code
88 ** is guaranteed to be bracketed as follows:
89 ** ficlLockDictionary(TRUE);
90 ** <code that updates dictionary>
91 ** ficlLockDictionary(FALSE);
92 **
93 ** Returns zero if successful, nonzero if unable to acquire lock
94 ** befor timeout (optional - could also block forever)
95 */
96 #if FICL_MULTITHREAD
97 int ficlLockDictionary(short fLock)
98 {
99         IGNORE(fLock);
100         return 0;
101 }
102 #endif /* FICL_MULTITHREAD */
103
104