public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
@ 2016-09-16  1:43 Felipe Magno de Almeida
  2016-09-16  5:42 ` Marc Glisse
  0 siblings, 1 reply; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-09-16  1:43 UTC (permalink / raw)
  To: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 490 bytes --]

Hello,

I've fixed a few compilation errors with libstdc++v3 with AVR-Libc and
was even able to use boost.spirit x3 with small patches to boost as
well.

Attached is the patch.

Please don't hesitate to ask modifications for upstream inclusion.

Right now std::cout is not working (and just include'ing <iostream>
makes the final executable 100k bigger), however being able to use all
C++11 and C++14 goodies from the STL is already really great.

Kind regards,
-- 
Felipe Magno de Almeida

[-- Attachment #2: fix-libstdc++-compilation-for-avr.patch --]
[-- Type: text/x-diff, Size: 10352 bytes --]

From 53952b274a4e4f4578bf4eb2332a7aa07b26a23b Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 15:54:50 -0300
Subject: [PATCH 1/3] Add #ifdef case for 16 bits in cow-stdexcept.cc

Added #ifdef case for when void* is 16 bits so it compiles in AVR
target.
---
 libstdc++-v3/src/c++11/cow-stdexcept.cc | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 31a89df..5b7f9ba 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -208,6 +208,8 @@ extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
 extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
 extern uint8_t _ITM_RU1(const uint8_t *p)
   ITM_REGPARM __attribute__((weak));
+extern uint16_t _ITM_RU2(const uint16_t *p)
+  ITM_REGPARM __attribute__((weak));
 extern uint32_t _ITM_RU4(const uint32_t *p)
   ITM_REGPARM __attribute__((weak));
 extern uint64_t _ITM_RU8(const uint64_t *p)
@@ -272,12 +274,15 @@ _txnal_cow_string_C1_for_exceptions(void* that, const char* s,
 static void* txnal_read_ptr(void* const * ptr)
 {
   static_assert(sizeof(uint64_t) == sizeof(void*)
-		|| sizeof(uint32_t) == sizeof(void*),
-		"Pointers must be 32 bits or 64 bits wide");
+		|| sizeof(uint32_t) == sizeof(void*)
+                || sizeof(uint16_t) == sizeof(void*),
+		"Pointers must be 16 bits, 32 bits or 64 bits wide");
 #if __UINTPTR_MAX__ == __UINT64_MAX__
   return (void*)_ITM_RU8((const uint64_t*)ptr);
-#else
+#elif __UINTPTR_MAX__ == __UINT32_MAX__
   return (void*)_ITM_RU4((const uint32_t*)ptr);
+#else
+  return (void*)_ITM_RU2((const uint16_t*)ptr);
 #endif
 }
 
-- 
2.9.3


From 24d0e86a560fc109298b8a530f04e2129ff613c6 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 18:52:57 -0300
Subject: [PATCH 2/3] Use temporary int objects to access struct tm members

Call _M_extract_* functions family through temporary int objects, so
it doesn't convert from lvalue to rvalue through a temporary in AVR
because of the incompatible types used in AVR-Libc.

This fixes compilation errors with AVR-Libc while compiling libstdc++
for AVR target.
---
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 44 ++++++++++++++++-------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..cc9d2df 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+                  __tm->tm_wday = __mem;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+                  __mem = __tm->tm_wday;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+                  __mem = __tm->tm_wday;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+                  __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months1, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months2, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +701,22 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+                  __mem = __tm->tm_mday;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
+                  __mem = __tm->tm_mday;
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +727,17 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +748,10 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+                  __mem = __tm->tm_min;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+                  __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+                  __mem = __tm->tm_sec;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+                  __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
-- 
2.9.3


From cfb0f8c760fdbc91aa23afcd767e1ba8533a1a84 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 16:05:02 -0300
Subject: [PATCH 3/3] Enable libstdc++ compilation in AVR targets

Enable libstdc++ compilation in AVR targets with AVR-Libc. Most float
pointing math functions are already defined in AVR-Libc, so defines
are in place to avoid multiple definition of these functions.
---
 libstdc++-v3/configure      | 49 +++++++++++++++++++++++++++++++++++++++++++++
 libstdc++-v3/crossconfig.m4 | 26 ++++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6332c4d..b970077 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28830,6 +28830,55 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    $as_echo "#define HAVE_ACOSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ASINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATAN2F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_CEILF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_EXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FABSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FLOORF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FMODF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FREXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SQRTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_HYPOTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LDEXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOG10F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOGF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_MODFF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_POWF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANHF 1" >>confdefs.h
+
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index 6abc84f..2b955ec 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -9,6 +9,32 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    AC_DEFINE(HAVE_ACOSF)
+    AC_DEFINE(HAVE_ASINF)
+    AC_DEFINE(HAVE_ATAN2F)
+    AC_DEFINE(HAVE_ATANF)
+    AC_DEFINE(HAVE_CEILF)
+    AC_DEFINE(HAVE_COSF)
+    AC_DEFINE(HAVE_COSHF)
+    AC_DEFINE(HAVE_EXPF)
+    AC_DEFINE(HAVE_FABSF)
+    AC_DEFINE(HAVE_FLOORF)
+    AC_DEFINE(HAVE_FMODF)
+    AC_DEFINE(HAVE_FREXPF)
+    AC_DEFINE(HAVE_SQRTF)
+    AC_DEFINE(HAVE_HYPOTF)
+    AC_DEFINE(HAVE_LDEXPF)
+    AC_DEFINE(HAVE_LOG10F)
+    AC_DEFINE(HAVE_LOGF)
+    AC_DEFINE(HAVE_MODFF)
+    AC_DEFINE(HAVE_POWF)
+    AC_DEFINE(HAVE_SINF)
+    AC_DEFINE(HAVE_SINHF)
+    AC_DEFINE(HAVE_TANF)
+    AC_DEFINE(HAVE_TANHF)
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
-- 
2.9.3


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-09-16  1:43 Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx Felipe Magno de Almeida
@ 2016-09-16  5:42 ` Marc Glisse
  2016-09-16  5:53   ` Felipe Magno de Almeida
  0 siblings, 1 reply; 18+ messages in thread
From: Marc Glisse @ 2016-09-16  5:42 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On Thu, 15 Sep 2016, Felipe Magno de Almeida wrote:

+               || sizeof(uint32_t) == sizeof(void*)
+                || sizeof(uint16_t) == sizeof(void*),

Indentation is off?

> Call _M_extract_* functions family through temporary int objects

Would it make sense to use a template type instead of int for this 
parameter? Or possibly have a typedef that defaults to int (what POSIX 
requires). The hard case would be a libc that uses bitfields for the 
fields of struct tm (that could save some space), but I don't think anyone 
does that.

> float pointing

floating point?

A ChangeLog entry would also help.

-- 
Marc Glisse

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-09-16  5:42 ` Marc Glisse
@ 2016-09-16  5:53   ` Felipe Magno de Almeida
  2016-09-16  6:37     ` Felipe Magno de Almeida
  2016-12-06 18:45     ` Jonathan Wakely
  0 siblings, 2 replies; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-09-16  5:53 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

On Fri, Sep 16, 2016 at 2:42 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
> On Thu, 15 Sep 2016, Felipe Magno de Almeida wrote:
>
> +               || sizeof(uint32_t) == sizeof(void*)
> +                || sizeof(uint16_t) == sizeof(void*),
>
> Indentation is off?
>
>> Call _M_extract_* functions family through temporary int objects
>
>
> Would it make sense to use a template type instead of int for this
> parameter? Or possibly have a typedef that defaults to int (what POSIX
> requires). The hard case would be a libc that uses bitfields for the fields
> of struct tm (that could save some space), but I don't think anyone does
> that.

I've tried both approaches. Templates were causing problems of not
defined instantations because they were being used as ints too
in other _M_extract functions through a tmp integer. And typedef's
caused the same problem of having to use a tmp value of the right
type but for example _M_extract_wday_or_month could not have the
same type (in AVR they do) and I'd have to use a temporary anyway
then.

This was the least intrusive way.

>> float pointing
>
> floating point?

:D. Yes.

> A ChangeLog entry would also help.

OK.

> --
> Marc Glisse

Regards,
-- 
Felipe Magno de Almeida

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-09-16  5:53   ` Felipe Magno de Almeida
@ 2016-09-16  6:37     ` Felipe Magno de Almeida
  2016-11-10 15:40       ` Felipe Magno de Almeida
  2016-12-06 18:45     ` Jonathan Wakely
  1 sibling, 1 reply; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-09-16  6:37 UTC (permalink / raw)
  To: libstdc++; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1434 bytes --]

Hello,

Another patch.

On Fri, Sep 16, 2016 at 2:53 AM, Felipe Magno de Almeida
<felipe.m.almeida@gmail.com> wrote:
> On Fri, Sep 16, 2016 at 2:42 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> On Thu, 15 Sep 2016, Felipe Magno de Almeida wrote:
>>
>> +               || sizeof(uint32_t) == sizeof(void*)
>> +                || sizeof(uint16_t) == sizeof(void*),
>>
>> Indentation is off?
>>
>>> Call _M_extract_* functions family through temporary int objects
>>
>>
>> Would it make sense to use a template type instead of int for this
>> parameter? Or possibly have a typedef that defaults to int (what POSIX
>> requires). The hard case would be a libc that uses bitfields for the fields
>> of struct tm (that could save some space), but I don't think anyone does
>> that.
>
> I've tried both approaches. Templates were causing problems of not
> defined instantations because they were being used as ints too
> in other _M_extract functions through a tmp integer. And typedef's
> caused the same problem of having to use a tmp value of the right
> type but for example _M_extract_wday_or_month could not have the
> same type (in AVR they do) and I'd have to use a temporary anyway
> then.
>
> This was the least intrusive way.
>
>>> float pointing
>>
>> floating point?
>
> :D. Yes.
>
>> A ChangeLog entry would also help.
>
> OK.
>
>> --
>> Marc Glisse
>
> Regards,
> --
> Felipe Magno de Almeida



-- 
Felipe Magno de Almeida

[-- Attachment #2: fix-libstdc++-compilation-for-avr.patch --]
[-- Type: text/x-diff, Size: 11948 bytes --]

From d7ea93964ff4c6ee78c34c86ba789bdb0c4582d7 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 15:54:50 -0300
Subject: [PATCH 1/3] Add #ifdef case for 16 bits in cow-stdexcept.cc

Added #ifdef case for when void* is 16 bits so it compiles in AVR
target.
---
 libstdc++-v3/ChangeLog                  |  4 ++++
 libstdc++-v3/src/c++11/cow-stdexcept.cc | 11 ++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f81e87f..5406fbf 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,7 @@
+2016-09-16  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
+	* src/c++11/cow-stdexcept.cc: Add special case for 16 bit pointers
+
 2016-09-15  Jonathan Wakely  <jwakely@redhat.com>
 
 	* doc/xml/manual/debug_mode.xml: Minor editorial fixes.
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 31a89df..641b372 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -208,6 +208,8 @@ extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
 extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
 extern uint8_t _ITM_RU1(const uint8_t *p)
   ITM_REGPARM __attribute__((weak));
+extern uint16_t _ITM_RU2(const uint16_t *p)
+  ITM_REGPARM __attribute__((weak));
 extern uint32_t _ITM_RU4(const uint32_t *p)
   ITM_REGPARM __attribute__((weak));
 extern uint64_t _ITM_RU8(const uint64_t *p)
@@ -272,12 +274,15 @@ _txnal_cow_string_C1_for_exceptions(void* that, const char* s,
 static void* txnal_read_ptr(void* const * ptr)
 {
   static_assert(sizeof(uint64_t) == sizeof(void*)
-		|| sizeof(uint32_t) == sizeof(void*),
-		"Pointers must be 32 bits or 64 bits wide");
+		|| sizeof(uint32_t) == sizeof(void*)
+		|| sizeof(uint16_t) == sizeof(void*),
+		"Pointers must be 16 bits, 32 bits or 64 bits wide");
 #if __UINTPTR_MAX__ == __UINT64_MAX__
   return (void*)_ITM_RU8((const uint64_t*)ptr);
-#else
+#elif __UINTPTR_MAX__ == __UINT32_MAX__
   return (void*)_ITM_RU4((const uint32_t*)ptr);
+#else
+  return (void*)_ITM_RU2((const uint16_t*)ptr);
 #endif
 }
 
-- 
2.9.3


From 95c3782df30690790c7e0d8bcd137a614403cc90 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 18:52:57 -0300
Subject: [PATCH 2/3] Use temporary int objects to access struct tm members

Call _M_extract_* functions family through temporary int objects, so
it doesn't convert from lvalue to rvalue through a temporary in AVR
because of the incompatible types used in AVR-Libc.

This fixes compilation errors with AVR-Libc while compiling libstdc++
for AVR target.
---
 libstdc++-v3/ChangeLog                            |  5 +++
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 44 ++++++++++++++++-------
 2 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 5406fbf..a16f6a9 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
 2016-09-16  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
 
+	* include/bits/locale_facets_nonio.tcc: Avoid compilation errors
+	with non-standard struct tm.
+
+2016-09-16  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
 	* src/c++11/cow-stdexcept.cc: Add special case for 16 bit pointers
 
 2016-09-15  Jonathan Wakely  <jwakely@redhat.com>
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..cc9d2df 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+                  __tm->tm_wday = __mem;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+                  __mem = __tm->tm_wday;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+                  __mem = __tm->tm_wday;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+                  __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months1, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months2, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +701,22 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+                  __mem = __tm->tm_mday;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
+                  __mem = __tm->tm_mday;
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +727,17 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +748,10 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+                  __mem = __tm->tm_min;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+                  __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+                  __mem = __tm->tm_sec;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+                  __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
-- 
2.9.3


From f0f2b3095add54d3ebb4afb5fcd5435630518e48 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 16:05:02 -0300
Subject: [PATCH 3/3] Enable libstdc++ compilation in AVR targets

Enable libstdc++ compilation in AVR targets with AVR-Libc. Most
floating point math functions are already defined in AVR-Libc, so
defines are in place to avoid multiple definition of these functions.
---
 libstdc++-v3/ChangeLog      |  5 +++++
 libstdc++-v3/configure      | 49 +++++++++++++++++++++++++++++++++++++++++++++
 libstdc++-v3/crossconfig.m4 | 26 ++++++++++++++++++++++++
 3 files changed, 80 insertions(+)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a16f6a9..c42b44f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
 2016-09-16  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
 
+	* crossconfig.m4: Add avr target for cross-compilation
+	* configure: Regenerate
+
+2016-09-16  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
 	* include/bits/locale_facets_nonio.tcc: Avoid compilation errors
 	with non-standard struct tm.
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 6332c4d..b970077 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28830,6 +28830,55 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    $as_echo "#define HAVE_ACOSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ASINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATAN2F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_CEILF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_EXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FABSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FLOORF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FMODF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FREXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SQRTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_HYPOTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LDEXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOG10F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOGF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_MODFF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_POWF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANHF 1" >>confdefs.h
+
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index 6abc84f..2b955ec 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -9,6 +9,32 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    AC_DEFINE(HAVE_ACOSF)
+    AC_DEFINE(HAVE_ASINF)
+    AC_DEFINE(HAVE_ATAN2F)
+    AC_DEFINE(HAVE_ATANF)
+    AC_DEFINE(HAVE_CEILF)
+    AC_DEFINE(HAVE_COSF)
+    AC_DEFINE(HAVE_COSHF)
+    AC_DEFINE(HAVE_EXPF)
+    AC_DEFINE(HAVE_FABSF)
+    AC_DEFINE(HAVE_FLOORF)
+    AC_DEFINE(HAVE_FMODF)
+    AC_DEFINE(HAVE_FREXPF)
+    AC_DEFINE(HAVE_SQRTF)
+    AC_DEFINE(HAVE_HYPOTF)
+    AC_DEFINE(HAVE_LDEXPF)
+    AC_DEFINE(HAVE_LOG10F)
+    AC_DEFINE(HAVE_LOGF)
+    AC_DEFINE(HAVE_MODFF)
+    AC_DEFINE(HAVE_POWF)
+    AC_DEFINE(HAVE_SINF)
+    AC_DEFINE(HAVE_SINHF)
+    AC_DEFINE(HAVE_TANF)
+    AC_DEFINE(HAVE_TANHF)
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
-- 
2.9.3


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-09-16  6:37     ` Felipe Magno de Almeida
@ 2016-11-10 15:40       ` Felipe Magno de Almeida
  2016-11-10 15:52         ` Felipe Magno de Almeida
  2016-11-12  3:19         ` Jonathan Wakely
  0 siblings, 2 replies; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-11-10 15:40 UTC (permalink / raw)
  To: libstdc++, Jonathan Wakely; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1932 bytes --]

Hello,

Sorry for top-posting, but this is a ping for the attached patch.

The patch doesn't seem to have been applied nor refused. So I'm
pinging to see if I need to change something? I already have a
copyright assignment now.

I'm attaching a updated patch that doesn't conflict in the Changelog
file.

Regards,

On Fri, Sep 16, 2016 at 3:37 AM, Felipe Magno de Almeida
<felipe.m.almeida@gmail.com> wrote:
> Hello,
>
> Another patch.
>
> On Fri, Sep 16, 2016 at 2:53 AM, Felipe Magno de Almeida
> <felipe.m.almeida@gmail.com> wrote:
>> On Fri, Sep 16, 2016 at 2:42 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>>> On Thu, 15 Sep 2016, Felipe Magno de Almeida wrote:
>>>
>>> +               || sizeof(uint32_t) == sizeof(void*)
>>> +                || sizeof(uint16_t) == sizeof(void*),
>>>
>>> Indentation is off?
>>>
>>>> Call _M_extract_* functions family through temporary int objects
>>>
>>>
>>> Would it make sense to use a template type instead of int for this
>>> parameter? Or possibly have a typedef that defaults to int (what POSIX
>>> requires). The hard case would be a libc that uses bitfields for the fields
>>> of struct tm (that could save some space), but I don't think anyone does
>>> that.
>>
>> I've tried both approaches. Templates were causing problems of not
>> defined instantations because they were being used as ints too
>> in other _M_extract functions through a tmp integer. And typedef's
>> caused the same problem of having to use a tmp value of the right
>> type but for example _M_extract_wday_or_month could not have the
>> same type (in AVR they do) and I'd have to use a temporary anyway
>> then.
>>
>> This was the least intrusive way.
>>
>>>> float pointing
>>>
>>> floating point?
>>
>> :D. Yes.
>>
>>> A ChangeLog entry would also help.
>>
>> OK.
>>
>>> --
>>> Marc Glisse
>>
>> Regards,
>> --
>> Felipe Magno de Almeida
>
>
>
> --
> Felipe Magno de Almeida



-- 
Felipe Magno de Almeida

[-- Attachment #2: fix-libstdc++-compilation-for-avr-v3.patch --]
[-- Type: text/x-diff, Size: 9356 bytes --]

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f405ccd..b0efe72 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,17 @@
+2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
+	* src/c++11/cow-stdexcept.cc: Add special case for 16 bit pointers
+
+2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
+	* include/bits/locale_facets_nonio.tcc: Avoid compilation errors
+	with non-standard struct tm.
+
+2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
+	* crossconfig.m4: Add avr target for cross-compilation
+	* configure: Regenerate
+
 2016-11-09  Tim Shen  <timshen@google.com>
 
 	* libstdc++-v3/include/bits/regex.h (regex_iterator::regex_iterator()):
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 8481a48..5e3f783 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28840,6 +28840,55 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    $as_echo "#define HAVE_ACOSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ASINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATAN2F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_CEILF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_EXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FABSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FLOORF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FMODF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FREXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SQRTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_HYPOTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LDEXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOG10F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOGF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_MODFF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_POWF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANHF 1" >>confdefs.h
+
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index 6abc84f..2b955ec 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -9,6 +9,32 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    AC_DEFINE(HAVE_ACOSF)
+    AC_DEFINE(HAVE_ASINF)
+    AC_DEFINE(HAVE_ATAN2F)
+    AC_DEFINE(HAVE_ATANF)
+    AC_DEFINE(HAVE_CEILF)
+    AC_DEFINE(HAVE_COSF)
+    AC_DEFINE(HAVE_COSHF)
+    AC_DEFINE(HAVE_EXPF)
+    AC_DEFINE(HAVE_FABSF)
+    AC_DEFINE(HAVE_FLOORF)
+    AC_DEFINE(HAVE_FMODF)
+    AC_DEFINE(HAVE_FREXPF)
+    AC_DEFINE(HAVE_SQRTF)
+    AC_DEFINE(HAVE_HYPOTF)
+    AC_DEFINE(HAVE_LDEXPF)
+    AC_DEFINE(HAVE_LOG10F)
+    AC_DEFINE(HAVE_LOGF)
+    AC_DEFINE(HAVE_MODFF)
+    AC_DEFINE(HAVE_POWF)
+    AC_DEFINE(HAVE_SINF)
+    AC_DEFINE(HAVE_SINHF)
+    AC_DEFINE(HAVE_TANF)
+    AC_DEFINE(HAVE_TANHF)
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..cc9d2df 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+                  __tm->tm_wday = __mem;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+                  __mem = __tm->tm_wday;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+                  __mem = __tm->tm_wday;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+                  __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months1, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months2, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +701,22 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+                  __mem = __tm->tm_mday;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
+                  __mem = __tm->tm_mday;
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +727,17 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +748,10 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+                  __mem = __tm->tm_min;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+                  __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+                  __mem = __tm->tm_sec;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+                  __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 31a89df..641b372 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -208,6 +208,8 @@ extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
 extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
 extern uint8_t _ITM_RU1(const uint8_t *p)
   ITM_REGPARM __attribute__((weak));
+extern uint16_t _ITM_RU2(const uint16_t *p)
+  ITM_REGPARM __attribute__((weak));
 extern uint32_t _ITM_RU4(const uint32_t *p)
   ITM_REGPARM __attribute__((weak));
 extern uint64_t _ITM_RU8(const uint64_t *p)
@@ -272,12 +274,15 @@ _txnal_cow_string_C1_for_exceptions(void* that, const char* s,
 static void* txnal_read_ptr(void* const * ptr)
 {
   static_assert(sizeof(uint64_t) == sizeof(void*)
-		|| sizeof(uint32_t) == sizeof(void*),
-		"Pointers must be 32 bits or 64 bits wide");
+		|| sizeof(uint32_t) == sizeof(void*)
+		|| sizeof(uint16_t) == sizeof(void*),
+		"Pointers must be 16 bits, 32 bits or 64 bits wide");
 #if __UINTPTR_MAX__ == __UINT64_MAX__
   return (void*)_ITM_RU8((const uint64_t*)ptr);
-#else
+#elif __UINTPTR_MAX__ == __UINT32_MAX__
   return (void*)_ITM_RU4((const uint32_t*)ptr);
+#else
+  return (void*)_ITM_RU2((const uint16_t*)ptr);
 #endif
 }
 

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-11-10 15:40       ` Felipe Magno de Almeida
@ 2016-11-10 15:52         ` Felipe Magno de Almeida
  2016-12-06 15:08           ` Jonathan Wakely
                             ` (2 more replies)
  2016-11-12  3:19         ` Jonathan Wakely
  1 sibling, 3 replies; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-11-10 15:52 UTC (permalink / raw)
  To: libstdc++, Jonathan Wakely; +Cc: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 574 bytes --]

