Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add ilogbl(3).



details:   https://anonhg.NetBSD.org/src/rev/b48a2673bb84
branches:  trunk
changeset: 767747:b48a2673bb84
user:      joerg <joerg%NetBSD.org@localhost>
date:      Thu Jul 28 22:32:28 2011 +0000

description:
Add ilogbl(3).

diffstat:

 distrib/sets/lists/comp/mi    |   5 ++-
 include/math.h                |   4 +-
 lib/libm/Makefile             |  10 ++--
 lib/libm/arch/i387/s_ilogbl.S |  24 +++++++++++++
 lib/libm/man/ilogb.3          |  17 +++++----
 lib/libm/src/s_ilogb.c        |   6 ++-
 lib/libm/src/s_ilogbl.c       |  76 +++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 126 insertions(+), 16 deletions(-)

diffs (269 lines):

diff -r 70265b3c8863 -r b48a2673bb84 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi        Thu Jul 28 22:28:07 2011 +0000
+++ b/distrib/sets/lists/comp/mi        Thu Jul 28 22:32:28 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: mi,v 1.1648 2011/07/28 21:10:25 joerg Exp $
+#      $NetBSD: mi,v 1.1649 2011/07/28 22:32:28 joerg Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6782,6 +6782,7 @@
 ./usr/share/man/cat3/ilog2.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/ilogb.0                   comp-c-catman           .cat
 ./usr/share/man/cat3/ilogbf.0                  comp-c-catman           .cat
+./usr/share/man/cat3/ilogbl.0                  comp-c-catman           .cat
 ./usr/share/man/cat3/imaxabs.0                 comp-c-catman           .cat
 ./usr/share/man/cat3/imaxdiv.0                 comp-c-catman           .cat
 ./usr/share/man/cat3/inch.0                    comp-c-catman           .cat
@@ -12877,6 +12878,7 @@
 ./usr/share/man/html3/ilog2.html               comp-c-htmlman          html
 ./usr/share/man/html3/ilogb.html               comp-c-htmlman          html
 ./usr/share/man/html3/ilogbf.html              comp-c-htmlman          html
+./usr/share/man/html3/ilogbl.html              comp-c-htmlman          html
 ./usr/share/man/html3/imaxabs.html             comp-c-htmlman          html
 ./usr/share/man/html3/imaxdiv.html             comp-c-htmlman          html
 ./usr/share/man/html3/inch.html                        comp-c-htmlman          html
@@ -18891,6 +18893,7 @@
 ./usr/share/man/man3/ilog2.3                   comp-c-man              .man
 ./usr/share/man/man3/ilogb.3                   comp-c-man              .man
 ./usr/share/man/man3/ilogbf.3                  comp-c-man              .man
+./usr/share/man/man3/ilogbl.3                  comp-c-man              .man
 ./usr/share/man/man3/imaxabs.3                 comp-c-man              .man
 ./usr/share/man/man3/imaxdiv.3                 comp-c-man              .man
 ./usr/share/man/man3/inch.3                    comp-c-man              .man
