Module Name:    src
Committed By:   riz
Date:           Fri Mar 12 21:58:44 UTC 2010

Modified Files:
        src/distrib/sets/lists/base [netbsd-5]: md.amd64 md.sparc64 shl.mi
        src/distrib/sets/lists/comp [netbsd-5]: mi
        src/include [netbsd-5]: math.h
        src/lib/libm [netbsd-5]: Makefile shlib_version
Added Files:
        src/lib/libm/man [netbsd-5]: fdim.3 fmax.3
        src/lib/libm/src [netbsd-5]: s_fdim.c s_fmax.c s_fmaxf.c s_fmaxl.c
            s_fmin.c s_fminf.c s_fminl.c

Log Message:
Pull up following revision(s) (requested by snj in ticket #1330):
        lib/libm/man/fmax.3: revision 1.1-1.2
        lib/libm/src/s_fmin.c: revision 1.1-1.2
        lib/libm/src/s_fdim.c: revision 1.1
        lib/libm/src/s_fmaxl.c: revision 1.1
        lib/libm/Makefile: revision 1.90
        include/math.h: revision 1.49
        lib/libm/src/s_fmaxf.c: revision 1.1
        lib/libm/src/s_fmax.c: revision 1.1
        lib/libm/shlib_version: revision 1.10
        distrib/sets/lists/base/md.sparc64: revision 1.63 (via patch)
        distrib/sets/lists/base/shl.mi: revision 1.495 (via patch)
        lib/libm/src/s_fminl.c: revision 1.1
        distrib/sets/lists/comp/mi: revision 1.1317
        lib/libm/man/fdim.3: revision 1.1-1.3
        lib/libm/src/s_fminf.c: revision 1.1
        distrib/sets/lists/base/md.amd64: revision 1.70 (via patch)
add f{min,max,dim}{,l,f} from FreeBSD
These functions are going to first appear in 5.1, not 6.0.


To generate a diff of this commit:
cvs rdiff -u -r1.25.2.7 -r1.25.2.8 src/distrib/sets/lists/base/md.amd64
cvs rdiff -u -r1.23.2.7 -r1.23.2.8 src/distrib/sets/lists/base/md.sparc64
cvs rdiff -u -r1.450.2.6 -r1.450.2.7 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.1201.2.13 -r1.1201.2.14 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.47.8.1 -r1.47.8.2 src/include/math.h
cvs rdiff -u -r1.88 -r1.88.4.1 src/lib/libm/Makefile
cvs rdiff -u -r1.9 -r1.9.14.1 src/lib/libm/shlib_version
cvs rdiff -u -r0 -r1.3.2.2 src/lib/libm/man/fdim.3
cvs rdiff -u -r0 -r1.2.2.2 src/lib/libm/man/fmax.3
cvs rdiff -u -r0 -r1.2.2.2 src/lib/libm/src/s_fdim.c \
    src/lib/libm/src/s_fmax.c src/lib/libm/src/s_fmaxf.c \
    src/lib/libm/src/s_fmaxl.c src/lib/libm/src/s_fminf.c \
    src/lib/libm/src/s_fminl.c
cvs rdiff -u -r0 -r1.1.2.2 src/lib/libm/src/s_fmin.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/base/md.amd64
diff -u src/distrib/sets/lists/base/md.amd64:1.25.2.7 src/distrib/sets/lists/base/md.amd64:1.25.2.8
--- src/distrib/sets/lists/base/md.amd64:1.25.2.7	Fri Jan 22 21:05:05 2010
+++ src/distrib/sets/lists/base/md.amd64	Fri Mar 12 21:58:42 2010
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.25.2.7 2010/01/22 21:05:05 snj Exp $
+# $NetBSD: md.amd64,v 1.25.2.8 2010/03/12 21:58:42 riz Exp $
 ./@MODULEDIR@/adosfs				base-kernel-modules
 ./@MODULEDIR@/adosfs/adosfs.kmod		base-kernel-modules
 ./@MODULEDIR@/azalia				base-kernel-modules
@@ -193,7 +193,7 @@
 ./usr/lib/i386/liblwres.so.1			base-compat-shlib	compat,pic
 ./usr/lib/i386/liblwres.so.1.1			base-compat-shlib	compat,pic
 ./usr/lib/i386/libm.so.0			base-compat-shlib	compat,pic
-./usr/lib/i386/libm.so.0.6			base-compat-shlib	compat,pic
+./usr/lib/i386/libm.so.0.7			base-compat-shlib	compat,pic
 ./usr/lib/i386/libmagic.so.1			base-compat-shlib	compat,pic
 ./usr/lib/i386/libmagic.so.1.0			base-compat-shlib	compat,pic
 ./usr/lib/i386/libmenu.so.5			base-compat-shlib	compat,pic

Index: src/distrib/sets/lists/base/md.sparc64
diff -u src/distrib/sets/lists/base/md.sparc64:1.23.2.7 src/distrib/sets/lists/base/md.sparc64:1.23.2.8
--- src/distrib/sets/lists/base/md.sparc64:1.23.2.7	Fri Jan 22 21:05:06 2010
+++ src/distrib/sets/lists/base/md.sparc64	Fri Mar 12 21:58:42 2010
@@ -1,4 +1,4 @@
-# $NetBSD: md.sparc64,v 1.23.2.7 2010/01/22 21:05:06 snj Exp $
+# $NetBSD: md.sparc64,v 1.23.2.8 2010/03/12 21:58:42 riz Exp $
 ./sbin/edlabel					base-sysutil-root
 ./usr/bin/fdformat				base-util-bin
 ./usr/lib/sparc					base-compat-lib		compat
@@ -124,7 +124,7 @@
 ./usr/lib/sparc/liblwres.so.1			base-compat-shlib	compat,pic
 ./usr/lib/sparc/liblwres.so.1.1			base-compat-shlib	compat,pic
 ./usr/lib/sparc/libm.so.0			base-compat-shlib	compat,pic
-./usr/lib/sparc/libm.so.0.6			base-compat-shlib	compat,pic
+./usr/lib/sparc/libm.so.0.7			base-compat-shlib	compat,pic
 ./usr/lib/sparc/libmagic.so.1			base-compat-shlib	compat,pic
 ./usr/lib/sparc/libmagic.so.1.0			base-compat-shlib	compat,pic
 ./usr/lib/sparc/libmenu.so.5			base-compat-shlib	compat,pic

Index: src/distrib/sets/lists/base/shl.mi
diff -u src/distrib/sets/lists/base/shl.mi:1.450.2.6 src/distrib/sets/lists/base/shl.mi:1.450.2.7
--- src/distrib/sets/lists/base/shl.mi:1.450.2.6	Fri Jan 22 21:05:06 2010
+++ src/distrib/sets/lists/base/shl.mi	Fri Mar 12 21:58:42 2010
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.450.2.6 2010/01/22 21:05:06 snj Exp $
+# $NetBSD: shl.mi,v 1.450.2.7 2010/03/12 21:58:42 riz Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -20,7 +20,7 @@
 ./lib/libevent.so.2.1				base-sys-shlib		dynamicroot
 ./lib/libipsec.so.2.2				base-net-shlib		dynamicroot
 ./lib/libkvm.so.5.3				base-sys-shlib		dynamicroot
-./lib/libm.so.0.6				base-sys-shlib		dynamicroot
+./lib/libm.so.0.7				base-sys-shlib		dynamicroot
 ./lib/libprop.so.0.7				base-sys-shlib		dynamicroot
 ./lib/libradius.so.2.0				base-sys-shlib		dynamicroot
 ./lib/libtermcap.so.0.6				base-sys-shlib		dynamicroot
@@ -91,7 +91,7 @@
 ./usr/lib/libldap.so.2.5			base-ldap-shlib		ldap
 ./usr/lib/libldap_r.so.2.5			base-ldap-shlib		ldap
 ./usr/lib/liblwres.so.1.1			base-bind-shlib
-./usr/lib/libm.so.0.6				base-sys-shlib
+./usr/lib/libm.so.0.7				base-sys-shlib
 ./usr/lib/libmagic.so.1.0			base-sys-shlib
 ./usr/lib/libmenu.so.5.0			base-sys-shlib
 ./usr/lib/libobjc.so.2.0			base-sys-shlib		gcc=3

Index: src/distrib/sets/lists/comp/mi
diff -u src/distrib/sets/lists/comp/mi:1.1201.2.13 src/distrib/sets/lists/comp/mi:1.1201.2.14
--- src/distrib/sets/lists/comp/mi:1.1201.2.13	Sun Oct 18 18:26:26 2009
+++ src/distrib/sets/lists/comp/mi	Fri Mar 12 21:58:43 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1201.2.13 2009/10/18 18:26:26 snj Exp $
+#	$NetBSD: mi,v 1.1201.2.14 2010/03/12 21:58:43 riz Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -5290,6 +5290,9 @@
 ./usr/share/man/cat3/fabs.0			comp-c-catman		.cat
 ./usr/share/man/cat3/fabsf.0			comp-c-catman		.cat
 ./usr/share/man/cat3/fclose.0			comp-c-catman		.cat
+./usr/share/man/cat3/fdim.0			comp-c-catman		.cat
+./usr/share/man/cat3/fdimf.0			comp-c-catman		.cat
+./usr/share/man/cat3/fdiml.0			comp-c-catman		.cat
 ./usr/share/man/cat3/fdopen.0			comp-c-catman		.cat
 ./usr/share/man/cat3/feof.0			comp-c-catman		.cat
 ./usr/share/man/cat3/ferror.0			comp-c-catman		.cat
@@ -5331,6 +5334,12 @@
 ./usr/share/man/cat3/floorf.0			comp-c-catman		.cat
 ./usr/share/man/cat3/flushinp.0			comp-c-catman		.cat
 ./usr/share/man/cat3/flushok.0			comp-c-catman		.cat
+./usr/share/man/cat3/fmax.0			comp-c-catman		.cat
+./usr/share/man/cat3/fmaxf.0			comp-c-catman		.cat
+./usr/share/man/cat3/fmaxl.0			comp-c-catman		.cat
+./usr/share/man/cat3/fmin.0			comp-c-catman		.cat
+./usr/share/man/cat3/fminf.0			comp-c-catman		.cat
+./usr/share/man/cat3/fminl.0			comp-c-catman		.cat
 ./usr/share/man/cat3/fmod.0			comp-c-catman		.cat
 ./usr/share/man/cat3/fmodf.0			comp-c-catman		.cat
 ./usr/share/man/cat3/fmtcheck.0			comp-c-catman		.cat
@@ -10625,6 +10634,9 @@
 ./usr/share/man/html3/fabs.html			comp-c-htmlman		html
 ./usr/share/man/html3/fabsf.html		comp-c-htmlman		html
 ./usr/share/man/html3/fclose.html		comp-c-htmlman		html
+./usr/share/man/html3/fdim.html			comp-c-htmlman		html
+./usr/share/man/html3/fdimf.html		comp-c-htmlman		html
+./usr/share/man/html3/fdiml.html		comp-c-htmlman		html
 ./usr/share/man/html3/fdopen.html		comp-c-htmlman		html
 ./usr/share/man/html3/feof.html			comp-c-htmlman		html
 ./usr/share/man/html3/fetch.html		comp-c-htmlman		html
@@ -10665,6 +10677,12 @@
 ./usr/share/man/html3/floorf.html		comp-c-htmlman		html
 ./usr/share/man/html3/flushinp.html		comp-c-htmlman		html
 ./usr/share/man/html3/flushok.html		comp-c-htmlman		html
+./usr/share/man/html3/fmax.html			comp-c-htmlman		html
+./usr/share/man/html3/fmaxf.html		comp-c-htmlman		html
+./usr/share/man/html3/fmaxl.html		comp-c-htmlman		html
+./usr/share/man/html3/fmin.html			comp-c-htmlman		html
+./usr/share/man/html3/fminf.html		comp-c-htmlman		html
+./usr/share/man/html3/fminl.html		comp-c-htmlman		html
 ./usr/share/man/html3/fmod.html			comp-c-htmlman		html
 ./usr/share/man/html3/fmodf.html		comp-c-htmlman		html
 ./usr/share/man/html3/fmtcheck.html		comp-c-htmlman		html
@@ -15869,6 +15887,9 @@
 ./usr/share/man/man3/fabs.3			comp-c-man		.man
 ./usr/share/man/man3/fabsf.3			comp-c-man		.man
 ./usr/share/man/man3/fclose.3			comp-c-man		.man
+./usr/share/man/man3/fdim.3			comp-c-man		.man
+./usr/share/man/man3/fdimf.3			comp-c-man		.man
+./usr/share/man/man3/fdiml.3			comp-c-man		.man
 ./usr/share/man/man3/fdopen.3			comp-c-man		.man
 ./usr/share/man/man3/feof.3			comp-c-man		.man
 ./usr/share/man/man3/ferror.3			comp-c-man		.man
@@ -15910,6 +15931,12 @@
 ./usr/share/man/man3/floorf.3			comp-c-man		.man
 ./usr/share/man/man3/flushinp.3			comp-c-man		.man
 ./usr/share/man/man3/flushok.3			comp-c-man		.man
+./usr/share/man/man3/fmax.3			comp-c-man		.man
+./usr/share/man/man3/fmaxf.3			comp-c-man		.man
+./usr/share/man/man3/fmaxl.3			comp-c-man		.man
+./usr/share/man/man3/fmin.3			comp-c-man		.man
+./usr/share/man/man3/fminf.3			comp-c-man		.man
+./usr/share/man/man3/fminl.3			comp-c-man		.man
 ./usr/share/man/man3/fmod.3			comp-c-man		.man
 ./usr/share/man/man3/fmodf.3			comp-c-man		.man
 ./usr/share/man/man3/fmtcheck.3			comp-c-man		.man

Index: src/include/math.h
diff -u src/include/math.h:1.47.8.1 src/include/math.h:1.47.8.2
--- src/include/math.h:1.47.8.1	Sat Mar  6 22:02:41 2010
+++ src/include/math.h	Fri Mar 12 21:58:42 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: math.h,v 1.47.8.1 2010/03/06 22:02:41 sborrill Exp $	*/
+/*	$NetBSD: math.h,v 1.47.8.2 2010/03/12 21:58:42 riz Exp $	*/
 
 /*
  * ====================================================
@@ -359,6 +359,15 @@
 #define islessequal(x, y)	(!isunordered((x), (y)) && (x) <= (y))
 #define islessgreater(x, y)	(!isunordered((x), (y)) && \
 				 ((x) > (y) || (y) > (x)))
+double	fdim(double, double);
+double	fmax(double, double);
+double	fmin(double, double);
+float	fdimf(float, float);
+float	fmaxf(float, float);
+float	fminf(float, float);
+long double fdiml(long double, long double);
+long double fmaxl(long double, long double);
+long double fminl(long double, long double);
 
 #endif /* !_ANSI_SOURCE && ... */
 

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.88 src/lib/libm/Makefile:1.88.4.1
--- src/lib/libm/Makefile:1.88	Fri Aug 29 00:02:22 2008
+++ src/lib/libm/Makefile	Fri Mar 12 21:58:42 2010
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.88 2008/08/29 00:02:22 gmcgarry Exp $
+#  $NetBSD: Makefile,v 1.88.4.1 2010/03/12 21:58:42 riz 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
 
 .ifdef (${MKCOMPLEX} != "no")
 .include "${.CURDIR}/complex/Makefile.inc"

Index: src/lib/libm/shlib_version
diff -u src/lib/libm/shlib_version:1.9 src/lib/libm/shlib_version:1.9.14.1
--- src/lib/libm/shlib_version:1.9	Mon Aug 20 16:01:30 2007
+++ src/lib/libm/shlib_version	Fri Mar 12 21:58:42 2010
@@ -1,5 +1,5 @@
-#	$NetBSD: shlib_version,v 1.9 2007/08/20 16:01:30 drochner Exp $
+#	$NetBSD: shlib_version,v 1.9.14.1 2010/03/12 21:58:42 riz Exp $
 #	Remember to update distrib/sets/lists/base/shl.* when changing
 #
 major=0
-minor=6
+minor=7

Added files:

Index: src/lib/libm/man/fdim.3
diff -u /dev/null src/lib/libm/man/fdim.3:1.3.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/man/fdim.3	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,89 @@
+.\" Copyright (c) 2004 David Schultz <[email protected]>
+.\" 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$
+.\"
+.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
+and
+.Nx 5.1 .

Index: src/lib/libm/man/fmax.3
diff -u /dev/null src/lib/libm/man/fmax.3:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/man/fmax.3	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,100 @@
+.\" Copyright (c) 2004 David Schultz <[email protected]>
+.\" 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$
+.\"
+.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 5.1 .

Index: src/lib/libm/src/s_fdim.c
diff -u /dev/null src/lib/libm/src/s_fdim.c:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fdim.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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)
+DECL(float, fdimf)
+DECL(long double, fdiml)
Index: src/lib/libm/src/s_fmax.c
diff -u /dev/null src/lib/libm/src/s_fmax.c:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fmax.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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_fmax.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#include <machine/ieee.h>
+
+double
+fmax(double x, double y)
+{
+	union ieee_double_u u[2];
+
+	u[0].dblu_d = x;
+	u[1].dblu_d = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
+	    (u[0].dblu_dbl.dbl_frach | u[0].dblu_dbl.dbl_fracl) != 0)
+		return (y);
+	if (u[1].dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
+	    (u[1].dblu_dbl.dbl_frach | u[1].dblu_dbl.dbl_fracl) != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].dblu_dbl.dbl_sign != u[1].dblu_dbl.dbl_sign)
+		return (u[u[0].dblu_dbl.dbl_sign].dblu_d);
+
+	return (x > y ? x : y);
+}
Index: src/lib/libm/src/s_fmaxf.c
diff -u /dev/null src/lib/libm/src/s_fmaxf.c:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fmaxf.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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_fmaxf.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#include <machine/ieee.h>
+
+float
+fmaxf(float x, float y)
+{
+	union ieee_single_u u[2];
+
+	u[0].sngu_f = x;
+	u[1].sngu_f = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].sngu_sng.sng_exp == SNG_EXP_INFNAN &&
+	    u[0].sngu_sng.sng_frac != 0)
+		return (y);
+	if (u[1].sngu_sng.sng_exp == SNG_EXP_INFNAN &&
+	    u[1].sngu_sng.sng_frac != 0)
+		return (x);
+
+	/* Handle comparisons of sng_signed zeroes. */
+	if (u[0].sngu_sng.sng_sign != u[1].sngu_sng.sng_sign)
+		return (u[u[0].sngu_sng.sng_sign].sngu_f);
+
+	return (x > y ? x : y);
+}
Index: src/lib/libm/src/s_fmaxl.c
diff -u /dev/null src/lib/libm/src/s_fmaxl.c:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fmaxl.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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_fmaxl.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#include <machine/ieee.h>
+#ifdef EXT_EXP_INFNAN
+long double
+fmaxl(long double x, long double y)
+{
+	union ieee_ext_u u[2];
+
+	u[0].extu_ld = x;
+	u[0].extu_ext.ext_frach &= ~0x80000000;
+	u[1].extu_ld = y;
+	u[1].extu_ext.ext_frach &= ~0x80000000;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].extu_ext.ext_exp == EXT_EXP_INFNAN &&
+	    (u[0].extu_ext.ext_frach | u[0].extu_ext.ext_fracl) != 0)
+		return (y);
+	if (u[1].extu_ext.ext_exp == EXT_EXP_INFNAN &&
+	    (u[1].extu_ext.ext_frach | u[1].extu_ext.ext_fracl) != 0)
+		return (x);
+
+	/* Handle comparisons of ext_signed zeroes. */
+	if (u[0].extu_ext.ext_sign != u[1].extu_ext.ext_sign)
+		return (u[0].extu_ext.ext_sign ? y : x);
+
+	return (x > y ? x : y);
+}
+#endif
Index: src/lib/libm/src/s_fminf.c
diff -u /dev/null src/lib/libm/src/s_fminf.c:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fminf.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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_fminf.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#include <machine/ieee.h>
+
+float
+fminf(float x, float y)
+{
+	union ieee_single_u u[2];
+
+	u[0].sngu_f = x;
+	u[1].sngu_f = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].sngu_sng.sng_exp == SNG_EXP_INFNAN &&
+	    u[0].sngu_sng.sng_frac != 0)
+		return (y);
+	if (u[1].sngu_sng.sng_exp == SNG_EXP_INFNAN &&
+	    u[1].sngu_sng.sng_frac != 0)
+		return (x);
+
+	/* Handle comparisons of sng_singed zeroes. */
+	if (u[0].sngu_sng.sng_sign != u[1].sngu_sng.sng_sign)
+		return (u[u[1].sngu_sng.sng_sign].sngu_f);
+
+	return (x < y ? x : y);
+}
Index: src/lib/libm/src/s_fminl.c
diff -u /dev/null src/lib/libm/src/s_fminl.c:1.2.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fminl.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,61 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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_fminl.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#include <machine/ieee.h>
+#ifdef EXT_EXP_INFNAN
+long double
+fminl(long double x, long double y)
+{
+	union ieee_ext_u u[2];
+
+	u[0].extu_ld = x;
+	u[0].extu_ext.ext_frach &= ~0x80000000;
+	u[1].extu_ld = y;
+	u[1].extu_ext.ext_frach &= ~0x80000000;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].extu_ext.ext_exp == EXT_EXP_INFNAN &&
+	    (u[0].extu_ext.ext_frach | u[0].extu_ext.ext_fracl) != 0)
+		return (y);
+	if (u[1].extu_ext.ext_exp == EXT_EXP_INFNAN &&
+	    (u[1].extu_ext.ext_frach | u[1].extu_ext.ext_fracl) != 0)
+		return (x);
+
+	/* Handle comparisons of ext_signed zeroes. */
+	if (u[0].extu_ext.ext_sign != u[1].extu_ext.ext_sign)
+		return (u[1].extu_ext.ext_sign ? y : x);
+
+	return (x < y ? x : y);
+}
+#endif

