From patchwork Wed Sep 29 18:21:08 2021
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Do not declare fmax, fmin _FloatN,
_FloatNx versions for C2X [committed]
X-Patchwork-Submitter: Joseph Myers
X-Patchwork-Id: 60917
Message-Id:
To:
Date: Wed, 29 Sep 2021 18:21:08 +0000
From: Joseph Myers
List-Id: Libc-alpha mailing list
At the last WG14 meeting,
was
accepted, which places more emphasis on the new fmaximum / fminimum
functions and less on the old fmax / fmin functions. Some of the
changes are to examples, notes or otherwise don't require
implementation changes. However, the changes include removing the
_FloatN / _FloatNx versions of the fmax and fmin functions that came
from TS 18661-3.
Thus, those function versions should only be declared under similar
conditions to the _FloatN / _FloatNx versions of fmaxmag and fminmag:
for _GNU_SOURCE and pre-C2X use of __STDC_WANT_IEC_60559_TYPES_EXT__,
but not for C2X without _GNU_SOURCE.
In turn this requires a tgmath.h change so that the corresponding
tgmath.h macros, for C2X with __STDC_WANT_IEC_60559_TYPES_EXT__ but
without _GNU_SOURCE, don't try to use function variants that aren't
declared. (That issue doesn't arise for the tgmath.h macros for
fmaxmag and fminmag, because those aren't defined at all in those
circumstances unless __STDC_WANT_IEC_60559_BFP_EXT__ (from TS 18661-1
and not specified at all by C2X) is also defined, and in that case the
_FloatN / _FloatNx versions of fmaxmag and fminmag get declared - this
is only ever an issue when it's possible for some functions
corresponding to a type-generic-macro to be declared, and for _FloatN
/ _FloatNx functions in general to be declared, but without the
_FloatN / _FloatNx functions corresponding to that particular macro
being declared.)
Tested for x86_64.
---
Committed.
--
Joseph S. Myers
joseph@codesourcery.com
diff --git a/math/bits/mathcalls.h b/math/bits/mathcalls.h
index ee0c6d7219..da4cf4e10c 100644
--- a/math/bits/mathcalls.h
+++ b/math/bits/mathcalls.h
@@ -328,11 +328,13 @@ __MATHDECL (long long int,llround,, (_Mdouble_ __x));
/* Return positive difference between X and Y. */
__MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
+# if !__MATH_DECLARING_FLOATN || defined __USE_GNU || !__GLIBC_USE (ISOC2X)
/* Return maximum numeric value from X and Y. */
__MATHCALLX (fmax,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
/* Return minimum numeric value from X and Y. */
__MATHCALLX (fmin,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
+# endif
/* Multiply-add function computed as a ternary operation. */
__MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
diff --git a/math/tgmath.h b/math/tgmath.h
index 3d7b0998df..e8042833dd 100644
--- a/math/tgmath.h
+++ b/math/tgmath.h
@@ -892,12 +892,20 @@
/* Return positive difference between X and Y. */
#define fdim(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fdim)
+#if __GLIBC_USE (ISOC2X) && !defined __USE_GNU
/* Return maximum numeric value from X and Y. */
-#define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
+# define fmax(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, fmax)
/* Return minimum numeric value from X and Y. */
-#define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
+# define fmin(Val1, Val2) __TGMATH_BINARY_REAL_STD_ONLY (Val1, Val2, fmin)
+#else
+/* Return maximum numeric value from X and Y. */
+# define fmax(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmax)
+/* Return minimum numeric value from X and Y. */
+# define fmin(Val1, Val2) __TGMATH_BINARY_REAL_ONLY (Val1, Val2, fmin)
+#endif
+
/* Multiply-add function computed as a ternary operation. */
#define fma(Val1, Val2, Val3) \