diff -r 70265b3c8863 -r b48a2673bb84 include/math.h
--- a/include/math.h    Thu Jul 28 22:28:07 2011 +0000
+++ b/include/math.h    Thu Jul 28 22:32:28 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: math.h,v 1.55 2011/07/26 16:10:15 joerg Exp $  */
+/*     $NetBSD: math.h,v 1.56 2011/07/28 22:32:28 joerg Exp $  */
 
 /*
  * ====================================================
@@ -498,6 +498,8 @@
 int    __signbitl(long double);
 #endif
 
+int            ilogbl(long double);
+long double    logbl(long double);
 long double    scalbnl(long double, int);
 
 __END_DECLS
diff -r 70265b3c8863 -r b48a2673bb84 lib/libm/Makefile
--- a/lib/libm/Makefile Thu Jul 28 22:28:07 2011 +0000
+++ b/lib/libm/Makefile Thu Jul 28 22:32:28 2011 +0000
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.114 2011/07/28 21:10:29 joerg Exp $
+#  $NetBSD: Makefile,v 1.115 2011/07/28 22:32:28 joerg Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -69,8 +69,8 @@
            e_remainderf.S e_scalb.S e_scalbf.S e_sqrt.S e_sqrtf.S s_atan.S \
            s_atanf.S s_ceil.S s_ceilf.S s_copysign.S s_copysignf.S s_cos.S \
            s_cosf.S s_finite.S s_finitef.S s_floor.S s_floorf.S s_ilogb.S \
-           s_ilogbf.S s_log1p.S s_log1pf.S s_logb.S s_logbf.S s_rint.S \
-           s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
+           s_ilogbf.S s_ilogbl.S s_log1p.S s_log1pf.S s_logb.S s_logbf.S \
+           s_rint.S s_rintf.S s_scalbn.S s_scalbnf.S s_significand.S \
            s_significandf.S s_sin.S s_sinf.S s_tan.S s_tanf.S lrint.S
 # do not pick up the i387 asm version, it is incorrect
 s_modf.o s_modf.pico s_modf.po s_modf.d: s_modf.c
@@ -137,7 +137,7 @@
        s_ceilf.c s_copysign.c s_copysignf.c s_copysignl.c s_cos.c s_cosf.c s_erf.c \
        s_erff.c s_exp2.c s_exp2f.c s_expm1.c s_expm1f.c s_fabsf.c s_fabsl.c \
        s_finite.c s_finitef.c \
-       s_floor.c s_floorf.c s_frexpf.c s_ilogb.c s_ilogbf.c \
+       s_floor.c s_floorf.c s_frexpf.c s_ilogb.c s_ilogbf.c s_ilogbl.c \
        s_isinff.c s_isnanf.c s_ldexpf.c s_lib_version.c s_log1p.c \
        s_log1pf.c s_logb.c s_logbf.c s_matherr.c s_modff.c s_nextafter.c \
        s_nextafterf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c s_round.c s_roundf.c s_scalbn.c \
@@ -257,7 +257,7 @@
 MLINKS+=ieee_test.3 logb.3 ieee_test.3 logbf.3
 MLINKS+=ieee_test.3 scalb.3 ieee_test.3 scalbf.3
 MLINKS+=ieee_test.3 significand.3 ieee_test.3 significandf.3
-MLINKS+=ilogb.3 ilogbf.3
+MLINKS+=ilogb.3 ilogbf.3 ilogb.3 ilogbl.3
 MLINKS+=isinff.3 isnanf.3
 MLINKS+=j0.3 j0f.3 j0.3 j1.3 j0.3 j1f.3 j0.3 jn.3 j0.3 jnf.3 \
        j0.3 y0.3 j0.3 y0f.3 j0.3 y1.3 j0.3 y1f.3 j0.3 yn.3 j0.3 ynf.3
diff -r 70265b3c8863 -r b48a2673bb84 lib/libm/arch/i387/s_ilogbl.S
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/arch/i387/s_ilogbl.S     Thu Jul 28 22:32:28 2011 +0000
@@ -0,0 +1,24 @@
+/*
+ * Written by J.T. Conklin <jtc%NetBSD.org@localhost>.
+ * Public domain.
+ */
+
+#include <machine/asm.h>
+
+RCSID("$NetBSD: s_ilogbl.S,v 1.1 2011/07/28 22:32:28 joerg Exp $")
+
+#include "abi.h"
+
+ENTRY(ilogbl)
+       fldt    ARG_LONG_DOUBLE_ONE
+       fxtract
+       fstp    %st
+#ifdef __i386__
+       pushl   %eax
+       fistpl  0(%esp)
+       popl    %eax
+#else
+       fistpl  -4(%rsp)
+       movl    -4(%rsp), %eax
+#endif
+       ret
diff -r 70265b3c8863 -r b48a2673bb84 lib/libm/man/ilogb.3
--- a/lib/libm/man/ilogb.3      Thu Jul 28 22:28:07 2011 +0000
+++ b/lib/libm/man/ilogb.3      Thu Jul 28 22:32:28 2011 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ilogb.3,v 1.1 2011/05/10 06:38:33 jruoho Exp $
+.\" $NetBSD: ilogb.3,v 1.2 2011/07/28 22:32:29 joerg Exp $
 .\"
 .\" Copyright (c) 2011 Jukka Ruohonen <jruohonen%iki.fi@localhost>
 .\" All rights reserved.
