public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed 1/2] libstdc++: Fix deduction failure for std::min call [PR104080]
@ 2022-01-18 10:12 Jonathan Wakely
  2022-01-18 10:12 ` [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080] Jonathan Wakely
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2022-01-18 10:12 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: hp, ppalka

Tested x86_64-linux, pushed to trunk.
Reported upstream as https://github.com/fastfloat/fast_float/pull/122


libstdc++-v3/ChangeLog:

	PR libstdc++/104080
	* src/c++17/fast_float/LOCAL_PATCHES: UPDATE.
	* src/c++17/fast_float/fast_float.h (round): Use explicit
	template argument list for std::min.
---
 libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES | 1 +
 libstdc++-v3/src/c++17/fast_float/fast_float.h  | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
index 71495d6728b..447c7ed2cdb 100644
--- a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
+++ b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
@@ -1,2 +1,3 @@
 r12-6647
 r12-6648
+r12-6664
diff --git a/libstdc++-v3/src/c++17/fast_float/fast_float.h b/libstdc++-v3/src/c++17/fast_float/fast_float.h
index 97d28940944..ee129309ba3 100644
--- a/libstdc++-v3/src/c++17/fast_float/fast_float.h
+++ b/libstdc++-v3/src/c++17/fast_float/fast_float.h
@@ -2466,7 +2466,7 @@ fastfloat_really_inline void round(adjusted_mantissa& am, callback cb) noexcept
   if (-am.power2 >= mantissa_shift) {
     // have a denormal float
     int32_t shift = -am.power2 + 1;
-    cb(am, std::min(shift, 64));
+    cb(am, std::min<int32_t>(shift, 64));
     // check for round-up: if rounding-nearest carried us to the hidden bit.
     am.power2 = (am.mantissa < (uint64_t(1) << binary_format<T>::mantissa_explicit_bits())) ? 0 : 1;
     return;
-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080]
  2022-01-18 10:12 [committed 1/2] libstdc++: Fix deduction failure for std::min call [PR104080] Jonathan Wakely
@ 2022-01-18 10:12 ` Jonathan Wakely
  2022-01-18 19:44   ` Patrick Palka
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Wakely @ 2022-01-18 10:12 UTC (permalink / raw)
  To: libstdc++, gcc-patches; +Cc: hp, ppalka

Tested x86_64-linux, pushed to trunk.


Instead of hardcoded preprocessor conditionals with explicit target
checks, just rely on the fact that __BYTE_ORDER__ is always defined by
GCC.

libstdc++-v3/ChangeLog:

	PR libstdc++/104080
	* src/c++17/fast_float/LOCAL_PATCHES: Update.
	* src/c++17/fast_float/fast_float.h (FASTFLOAT_IS_BIG_ENDIAN):
	Define in terms of __BYTE_ORDER__.
---
 libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES | 1 +
 libstdc++-v3/src/c++17/fast_float/fast_float.h  | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
index 447c7ed2cdb..5bb42933398 100644
--- a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
+++ b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
@@ -1,3 +1,4 @@
 r12-6647
 r12-6648
 r12-6664
+r12-6665
diff --git a/libstdc++-v3/src/c++17/fast_float/fast_float.h b/libstdc++-v3/src/c++17/fast_float/fast_float.h
index ee129309ba3..31fb88b8aba 100644
--- a/libstdc++-v3/src/c++17/fast_float/fast_float.h
+++ b/libstdc++-v3/src/c++17/fast_float/fast_float.h
@@ -128,7 +128,9 @@ from_chars_result from_chars_advanced(const char *first, const char *last,
 #define FASTFLOAT_VISUAL_STUDIO 1
 #endif
 
-#ifdef _WIN32
+#ifdef __BYTE_ORDER__
+#define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
+#elif defined _WIN32
 #define FASTFLOAT_IS_BIG_ENDIAN 0
 #else
 #if defined(__APPLE__) || defined(__FreeBSD__)
-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080]
  2022-01-18 10:12 ` [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080] Jonathan Wakely
