Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F176388170
D55834.id174631.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
27 KB
Referenced Files
None
Subscribers
None
D55834.id174631.diff
View Options
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -88,7 +88,8 @@
s_signgam.c s_significand.c s_significandf.c s_sin.c \
s_sincos.c s_sincosf.c s_sinf.c \
s_tan.c s_tanf.c s_tanh.c s_tanhf.c s_tgammaf.c s_trunc.c s_truncf.c \
- w_cabs.c w_cabsf.c w_drem.c w_dremf.c
+ w_cabs.c w_cabsf.c w_drem.c w_dremf.c \
+ s_fmaximum.c s_fmaximumf.c s_fminimum.c s_fminimumf.c
# IEEE-754 2008 and ISO/IEC TS 18661-4 half-cycle trignometric functions
COMMON_SRCS+= s_cospi.c s_cospif.c \
@@ -134,7 +135,8 @@
s_fmaxl.c s_fminl.c s_frexpl.c s_logbl.c s_logl.c s_nanl.c \
s_nextafterl.c s_nexttoward.c s_remquol.c s_rintl.c s_roundl.c \
s_scalbnl.c s_sinl.c s_sincosl.c s_sinpil.c \
- s_tanhl.c s_tanl.c s_tanpil.c s_truncl.c w_cabsl.c
+ s_tanhl.c s_tanl.c s_tanpil.c s_truncl.c w_cabsl.c \
+ s_fmaximuml.c s_fminimuml.c
# Work around this warning from gcc:
# lib/msun/ld80/e_powl.c:275:1: error: floating constant exceeds range of
# 'long double' [-Werror=overflow]
@@ -181,7 +183,8 @@
nextafter.3 remainder.3 rint.3 \
round.3 scalbn.3 signbit.3 sin.3 sincos.3 \
sinh.3 sinpi.3 sqrt.3 tan.3 tanh.3 tanpi.3 trunc.3 \
- complex.3
+ complex.3 \
+ fmaximum.3
MLINKS+=acos.3 acosf.3 acos.3 acosl.3
MLINKS+=acosh.3 acoshf.3 acosh.3 acoshl.3
@@ -270,6 +273,9 @@
MLINKS+=tanh.3 tanhf.3 tanh.3 tanhl.3
MLINKS+=tanpi.3 tanpif.3 tanpi.3 tanpil.3
MLINKS+=trunc.3 truncf.3 trunc.3 truncl.3
+MLINKS+=fmaximum.3 fmaximuml.3 fmaximum.3 fmaximumf.3 \
+ fmaximum.3 fminimum.3 fmaximum.3 fminimumf.3 \
+ fmaximum.3 fminimuml.3
.include <src.opts.mk>
diff --git a/lib/msun/Symbol.map b/lib/msun/Symbol.map
--- a/lib/msun/Symbol.map
+++ b/lib/msun/Symbol.map
@@ -316,3 +316,14 @@
tanpif;
tanpil;
};
+
+/* First added in 16.0-CURRENT */
+
+FBSD_1.9 {
+ fmaximum;
+ fmaximumf;
+ fmaximuml;
+ fminimum;
+ fminimumf;
+ fminimuml;
+};
diff --git a/lib/msun/man/fmaximum.3 b/lib/msun/man/fmaximum.3
new file mode 100644
--- /dev/null
+++ b/lib/msun/man/fmaximum.3
@@ -0,0 +1,103 @@
+.\" Copyright (c) 2004 David Schultz <das@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.
+.\"
+.Dd March 31, 2026
+.Dt FMAXIMUM 3
+.Os
+.Sh NAME
+.Nm fmaximum ,
+.Nm fmaximumf ,
+.Nm fmaximuml ,
+.Nm fminimum ,
+.Nm fminimumf ,
+.Nm fminimuml
+.Nd floating-point maximum and minimum functions
+.Sh LIBRARY
+.Lb libm
+.Sh SYNOPSIS
+.In math.h
+.Ft double
+.Fn fmaximum "double x" "double y"
+.Ft float
+.Fn fmaximumf "float x" "float y"
+.Ft "long double"
+.Fn fmaximuml "long double x" "long double y"
+.Ft double
+.Fn fminimum "double x" "double y"
+.Ft float
+.Fn fminimumf "float x" "float y"
+.Ft "long double"
+.Fn fminimuml "long double x" "long double y"
+.Sh DESCRIPTION
+The
+.Fn fmaximum ,
+.Fn fmaximumf ,
+and
+.Fn fmaximuml
+functions return the larger of
+.Fa x
+and
+.Fa y ,
+and likewise, the
+.Fn fminimum ,
+.Fn fminimumf ,
+and
+.Fn fminimuml
+functions return the smaller of
+.Fa x
+and
+.Fa y .
+They treat
+.Li +0.0
+as being larger than
+.Li -0.0 .
+.Pp
+Unlike the
+.Xr fmax 3
+family of functions, which ignore an \*(Na, if either argument to
+.Fn fmaximum
+or
+.Fn fminimum
+is an \*(Na, then the result is an \*(Na.
+If either argument is a signaling \*(Na, an invalid exception is raised.
+Otherwise, these routines do not raise any floating-point exceptions.
+.Sh SEE ALSO
+.Xr fabs 3 ,
+.Xr fdim 3 ,
+.Xr fmax 3 ,
+.Xr math 3
+.Sh STANDARDS
+The
+.Fn fmaximum ,
+.Fn fmaximumf ,
+.Fn fmaximuml ,
+.Fn fminimum ,
+.Fn fminimumf ,
+and
+.Fn fminimuml
+functions conform to
+.St -isoC-2023 .
+.Sh HISTORY
+These routines first appeared in
+.Fx 16.0 .
diff --git a/lib/msun/src/math.h b/lib/msun/src/math.h
--- a/lib/msun/src/math.h
+++ b/lib/msun/src/math.h
@@ -520,6 +520,12 @@
double tanpi(double);
float tanpif(float);
long double tanpil(long double);
+double fmaximum(double, double);
+float fmaximumf(float, float);
+long double fmaximuml(long double, long double);
+double fminimum(double, double);
+float fminimumf(float, float);
+long double fminimuml(long double, long double);
#endif /* __ISO_C_VISIBLE >= 2023 */
__END_DECLS
diff --git a/lib/msun/src/s_fmaximum.c b/lib/msun/src/s_fmaximum.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/src/s_fmaximum.c
@@ -0,0 +1,64 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2004 David Schultz <das@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.
+ */
+
+#include <float.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+#ifdef USE_BUILTIN_FMAXIMUM
+double
+fmaximum(double x, double y)
+{
+ return (__builtin_fmaximum(x, y));
+}
+#else
+double
+fmaximum(double x, double y)
+{
+ union IEEEd2bits u[2];
+
+ u[0].d = x;
+ u[1].d = y;
+
+ /* Handle NaN according to ISO/IEC 60559. NaN argument -> NaN return */
+ if ((u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0) ||
+ (u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0))
+ return (x + y);
+
+ /* Handle comparisons of signed zeroes. */
+ if (u[0].bits.sign != u[1].bits.sign)
+ return (u[u[0].bits.sign].d);
+
+ return (x > y ? x : y);
+}
+#endif
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(fmaximum, fmaximuml);
+#endif
diff --git a/lib/msun/src/s_fmaximumf.c b/lib/msun/src/s_fmaximumf.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/src/s_fmaximumf.c
@@ -0,0 +1,59 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2004 David Schultz <das@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.
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+#ifdef USE_BUILTIN_FMAXIMUMF
+float
+fmaximumf(float x, float y)
+{
+ return (__builtin_fmaximumf(x, y));
+}
+#else
+float
+fmaximumf(float x, float y)
+{
+ union IEEEf2bits u[2];
+
+ u[0].f = x;
+ u[1].f = y;
+
+ /* Handle NaN according to ISO/IEC 60559. NaN argument -> NaN return */
+ if ((u[0].bits.exp == 255 && u[0].bits.man != 0) ||
+ (u[1].bits.exp == 255 && u[1].bits.man != 0))
+ return (x + y);
+
+ /* Handle comparisons of signed zeroes. */
+ if (u[0].bits.sign != u[1].bits.sign)
+ return (u[u[0].bits.sign].f);
+
+ return (x > y ? x : y);
+}
+#endif
diff --git a/lib/msun/src/s_fmaximuml.c b/lib/msun/src/s_fmaximuml.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/src/s_fmaximuml.c
@@ -0,0 +1,53 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2004 David Schultz <das@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.
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+long double
+fmaximuml(long double x, long double y)
+{
+ union IEEEl2bits u[2];
+
+ u[0].e = x;
+ mask_nbit_l(u[0]);
+ u[1].e = y;
+ mask_nbit_l(u[1]);
+
+ /* Handle NaN according to ISO/IEC 60559. NaN argument -> NaN return */
+ if ((u[0].bits.exp == 32767 && (u[0].bits.manh | u[0].bits.manl) != 0) ||
+ (u[1].bits.exp == 32767 && (u[1].bits.manh | u[1].bits.manl) != 0))
+ return (x + y);
+
+ /* Handle comparisons of signed zeroes. */
+ if (u[0].bits.sign != u[1].bits.sign)
+ return (u[0].bits.sign ? y : x);
+
+ return (x > y ? x : y);
+}
diff --git a/lib/msun/src/s_fminimum.c b/lib/msun/src/s_fminimum.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/src/s_fminimum.c
@@ -0,0 +1,65 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2004 David Schultz <das@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.
+ */
+
+#include <float.h>
+#include <math.h>
+
+#include "fpmath.h"
+
+#ifdef USE_BUILTIN_FMINIMUM
+double
+fminimum(double x, double y)
+{
+ return (__builtin_fminimum(x, y));
+}
+#else
+double
+fminimum(double x, double y)
+{
+ union IEEEd2bits u[2];
+
+ u[0].d = x;
+ u[1].d = y;
+
+ /* Check for NaNs to avoid raising spurious exceptions. */
+ if (u[0].bits.exp == 2047 && (u[0].bits.manh | u[0].bits.manl) != 0 ||
+ u[1].bits.exp == 2047 && (u[1].bits.manh | u[1].bits.manl) != 0)
+ return (x + y);
+
+ /* Handle comparisons of signed zeroes. */
+ if (u[0].bits.sign != u[1].bits.sign)
+ return (u[u[1].bits.sign].d);
+
+ return (x < y ? x : y);
+}
+#endif
+
+#if (LDBL_MANT_DIG == 53)
+__weak_reference(fminimum, fminimuml);
+#endif
+
diff --git a/lib/msun/src/s_fminimumf.c b/lib/msun/src/s_fminimumf.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/src/s_fminimumf.c
@@ -0,0 +1,60 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2004 David Schultz <das@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.
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+#ifdef USE_BUILTIN_FMINIMUMF
+float
+fminimumf(float x, float y)
+{
+ return (__builtin_fminimumf(x, y));
+}
+#else
+float
+fminimumf(float x, float y)
+{
+ union IEEEf2bits u[2];
+
+ u[0].f = x;
+ u[1].f = y;
+
+ /* Check for NaNs to avoid raising spurious exceptions. */
+ if (u[0].bits.exp == 255 && u[0].bits.man != 0 ||
+ u[1].bits.exp == 255 && u[1].bits.man != 0)
+ return (x + y);
+
+ /* Handle comparisons of signed zeroes. */
+ if (u[0].bits.sign != u[1].bits.sign)
+ return (u[u[1].bits.sign].f);
+
+ return (x < y ? x : y);
+}
+#endif
+
diff --git a/lib/msun/src/s_fminimuml.c b/lib/msun/src/s_fminimuml.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/src/s_fminimuml.c
@@ -0,0 +1,54 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2004 David Schultz <das@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.
+ */
+
+#include <math.h>
+
+#include "fpmath.h"
+
+long double
+fminimuml(long double x, long double y)
+{
+ union IEEEl2bits u[2];
+
+ u[0].e = x;
+ mask_nbit_l(u[0]);
+ u[1].e = y;
+ mask_nbit_l(u[1]);
+
+ /* Check for NaNs to avoid raising spurious exceptions. */
+ if (u[0].bits.exp == 32767 && (u[0].bits.manh | u[0].bits.manl) != 0 ||
+ u[1].bits.exp == 32767 && (u[1].bits.manh | u[1].bits.manl) != 0)
+ return (x + y);
+
+ /* Handle comparisons of signed zeroes. */
+ if (u[0].bits.sign != u[1].bits.sign)
+ return (u[1].bits.sign ? y : x);
+
+ return (x < y ? x : y);
+}
+
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -69,6 +69,7 @@
ATF_TESTS_C+= next_test
ATF_TESTS_C+= rem_test
ATF_TESTS_C+= trig_test
+ATF_TESTS_C+= fmaximum_fminimum_test
.if !empty(PROG) && !empty(TAP_TESTS_C:M${PROG})
CFLAGS+= -O0
diff --git a/lib/msun/tests/fmaximum_fminimum_test.c b/lib/msun/tests/fmaximum_fminimum_test.c
new file mode 100644
--- /dev/null
+++ b/lib/msun/tests/fmaximum_fminimum_test.c
@@ -0,0 +1,188 @@
+/*
+ * Copyright (c) 2008 David Schultz <das@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.
+ */
+
+/*
+ * Tests for fmaximum{,f,l}() and fminimum{,f,l}()
+ */
+
+#include <sys/cdefs.h>
+#include <fenv.h>
+#include <float.h>
+#include <math.h>
+
+#include "test-utils.h"
+
+#pragma STDC FENV_ACCESS ON
+
+/*
+ * Test whether func(x, y) has the expected result, and make sure no
+ * exceptions are raised.
+ */
+#define TEST(func, type, x, y, expected, rmode) do { \
+ type __x = (x); /* convert before we clear exceptions */ \
+ type __y = (y); \
+ ATF_REQUIRE_EQ(0, feclearexcept(ALL_STD_EXCEPT)); \
+ long double __result = func((__x), (__y)); \
+ CHECK_FP_EXCEPTIONS_MSG(0, ALL_STD_EXCEPT, \
+ #func "(%.20Lg, %.20Lg) rmode%d", (x), (y), rmode); \
+ ATF_CHECK_MSG(fpequal_cs(__result, (expected), true), \
+ #func "(%.20Lg, %.20Lg) rmode%d = %.20Lg, expected %.20Lg", \
+ (x), (y), rmode, __result, (expected)); \
+} while (0)
+
+static void
+testall_r(long double big, long double small, int rmode)
+{
+ long double expected_max, expected_min;
+ if (isnan(big) || isnan(small)) {
+ expected_max = big + small;
+ expected_min = expected_max;
+ } else {
+ expected_max = big;
+ expected_min = small;
+ }
+
+ TEST(fmaximumf, float, big, small, expected_max, rmode);
+ TEST(fmaximumf, float, small, big, expected_max, rmode);
+ TEST(fmaximum, double, big, small, expected_max, rmode);
+ TEST(fmaximum, double, small, big, expected_max, rmode);
+ TEST(fmaximuml, long double, big, small, expected_max, rmode);
+ TEST(fmaximuml, long double, small, big, expected_max, rmode);
+ TEST(fminimumf, float, big, small, expected_min, rmode);
+ TEST(fminimumf, float, small, big, expected_min, rmode);
+ TEST(fminimum, double, big, small, expected_min, rmode);
+ TEST(fminimum, double, small, big, expected_min, rmode);
+ TEST(fminimuml, long double, big, small, expected_min, rmode);
+ TEST(fminimuml, long double, small, big, expected_min, rmode);
+}
+
+/*
+ * Test all the functions: fmaximumf, fmaximum, fmaximuml, fminimumf, fminimum, fminimuml
+ * in all rounding modes and with the arguments in different orders.
+ * The input 'big' must be >= 'small'.
+ */
+static void
+testall(long double big, long double small)
+{
+ static const int rmodes[] = {
+ FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO
+ };
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ fesetround(rmodes[i]);
+ testall_r(big, small, rmodes[i]);
+ }
+}
+
+ATF_TC_WITHOUT_HEAD(test1);
+ATF_TC_BODY(test1, tc)
+{
+ testall(1.0, 0.0);
+}
+
+ATF_TC_WITHOUT_HEAD(test2);
+ATF_TC_BODY(test2, tc)
+{
+ testall(42.0, nextafterf(42.0, -INFINITY));
+}
+ATF_TC_WITHOUT_HEAD(test3);
+ATF_TC_BODY(test3, tc)
+{
+ testall(nextafterf(42.0, INFINITY), 42.0);
+}
+
+ATF_TC_WITHOUT_HEAD(test4);
+ATF_TC_BODY(test4, tc)
+{
+ testall(-5.0, -5.0);
+}
+
+ATF_TC_WITHOUT_HEAD(test5);
+ATF_TC_BODY(test5, tc)
+{
+ testall(-3.0, -4.0);
+}
+
+ATF_TC_WITHOUT_HEAD(test6);
+ATF_TC_BODY(test6, tc)
+{
+ testall(1.0, NAN);
+}
+ATF_TC_WITHOUT_HEAD(test7);
+ATF_TC_BODY(test7, tc)
+{
+ testall(INFINITY, NAN);
+}
+
+ATF_TC_WITHOUT_HEAD(test8);
+ATF_TC_BODY(test8, tc)
+{
+ testall(INFINITY, 1.0);
+}
+
+ATF_TC_WITHOUT_HEAD(test9);
+ATF_TC_BODY(test9, tc)
+{
+ testall(-3.0, -INFINITY);
+}
+
+ATF_TC_WITHOUT_HEAD(test10);
+ATF_TC_BODY(test10, tc)
+{
+ testall(3.0, -INFINITY);
+}
+
+ATF_TC_WITHOUT_HEAD(test11);
+ATF_TC_BODY(test11, tc)
+{
+ testall(NAN, NAN);
+}
+
+ATF_TC_WITHOUT_HEAD(test12);
+ATF_TC_BODY(test12, tc)
+{
+ testall(0.0, -0.0);
+}
+
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, test1);
+ ATF_TP_ADD_TC(tp, test2);
+ ATF_TP_ADD_TC(tp, test3);
+ ATF_TP_ADD_TC(tp, test4);
+ ATF_TP_ADD_TC(tp, test5);
+ ATF_TP_ADD_TC(tp, test6);
+ ATF_TP_ADD_TC(tp, test7);
+ ATF_TP_ADD_TC(tp, test8);
+ ATF_TP_ADD_TC(tp, test9);
+ ATF_TP_ADD_TC(tp, test10);
+ ATF_TP_ADD_TC(tp, test11);
+ ATF_TP_ADD_TC(tp, test12);
+
+ return (atf_no_error());
+}
diff --git a/usr.bin/calendar/calendars/calendar.freebsd b/usr.bin/calendar/calendars/calendar.freebsd
--- a/usr.bin/calendar/calendars/calendar.freebsd
+++ b/usr.bin/calendar/calendars/calendar.freebsd
@@ -123,7 +123,6 @@
03/14 Eric Turgeon <ericbsd@FreeBSD.org> born in Edmundston, New Brunswick, Canada, 1982
03/15 Paolo Pisati <piso@FreeBSD.org> born in Lodi, Italy, 1977
03/15 Brian Fundakowski Feldman <green@FreeBSD.org> born in Alexandria, Virginia, United States, 1983
-03/15 First quarterly status reports are due on 03/31
03/17 Michael Smith <msmith@FreeBSD.org> born in Bankstown, New South Wales, Australia, 1971
03/17 Alexander Motin <mav@FreeBSD.org> born in Simferopol, Ukraine, 1979
03/18 Koop Mast <kwm@FreeBSD.org> born in Dokkum, the Netherlands, 1981
@@ -260,7 +259,6 @@
06/09 Stanislav Galabov <sgalabov@FreeBSD.org> born in Sofia, Bulgaria, 1978
06/11 Alonso Cardenas Marquez <acm@FreeBSD.org> born in Arequipa, Peru, 1979
06/14 Josh Paetzel <jpaetzel@FreeBSD.org> born in Minneapolis, Minnesota, United States, 1973
-06/15 Second quarterly status reports are due on 06/30
06/15 Aymeric Wibo <obiwac@FreeBSD.org> born in Plaistow, London, United Kingdom, 2004
06/17 Tilman Linneweh <arved@FreeBSD.org> born in Weinheim, Baden-Wuerttemberg, Germany, 1978
06/18 Li-Wen Hsu <lwhsu@FreeBSD.org> born in Taipei, Taiwan, Republic of China, 1984
@@ -382,7 +380,6 @@
09/14 Matthew Seaman <matthew@FreeBSD.org> born in Bristol, United Kingdom, 1965
09/15 Aleksandr Rybalko <ray@FreeBSD.org> born in Odessa, Ukraine, 1977
09/15 Dima Panov <fluffy@FreeBSD.org> born in Khabarovsk, Russian Federation, 1978
-09/15 Third quarterly status reports are due on 09/30
09/16 Maksim Yevmenkin <emax@FreeBSD.org> born in Taganrog, USSR, 1974
09/17 Maxim Bolotin <mb@FreeBSD.org> born in Rostov-on-Don, Russian Federation, 1976
09/18 Matthew Fleming <mdf@FreeBSD.org> born in Cleveland, Ohio, United States, 1975
@@ -488,7 +485,6 @@
12/11 Koichiro Iwao <meta@FreeBSD.org> born in Oita, Japan, 1987
12/15 James FitzGibbon <jfitz@FreeBSD.org> born in Amersham, Buckinghamshire, United Kingdom, 1974
12/15 Timur I. Bakeyev <timur@FreeBSD.org> born in Kazan, Republic of Tatarstan, USSR, 1974
-12/15 Fourth quarterly status reports are due on 12/31
12/18 Chris Timmons <cwt@FreeBSD.org> born in Ellensburg, Washington, United States, 1964
12/18 Dag-Erling Smorgrav <des@FreeBSD.org> born in Brussels, Belgium, 1977
12/18 Muhammad Moinur Rahman <bofh@FreeBSD.org> born in Dhaka, Bangladesh, 1983
diff --git a/usr.bin/calendar/calendars/calendar.status_reports b/usr.bin/calendar/calendars/calendar.status_reports
new file mode 100644
--- /dev/null
+++ b/usr.bin/calendar/calendars/calendar.status_reports
@@ -0,0 +1,28 @@
+/*
+ * FreeBSD
+ */
+
+#ifndef _calendar_status_reports_
+#define _calendar_status_reports_
+
+03/01 Status Reports: First call for Q1
+03/15 Status Reports: 1 month left reminder for Q1
+03/31 Status Reports: 2 weeks left reminder for Q1
+04/14 Status Reports: Q1 deadline
+
+06/01 Status Reports: First call for Q2
+06/15 Status Reports: 1 month left reminder for Q2
+06/30 Status Reports: 2 weeks left reminder for Q2
+07/14 Status Reports: Q2 deadline
+
+09/01 Status Reports: First call for Q3
+09/15 Status Reports: 1 month left reminder for Q3
+09/30 Status Reports: 2 weeks left reminder for Q3
+10/14 Status Reports: Q3 deadline
+
+12/01 Status Reports: First call for Q4
+12/15 Status Reports: 1 month left reminder for Q4
+12/31 Status Reports: 2 weeks left reminder for Q4
+01/14 Status Reports: Q4 deadline
+
+#endif /* !_calendar_status_reports_ */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 19, 11:35 AM (1 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41048848
Default Alt Text
D55834.id174631.diff (27 KB)
Attached To
Mode
D55834: lib/msun: Added fmaximum and fminimum family. Tests and man page
Attached
Detach File
Event Timeline
Log In to Comment