/*******************************************************************1** s y s d e p . c2** Forth Inspired Command Language3** Author: John Sadler ([email protected])4** Created: 16 Oct 19975** Implementations of FICL external interface functions...6**7*******************************************************************/8910#ifdef TESTMAIN11#include <stdio.h>12#include <stdlib.h>13#else14#include <stand.h>15#endif16#include "ficl.h"1718/*19******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith20*/2122#if PORTABLE_LONGMULDIV == 023DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)24{25DPUNS q;26uint64_t qx;2728qx = (uint64_t)x * (uint64_t) y;2930q.hi = (uint32_t)( qx >> 32 );31q.lo = (uint32_t)( qx & 0xFFFFFFFFL);3233return q;34}3536UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)37{38UNSQR result;39uint64_t qx, qh;4041qh = q.hi;42qx = (qh << 32) | q.lo;4344result.quot = qx / y;45result.rem = qx % y;4647return result;48}49#endif5051void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)52{53IGNORE(pVM);5455while(*msg != 0)56putchar(*(msg++));57if (fNewline)58putchar('\n');5960return;61}6263void *ficlMalloc (size_t size)64{65return malloc(size);66}6768void *ficlRealloc (void *p, size_t size)69{70return realloc(p, size);71}7273void ficlFree (void *p)74{75free(p);76}777879/*80** Stub function for dictionary access control - does nothing81** by default, user can redefine to guarantee exclusive dict82** access to a single thread for updates. All dict update code83** is guaranteed to be bracketed as follows:84** ficlLockDictionary(TRUE);85** <code that updates dictionary>86** ficlLockDictionary(FALSE);87**88** Returns zero if successful, nonzero if unable to acquire lock89** befor timeout (optional - could also block forever)90*/91#if FICL_MULTITHREAD92int ficlLockDictionary(short fLock)93{94IGNORE(fLock);95return 0;96}97#endif /* FICL_MULTITHREAD */9899100