@ 2022-01-18 19:44   ` Patrick Palka
  2022-01-18 20:01     ` Patrick Palka
  2022-01-18 20:10     ` Jakub Jelinek
  0 siblings, 2 replies; 6+ messages in thread
From: Patrick Palka @ 2022-01-18 19:44 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Jonathan Wakely via Libstdc++, GCC Patches, hp

On Tue, Jan 18, 2022 at 5:12 AM Jonathan Wakely <jwakely@redhat.com> wrote:
>
> Tested x86_64-linux, pushed to trunk.
>
>
> Instead of hardcoded preprocessor conditionals with explicit target
> checks, just rely on the fact that __BYTE_ORDER__ is always defined by
> GCC.

Thanks a lot for fixing these!  I apparently missed removing this
batch of #includes from the amalgamation in r12-6647.  For
completeness I suppose we should remove these #includes too.   I
wonder if we can rely on __BYTE_ORDER__ being defined by other
compilers?

>
> libstdc++-v3/ChangeLog:
>
>         PR libstdc++/104080
>         * src/c++17/fast_float/LOCAL_PATCHES: Update.
>         * src/c++17/fast_float/fast_float.h (FASTFLOAT_IS_BIG_ENDIAN):
>         Define in terms of __BYTE_ORDER__.
> ---
>  libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES | 1 +
>  libstdc++-v3/src/c++17/fast_float/fast_float.h  | 4 +++-
>  2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
> index 447c7ed2cdb..5bb42933398 100644
> --- a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
> +++ b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
> @@ -1,3 +1,4 @@
>  r12-6647
>  r12-6648
>  r12-6664
> +r12-6665
> diff --git a/libstdc++-v3/src/c++17/fast_float/fast_float.h b/libstdc++-v3/src/c++17/fast_float/fast_float.h
> index ee129309ba3..31fb88b8aba 100644
> --- a/libstdc++-v3/src/c++17/fast_float/fast_float.h
> +++ b/libstdc++-v3/src/c++17/fast_float/fast_float.h
> @@ -128,7 +128,9 @@ from_chars_result from_chars_advanced(const char *first, const char *last,
>  #define FASTFLOAT_VISUAL_STUDIO 1
>  #endif
>
> -#ifdef _WIN32
> +#ifdef __BYTE_ORDER__
> +#define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
> +#elif defined _WIN32
>  #define FASTFLOAT_IS_BIG_ENDIAN 0
>  #else
>  #if defined(__APPLE__) || defined(__FreeBSD__)
> --
> 2.31.1
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080]
  2022-01-18 19:44   ` Patrick Palka
@ 2022-01-18 20:01     ` Patrick Palka
  2022-01-18 20:51       ` Jonathan Wakely
  2022-01-18 20:10     ` Jakub Jelinek
  1 sibling, 1 reply; 6+ messages in thread
From: Patrick Palka @ 2022-01-18 20:01 UTC (permalink / raw)
  To: Patrick Palka
  Cc: Jonathan Wakely, Jonathan Wakely via Libstdc++, GCC Patches, hp

On Tue, 18 Jan 2022, Patrick Palka wrote:

> On Tue, Jan 18, 2022 at 5:12 AM Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > Tested x86_64-linux, pushed to trunk.
> >
> >
> > Instead of hardcoded preprocessor conditionals with explicit target
> > checks, just rely on the fact that __BYTE_ORDER__ is always defined by
> > GCC.
> 
> Thanks a lot for fixing these!  I apparently missed removing this
> batch of #includes from the amalgamation in r12-6647.  For
> completeness I suppose we should remove these #includes too.   I
> wonder if we can rely on __BYTE_ORDER__ being defined by other
> compilers?

(N.B. not just for completeness but potentially also for correctness,
since floating_from_chars.cc #includes "fast_float/fast_float.h" into an
anonymous namespace, and we probably shouldn't be #including system
headers into an anonymous namespace..)

> 
> >
> > libstdc++-v3/ChangeLog:
> >
> >         PR libstdc++/104080
> >         * src/c++17/fast_float/LOCAL_PATCHES: Update.
> >         * src/c++17/fast_float/fast_float.h (FASTFLOAT_IS_BIG_ENDIAN):
> >         Define in terms of __BYTE_ORDER__.
> > ---
> >  libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES | 1 +
> >  libstdc++-v3/src/c++17/fast_float/fast_float.h  | 4 +++-
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
> > index 447c7ed2cdb..5bb42933398 100644
> > --- a/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
> > +++ b/libstdc++-v3/src/c++17/fast_float/LOCAL_PATCHES
> > @@ -1,3 +1,4 @@
> >  r12-6647
> >  r12-6648
> >  r12-6664
> > +r12-6665
> > diff --git a/libstdc++-v3/src/c++17/fast_float/fast_float.h b/libstdc++-v3/src/c++17/fast_float/fast_float.h
> > index ee129309ba3..31fb88b8aba 100644
> > --- a/libstdc++-v3/src/c++17/fast_float/fast_float.h
> > +++ b/libstdc++-v3/src/c++17/fast_float/fast_float.h
> > @@ -128,7 +128,9 @@ from_chars_result from_chars_advanced(const char *first, const char *last,
> >  #define FASTFLOAT_VISUAL_STUDIO 1
> >  #endif
> >
> > -#ifdef _WIN32
> > +#ifdef __BYTE_ORDER__
> > +#define FASTFLOAT_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
> > +#elif defined _WIN32
> >  #define FASTFLOAT_IS_BIG_ENDIAN 0
> >  #else
> >  #if defined(__APPLE__) || defined(__FreeBSD__)
> > --
> > 2.31.1
> >
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080]
  2022-01-18 19:44   ` Patrick Palka
  2022-01-18 20:01     ` Patrick Palka
@ 2022-01-18 20:10     ` Jakub Jelinek
  1 sibling, 0 replies; 6+ messages in thread
