* [committed] libstdc++: Reuse double overload of __convert_to_v if possible
@ 2023-08-17 20:32 Jonathan Wakely
2023-08-17 23:19 ` Hans-Peter Nilsson
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Wakely @ 2023-08-17 20:32 UTC (permalink / raw)
To: libstdc++, gcc-patches
Tested x86_64-linux. Pushed to trunk.
-- >8 --
For targets where double and long double have the same representation we
can reuse the same __convert_to_v code for both types. This will
slightly reduce the size of the compiled code in the library.
libstdc++-v3/ChangeLog:
* config/locale/generic/c_locale.cc (__convert_to_v): Reuse
double overload for long double if possible.
---
libstdc++-v3/config/locale/generic/c_locale.cc | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libstdc++-v3/config/locale/generic/c_locale.cc b/libstdc++-v3/config/locale/generic/c_locale.cc
index 8849d78fdfa..866ba0361dc 100644
--- a/libstdc++-v3/config/locale/generic/c_locale.cc
+++ b/libstdc++-v3/config/locale/generic/c_locale.cc
@@ -187,6 +187,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&) throw()
{
+#if __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
+ double __d;
+ __convert_to_v(__s, __d, __err, __c_locale);
+ __v = __d;
+#else
// Assumes __s formatted for "C" locale.
const char* __sav = __set_C_locale();
if (!__sav)
@@ -233,6 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
setlocale(LC_ALL, __sav);
delete [] __sav;
+#endif // __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
}
void
--
2.41.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed] libstdc++: Reuse double overload of __convert_to_v if possible
2023-08-17 20:32 [committed] libstdc++: Reuse double overload of __convert_to_v if possible Jonathan Wakely
@ 2023-08-17 23:19 ` Hans-Peter Nilsson
2023-08-17 23:30 ` Jonathan Wakely
0 siblings, 1 reply; 3+ messages in thread
From: Hans-Peter Nilsson @ 2023-08-17 23:19 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: libstdc++, gcc-patches
> Date: Thu, 17 Aug 2023 21:32:29 +0100
> From: Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org>
> Tested x86_64-linux. Pushed to trunk.
Does the below typo imply that for x86_64-linux,
"__DBL_MANT_DIG__ == __LDBL_MANT_DIG__" is false and the
code is actually untested?
> libstdc++-v3/ChangeLog:
>
> * config/locale/generic/c_locale.cc (__convert_to_v): Reuse
> double overload for long double if possible.
Breakage for cris-elf:
libtool: compile: /auto/cris-elf/gccobj/./gcc/xgcc -shared-libgcc -B/auto/cris-elf/gccobj/./gcc -nostdinc++ -L/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/src -L/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/src/.libs -L/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/libsupc++/.libs -nostdinc -B/auto/cris-elf/gccobj/cris-elf/newlib/ -isystem /auto/cris-elf/gccobj/cris-elf/newlib/targ-include -isystem /auto/gcc/newlib/libc/include -B/auto/cris-elf/gccobj/cris-elf/libgloss/cris -L/auto/cris-elf/gccobj/cris-elf/libgloss/libnosys -L/auto/gcc/libgloss/cris -B/auto/cris-elf/pre/cris-elf/bin/ -B/auto/cris-elf/pre/cris-elf/lib/ -isystem /auto/cris-elf/pre/cris-elf/include -isystem /auto/cris-elf/pre/cris-elf/sys-include -I/auto/gcc/libstdc++-v3/../libgcc -I/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/include/cris-elf -I/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/include -I/auto/gcc/libstdc++-v3/libsupc++ -std=gnu++98 -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnos
tics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=c++locale.lo -g -O2 -fimplicit-templates -c c++locale.cc -o c++locale.o
c++locale.cc: In function 'void std::__convert_to_v(const char*, _Tp&, ios_base::iostate&, int* const&) [with _Tp = long double; ios_base::iostate = ios_base::iostate; __c_locale = int*]':
c++locale.cc:192:49: error: expected primary-expression before ')' token
192 | __convert_to_v(__s, __d, __err, __c_locale);
| ^
make[5]: *** [Makefile:881: c++locale.lo] Error 1
make[5]: Leaving directory '/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/src/c++98'
(Formally, a commit in the range ee40bdbfb07c..aad83d61d2e9
but this one seems pretty clear.)
In the context:
__convert_to_v(const char* __s, long double& __v,
ios_base::iostate& __err, const __c_locale&) throw()
So, __c_locale" appears to be the type(def) and you're
missing a parameter name. :)
brgds, H-P
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [committed] libstdc++: Reuse double overload of __convert_to_v if possible
2023-08-17 23:19 ` Hans-Peter Nilsson
@ 2023-08-17 23:30 ` Jonathan Wakely
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Wakely @ 2023-08-17 23:30 UTC (permalink / raw)
To: Hans-Peter Nilsson; +Cc: libstdc++, gcc-patches
On Fri, 18 Aug 2023 at 00:20, Hans-Peter Nilsson <hp@axis.com> wrote:
>
> > Date: Thu, 17 Aug 2023 21:32:29 +0100
> > From: Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org>
>
> > Tested x86_64-linux. Pushed to trunk.
>
> Does the below typo imply that for x86_64-linux,
> "__DBL_MANT_DIG__ == __LDBL_MANT_DIG__" is false and the
> code is actually untested?
Yes, but I thought I'd tested it on a suitable cross-compiler last week.
I've reverted it for now (at r14-3310-gb860e657802b96) and will retest
next week.
>
> > libstdc++-v3/ChangeLog:
> >
> > * config/locale/generic/c_locale.cc (__convert_to_v): Reuse
> > double overload for long double if possible.
>
> Breakage for cris-elf:
>
> libtool: compile: /auto/cris-elf/gccobj/./gcc/xgcc -shared-libgcc -B/auto/cris-elf/gccobj/./gcc -nostdinc++ -L/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/src -L/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/src/.libs -L/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/libsupc++/.libs -nostdinc -B/auto/cris-elf/gccobj/cris-elf/newlib/ -isystem /auto/cris-elf/gccobj/cris-elf/newlib/targ-include -isystem /auto/gcc/newlib/libc/include -B/auto/cris-elf/gccobj/cris-elf/libgloss/cris -L/auto/cris-elf/gccobj/cris-elf/libgloss/libnosys -L/auto/gcc/libgloss/cris -B/auto/cris-elf/pre/cris-elf/bin/ -B/auto/cris-elf/pre/cris-elf/lib/ -isystem /auto/cris-elf/pre/cris-elf/include -isystem /auto/cris-elf/pre/cris-elf/sys-include -I/auto/gcc/libstdc++-v3/../libgcc -I/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/include/cris-elf -I/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/include -I/auto/gcc/libstdc++-v3/libsupc++ -std=gnu++98 -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi=2 -fdiagnos
> tics-show-location=once -ffunction-sections -fdata-sections -frandom-seed=c++locale.lo -g -O2 -fimplicit-templates -c c++locale.cc -o c++locale.o
> c++locale.cc: In function 'void std::__convert_to_v(const char*, _Tp&, ios_base::iostate&, int* const&) [with _Tp = long double; ios_base::iostate = ios_base::iostate; __c_locale = int*]':
> c++locale.cc:192:49: error: expected primary-expression before ')' token
> 192 | __convert_to_v(__s, __d, __err, __c_locale);
> | ^
> make[5]: *** [Makefile:881: c++locale.lo] Error 1
> make[5]: Leaving directory '/auto/cris-elf/gccobj/cris-elf/libstdc++-v3/src/c++98'
>
> (Formally, a commit in the range ee40bdbfb07c..aad83d61d2e9
> but this one seems pretty clear.)
>
> In the context:
> __convert_to_v(const char* __s, long double& __v,
> ios_base::iostate& __err, const __c_locale&) throw()
>
> So, __c_locale" appears to be the type(def) and you're
> missing a parameter name. :)
>
> brgds, H-P
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-17 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 20:32 [committed] libstdc++: Reuse double overload of __convert_to_v if possible Jonathan Wakely
2023-08-17 23:19 ` Hans-Peter Nilsson
2023-08-17 23:30 ` Jonathan Wakely
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).