Source-Changes-HG archive

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

[src/trunk]: src/lib/libm add f{min,max,dim}{,l,f} from FreeBSD



details:   https://anonhg.NetBSD.org/src/rev/677a5ee4381a
branches:  trunk
changeset: 747890:677a5ee4381a
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Oct 04 22:04:30 2009 +0000

description:
add f{min,max,dim}{,l,f} from FreeBSD

diffstat:

 lib/libm/Makefile      |   15 +++++-
 lib/libm/man/fdim.3    |   87 ++++++++++++++++++++++++++++++++++++++++++
 lib/libm/man/fmax.3    |  100 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/libm/shlib_version |    4 +-
 lib/libm/src/s_fdim.c  |   49 ++++++++++++++++++++++++
 lib/libm/src/s_fmax.c  |   58 ++++++++++++++++++++++++++++
 lib/libm/src/s_fmaxf.c |   58 ++++++++++++++++++++++++++++
 lib/libm/src/s_fmaxl.c |   61 +++++++++++++++++++++++++++++
 lib/libm/src/s_fmin.c  |   58 ++++++++++++++++++++++++++++
 lib/libm/src/s_fminf.c |   58 ++++++++++++++++++++++++++++
 lib/libm/src/s_fminl.c |   61 +++++++++++++++++++++++++++++
 11 files changed, 604 insertions(+), 5 deletions(-)

diffs (truncated from 680 to 300 lines):

diff -r d7df870b22e9 -r 677a5ee4381a lib/libm/Makefile
--- a/lib/libm/Makefile Sun Oct 04 21:58:25 2009 +0000
+++ b/lib/libm/Makefile Sun Oct 04 22:04:30 2009 +0000
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.89 2009/01/18 20:42:11 he Exp $
+#  $NetBSD: Makefile,v 1.90 2009/10/04 22:04:30 christos Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -136,7 +136,9 @@
        w_pow.c w_powf.c w_remainder.c w_remainderf.c w_scalb.c w_scalbf.c \
        w_sinh.c w_sinhf.c w_sqrt.c w_sqrtf.c \
        lrint.c lrintf.c llrint.c llrintf.c lround.c lroundf.c llround.c \
-       llroundf.c
+       llroundf.c \
+       s_fmax.c s_fmaxf.c s_fmaxl.c s_fmin.c s_fminf.c s_fminl.c s_fdim.c
+
 # Also in libc.
 #COMMON_SRCS += s_frexp.c s_ldexp.c s_modf.c
 
@@ -186,7 +188,7 @@
        cos.3 cosh.3 erf.3 exp.3 fabs.3 floor.3 fmod.3 frexp.3 hypot.3 ieee.3 \
        ieee_test.3 isinff.3 j0.3 ldexp.3 lgamma.3 lrint.3 \
        math.3 modf.3 rint.3 round.3 sin.3 sinh.3 \
-       sqrt.3 tan.3 tanh.3 trunc.3
+       sqrt.3 tan.3 tanh.3 trunc.3 fmax.3 fdim.3
 
 MLINKS+=acos.3 acosf.3
 MLINKS+=acosh.3 acoshf.3
@@ -227,6 +229,13 @@
 MLINKS+=tanh.3 tanhf.3
 MLINKS+=round.3 roundf.3
 MLINKS+=trunc.3 truncf.3
+MLINKS+=fmax.3 fmaxl.3
+MLINKS+=fmax.3 fmaxf.3
+MLINKS+=fmax.3 fmin.3
+MLINKS+=fmax.3 fminl.3
+MLINKS+=fmax.3 fminf.3
+MLINKS+=fdim.3 fdiml.3
+MLINKS+=fdim.3 fdimf.3
 
 .if (${MKCOMPLEX} != "no")
 .include "${.CURDIR}/complex/Makefile.inc"
