abi_check.cc (hash<string>): Specialize.
authorBenjamin Kosnik <bkoz@redhat.com>
Sun, 13 Oct 2002 04:46:58 +0000 (04:46 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Sun, 13 Oct 2002 04:46:58 +0000 (04:46 +0000)
2002-10-12  Benjamin Kosnik  <bkoz@redhat.com>

* testsuite/abi_check.cc (hash<string>): Specialize.
Simplify. Check compatible symbol versions.
* config/linker-map.gnu: Clarify, explicitly export
std::codecvt::c* symbols.

* testsuite/22_locale/static_members.cc (test02): Avoid null strings.

From-SVN: r58091

libstdc++-v3/ChangeLog
libstdc++-v3/config/linker-map.gnu
libstdc++-v3/testsuite/22_locale/static_members.cc
libstdc++-v3/testsuite/abi_check.cc

index e6b8cf3c5dd649849a249ce8900a7515b34c9d1d..94d81077b04ce8ae2db63a1c35ccbcc052a48f43 100644 (file)
@@ -1,3 +1,12 @@
+2002-10-12  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * testsuite/abi_check.cc (hash<string>): Specialize.
+       Simplify. Check compatible symbol versions.
+       * config/linker-map.gnu: Clarify, explicitly export
+       std::codecvt::c* symbols.
+
+       * testsuite/22_locale/static_members.cc (test02): Avoid null strings.
+
 2002-10-12  Jonathan Wakely  <jw@kayari.org>
             Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
index a43ab2cc0c5ad39679e3749f2d1eddfdef4d955a..0896c9ff1ab687335ae7e5160f2dc2f9e1cc5583 100644 (file)
@@ -28,17 +28,27 @@ GLIBCPP_3.2 {
     # All but the last are terminated with a semicolon.
     extern "C++"
     {
-      std::[A-Za-k]*;
+      std::[A-Za-b]*;
+      std::c[a-n]*;
+      std::co[a-c]*;
+      std::codecvt_byname*;
+      std::codecvt::[A-Za-b]*;
+      std::codecvt::[A-Zd-z]*;
+      std::codecvt_c;
+      std::codecvt_w;
+      std::co[e-z]*;
+      std::c[p-z]*;
+      std::c_[a-z]*;
+      std::[A-Zd-k]*;
       std::length_error*;
       std::logic_error*;
       std::locale::[A-Za-z]*;
-      std::locale::_Impl*;
+      std::locale::_[A-Ra-z]*;
       std::locale::_S_classic;
       std::locale::_S_global;
       std::locale::_S_num_categories;
-      std::locale::facet*;
-      std::locale::id*;
-      std::locale::locale*;
+      std::locale::_S_normalize_category*;
+      std::locale::_[T-Za-z]*;
       std::[A-Zm-z]*;
       std::__throw_*;
       std::__basic_file*;
@@ -53,10 +63,32 @@ GLIBCPP_3.2 {
 
     # Names not in an 'extern' block are mangled names.
 
-    _ZNSt6localeC1E*;
-    _ZNSt6locale11_M_coalesceERKS_S1_j;
-    _ZNSt6locale21_S_normalize_categoryEj;
+    # std::locale destructors
     _ZNSt6localeD*;
+        
+    # std::codecvt<char> members.
+    _ZNKSt7codecvtIcc11__mbstate_tE*;
+    # std::codecvt<char>::~codecvt
+    _ZNSt7codecvtIcc11__mbstate_tED*;
+    # std::codecvt<char>::codecvt default
+    _ZNSt7codecvtIcc11__mbstate_tEC1Ej;
+    _ZNSt7codecvtIcc11__mbstate_tEC2Ej;
+    # std::codecvt<char>::id
+    _ZNSt7codecvtIcc11__mbstate_tE2idE;
+
+    # std::codecvt<wchar_t> members.
+    _ZNKSt7codecvtIwc11__mbstate_tE*;
+    # std::codecvt<wchar_t>::~codecvt
+    _ZNSt7codecvtIwc11__mbstate_tED*;
+    # std::codecvt<wchar_t>::codecvt default
+    _ZNSt7codecvtIwc11__mbstate_tEC1Ej;
+    _ZNSt7codecvtIwc11__mbstate_tEC2Ej;
+    # std::codecvt<wchar_t>::id
+    _ZNSt7codecvtIwc11__mbstate_tE2idE;
+
+     # std::use_facet<codecvt>
+    _ZSt9use_facetISt7codecvtIcc11__mbstate_tEERKT_RKSt6locale;
+    _ZSt9use_facetISt7codecvtIwc11__mbstate_tEERKT_RKSt6locale;
 
     # std::has_facet*
     _ZSt9has_facet*;
index 06cd831c482cebc94b3fff6505be5c835e23931c..dd020340b7616d3bc2ab8fedcbbef86fd557c84d 100644 (file)
@@ -74,7 +74,6 @@ void test02()
   const locale loc_mx(mx.c_str());
 
   // Get underlying current locale and environment settings.
-  const string lc_all_orig = std::setlocale(LC_ALL, NULL);
   const locale env_orig("");
 
   // setlocale to en_PH
@@ -84,8 +83,9 @@ void test02()
   VERIFY( loc_env == env_orig );
 
   locale global_orig = locale::global(loc_mx);
-  string lc_all_mx = std::setlocale(LC_ALL, NULL);
-  VERIFY( lc_all_mx == mx.c_str() );
+  const char* lc_all_mx = std::setlocale(LC_ALL, NULL);
+  if (lc_all_mx)
+    VERIFY( mx == lc_all_mx );
 
   // Restore global settings.
   locale::global(global_orig);
index 1e407811437a3cf479f2f2e40d0ba046d4b53e53..4018cd5377ee956c36aad2c7eed88662ca562b9e 100644 (file)
@@ -46,17 +46,35 @@ struct symbol_info
   enum category { none, function, object, error };
   category     type;
   std::string  name;
-  std::string  name_demangled;
-  std::string  version;
+  std::string  demangled_name;
   int          size;
+  std::string  version_name;
 
   symbol_info() : type(none), size(0) { }
 
   symbol_info(const symbol_info& other) 
-  : type(other.type), name(other.name), name_demangled(other.name_demangled), 
-  version(other.version), size(other.size) { }
+  : type(other.type), name(other.name), demangled_name(other.demangled_name), 
+   size(other.size), version_name(other.version_name) { }
 };
 
+namespace __gnu_cxx
+{
+  using namespace std;
+
+  template<> 
+    struct hash<string>
+    {
+      size_t operator()(const string& s) const 
+      { 
+       const collate<char>& c = use_facet<collate<char> >(locale::classic());
+       return c.hash(s.c_str(), s.c_str() + s.size());
+      }
+    }; 
+}
+
+typedef std::deque<std::string>                                symbol_names;
+typedef __gnu_cxx::hash_map<std::string, symbol_info>  symbol_infos;
+
 bool 
 check_compatible(const symbol_info& lhs, const symbol_info& rhs, 
                 bool verbose = false)
@@ -93,8 +111,7 @@ check_compatible(const symbol_info& lhs, const symbol_info& rhs,
        }
     }
 
-  // Expect something more sophisticated eventually.
-  if (lhs.version != rhs.version)
+  if (lhs.version_name != rhs.version_name)
     {
       ret = false;
       if (verbose)
@@ -106,19 +123,6 @@ check_compatible(const symbol_info& lhs, const symbol_info& rhs,
   return ret;
 }
 
-template<typename _CharT, typename _Traits>
-  std::basic_ostream<_CharT, _Traits>&
-  operator<<(std::basic_ostream<_CharT, _Traits>& os, symbol_info& si)
-  {
-    using namespace std;
-    os << si.type << endl;
-    os << si.name << endl;
-    os << si.name_demangled << endl;
-    os << si.version << endl;
-    os << si.size << endl;
-    return os;
-  }
 const char*
 demangle(const std::string& mangled)
 {
@@ -203,7 +207,7 @@ line_to_symbol_info(std::string& input, symbol_info& output)
       input.erase(input.begin(), input.begin() + n + 1);
 
       // Set version name.
-      output.version = input;
+      output.version_name = input;
     }
   else
     {
@@ -213,12 +217,9 @@ line_to_symbol_info(std::string& input, symbol_info& output)
     }
 
   // Set the demangled name.
-  output.name_demangled = demangle(output.name);
+  output.demangled_name = demangle(output.name);
 }
 
-typedef std::deque<std::string>                                symbol_names;
-typedef __gnu_cxx::hash_map<const char*, symbol_info>  symbol_infos;
-
 void
 create_symbol_data(const char* file, symbol_infos& symbols, 
                   symbol_names& names)
@@ -238,7 +239,7 @@ create_symbol_data(const char* file, symbol_infos& symbols,
        {
          symbol_info symbol;
          line_to_symbol_info(line, symbol);
-         symbols[symbol.name.c_str()] = symbol;
+         symbols[symbol.name] = symbol;
          names.push_back(symbol.name);
          line = empty;
        }
@@ -256,7 +257,7 @@ report_symbol_info(const symbol_info& symbol, std::size_t n)
 
   // Add any other information to display here.
   cout << tab << "demangled symbol"<< endl;
-  cout << tab << symbol.name_demangled << endl;
+  cout << tab << symbol.demangled_name << endl;
 
   cout << endl;
 }
@@ -279,10 +280,10 @@ main(int argc, char** argv)
       exit(1);
     }
 
+
+  // Quick sanity/setup check for arguments.
   const char* test_file = argv[2];
   const char* baseline_file = argv[3];
-
-  // Quick sanity/setup check
   if (access(test_file, R_OK) != 0)
     {
       cerr << "Cannot read symbols file " << test_file
@@ -303,7 +304,7 @@ main(int argc, char** argv)
   create_symbol_data(baseline_file, baseline_symbols, baseline_names);
   create_symbol_data(test_file, test_symbols, test_names);
 
-  // More sanity checking.
+  //  Sanity check results.
   const symbol_names::size_type baseline_size = baseline_names.size();
   const symbol_names::size_type test_size = test_names.size();
   if (!baseline_size || !test_size)
@@ -315,53 +316,71 @@ main(int argc, char** argv)
   // Sort out names.
   // Assuming baseline_names, test_names are both unique w/ no duplicates.
   //
-  // The pairs of names in shared_names are needed to do lookups on
-  // the hash tables of common symbols to do compares.
-  //
   // The names added to missing_names are baseline_names not found in
   // test_names 
   // -> symbols that have been deleted.
   //
-  // The names left in test_names are names not in baseline_names
+  // The names added to added_names are test_names are names not in
+  // baseline_names
   // -> symbols that have been added.
-  typedef pair<string, string> string_pair;
-  vector<string_pair> shared_names;
+  symbol_names shared_names;
   symbol_names missing_names;
+  symbol_names added_names = test_names;
   for (size_t i = 0; i < baseline_size; ++i)
     {
-      symbol_names::iterator end = test_names.end();
-      symbol_names::iterator it = find(test_names.begin(), end, 
-                                      baseline_names[i]);
+      string what(baseline_names[i]);
+      symbol_names::iterator end = added_names.end();
+      symbol_names::iterator it = find(added_names.begin(), end, what);
       if (it != end)
        {
          // Found.
-         shared_names.push_back(string_pair(baseline_names[i], *it));
-         test_names.erase(it);
+         shared_names.push_back(what);
+         added_names.erase(it);
        }
       else
-       missing_names.push_back(baseline_names[i]);
+       missing_names.push_back(what);
     }
 
-  // Check common names for detailed compatibility.
-  const vector<string_pair>::size_type shared_size = shared_names.size();
+  // Check shared names for compatibility.
   typedef pair<symbol_info, symbol_info> symbol_pair;
   vector<symbol_pair> incompatible;
-  for (size_t i = 0; i < shared_size; ++i)
+  for (size_t i = 0; i < shared_names.size(); ++i)
     {
-      symbol_info base = baseline_symbols[shared_names[i].first.c_str()];
-      symbol_info test = test_symbols[shared_names[i].second.c_str()];
+      symbol_info base = baseline_symbols[shared_names[i]];
+      symbol_info test = test_symbols[shared_names[i]];
       if (!check_compatible(base, test))
        incompatible.push_back(symbol_pair(base, test));
     }
 
+  // Check added names for compatibility.
+  for (size_t i = 0; i < added_names.size(); ++i)
+    {
+      vector<string> compatible_versions;
+      compatible_versions.push_back("GLIBCPP_3.2.1");
+
+      symbol_info test = test_symbols[added_names[i]];
+      vector<string>::iterator end = compatible_versions.end();
+
+      // Check version names for compatibility...
+      vector<string>::iterator it1 = find(compatible_versions.begin(), end, 
+                                         test.version_name);
+
+      // Check for weak label.
+      vector<string>::iterator it2 = find(compatible_versions.begin(), end, 
+                                         test.name);
+
+      if (it1 == end && it2 == end)
+       incompatible.push_back(symbol_pair(test, test));
+    }
+
   // Report results.
-  cout << test_names.size() << " added symbols " << endl;
-  for (size_t j = 0; j < test_names.size() ; ++j)
-    report_symbol_info(test_symbols[test_names[j].c_str()], j + 1);
+  cout << added_names.size() << " added symbols " << endl;
+  for (size_t j = 0; j < added_names.size() ; ++j)
+    report_symbol_info(test_symbols[added_names[j]], j + 1);
 
   cout << missing_names.size() << " missing symbols " << endl;
   for (size_t j = 0; j < missing_names.size() ; ++j)
-    report_symbol_info(baseline_symbols[missing_names[j].c_str()], j + 1);
+    report_symbol_info(baseline_symbols[missing_names[j]], j + 1);
 
   cout << incompatible.size() << " incompatible symbols " << endl;
   for (size_t j = 0; j < incompatible.size() ; ++j)