Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Pedro Alves
On 04/04/2012 04:07 PM, Ian Lance Taylor wrote:

> Tristan Gingold  writes:
> 
>> > Would something like that be acceptable ?
>> > I have just checked that I can still build gcc with that patch.  If you 
>> > like this approach I will properly submit a patch.
> Thanks.
> 
> You should also test that gdb continues to build with this patch.


GDB pulls stdint.h from gnulib (though not inttypes.h), so it should
be fine in principle.

> I guess the question here is portability.  Do we still care about
> portability to systems that have neither inttypes.h nor stdint.h?  I'm
> willing to try this and see if anybody complains.


-- 
Pedro Alves


Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Tristan Gingold

On Apr 4, 2012, at 5:07 PM, Ian Lance Taylor wrote:

> Tristan Gingold  writes:
> 
>> Would something like that be acceptable ?
>> I have just checked that I can still build gcc with that patch.  If you like 
>> this approach I will properly submit a patch.
> 
> Thanks.
> 
> You should also test that gdb continues to build with this patch.

Argh, good point.

> I guess the question here is portability.  Do we still care about
> portability to systems that have neither inttypes.h nor stdint.h?  I'm
> willing to try this and see if anybody complains.

In this case, autoconf defines uintptr_t so I don't think there is an issue 
here.

Tristan.

