public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* [patch libiberty's include]: Fixes PR 39064 and partial PR 54620
@ 2013-01-30 10:53 Kai Tietz
  2013-01-30 14:31 ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2013-01-30 10:53 UTC (permalink / raw)
  To: GCC Patches; +Cc: Binutils, gdb

Hi,

this patch fixes for targets with sys/types.h the issue that wrong
assumptions about pointer-sizes are used.
Instead it uses uintptr_t/intptr_t.

ChangeLog /include

2013-01-30  Kai Tietz  <ktietz@redhat.com>

	PR other/54620
	PR target/39064
	* md5.h: Include sys/types.h if HAVE_SYS_TYPES_H
	is defined.
	* sha1.h: Likewise.

Tested for x86_64-unknown-linux-gnu, x86_64-w64-mingw32, and
i686-w64-mingw32.  Ok for apply?

Regards,
Kai

Index: md5.h
===================================================================
--- md5.h	(Revision 195288)
+++ md5.h	(Arbeitskopie)
@@ -36,7 +36,7 @@
    the resulting executable.  Locally running cross-compiled executables
    is usually not possible.  */

-#ifdef _LIBC
+#if defined (_LIBC) || defined (HAVE_SYS_TYPES_H)
 # include <sys/types.h>
 typedef u_int32_t md5_uint32;
 typedef uintptr_t md5_uintptr;
Index: sha1.h
===================================================================
--- sha1.h	(Revision 195288)
+++ sha1.h	(Arbeitskopie)
@@ -35,7 +35,7 @@
    the resulting executable.  Locally running cross-compiled executables
    is usually not possible.  */

-#ifdef _LIBC
+#if defined (_LIBC) || defined (HAVE_SYS_TYPES_H)
 # include <sys/types.h>
 typedef u_int32_t sha1_uint32;
 typedef uintptr_t sha1_uintptr;

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

* Re: [patch libiberty's include]: Fixes PR 39064 and partial PR 54620
  2013-01-30 10:53 [patch libiberty's include]: Fixes PR 39064 and partial PR 54620 Kai Tietz
@ 2013-01-30 14:31 ` Ian Lance Taylor
  2013-01-30 14:48   ` Kai Tietz
  0 siblings, 1 reply; 6+ messages in thread
From: Ian Lance Taylor @ 2013-01-30 14:31 UTC (permalink / raw)
  To: Kai Tietz; +Cc: GCC Patches, Binutils, gdb

On Wed, Jan 30, 2013 at 2:53 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>
> this patch fixes for targets with sys/types.h the issue that wrong
> assumptions about pointer-sizes are used.
> Instead it uses uintptr_t/intptr_t.
>
> ChangeLog /include
>
> 2013-01-30  Kai Tietz  <ktietz@redhat.com>
>
>         PR other/54620
>         PR target/39064
>         * md5.h: Include sys/types.h if HAVE_SYS_TYPES_H
>         is defined.
>         * sha1.h: Likewise.
>
> Tested for x86_64-unknown-linux-gnu, x86_64-w64-mingw32, and
> i686-w64-mingw32.  Ok for apply?
>
> Regards,
> Kai
>
> Index: md5.h
> ===================================================================
> --- md5.h       (Revision 195288)
> +++ md5.h       (Arbeitskopie)
> @@ -36,7 +36,7 @@
>     the resulting executable.  Locally running cross-compiled executables
>     is usually not possible.  */
>
> -#ifdef _LIBC
> +#if defined (_LIBC) || defined (HAVE_SYS_TYPES_H)
>  # include <sys/types.h>
>  typedef u_int32_t md5_uint32;
>  typedef uintptr_t md5_uintptr;
> Index: sha1.h
> ===================================================================
> --- sha1.h      (Revision 195288)
> +++ sha1.h      (Arbeitskopie)
> @@ -35,7 +35,7 @@
>     the resulting executable.  Locally running cross-compiled executables
>     is usually not possible.  */
>
> -#ifdef _LIBC
> +#if defined (_LIBC) || defined (HAVE_SYS_TYPES_H)
>  # include <sys/types.h>
>  typedef u_int32_t sha1_uint32;
>  typedef uintptr_t sha1_uintptr;



This code is intended to be highly portable.  I don't have a problem
with uintptr_t, but I'm not certain that <sys/types.h> on all systems
defines u_int32_t.

Ian

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

* Re: [patch libiberty's include]: Fixes PR 39064 and partial PR 54620
  2013-01-30 14:31 ` Ian Lance Taylor
@ 2013-01-30 14:48   ` Kai Tietz
  2013-01-30 14:56     ` Rainer Orth
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2013-01-30 14:48 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: GCC Patches, Binutils, gdb

2013/1/30 Ian Lance Taylor <iant@google.com>:
> On Wed, Jan 30, 2013 at 2:53 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>
>> this patch fixes for targets with sys/types.h the issue that wrong
>> assumptions about pointer-sizes are used.
>> Instead it uses uintptr_t/intptr_t.
>>
>> ChangeLog /include
>>
>> 2013-01-30  Kai Tietz  <ktietz@redhat.com>
>>
>>         PR other/54620
>>         PR target/39064
>>         * md5.h: Include sys/types.h if HAVE_SYS_TYPES_H
>>         is defined.
>>         * sha1.h: Likewise.
>>
>> Tested for x86_64-unknown-linux-gnu, x86_64-w64-mingw32, and
>> i686-w64-mingw32.  Ok for apply?
>>
>> Regards,
>> Kai
>>
>> Index: md5.h
>> ===================================================================
>> --- md5.h       (Revision 195288)
>> +++ md5.h       (Arbeitskopie)
>> @@ -36,7 +36,7 @@
>>     the resulting executable.  Locally running cross-compiled executables
>>     is usually not possible.  */
>>
>> -#ifdef _LIBC
>> +#if defined (_LIBC) || defined (HAVE_SYS_TYPES_H)
>>  # include <sys/types.h>
>>  typedef u_int32_t md5_uint32;
>>  typedef uintptr_t md5_uintptr;
>> Index: sha1.h
>> ===================================================================
>> --- sha1.h      (Revision 195288)
>> +++ sha1.h      (Arbeitskopie)
>> @@ -35,7 +35,7 @@
>>     the resulting executable.  Locally running cross-compiled executables
>>     is usually not possible.  */
>>
>> -#ifdef _LIBC
>> +#if defined (_LIBC) || defined (HAVE_SYS_TYPES_H)
>>  # include <sys/types.h>
>>  typedef u_int32_t sha1_uint32;
>>  typedef uintptr_t sha1_uintptr;
>
>
>
> This code is intended to be highly portable.  I don't have a problem
> with uintptr_t, but I'm not certain that <sys/types.h> on all systems
> defines u_int32_t.
>
> Ian

Yes, this is a valid point.  The (u)int??_t types aren't necessarily
declared by including sys/types.h.  So what's about the following
patch.  If stdint.h header is present, then we should include it and
then we can assume that the (u)int??_t types are present.

Index: md5.h
===================================================================
--- md5.h	(Revision 195572)
+++ md5.h	(Arbeitskopie)
@@ -36,7 +36,11 @@
    the resulting executable.  Locally running cross-compiled executables
    is usually not possible.  */

-#ifdef _LIBC
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#if defined (_LIBC) || (defined (HAVE_SYS_TYPES_H) && defined (HAVE_STDINT_H))
 # include <sys/types.h>
 typedef u_int32_t md5_uint32;
 typedef uintptr_t md5_uintptr;
Index: sha1.h
===================================================================
--- sha1.h	(Revision 195572)
+++ sha1.h	(Arbeitskopie)
@@ -35,7 +35,11 @@
    the resulting executable.  Locally running cross-compiled executables
    is usually not possible.  */

-#ifdef _LIBC
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+#if defined (_LIBC) || (defined (HAVE_SYS_TYPES_H) && defined (HAVE_STDINT_H))
 # include <sys/types.h>
 typedef u_int32_t sha1_uint32;
 typedef uintptr_t sha1_uintptr;

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

* Re: [patch libiberty's include]: Fixes PR 39064 and partial PR 54620
  2013-01-30 14:48   ` Kai Tietz
@ 2013-01-30 14:56     ` Rainer Orth
  2013-01-30 15:03       ` Kai Tietz
  0 siblings, 1 reply; 6+ messages in thread
From: Rainer Orth @ 2013-01-30 14:56 UTC (permalink / raw)
  To: Kai Tietz; +Cc: Ian Lance Taylor, GCC Patches, Binutils, gdb

Kai Tietz <ktietz70@googlemail.com> writes:

> Yes, this is a valid point.  The (u)int??_t types aren't necessarily
> declared by including sys/types.h.  So what's about the following
> patch.  If stdint.h header is present, then we should include it and
> then we can assume that the (u)int??_t types are present.

This is wrong: <stdint.h> provides e.g. uint32_t, but not u_int32_t.
The latter is a BSDism.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

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

* Re: [patch libiberty's include]: Fixes PR 39064 and partial PR 54620
  2013-01-30 14:56     ` Rainer Orth
@ 2013-01-30 15:03       ` Kai Tietz
  2013-01-30 15:44         ` Ian Lance Taylor
  0 siblings, 1 reply; 6+ messages in thread
From: Kai Tietz @ 2013-01-30 15:03 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Ian Lance Taylor, GCC Patches, Binutils, gdb

Hmm, I see ...  so we need an new condition.

Is it ok to apply?

Thanks,
Kai

Index: md5.h
===================================================================
--- md5.h	(Revision 195572)
+++ md5.h	(Arbeitskopie)
@@ -40,6 +40,11 @@
 # include <sys/types.h>
 typedef u_int32_t md5_uint32;
 typedef uintptr_t md5_uintptr;
+#elif defined (HAVE_SYS_TYPES_H) && defined (HAVE_STDINT_H)
+#include <stdint.h>
+#include <sys/types.h>
+typedef uint32_t md5_uint32;
+typedef uintptr_t md5_uintptr;
 #else
 #  define INT_MAX_32_BITS 2147483647

Index: sha1.h
===================================================================
--- sha1.h	(Revision 195572)
+++ sha1.h	(Arbeitskopie)
@@ -39,6 +39,11 @@
 # include <sys/types.h>
 typedef u_int32_t sha1_uint32;
 typedef uintptr_t sha1_uintptr;
+#elif defined (HAVE_SYS_TYPES_H) && defined (HAVE_STDINT_H)
+#include <stdint.h>
+#include <sys/types.h>
+typedef uint32_t sha1_uint32;
+typedef uintptr_t sha1_uintptr;
 #else
 #  define INT_MAX_32_BITS 2147483647

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

* Re: [patch libiberty's include]: Fixes PR 39064 and partial PR 54620
  2013-01-30 15:03       ` Kai Tietz
@ 2013-01-30 15:44         ` Ian Lance Taylor
  0 siblings, 0 replies; 6+ messages in thread
From: Ian Lance Taylor @ 2013-01-30 15:44 UTC (permalink / raw)
  To: Kai Tietz; +Cc: Rainer Orth, GCC Patches, Binutils, gdb

On Wed, Jan 30, 2013 at 7:03 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hmm, I see ...  so we need an new condition.
>
> Is it ok to apply?

This version is OK if it bootstraps.

Thanks.

Ian

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

end of thread, other threads:[~2013-01-30 15:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-30 10:53 [patch libiberty's include]: Fixes PR 39064 and partial PR 54620 Kai Tietz
2013-01-30 14:31 ` Ian Lance Taylor
2013-01-30 14:48   ` Kai Tietz
2013-01-30 14:56     ` Rainer Orth
2013-01-30 15:03       ` Kai Tietz
2013-01-30 15:44         ` Ian Lance Taylor

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).