Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-14 Thread Joel Sherrill
Attached is an updated version of the patch which includes
some commentary above the include of stdint.h.

Is this OK to apply?

--joel

On 11/10/2014 1:03 PM, Paolo Carlini wrote:
 Hi,

 On 11/10/2014 07:34 PM, Jonathan Wakely wrote:
 On 10/11/14 12:01 -0600, Joel Sherrill wrote:
 cc'ing since both lists should be included.

 The m32c has 24-bit pointers and 16-bit size_t. This changes
 pushing a pointer through a size_t to pushing it through a
 uintptr_t.
 I'm OK with this change if Paolo is.
 No problem with the experiment (frankly, I'm not at all sure that the 
 targets not providing stdint.h are *that* much uncommon than the 
 target which we are fixing with the patch), but please add a comment 
 about stdint.h in the code, then if bootstrap actually breaks the 
 issue is clear...

 Paolo.

-- 
Joel Sherrill, Ph.D. Director of Research  Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985

From d1468be689dc23e39209b5cc981d00e89a465673 Mon Sep 17 00:00:00 2001
From: Joel Sherrill joel.sherr...@oarcorp.com
Date: Mon, 10 Nov 2014 09:34:15 -0600
Subject: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) ==
 sizeof(size_t)

2014-11-14  Joel Sherrill joel.sherr...@oarcorp.com

	* src/c++98/mt_allocator.cc: Fix assumption that sizeof(void *) is
	equal to sizeof(size_t). The m32c breaks this assumption.
---
 libstdc++-v3/src/c++98/mt_allocator.cc | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++98/mt_allocator.cc b/libstdc++-v3/src/c++98/mt_allocator.cc
index 38e17df..51b2605 100644
--- a/libstdc++-v3/src/c++98/mt_allocator.cc
+++ b/libstdc++-v3/src/c++98/mt_allocator.cc
@@ -31,6 +31,11 @@
 #include ext/mt_allocator.h
 #include cstring
 
