* [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes @ 2012-12-21 8:00 Kai Tietz 2012-12-21 9:12 ` Marc Glisse ` (2 more replies) 0 siblings, 3 replies; 15+ messages in thread From: Kai Tietz @ 2012-12-21 8:00 UTC (permalink / raw) To: GCC Patches; +Cc: libstdc++ Hello, this patch fixes some remaining issues with pointer-sizes for llp64 abi in libstdc++. ChangeLog 2012-12-21 Kai Tietz * config/os/mingw32/os_defines.h (_GLIBCXX_LLP64): Define if llp64 abi is used. * config/os/mingw32-w64/os_defines.h: Likewise. * libsupc++/cxxabi.h (__base_class_type_info): Change type __offset_flags to intptr_t. * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define proper for llp64 abi. (EMERGENCY_OBJ_COUNT): Likewise. (bitmask_type): Likewise. * ibsupc++/hash_bytes.cc (_Hash_bytes): Handle llp64. Tested for i686-w64-mingw32, x86_64-w64-mingw32, and x86_64-unknown-linux-gnu. Ok for apply? Regards, Kai Index: config/os/mingw32/os_defines.h =================================================================== --- config/os/mingw32/os_defines.h (Revision 194655) +++ config/os/mingw32/os_defines.h (Arbeitskopie) @@ -72,4 +72,8 @@ #define _GLIBCXX_CDTOR_CALLABI __thiscall #endif +#ifdef __x86_64__ +#define _GLIBCXX_LLP64 1 #endif + +#endif Index: config/os/mingw32-w64/os_defines.h =================================================================== --- config/os/mingw32-w64/os_defines.h (Revision 194655) +++ config/os/mingw32-w64/os_defines.h (Arbeitskopie) @@ -74,4 +74,8 @@ #define _GLIBCXX_CDTOR_CALLABI __thiscall #endif +#ifdef __x86_64__ +#define _GLIBCXX_LLP64 1 #endif + +#endif Index: libsupc++/cxxabi.h =================================================================== --- libsupc++/cxxabi.h (Revision 194655) +++ libsupc++/cxxabi.h (Arbeitskopie) @@ -356,7 +356,7 @@ namespace __cxxabiv1 { public: const __class_type_info* __base_type; // Base class type. - long __offset_flags; // Offset and info. + intptr_t __offset_flags; // Offset and info. enum __offset_flags_masks { Index: libsupc++/eh_alloc.cc =================================================================== --- libsupc++/eh_alloc.cc (Revision 194655) +++ libsupc++/eh_alloc.cc (Arbeitskopie) @@ -60,7 +60,7 @@ using namespace __cxxabiv1; #if INT_MAX == 32767 # define EMERGENCY_OBJ_SIZE 128 # define EMERGENCY_OBJ_COUNT 16 -#elif LONG_MAX == 2147483647 +#elif !defined (_GLIBCXX_LLP64) && LONG_MAX == 2147483647 # define EMERGENCY_OBJ_SIZE 512 # define EMERGENCY_OBJ_COUNT 32 #else @@ -76,8 +76,12 @@ using namespace __cxxabiv1; #if INT_MAX == 32767 || EMERGENCY_OBJ_COUNT <= 32 typedef unsigned int bitmask_type; #else +#if defined (_GLIBCXX_LLP64) +typedef unsigned long long bitmask_type; +#else typedef unsigned long bitmask_type; #endif +#endif typedef char one_buffer[EMERGENCY_OBJ_SIZE] __attribute__((aligned)); Index: libsupc++/hash_bytes.cc =================================================================== --- libsupc++/hash_bytes.cc (Revision 194655) +++ libsupc++/hash_bytes.cc (Arbeitskopie) @@ -128,7 +128,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t _Hash_bytes(const void* ptr, size_t len, size_t seed) { - static const size_t mul = (0xc6a4a793UL << 32UL) + 0x5bd1e995UL; + static const size_t mul = (((size_t) 0xc6a4a793UL) << 32UL) + + (size_t) 0x5bd1e995UL; const char* const buf = static_cast<const char*>(ptr); // Remove the bytes not divisible by the sizeof(size_t). This ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 8:00 [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes Kai Tietz @ 2012-12-21 9:12 ` Marc Glisse 2012-12-21 9:13 ` Paolo Carlini 2012-12-21 14:59 ` Gabriel Dos Reis 2 siblings, 0 replies; 15+ messages in thread From: Marc Glisse @ 2012-12-21 9:12 UTC (permalink / raw) To: Kai Tietz; +Cc: GCC Patches, libstdc++ On Fri, 21 Dec 2012, Kai Tietz wrote: > 2012-12-21 Kai Tietz > > * config/os/mingw32/os_defines.h (_GLIBCXX_LLP64): Define if llp64 > abi is used. > * config/os/mingw32-w64/os_defines.h: Likewise. > * libsupc++/cxxabi.h (__base_class_type_info): Change > type __offset_flags to intptr_t. Don't you want to make it a ptrdiff_t directly and remove the later cast? > * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define proper > for llp64 abi. > (EMERGENCY_OBJ_COUNT): Likewise. > (bitmask_type): Likewise. > * ibsupc++/hash_bytes.cc (_Hash_bytes): Handle llp64. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 8:00 [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes Kai Tietz 2012-12-21 9:12 ` Marc Glisse @ 2012-12-21 9:13 ` Paolo Carlini 2012-12-21 9:16 ` Kai Tietz 2012-12-21 14:59 ` Gabriel Dos Reis 2 siblings, 1 reply; 15+ messages in thread From: Paolo Carlini @ 2012-12-21 9:13 UTC (permalink / raw) To: Kai Tietz; +Cc: GCC Patches, libstdc++ Hi, On 12/21/2012 08:59 AM, Kai Tietz wrote: > Index: libsupc++/cxxabi.h > =================================================================== > --- libsupc++/cxxabi.h (Revision 194655) > +++ libsupc++/cxxabi.h (Arbeitskopie) > @@ -356,7 +356,7 @@ namespace __cxxabiv1 > { > public: > const __class_type_info* __base_type; // Base class type. > - long __offset_flags; // Offset and info. > + intptr_t __offset_flags; // Offset and info. I don't think this is a safe change, in the sense that intptr_t is in general only available on targets providing the C99 stdint.h. Paolo. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:13 ` Paolo Carlini @ 2012-12-21 9:16 ` Kai Tietz 2012-12-21 9:32 ` Paolo Carlini 0 siblings, 1 reply; 15+ messages in thread From: Kai Tietz @ 2012-12-21 9:16 UTC (permalink / raw) To: Paolo Carlini; +Cc: GCC Patches, libstdc++ 2012/12/21 Paolo Carlini <paolo.carlini@oracle.com>: > Hi, > > > On 12/21/2012 08:59 AM, Kai Tietz wrote: >> >> Index: libsupc++/cxxabi.h >> =================================================================== >> --- libsupc++/cxxabi.h (Revision 194655) >> +++ libsupc++/cxxabi.h (Arbeitskopie) >> @@ -356,7 +356,7 @@ namespace __cxxabiv1 >> { >> public: >> const __class_type_info* __base_type; // Base class type. >> - long __offset_flags; // Offset and info. >> + intptr_t __offset_flags; // Offset and info. > > I don't think this is a safe change, in the sense that intptr_t is in > general only available on targets providing the C99 stdint.h. > > Paolo. Well, I thought it is always present for gcc due gstdint.h header, but well, using ptrdiff_t here instead would be ok too IMHO, and later is compatible to none C99-systems. Ok, with that change (and remove of later cast to ptrdiff_t for it)? Kai ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:16 ` Kai Tietz @ 2012-12-21 9:32 ` Paolo Carlini 2012-12-21 9:36 ` Kai Tietz 0 siblings, 1 reply; 15+ messages in thread From: Paolo Carlini @ 2012-12-21 9:32 UTC (permalink / raw) To: Kai Tietz; +Cc: GCC Patches, libstdc++ Hi, On 12/21/2012 10:16 AM, Kai Tietz wrote: > Well, I thought it is always present for gcc due gstdint.h header, As far as I know, that project isn't finished yet, there are still targets which neither provide the header, neither GCC synthetizes it. See also "dg-require-effective-target stdint_types". > but well, using ptrdiff_t here instead would be ok too IMHO, and later > is compatible to none C99-systems. Ok, with that change (and remove of > later cast to ptrdiff_t for it)? Are we 100% sure that, besides the targets we know well and love, elsewhere long is always == ptrdiff_t? Paolo. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:32 ` Paolo Carlini @ 2012-12-21 9:36 ` Kai Tietz 2012-12-21 9:39 ` Paolo Carlini 0 siblings, 1 reply; 15+ messages in thread From: Kai Tietz @ 2012-12-21 9:36 UTC (permalink / raw) To: Paolo Carlini; +Cc: GCC Patches, libstdc++ 2012/12/21 Paolo Carlini <paolo.carlini@oracle.com>: > Hi, > > > On 12/21/2012 10:16 AM, Kai Tietz wrote: >> >> Well, I thought it is always present for gcc due gstdint.h header, > > As far as I know, that project isn't finished yet, there are still targets > which neither provide the header, neither GCC synthetizes it. See also > "dg-require-effective-target stdint_types". > >> but well, using ptrdiff_t here instead would be ok too IMHO, and later is >> compatible to none C99-systems. Ok, with that change (and remove of later >> cast to ptrdiff_t for it)? > > Are we 100% sure that, besides the targets we know well and love, elsewhere > long is always == ptrdiff_t? > > Paolo. well, issue isn't that 'long' is always 'ptrdiff_t'. As this is indeed the wrong assumption here. As we treat here pointers later-one as pointer-diff, it doesn't make any difference, even if pointer-size might exceed 'ptrdiff_t' (well size_t would have here the same issue, and all in all we lack a longptr_t type-definition in standard), then we still don't change behavior AFAICS. Kai ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:36 ` Kai Tietz @ 2012-12-21 9:39 ` Paolo Carlini 2012-12-21 9:48 ` Kai Tietz 0 siblings, 1 reply; 15+ messages in thread From: Paolo Carlini @ 2012-12-21 9:39 UTC (permalink / raw) To: Kai Tietz; +Cc: GCC Patches, libstdc++ On 12/21/2012 10:36 AM, Kai Tietz wrote: > well, issue isn't that 'long' is always 'ptrdiff_t'. But then, if we just change the type without paying attention to size (and alignment) aren't we looking for BIG ABI trouble?!? Paolo. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:39 ` Paolo Carlini @ 2012-12-21 9:48 ` Kai Tietz 2012-12-21 9:59 ` Kai Tietz 2012-12-21 15:04 ` Gabriel Dos Reis 0 siblings, 2 replies; 15+ messages in thread From: Kai Tietz @ 2012-12-21 9:48 UTC (permalink / raw) To: Paolo Carlini; +Cc: GCC Patches, libstdc++ 2012/12/21 Paolo Carlini <paolo.carlini@oracle.com>: > On 12/21/2012 10:36 AM, Kai Tietz wrote: >> >> well, issue isn't that 'long' is always 'ptrdiff_t'. > > But then, if we just change the type without paying attention to size (and > alignment) aren't we looking for BIG ABI trouble?!? Huh? We have ABI-trouble due long is too small to hold a pointer-diff for llp64. Intended is here 'pointer-size' AFAICS in code, but with wrong assumption that a 'long' is always long enough. Btw I just checked all targets we have right now in gcc. The type ptrdiff_t is always either 'long', or 'int' (ilp32, lp64), and 'long long' for LLP64. Means ptrdiff_t gets always equal (or bigger) to biggest pointer-size for target (AFAICS). Kai ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:48 ` Kai Tietz @ 2012-12-21 9:59 ` Kai Tietz 2012-12-21 10:02 ` Paolo Carlini 2012-12-21 15:04 ` Gabriel Dos Reis 1 sibling, 1 reply; 15+ messages in thread From: Kai Tietz @ 2012-12-21 9:59 UTC (permalink / raw) To: Paolo Carlini; +Cc: GCC Patches, libstdc++ Hello, I changed type in __base_class_type_info to wide-enough type only for llp64 target. By this we have no (new) side-effects to other targets. ChangeLog 2012-12-21 Kai Tietz * config/os/mingw32/os_defines.h (_GLIBCXX_LLP64): Define if llp64 abi is used. * config/os/mingw32-w64/os_defines.h: Likewise. * libsupc++/cxxabi.h (__base_class_type_info): Adjust type of __offset_flags for llp64. * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define proper for llp64 abi. (EMERGENCY_OBJ_COUNT): Likewise. (bitmask_type): Likewise. * ibsupc++/hash_bytes.cc (_Hash_bytes): Handle llp64. Tested for i686-w64-mingw32, x86_64-w64-mingw32, and x86_64-unknown-linux-gnu. Ok for apply? Regards, Kai Index: config/os/mingw32/os_defines.h =================================================================== --- config/os/mingw32/os_defines.h (Revision 194655) +++ config/os/mingw32/os_defines.h (Arbeitskopie) @@ -72,4 +72,8 @@ #define _GLIBCXX_CDTOR_CALLABI __thiscall #endif +#ifdef __x86_64__ +#define _GLIBCXX_LLP64 1 #endif + +#endif Index: config/os/mingw32-w64/os_defines.h =================================================================== --- config/os/mingw32-w64/os_defines.h (Revision 194655) +++ config/os/mingw32-w64/os_defines.h (Arbeitskopie) @@ -74,4 +74,8 @@ #define _GLIBCXX_CDTOR_CALLABI __thiscall #endif +#ifdef __x86_64__ +#define _GLIBCXX_LLP64 1 #endif + +#endif Index: libsupc++/cxxabi.h =================================================================== --- libsupc++/cxxabi.h (Revision 194655) +++ libsupc++/cxxabi.h (Arbeitskopie) @@ -356,7 +356,11 @@ namespace __cxxabiv1 { public: const __class_type_info* __base_type; // Base class type. +#ifdef _GLIBCXX_LLP64 + long long __offset_flags; // Offset and info. +#else long __offset_flags; // Offset and info. +#endif enum __offset_flags_masks { Index: libsupc++/eh_alloc.cc =================================================================== --- libsupc++/eh_alloc.cc (Revision 194655) +++ libsupc++/eh_alloc.cc (Arbeitskopie) @@ -60,7 +60,7 @@ using namespace __cxxabiv1; #if INT_MAX == 32767 # define EMERGENCY_OBJ_SIZE 128 # define EMERGENCY_OBJ_COUNT 16 -#elif LONG_MAX == 2147483647 +#elif !defined (_GLIBCXX_LLP64) && LONG_MAX == 2147483647 # define EMERGENCY_OBJ_SIZE 512 # define EMERGENCY_OBJ_COUNT 32 #else @@ -76,8 +76,12 @@ using namespace __cxxabiv1; #if INT_MAX == 32767 || EMERGENCY_OBJ_COUNT <= 32 typedef unsigned int bitmask_type; #else +#if defined (_GLIBCXX_LLP64) +typedef unsigned long long bitmask_type; +#else typedef unsigned long bitmask_type; #endif +#endif typedef char one_buffer[EMERGENCY_OBJ_SIZE] __attribute__((aligned)); Index: libsupc++/hash_bytes.cc =================================================================== --- libsupc++/hash_bytes.cc (Revision 194655) +++ libsupc++/hash_bytes.cc (Arbeitskopie) @@ -128,7 +128,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION size_t _Hash_bytes(const void* ptr, size_t len, size_t seed) { - static const size_t mul = (0xc6a4a793UL << 32UL) + 0x5bd1e995UL; + static const size_t mul = (((size_t) 0xc6a4a793UL) << 32UL) + + (size_t) 0x5bd1e995UL; const char* const buf = static_cast<const char*>(ptr); // Remove the bytes not divisible by the sizeof(size_t). This Index: testsuite/18_support/50594.cc =================================================================== --- testsuite/18_support/50594.cc (Revision 194655) +++ testsuite/18_support/50594.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-fwhole-program" } +// { dg-options "-fwhole-program -static-libstdc++" { target *-*-mingw* } } // Copyright (C) 2011 Free Software Foundation // Index: testsuite/19_diagnostics/error_code/cons/1.cc =================================================================== --- testsuite/19_diagnostics/error_code/cons/1.cc (Revision 194655) +++ testsuite/19_diagnostics/error_code/cons/1.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // 2007-08-22 Benjamin Kosnik <bkoz@redhat.com> // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. Index: testsuite/19_diagnostics/error_code/operators/bool.cc =================================================================== --- testsuite/19_diagnostics/error_code/operators/bool.cc (Revision 194655) +++ testsuite/19_diagnostics/error_code/operators/bool.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // 2007-08-22 Benjamin Kosnik <bkoz@redhat.com> // Copyright (C) 2007, 2009 Free Software Foundation, Inc. Index: testsuite/19_diagnostics/error_code/operators/equal.cc =================================================================== --- testsuite/19_diagnostics/error_code/operators/equal.cc (Revision 194655) +++ testsuite/19_diagnostics/error_code/operators/equal.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // 2007-08-22 Benjamin Kosnik <bkoz@redhat.com> // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. Index: testsuite/19_diagnostics/error_code/operators/not_equal.cc =================================================================== --- testsuite/19_diagnostics/error_code/operators/not_equal.cc (Revision 194655) +++ testsuite/19_diagnostics/error_code/operators/not_equal.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // 2007-08-22 Benjamin Kosnik <bkoz@redhat.com> // Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc. Index: testsuite/19_diagnostics/error_condition/cons/1.cc =================================================================== --- testsuite/19_diagnostics/error_condition/cons/1.cc (Revision 194655) +++ testsuite/19_diagnostics/error_condition/cons/1.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-additional-options "-static-libstdc++" { target *-*-mingw* } } // Copyright (C) 2008, 2009 Free Software Foundation, Inc. // Index: testsuite/19_diagnostics/error_condition/operators/bool.cc =================================================================== --- testsuite/19_diagnostics/error_condition/operators/bool.cc (Revision 194655) +++ testsuite/19_diagnostics/error_condition/operators/bool.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // Copyright (C) 2008, 2009 Free Software Foundation, Inc. // Index: testsuite/19_diagnostics/error_condition/operators/equal.cc =================================================================== --- testsuite/19_diagnostics/error_condition/operators/equal.cc (Revision 194655) +++ testsuite/19_diagnostics/error_condition/operators/equal.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // Copyright (C) 2008, 2009 Free Software Foundation, Inc. // Index: testsuite/19_diagnostics/error_condition/operators/not_equal.cc =================================================================== --- testsuite/19_diagnostics/error_condition/operators/not_equal.cc (Revision 194655) +++ testsuite/19_diagnostics/error_condition/operators/not_equal.cc (Arbeitskopie) @@ -1,4 +1,5 @@ // { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++0x -static-libstdc++" { target *-*-mingw* } } // Copyright (C) 2008, 2009 Free Software Foundation, Inc. // ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:59 ` Kai Tietz @ 2012-12-21 10:02 ` Paolo Carlini 0 siblings, 0 replies; 15+ messages in thread From: Paolo Carlini @ 2012-12-21 10:02 UTC (permalink / raw) To: Kai Tietz; +Cc: GCC Patches, libstdc++ On 12/21/2012 10:59 AM, Kai Tietz wrote: > Hello, > > I changed type in __base_class_type_info to wide-enough type only for > llp64 target. > By this we have no (new) side-effects to other targets. Thanks. This is something I can approve at once. Paolo. ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 9:48 ` Kai Tietz 2012-12-21 9:59 ` Kai Tietz @ 2012-12-21 15:04 ` Gabriel Dos Reis 2012-12-21 15:54 ` Kai Tietz 1 sibling, 1 reply; 15+ messages in thread From: Gabriel Dos Reis @ 2012-12-21 15:04 UTC (permalink / raw) To: Kai Tietz; +Cc: Paolo Carlini, GCC Patches, libstdc++ On Fri, Dec 21, 2012 at 3:48 AM, Kai Tietz <ktietz70@googlemail.com> wrote: > 2012/12/21 Paolo Carlini <paolo.carlini@oracle.com>: >> On 12/21/2012 10:36 AM, Kai Tietz wrote: >>> >>> well, issue isn't that 'long' is always 'ptrdiff_t'. >> >> But then, if we just change the type without paying attention to size (and >> alignment) aren't we looking for BIG ABI trouble?!? > > Huh? We have ABI-trouble due long is too small to hold a > pointer-diff for llp64. Intended is here 'pointer-size' AFAICS in > code, but with wrong assumption that a 'long' is always long enough. > > Btw I just checked all targets we have right now in gcc. The type > ptrdiff_t is always either 'long', or 'int' (ilp32, lp64), and 'long > long' for LLP64. Means ptrdiff_t gets always equal (or bigger) to > biggest pointer-size for target (AFAICS). > > Kai We must write the codes so that their intents are clear, without requiring lot of reverse engineering every time one looks at them. If we intend offset, then clearly ptrdiff_t is the first choice. Solid reasons must be provided why it can't be ptrdiff_t and such reasons must be part of the code as comments explaining why the obvious thing should be discounted. - Gaby ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 15:04 ` Gabriel Dos Reis @ 2012-12-21 15:54 ` Kai Tietz 0 siblings, 0 replies; 15+ messages in thread From: Kai Tietz @ 2012-12-21 15:54 UTC (permalink / raw) To: Gabriel Dos Reis; +Cc: Paolo Carlini, GCC Patches, libstdc++ 2012/12/21 Gabriel Dos Reis <gdr@integrable-solutions.net>: > On Fri, Dec 21, 2012 at 3:48 AM, Kai Tietz <ktietz70@googlemail.com> wrote: >> 2012/12/21 Paolo Carlini <paolo.carlini@oracle.com>: >>> On 12/21/2012 10:36 AM, Kai Tietz wrote: >>>> >>>> well, issue isn't that 'long' is always 'ptrdiff_t'. >>> >>> But then, if we just change the type without paying attention to size (and >>> alignment) aren't we looking for BIG ABI trouble?!? >> >> Huh? We have ABI-trouble due long is too small to hold a >> pointer-diff for llp64. Intended is here 'pointer-size' AFAICS in >> code, but with wrong assumption that a 'long' is always long enough. >> >> Btw I just checked all targets we have right now in gcc. The type >> ptrdiff_t is always either 'long', or 'int' (ilp32, lp64), and 'long >> long' for LLP64. Means ptrdiff_t gets always equal (or bigger) to >> biggest pointer-size for target (AFAICS). >> >> Kai > > We must write the codes so that their intents are clear, without > requiring lot of reverse engineering every time one looks at them. If we > intend offset, then clearly ptrdiff_t is the first choice. Solid > reasons must be provided why it can't be ptrdiff_t and such > reasons must be part of the code as comments explaining why > the obvious thing should be discounted. > > - Gaby Agreed that we are using at some place too complex logic to avoid standard-types we already have ... We need to modify for cxxabi.h header-change also cp/rtti.c, as here the 'long' type-assumption is done, too. instead of using integer_type[itk_long/itk_long_long] there we then have to use instead ptrdiff_type_node. And this is for some targets a possible ABI-change due type_info-record might change size ... for 4.9 this change looks suitable to me, but for 4.8 we should simply check for now for itk_long/itk_long_long here (as done by other patch I've sent). Kai ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 8:00 [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes Kai Tietz 2012-12-21 9:12 ` Marc Glisse 2012-12-21 9:13 ` Paolo Carlini @ 2012-12-21 14:59 ` Gabriel Dos Reis 2 siblings, 0 replies; 15+ messages in thread From: Gabriel Dos Reis @ 2012-12-21 14:59 UTC (permalink / raw) To: Kai Tietz; +Cc: GCC Patches, libstdc++ On Fri, Dec 21, 2012 at 1:59 AM, Kai Tietz <ktietz70@googlemail.com> wrote: > Hello, > > this patch fixes some remaining issues with pointer-sizes for llp64 > abi in libstdc++. See comments below. > > ChangeLog > > 2012-12-21 Kai Tietz > > * config/os/mingw32/os_defines.h (_GLIBCXX_LLP64): Define if llp64 > abi is used. > * config/os/mingw32-w64/os_defines.h: Likewise. > * libsupc++/cxxabi.h (__base_class_type_info): Change > type __offset_flags to intptr_t. > * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define proper > for llp64 abi. > (EMERGENCY_OBJ_COUNT): Likewise. > (bitmask_type): Likewise. > * ibsupc++/hash_bytes.cc (_Hash_bytes): Handle llp64. > > Tested for i686-w64-mingw32, x86_64-w64-mingw32, and > x86_64-unknown-linux-gnu. Ok for apply? > > Regards, > Kai > > Index: config/os/mingw32/os_defines.h > =================================================================== > --- config/os/mingw32/os_defines.h (Revision 194655) > +++ config/os/mingw32/os_defines.h (Arbeitskopie) > @@ -72,4 +72,8 @@ > #define _GLIBCXX_CDTOR_CALLABI __thiscall > #endif > > +#ifdef __x86_64__ > +#define _GLIBCXX_LLP64 1 > #endif > + > +#endif > Index: config/os/mingw32-w64/os_defines.h > =================================================================== > --- config/os/mingw32-w64/os_defines.h (Revision 194655) > +++ config/os/mingw32-w64/os_defines.h (Arbeitskopie) > @@ -74,4 +74,8 @@ > #define _GLIBCXX_CDTOR_CALLABI __thiscall > #endif > > +#ifdef __x86_64__ > +#define _GLIBCXX_LLP64 1 > #endif > + > +#endif > Index: libsupc++/cxxabi.h > =================================================================== > --- libsupc++/cxxabi.h (Revision 194655) > +++ libsupc++/cxxabi.h (Arbeitskopie) > @@ -356,7 +356,7 @@ namespace __cxxabiv1 > { > public: > const __class_type_info* __base_type; // Base class type. > - long __offset_flags; // Offset and info. > + intptr_t __offset_flags; // Offset and info. this should use ptrdiff_t. > > enum __offset_flags_masks > { > Index: libsupc++/eh_alloc.cc > =================================================================== > --- libsupc++/eh_alloc.cc (Revision 194655) > +++ libsupc++/eh_alloc.cc (Arbeitskopie) > @@ -60,7 +60,7 @@ using namespace __cxxabiv1; > #if INT_MAX == 32767 > # define EMERGENCY_OBJ_SIZE 128 > # define EMERGENCY_OBJ_COUNT 16 > -#elif LONG_MAX == 2147483647 > +#elif !defined (_GLIBCXX_LLP64) && LONG_MAX == 2147483647 > # define EMERGENCY_OBJ_SIZE 512 > # define EMERGENCY_OBJ_COUNT 32 > #else > @@ -76,8 +76,12 @@ using namespace __cxxabiv1; > #if INT_MAX == 32767 || EMERGENCY_OBJ_COUNT <= 32 > typedef unsigned int bitmask_type; > #else > +#if defined (_GLIBCXX_LLP64) > +typedef unsigned long long bitmask_type; > +#else > typedef unsigned long bitmask_type; > #endif > +#endif Use size_t here > > > typedef char one_buffer[EMERGENCY_OBJ_SIZE] __attribute__((aligned)); > Index: libsupc++/hash_bytes.cc > =================================================================== > --- libsupc++/hash_bytes.cc (Revision 194655) > +++ libsupc++/hash_bytes.cc (Arbeitskopie) > @@ -128,7 +128,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > size_t > _Hash_bytes(const void* ptr, size_t len, size_t seed) > { > - static const size_t mul = (0xc6a4a793UL << 32UL) + 0x5bd1e995UL; > + static const size_t mul = (((size_t) 0xc6a4a793UL) << 32UL) > + + (size_t) 0x5bd1e995UL; > const char* const buf = static_cast<const char*>(ptr); > > // Remove the bytes not divisible by the sizeof(size_t). This ^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes
@ 2012-12-21 10:13 Uros Bizjak
2012-12-21 10:16 ` Kai Tietz
0 siblings, 1 reply; 15+ messages in thread
From: Uros Bizjak @ 2012-12-21 10:13 UTC (permalink / raw)
To: gcc-patches; +Cc: libstdc++, Paolo Carlini, Kai Tietz
Hello!
> 2012-12-21 Kai Tietz
>
> * config/os/mingw32/os_defines.h (_GLIBCXX_LLP64): Define if llp64
> abi is used.
> * config/os/mingw32-w64/os_defines.h: Likewise.
> * libsupc++/cxxabi.h (__base_class_type_info): Adjust
> type of __offset_flags for llp64.
> * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define proper
> for llp64 abi.
> (EMERGENCY_OBJ_COUNT): Likewise.
> (bitmask_type): Likewise.
> * ibsupc++/hash_bytes.cc (_Hash_bytes): Handle llp64.
// { dg-options "-fwhole-program" }
+// { dg-options "-fwhole-program -static-libstdc++" { target *-*-mingw* } }
Please use dg-additional-options in these cases.
Uros.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes 2012-12-21 10:13 Uros Bizjak @ 2012-12-21 10:16 ` Kai Tietz 0 siblings, 0 replies; 15+ messages in thread From: Kai Tietz @ 2012-12-21 10:16 UTC (permalink / raw) To: Uros Bizjak; +Cc: gcc-patches, libstdc++, Paolo Carlini 2012/12/21 Uros Bizjak <ubizjak@gmail.com>: > Hello! > >> 2012-12-21 Kai Tietz >> >> * config/os/mingw32/os_defines.h (_GLIBCXX_LLP64): Define if llp64 >> abi is used. >> * config/os/mingw32-w64/os_defines.h: Likewise. >> * libsupc++/cxxabi.h (__base_class_type_info): Adjust >> type of __offset_flags for llp64. >> * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define proper >> for llp64 abi. >> (EMERGENCY_OBJ_COUNT): Likewise. >> (bitmask_type): Likewise. >> * ibsupc++/hash_bytes.cc (_Hash_bytes): Handle llp64. > > // { dg-options "-fwhole-program" } > +// { dg-options "-fwhole-program -static-libstdc++" { target *-*-mingw* } } > > Please use dg-additional-options in these cases. I tried, but it doesn't seems to be supported by libstdc++'s testsuite. Kai PS: Sorry, testsuite cases I wanted sent separately, as I am still going through it to adjust static-linking. ^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2012-12-21 15:54 UTC | newest] Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-12-21 8:00 [patch libstdc++]: Fix LLP64 pointer-size issues for cxxabi, eh_alloc, and hash_bytes Kai Tietz 2012-12-21 9:12 ` Marc Glisse 2012-12-21 9:13 ` Paolo Carlini 2012-12-21 9:16 ` Kai Tietz 2012-12-21 9:32 ` Paolo Carlini 2012-12-21 9:36 ` Kai Tietz 2012-12-21 9:39 ` Paolo Carlini 2012-12-21 9:48 ` Kai Tietz 2012-12-21 9:59 ` Kai Tietz 2012-12-21 10:02 ` Paolo Carlini 2012-12-21 15:04 ` Gabriel Dos Reis 2012-12-21 15:54 ` Kai Tietz 2012-12-21 14:59 ` Gabriel Dos Reis 2012-12-21 10:13 Uros Bizjak 2012-12-21 10:16 ` Kai Tietz
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).