From patchwork Thu Nov 10 15:39:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Magno de Almeida X-Patchwork-Id: 81688 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp790239qge; Thu, 10 Nov 2016 07:40:35 -0800 (PST) X-Received: by 10.98.64.195 with SMTP id f64mr11184403pfd.16.1478792435886; Thu, 10 Nov 2016 07:40:35 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id kf2si4603253pad.130.2016.11.10.07.40.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Nov 2016 07:40:35 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-440964-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-440964-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440964-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=QDFr81wtNK7ZMJD uUeibgJxXo4ZB1emEaIML5mOJuGryYEAYTUk4tllDHp9Dnjz3RcyEszfYCU1F4Qo JxVUnwp9WEFVAAViRsbM2PUF+dpks3uxmEE2oBSvI9pbBY0WEm/LYzTSMUjrOj+p RoD4o3fzGf8kQXWdYM0qz4yN9ui4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=bgFx7SLTb/prj8fJQPKS+ TrAS0s=; b=bp+XRwKyZgllv711tKqlYXWIg6VukCWXhIgFg7VL8lpPGasL2M+3e c/M1E3a3Wdjr8I7HN4AlaePMEhAe22uoG2LgQXP7laAZSWLHZVFgujgIsk7+J9ZS hX8ANNFu8ZTVqelKju1rhYyXAFSlQxFmcyBnA1yj3EWJRVy6FBeI5g= Received: (qmail 112013 invoked by alias); 10 Nov 2016 15:40:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 111978 invoked by uid 89); 10 Nov 2016 15:40:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=D*com.br, Month, Felipe, felipe X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-qk0-f173.google.com Received: from mail-qk0-f173.google.com (HELO mail-qk0-f173.google.com) (209.85.220.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Nov 2016 15:39:56 +0000 Received: by mail-qk0-f173.google.com with SMTP id n204so290082347qke.2; Thu, 10 Nov 2016 07:39:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7kcbu7wV2ouehR1ytF3Qu4p7gd2yPD6WwFk38GcIcQI=; b=S41ctIT3vQgyehhft2jKYlSVvYv+tHDeResjGefGr6I2gu7Yf87PoafhRlyGtukuET z093ofB9/yPZF8VKcP0KQiUmbs1uLfRPZ0q9sNy8ds1fmqUi2tcN5XlF+U4eqlni8f16 QhKum3RWWL2xInRZEYL3xhP4sxS1W3aSl1Ih7KFFV/R8A9pkUIhbS1tdYmYVmVWLkC7p 6VAXDNRod9EWaOBFUG8w456qOPBfBw/kWZRDKRzYkJmVcAyl78Eh4mBroZGXsvRvZIB7 /8tgwqMgU7h91hVOJJXXJPGtdYY6v4jVGLCMt4rAb8aIMB2j4CZjrN7Dl+Iiuoa57Mcn HMqA== X-Gm-Message-State: ABUngvfoh3tjNIYiEu2qzh9qEtNuvba26sCh8/nIrYGdgjy96MTY4HOFOcQidQPv4rBtdB9TrbBdAu2nrpr/bA== X-Received: by 10.55.183.197 with SMTP id h188mr6840217qkf.107.1478792395015; Thu, 10 Nov 2016 07:39:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.140.27.243 with HTTP; Thu, 10 Nov 2016 07:39:24 -0800 (PST) In-Reply-To: References: From: Felipe Magno de Almeida Date: Thu, 10 Nov 2016 13:39:24 -0200 Message-ID: Subject: Re: Fix compilation errors with libstdc++v3 for AVR target and allow --enable-libstdcxx To: libstdc++@gcc.gnu.org, Jonathan Wakely Cc: gcc-patches@gcc.gnu.org X-IsSubscribed: yes 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 wrote: > Hello, > > Another patch. > > On Fri, Sep 16, 2016 at 2:53 AM, Felipe Magno de Almeida > wrote: >> On Fri, Sep 16, 2016 at 2:42 AM, Marc Glisse 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 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 + + * src/c++11/cow-stdexcept.cc: Add special case for 16 bit pointers + +2016-11-10 Felipe Magno de Almeida + + * include/bits/locale_facets_nonio.tcc: Avoid compilation errors + with non-standard struct tm. + +2016-11-10 Felipe Magno de Almeida + + * crossconfig.m4: Add avr target for cross-compilation + * configure: Regenerate + 2016-11-09 Tim Shen * 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 }