On Thu, Nov 10, 2016 at 1:39 PM, Felipe Magno de Almeida
<felipe.m.almeida@gmail.com> wrote:
> Hello,
>
> Sorry for top-posting, but this is a ping for the attached patch.
>
> The patch doesn't seem to have been applied nor refused. So I'm
> pinging to see if I need to change something? I already have a
> copyright assignment now.
>
> I'm attaching a updated patch that doesn't conflict in the Changelog
> file.

Reattaching the patch with the correct git commit descriptions.

> Regards,

[snip]

> --
> Felipe Magno de Almeida

Kind regards,
-- 
Felipe Magno de Almeida

[-- Attachment #2: fix-libstdc++-compilation-for-avr-v4.patch --]
[-- Type: text/x-diff, Size: 11953 bytes --]

From 2e62f3a4b3c307e2abec0cb0302ec601b8f693e8 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 15:54:50 -0300
Subject: [PATCH 1/3] Add #ifdef case for 16 bits in cow-stdexcept.cc

Added #ifdef case for when void* is 16 bits so it compiles in AVR
target.
---
 libstdc++-v3/ChangeLog                  |  4 ++++
 libstdc++-v3/src/c++11/cow-stdexcept.cc | 11 ++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index f405ccd..80d2e9d 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,7 @@
+2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
+	* src/c++11/cow-stdexcept.cc: Add special case for 16 bit pointers
+
 2016-11-09  Tim Shen  <timshen@google.com>
 
 	* libstdc++-v3/include/bits/regex.h (regex_iterator::regex_iterator()):
diff --git a/libstdc++-v3/src/c++11/cow-stdexcept.cc b/libstdc++-v3/src/c++11/cow-stdexcept.cc
index 31a89df..641b372 100644
--- a/libstdc++-v3/src/c++11/cow-stdexcept.cc
+++ b/libstdc++-v3/src/c++11/cow-stdexcept.cc
@@ -208,6 +208,8 @@ extern void* _ZGTtnaX (size_t sz) __attribute__((weak));
 extern void _ZGTtdlPv (void* ptr) __attribute__((weak));
 extern uint8_t _ITM_RU1(const uint8_t *p)
   ITM_REGPARM __attribute__((weak));
+extern uint16_t _ITM_RU2(const uint16_t *p)
+  ITM_REGPARM __attribute__((weak));
 extern uint32_t _ITM_RU4(const uint32_t *p)
   ITM_REGPARM __attribute__((weak));
 extern uint64_t _ITM_RU8(const uint64_t *p)
@@ -272,12 +274,15 @@ _txnal_cow_string_C1_for_exceptions(void* that, const char* s,
 static void* txnal_read_ptr(void* const * ptr)
 {
   static_assert(sizeof(uint64_t) == sizeof(void*)
-		|| sizeof(uint32_t) == sizeof(void*),
-		"Pointers must be 32 bits or 64 bits wide");
+		|| sizeof(uint32_t) == sizeof(void*)
+		|| sizeof(uint16_t) == sizeof(void*),
+		"Pointers must be 16 bits, 32 bits or 64 bits wide");
 #if __UINTPTR_MAX__ == __UINT64_MAX__
   return (void*)_ITM_RU8((const uint64_t*)ptr);
-#else
+#elif __UINTPTR_MAX__ == __UINT32_MAX__
   return (void*)_ITM_RU4((const uint32_t*)ptr);
+#else
+  return (void*)_ITM_RU2((const uint16_t*)ptr);
 #endif
 }
 
-- 
2.10.2


From 7ed4af72fe0bdee1a38c7487955590fb64f76a5d Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 18:52:57 -0300
Subject: [PATCH 2/3] Use temporary int objects to access struct tm members

Call _M_extract_* functions family through temporary int objects, so
it doesn't convert from lvalue to rvalue through a temporary in AVR
because of the incompatible types used in AVR-Libc.

This fixes compilation errors with AVR-Libc while compiling libstdc++
for AVR target.
---
 libstdc++-v3/ChangeLog                            |  5 +++
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 44 ++++++++++++++++-------
 2 files changed, 37 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 80d2e9d..80c75c6 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
 2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
 
+	* include/bits/locale_facets_nonio.tcc: Avoid compilation errors
+	with non-standard struct tm.
+
+2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
 	* src/c++11/cow-stdexcept.cc: Add special case for 16 bit pointers
 
 2016-11-09  Tim Shen  <timshen@google.com>
diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..cc9d2df 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+                  __tm->tm_wday = __mem;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+                  __mem = __tm->tm_wday;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+                  __mem = __tm->tm_wday;
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+                  __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months1, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+                  __mem = __tm->tm_mon;
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months2, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +701,22 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+                  __mem = __tm->tm_mday;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
+                  __mem = __tm->tm_mday;
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +727,17 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+                  __mem = __tm->tm_hour;
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +748,10 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+                  __mem = __tm->tm_min;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+                  __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+                  __mem = __tm->tm_sec;
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+                  __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
-- 
2.10.2


From 5bec19a49d6ae7e18327bb1b323275f78ef5aa42 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 16:05:02 -0300
Subject: [PATCH 3/3] Enable libstdc++ compilation in AVR targets

Enable libstdc++ compilation in AVR targets with AVR-Libc. Most
floating point math functions are already defined in AVR-Libc, so
defines are in place to avoid multiple definition of these functions.
---
 libstdc++-v3/ChangeLog      |  5 +++++
 libstdc++-v3/configure      | 49 +++++++++++++++++++++++++++++++++++++++++++++
 libstdc++-v3/crossconfig.m4 | 26 ++++++++++++++++++++++++
 3 files changed, 80 insertions(+)

diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 80c75c6..ca2736f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,10 @@
 2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
 
+	* crossconfig.m4: Add avr target for cross-compilation
+	* configure: Regenerate
+
+2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
+
 	* include/bits/locale_facets_nonio.tcc: Avoid compilation errors
 	with non-standard struct tm.
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 8481a48..5e3f783 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -28840,6 +28840,55 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    $as_echo "#define HAVE_ACOSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ASINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATAN2F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_ATANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_CEILF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_COSHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_EXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FABSF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FLOORF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FMODF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_FREXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SQRTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_HYPOTF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LDEXPF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOG10F 1" >>confdefs.h
+
+    $as_echo "#define HAVE_LOGF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_MODFF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_POWF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_SINHF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANF 1" >>confdefs.h
+
+    $as_echo "#define HAVE_TANHF 1" >>confdefs.h
+
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index 6abc84f..2b955ec 100644
--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -9,6 +9,32 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;
 
+  avr*-*-*)
+    AC_DEFINE(HAVE_ACOSF)
+    AC_DEFINE(HAVE_ASINF)
+    AC_DEFINE(HAVE_ATAN2F)
+    AC_DEFINE(HAVE_ATANF)
+    AC_DEFINE(HAVE_CEILF)
+    AC_DEFINE(HAVE_COSF)
+    AC_DEFINE(HAVE_COSHF)
+    AC_DEFINE(HAVE_EXPF)
+    AC_DEFINE(HAVE_FABSF)
+    AC_DEFINE(HAVE_FLOORF)
+    AC_DEFINE(HAVE_FMODF)
+    AC_DEFINE(HAVE_FREXPF)
+    AC_DEFINE(HAVE_SQRTF)
+    AC_DEFINE(HAVE_HYPOTF)
+    AC_DEFINE(HAVE_LDEXPF)
+    AC_DEFINE(HAVE_LOG10F)
+    AC_DEFINE(HAVE_LOGF)
+    AC_DEFINE(HAVE_MODFF)
+    AC_DEFINE(HAVE_POWF)
+    AC_DEFINE(HAVE_SINF)
+    AC_DEFINE(HAVE_SINHF)
+    AC_DEFINE(HAVE_TANF)
+    AC_DEFINE(HAVE_TANHF)
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'
-- 
2.10.2


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-11-10 15:40       ` Felipe Magno de Almeida
  2016-11-10 15:52         ` Felipe Magno de Almeida
