_Qfpack.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Copyright (c) 1988 by Sun Microsystems, Inc.
*/
/* Pack procedures for Sparc FPU simulator. */
#include "_Qquad.h"
#include "_Qglobals.h"
PRIVATE int
int sign;
/* Returns 1 if overflow should go to infinity, 0 if to max finite. */
{
int inf;
switch (fp_direction) {
case fp_nearest:
inf = 1;
break;
case fp_tozero:
inf = 0;
break;
case fp_positive:
break;
case fp_negative:
break;
}
return (inf);
}
PRIVATE void
/* Round according to current rounding mode. */
{
int increment; /* boolean to indicate round up */
int sr;
if (sr == 0)
return;
switch (fp_direction) {
case fp_nearest:
break;
case fp_tozero:
increment = 0;
break;
case fp_positive:
break;
case fp_negative:
break;
}
if (increment) {
}
}
}
}
}
if ((fp_direction == fp_nearest) &&
}
}
PRIVATE void
int *px; /* packed integer */
{
case fp_zero:
*px = 0;
break;
case fp_normal:
goto overflow;
goto overflow;
break;
case fp_infinity:
case fp_quiet:
case fp_signaling:
*px = 0x80000000;
else
*px = 0x7fffffff;
break;
}
}
PRIVATE void
{
case fp_zero:
px->significand = 0;
break;
case fp_infinity:
px->significand = 0;
break;
case fp_quiet:
case fp_signaling:
break;
case fp_normal:
* back up to
* normal */
px->significand = 0;
return;
}
return;
}
}
goto infinity;
return;
}
}
}
PRIVATE void
unsigned *py;
{
case fp_zero:
px->significand = 0;
*py = 0;
break;
case fp_infinity:
px->significand = 0;
*py = 0;
break;
case fp_quiet:
case fp_signaling:
break;
case fp_normal:
* back up to
* normal */
px->significand = 0;
*py = 0;
return;
}
return;
}
}
goto infinity;
*py = 0xffffffff;
return;
}
break;
}
}
PRIVATE void
{
case fp_zero:
px->significand = 0;
*pz = 0;
*py = 0;
*pw = 0;
break;
case fp_infinity:
px->significand = 0;
*pz = 0;
*py = 0;
*pw = 0;
break;
case fp_quiet:
case fp_signaling:
* nan. */
break;
case fp_normal:
* back up
* to normal */
} else
return;
}
goto infinity;
*py = 0xffffffff;
*pz = 0xffffffff;
*pw = 0xffffffff;
return;
}
break;
}
}
void
int *n; /* output result's address */
{
switch (type) {
case fp_op_integer:
{
packinteger(pu, n);
break;
}
case fp_op_single:
{
single_type x;
packsingle(pu, &x);
n[0] = *(int*)&x;
break;
}
case fp_op_double:
{
double_type x;
double t=1.0;
n[i0] = *(int*)&x;
break;
}
case fp_op_extended:
{
unsigned y, z, w;
unpacked u;
int k;
switch (fp_precision) { /* Implement extended
* rounding precision mode. */
case fp_single:
{
pu = &u;
break;
}
case fp_double:
{
unsigned ty;
pu = &u;
break;
}
case fp_precision_3: /* rounded to 64 bits */
{
if(k>=0) k = 113-64;
else k = 113-64-k;
break;
}
}
{
double t = 1.0;
n[i0] = *(int*)&x;
}
break;
}
}
}