/**************************************************************************/
/*                                                                        */
/*                                 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: t_srnd.c,v 1.5 1997/09/25 18:23:28 ae59 Exp $ */
/*
$Log: t_srnd.c,v $
 * Revision 1.5  1997/09/25  18:23:28  ae59
 * Copyright-message
 *
 * Revision 1.4  1995/09/04  17:25:22  ae59
 * hardware support for ibm_emx_c similar to ibm_linux_c
 *
 * Revision 1.3  1995/08/21  14:50:55  ae59
 * can be compiled now if IEEE_Hardware is not set
 *
 * Revision 1.2  1995/08/17  12:57:47  ae59
 * support for linux-387 added by CB, restructuring
 *
 * Revision 1.1  1994/01/27  13:25:50  ae59
 * Put under RCS control
 *
 */
/*****************************************************************
**                                                              **
**  t_srnd.c   06.02.91 Baumhof                                 **
**                                                              **
**  Rundungsauswahl                                             **
**                                                              **
**  Format:                                                     **
**      int  t_srnd (int rnd);  alle viere                      **
**      int  t_grnd ;           aktuelle Rundung abfragen       **
**                                                              **
**      Date    : 1992-07-21                                    **
**      1992-07-21 : add sun4_gnu_c sun4_cpp_c =b=              **
**      1992-07-08 : changed fsrq(,d,n,u,c) to e_srq(_,d,n,u,c) **
**      1992-06-23 : switched back to 80bit SW (SPARC)          **
**      1992-05-12 : support for SPARC FP HW (IEEE 128bit)      **
*****************************************************************/

#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
extern int b_rflg;

#ifdef IEEE_HARDWARE
#if SUN4_OS4_C+SUN4_GNU_C+SUN4_CPP_C
/* #define __CB_SUN4_OS4_HARDWARE */
#endif
#endif


#ifdef IEEE_HARDWARE

#ifdef __CB_SUN4_OS4_HARDWARE

#define __T_SRND_DEFINED

extern unsigned int e_srq_, e_srqn, e_srqd, e_srqu, e_srqc;

#ifdef LINT_ARGS
int t_srnd(int rnd)
#else
int t_srnd(rnd)
int rnd;
#endif
{
    if (rnd==DOWN || rnd==UP || rnd==NEAREST || rnd==CHOP)
    {
        b_rflg = rnd;
	switch (rnd)
	{
	    case NEAREST:	e_srq_ = e_srqn; break;
	    case UP:		e_srq_ = e_srqu; break;
	    case DOWN:		e_srq_ = e_srqd; break;
	    case CHOP:		e_srq_ = e_srqc; break;
	}
        return(0);
    }
    else
    {
        b_rflg = NEAREST;
	e_srq_ = e_srqn;
        return(1);
    }
}

#endif	/* __CB_SUN4_OS4_HARDWARE */

#if IBM_LINUX_C+IBM_EMX_C

#define __T_SRND_DEFINED

extern unsigned int e_cwe_, e_cwen, e_cwed, e_cweu, e_cwec;

#ifdef LINT_ARGS
int t_srnd(int rnd)
#else
int t_srnd(rnd)
int rnd;
#endif
{
    if (rnd==DOWN || rnd==UP || rnd==NEAREST || rnd==CHOP)
    {
        b_rflg = rnd;
	switch (rnd)
	{
	    case NEAREST:	e_cwe_ = e_cwen; break;
	    case UP:		e_cwe_ = e_cweu; break;
	    case DOWN:		e_cwe_ = e_cwed; break;
	    case CHOP:		e_cwe_ = e_cwec; break;
	}
        return(0);
    }
    else
    {
        b_rflg = NEAREST;
	e_cwe_ = e_cwen;
        return(1);
    }
}

#endif	/* IBM_LINUX_C */

#endif	/* IEEE_HARDWARE */

#ifndef __T_SRND_DEFINED

#ifdef LINT_ARGS
int t_srnd(int rnd)
#else
int t_srnd(rnd)
int rnd;
#endif
{
    if (rnd==DOWN || rnd==UP || rnd==NEAREST || rnd==CHOP)
    {
        b_rflg = rnd;
        return(0);
    }
    else
    {
        b_rflg = NEAREST;
        return(1);
    }
}

#endif	/* __T_SRND_DEFINED */


#ifdef LINT_ARGS
int t_grnd(void)
#else
int t_grnd()
#endif
{
    return(b_rflg);
}
