/*******************************************************************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#include "../x86/sysdep.c"1920/*21******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith22*/2324#if PORTABLE_LONGMULDIV == 025DPUNS ficlLongMul(FICL_UNS x, FICL_UNS y)26{27DPUNS q;28uint64_t qx;2930qx = (uint64_t)x * (uint64_t) y;3132q.hi = (uint32_t)( qx >> 32 );33q.lo = (uint32_t)( qx & 0xFFFFFFFFL);3435return q;36}3738UNSQR ficlLongDiv(DPUNS q, FICL_UNS y)39{40UNSQR result;41uint64_t qx, qh;4243qh = q.hi;44qx = (qh << 32) | q.lo;4546result.quot = qx / y;47result.rem = qx % y;4849return result;50}51#endif5253void ficlTextOut(FICL_VM *pVM, char *msg, int fNewline)54{55IGNORE(pVM);5657while(*msg != 0)58putchar((unsigned char)*(msg++));59if (fNewline)60putchar('\n');6162return;63}6465void *ficlMalloc (size_t size)66{67return malloc(size);68}6970void *ficlRealloc (void *p, size_t size)71{72return realloc(p, size);73}7475void ficlFree (void *p)76{77free(p);78}798081/*82** Stub function for dictionary access control - does nothing83** by default, user can redefine to guarantee exclusive dict84** access to a single thread for updates. All dict update code85** 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 lock91** befor timeout (optional - could also block forever)92*/93#if FICL_MULTITHREAD94int ficlLockDictionary(short fLock)95{96IGNORE(fLock);97return 0;98}99#endif /* FICL_MULTITHREAD */100101102