/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: a_gets.c,v 1.2 1997/09/25 16:51:39 ae59 Exp $ */
/*
$Log: a_gets.c,v $
 * Revision 1.2  1997/09/25  16:51:39  ae59
 * Copyright-message
 *
 * Revision 1.1  1994/01/27  13:20:45  ae59
 * Put under RCS control
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : a_gets.c                              */
/*                                                              */
/*      Entries         : a_btyp a_gets(rc)                     */
/*                        a_btyp *rc;                           */
/*                                                              */
/*      Arguments       : rc = error condition code             */
/*                                                              */
/*      Description     : Get hardware status and determine     */
/*                        error condition code.                 */
/*                                                              */
/*      Note            : Version for IBM_RT_C                  */
/*                                                              */
/*      Date            : 1991-12-18                            */
/*      1991-12-18 : empty routine if not used                  */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
extern a_bool e_efdz;
extern a_bool e_efie;
extern a_bool e_efio;
extern a_bool e_efof;
extern a_bool e_efuf;
extern a_bool e_ofdz;
extern a_bool e_ofie;
extern a_bool e_ofio;
extern a_bool e_ofof;
extern a_bool e_ofuf;
#endif

#ifdef IEEE_HARDWARE
#if IBM_RT_C

#undef MININT
#include <sys/FP.h>
#undef MININT

#ifdef LINT_ARGS
local a_btyp a_gets(a_btyp *rc)
#else
local a_btyp a_gets(rc)

a_btyp *rc;
#endif
        {
        FP_STATUS status;

        /* get status */
        *((unsigned *)&status) =
           (*(unsigned (*)())_fpfpf[(int)FP_getst])();

        /* test status flag for exception occurrence */
        if (status.xcp_flag==0)
           {

           /* test status flag for inexact result */
           if (status.ir_flag==0) return(*rc = NO_ERROR);
           if (e_efie) return(*rc = INEXACT);
           e_ofie = TRUE;
           }

        /* test status flag for overflow occurrence */
        else if (status.of_flag)
           {
           if (e_efof) return(*rc = OVERFLOW);
           e_ofof = TRUE;
           }

        /* test status flag for underflow occurrence */
        else if (status.uf_flag)
           {
           if (e_efuf) return(*rc = UNDERFLOW);
           e_ofuf = TRUE;
           }

        /* test status flag for invalid-operation occurrence */
        else if (status.io_flag)
           {
           if (e_efio) return(*rc = INV_OP);
           e_ofio = TRUE;
           }

        /* test status flag for division-by-zero occurrence */
        else if (status.dz_flag)
           {
           if (e_efdz) return(*rc = DIV_BY_ZERO);
           e_ofdz = TRUE;
           }

        return(*rc = NO_ERROR);
        }
#else
#ifdef LINT_ARGS
local a_btyp a_gets(a_btyp *rc)
#else
local a_btyp a_gets(rc)

a_btyp *rc;
#endif
        {
        return(NO_ERROR);
        }
#endif
#else
#ifdef LINT_ARGS
local a_btyp a_gets(a_btyp *rc)
#else
local a_btyp a_gets(rc)

a_btyp *rc;
#endif
        {
        return(NO_ERROR);
        }
#endif
