math64.h revision 76116
1/******************************************************************* 2** m a t h 6 4 . h 3** Forth Inspired Command Language - 64 bit math support routines 4** Author: John Sadler (john_sadler@alum.mit.edu) 5** Created: 25 January 1998 6** $Id: math64.h,v 1.5 2001-04-26 21:41:53-07 jsadler Exp jsadler $ 7*******************************************************************/ 8/* 9** Copyright (c) 1997-2001 John Sadler (john_sadler@alum.mit.edu) 10** All rights reserved. 11** 12** Get the latest Ficl release at http://ficl.sourceforge.net 13** 14** L I C E N S E and D I S C L A I M E R 15** 16** Redistribution and use in source and binary forms, with or without 17** modification, are permitted provided that the following conditions 18** are met: 19** 1. Redistributions of source code must retain the above copyright 20** notice, this list of conditions and the following disclaimer. 21** 2. Redistributions in binary form must reproduce the above copyright 22** notice, this list of conditions and the following disclaimer in the 23** documentation and/or other materials provided with the distribution. 24** 25** THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 26** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28** ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 29** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30** DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31** OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32** HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33** LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34** OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35** SUCH DAMAGE. 36** 37** I am interested in hearing from anyone who uses ficl. If you have 38** a problem, a success story, a defect, an enhancement request, or 39** if you would like to contribute to the ficl release, please send 40** contact me by email at the address above. 41** 42** $Id: math64.h,v 1.5 2001-04-26 21:41:53-07 jsadler Exp jsadler $ 43*/ 44 45/* $FreeBSD: head/sys/boot/ficl/math64.h 76116 2001-04-29 02:36:36Z dcs $ */ 46 47#if !defined (__MATH64_H__) 48#define __MATH64_H__ 49 50#ifdef __cplusplus 51extern "C" { 52#endif 53 54DPINT m64Abs(DPINT x); 55int m64IsNegative(DPINT x); 56DPUNS m64Mac(DPUNS u, FICL_UNS mul, FICL_UNS add); 57DPINT m64MulI(FICL_INT x, FICL_INT y); 58DPINT m64Negate(DPINT x); 59INTQR m64FlooredDivI(DPINT num, FICL_INT den); 60void i64Push(FICL_STACK *pStack, DPINT i64); 61DPINT i64Pop(FICL_STACK *pStack); 62void u64Push(FICL_STACK *pStack, DPUNS u64); 63DPUNS u64Pop(FICL_STACK *pStack); 64INTQR m64SymmetricDivI(DPINT num, FICL_INT den); 65UNS16 m64UMod(DPUNS *pUD, UNS16 base); 66 67 68#if PORTABLE_LONGMULDIV != 0 /* see sysdep.h */ 69DPUNS m64Add(DPUNS x, DPUNS y); 70DPUNS m64ASL( DPUNS x ); 71DPUNS m64ASR( DPUNS x ); 72int m64Compare(DPUNS x, DPUNS y); 73DPUNS m64Or( DPUNS x, DPUNS y ); 74DPUNS m64Sub(DPUNS x, DPUNS y); 75#endif 76 77#define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 0 78#define m64CastIU(i64) (*(DPUNS *)(&(i64))) 79#define m64CastUI(u64) (*(DPINT *)(&(u64))) 80#define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr))) 81#define m64CastQRUI(uqr) (*(INTQR *)(&(uqr))) 82 83#define CELL_HI_BIT (1L << (BITS_PER_CELL-1)) 84 85#ifdef __cplusplus 86} 87#endif 88 89#endif 90 91