diff -r d7df870b22e9 -r 677a5ee4381a lib/libm/man/fdim.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/man/fdim.3       Sun Oct 04 22:04:30 2009 +0000
@@ -0,0 +1,87 @@
+.\" Copyright (c) 2004 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.
+.\"
+.\" $FreeBSD: src/lib/msun/man/fdim.3,v 1.1 2004/06/30 07:04:01 das Exp $
+.\" $NetBSD: fdim.3,v 1.1 2009/10/04 22:04:30 christos Exp $
+.\"
+.Dd June 29, 2004
+.Dt FDIM 3
+.Os
+.Sh NAME
+.Nm fdim ,
+.Nm fdimf ,
+.Nm fdiml
+.Nd positive difference functions
+.Sh LIBRARY
+.Lb libm
+.Sh SYNOPSIS
+.In math.h
+.Ft double
+.Fn fdim "double x" "double y"
+.Ft float
+.Fn fdimf "float x" "float y"
+.Ft long double
+.Fn fdiml "long double x" "long double y"
+.Sh DESCRIPTION
+The
+.Fn fdim ,
+.Fn fdimf ,
+and
+.Fn fdiml
+functions return the positive difference between
+.Fa x
+and
+.Fa y .
+That is, if
+.Fa x\- Ns Fa y
+is positive, then
+.Fa x\- Ns Fa y
+is returned.
+If either
+.Fa x
+or
+.Fa y
+is an \*(Na, then an \*(Na is returned.
+Otherwise, the result is
+.Li +0.0 .
+.Pp
+Overflow or underflow may occur iff the exact result is not
+representable in the return type.
+No other exceptions are raised.
+.Sh SEE ALSO
+.Xr fabs 3 ,
+.Xr fmax 3 ,
+.Xr fmin 3 ,
+.Xr math 3
+.Sh STANDARDS
+The
+.Fn fdim ,
+.Fn fdimf ,
+and
+.Fn fdiml
+functions conform to
+.St -isoC-99 .
+.Sh HISTORY
+These routines first appeared in
+.Fx 5.3 .
diff -r d7df870b22e9 -r 677a5ee4381a lib/libm/man/fmax.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/man/fmax.3       Sun Oct 04 22:04:30 2009 +0000
@@ -0,0 +1,100 @@
+.\" Copyright (c) 2004 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.
+.\"
+.\" $FreeBSD: src/lib/msun/man/fmax.3,v 1.2 2005/01/14 09:12:05 ru Exp $
+.\" $NetBSD: fmax.3,v 1.1 2009/10/04 22:04:30 christos Exp $
+.\"
+.Dd June 29, 2004
+.Dt FMAX 3
+.Os
+.Sh NAME
+.Nm fmax ,
+.Nm fmaxf ,
+.Nm fmaxl ,
+.Nm fmin ,
+.Nm fminf ,
+.Nm fminl
+.Nd floating-point maximum and minimum functions
+.Sh LIBRARY
+.Lb libm
+.Sh SYNOPSIS
+.In math.h
+.Ft double
+.Fn fmax "double x" "double y"
+.Ft float
+.Fn fmaxf "float x" "float y"
+.Ft "long double"
+.Fn fmaxl "long double x" "long double y"
+.Ft double
+.Fn fmin "double x" "double y"
+.Ft float
+.Fn fminf "float x" "float y"
+.Ft "long double"
+.Fn fminl "long double x" "long double y"
+.Sh DESCRIPTION
+The
+.Fn fmax ,
+.Fn fmaxf ,
+and
+.Fn fmaxl
+functions return the larger of
+.Fa x
+and
+.Fa y ,
+and likewise, the
+.Fn fmin ,
+.Fn fminf ,
+and
+.Fn fminl
+functions return the smaller of
+.Fa x
+and
+.Fa y .
+They treat
+.Li +0.0
+as being larger than
+.Li -0.0 .
+If one argument is an \*(Na, then the other argument is returned.
+If both arguments are \*(Nas, then the result is an \*(Na.
+These routines do not raise any floating-point exceptions.
+.Sh SEE ALSO
+.Xr fabs 3 ,
+.Xr fdim 3 ,
+.Xr math 3
+.Sh STANDARDS
+The
+.Fn fmax ,
+.Fn fmaxf ,
+.Fn fmaxl ,
+.Fn fmin ,
+.Fn fminf ,
+and
+.Fn fminl
+functions conform to
+.St -isoC-99 .
+.Sh HISTORY
+These routines first appeared in
+.Fx 5.3
+and
+.Nx 6.0 .
diff -r d7df870b22e9 -r 677a5ee4381a lib/libm/shlib_version
--- a/lib/libm/shlib_version    Sun Oct 04 21:58:25 2009 +0000
+++ b/lib/libm/shlib_version    Sun Oct 04 22:04:30 2009 +0000
@@ -1,5 +1,5 @@
-#      $NetBSD: shlib_version,v 1.9 2007/08/20 16:01:30 drochner Exp $
+#      $NetBSD: shlib_version,v 1.10 2009/10/04 22:04:30 christos Exp $
 #      Remember to update distrib/sets/lists/base/shl.* when changing
 #
 major=0
-minor=6
+minor=7
diff -r d7df870b22e9 -r 677a5ee4381a lib/libm/src/s_fdim.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/libm/src/s_fdim.c     Sun Oct 04 22:04:30 2009 +0000
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2004 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("NetBSD$");
+#ifdef notdef
+__FBSDID("$FreeBSD: src/lib/msun/src/s_fdim.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#define        DECL(type, fn)                  \
+type                                   \
+fn(type x, type y)                     \
+{                                      \
+                                       \
+       if (isnan(x))                   \
+               return (x);             \
+       if (isnan(y))                   \
+               return (y);             \
+       return (x > y ? x - y : 0.0);   \
+}
+
+DECL(double, fdim)



Home | Main Index | Thread Index | Old Index