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