@ 2016-11-12  3:19         ` Jonathan Wakely
  1 sibling, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2016-11-12  3:19 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On 10/11/16 13:39 -0200, Felipe Magno de Almeida wrote:
>Hello,
>
>Sorry for top-posting, but this is a ping for the attached patch.
>
>The patch doesn't seem to have been applied nor refused. So I'm
>pinging to see if I need to change something? I already have a
>copyright assignment now.

Sorry for the delay. It's on my list to deal with. I've been on
vacation and then busy at C++ standards meeting.


>I'm attaching a updated patch that doesn't conflict in the Changelog
>file.

Don't include ChangeLogs in the patch, just include the ChangeLog
content in the email, so there's no problem with the ChangeLog churn
making the patch fail :-)

I'll deal with it next week when I'm back home.


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-11-10 15:52         ` Felipe Magno de Almeida
@ 2016-12-06 15:08           ` Jonathan Wakely
  2016-12-06 17:59           ` Jonathan Wakely
  2016-12-06 18:11           ` Jonathan Wakely
  2 siblings, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2016-12-06 15:08 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On 10/11/16 13:51 -0200, Felipe Magno de Almeida wrote:
>--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
>+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
>@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
> 		  // Abbreviated weekday name [tm_wday]
> 		  const char_type*  __days1[7];
> 		  __tp._M_days_abbreviated(__days1);
>-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
>+                  __tm->tm_wday = __mem;
>+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
> 					  7, __io, __tmperr);
>+                  __mem = __tm->tm_wday;
> 		  break;

Isn't this backwards?

You assign a garbage value to tm_wday, read into __mem, then assign
the garbage back to it.

Has this change been tested?

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-11-10 15:52         ` Felipe Magno de Almeida
  2016-12-06 15:08           ` Jonathan Wakely
@ 2016-12-06 17:59           ` Jonathan Wakely
  2023-09-29 14:07             ` Jonathan Wakely
  2016-12-06 18:11           ` Jonathan Wakely
  2 siblings, 1 reply; 18+ messages in thread
