/* @(#)Copyright (c), 1987, 1993 StatSci, Inc.  All rights reserved. */
/* @(#)fpp.h version 3.1 created 5/30/93 */
#if defined(APOLLO)
/* Splus options and C compiler version changes required slight changes in
 * this APOLLO header file to get compilations/executions to work.  DLR.
 */
/************************************************************************************  
**  Floating Point Package   04-SEP-86 EP                                          **
**                                                                                 **
**  Procedures to manipulate FPP error mask bits                                   **
**                                                                                 **
**                                                                                 **
**   --------------------------------------------------------------------------    **
**  |   THE FOLLOWING PROGRAMS ARE THE SOLE PROPERTY OF APOLLO COMPUTER INC.   |   **
**  |         AND CONTAIN ITS PROPRIETARY AND CONFIDENTIAL INFORMATION.        |   **
**   --------------------------------------------------------------------------    **
**                                                                                 **
**  FPP_$ CALLS MAY BE USED BY ANY USER  PROGRAM TO CHANGE THE FP STATE ON THE     **
**                        MC68881/FPX/FPA/PRISM MACHINES.                          **
************************************************************************************/

#ifndef apollo_fpp_h
#define apollo_fpp_h
 
#ifndef _SYS_STDSYMS_INCLUDED
#	include <sys/stdsyms.h>
#endif /* _SYS_STDSYMS_INCLUDED */

typedef short enum {
        read_op, write_op, exch_op
} fpp_op_t;
 
typedef short enum { fpp_$round_to_nearest,    
                     fpp_$round_to_zero,
                     fpp_$round_to_negative,
                     fpp_$round_to_positive
} fpp_$rounding_mode_t;
 
typedef short enum { fpp_$extended_precision_mode,
                     fpp_$single_precision_mode,
                     fpp_$double_precision_mode,
                     fpp_$reserved_precision_mode 
} fpp_$mc68881_precision_mode_t;
                          
typedef short enum { fpp_$enable_inexact             =      1,
                     fpp_$enable_divide_by_zero      =      2,
                     fpp_$enable_underflow           =      4,
                     fpp_$enable_overflow            =      8,
                     fpp_$enable_invalid_operation   =     16,
                     fpp_$enable_signaling_nan       =     32,
                     fpp_$enable_branch_unordered    =     64
} fpp_$trap_enables_t;

typedef short enum { fpp_$inexact                    =      1,
                     fpp_$divide_by_zero             =      2,
                     fpp_$underflow                  =      4,
                     fpp_$overflow                   =      8,
                     fpp_$invalid_operation          =     16,
                     fpp_$signaling_nan              =     32,
                     fpp_$branch_unordered           =     64
} fpp_$accumulated_status_t;

