fpu_implode.c (92986) | fpu_implode.c (95587) |
---|---|
1/* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * --- 30 unchanged lines hidden (view full) --- 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * @(#)fpu_implode.c 8.1 (Berkeley) 6/11/93 43 * $NetBSD: fpu_implode.c,v 1.8 2001/08/26 05:44:46 eeh Exp $ 44 */ 45 46#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1992, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This software was developed by the Computer Systems Engineering group 6 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 7 * contributed to Berkeley. 8 * --- 30 unchanged lines hidden (view full) --- 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * @(#)fpu_implode.c 8.1 (Berkeley) 6/11/93 43 * $NetBSD: fpu_implode.c,v 1.8 2001/08/26 05:44:46 eeh Exp $ 44 */ 45 46#include <sys/cdefs.h> |
47__FBSDID("$FreeBSD: head/lib/libc/sparc64/fpu/fpu_implode.c 92986 2002-03-22 21:53:29Z obrien $"); | 47__FBSDID("$FreeBSD: head/lib/libc/sparc64/fpu/fpu_implode.c 95587 2002-04-27 21:56:28Z jake $"); |
48 49/* 50 * FPU subroutines: `implode' internal format numbers into the machine's 51 * `packed binary' format. 52 */ 53 54#include <sys/param.h> 55 56#include <machine/frame.h> 57#include <machine/fp.h> 58#include <machine/fsr.h> 59#include <machine/ieee.h> 60#include <machine/instr.h> 61 62#include "fpu_arith.h" 63#include "fpu_emu.h" 64#include "fpu_extern.h" | 48 49/* 50 * FPU subroutines: `implode' internal format numbers into the machine's 51 * `packed binary' format. 52 */ 53 54#include <sys/param.h> 55 56#include <machine/frame.h> 57#include <machine/fp.h> 58#include <machine/fsr.h> 59#include <machine/ieee.h> 60#include <machine/instr.h> 61 62#include "fpu_arith.h" 63#include "fpu_emu.h" 64#include "fpu_extern.h" |
65#include "__sparc_utrap_private.h" |
|
65 66static int round(struct fpemu *, struct fpn *); 67static int toinf(struct fpemu *, int); 68 69/* 70 * Round a number (algorithm from Motorola MC68882 manual, modified for 71 * our internal format). Set inexact exception if rounding is required. 72 * Return true iff we rounded up. --- 276 unchanged lines hidden (view full) --- 349 (fe->fe_fsr & (FSR_UF << FSR_TEM_SHIFT))) 350 fe->fe_cx |= FSR_UF; 351 return (sign | SNG_EXP(0) | fp->fp_mant[3]); 352 } 353 /* -FP_NG for g,r; -1 for implied 1; -SNG_FRACBITS for fraction */ 354 (void) __fpu_shr(fp, FP_NMANT - FP_NG - 1 - SNG_FRACBITS); 355#ifdef DIAGNOSTIC 356 if ((fp->fp_mant[3] & SNG_EXP(1 << FP_NG)) == 0) | 66 67static int round(struct fpemu *, struct fpn *); 68static int toinf(struct fpemu *, int); 69 70/* 71 * Round a number (algorithm from Motorola MC68882 manual, modified for 72 * our internal format). Set inexact exception if rounding is required. 73 * Return true iff we rounded up. --- 276 unchanged lines hidden (view full) --- 350 (fe->fe_fsr & (FSR_UF << FSR_TEM_SHIFT))) 351 fe->fe_cx |= FSR_UF; 352 return (sign | SNG_EXP(0) | fp->fp_mant[3]); 353 } 354 /* -FP_NG for g,r; -1 for implied 1; -SNG_FRACBITS for fraction */ 355 (void) __fpu_shr(fp, FP_NMANT - FP_NG - 1 - SNG_FRACBITS); 356#ifdef DIAGNOSTIC 357 if ((fp->fp_mant[3] & SNG_EXP(1 << FP_NG)) == 0) |
357 __fpu_panic("fpu_ftos"); | 358 __utrap_panic("fpu_ftos"); |
358#endif 359 if (round(fe, fp) && fp->fp_mant[3] == SNG_EXP(2)) 360 exp++; 361 if (exp >= SNG_EXP_INFNAN) { 362 /* overflow to inf or to max single */ 363 fe->fe_cx |= FSR_OF | FSR_NX; 364 if (toinf(fe, sign)) 365 return (sign | SNG_EXP(SNG_EXP_INFNAN)); --- 158 unchanged lines hidden (view full) --- 524 break; 525 526 case FTYPE_EXT: 527 /* funky rounding precision options ?? */ 528 space[0] = __fpu_ftoq(fe, fp, space); 529 break; 530 531 default: | 359#endif 360 if (round(fe, fp) && fp->fp_mant[3] == SNG_EXP(2)) 361 exp++; 362 if (exp >= SNG_EXP_INFNAN) { 363 /* overflow to inf or to max single */ 364 fe->fe_cx |= FSR_OF | FSR_NX; 365 if (toinf(fe, sign)) 366 return (sign | SNG_EXP(SNG_EXP_INFNAN)); --- 158 unchanged lines hidden (view full) --- 525 break; 526 527 case FTYPE_EXT: 528 /* funky rounding precision options ?? */ 529 space[0] = __fpu_ftoq(fe, fp, space); 530 break; 531 532 default: |
532 __fpu_panic("fpu_implode"); | 533 __utrap_panic("fpu_implode"); |
533 } 534 DPRINTF(FPE_REG, ("fpu_implode: %x %x %x %x\n", 535 space[0], space[1], space[2], space[3])); 536} | 534 } 535 DPRINTF(FPE_REG, ("fpu_implode: %x %x %x %x\n", 536 space[0], space[1], space[2], space[3])); 537} |