From: Jonathan Wakely @ 2016-12-06 17:59 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On 10/11/16 13:51 -0200, Felipe Magno de Almeida wrote:
>Subject: [PATCH 1/3] Add #ifdef case for 16 bits in cow-stdexcept.cc
>
>Added #ifdef case for when void* is 16 bits so it compiles in AVR
>target.

I've committed this patch.

From 7ed4af72fe0bdee1a38c7487955590fb64f76a5d Mon Sep 17 00:00:00 2001
>From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
>Date: Thu, 15 Sep 2016 18:52:57 -0300
>Subject: [PATCH 2/3] Use temporary int objects to access struct tm members
>
>Call _M_extract_* functions family through temporary int objects, so
>it doesn't convert from lvalue to rvalue through a temporary in AVR
>because of the incompatible types used in AVR-Libc.
>
>This fixes compilation errors with AVR-Libc while compiling libstdc++
>for AVR target.

This one has problems, see my earlier email.


>Subject: [PATCH 3/3] Enable libstdc++ compilation in AVR targets
>
>Enable libstdc++ compilation in AVR targets with AVR-Libc. Most
>floating point math functions are already defined in AVR-Libc, so
>defines are in place to avoid multiple definition of these functions.

I've committed this one too.

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-11-10 15:52         ` Felipe Magno de Almeida
  2016-12-06 15:08           ` Jonathan Wakely
  2016-12-06 17:59           ` Jonathan Wakely
@ 2016-12-06 18:11           ` Jonathan Wakely
  2 siblings, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2016-12-06 18:11 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On 10/11/16 13:51 -0200, Felipe Magno de Almeida wrote:
>@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
> 		  // Seconds. [tm_sec]
> 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
> #if _GLIBCXX_USE_C99
>-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
>+                  __mem = __tm->tm_sec;
>+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
> #else
>-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
>+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
> #endif
> 					 __io, __tmperr);
>+                  __tm->tm_sec = __mem;
> 		  break;
> 		case 't':
> 		  if (__ctype.narrow(*__beg, 0) == '\t')

This part looks wrong too. The assignment to __mem should be outside
the #if condition.

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-09-16  5:53   ` Felipe Magno de Almeida
  2016-09-16  6:37     ` Felipe Magno de Almeida
@ 2016-12-06 18:45     ` Jonathan Wakely
  2016-12-14 21:39       ` Felipe Magno de Almeida
  1 sibling, 1 reply; 18+ messages in thread
From: Jonathan Wakely @ 2016-12-06 18:45 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1374 bytes --]

On 16/09/16 02:53 -0300, Felipe Magno de Almeida wrote:
>On Fri, Sep 16, 2016 at 2:42 AM, Marc Glisse <marc.glisse@inria.fr> wrote:
>> On Thu, 15 Sep 2016, Felipe Magno de Almeida wrote:
>>
>> +               || sizeof(uint32_t) == sizeof(void*)
>> +                || sizeof(uint16_t) == sizeof(void*),
>>
>> Indentation is off?
>>
>>> Call _M_extract_* functions family through temporary int objects
>>
>>
>> Would it make sense to use a template type instead of int for this
>> parameter? Or possibly have a typedef that defaults to int (what POSIX
>> requires). The hard case would be a libc that uses bitfields for the fields
>> of struct tm (that could save some space), but I don't think anyone does
>> that.
>
>I've tried both approaches. Templates were causing problems of not
>defined instantations because they were being used as ints too
>in other _M_extract functions through a tmp integer. And typedef's
>caused the same problem of having to use a tmp value of the right
>type but for example _M_extract_wday_or_month could not have the
>same type (in AVR they do) and I'd have to use a temporary anyway
>then.
>
>This was the least intrusive way.

Did you consider something like this?

This should have no overhead for the targets with standard conforming
struct tm, and only uses a temporary variable and additional
assignments for AVR.

It's ugly though.


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 5221 bytes --]

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..30cc57f 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -626,6 +626,29 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
     time_get<_CharT, _InIter>::do_date_order() const
     { return time_base::no_order; }
 
+  template<typename _Tp>
+    struct _Tm_member
+    {
+      explicit
+      _Tm_member(_Tp& __mem) : _M_mem(__mem) { _M_tmp = __mem; }
+      ~_Tm_member() { _M_mem = _M_tmp; }
+      operator int&() { return _M_mem; }
+      _Tp& _M_mem;
+      int _M_tmp;
+    };
+
+  template<>
+    struct _Tm_member<int>
+    {
+      explicit
+      _Tm_member(int& __mem) : _M_mem(__mem) { }
+      operator int&() { return _M_mem; }
+      int& _M_mem;
+    };
+
+#define _GLIBCXX_TM_MEM(_M) \
+  static_cast<int&>(_Tm_member<__decltype(__tm->tm_##_M)>(__tm->tm_##_M))
+
   // Expand a strftime format string and parse it.  E.g., do_get_date() may
   // pass %m/%d/%Y => extracted characters.
   template<typename _CharT, typename _InIter>
@@ -659,29 +682,29 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
-					  7, __io, __tmperr);
+		  __beg = _M_extract_name(__beg, __end, _GLIBCXX_TM_MEM(wday),
+					  __days1, 7, __io, __tmperr);
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
-					  7, __io, __tmperr);
+		  __beg = _M_extract_name(__beg, __end, _GLIBCXX_TM_MEM(wday),
+					  __days2, 7, __io, __tmperr);
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, _GLIBCXX_TM_MEM(mon),
 					  __months1, 12, __io, __tmperr);
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, _GLIBCXX_TM_MEM(mon),
 					  __months2, 12, __io, __tmperr);
 		  break;
 		case 'c':
