Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Linux/PA-RISC Project (http://www.parisc-linux.org/)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Floating-point emulation code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *  Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * BEGIN_DESC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *  File:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *	@(#)	pa/spmath/sfrem.c		$Revision: 1.1 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *  Purpose:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *	Single Precision Floating-point Remainder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *  External Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  *	sgl_frem(srcptr1,srcptr2,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *  Internal Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *  Theory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *	<<please update with a overview of the operation of this file>>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * END_DESC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include "float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include "sgl_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  *  Single Precision Floating-point Remainder
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) sgl_frem (sgl_floating_point * srcptr1, sgl_floating_point * srcptr2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	  sgl_floating_point * dstptr, unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	register unsigned int opnd1, opnd2, result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	register int opnd1_exponent, opnd2_exponent, dest_exponent, stepcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	register boolean roundup = FALSE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	opnd1 = *srcptr1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	opnd2 = *srcptr2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 * check first operand for NaN's or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	if ((opnd1_exponent = Sgl_exponent(opnd1)) == SGL_INFINITY_EXPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		if (Sgl_iszero_mantissa(opnd1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			if (Sgl_isnotnan(opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 				/* invalid since first operand is infinity */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				if (Is_invalidtrap_enabled()) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55)                                 	return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)                                 Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)                                 Sgl_makequietnan(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 				*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 				return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)                 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64)                  	 * is NaN; signaling or quiet?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)                  	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)                 	if (Sgl_isone_signaling(opnd1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)                         	/* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)                         	if (Is_invalidtrap_enabled()) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)                             		return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)                         	/* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)                         	Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)                         	Sgl_set_quiet(opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)                 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 			 * is second operand a signaling NaN? 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			else if (Sgl_is_signalingnan(opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)                         	/* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)                         	if (Is_invalidtrap_enabled()) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)                             		return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)                         	/* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)                         	Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)                         	Sgl_set_quiet(opnd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)                 		*dstptr = opnd2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)                 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)                 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88)                  	 * return quiet NaN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89)                  	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)                 	*dstptr = opnd1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91)                 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	} 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	 * check second operand for NaN's or infinity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if ((opnd2_exponent = Sgl_exponent(opnd2)) == SGL_INFINITY_EXPONENT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		if (Sgl_iszero_mantissa(opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			 * return first operand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)                 	*dstptr = opnd1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 			return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)                 /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)                  * is NaN; signaling or quiet?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)                 if (Sgl_isone_signaling(opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)                         /* trap if INVALIDTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)                         if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)                         /* make NaN quiet */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)                         Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)                         Sgl_set_quiet(opnd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)                 /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)                  * return quiet NaN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)                 *dstptr = opnd2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)                 return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	 * check second operand for zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	if (Sgl_iszero_exponentmantissa(opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		/* invalid since second operand is zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)                 Set_invalidflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)                 Sgl_makequietnan(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	 * get sign of result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	result = opnd1;  
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	 * check for denormalized operands
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	if (opnd1_exponent == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		/* check for zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		if (Sgl_iszero_mantissa(opnd1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 			*dstptr = opnd1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 		/* normalize, then continue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 		opnd1_exponent = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		Sgl_normalize(opnd1,opnd1_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 		Sgl_clear_signexponent_set_hidden(opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	if (opnd2_exponent == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		/* normalize, then continue */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		opnd2_exponent = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		Sgl_normalize(opnd2,opnd2_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 		Sgl_clear_signexponent_set_hidden(opnd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	/* find result exponent and divide step loop count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	dest_exponent = opnd2_exponent - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	stepcount = opnd1_exponent - opnd2_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	 * check for opnd1/opnd2 < 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if (stepcount < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		 * check for opnd1/opnd2 > 1/2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		 * In this case n will round to 1, so 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		 *    r = opnd1 - opnd2 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		if (stepcount == -1 && Sgl_isgreaterthan(opnd1,opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 			Sgl_all(result) = ~Sgl_all(result);   /* set sign */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 			/* align opnd2 with opnd1 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 			Sgl_leftshiftby1(opnd2); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 			Sgl_subtract(opnd2,opnd1,opnd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			/* now normalize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)                 	while (Sgl_iszero_hidden(opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)                         	Sgl_leftshiftby1(opnd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)                         	dest_exponent--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			Sgl_set_exponentmantissa(result,opnd2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			goto testforunderflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		 * opnd1/opnd2 <= 1/2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		 * In this case n will round to zero, so 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		 *    r = opnd1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		Sgl_set_exponentmantissa(result,opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		dest_exponent = opnd1_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		goto testforunderflow;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	 * Generate result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	 * Do iterative subtract until remainder is less than operand 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	while (stepcount-- > 0 && Sgl_all(opnd1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		if (Sgl_isnotlessthan(opnd1,opnd2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 			Sgl_subtract(opnd1,opnd2,opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		Sgl_leftshiftby1(opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	 * Do last subtract, then determine which way to round if remainder 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 * is exactly 1/2 of opnd2 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	if (Sgl_isnotlessthan(opnd1,opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		Sgl_subtract(opnd1,opnd2,opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		roundup = TRUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (stepcount > 0 || Sgl_iszero(opnd1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		/* division is exact, remainder is zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		Sgl_setzero_exponentmantissa(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	/* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	 * Check for cases where opnd1/opnd2 < n 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	 * In this case the result's sign will be opposite that of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 	 * opnd1.  The mantissa also needs some correction.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	Sgl_leftshiftby1(opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	if (Sgl_isgreaterthan(opnd1,opnd2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		Sgl_invert_sign(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 		Sgl_subtract((opnd2<<1),opnd1,opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	/* check for remainder being exactly 1/2 of opnd2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	else if (Sgl_isequal(opnd1,opnd2) && roundup) { 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		Sgl_invert_sign(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	/* normalize result's mantissa */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)         while (Sgl_iszero_hidden(opnd1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)                 dest_exponent--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)                 Sgl_leftshiftby1(opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)         }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	Sgl_set_exponentmantissa(result,opnd1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)         /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)          * Test for underflow
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)     testforunderflow:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if (dest_exponent <= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)                 /* trap if UNDERFLOWTRAP enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)                 if (Is_underflowtrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)                         /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)                          * Adjust bias of result
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)                          */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)                         Sgl_setwrapped_exponent(result,dest_exponent,unfl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			/* frem is always exact */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			return(UNDERFLOWEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)                 /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)                  * denormalize result or set to signed zero
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)                  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)                 if (dest_exponent >= (1 - SGL_P)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 			Sgl_rightshift_exponentmantissa(result,1-dest_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)                 }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)                 else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 			Sgl_setzero_exponentmantissa(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	else Sgl_set_exponent(result,dest_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }