math64.h revision 51786
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**
7*******************************************************************/
8/*
9** N O T I C E -- DISCLAIMER OF WARRANTY
10**
11** Ficl is freeware. Use it in any way that you like, with
12** the understanding that the code is not supported.
13**
14** Any third party may reproduce, distribute, or modify the ficl
15** software code or any derivative  works thereof without any
16** compensation or license, provided that the author information
17** and this disclaimer text are retained in the source code files.
18** The ficl software code is provided on an "as is"  basis without
19** warranty of any kind, including, without limitation, the implied
20** warranties of merchantability and fitness for a particular purpose
21** and their equivalents under the laws of any jurisdiction.
22**
23** I am interested in hearing from anyone who uses ficl. If you have
24** a problem, a success story, a defect, an enhancement request, or
25** if you would like to contribute to the ficl release (yay!), please
26** send me email at the address above.
27**
28** NOTE: this file depends on sysdep.h for the definition
29** of PORTABLE_LONGMULDIV and several abstract types.
30**
31*/
32
33/* $FreeBSD: head/sys/boot/ficl/math64.h 51786 1999-09-29 04:43:16Z dcs $ */
34
35#if !defined (__MATH64_H__)
36#define __MATH64_H__
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42DPINT   m64Abs(DPINT x);
43int     m64IsNegative(DPINT x);
44DPUNS   m64Mac(DPUNS u, FICL_UNS mul, FICL_UNS add);
45DPINT   m64MulI(FICL_INT x, FICL_INT y);
46DPINT   m64Negate(DPINT x);
47INTQR   m64FlooredDivI(DPINT num, FICL_INT den);
48void    i64Push(FICL_STACK *pStack, DPINT i64);
49DPINT   i64Pop(FICL_STACK *pStack);
50void    u64Push(FICL_STACK *pStack, DPUNS u64);
51DPUNS   u64Pop(FICL_STACK *pStack);
52INTQR   m64SymmetricDivI(DPINT num, FICL_INT den);
53UNS16   m64UMod(DPUNS *pUD, UNS16 base);
54
55
56#if PORTABLE_LONGMULDIV != 0   /* see sysdep.h */
57DPUNS   m64Add(DPUNS x, DPUNS y);
58DPUNS   m64ASL( DPUNS x );
59DPUNS   m64ASR( DPUNS x );
60int     m64Compare(DPUNS x, DPUNS y);
61DPUNS   m64Or( DPUNS x, DPUNS y );
62DPUNS   m64Sub(DPUNS x, DPUNS y);
63#endif
64
65#define i64Extend(i64) (i64).hi = ((i64).lo < 0) ? -1L : 0
66#define m64CastIU(i64) (*(DPUNS *)(&(i64)))
67#define m64CastUI(u64) (*(DPINT *)(&(u64)))
68#define m64CastQRIU(iqr) (*(UNSQR *)(&(iqr)))
69#define m64CastQRUI(uqr) (*(INTQR *)(&(uqr)))
70
71#define CELL_HI_BIT (1L << (BITS_PER_CELL-1))
72
73#ifdef __cplusplus
74}
75#endif
76
77#endif
78
79