1161454Simp/******************************************************************* 2161454Simp** s y s d e p . c 3161454Simp** Forth Inspired Command Language 4161454Simp** Author: John Sadler (john_sadler@alum.mit.edu) 5161454Simp** Created: 16 Oct 1997 6161454Simp** Implementations of FICL external interface functions... 7161454Simp** 8161454Simp*******************************************************************/ 9161454Simp 10161454Simp/* $FreeBSD: releng/10.2/sys/boot/ficl/arm/sysdep.c 161454 2006-08-18 21:41:43Z imp $ */ 11161454Simp 12161454Simp#ifdef TESTMAIN 13161454Simp#include <stdio.h> 14161454Simp#include <stdlib.h> 15161454Simp#else 16161454Simp#include <stand.h> 17161454Simp#endif 18161454Simp#include "ficl.h" 19161454Simp 20161454Simp/* 21161454Simp******************* FreeBSD P O R T B E G I N S H E R E ******************** Michael Smith 22161454Simp*/ 23161454Simp 24161454Simp#if PORTABLE_LONGMULDIV == 0 25161454SimpDPUNS ficlLongMul(FICL_UNS x, FICL_UNS y) 26161454Simp{ 27161454Simp DPUNS q; 28161454Simp u_int64_t qx; 29161454Simp 30161454Simp qx = (u_int64_t)x * (u_int64_t) y; 31161454Simp 32161454Simp q.hi = (u_int32_t)( qx >> 32 ); 33161454Simp q.lo = (u_int32_t)( qx & 0xFFFFFFFFL); 34161454Simp 35161454Simp return q; 36161454Simp} 37161454Simp 38161454SimpUNSQR ficlLongDiv(DPUNS q, FICL_UNS y) 39161454Simp{ 40161454Simp UNSQR result; 41161454Simp u_int64_t qx, qh; 42161454Simp 43161454Simp qh = q.hi; 44161454Simp qx = (qh << 32) | q.lo; 45161454Simp 46161454Simp result.quot = qx / y; 47161454Simp result.rem = qx % y; 48161454Simp 49161454Simp return result; 50161454Simp} 51161454Simp#endif 52161454Simp 53161454Simpvoid ficlTextOut(FICL_VM *pVM, char *msg, int fNewline) 54161454Simp{ 55161454Simp IGNORE(pVM); 56161454Simp 57161454Simp while(*msg != 0) 58161454Simp putchar(*(msg++)); 59161454Simp if (fNewline) 60161454Simp putchar('\n'); 61161454Simp 62161454Simp return; 63161454Simp} 64161454Simp 65161454Simpvoid *ficlMalloc (size_t size) 66161454Simp{ 67161454Simp return malloc(size); 68161454Simp} 69161454Simp 70161454Simpvoid *ficlRealloc (void *p, size_t size) 71161454Simp{ 72161454Simp return realloc(p, size); 73161454Simp} 74161454Simp 75161454Simpvoid ficlFree (void *p) 76161454Simp{ 77161454Simp free(p); 78161454Simp} 79161454Simp 80161454Simp 81161454Simp/* 82161454Simp** Stub function for dictionary access control - does nothing 83161454Simp** by default, user can redefine to guarantee exclusive dict 84161454Simp** access to a single thread for updates. All dict update code 85161454Simp** is guaranteed to be bracketed as follows: 86161454Simp** ficlLockDictionary(TRUE); 87161454Simp** <code that updates dictionary> 88161454Simp** ficlLockDictionary(FALSE); 89161454Simp** 90161454Simp** Returns zero if successful, nonzero if unable to acquire lock 91161454Simp** befor timeout (optional - could also block forever) 92161454Simp*/ 93161454Simp#if FICL_MULTITHREAD 94161454Simpint ficlLockDictionary(short fLock) 95161454Simp{ 96161454Simp IGNORE(fLock); 97161454Simp return 0; 98161454Simp} 99161454Simp#endif /* FICL_MULTITHREAD */ 100161454Simp 101161454Simp 102