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