/*{{{  module header */

/*
 *	extlib definitions
 *	Copyright (C) 1987 Inmos Limited
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*}}}*/

#ifndef _EXTLIBH
/*{{{  not included header file */
#define _EXTLIBH

/*{{{  standard includes */
#ifndef _IMSTYPEH
#include "imstype.h"
#endif
#ifndef _IMSMISCH
#include "imsmisc.h"
#endif
#ifndef _IMSSTDH
#include "imsstd.h"
#endif
/*}}}*/

/*{{{  constant definitions */
/*{{{  operation and rounding codes */
#define Truncate 0 /* Conversion mode to round to zero */
#define Nearest  1 /* Conversion mode to round to nearest */

#define OpMask  3 /* Extract Rounding Mode and Operation from RMOp */
#define RMShift 2

#define Op_Add 0 /* Operation code for addition */
#define Op_Sub 1 /* Operation code for subtraction */
#define Op_Mul 2 /* Operation code for multiplication */
#define Op_Div 3 /* Operation code for division */
#define Op_Rem 4 /* Operation code for remainder, integers only */

#define RN 0 /* Round to nearest */
#define RZ 1 /* Round to zero */
#define RP 2 /* Round to +infinity */
#define RM 3 /* Round to -infinity */
/*}}}*/

/*{{{  IEEE floating point constants */
/*{{{  IEEE single length values */
#define RealShift     8
#define BitsInFrac    24
#define RealExpSh     23

#define RealExp       0X000000FF
#define RealXcess     0X0000007F
#define RealRBit      0X00000080
#define BiggestFinite 0X7F7FFFFF

#define RealInf       0X7F800000
#define RealNaN       0X7F800001

#define REAL32MININT32 0XCF000000
#define REAL32MININT64 0XDF000000
/*}}}*/

/*{{{  IEEE double length values */
#define DRealShift       11
#define DBitsInFrac      53
#define DRealExpSh       20

#define DRealExp         0X000007FF
#define DRealXcess       0X000003FF
#define DRealRBit        0X00000400
#define DBiggestFiniteLo 0XFFFFFFFF
#define DBiggestFiniteHi 0X7FEFFFFF

#define DRealInf         0X7FF00000
#define DRealNaNLo       0X00000001
#define DRealNaNHi       DRealInf

#define REAL64MININT32Hi 0XC1E00000
#define REAL64MININT64Hi 0XC2E00000
/*}}}*/

/*{{{  IEEE NaNs for 32 bit reals */
#define ZeroZeroDivNaN  0X7FC00000
#define InfInfDivNaN    0X7FA00000
#define ZeroInfMulNaN   0X7F900000
#define AddSubInfInfNaN 0X7F880000
#define NegSqrtNaN      0X7F840000
#define RemInfNaN       0X7F804000
#define RemZeroNaN      0X7F802000

#define Real64to32NaN     0X7F820000
#define Real64to32NaNfrac 0X02000000
/*}}}*/

/*{{{  IEEE NaNs for 64 bit reals */
#define DZeroZeroDivNaN  0X7FF80000
#define DInfInfDivNaN    0X7FF40000
#define DZeroInfMulNaN   0X7FF20000
#define DAddSubInfInfNaN 0X7FF10000
#define DNegSqrtNaN      0X7FF08000
#define DRemInfNaN       0X7FF00800
#define DRemZeroNaN      0X7FF00400

#define DReal64to32NaN   0X7FF04000
/*}}}*/
/*}}}*/
/*}}}*/

/*{{{  routine prototypes */
/*{{{  extstr.c */
EXTERNAL VOID RealIMul PARMS((INT32 *, INT32 *, INT32, INT32));

EXTERNAL VOID RealIDiv PARMS((INT32 *, INT32 *, INT32 *, INT32 *, INT32 *));