@@ -693,18 +716,20 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
-					 __io, __tmperr);
+		  __beg = _M_extract_num(__beg, __end, _GLIBCXX_TM_MEM(mday),
+					 1, 31, 2, __io, __tmperr);
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
-					   1, __io, __tmperr);
+		    __beg = _M_extract_num(++__beg, __end,
+					   _GLIBCXX_TM_MEM(mday),
+					   1, 9, 1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
-					   2, __io, __tmperr);
+		    __beg = _M_extract_num(__beg, __end,
+					   _GLIBCXX_TM_MEM(mday),
+					   10, 31, 2, __io, __tmperr);
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +740,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
-					 __io, __tmperr);
+		  __beg = _M_extract_num(__beg, __end, _GLIBCXX_TM_MEM(hour),
+					 0, 23, 2, __io, __tmperr);
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
-					 __io, __tmperr);
+		  __beg = _M_extract_num(__beg, __end, _GLIBCXX_TM_MEM(hour),
+					 1, 12, 2, __io, __tmperr);
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +757,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
-					 __io, __tmperr);
+		  __beg = _M_extract_num(__beg, __end, _GLIBCXX_TM_MEM(min),
+					 0, 59, 2, __io, __tmperr);
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +777,12 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+		  static const int __max_secs = 60;
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  static const int __max_secs = 61;
 #endif
-					 __io, __tmperr);
+		  __beg = _M_extract_num(__beg, __end, _GLIBCXX_TM_MEM(sec),
+					 0, __max_secs, 2, __io, __tmperr);
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
@@ -842,6 +868,8 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
       return __beg;
     }
 
+#undef _GLIBCXX_TM_MEM
+
   template<typename _CharT, typename _InIter>
     _InIter
     time_get<_CharT, _InIter>::

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-12-06 18:45     ` Jonathan Wakely
@ 2016-12-14 21:39       ` Felipe Magno de Almeida
  2016-12-15 11:15         ` Jonathan Wakely
  0 siblings, 1 reply; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-12-14 21:39 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1917 bytes --]

Hello Jonathan,

Sorry for the delay, I was in mid-vacation.

Comments are inline.

On Tue, Dec 6, 2016 at 3:45 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 16/09/16 02:53 -0300, Felipe Magno de Almeida wrote:
>>

[snip]

>> I've tried both approaches. Templates were causing problems of not
>> defined instantations because they were being used as ints too
>> in other _M_extract functions through a tmp integer. And typedef's
>> caused the same problem of having to use a tmp value of the right
>> type but for example _M_extract_wday_or_month could not have the
>> same type (in AVR they do) and I'd have to use a temporary anyway
>> then.
>>
>> This was the least intrusive way.
>
>
> Did you consider something like this?

I have, but I did not like how it could run code that is not very explicit
in case of exceptions, possibly assigning from a non-initialized variable,
causing, theoretically UB. Besides, __mem was already used for
tm_mom, so it seemed best to just mimic for the rest.

I have another patch attached which fixes the problem you mentioned
and the same problem with the tm_wday in a different switch-case.
I've removed all initializations of __mem, the same way that tm_mon
already did not initialize it, because the value is not actually used at
all in extract_num and variants.

I have ran the test and nothing on locale failed, I've ran again with the fixes,
and there are also no errors on locale. Testing with x86_64.

Changelog is:

2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>

   * include/bits/locale_facets_nonio.tcc: Avoid compilation errors
   with non-standard struct tm.

> This should have no overhead for the targets with standard conforming
> struct tm, and only uses a temporary variable and additional
> assignments for AVR.
>
> It's ugly though.

Quite ugly, specially because of exceptions IMO.

Kind regards,
-- 
Felipe Magno de Almeida

[-- Attachment #2: 0001-Use-temporary-int-objects-to-access-struct-tm-member.patch --]
[-- Type: text/x-diff, Size: 4812 bytes --]

From a16f976cc02d5d8431923943ba3962733e17d13f Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 18:52:57 -0300
Subject: [PATCH] Use temporary int objects to access struct tm members

Call _M_extract_* functions family through temporary int objects, so
it doesn't convert from lvalue to rvalue through a temporary in AVR
because of the incompatible types used in AVR-Libc.

This fixes compilation errors with AVR-Libc while compiling libstdc++
for AVR target.
---
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 34 +++++++++++++++--------
 1 file changed, 22 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..cfbd381 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,34 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+                  __tm->tm_wday = __mem;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+                  __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months1, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months2, 12, __io, __tmperr);
+                  __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +697,20 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+                  __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +721,15 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+                  __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +740,9 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+                  __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +761,12 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+                  __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
-- 
2.10.2


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-12-14 21:39       ` Felipe Magno de Almeida
@ 2016-12-15 11:15         ` Jonathan Wakely
       [not found]           ` <CADfx-VRosQDhU0uOQhknAzcbhVyrdnQ9n=9NmGVmPkP9n+NqGg@mail.gmail.com>
  0 siblings, 1 reply; 18+ messages in thread
From: Jonathan Wakely @ 2016-12-15 11:15 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On 14/12/16 18:38 -0300, Felipe Magno de Almeida wrote:
>Hello Jonathan,
>
>Sorry for the delay, I was in mid-vacation.
>
>Comments are inline.
>
>On Tue, Dec 6, 2016 at 3:45 PM, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On 16/09/16 02:53 -0300, Felipe Magno de Almeida wrote:
>>>
>
>[snip]
>
>>> I've tried both approaches. Templates were causing problems of not
>>> defined instantations because they were being used as ints too
>>> in other _M_extract functions through a tmp integer. And typedef's
>>> caused the same problem of having to use a tmp value of the right
>>> type but for example _M_extract_wday_or_month could not have the
>>> same type (in AVR they do) and I'd have to use a temporary anyway
>>> then.
>>>
>>> This was the least intrusive way.
>>
>>
>> Did you consider something like this?
>
>I have, but I did not like how it could run code that is not very explicit
>in case of exceptions, possibly assigning from a non-initialized variable,

OK, but that assignment from a possibly-uninitialized variable was
also present in your original patch.

>causing, theoretically UB. Besides, __mem was already used for
>tm_mom, so it seemed best to just mimic for the rest.

Yes, but now we have that overhead of extra reads and writes for every
function, not just that one.

>I have another patch attached which fixes the problem you mentioned
>and the same problem with the tm_wday in a different switch-case.
>I've removed all initializations of __mem, the same way that tm_mon
>already did not initialize it, because the value is not actually used at
>all in extract_num and variants.

Doesn't this now mean that if an error happens in the _M_extract_xxx
function we set tm.tm_xxx to garbage?

The existing tm.tm_mon case handles that correctly, by checking for an
error first.

>I have ran the test and nothing on locale failed, I've ran again with the fixes,
>and there are also no errors on locale. Testing with x86_64.

Good, thanks for testing it.

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
       [not found]           ` <CADfx-VRosQDhU0uOQhknAzcbhVyrdnQ9n=9NmGVmPkP9n+NqGg@mail.gmail.com>
@ 2016-12-16 12:45             ` Jonathan Wakely
  2016-12-23 15:19               ` Felipe Magno de Almeida
  0 siblings, 1 reply; 18+ messages in thread
From: Jonathan Wakely @ 2016-12-16 12:45 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On 15/12/16 21:41 -0300, Felipe Magno de Almeida wrote:
>Good point. Do you want me to update the patch with __men or go your way
>with the wrapper?

I think my wrapper's too ugly :-)

So please follow the same approach as for tm_mon (pass __mem to the
function, the copy it to tm_mon if there was no error). That adds a
write and a branch for every extracted field, which I hope shouldn't
have too much impact.

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-12-16 12:45             ` Jonathan Wakely
@ 2016-12-23 15:19               ` Felipe Magno de Almeida
  2017-01-10 14:16                 ` Jonathan Wakely
  0 siblings, 1 reply; 18+ messages in thread