From: Jakub Jelinek @ 2022-01-18 20:10 UTC (permalink / raw)
  To: Patrick Palka
  Cc: Jonathan Wakely, hp, Jonathan Wakely via Libstdc++, GCC Patches

On Tue, Jan 18, 2022 at 02:44:34PM -0500, Patrick Palka via Gcc-patches wrote:
> On Tue, Jan 18, 2022 at 5:12 AM Jonathan Wakely <jwakely@redhat.com> wrote:
> >
> > Tested x86_64-linux, pushed to trunk.
> >
> >
> > Instead of hardcoded preprocessor conditionals with explicit target
> > checks, just rely on the fact that __BYTE_ORDER__ is always defined by
> > GCC.
> 
> Thanks a lot for fixing these!  I apparently missed removing this
> batch of #includes from the amalgamation in r12-6647.  For
> completeness I suppose we should remove these #includes too.   I
> wonder if we can rely on __BYTE_ORDER__ being defined by other
> compilers?

clang++ 8 and later defines, them, ICC 16+ too.

	Jakub


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080]
  2022-01-18 20:01     ` Patrick Palka
@ 2022-01-18 20:51       ` Jonathan Wakely
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Wakely @ 2022-01-18 20:51 UTC (permalink / raw)
  To: Patrick Palka; +Cc: Jonathan Wakely via Libstdc++, GCC Patches, hp

On Tue, 18 Jan 2022 at 20:01, Patrick Palka <ppalka@redhat.com> wrote:

> On Tue, 18 Jan 2022, Patrick Palka wrote:
>
> > On Tue, Jan 18, 2022 at 5:12 AM Jonathan Wakely <jwakely@redhat.com>
> wrote:
> > >
> > > Tested x86_64-linux, pushed to trunk.
> > >
> > >
> > > Instead of hardcoded preprocessor conditionals with explicit target
> > > checks, just rely on the fact that __BYTE_ORDER__ is always defined by
> > > GCC.
> >
> > Thanks a lot for fixing these!  I apparently missed removing this
> > batch of #includes from the amalgamation in r12-6647.  For
> > completeness I suppose we should remove these #includes too.   I
> > wonder if we can rely on __BYTE_ORDER__ being defined by other
> > compilers?
>
>
We already use it unconditionally in <bit>, for std::endian.

I actually considered replacing all the FAST_FLOAT_USES_BIG_ENDIAN
preprocessor checks with:

if constexpr (std::endian::native == std::endian::big)

But it would make the diffs from upstream bigger for no benefit.

I did wonder whether some of those functions could avoid doing memcpy then
byteswap, if we just swapped the bytes without the memcpy. But GCC probably
optimizes that code well anyway, so I didn't even bother checking it.
Upstream probably tested that already as well.



> (N.B. not just for completeness but potentially also for correctness,
> since floating_from_chars.cc #includes "fast_float/fast_float.h" into an
> anonymous namespace, and we probably shouldn't be #including system
> headers into an anonymous namespace..)
>

Good point.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-01-18 20:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-18 10:12 [committed 1/2] libstdc++: Fix deduction failure for std::min call [PR104080] Jonathan Wakely
2022-01-18 10:12 ` [committed 2/2] libstdc++: Use GCC's predefined macro for endianness [PR104080] Jonathan Wakely
2022-01-18 19:44   ` Patrick Palka
2022-01-18 20:01     ` Patrick Palka
2022-01-18 20:51       ` Jonathan Wakely
2022-01-18 20:10     ` Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).