Module Name:    src
Committed By:   joerg
Date:           Mon Jun 16 12:54:43 UTC 2014

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/distrib/sets/lists/debug: mi
        src/distrib/sets/lists/tests: mi
        src/lib/libm: Makefile
        src/lib/libm/src: namespace.h s_modf.c
        src/tests/lib/libm: Makefile
Added Files:
        src/lib/libm/src: s_modfl.c
        src/tests/lib/libm: t_modf.c

Log Message:
Add modfl(3). From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.1894 -r1.1895 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.60 -r1.61 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.571 -r1.572 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.159 -r1.160 src/lib/libm/Makefile
cvs rdiff -u -r1.10 -r1.11 src/lib/libm/src/namespace.h
cvs rdiff -u -r1.14 -r1.15 src/lib/libm/src/s_modf.c
cvs rdiff -u -r0 -r1.1 src/lib/libm/src/s_modfl.c
cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libm/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libm/t_modf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1894 src/distrib/sets/lists/comp/mi:1.1895
--- src/distrib/sets/lists/comp/mi:1.1894	Wed May 28 11:32:50 2014
+++ src/distrib/sets/lists/comp/mi	Mon Jun 16 12:54:42 2014
@@ -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

Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.60 src/distrib/sets/lists/debug/mi:1.61
--- src/distrib/sets/lists/debug/mi:1.60	Tue Apr 29 06:29:02 2014
+++ src/distrib/sets/lists/debug/mi	Mon Jun 16 12:54:42 2014
@@ -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

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.571 src/distrib/sets/lists/tests/mi:1.572
--- src/distrib/sets/lists/tests/mi:1.571	Sat May 31 20:26:51 2014
+++ src/distrib/sets/lists/tests/mi	Mon Jun 16 12:54:43 2014
@@ -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

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.159 src/lib/libm/Makefile:1.160
--- src/lib/libm/Makefile:1.159	Sun May 18 10:47:03 2014
+++ src/lib/libm/Makefile	Mon Jun 16 12:54:43 2014
@@ -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 @@ COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c
 	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+=j0.3 j0f.3 j0.3 j1.3 j0.3 j1f.3 
 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

Index: src/lib/libm/src/namespace.h
diff -u src/lib/libm/src/namespace.h:1.10 src/lib/libm/src/namespace.h:1.11
--- src/lib/libm/src/namespace.h:1.10	Tue Nov 19 19:24:34 2013
+++ src/lib/libm/src/namespace.h	Mon Jun 16 12:54:43 2014
@@ -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

Index: src/lib/libm/src/s_modf.c
diff -u src/lib/libm/src/s_modf.c:1.14 src/lib/libm/src/s_modf.c:1.15
--- src/lib/libm/src/s_modf.c:1.14	Wed Jan 27 14:07:41 2010
+++ src/lib/libm/src/s_modf.c	Mon Jun 16 12:54:43 2014
@@ -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 @@ __RCSID("$NetBSD: s_modf.c,v 1.14 2010/0
 
 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)
 {

Index: src/tests/lib/libm/Makefile
diff -u src/tests/lib/libm/Makefile:1.24 src/tests/lib/libm/Makefile:1.25
--- src/tests/lib/libm/Makefile:1.24	Sun May 18 10:47:38 2014
+++ src/tests/lib/libm/Makefile	Mon Jun 16 12:54:43 2014
@@ -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_fmod
 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

Added files:

Index: src/lib/libm/src/s_modfl.c
diff -u /dev/null src/lib/libm/src/s_modfl.c:1.1
--- /dev/null	Mon Jun 16 12:54:43 2014
+++ src/lib/libm/src/s_modfl.c	Mon Jun 16 12:54:43 2014
@@ -0,0 +1,109 @@
+/*-
+ * Copyright (c) 2007 David Schultz <d...@freebsd.org>
+ * 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 */

Index: src/tests/lib/libm/t_modf.c
diff -u /dev/null src/tests/lib/libm/t_modf.c:1.1
--- /dev/null	Mon Jun 16 12:54:43 2014
+++ src/tests/lib/libm/t_modf.c	Mon Jun 16 12:54:43 2014
@@ -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
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <atf-c.h>
+#include <float.h>
+#include <math.h>
+
+ATF_TC(modf);
+ATF_TC_HEAD(modf, tc)
+{
+	atf_tc_set_md_var(tc, "descr","Check modf family");
+}
+
+ATF_TC_BODY(modf, tc)
+{
+	float basef;
+	double base;
+	long double basel;
+	ATF_CHECK(modff(1.0, &basef) == 0.0);
+	ATF_CHECK(basef == 1.0);
+	ATF_CHECK(modf(1.0, &base) == 0.0);
+	ATF_CHECK(base == 1.0);
+	ATF_CHECK(modfl(1.0, &basel) == 0.0);
+	ATF_CHECK(basel == 1.0);
+
+	ATF_CHECK(modff(-1 - FLT_EPSILON, &basef) == -FLT_EPSILON);
+	ATF_CHECK(basef == -1.0);
+	ATF_CHECK(modf(-1 - DBL_EPSILON, &base) == -DBL_EPSILON);
+	ATF_CHECK(base == -1.0);
+	ATF_CHECK(modfl(-1 - LDBL_EPSILON, &basel) == -LDBL_EPSILON);
+	ATF_CHECK(basel == -1.0);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+	ATF_TP_ADD_TC(tp, modf);
+
+	return atf_no_error();
+}

Reply via email to