> 
> Ian
> 
> 
>> --- a/include/splay-tree.h
>> +++ b/include/splay-tree.h
>> @@ -37,18 +37,11 @@ extern "C" {
>> 
>> #include "ansidecl.h"
>> 
>> -#ifndef _WIN64
>> -  typedef unsigned long int libi_uhostptr_t;
>> -  typedef long int libi_shostptr_t;
>> -#else
>> -#ifdef __GNUC__
>> -  __extension__
>> +#ifdef HAVE_STDINT_H
>> +#include 
>> #endif
>> -  typedef unsigned long long libi_uhostptr_t;
>> -#ifdef __GNUC__
>> -  __extension__
>> -#endif
>> -  typedef long long libi_shostptr_t;
>> +#ifdef HAVE_INTTYPES_H
>> +#include 
>> #endif
>> 
>> #ifndef GTY
>> @@ -59,8 +52,8 @@ extern "C" {
>>these types, if necessary.  These types should be sufficiently wide
>>that any pointer or scalar can be cast to these types, and then
>>cast back, without loss of precision.  */
>> -typedef libi_uhostptr_t splay_tree_key;
>> -typedef libi_uhostptr_t splay_tree_value;
>> +typedef uintptr_t splay_tree_key;
>> +typedef uintptr_t splay_tree_value;
>> 
>> /* Forward declaration for a node in the tree.  */
>> typedef struct splay_tree_node_s *splay_tree_node;
>> 
>> 
>> index 7450eeb..fa45392 100644
>> --- a/gcc/gengtype.c
>> +++ b/gcc/gengtype.c
>> @@ -4976,6 +4976,7 @@ main (int argc, char **argv)
>>   POS_HERE (do_scalar_typedef ("double_int", &pos));
>>   POS_HERE (do_scalar_typedef ("uint64_t", &pos));
>>   POS_HERE (do_scalar_typedef ("uint8", &pos));
>> +  POS_HERE (do_scalar_typedef ("uintptr_t", &pos));
>>   POS_HERE (do_scalar_typedef ("jword", &pos));
>>   POS_HERE (do_scalar_typedef ("JCF_u2", &pos));
>>   POS_HERE (do_scalar_typedef ("void", &pos));



Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Ian Lance Taylor
Tristan Gingold  writes:

> Would something like that be acceptable ?
> I have just checked that I can still build gcc with that patch.  If you like 
> this approach I will properly submit a patch.

Thanks.

You should also test that gdb continues to build with this patch.

I guess the question here is portability.  Do we still care about
portability to systems that have neither inttypes.h nor stdint.h?  I'm
willing to try this and see if anybody complains.

Ian


> --- a/include/splay-tree.h
> +++ b/include/splay-tree.h
> @@ -37,18 +37,11 @@ extern "C" {
>  
>  #include "ansidecl.h"
>  
> -#ifndef _WIN64
> -  typedef unsigned long int libi_uhostptr_t;
> -  typedef long int libi_shostptr_t;
> -#else
> -#ifdef __GNUC__
> -  __extension__
> +#ifdef HAVE_STDINT_H
> +#include 
>  #endif
> -  typedef unsigned long long libi_uhostptr_t;
> -#ifdef __GNUC__
> -  __extension__
> -#endif
> -  typedef long long libi_shostptr_t;
> +#ifdef HAVE_INTTYPES_H
> +#include 
>  #endif
>  
>  #ifndef GTY
> @@ -59,8 +52,8 @@ extern "C" {
> these types, if necessary.  These types should be sufficiently wide
> that any pointer or scalar can be cast to these types, and then
> cast back, without loss of precision.  */
> -typedef libi_uhostptr_t splay_tree_key;
> -typedef libi_uhostptr_t splay_tree_value;
> +typedef uintptr_t splay_tree_key;
> +typedef uintptr_t splay_tree_value;
>  
>  /* Forward declaration for a node in the tree.  */
>  typedef struct splay_tree_node_s *splay_tree_node;
>
>
> index 7450eeb..fa45392 100644
> --- a/gcc/gengtype.c
> +++ b/gcc/gengtype.c
> @@ -4976,6 +4976,7 @@ main (int argc, char **argv)
>POS_HERE (do_scalar_typedef ("double_int", &pos));
>POS_HERE (do_scalar_typedef ("uint64_t", &pos));
>POS_HERE (do_scalar_typedef ("uint8", &pos));
> +  POS_HERE (do_scalar_typedef ("uintptr_t", &pos));
>POS_HERE (do_scalar_typedef ("jword", &pos));
>POS_HERE (do_scalar_typedef ("JCF_u2", &pos));
>POS_HERE (do_scalar_typedef ("void", &pos));


Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Tristan Gingold

On Apr 4, 2012, at 3:58 PM, Ian Lance Taylor wrote:

> Tristan Gingold  writes:
> 
>> include/
>> 2012-04-04  Tristan Gingold  
>> 
>>  * splay-tree.h: Use LLP64 definitions of libi_shostptr_t and
>>  libi_hostptr_t for VMS with 64bit pointers.
> 
> I was strongly opposed to adding a _WIN64 define here and this is just
> making it worse.

Understood.

Would something like that be acceptable ?
I have just checked that I can still build gcc with that patch.  If you like 
this approach I will properly submit a patch.

Tristan.

--- a/include/splay-tree.h
+++ b/include/splay-tree.h
@@ -37,18 +37,11 @@ extern "C" {
 
 #include "ansidecl.h"
 
-#ifndef _WIN64
-  typedef unsigned long int libi_uhostptr_t;
-  typedef long int libi_shostptr_t;
-#else
-#ifdef __GNUC__
-  __extension__
+#ifdef HAVE_STDINT_H
+#include 
 #endif
-  typedef unsigned long long libi_uhostptr_t;
-#ifdef __GNUC__
-  __extension__
-#endif
-  typedef long long libi_shostptr_t;
+#ifdef HAVE_INTTYPES_H
+#include 
 #endif
 
 #ifndef GTY
@@ -59,8 +52,8 @@ extern "C" {
these types, if necessary.  These types should be sufficiently wide
that any pointer or scalar can be cast to these types, and then
cast back, without loss of precision.  */
-typedef libi_uhostptr_t splay_tree_key;
-typedef libi_uhostptr_t splay_tree_value;
+typedef uintptr_t splay_tree_key;
+typedef uintptr_t splay_tree_value;
 
 /* Forward declaration for a node in the tree.  */
 typedef struct splay_tree_node_s *splay_tree_node;


index 7450eeb..fa45392 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -4976,6 +4976,7 @@ main (int argc, char **argv)
   POS_HERE (do_scalar_typedef ("double_int", &pos));
   POS_HERE (do_scalar_typedef ("uint64_t", &pos));
   POS_HERE (do_scalar_typedef ("uint8", &pos));
+  POS_HERE (do_scalar_typedef ("uintptr_t", &pos));
   POS_HERE (do_scalar_typedef ("jword", &pos));
   POS_HERE (do_scalar_typedef ("JCF_u2", &pos));
   POS_HERE (do_scalar_typedef ("void", &pos));



Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Ian Lance Taylor
Tristan Gingold  writes:

> include/
> 2012-04-04  Tristan Gingold  
>
>   * splay-tree.h: Use LLP64 definitions of libi_shostptr_t and
>   libi_hostptr_t for VMS with 64bit pointers.

I was strongly opposed to adding a _WIN64 define here and this is just
making it worse.

Ian


> --- a/include/splay-tree.h
> +++ b/include/splay-tree.h
> @@ -37,7 +37,8 @@ extern "C" {
>  
>  #include "ansidecl.h"
>  
> -#ifndef _WIN64
> +#if !(defined (_WIN64) \
> +  || (defined (__VMS__) && __INITIAL_POINTER_SIZE == 64))
>typedef unsigned long int libi_uhostptr_t;
>typedef long int libi_shostptr_t;
>  #else


Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Tristan Gingold

On Apr 4, 2012, at 11:26 AM, Pedro Alves wrote:

> On 04/04/2012 09:55 AM, Tristan Gingold wrote:
> 
>> Hi,
>> 
>> unfortunately VMS (when 64bit pointers are used - which is nice for gcc) is 
>> also an LLP64 platform.
>> So I need to follow to Win64 way in splay-tree.h.
> 
> 
> Doesn't VMS gcc define __LP64__/__LLP64__?

Unfortunately no (like mingw if I read config files correctly).

This makes even less sense on VMS where 32bit and 64bit can be used at the same 
time.

>  Then we could for example:
> 
> #if !(defined (_WIN64) || defined (__LLP64__))
> 
> and thus avoid sprinkling __VMS__ checks around.

In fact this is the only place where we need it, so this is under control :-)

Tristan.

> 
>> 
>> Tested manually by build (and using) gcc on ia64-hp-openvms.
>> 
>> Ok for trunk ?
>> 
>> Tristan.
>> 
>> include/
>> 2012-04-04  Tristan Gingold  
>> 
>>  * splay-tree.h: Use LLP64 definitions of libi_shostptr_t and
>>  libi_hostptr_t for VMS with 64bit pointers.
>> 
>> --- a/include/splay-tree.h
>> +++ b/include/splay-tree.h
>> @@ -37,7 +37,8 @@ extern "C" {
>> 
>> #include "ansidecl.h"
>> 
>> -#ifndef _WIN64
>> +#if !(defined (_WIN64) \
>> +  || (defined (__VMS__) && __INITIAL_POINTER_SIZE == 64))
>>   typedef unsigned long int libi_uhostptr_t;
>>   typedef long int libi_shostptr_t;
>> #else
>> 
> 
> 
> 
> -- 
> Pedro Alves



Re: [Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Pedro Alves
On 04/04/2012 09:55 AM, Tristan Gingold wrote:

> Hi,
> 
> unfortunately VMS (when 64bit pointers are used - which is nice for gcc) is 
> also an LLP64 platform.
> So I need to follow to Win64 way in splay-tree.h.


Doesn't VMS gcc define __LP64__/__LLP64__?  Then we could for example:

#if !(defined (_WIN64) || defined (__LLP64__))

and thus avoid sprinkling __VMS__ checks around.

> 
> Tested manually by build (and using) gcc on ia64-hp-openvms.
> 
> Ok for trunk ?
> 
> Tristan.
> 
> include/
> 2012-04-04  Tristan Gingold  
> 
>   * splay-tree.h: Use LLP64 definitions of libi_shostptr_t and
>   libi_hostptr_t for VMS with 64bit pointers.
> 
> --- a/include/splay-tree.h
> +++ b/include/splay-tree.h
> @@ -37,7 +37,8 @@ extern "C" {
>  
>  #include "ansidecl.h"
>  
> -#ifndef _WIN64
> +#if !(defined (_WIN64) \
> +  || (defined (__VMS__) && __INITIAL_POINTER_SIZE == 64))
>typedef unsigned long int libi_uhostptr_t;
>typedef long int libi_shostptr_t;
>  #else
> 



-- 
Pedro Alves


[Libiberty]: Handle VMS as a LLP64 platform in splay-tree.h

2012-04-04 Thread Tristan Gingold
Hi,

unfortunately VMS (when 64bit pointers are used - which is nice for gcc) is 
also an LLP64 platform.
So I need to follow to Win64 way in splay-tree.h.

Tested manually by build (and using) gcc on ia64-hp-openvms.

Ok for trunk ?

Tristan.

include/
2012-04-04  Tristan Gingold  

* splay-tree.h: Use LLP64 definitions of libi_shostptr_t and
libi_hostptr_t for VMS with 64bit pointers.

--- a/include/splay-tree.h
+++ b/include/splay-tree.h
@@ -37,7 +37,8 @@ extern "C" {
 
 #include "ansidecl.h"
 
-#ifndef _WIN64
+#if !(defined (_WIN64) \
+  || (defined (__VMS__) && __INITIAL_POINTER_SIZE == 64))
   typedef unsigned long int libi_uhostptr_t;
   typedef long int libi_shostptr_t;
 #else