Deleted Added
sdiff udiff text old ( 42634 ) new ( 42679 )
full compact
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#ifdef TESTMAIN
11#include <stdio.h>
12#include <stdlib.h>
13#else
14#include <stand.h>
15#endif
16#ifdef __i386__
17#include <machine/cpufunc.h>
18#endif
19#include "ficl.h"
20
21/*
22******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith
23*/
24
25UNS64 ficlLongMul(UNS32 x, UNS32 y)
26{
27 UNS64 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
38UNSQR ficlLongDiv(UNS64 q, UNS32 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
52void 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
64void *ficlMalloc (size_t size)
65{
66 return malloc(size);
67}
68
69void ficlFree (void *p)
70{
71 free(p);
72}
73
74#ifdef __i386__
75/*
76 * pc! ( port# c -- )
77 * Store a byte to I/O port number port#
78 */
79void
80pc_store(FICL_VM *pVM)
81{
82 u_char c;
83 u_int32_t port;
84
85 port=stackPopUNS32(pVM->pStack);
86 c=(u_char)stackPopINT32(pVM->pStack);
87 outb(port,c);
88}
89
90/*
91 * pc@ ( port# -- c )
92 * Fetch a byte from I/O port number port#
93 */
94void
95pc_fetch(FICL_VM *pVM)
96{
97 u_char c;
98 u_int32_t port;
99
100 port=stackPopUNS32(pVM->pStack);
101 c=inb(port);
102 stackPushINT32(pVM->pStack,c);
103}
104#endif
105
106/*
107** Stub function for dictionary access control - does nothing
108** by default, user can redefine to guarantee exclusive dict
109** access to a single thread for updates. All dict update code
110** is guaranteed to be bracketed as follows:
111** ficlLockDictionary(TRUE);
112** <code that updates dictionary>
113** ficlLockDictionary(FALSE);
114**
115** Returns zero if successful, nonzero if unable to acquire lock
116** befor timeout (optional - could also block forever)
117*/
118#if FICL_MULTITHREAD
119int ficlLockDictionary(short fLock)
120{
121 IGNORE(fLock);
122 return 0;
123}
124#endif /* FICL_MULTITHREAD */
125
126