Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add modfl(3). From FreeBSD.
details: https://anonhg.NetBSD.org/src/rev/26c667df2792
branches: trunk
changeset: 329991:26c667df2792
user: joerg <joerg%NetBSD.org@localhost>
date: Mon Jun 16 12:54:42 2014 +0000
description:
Add modfl(3). From FreeBSD.
diffstat:
distrib/sets/lists/comp/mi | 8 ++-
distrib/sets/lists/debug/mi | 3 +-
distrib/sets/lists/tests/mi | 3 +-
lib/libm/Makefile | 6 +-
lib/libm/src/namespace.h | 3 +-
lib/libm/src/s_modf.c | 7 ++-
lib/libm/src/s_modfl.c | 109 ++++++++++++++++++++++++++++++++++++++++++++
tests/lib/libm/Makefile | 3 +-
tests/lib/libm/t_modf.c | 68 +++++++++++++++++++++++++++
9 files changed, 202 insertions(+), 8 deletions(-)
diffs (truncated from 340 to 300 lines):
diff -r 70b6f3c9a306 -r 26c667df2792 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Mon Jun 16 12:38:32 2014 +0000
+++ b/distrib/sets/lists/comp/mi Mon Jun 16 12:54:42 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1894 2014/05/28 11:32:50 tron Exp $
+# $NetBSD: mi,v 1.1895 2014/06/16 12:54:42 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -7960,6 +7960,8 @@
./usr/share/man/cat3/mktime.0 comp-c-catman .cat
./usr/share/man/cat3/mktime_z.0 comp-c-catman .cat
./usr/share/man/cat3/modf.0 comp-c-catman .cat
+./usr/share/man/cat3/modff.0 comp-c-catman .cat
+./usr/share/man/cat3/modfl.0 comp-c-catman .cat
./usr/share/man/cat3/moncontrol.0 comp-c-catman .cat
./usr/share/man/cat3/monstartup.0 comp-c-catman .cat
./usr/share/man/cat3/move.0 comp-c-catman .cat
@@ -14745,6 +14747,8 @@
./usr/share/man/html3/mktime.html comp-c-htmlman html
./usr/share/man/html3/mktime_z.html comp-c-htmlman html
./usr/share/man/html3/modf.html comp-c-htmlman html
+./usr/share/man/html3/modff.html comp-c-htmlman html
+./usr/share/man/html3/modfl.html comp-c-htmlman html
./usr/share/man/html3/moncontrol.html comp-c-htmlman html
./usr/share/man/html3/monstartup.html comp-c-htmlman html
./usr/share/man/html3/move.html comp-c-htmlman html
@@ -21516,6 +21520,8 @@
./usr/share/man/man3/mktime.3 comp-c-man .man
./usr/share/man/man3/mktime_z.3 comp-c-man .man
./usr/share/man/man3/modf.3 comp-c-man .man
+./usr/share/man/man3/modff.3 comp-c-man .man
+./usr/share/man/man3/modfl.3 comp-c-man .man
./usr/share/man/man3/moncontrol.3 comp-c-man .man
./usr/share/man/man3/monstartup.3 comp-c-man .man
./usr/share/man/man3/move.3 comp-c-man .man
diff -r 70b6f3c9a306 -r 26c667df2792 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Mon Jun 16 12:38:32 2014 +0000
+++ b/distrib/sets/lists/debug/mi Mon Jun 16 12:54:42 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.60 2014/04/29 06:29:02 uebayasi Exp $
+# $NetBSD: mi,v 1.61 2014/06/16 12:54:42 joerg Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib
@@ -2043,6 +2043,7 @@
./usr/libdata/debug/usr/tests/lib/libm/t_infinity.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_ldexp.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_libm.debug tests-obsolete obsolete
+./usr/libdata/debug/usr/tests/lib/libm/t_modf.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_log.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_pow.debug tests-lib-debug debug,atf
./usr/libdata/debug/usr/tests/lib/libm/t_precision.debug tests-lib-debug debug,atf
diff -r 70b6f3c9a306 -r 26c667df2792 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Jun 16 12:38:32 2014 +0000
+++ b/distrib/sets/lists/tests/mi Mon Jun 16 12:54:42 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.571 2014/05/31 20:26:51 christos Exp $
+# $NetBSD: mi,v 1.572 2014/06/16 12:54:43 joerg Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2841,6 +2841,7 @@
./usr/tests/lib/libm/t_ldexp tests-lib-tests atf
./usr/tests/lib/libm/t_libm tests-obsolete obsolete
./usr/tests/lib/libm/t_log tests-lib-tests atf
+./usr/tests/lib/libm/t_modf tests-lib-tests atf
./usr/tests/lib/libm/t_pow tests-lib-tests atf
./usr/tests/lib/libm/t_precision tests-lib-tests atf
./usr/tests/lib/libm/t_round tests-lib-tests atf
diff -r 70b6f3c9a306 -r 26c667df2792 lib/libm/Makefile
--- a/lib/libm/Makefile Mon Jun 16 12:38:32 2014 +0000
+++ b/lib/libm/Makefile Mon Jun 16 12:54:42 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.159 2014/05/18 10:47:03 martin Exp $
+# $NetBSD: Makefile,v 1.160 2014/06/16 12:54:43 joerg Exp $
#
# @(#)Makefile 5.1beta 93/09/24
#
@@ -178,7 +178,7 @@
s_ilogb.c s_ilogbf.c s_ilogbl.c \
s_isinff.c s_isnanf.c s_lib_version.c s_log1p.c \
s_log1pf.c s_logb.c s_logbf.c s_logbl.c \
- s_matherr.c s_modff.c s_nextafter.c s_nextafterl.c \
+ s_matherr.c s_modff.c s_modfl.c s_nextafter.c s_nextafterl.c \
s_nextafterf.c s_remquo.c s_remquof.c s_rint.c s_rintf.c \
s_round.c s_roundf.c s_roundl.c s_scalbn.c \
s_scalbnf.c s_scalbnl.c s_signgam.c s_significand.c s_significandf.c s_sin.c \
@@ -311,6 +311,8 @@
MLINKS+=lgamma.3 lgammaf.3 lgamma.3 lgamma_r.3 lgamma.3 lgammaf_r.3 \
lgamma.3 gamma.3 lgamma.3 gammaf.3 lgamma.3 gamma_r.3 \
lgamma.3 gammaf_r.3 lgamma.3 tgamma.3 lgamma.3 tgammaf.3
+MLINKS+=modf.3 modff.3 \
+ modf.3 modfl.3
MLINKS+=nextafter.3 nextafterf.3 \
nextafter.3 nextafterl.3 \
nextafter.3 nexttoward.3
diff -r 70b6f3c9a306 -r 26c667df2792 lib/libm/src/namespace.h
--- a/lib/libm/src/namespace.h Mon Jun 16 12:38:32 2014 +0000
+++ b/lib/libm/src/namespace.h Mon Jun 16 12:54:42 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: namespace.h,v 1.10 2013/11/19 19:24:34 joerg Exp $ */
+/* $NetBSD: namespace.h,v 1.11 2014/06/16 12:54:43 joerg Exp $ */
#define atan2 _atan2
#define atan2f _atan2f
@@ -52,6 +52,7 @@
#define floorl _floorl
#define roundl _roundl
#define fmodl _fmodl
+#define modfl _modfl
#define truncl _truncl
#define exp2l _exp2l
diff -r 70b6f3c9a306 -r 26c667df2792 lib/libm/src/s_modf.c
--- a/lib/libm/src/s_modf.c Mon Jun 16 12:38:32 2014 +0000
+++ b/lib/libm/src/s_modf.c Mon Jun 16 12:54:42 2014 +0000
@@ -12,7 +12,7 @@
#include <sys/cdefs.h>
#if defined(LIBM_SCCS) && !defined(lint)
-__RCSID("$NetBSD: s_modf.c,v 1.14 2010/01/27 14:07:41 drochner Exp $");
+__RCSID("$NetBSD: s_modf.c,v 1.15 2014/06/16 12:54:43 joerg Exp $");
#endif
/*
@@ -30,6 +30,11 @@
static const double one = 1.0;
+#ifndef __HAVE_LONG_DOUBLE
+__strong_alias(_modfl, modf)
+__weak_alias(modfl, modf)
+#endif
+
double
modf(double x, double *iptr)
{
diff -r 70b6f3c9a306 -r 26c667df2792 lib/libm/src/s_modfl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/src/s_modfl.c Mon Jun 16 12:54:42 2014 +0000
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 2007 David Schultz <das%FreeBSD.ORG@localhost>
+ * 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.
+ *
+ * Derived from s_modf.c, which has the following Copyright:
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ *
+ * $FreeBSD: head/lib/msun/src/s_modfl.c 165855 2007-01-07 07:54:21Z das $
+ */
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: s_modfl.c,v 1.1 2014/06/16 12:54:43 joerg Exp $");
+
+#include "namespace.h"
+
+#include <float.h>
+#include <math.h>
+#include <stdint.h>
+#include <machine/ieee.h>
+
+#ifdef __HAVE_LONG_DOUBLE
+
+#ifdef __weak_alias
+__weak_alias(modfl, _modfl)
+#endif
+
+#if LDBL_MANL_SIZE > 32
+#define MASK ((uint64_t)-1)
+#else
+#define MASK ((uint32_t)-1)
+#endif
+/* Return the last n bits of a word, representing the fractional part. */
+#define GETFRAC(bits, n) ((bits) & ~(MASK << (n)))
+/* The number of fraction bits in manh, not counting the integer bit */
+#define HIBITS (LDBL_MANT_DIG - EXT_FRACHBITS)
+
+static const long double zero[] = { 0.0L, -0.0L };
+
+long double
+modfl(long double x, long double *iptr)
+{
+ union ieee_ext_u ux = { .extu_ld = x, };
+ int e = ux.extu_exp - LDBL_MAX_EXP + 1;
+
+ if (e < HIBITS) { /* Integer part is in manh. */
+ if (e < 0) { /* |x|<1 */
+ *iptr = zero[ux.extu_sign];
+ return (x);
+ } else {
+ if ((GETFRAC(ux.extu_frach, HIBITS - 1 - e) |
+ ux.extu_fracl) == 0) { /* X is an integer. */
+ *iptr = x;
+ return (zero[ux.extu_sign]);
+ } else {
+ /* Clear all but the top e+1 bits. */
+ ux.extu_frach >>= HIBITS - 1 - e;
+ ux.extu_frach <<= HIBITS - 1 - e;
+ ux.extu_fracl = 0;
+ *iptr = ux.extu_ld;
+ return (x - ux.extu_ld);
+ }
+ }
+ } else if (e >= LDBL_MANT_DIG - 1) { /* x has no fraction part. */
+ *iptr = x;
+ if (x != x) /* Handle NaNs. */
+ return (x);
+ return (zero[ux.extu_sign]);
+ } else { /* Fraction part is in manl. */
+ if (GETFRAC(ux.extu_fracl, LDBL_MANT_DIG - 1 - e) == 0) {
+ /* x is integral. */
+ *iptr = x;
+ return (zero[ux.extu_sign]);
+ } else {
+ /* Clear all but the top e+1 bits. */
+ ux.extu_fracl >>= LDBL_MANT_DIG - 1 - e;
+ ux.extu_fracl <<= LDBL_MANT_DIG - 1 - e;
+ *iptr = ux.extu_ld;
+ return (x - ux.extu_ld);
+ }
+ }
+}
+#endif /* __HAVE_LONG_DOUBLE */
diff -r 70b6f3c9a306 -r 26c667df2792 tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile Mon Jun 16 12:38:32 2014 +0000
+++ b/tests/lib/libm/Makefile Mon Jun 16 12:54:42 2014 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.24 2014/05/18 10:47:38 martin Exp $
+# $NetBSD: Makefile,v 1.25 2014/06/16 12:54:43 joerg Exp $
.include <bsd.own.mk>
@@ -27,6 +27,7 @@
TESTS_C+= t_infinity
TESTS_C+= t_ldexp
TESTS_C+= t_log
+TESTS_C+= t_modf
TESTS_C+= t_pow
TESTS_C+= t_precision
TESTS_C+= t_round
diff -r 70b6f3c9a306 -r 26c667df2792 tests/lib/libm/t_modf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_modf.c Mon Jun 16 12:54:42 2014 +0000
@@ -0,0 +1,68 @@
+/* $NetBSD: t_modf.c,v 1.1 2014/06/16 12:54:43 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2014 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
Home |
Main Index |
Thread Index |
Old Index