Index: src/lib/libm/src/s_fmin.c
diff -u /dev/null src/lib/libm/src/s_fmin.c:1.1.2.2
--- /dev/null	Fri Mar 12 21:58:44 2010
+++ src/lib/libm/src/s_fmin.c	Fri Mar 12 21:58:42 2010
@@ -0,0 +1,58 @@
+/*-
+ * Copyright (c) 2004 David Schultz <[email protected]>
+ * 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: s_fmin.c,v 1.1.2.2 2010/03/12 21:58:42 riz Exp $");
+#ifdef notdef
+__FBSDID("$FreeBSD: src/lib/msun/src/s_fmin.c,v 1.1 2004/06/30 07:04:01 das Exp $");
+#endif
+
+#include <math.h>
+
+#include <machine/ieee.h>
+
+double
+fmin(double x, double y)
+{
+	union ieee_double_u u[2];
+
+	u[0].dblu_d = x;
+	u[1].dblu_d = y;
+
+	/* Check for NaNs to avoid raising spurious exceptions. */
+	if (u[0].dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
+	    (u[0].dblu_dbl.dbl_frach | u[0].dblu_dbl.dbl_fracl) != 0)
+		return (y);
+	if (u[1].dblu_dbl.dbl_exp == DBL_EXP_INFNAN &&
+	    (u[1].dblu_dbl.dbl_frach | u[1].dblu_dbl.dbl_fracl) != 0)
+		return (x);
+
+	/* Handle comparisons of signed zeroes. */
+	if (u[0].dblu_dbl.dbl_sign != u[1].dblu_dbl.dbl_sign)
+		return (u[u[1].dblu_dbl.dbl_sign].dblu_d);
+
+	return (x < y ? x : y);
+}

Reply via email to