jcs's openbsd hax
openbsd

Make sure modf() returns correct values for infinities. While there, drop the few assembler versions as has been done on other *BSD systems; this function (modf) turns out to be non-trivial enough, having only one known-to-work version is preferrable.

Reported by Willemijn Coene.

miod f78f1c7c ec5fc283

+14 -433
+2 -2
lib/libc/arch/amd64/gen/Makefile.inc
··· 1 - # $OpenBSD: Makefile.inc,v 1.13 2020/07/06 13:33:05 pirofti Exp $ 1 + # $OpenBSD: Makefile.inc,v 1.14 2023/08/13 06:55:37 miod Exp $ 2 2 3 - SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.S nan.c setjmp.S \ 3 + SRCS+= _setjmp.S fabs.S infinity.c ldexp.c modf.c nan.c setjmp.S \ 4 4 sigsetjmp.S 5 5 SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c isnormall.c signbitl.c \ 6 6 usertc.c
-94
lib/libc/arch/amd64/gen/modf.S
··· 1 - /* $OpenBSD: modf.S,v 1.6 2018/07/03 23:14:05 mortimer Exp $ */ 2 - /* $NetBSD: modf.S,v 1.1 2001/06/19 00:25:03 fvdl Exp $ */ 3 - 4 - /*- 5 - * Copyright (c) 1990 The Regents of the University of California. 6 - * All rights reserved. 7 - * 8 - * This code is derived from software contributed to Berkeley by 9 - * Sean Eric Fagan. 10 - * 11 - * Redistribution and use in source and binary forms, with or without 12 - * modification, are permitted provided that the following conditions 13 - * are met: 14 - * 1. Redistributions of source code must retain the above copyright 15 - * notice, this list of conditions and the following disclaimer. 16 - * 2. Redistributions in binary form must reproduce the above copyright 17 - * notice, this list of conditions and the following disclaimer in the 18 - * documentation and/or other materials provided with the distribution. 19 - * 3. All advertising materials mentioning features or use of this software 20 - * must display the following acknowledgement: 21 - * This product includes software developed by the University of 22 - * California, Berkeley and its contributors. 23 - * 4. Neither the name of the University nor the names of its contributors 24 - * may be used to endorse or promote products derived from this software 25 - * without specific prior written permission. 26 - * 27 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37 - * SUCH DAMAGE. 38 - * 39 - * from: @(#)modf.s 5.5 (Berkeley) 3/18/91 40 - */ 41 - 42 - #include <machine/asm.h> 43 - 44 - /* 45 - * modf(value, iptr): return fractional part of value, and stores the 46 - * integral part into iptr (a pointer to double). 47 - * 48 - * Written by Sean Eric Fagan (sef@kithrup.COM) 49 - * Sun Mar 11 20:27:30 PST 1990 50 - */ 51 - 52 - /* With CHOP mode on, frndint behaves as TRUNC does. Useful. */ 53 - ENTRY(modf) 54 - RETGUARD_SETUP(modf, r11) 55 - 56 - /* 57 - * Set chop mode. 58 - */ 59 - fnstcw -12(%rsp) 60 - movw -12(%rsp),%dx 61 - orw $3072,%dx 62 - movw %dx,-16(%rsp) 63 - fldcw -16(%rsp) 64 - 65 - /* 66 - * Get integral part. 67 - */ 68 - movsd %xmm0,-24(%rsp) 69 - fldl -24(%rsp) 70 - frndint 71 - fstpl -8(%rsp) 72 - 73 - /* 74 - * Restore control word. 75 - */ 76 - fldcw -12(%rsp) 77 - 78 - /* 79 - * Store integral part. 80 - */ 81 - movsd -8(%rsp),%xmm0 82 - movsd %xmm0,(%rdi) 83 - 84 - /* 85 - * Get fractional part and return it. 86 - */ 87 - fldl -24(%rsp) 88 - fsubl -8(%rsp) 89 - fstpl -8(%rsp) 90 - movsd -8(%rsp),%xmm0 91 - 92 - RETGUARD_CHECK(modf, r11) 93 - ret 94 - END(modf)
+2 -2
lib/libc/arch/i386/gen/Makefile.inc
··· 1 - # $OpenBSD: Makefile.inc,v 1.15 2020/07/06 13:33:05 pirofti Exp $ 1 + # $OpenBSD: Makefile.inc,v 1.16 2023/08/13 06:55:37 miod Exp $ 2 2 3 3 SRCS+= _setjmp.S fabs.S infinity.c ldexp.c usertc.c \ 4 - modf.S nan.c setjmp.S sigsetjmp.S 4 + modf.c nan.c setjmp.S sigsetjmp.S 5 5 SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c isnormall.c signbitl.c 6 6 SRCS+= flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S fpsetmask.S \ 7 7 fpsetround.S fpsetsticky.S
-68
lib/libc/arch/i386/gen/modf.S
··· 1 - /* $OpenBSD: modf.S,v 1.7 2011/07/08 22:28:33 martynas Exp $ */ 2 - /*- 3 - * Copyright (c) 1990 The Regents of the University of California. 4 - * All rights reserved. 5 - * 6 - * This code is derived from software contributed to Berkeley by 7 - * Sean Eric Fagan. 8 - * 9 - * Redistribution and use in source and binary forms, with or without 10 - * modification, are permitted provided that the following conditions 11 - * are met: 12 - * 1. Redistributions of source code must retain the above copyright 13 - * notice, this list of conditions and the following disclaimer. 14 - * 2. Redistributions in binary form must reproduce the above copyright 15 - * notice, this list of conditions and the following disclaimer in the 16 - * documentation and/or other materials provided with the distribution. 17 - * 3. Neither the name of the University nor the names of its contributors 18 - * may be used to endorse or promote products derived from this software 19 - * without specific prior written permission. 20 - * 21 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 - * SUCH DAMAGE. 32 - */ 33 - 34 - #include <machine/asm.h> 35 - 36 - /* 37 - * modf(value, iptr): return fractional part of value, and stores the 38 - * integral part into iptr (a pointer to double). 39 - * 40 - * Written by Sean Eric Fagan (sef@kithrup.COM) 41 - * Sun Mar 11 20:27:30 PST 1990 42 - */ 43 - 44 - /* With CHOP mode on, frndint behaves as TRUNC does. Useful. */ 45 - ENTRY(modf) 46 - pushl %ebp 47 - movl %esp,%ebp 48 - subl $16,%esp 49 - fnstcw -12(%ebp) 50 - movw -12(%ebp),%dx 51 - orw $3072,%dx 52 - movw %dx,-16(%ebp) 53 - fldcw -16(%ebp) 54 - fldl 8(%ebp) 55 - frndint 56 - fstpl -8(%ebp) 57 - fldcw -12(%ebp) 58 - movl 16(%ebp),%eax 59 - movl -8(%ebp),%edx 60 - movl -4(%ebp),%ecx 61 - movl %edx,(%eax) 62 - movl %ecx,4(%eax) 63 - fldl 8(%ebp) 64 - fsubl -8(%ebp) 65 - jmp L1 66 - L1: 67 - leave 68 - ret
+2 -2
lib/libc/arch/mips64/gen/Makefile.inc
··· 1 - # $OpenBSD: Makefile.inc,v 1.13 2020/07/06 13:33:05 pirofti Exp $ 1 + # $OpenBSD: Makefile.inc,v 1.14 2023/08/13 06:55:37 miod Exp $ 2 2 3 - SRCS+= _setjmp.S fabs.S infinity.c ldexp.S modf.S nan.c usertc.c 3 + SRCS+= _setjmp.S fabs.S infinity.c ldexp.S modf.c nan.c usertc.c 4 4 SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ 5 5 fpsetround.c fpsetsticky.c 6 6 SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c isnormall.c signbitl.c
-71
lib/libc/arch/mips64/gen/modf.S
··· 1 - /* $OpenBSD: modf.S,v 1.5 2011/07/08 22:28:33 martynas Exp $ */ 2 - /*- 3 - * Copyright (c) 1991, 1993, 1995 4 - * The Regents of the University of California. All rights reserved. 5 - * 6 - * This code is derived from software contributed to Berkeley by 7 - * Ralph Campbell. 8 - * 9 - * Redistribution and use in source and binary forms, with or without 10 - * modification, are permitted provided that the following conditions 11 - * are met: 12 - * 1. Redistributions of source code must retain the above copyright 13 - * notice, this list of conditions and the following disclaimer. 14 - * 2. Redistributions in binary form must reproduce the above copyright 15 - * notice, this list of conditions and the following disclaimer in the 16 - * documentation and/or other materials provided with the distribution. 17 - * 3. Neither the name of the University nor the names of its contributors 18 - * may be used to endorse or promote products derived from this software 19 - * without specific prior written permission. 20 - * 21 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 - * SUCH DAMAGE. 32 - */ 33 - 34 - #include <machine/asm.h> 35 - 36 - /* 37 - * double modf(val, iptr) 38 - * double val, *iptr; 39 - * returns: xxx and n (in *iptr) where val == n.xxx 40 - */ 41 - LEAF(modf, 0) 42 - .set reorder 43 - cfc1 t0, $31 # get the control register 44 - li.d $f2, 4503599627370496e0 # f2 <- 2^52 45 - 46 - or t1, t0, 0x3 # set rounding mode to round to zero 47 - xor t1, t1, 0x2 # (i.e., 01) 48 - ctc1 t1, $31 49 - 50 - mov.d $f0, $f12 # f0 <- f12 51 - abs.d $f4, $f12 # f4 <- |f12| 52 - c.olt.d $f4, $f2 # f4 ? < f2 53 - bc1f 1f # leave f0 alone if Nan, infinity 54 - # or >=2^52 55 - c.eq.d $f12,$f4 # was f12 positive ? 56 - add.d $f4,$f2,$f4 # round off to integer 57 - bc1f 2f # No -> will have to negate result 58 - sub.d $f0,$f4,$f2 # Remove fudge factor 59 - j 1f # integer fraction got 60 - 2: 61 - sub.d $f0,$f2,$f4 # Remove fudge factor and negate 62 - 1: 63 - ctc1 t0, $31 # restore old rounding mode 64 - #ifdef __mips64 65 - s.d $f0, 0(a1) # save the integer part 66 - #else 67 - s.d $f0, 0(a2) # save the integer part 68 - #endif 69 - sub.d $f0, $f12, $f0 # subtract val - integer part 70 - j ra 71 - END(modf)
+2 -2
lib/libc/arch/sparc64/gen/Makefile.inc
··· 1 - # $OpenBSD: Makefile.inc,v 1.16 2020/07/08 09:20:28 kettenis Exp $ 1 + # $OpenBSD: Makefile.inc,v 1.17 2023/08/13 06:55:37 miod Exp $ 2 2 3 3 SRCS+= _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpclassifyl.c \ 4 4 fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ 5 5 fpsetround.c fpsetsticky.c infinity.c isfinitel.c \ 6 - isinfl.c isnanl.c isnormall.c ldexp.c usertc.c modf.S \ 6 + isinfl.c isnanl.c isnormall.c ldexp.c usertc.c modf.c \ 7 7 mul.S nan.c setjmp.S signbitl.c sigsetjmp.S umul.S 8 8 9 9 CFLAGS += -Wa,-Av9b
-188
lib/libc/arch/sparc64/gen/modf.S
··· 1 - /* $OpenBSD: modf.S,v 1.7 2023/01/13 17:52:08 miod Exp $ */ 2 - /* $NetBSD: modf.S,v 1.3 2000/11/01 23:32:41 eeh Exp $ */ 3 - 4 - /* 5 - * Copyright (c) 1992, 1993 6 - * The Regents of the University of California. All rights reserved. 7 - * 8 - * This software was developed by the Computer Systems Engineering group 9 - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 10 - * contributed to Berkeley. 11 - * 12 - * Redistribution and use in source and binary forms, with or without 13 - * modification, are permitted provided that the following conditions 14 - * are met: 15 - * 1. Redistributions of source code must retain the above copyright 16 - * notice, this list of conditions and the following disclaimer. 17 - * 2. Redistributions in binary form must reproduce the above copyright 18 - * notice, this list of conditions and the following disclaimer in the 19 - * documentation and/or other materials provided with the distribution. 20 - * 3. Neither the name of the University nor the names of its contributors 21 - * may be used to endorse or promote products derived from this software 22 - * without specific prior written permission. 23 - * 24 - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34 - * SUCH DAMAGE. 35 - */ 36 - 37 - #include <machine/asm.h> 38 - 39 - #include <machine/fsr.h> 40 - 41 - /* 42 - * double modf(double val, double *iptr) 43 - * 44 - * Returns the fractional part of `val', storing the integer part of 45 - * `val' in *iptr. Both *iptr and the return value have the same sign 46 - * as `val'. 47 - * 48 - * Method: 49 - * 50 - * We use the fpu's normalization hardware to compute the integer portion 51 - * of the double precision argument. Sun IEEE double precision numbers 52 - * have 52 bits of mantissa, 11 bits of exponent, and one bit of sign, 53 - * with the sign occupying bit 31 of word 0, and the exponent bits 30:20 54 - * of word 0. Thus, values >= 2^52 are by definition integers. 55 - * 56 - * If we take a value that is in the range [+0..2^52) and add 2^52, all 57 - * of the fractional bits fall out and all of the integer bits are summed 58 - * with 2^52. If we then subtract 2^52, we get those integer bits back. 59 - * This must be done with rounding set to `towards 0' or `towards -inf'. 60 - * `Toward -inf' fails when the value is 0 (we get -0 back).... 61 - * 62 - * Note that this method will work anywhere, but is machine dependent in 63 - * various aspects. 64 - * 65 - * Stack usage: 66 - * 4@[%fp + BIAS - 4] saved %fsr 67 - * 4@[%fp + BIAS - 8] new %fsr with rounding set to `towards 0' 68 - * 8@[%fp + BIAS - 16] space for moving between %i and %f registers 69 - * Register usage: 70 - * %f0:f1 double val; 71 - * %l0 scratch 72 - * %l1 sign bit (0x80000000) 73 - * %i1 double *iptr; 74 - * %f2:f3 `magic number' 2^52, in fpu registers 75 - * %f4:f5 double v, in fpu registers 76 - * %f6:f7 double temp. 77 - */ 78 - 79 - .section .rodata 80 - .align 8 81 - Lmagic: 82 - .word 0x43300000 ! sign = 0, exponent = 52 + 1023, mantissa = 0 83 - .word 0 ! (i.e., .double 0r4503599627370496e+00) 84 - 85 - L0: 86 - .word 0 ! 0.0 87 - .word 0 88 - 89 - .text 90 - ENTRY(modf) 91 - save %sp, -CC64FSZ-16, %sp 92 - #ifdef __PIC__ 93 - PIC_PROLOGUE(%o5, %o4) 94 - #endif 95 - 96 - /* 97 - * First, compute v = abs(val) 98 - */ 99 - fabsd %f0, %f4 ! %f4:f5 = v 100 - fcmped %fcc1, %f0, %f4 ! %fcc1 = (val == abs(val)) 101 - #ifdef __PIC__ 102 - set Lmagic, %o4 103 - ldx [%o5 + %o4], %l0 104 - ldd [%l0], %f2 105 - #else 106 - sethi %hi(Lmagic), %l0 107 - ldd [%l0 + %lo(Lmagic)], %f2 108 - #endif 109 - 110 - /* 111 - * Is %f4:f5 >= %f2:f3 ? If so, it is all integer bits. 112 - * It is probably less, though. 113 - */ 114 - fcmped %f4, %f2 115 - fbuge Lbig ! if >= (or unordered), go out 116 - nop 117 - 118 - /* 119 - * v < 2^52, so add 2^52, then subtract 2^52, but do it all 120 - * with rounding set towards zero. We leave any enabled 121 - * traps enabled, but change the rounding mode. This might 122 - * not be so good. Oh well.... 123 - */ 124 - st %fsr, [%fp + BIAS - 4] ! %l5 = current FSR mode 125 - set FSR_RD, %l3 ! %l3 = rounding direction mask 126 - ld [%fp + BIAS - 4], %l5 127 - set FSR_RD_RZ << FSR_RD_SHIFT, %l4 128 - andn %l5, %l3, %l6 129 - or %l6, %l4, %l6 ! round towards zero, please 130 - and %l5, %l3, %l5 ! save original rounding mode 131 - st %l6, [%fp + BIAS - 8] 132 - ld [%fp + BIAS - 8], %fsr 133 - 134 - faddd %f4, %f2, %f4 ! %f4:f5 += 2^52 135 - fsubd %f4, %f2, %f4 ! %f4:f5 -= 2^52 136 - 137 - /* 138 - * Restore %fsr, but leave exceptions accrued. 139 - */ 140 - st %fsr, [%fp + BIAS - 4] 141 - ld [%fp + BIAS - 4], %l6 142 - andn %l6, %l3, %l6 ! %l6 = %fsr & ~FSR_RD; 143 - or %l5, %l6, %l5 ! %l5 |= %l6; 144 - st %l5, [%fp + BIAS - 4] 145 - ld [%fp + BIAS - 4], %fsr ! restore %fsr, leaving accrued stuff 146 - 147 - /* 148 - * Now insert the original sign in %f4:f5. 149 - * %fcc1 should still have the reults of (val == abs(val)) 150 - * from above, so we use a conditional move on %fcc1 to: 151 - * 152 - * %f4 = (val == abs(val)) ? %f4 : -%f4 153 - * 154 - */ 155 - fnegd %f4, %f6 156 - fmovdnz %fcc1, %f6, %f4 157 - 1: 158 - 159 - /* 160 - * The value in %f4:f5 is now the integer portion of the original 161 - * argument. We need to store this in *ival (%i1), subtract it 162 - * from the original value argument (%d0), and return the result. 163 - */ 164 - std %f4, [%i1] ! *ival = %f4:f5; 165 - fsubd %f0, %f4, %f0 ! %f0:f1 -= %f4:f5; 166 - ret 167 - restore 168 - 169 - Lbig: 170 - /* 171 - * We get here if the original comparison of %f4:f5 (v) to 172 - * %f2:f3 (2^52) came out `greater or unordered'. In this 173 - * case the integer part is the original value, and the 174 - * fractional part is 0. 175 - */ 176 - #ifdef __PIC__ 177 - set L0, %o4 178 - ldx [%o5 + %o4], %l0 179 - std %f0, [%i1] ! *ival = val; 180 - ldd [%l0], %f0 ! return 0.0; 181 - #else 182 - sethi %hi(L0), %l0 183 - std %f0, [%i1] ! *ival = val; 184 - ldd [%l0 + %lo(L0)], %f0 ! return 0.0; 185 - #endif 186 - ret 187 - restore 188 -
+6 -4
lib/libc/gen/modf.c
··· 1 - /* $OpenBSD: modf.c,v 1.6 2013/07/03 04:46:36 espie Exp $ */ 1 + /* $OpenBSD: modf.c,v 1.7 2023/08/13 06:55:37 miod Exp $ */ 2 2 /* $NetBSD: modf.c,v 1.1 1995/02/10 17:50:25 cgd Exp $ */ 3 3 4 4 /* ··· 51 51 u_int64_t frac; 52 52 53 53 /* 54 - * If input is Inf or NaN, return it and leave i alone. 54 + * If input is +/-Inf or NaN, return +/-0 or NaN. 55 55 */ 56 56 u.v = val; 57 - if (u.s.dbl_exp == DBL_EXP_INFNAN) 58 - return (u.v); 57 + if (u.s.dbl_exp == DBL_EXP_INFNAN) { 58 + *iptr = u.v; 59 + return (0.0 / u.v); 60 + } 59 61 60 62 /* 61 63 * If input can't have a fractional part, return