From: Felipe Magno de Almeida @ 2016-12-23 15:19 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 782 bytes --]

On Fri, Dec 16, 2016 at 10:45 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
> On 15/12/16 21:41 -0300, Felipe Magno de Almeida wrote:
>>
>> Good point. Do you want me to update the patch with __men or go your way
>> with the wrapper?

Hello Jonathan,

> I think my wrapper's too ugly :-)

:)

> So please follow the same approach as for tm_mon (pass __mem to the
> function, the copy it to tm_mon if there was no error). That adds a
> write and a branch for every extracted field, which I hope shouldn't
> have too much impact.

Please find it attached.

Changelog is the same:

2016-11-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>

   * include/bits/locale_facets_nonio.tcc: Avoid compilation errors
   with non-standard struct tm.

-- 
Felipe Magno de Almeida

[-- Attachment #2: 0001-Use-temporary-int-objects-to-access-struct-tm-member.patch --]
[-- Type: text/x-diff, Size: 5033 bytes --]

From f5da929741a2e58cfc9bcc4fab3f8b053d56d800 Mon Sep 17 00:00:00 2001
From: Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
Date: Thu, 15 Sep 2016 18:52:57 -0300
Subject: [PATCH] Use temporary int objects to access struct tm members

Call _M_extract_* functions family through temporary int objects, so
it doesn't convert from lvalue to rvalue through a temporary in AVR
because of the incompatible types used in AVR-Libc.

This fixes compilation errors with AVR-Libc while compiling libstdc++
for AVR target.
---
 libstdc++-v3/include/bits/locale_facets_nonio.tcc | 44 ++++++++++++++++-------
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 1a4f9a0..306dd2e 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_wday = __mem;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months1, 12, __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, __mem, 
 					  __months2, 12, __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +701,22 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +727,17 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +748,10 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+		  if (!__tmperr)
+                    __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')
-- 
2.10.2


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-12-23 15:19               ` Felipe Magno de Almeida
@ 2017-01-10 14:16                 ` Jonathan Wakely
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2017-01-10 14:16 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

On 23/12/16 13:18 -0200, Felipe Magno de Almeida wrote:
>On Fri, Dec 16, 2016 at 10:45 AM, Jonathan Wakely <jwakely@redhat.com> wrote:
>> On 15/12/16 21:41 -0300, Felipe Magno de Almeida wrote:
>>>
>>> Good point. Do you want me to update the patch with __men or go your way
>>> with the wrapper?
>
>Hello Jonathan,
>
>> I think my wrapper's too ugly :-)
>
>:)
>
>> So please follow the same approach as for tm_mon (pass __mem to the
>> function, the copy it to tm_mon if there was no error). That adds a
>> write and a branch for every extracted field, which I hope shouldn't
>> have too much impact.
>
>Please find it attached.

This has now been committed to trunk (with whitespace fixes) - thanks.


