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