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#ifdef __i386__ 16#include <machine/cpufunc.h> 17#endif 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
| 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#ifdef __i386__ 16#include <machine/cpufunc.h> 17#endif 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 *ficlRealloc (void *p, size_t size) 70{ 71 return realloc(p, size); 72} 73
|
69void ficlFree (void *p) 70{ 71 free(p); 72} 73
| 74void ficlFree (void *p) 75{ 76 free(p); 77} 78
|
| 79#ifndef TESTMAIN
|
74#ifdef __i386__ 75/* 76 * outb ( port# c -- ) 77 * Store a byte to I/O port number port# 78 */ 79void 80ficlOutb(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 * inb ( port# -- c ) 92 * Fetch a byte from I/O port number port# 93 */ 94void 95ficlInb(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
| 80#ifdef __i386__ 81/* 82 * outb ( port# c -- ) 83 * Store a byte to I/O port number port# 84 */ 85void 86ficlOutb(FICL_VM *pVM) 87{ 88 u_char c; 89 u_int32_t port; 90 91 port=stackPopUNS32(pVM->pStack); 92 c=(u_char)stackPopINT32(pVM->pStack); 93 outb(port,c); 94} 95 96/* 97 * inb ( port# -- c ) 98 * Fetch a byte from I/O port number port# 99 */ 100void 101ficlInb(FICL_VM *pVM) 102{ 103 u_char c; 104 u_int32_t port; 105 106 port=stackPopUNS32(pVM->pStack); 107 c=inb(port); 108 stackPushINT32(pVM->pStack,c); 109} 110#endif
|
| 111#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
| 112 113/* 114** Stub function for dictionary access control - does nothing 115** by default, user can redefine to guarantee exclusive dict 116** access to a single thread for updates. All dict update code 117** is guaranteed to be bracketed as follows: 118** ficlLockDictionary(TRUE); 119** <code that updates dictionary> 120** ficlLockDictionary(FALSE); 121** 122** Returns zero if successful, nonzero if unable to acquire lock 123** befor timeout (optional - could also block forever) 124*/ 125#if FICL_MULTITHREAD 126int ficlLockDictionary(short fLock) 127{ 128 IGNORE(fLock); 129 return 0; 130} 131#endif /* FICL_MULTITHREAD */ 132 133
|