[-- Attachment #2: patch.txt --]
[-- Type: text/x-patch, Size: 4944 bytes --]

commit 1cf9a4be2647a9bb54e763b74fb09d5a21706bd6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jan 10 12:43:29 2017 +0000

    Use temporary int objects to access struct tm members
    
    Call _M_extract_* functions family through temporary int objects, so
    it doesn't convert from lvalue to rvalue through a temporary in AVR
    because of the incompatible types used in AVR-Libc.
    
    This fixes compilation errors with AVR-Libc while compiling libstdc++
    for AVR target.
    
    2017-01-10  Felipe Magno de Almeida <felipe@expertisesolutions.com.br>
    
    	* include/bits/locale_facets_nonio.tcc
    	(time_get::_M_extract_via_format): Avoid compilation errors with
    	non-standard struct tm.

diff --git a/libstdc++-v3/include/bits/locale_facets_nonio.tcc b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
index 2fcf234..a449c41 100644
--- a/libstdc++-v3/include/bits/locale_facets_nonio.tcc
+++ b/libstdc++-v3/include/bits/locale_facets_nonio.tcc
@@ -659,30 +659,38 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Abbreviated weekday name [tm_wday]
 		  const char_type*  __days1[7];
 		  __tp._M_days_abbreviated(__days1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days1,
+		  __beg = _M_extract_name(__beg, __end, __mem, __days1,
 					  7, __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_wday = __mem;
 		  break;
 		case 'A':
 		  // Weekday name [tm_wday].
 		  const char_type*  __days2[7];
 		  __tp._M_days(__days2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_wday, __days2,
+		  __beg = _M_extract_name(__beg, __end, __mem, __days2,
 					  7, __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_wday = __mem;
 		  break;
 		case 'h':
 		case 'b':
 		  // Abbreviated month name [tm_mon]
 		  const char_type*  __months1[12];
 		  __tp._M_months_abbreviated(__months1);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, __mem,
 					  __months1, 12, __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_mon = __mem;
 		  break;
 		case 'B':
 		  // Month name [tm_mon].
 		  const char_type*  __months2[12];
 		  __tp._M_months(__months2);
-		  __beg = _M_extract_name(__beg, __end, __tm->tm_mon, 
+		  __beg = _M_extract_name(__beg, __end, __mem,
 					  __months2, 12, __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_mon = __mem;
 		  break;
 		case 'c':
 		  // Default time and date representation.
@@ -693,18 +701,22 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'd':
 		  // Day [01, 31]. [tm_mday]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 1, 31, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 31, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_mday = __mem;
 		  break;
 		case 'e':
 		  // Day [1, 31], with single digits preceded by
 		  // space. [tm_mday]
 		  if (__ctype.is(ctype_base::space, *__beg))
-		    __beg = _M_extract_num(++__beg, __end, __tm->tm_mday, 1, 9,
+		    __beg = _M_extract_num(++__beg, __end, __mem, 1, 9,
 					   1, __io, __tmperr);
 		  else
-		    __beg = _M_extract_num(__beg, __end, __tm->tm_mday, 10, 31,
+		    __beg = _M_extract_num(__beg, __end, __mem, 10, 31,
 					   2, __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_mday = __mem;
 		  break;
 		case 'D':
 		  // Equivalent to %m/%d/%y.[tm_mon, tm_mday, tm_year]
@@ -715,13 +727,17 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'H':
 		  // Hour [00, 23]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 0, 23, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 23, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_hour = __mem;
 		  break;
 		case 'I':
 		  // Hour [01, 12]. [tm_hour]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_hour, 1, 12, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 1, 12, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_hour = __mem;
 		  break;
 		case 'm':
 		  // Month [01, 12]. [tm_mon]
@@ -732,8 +748,10 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  break;
 		case 'M':
 		  // Minute [00, 59]. [tm_min]
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_min, 0, 59, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 59, 2,
 					 __io, __tmperr);
+		  if (!__tmperr)
+		    __tm->tm_min = __mem;
 		  break;
 		case 'n':
 		  if (__ctype.narrow(*__beg, 0) == '\n')
@@ -752,11 +770,13 @@ _GLIBCXX_END_NAMESPACE_LDBL_OR_CXX11
 		  // Seconds. [tm_sec]
 		  // [00, 60] in C99 (one leap-second), [00, 61] in C89.
 #if _GLIBCXX_USE_C99
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 60, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 60, 2,
 #else
-		  __beg = _M_extract_num(__beg, __end, __tm->tm_sec, 0, 61, 2,
+		  __beg = _M_extract_num(__beg, __end, __mem, 0, 61, 2,
 #endif
 					 __io, __tmperr);
+		  if (!__tmperr)
+		  __tm->tm_sec = __mem;
 		  break;
 		case 't':
 		  if (__ctype.narrow(*__beg, 0) == '\t')

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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2016-12-06 17:59           ` Jonathan Wakely
@ 2023-09-29 14:07             ` Jonathan Wakely
  2023-09-29 14:30               ` Jonathan Wakely
  0 siblings, 1 reply; 18+ messages in thread
From: Jonathan Wakely @ 2023-09-29 14:07 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On Tue, 6 Dec 2016 at 17:59, Jonathan Wakely wrote:
> >Subject: [PATCH 3/3] Enable libstdc++ compilation in AVR targets
> >
> >Enable libstdc++ compilation in AVR targets with AVR-Libc. Most
> >floating point math functions are already defined in AVR-Libc, so
> >defines are in place to avoid multiple definition of these functions.
>
> I've committed this one too.


Hi Felipe,

Back in 2006 we committed a patch from you that made this change:

--- a/libstdc++-v3/crossconfig.m4
+++ b/libstdc++-v3/crossconfig.m4
@@ -9,6 +9,32 @@ case "${host}" in
     # This is a freestanding configuration; there is nothing to do here.
     ;;

+  avr*-*-*)
+    AC_DEFINE(HAVE_ACOSF)
+    AC_DEFINE(HAVE_ASINF)
+    AC_DEFINE(HAVE_ATAN2F)
+    AC_DEFINE(HAVE_ATANF)
+    AC_DEFINE(HAVE_CEILF)
+    AC_DEFINE(HAVE_COSF)
+    AC_DEFINE(HAVE_COSHF)
+    AC_DEFINE(HAVE_EXPF)
+    AC_DEFINE(HAVE_FABSF)
+    AC_DEFINE(HAVE_FLOORF)
+    AC_DEFINE(HAVE_FMODF)
+    AC_DEFINE(HAVE_FREXPF)
+    AC_DEFINE(HAVE_SQRTF)
+    AC_DEFINE(HAVE_HYPOTF)
+    AC_DEFINE(HAVE_LDEXPF)
+    AC_DEFINE(HAVE_LOG10F)
+    AC_DEFINE(HAVE_LOGF)
+    AC_DEFINE(HAVE_MODFF)
+    AC_DEFINE(HAVE_POWF)
+    AC_DEFINE(HAVE_SINF)
+    AC_DEFINE(HAVE_SINHF)
+    AC_DEFINE(HAVE_TANF)
+    AC_DEFINE(HAVE_TANHF)
+    ;;
+
   mips*-sde-elf*)
     # These definitions are for the SDE C library rather than newlib.
     SECTION_FLAGS='-ffunction-sections -fdata-sections'

I'm testing a change today which causes a build failure on avr,
because of your config change.

I've filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111639 about
this, could you take a look please?

You said that AVR has those math functions, so we don't need to define
them in libstdc++-v3/src/c++98/math_stubs_float.cc but I don't think
that's true. It doesn't have them, it has macros like this:

extern double acos(double __x) __ATTR_CONST__;
#define acosf    acos        /**< The alias for acos().    */

That does indeed cause build failures in math_stubs_float.cc, but not
because of duplicate definitions of acosf etc.

And the macro definitions are not acceptable definitions of those
functions for a C++ library.

I've proposed a fix in the bug report.


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

* Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx
  2023-09-29 14:07             ` Jonathan Wakely
@ 2023-09-29 14:30               ` Jonathan Wakely
  0 siblings, 0 replies; 18+ messages in thread
From: Jonathan Wakely @ 2023-09-29 14:30 UTC (permalink / raw)
  To: Felipe Magno de Almeida; +Cc: libstdc++, gcc-patches

On Fri, 29 Sept 2023 at 15:07, Jonathan Wakely <jwakely@redhat.com> wrote:
>
> On Tue, 6 Dec 2016 at 17:59, Jonathan Wakely wrote:
> > >Subject: [PATCH 3/3] Enable libstdc++ compilation in AVR targets
> > >
> > >Enable libstdc++ compilation in AVR targets with AVR-Libc. Most
> > >floating point math functions are already defined in AVR-Libc, so
> > >defines are in place to avoid multiple definition of these functions.
> >
> > I've committed this one too.
>
>
> Hi Felipe,
>
> Back in 2006 we committed a patch from you that made this change:

Oops, sorry for the typo, I meant 2016 of course!


>
> --- a/libstdc++-v3/crossconfig.m4
> +++ b/libstdc++-v3/crossconfig.m4
> @@ -9,6 +9,32 @@ case "${host}" in
>      # This is a freestanding configuration; there is nothing to do here.
>      ;;
>
> +  avr*-*-*)
> +    AC_DEFINE(HAVE_ACOSF)
> +    AC_DEFINE(HAVE_ASINF)
> +    AC_DEFINE(HAVE_ATAN2F)
> +    AC_DEFINE(HAVE_ATANF)
> +    AC_DEFINE(HAVE_CEILF)
> +    AC_DEFINE(HAVE_COSF)
> +    AC_DEFINE(HAVE_COSHF)
> +    AC_DEFINE(HAVE_EXPF)
> +    AC_DEFINE(HAVE_FABSF)
> +    AC_DEFINE(HAVE_FLOORF)
> +    AC_DEFINE(HAVE_FMODF)
> +    AC_DEFINE(HAVE_FREXPF)
> +    AC_DEFINE(HAVE_SQRTF)
> +    AC_DEFINE(HAVE_HYPOTF)
> +    AC_DEFINE(HAVE_LDEXPF)
> +    AC_DEFINE(HAVE_LOG10F)
> +    AC_DEFINE(HAVE_LOGF)
> +    AC_DEFINE(HAVE_MODFF)
> +    AC_DEFINE(HAVE_POWF)
> +    AC_DEFINE(HAVE_SINF)
> +    AC_DEFINE(HAVE_SINHF)
> +    AC_DEFINE(HAVE_TANF)
> +    AC_DEFINE(HAVE_TANHF)
> +    ;;
> +
>    mips*-sde-elf*)
>      # These definitions are for the SDE C library rather than newlib.
>      SECTION_FLAGS='-ffunction-sections -fdata-sections'
>
> I'm testing a change today which causes a build failure on avr,
> because of your config change.
>
> I've filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111639 about
> this, could you take a look please?
>
> You said that AVR has those math functions, so we don't need to define
> them in libstdc++-v3/src/c++98/math_stubs_float.cc but I don't think
> that's true. It doesn't have them, it has macros like this:
>
> extern double acos(double __x) __ATTR_CONST__;
> #define acosf    acos        /**< The alias for acos().    */
>
> That does indeed cause build failures in math_stubs_float.cc, but not
> because of duplicate definitions of acosf etc.
>
> And the macro definitions are not acceptable definitions of those
> functions for a C++ library.
>
> I've proposed a fix in the bug report.


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

end of thread, other threads:[~2023-09-29 14:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16  1:43 Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx Felipe Magno de Almeida
2016-09-16  5:42 ` Marc Glisse
2016-09-16  5:53   ` Felipe Magno de Almeida
2016-09-16  6:37     ` Felipe Magno de Almeida
2016-11-10 15:40       ` Felipe Magno de Almeida
2016-11-10 15:52         ` Felipe Magno de Almeida
2016-12-06 15:08           ` Jonathan Wakely
2016-12-06 17:59           ` Jonathan Wakely
2023-09-29 14:07             ` Jonathan Wakely
2023-09-29 14:30               ` Jonathan Wakely
2016-12-06 18:11           ` Jonathan Wakely
2016-11-12  3:19         ` Jonathan Wakely
2016-12-06 18:45     ` Jonathan Wakely
2016-12-14 21:39       ` Felipe Magno de Almeida
2016-12-15 11:15         ` Jonathan Wakely
     [not found]           ` <CADfx-VRosQDhU0uOQhknAzcbhVyrdnQ9n=9NmGVmPkP9n+NqGg@mail.gmail.com>
2016-12-16 12:45             ` Jonathan Wakely
2016-12-23 15:19               ` Felipe Magno de Almeida
2017-01-10 14:16                 ` 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).