Merge tag 'usb-5.11-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[linux/fpc-iii.git] / arch / parisc / math-emu / denormal.c
blob7f1a60d59f21165010eef51822b953d4923b7e01
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Linux/PA-RISC Project (http://www.parisc-linux.org/)
5 * Floating-point emulation code
6 * Copyright (C) 2001 Hewlett-Packard (Paul Bame) <bame@debian.org>
7 */
8 /*
9 * BEGIN_DESC
11 * File:
12 * @(#) pa/fp/denormal.c $ Revision: $
14 * Purpose:
15 * <<please update with a synopsis of the functionality provided by this file>>
17 * External Interfaces:
18 * <<the following list was autogenerated, please review>>
19 * dbl_denormalize(dbl_opndp1,dbl_opndp2,inexactflag,rmode)
20 * sgl_denormalize(sgl_opnd,inexactflag,rmode)
22 * Internal Interfaces:
23 * <<please update>>
25 * Theory:
26 * <<please update with a overview of the operation of this file>>
28 * END_DESC
33 #include "float.h"
34 #include "sgl_float.h"
35 #include "dbl_float.h"
36 #include "hppa.h"
37 #include <linux/kernel.h>
38 /* #include <machine/sys/mdep_private.h> */
40 #undef Fpustatus_register
41 #define Fpustatus_register Fpu_register[0]
43 void
44 sgl_denormalize(unsigned int *sgl_opnd, boolean *inexactflag, int rmode)
46 unsigned int opnd;
47 int sign, exponent;
48 boolean guardbit = FALSE, stickybit, inexact;
50 opnd = *sgl_opnd;
51 stickybit = *inexactflag;
52 exponent = Sgl_exponent(opnd) - SGL_WRAP;
53 sign = Sgl_sign(opnd);
54 Sgl_denormalize(opnd,exponent,guardbit,stickybit,inexact);
55 if (inexact) {
56 switch (rmode) {
57 case ROUNDPLUS:
58 if (sign == 0) {
59 Sgl_increment(opnd);
61 break;
62 case ROUNDMINUS:
63 if (sign != 0) {
64 Sgl_increment(opnd);
66 break;
67 case ROUNDNEAREST:
68 if (guardbit && (stickybit ||
69 Sgl_isone_lowmantissa(opnd))) {
70 Sgl_increment(opnd);
72 break;
75 Sgl_set_sign(opnd,sign);
76 *sgl_opnd = opnd;
77 *inexactflag = inexact;
78 return;
81 void
82 dbl_denormalize(unsigned int *dbl_opndp1,
83 unsigned int * dbl_opndp2,
84 boolean *inexactflag,
85 int rmode)
87 unsigned int opndp1, opndp2;
88 int sign, exponent;
89 boolean guardbit = FALSE, stickybit, inexact;
91 opndp1 = *dbl_opndp1;
92 opndp2 = *dbl_opndp2;
93 stickybit = *inexactflag;
94 exponent = Dbl_exponent(opndp1) - DBL_WRAP;
95 sign = Dbl_sign(opndp1);
96 Dbl_denormalize(opndp1,opndp2,exponent,guardbit,stickybit,inexact);
97 if (inexact) {
98 switch (rmode) {
99 case ROUNDPLUS:
100 if (sign == 0) {
101 Dbl_increment(opndp1,opndp2);
103 break;
104 case ROUNDMINUS:
105 if (sign != 0) {
106 Dbl_increment(opndp1,opndp2);
108 break;
109 case ROUNDNEAREST:
110 if (guardbit && (stickybit ||
111 Dbl_isone_lowmantissap2(opndp2))) {
112 Dbl_increment(opndp1,opndp2);
114 break;
117 Dbl_set_sign(opndp1,sign);
118 *dbl_opndp1 = opndp1;
119 *dbl_opndp2 = opndp2;
120 *inexactflag = inexact;
121 return;