From 0f0b2faf47c360bc60e429fb7b558c25aabc99eb Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Sun, 4 Feb 2001 08:37:50 +0000 Subject: [PATCH] typeinfo (__GXX_MERGED_TYPEINFO_NAMES): New macro. * libsupc++/typeinfo (__GXX_MERGED_TYPEINFO_NAMES): New macro. * libsupc++/tinfo.cc (std::typeinfo::operator==): Use strcmp whenever !__GXX_MERGED_TYPEINFO_NAMES. * libsupc++/tinfo2.cc (std::typeinfo::before): Likewise. From-SVN: r39438 --- libstdc++-v3/ChangeLog | 7 +++++++ libstdc++-v3/libsupc++/tinfo.cc | 18 ++++++++++------- libstdc++-v3/libsupc++/tinfo2.cc | 9 +++++++-- libstdc++-v3/libsupc++/typeinfo | 34 ++++++++++++++++++++++---------- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 43b1cf9f467..f0c035acfc3 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2001-02-04 Mark Mitchell + + * libsupc++/typeinfo (__GXX_MERGED_TYPEINFO_NAMES): New macro. + * libsupc++/tinfo.cc (std::typeinfo::operator==): Use strcmp + whenever !__GXX_MERGED_TYPEINFO_NAMES. + * libsupc++/tinfo2.cc (std::typeinfo::before): Likewise. + 2001-02-03 Alexandre Oliva Gerald Pfeifer diff --git a/libstdc++-v3/libsupc++/tinfo.cc b/libstdc++-v3/libsupc++/tinfo.cc index 523f5b8653c..fefc815e759 100644 --- a/libstdc++-v3/libsupc++/tinfo.cc +++ b/libstdc++-v3/libsupc++/tinfo.cc @@ -41,6 +41,17 @@ std::type_info:: ~type_info () { } +#if !__GXX_MERGED_TYPEINFO_NAMES + +// We can't rely on common symbols being shared between shared objects. +bool std::type_info:: +operator== (const std::type_info& arg) const +{ + return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) == 0); +} + +#endif + #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 // original (old) abi @@ -64,13 +75,6 @@ convert_to_base (void *addr, bool is_virtual, myint32 offset) } -// We can't rely on common symbols being shared between shared objects. -bool std::type_info:: -operator== (const std::type_info& arg) const -{ - return (&arg == this) || (__builtin_strcmp (name (), arg.name ()) == 0); -} - extern "C" void __rtti_class (void *addr, const char *name, const __class_type_info::base_info *bl, std::size_t bn) diff --git a/libstdc++-v3/libsupc++/tinfo2.cc b/libstdc++-v3/libsupc++/tinfo2.cc index bbcbda79dc5..53e0fdf2784 100644 --- a/libstdc++-v3/libsupc++/tinfo2.cc +++ b/libstdc++-v3/libsupc++/tinfo2.cc @@ -1,5 +1,5 @@ // Methods for type_info for -*- C++ -*- Run Time Type Identification. -// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000 Free Software Foundation +// Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation // This file is part of GNU CC. @@ -36,13 +36,18 @@ extern "C" void abort (); using std::type_info; -#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 +#if !__GXX_MERGED_TYPEINFO_NAMES + bool type_info::before (const type_info &arg) const { return __builtin_strcmp (name (), arg.name ()) < 0; } +#endif + +#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 + // type info for pointer type. struct __pointer_type_info : public type_info { diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo index 092963c524f..949c6d81e2f 100644 --- a/libstdc++-v3/libsupc++/typeinfo +++ b/libstdc++-v3/libsupc++/typeinfo @@ -48,6 +48,19 @@ namespace __cxxabiv1 } // namespace __cxxabiv1 #endif + +#if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 + // In the old ABI, typeinfo name strings were not merged. + #define __GXX_MERGED_TYPEINFO_NAMES 0 +#elif !__GXX_WEAK__ + // If weak symbols are not supported, they are still not merged. + #define __GXX_MERGED_TYPEINFO_NAMES 0 +#else + // In the new ABI, on platforms that support weak symbols, they are + // merged. + #define __GXX_MERGED_TYPEINFO_NAMES 1 +#endif + namespace std { class type_info @@ -73,28 +86,29 @@ namespace std public: // the public interface #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100 - // In old abi, there can be multiple instances of a type_info - // object for one type. Uniqueness must use the _name value, not - // object address. - bool before(const type_info& arg) const; const char* name() const { return __name; } - bool operator==(const type_info& __arg) const; - bool operator!=(const type_info& __arg) const - { return !operator==(__arg); } +#else + const char* name() const + { return __name; } +#endif +#if !__GXX_MERGED_TYPEINFO_NAMES + bool before(const type_info& arg) const; + // In old abi, or when weak symbols are not supported, there can + // be multiple instances of a type_info object for one + // type. Uniqueness must use the _name value, not object address. + bool operator==(const type_info& __arg) const; #else // In new abi we can rely on type_info's NTBS being unique, // and therefore address comparisons are sufficient. bool before(const type_info& __arg) const { return __name < __arg.__name; } - const char* name() const - { return __name; } bool operator==(const type_info& __arg) const { return __name == __arg.__name; } +#endif bool operator!=(const type_info& __arg) const { return !operator==(__arg); } -#endif // the internal interface #if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100