@@ -24,12 +24,13 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd May 10, 2011
+.Dd July 29, 2011
 .Dt ILOGB 3
 .Os
 .Sh NAME
 .Nm ilogb ,
-.Nm ilogbf
+.Nm ilogbf ,
+.Nm ilogbl
 .Nd an unbiased exponent
 .Sh LIBRARY
 .Lb libm
@@ -39,11 +40,14 @@
 .Fn ilogb "double x"
 .Ft int
 .Fn ilogbf "float x"
+.Ft int
+.Fn ilogbl "long double x"
 .Sh DESCRIPTION
 The
-.Fn ilogb
+.Fn ilogb ,
+.Fn ilogbf
 and
-.Fn ilogbf
+.Fn ilogbl
 functions return the exponent of the non-zero real floating-point number
 .Fa x
 as a signed integer value.
@@ -105,6 +109,3 @@
 .Dv FP_ILOGBNAN
 is defined currently in
 .Nx .
-Furthermore, the
-.Vt long double
-variant of the functions is not yet supported.
diff -r 70265b3c8863 -r b48a2673bb84 lib/libm/src/s_ilogb.c
--- a/lib/libm/src/s_ilogb.c    Thu Jul 28 22:28:07 2011 +0000
+++ b/lib/libm/src/s_ilogb.c    Thu Jul 28 22:32:28 2011 +0000
@@ -12,7 +12,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_ilogb.c,v 1.12 2002/05/26 22:01:56 wiz Exp $");
+__RCSID("$NetBSD: s_ilogb.c,v 1.13 2011/07/28 22:32:29 joerg Exp $");
 #endif
 
 /* ilogb(double x)
@@ -24,6 +24,10 @@
 #include "math.h"
 #include "math_private.h"
 
+#ifndef __HAVE_LONG_DOUBLE
+__strong_alias(ilogbl,ilogb)
+#endif
+
 int
 ilogb(double x)
 {
diff -r 70265b3c8863 -r b48a2673bb84 lib/libm/src/s_ilogbl.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/src/s_ilogbl.c   Thu Jul 28 22:32:28 2011 +0000
@@ -0,0 +1,76 @@
+/*     $NetBSD: s_ilogbl.c,v 1.1 2011/07/28 22:32:29 joerg Exp $       */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Joerg Sonnenberger.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD: s_ilogbl.c,v 1.1 2011/07/28 22:32:29 joerg Exp $");
+
+#include "namespace.h"
+
+#include <float.h>
+#include <math.h>
+#include <machine/ieee.h>
+
+#ifdef __HAVE_LONG_DOUBLE
+
+#if LDBL_MANT_DIG == 64
+#define        FROM_UNDERFLOW  0x1p65L
+#elif LDBL_MANT_DIG == 113
+#define        FROM_UNDERFLOW  0x1p114L
+#else
+#error Unsupported long double format
+#endif
+
+int
+ilogbl(long double x)
+{
+       union ieee_ext_u u;
+
+       if (x == 0.0L)
+               return 0x80000001;      /* ilogbl(0) = 0x80000001 */
+
+       u.extu_ld = x;
+
+       if (u.extu_ext.ext_exp == EXT_EXP_INFNAN)
+               return 0x7fffffff;
+
+       if (u.extu_ext.ext_exp == 0) {
+               /*
+                * Scale denormalized numbers slightly,
+                * so that they are normal.
+                */
+               u.extu_ld *= FROM_UNDERFLOW;
+               return u.extu_ext.ext_exp - EXT_EXP_BIAS - LDBL_MANT_DIG - 1;
+       }
+       return u.extu_ext.ext_exp - EXT_EXP_BIAS;
+
+}
+
+#endif



Home | Main Index | Thread Index | Old Index