public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Jenner <andrew@codesourcery.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>, <libstdc++@gcc.gnu.org>
Subject: [PATCH 4/9] libstdc++ changes for ia16
Date: Sat, 01 Apr 2017 16:48:00 -0000	[thread overview]
Message-ID: <916ca0f1-1bb4-4032-8bfe-abd39b5714a1@codesourcery.com> (raw)

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

2017-04-01  Andrew Jenner  <andrew@codesourcery.com>

	* src/c++11/cow-stdexcept.cc (_ITM_RU2): Declare.
	(txnal_read_ptr): Allow 16-bit pointers.
	* src/c++11/codecvt.cc (read_utf8_code_point): Handle 16-bit int.



[-- Attachment #2: gcc_ia16_libstdc++.patch --]
[-- Type: text/x-patch, Size: 2207 bytes --]

Index: libstdc++-v3/src/c++11/cow-stdexcept.cc
===================================================================
--- libstdc++-v3/src/c++11/cow-stdexcept.cc	(revision 475331)
+++ libstdc++-v3/src/c++11/cow-stdexcept.cc	(revision 475455)
@@ -208,6 +208,8 @@ extern void* _ZGTtnaX (size_t sz) __attr
 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
 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 bit or 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
 }

Index: libstdc++-v3/src/c++11/codecvt.cc
===================================================================
--- libstdc++-v3/src/c++11/codecvt.cc	(revision 475331)
+++ libstdc++-v3/src/c++11/codecvt.cc	(revision 475455)
@@ -177,7 +177,7 @@ namespace
       unsigned char c3 = from.next[2];
       if ((c3 & 0xC0) != 0x80)
 	return invalid_mb_sequence;
-      char32_t c = (c1 << 12) + (c2 << 6) + c3 - 0xE2080;
+      char32_t c = ((char32_t)c1 << 12) + (c2 << 6) + c3 - 0xE2080;
       if (c <= maxcode)
 	from.next += 3;
       return c;
@@ -199,7 +199,8 @@ namespace
       unsigned char c4 = from.next[3];
       if ((c4 & 0xC0) != 0x80)
 	return invalid_mb_sequence;
-      char32_t c = (c1 << 18) + (c2 << 12) + (c3 << 6) + c4 - 0x3C82080;
+      char32_t c = ((char32_t)c1 << 18) + ((char32_t)c2 << 12) + (c3 << 6)
+		   + c4 - 0x3C82080;
       if (c <= maxcode)
 	from.next += 4;
       return c;




             reply	other threads:[~2017-04-01 16:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-01 16:48 Andrew Jenner [this message]
2017-04-03 14:55 ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=916ca0f1-1bb4-4032-8bfe-abd39b5714a1@codesourcery.com \
    --to=andrew@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).