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/fcnvuf.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)  *	Fixed point to Floating-point Converts
^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)  *	dbl_to_dbl_fcnvuf(srcptr,nullptr,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *	dbl_to_sgl_fcnvuf(srcptr,nullptr,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *	sgl_to_dbl_fcnvuf(srcptr,nullptr,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *	sgl_to_sgl_fcnvuf(srcptr,nullptr,dstptr,status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  *  Internal Interfaces:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *  Theory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  *	<<please update with a overview of the operation of this file>>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * END_DESC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include "float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #include "sgl_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include "dbl_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #include "cnv_float.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /************************************************************************
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *  Fixed point to Floating-point Converts				*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  ************************************************************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)  *  Convert Single Unsigned Fixed to Single Floating-point format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) sgl_to_sgl_fcnvuf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 			unsigned int *srcptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 			unsigned int *nullptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			sgl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	register unsigned int src, result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	register int dst_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	src = *srcptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	/* Check for zero */ 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (src == 0) { 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	       	Sgl_setzero(result); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 		*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	       	return(NOEXCEPTION); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	} 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	 * Generate exponent and normalized mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	dst_exponent = 16;    /* initialize for normalization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	 * Check word for most significant bit set.  Returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	 * a value in dst_exponent indicating the bit position,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	 * between -1 and 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	Find_ms_one_bit(src,dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	/*  left justify source, with msb at bit position 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	src <<= dst_exponent+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	Sgl_set_mantissa(result, src >> SGL_EXP_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	Sgl_set_exponent(result, 30+SGL_BIAS - dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	/* check for inexact */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	if (Suint_isinexact_to_sgl(src)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		switch (Rounding_mode()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			case ROUNDPLUS: 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 				Sgl_increment(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			case ROUNDMINUS: /* never negative */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			case ROUNDNEAREST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 				Sgl_roundnearest_from_suint(src,result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		if (Is_inexacttrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			return(INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)  *  Single Unsigned Fixed to Double Floating-point 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) sgl_to_dbl_fcnvuf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			unsigned int *srcptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			unsigned int *nullptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 			dbl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	register int dst_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	register unsigned int src, resultp1 = 0, resultp2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	src = *srcptr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	/* Check for zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (src == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	       	Dbl_setzero(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	       	Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	       	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	 * Generate exponent and normalized mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	dst_exponent = 16;    /* initialize for normalization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	 * Check word for most significant bit set.  Returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	 * a value in dst_exponent indicating the bit position,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	 * between -1 and 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	Find_ms_one_bit(src,dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	/*  left justify source, with msb at bit position 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	src <<= dst_exponent+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	Dbl_set_mantissap1(resultp1, src >> DBL_EXP_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	Dbl_set_mantissap2(resultp2, src << (32-DBL_EXP_LENGTH));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	Dbl_set_exponent(resultp1, (30+DBL_BIAS) - dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)  *  Double Unsigned Fixed to Single Floating-point 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) dbl_to_sgl_fcnvuf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 			dbl_unsigned *srcptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 			unsigned int *nullptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 			sgl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	int dst_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	unsigned int srcp1, srcp2, result = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	Duint_copyfromptr(srcptr,srcp1,srcp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	/* Check for zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	if (srcp1 == 0 && srcp2 == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	       	Sgl_setzero(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	       	*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	       	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	 * Generate exponent and normalized mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	dst_exponent = 16;    /* initialize for normalization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	if (srcp1 == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 		 * Check word for most significant bit set.  Returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 		 * a value in dst_exponent indicating the bit position,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 		 * between -1 and 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		Find_ms_one_bit(srcp2,dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		/*  left justify source, with msb at bit position 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 		srcp1 = srcp2 << dst_exponent+1;    
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 		srcp2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 		 *  since msb set is in second word, need to 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		 *  adjust bit position count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		dst_exponent += 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		 * Check word for most significant bit set.  Returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		 * a value in dst_exponent indicating the bit position,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		 * between -1 and 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		Find_ms_one_bit(srcp1,dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		/*  left justify source, with msb at bit position 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		if (dst_exponent >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 			Variable_shift_double(srcp1,srcp2,(31-dst_exponent),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 			 srcp1); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			srcp2 <<= dst_exponent+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	Sgl_set_mantissa(result, srcp1 >> SGL_EXP_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	Sgl_set_exponent(result, (62+SGL_BIAS) - dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	/* check for inexact */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	if (Duint_isinexact_to_sgl(srcp1,srcp2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		switch (Rounding_mode()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 			case ROUNDPLUS: 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 				Sgl_increment(result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 			case ROUNDMINUS: /* never negative */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			case ROUNDNEAREST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 				Sgl_roundnearest_from_duint(srcp1,srcp2,result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		if (Is_inexacttrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 			*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 			return(INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	*dstptr = result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)  *  Double Unsigned Fixed to Double Floating-point 
^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) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) dbl_to_dbl_fcnvuf(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		    dbl_unsigned *srcptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		    unsigned int *nullptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 		    dbl_floating_point *dstptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		    unsigned int *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	register int dst_exponent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	register unsigned int srcp1, srcp2, resultp1 = 0, resultp2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	Duint_copyfromptr(srcptr,srcp1,srcp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	/* Check for zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	if (srcp1 == 0 && srcp2 ==0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	       	Dbl_setzero(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	       	Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	       	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	 * Generate exponent and normalized mantissa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	dst_exponent = 16;    /* initialize for normalization */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	if (srcp1 == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		 * Check word for most significant bit set.  Returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		 * a value in dst_exponent indicating the bit position,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		 * between -1 and 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		Find_ms_one_bit(srcp2,dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		/*  left justify source, with msb at bit position 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		srcp1 = srcp2 << dst_exponent+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		srcp2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		 *  since msb set is in second word, need to 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		 *  adjust bit position count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		dst_exponent += 32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 		 * Check word for most significant bit set.  Returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		 * a value in dst_exponent indicating the bit position,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 		 * between -1 and 30.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 		Find_ms_one_bit(srcp1,dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 		/*  left justify source, with msb at bit position 0  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 		if (dst_exponent >= 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			Variable_shift_double(srcp1,srcp2,(31-dst_exponent),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 			 srcp1); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			srcp2 <<= dst_exponent+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	Dbl_set_mantissap1(resultp1, srcp1 >> DBL_EXP_LENGTH);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	Shiftdouble(srcp1,srcp2,DBL_EXP_LENGTH,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	Dbl_set_exponent(resultp1, (62+DBL_BIAS) - dst_exponent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	/* check for inexact */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	if (Duint_isinexact_to_dbl(srcp2)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		switch (Rounding_mode()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			case ROUNDPLUS: 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				Dbl_increment(resultp1,resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			case ROUNDMINUS: /* never negative */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 			case ROUNDNEAREST:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 				Dbl_roundnearest_from_duint(srcp2,resultp1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 				resultp2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 		if (Is_inexacttrap_enabled()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 			Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			return(INEXACTEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		else Set_inexactflag();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	Dbl_copytoptr(resultp1,resultp2,dstptr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	return(NOEXCEPTION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)