/* $NetBSD: s_rintl.c,v 1.5 2013/08/21 13:04:44 martin Exp $ */ /*- * Copyright (c) 2008 David Schultz * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include #if 0 __FBSDID("$FreeBSD: src/lib/msun/src/s_rintl.c,v 1.5 2008/02/22 11:59:05 bde Exp $"); #else __RCSID("$NetBSD: s_rintl.c,v 1.5 2013/08/21 13:04:44 martin Exp $"); #endif #include #include #include "math.h" #include "math_private.h" #ifdef __HAVE_LONG_DOUBLE static const float shift[2] = { #if EXT_FRACBITS == 64 0x1.0p63, -0x1.0p63 #elif EXT_FRACBITS == 113 0x1.0p112, -0x1.0p112 #elif EXT_FRACBITS == 112 0x1.0p111, -0x1.0p111 #else #error "Unsupported long double format" #endif }; static const float zero[2] = { 0.0, -0.0 }; long double rintl(long double x) { union ieee_ext_u u; uint32_t expsign; int ex, sign; u.extu_ld = x; u.extu_ext.ext_frach &= ~0x80000000; expsign = u.extu_ext.ext_sign; ex = expsign & 0x7fff; if (ex >= EXT_EXP_BIAS + EXT_FRACBITS - 1) { if (ex == EXT_EXP_BIAS + EXT_FRACBITS) return (x + x); /* Inf, NaN, or unsupported format */ return (x); /* finite and already an integer */ } sign = expsign >> 15; /* * The following code assumes that intermediate results are * evaluated in long double precision. If they are evaluated in * greater precision, double rounding may occur, and if they are * evaluated in less precision (as on i386), results will be * wildly incorrect. */ x += shift[sign]; x -= shift[sign]; /* * If the result is +-0, then it must have the same sign as x, but * the above calculation doesn't always give this. Fix up the sign. */ if (ex < EXT_EXP_BIAS && x == 0.0L) return (zero[sign]); return (x); } #endif /td>thorpej 2019-05-28 Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.msaitoh 2019-05-23 Whitespace fix (mainly tabify).msaitoh 2019-05-23- Use aprint_*().msaitoh 2018-06-26 Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backwardmsaitoh 2018-06-22 It's not required to include net/bpfdesc.h. Remove it.msaitoh 2016-12-15Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_inputozaki-r 2016-06-10Introduce m_set_rcvif and m_reset_rcvifozaki-r 2016-02-09Introduce softint-based if_inputozaki-r 2013-10-25Eliminate unused variablemartin 2010-12-15Need to include <sys/device.h> since vax's <sys/cpu.h> doesn't.matt 2010-11-13Don't pull in the whole uvm(9) API to access only PAGE_SIZE anduebayasi 2010-04-05Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpfjoerg 2010-01-19Redefine bpf linkage through an always present op vector, i.e.pooka 2010-01-16Delete some dead (#ifdef notyet) code.dyoung 2009-11-23Remove some unecessary includes sys/user.h header.rmind 2009-05-12KNFcegger 2009-03-14Change about 4500 of the K&R function definitions to ANSI ones.dsl 2008-11-07*** Summary ***dyoung 2008-07-09Fix device/softc split.joerg 2008-07-09- device/softc splitjoerg 2008-06-12use device_lookup_private to get softccegger 2008-04-06use aprint_*_dev and device_xnamecegger 2008-03-11Rototill the vax code. Switch to devicet/PRIV_ALLOC. Cleanup vax autoconfmatt 2007-10-19machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.had 2007-09-06Remove a now-unused local variable.he 2007-09-01Change a bazillion occurrences of code resembling this,dyoung 2007-03-08Cast to char* before doing pointer arithmetic.he 2007-03-04Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.christos 2007-02-16More vax changes.ad 2005-12-11merge ktrace-lwp.christos 2005-06-27Fixes due to cast-qual addition.ragge 2005-02-27nuke trailing whitespaceperry 2005-02-04de-__Pperry