+// The include file is needed for uintptr_t. If this file does not compile,
+// check to make sure the target has stdint.h and that it provides
+// uintptr_t.
+#include stdint.h
+
 namespace
 {
 #ifdef __GTHREADS
@@ -74,7 +79,7 @@ namespace
 __freelist freelist = get_freelist();
 {
   __gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
-  size_t _M_id = reinterpret_castsize_t(__id);
+  uintptr_t _M_id = reinterpret_castuintptr_t(__id);
   
   typedef __gnu_cxx::__pooltrue::_Thread_record _Thread_record;
   _Thread_record* __tr = freelist._M_thread_freelist_array[_M_id - 1];
@@ -627,7 +632,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
 	__freelist freelist = get_freelist();
 	void* v = __gthread_getspecific(freelist._M_key);
-	size_t _M_id = (size_t)v;
+	uintptr_t _M_id = (uintptr_t)v;
 	if (_M_id == 0)
 	  {
 	{
-- 
1.9.3



Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-14 Thread Jonathan Wakely

On 14/11/14 10:10 -0600, Joel Sherrill wrote:

Attached is an updated version of the patch which includes
some commentary above the include of stdint.h.

Is this OK to apply?


OK, thanks.


Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-14 Thread Joel Sherrill

On 11/14/2014 10:37 AM, Jonathan Wakely wrote:
 On 14/11/14 10:10 -0600, Joel Sherrill wrote:
 Attached is an updated version of the patch which includes
 some commentary above the include of stdint.h.

 Is this OK to apply?
 OK, thanks.
Committed. Thanks for all the feedback.

-- 
Joel Sherrill, Ph.D. Director of Research  Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985



[PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-10 Thread Joel Sherrill
2014-11-10  Joel Sherrill joel.sherr...@oarcorp.com

* src/c++98/mt_allocator.cc: Fix assumption that sizeof(void *) is
equal to sizeof(size_t). The m32c breaks this assumption.
---
 libstdc++-v3/src/c++98/mt_allocator.cc | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++98/mt_allocator.cc 
b/libstdc++-v3/src/c++98/mt_allocator.cc
index 38e17df..04dd8ad 100644
--- a/libstdc++-v3/src/c++98/mt_allocator.cc
+++ b/libstdc++-v3/src/c++98/mt_allocator.cc
@@ -30,6 +30,7 @@
 #include ext/concurrence.h
 #include ext/mt_allocator.h
 #include cstring
+#include stdint.h
 
 namespace
 {
@@ -74,7 +75,7 @@ namespace
 __freelist freelist = get_freelist();
 {
   __gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
-  size_t _M_id = reinterpret_castsize_t(__id);
+  uintptr_t _M_id = reinterpret_castuintptr_t(__id);
   
   typedef __gnu_cxx::__pooltrue::_Thread_record _Thread_record;
   _Thread_record* __tr = freelist._M_thread_freelist_array[_M_id - 1];
@@ -627,7 +628,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   {
__freelist freelist = get_freelist();
void* v = __gthread_getspecific(freelist._M_key);
-   size_t _M_id = (size_t)v;
+   uintptr_t _M_id = (uintptr_t)v;
if (_M_id == 0)
  {
{
-- 
1.9.3



Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-10 Thread Joel Sherrill
cc'ing since both lists should be included.

The m32c has 24-bit pointers and 16-bit size_t. This changes
pushing a pointer through a size_t to pushing it through a
uintptr_t.

--joel
On 11/10/2014 9:36 AM, Joel Sherrill wrote:
 2014-11-10  Joel Sherrill joel.sherr...@oarcorp.com

   * src/c++98/mt_allocator.cc: Fix assumption that sizeof(void *) is
   equal to sizeof(size_t). The m32c breaks this assumption.
 ---
  libstdc++-v3/src/c++98/mt_allocator.cc | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)

 diff --git a/libstdc++-v3/src/c++98/mt_allocator.cc 
 b/libstdc++-v3/src/c++98/mt_allocator.cc
 index 38e17df..04dd8ad 100644
 --- a/libstdc++-v3/src/c++98/mt_allocator.cc
 +++ b/libstdc++-v3/src/c++98/mt_allocator.cc
 @@ -30,6 +30,7 @@
  #include ext/concurrence.h
  #include ext/mt_allocator.h
  #include cstring
 +#include stdint.h
  
  namespace
  {
 @@ -74,7 +75,7 @@ namespace
  __freelist freelist = get_freelist();
  {
__gnu_cxx::__scoped_lock sentry(get_freelist_mutex());
 -  size_t _M_id = reinterpret_castsize_t(__id);
 +  uintptr_t _M_id = reinterpret_castuintptr_t(__id);

typedef __gnu_cxx::__pooltrue::_Thread_record _Thread_record;
_Thread_record* __tr = freelist._M_thread_freelist_array[_M_id - 1];
 @@ -627,7 +628,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
   __freelist freelist = get_freelist();
   void* v = __gthread_getspecific(freelist._M_key);
 - size_t _M_id = (size_t)v;
 + uintptr_t _M_id = (uintptr_t)v;
   if (_M_id == 0)
 {
   {

-- 
Joel Sherrill, Ph.D. Director of Research  Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985



Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-10 Thread Jonathan Wakely

On 10/11/14 12:01 -0600, Joel Sherrill wrote:

cc'ing since both lists should be included.

The m32c has 24-bit pointers and 16-bit size_t. This changes
pushing a pointer through a size_t to pushing it through a
uintptr_t.


I'm OK with this change if Paolo is.

If it breaks any targets without uintptr_t they can either add
stdint.h as Joseph suggested, or add some nasty #ifdef (it's only in
a .cc file not a public header ... and we don't really care about the
mt_allocator extension much now).



Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-10 Thread Paolo Carlini

Hi,

On 11/10/2014 07:34 PM, Jonathan Wakely wrote:

On 10/11/14 12:01 -0600, Joel Sherrill wrote:

cc'ing since both lists should be included.

The m32c has 24-bit pointers and 16-bit size_t. This changes
pushing a pointer through a size_t to pushing it through a
uintptr_t.


I'm OK with this change if Paolo is.
No problem with the experiment (frankly, I'm not at all sure that the 
targets not providing stdint.h are *that* much uncommon than the 
target which we are fixing with the patch), but please add a comment 
about stdint.h in the code, then if bootstrap actually breaks the 
issue is clear...


Paolo.


Re: [PATCH] c++98/mt_allcoator.cc: Fix assumption sizeof(void *) == sizeof(size_t)

2014-11-10 Thread Joel Sherrill

On 11/10/2014 1:03 PM, Paolo Carlini wrote:
 Hi,

 On 11/10/2014 07:34 PM, Jonathan Wakely wrote:
 On 10/11/14 12:01 -0600, Joel Sherrill wrote:
 cc'ing since both lists should be included.

 The m32c has 24-bit pointers and 16-bit size_t. This changes
 pushing a pointer through a size_t to pushing it through a
 uintptr_t.
 I'm OK with this change if Paolo is.
 No problem with the experiment (frankly, I'm not at all sure that the 
 targets not providing stdint.h are *that* much uncommon than the 
 target which we are fixing with the patch), but please add a comment 
 about stdint.h in the code, then if bootstrap actually breaks the 
 issue is clear...
Just to be clear add a comment above the include of stdint.h that it is
assumed
that a target provides this header file and defines uintptr_t.
 Paolo.

-- 
Joel Sherrill, Ph.D. Director of Research  Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985