/*  Required for C++ V2.0  */
#ifdef  __cplusplus
    extern "C" {
#endif

/************************************************************************************
** The following calls return float and double constant IEEE-754 types. These      **
** calls work on machine types, even types that do not support full IEEE-754 data  **
** types (INF, NaN, denormalized arithmetic, etc.).                                **
************************************************************************************/
                            
_DECL_FUNC(float,	fpp_$sp_max_normal,	(void));
_DECL_FUNC(double,	fpp_$dp_max_normal,	(void));
_DECL_FUNC(float,	fpp_$sp_min_normal,	(void));
_DECL_FUNC(double,	fpp_$dp_min_normal,	(void));
_DECL_FUNC(float,	fpp_$sp_max_subnormal,	(void));
_DECL_FUNC(double,	fpp_$dp_max_subnormal,	(void));
_DECL_FUNC(float,	fpp_$sp_min_subnormal,	(void));
_DECL_FUNC(double,	fpp_$dp_min_subnormal,	(void));
_DECL_FUNC(float,	fpp_$sp_infinity,	(void));
_DECL_FUNC(double,	fpp_$dp_infinity,	(void));
_DECL_FUNC(float,	fpp_$sp_quiet_nan,	(void));
_DECL_FUNC(double,	fpp_$dp_quiet_nan,	(void));
_DECL_FUNC(float,	fpp_$sp_signaling_nan,	(void));
_DECL_FUNC(double,	fpp_$dp_signaling_nan,	(void));

/************************************************************************************
** fpp_$xxx_rounding_mode is used to read or set the current rounding mode of the  **
** FPU                                                                             **
************************************************************************************/

_DECL_FUNC(void,	fpp_$get_rounding_mode, (
	    fpp_$rounding_mode_t    *rm,
            status_$t               *status 
            ));

_DECL_FUNC(void,	fpp_$set_rounding_mode, (
            fpp_$rounding_mode_t    &rm,
            status_$t               *status 
            ));

/************************************************************************************
** fpp_$xxx_trap_enables is used to enable or disable one or more floating point   **
** exception traps                                                                 **                  
************************************************************************************/

_DECL_FUNC(void,	fpp_$get_trap_enables, (
            fpp_$trap_enables_t    *fp_enab,
            status_$t              *status 
            ));

_DECL_FUNC(void,	fpp_$set_trap_enables, ( 
            fpp_$trap_enables_t    &fp_enab,
            status_$t              *status 
            ));     

/************************************************************************************
** The fpp_$xxx_ieee_underflow_mode is used to cause the FPU to work in full IEEE  **
** 754 denormalized mode, or in a mode which underflows from the smallest magnitude**
** normalized value all the way to zero,                                           **
************************************************************************************/

_DECL_FUNC(void,	fpp_$get_ieee_underflow_mode, ( 
            boolean                       *ieee_mode,
            status_$t                     *status 
            ));

_DECL_FUNC(void,	fpp_$set_ieee_underflow_mode, ( 
            boolean                       &ieee_mode,
            status_$t                     *status 
            ));

/************************************************************************************
** fpp_$xxx_accrued_exceptions is used to read or write the accrued exception      **
** status byte in 881/fpa/fpx/dn10000 based machines.                              **
************************************************************************************/

_DECL_FUNC(void,	fpp_$get_accrued_exceptions, ( 
            fpp_$accumulated_status_t      *acc_exc,
            status_$t                      *status 
            ));

_DECL_FUNC(void,	fpp_$set_accrued_exceptions, ( 
            fpp_$accumulated_status_t    &acc_exc,
            status_$t                    *status 
            ));

/************************************************************************************
** fpp_$xxx_mc68881_precision_mode is used to set or read the internal precision   **
** mode of all mc68881 and/or dn5xx/FPX based machines. This call has no effect on **
** any other Apollo machine.                                                       **
************************************************************************************/

_DECL_FUNC(void,	fpp_$get_mc68881_precision_mode, ( 
            fpp_$mc68881_precision_mode_t    *pr_mode,
            status_$t                        *status 
            ));

_DECL_FUNC(void,	fpp_$set_mc68881_precision_mode, ( 
            fpp_$mc68881_precision_mode_t    &pr_mode,
            status_$t                        *status 
            ));

/************************************************************************************
** fpp_$set_default_modes is used to unconditionally set the rounding mode, ieee   **
** underflow mode, the trap enables, and, ifd applicable, the precision mode, to   **
** their default values. The accrued exception byte is also cleared.               **
************************************************************************************/

_DECL_FUNC(void,	fpp_$set_default_modes, (
            status_$t               *status
            ));


/***********************************************************************************                                                          
** Procedures to read and write the FP control/status regtisters. Functional on   **
** all machines, including PRISM types, even though the call is modeled after the **
** MC68881.                                                                       **
***********************************************************************************/


_DECL_FUNC(void,	fpp_$control, (
            fpp_op_t          &op,
            unsigned long int *control_reg,
            status_$t         *status
            ));

_DECL_FUNC(void,	fpp_$status, (
        fpp_op_t              &op,
        unsigned long int     *status_reg,
        status_$t             *status
        ));

/****************************************************************************************
**    FPP_$SAVE saves the floating point state in the area provided(save_area).        **
**              the number of bytes saved is returned in bytes_saved.                  **
**              i is task number.                                                      **
****************************************************************************************/                                                          

_DECL_FUNC(short int,	fpp_$save, (
                 void        *&save_area,
                 status_$t   *status
                 ));              

/****************************************************************************************                                                          
**    FPP_$RESTORE restores the floating point state in the area provided(save_area).  **
**                 the number of bytes restored is returned in bytes_restored.         **
**                 i is task number.                                                   **
****************************************************************************************/
                                                  
_DECL_FUNC(short int,	fpp_$restore, (
                 void          *&restore_area,
                 status_$t     *status
                 ));

/****************************************************************************************                                                         
**    FPP_$SAVE_RESTORE first saves the current FP state in the first argument and     **
**                 then sets the FP state with the data in the second argument.        **
**                 The number of bytes moved in one direction is returned in bytes     **
**                 moved.  i and j are task numbers.                                   **
**                                                                                     **
**    bytes_moved =  fpp_$save_restore(&(save_area[i]),                                **
**                                     &(save_area[j]), status);                       **
**                                                                                     **
**                   where save_area is where to save current state and                **
**                   save_area0 is where to obtain information to restore.             **
****************************************************************************************/

_DECL_FUNC(short int,	fpp_$save_restore, (
                 void               *&save_area,
                 void               *&restore_area,
                 status_$t          *status
                 ));

/***************************************************************************************                                                          
**    FPP_$SAVE_RESTORE_SIZE returns the number of bytes required for one tasks       **
**                           FP state save.                                           **
**                                                                                    **
**    save_area_size = fpp_$save_restore_size();                                      **
***************************************************************************************/

_DECL_FUNC(short int,	fpp_$save_restore_size,	(void));

#ifdef  __cplusplus
    }
#endif

#endif /* apollo_fpp_h */
/* end of fpp.h */
#endif