EXTERNAL VOID StrToR64 PARMS((BOOL *, BIT32 *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToR32 PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToInt PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToI8 PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToI16 PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToI64 PARMS((BOOL *, BIT32 *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToHex PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToH8 PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToH16 PARMS((BOOL *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToH64 PARMS((BOOL *, BIT32 *, BIT32 *, VAL CHAR *));

EXTERNAL VOID StrToOct PARMS((BOOL *, BIT32 *, VAL CHAR *));
/*}}}*/

/*{{{  extlong.c */
EXTERNAL VOID LONGSUM PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID LONGADD PARMS((BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID LONGDIFF PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID LONGPROD PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID LONGDIV PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID SHIFTRIGHT PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID SHIFTLEFT PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID NORMALISE PARMS((BIT32 *, BIT32 *, BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  extconv.c */
EXTERNAL VOID I32ToI64 PARMS((BIT32 *, BIT32 *, BIT32));

EXTERNAL VOID I32ToR32 PARMS((BIT32 *, INT, BIT32));

EXTERNAL VOID I32ToR64 PARMS((BIT32 *, BIT32 *, BIT32));

EXTERNAL VOID I64ToI32 PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID I64ToR32 PARMS((BIT32 *, INT, BIT32, BIT32));

EXTERNAL VOID I64ToR64 PARMS((BIT32 *, BIT32 *, INT, BIT32, BIT32));

EXTERNAL VOID R32ToI32 PARMS((BOOL *, BIT32 *, INT, BIT32));

EXTERNAL VOID R32ToI64 PARMS((BOOL *, BIT32 *, BIT32 *, INT, BIT32));

EXTERNAL VOID R32ToR64 PARMS((BOOL *, BIT32 *, BIT32 *, BIT32));

EXTERNAL VOID R64ToI32 PARMS((BOOL *, BIT32 *, INT, BIT32, BIT32));

EXTERNAL VOID R64ToI64 PARMS((BOOL *, BIT32 *, BIT32 *, INT, BIT32, BIT32));

EXTERNAL VOID R64ToR32 PARMS((BOOL *, BIT32 *, INT, BIT32, BIT32));
/*}}}*/

/*{{{  exti8.c */
EXTERNAL VOID Int8Add PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Plus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Sub PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Minus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Mul PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Times PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Div PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Int8Gt PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Int8BitAnd PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8BitOr PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8Xor PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8BitNot PARMS((BIT32 *, BIT32));

EXTERNAL VOID Int8LShift PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int8RShift PARMS((BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  extui8.c */
EXTERNAL VOID UInt8Add PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Plus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Sub PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Minus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Mul PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Times PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Div PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID UInt8Gt PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID UInt8BitAnd PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8BitOr PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8Xor PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8BitNot PARMS((BIT32 *, BIT32));

EXTERNAL VOID UInt8LShift PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt8RShift PARMS((BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  exti16.c */
EXTERNAL VOID Int16Add PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Plus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Sub PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Minus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Mul PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Times PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Div PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Int16Gt PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Int16BitAnd PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16BitOr PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16Xor PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16BitNot PARMS((BIT32 *, BIT32));

EXTERNAL VOID Int16LShift PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int16RShift PARMS((BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  extui16.c */
EXTERNAL VOID UInt16Add PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Plus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Sub PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Minus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Mul PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Times PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Div PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID UInt16Gt PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID UInt16BitAnd PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16BitOr PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16Xor PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16BitNot PARMS((BIT32 *, BIT32));

EXTERNAL VOID UInt16LShift PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt16RShift PARMS((BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  exti32.c */
EXTERNAL VOID Int32Add PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Plus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Sub PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Minus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Mul PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Times PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Div PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Int32Gt PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Int32BitAnd PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32BitOr PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32Xor PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32BitNot PARMS((BIT32 *, BIT32));

EXTERNAL VOID Int32LShift PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int32RShift PARMS((BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  extui32.c */
EXTERNAL VOID UInt32Add PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Plus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Sub PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Minus PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Mul PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Times PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Div PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID UInt32Gt PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID UInt32BitAnd PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32BitOr PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32Xor PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32BitNot PARMS((BIT32 *, BIT32));

EXTERNAL VOID UInt32LShift PARMS((BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt32RShift PARMS((BIT32 *, BIT32, BIT32));
/*}}}*/

/*{{{  exti64.c */
EXTERNAL VOID Int64Add PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Plus PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Sub PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Minus PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Mul PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Times PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Div PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Rem PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Eq PARMS((BOOL *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Gt PARMS((BOOL *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64BitAnd PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64BitOr PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64Xor PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64BitNot PARMS((BIT32 *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Int64LShift PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID Int64RShift PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));
/*}}}*/

/*{{{  extui64.c */
EXTERNAL VOID UInt64Add PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Plus PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Sub PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Minus PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Mul PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Times PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Div PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Rem PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Eq PARMS((BOOL *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Gt PARMS((BOOL *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64BitAnd PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64BitOr PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64Xor PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64BitNot PARMS((BIT32 *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID UInt64LShift PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));

EXTERNAL VOID UInt64RShift PARMS((BIT32 *, BIT32 *, BIT32, BIT32, BIT32));
/*}}}*/

/*{{{  extr32.c */
EXTERNAL VOID Real32Op PARMS((BOOL *, BIT32 *, BIT32, INT, BIT32));

EXTERNAL VOID Real32Rem PARMS((BOOL *, BIT32 *, BIT32, BIT32));

EXTERNAL VOID Real32Eq PARMS((BOOL *, BIT32, BIT32));

EXTERNAL VOID Real32Gt PARMS((BOOL *, BIT32, BIT32));
/*}}}*/

/*{{{  extr64.c */
EXTERNAL VOID Real64Op PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, INT, BIT32, BIT32));

EXTERNAL VOID Real64Rem PARMS((BOOL *, BIT32 *, BIT32 *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Real64Eq PARMS((BOOL *, BIT32, BIT32, BIT32, BIT32));

EXTERNAL VOID Real64Gt PARMS((BOOL *, BIT32, BIT32, BIT32, BIT32));
/*}}}*/
/*}}}*/
/*}}}*/
#endif
