This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[libstdc++][patch] Move __stl_prime_list out of a header file


The attached patch moves __stl_prime_list out of the
include/backward/hashtable.h header and into a  new .cc file that is
linked in libstdc++. This reduces code size since now there is only of
copy of __stl_prime_list.

Bootstrapped and regression tested. OK for trunk?

2009-05-20  Rafael Avila de Espindola  <espindola@google.com>

	* config/abi/pre/gnu.ver: Add _ZN9__gnu_cxx16__stl_prime_listE.
	* include/backward/hashtable.h: Make __stl_prime_list extern.
	* src/Makefile.am (sources): Add hash_primes.cc.
	* src/Makefile.in: Regenerate.
	* src/hash_primes.cc: New.

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index 57183c1..33cd691 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -838,6 +838,7 @@ GLIBCXX_3.4.10 {
     
     _ZNSt8__detail12__prime_listE;
     _ZNSt3tr18__detail12__prime_listE;
+    _ZN9__gnu_cxx16__stl_prime_listE;
 
     # for parallel mode
     _ZN14__gnu_parallel9_Settings3getEv;
diff --git a/libstdc++-v3/include/backward/hashtable.h b/libstdc++-v3/include/backward/hashtable.h
index ca04c76..2ea12e3 100644
--- a/libstdc++-v3/include/backward/hashtable.h
+++ b/libstdc++-v3/include/backward/hashtable.h
@@ -207,15 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
   // Note: assumes long is at least 32 bits.
   enum { _S_num_primes = 29 };
 
-  static const unsigned long __stl_prime_list[_S_num_primes] =
-    {
-      5ul,          53ul,         97ul,         193ul,       389ul,
-      769ul,        1543ul,       3079ul,       6151ul,      12289ul,
-      24593ul,      49157ul,      98317ul,      196613ul,    393241ul,
-      786433ul,     1572869ul,    3145739ul,    6291469ul,   12582917ul,
-      25165843ul,   50331653ul,   100663319ul,  201326611ul, 402653189ul,
-      805306457ul,  1610612741ul, 3221225473ul, 4294967291ul
-    };
+  extern const unsigned long __stl_prime_list[_S_num_primes];
 
   inline unsigned long
   __stl_next_prime(unsigned long __n)
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index d218cea..00027c9 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -148,6 +148,7 @@ sources = \
 	hash_c++0x.cc \
 	globals_io.cc \
 	hashtable.cc \
+	hash_primes.cc \
 	hashtable_c++0x.cc \
 	ios.cc \
 	ios_failure.cc \
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index 9ee5275..fa92ace 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -76,16 +76,16 @@ am__DEPENDENCIES_1 =
 am__libstdc___la_SOURCES_DIST = atomic.cc bitmap_allocator.cc \
 	pool_allocator.cc mt_allocator.cc codecvt.cc compatibility.cc \
 	complex_io.cc ctype.cc debug.cc functexcept.cc hash.cc \
-	hash_c++0x.cc globals_io.cc hashtable.cc hashtable_c++0x.cc \
-	ios.cc ios_failure.cc ios_init.cc ios_locale.cc limits.cc \
-	limits_c++0x.cc list.cc debug_list.cc locale.cc locale_init.cc \
-	locale_facets.cc localename.cc math_stubs_float.cc \
-	math_stubs_long_double.cc stdexcept.cc strstream.cc \
-	system_error.cc tree.cc allocator-inst.cc concept-inst.cc \
-	fstream-inst.cc ext-inst.cc ios-inst.cc iostream-inst.cc \
-	istream-inst.cc istream.cc locale-inst.cc misc-inst.cc \
-	ostream-inst.cc sstream-inst.cc streambuf-inst.cc streambuf.cc \
-	string-inst.cc valarray-inst.cc wlocale-inst.cc \
+	hash_c++0x.cc globals_io.cc hashtable.cc hash_primes.cc \
+	hashtable_c++0x.cc ios.cc ios_failure.cc ios_init.cc \
+	ios_locale.cc limits.cc limits_c++0x.cc list.cc debug_list.cc \
+	locale.cc locale_init.cc locale_facets.cc localename.cc \
+	math_stubs_float.cc math_stubs_long_double.cc stdexcept.cc \
+	strstream.cc system_error.cc tree.cc allocator-inst.cc \
+	concept-inst.cc fstream-inst.cc ext-inst.cc ios-inst.cc \
+	iostream-inst.cc istream-inst.cc istream.cc locale-inst.cc \
+	misc-inst.cc ostream-inst.cc sstream-inst.cc streambuf-inst.cc \
+	streambuf.cc string-inst.cc valarray-inst.cc wlocale-inst.cc \
 	wstring-inst.cc mutex.cc condition_variable.cc chrono.cc \
 	thread.cc atomicity.cc codecvt_members.cc collate_members.cc \
 	ctype_members.cc messages_members.cc monetary_members.cc \
@@ -102,8 +102,8 @@ am__objects_4 = basic_file.lo c++locale.lo $(am__objects_2) \
 am__objects_5 = atomic.lo bitmap_allocator.lo pool_allocator.lo \
 	mt_allocator.lo codecvt.lo compatibility.lo complex_io.lo \
 	ctype.lo debug.lo functexcept.lo hash.lo hash_c++0x.lo \
-	globals_io.lo hashtable.lo hashtable_c++0x.lo ios.lo \
-	ios_failure.lo ios_init.lo ios_locale.lo limits.lo \
+	globals_io.lo hashtable.lo hash_primes.lo hashtable_c++0x.lo \
+	ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo \
 	limits_c++0x.lo list.lo debug_list.lo locale.lo locale_init.lo \
 	locale_facets.lo localename.lo math_stubs_float.lo \
 	math_stubs_long_double.lo stdexcept.lo strstream.lo \
@@ -400,6 +400,7 @@ sources = \
 	hash_c++0x.cc \
 	globals_io.cc \
 	hashtable.cc \
+	hash_primes.cc \
 	hashtable_c++0x.cc \
 	ios.cc \
 	ios_failure.cc \
diff --git a/libstdc++-v3/src/hash_primes.cc b/libstdc++-v3/src/hash_primes.cc
new file mode 100644
index 0000000..c88081c
--- /dev/null
+++ b/libstdc++-v3/src/hash_primes.cc
@@ -0,0 +1,66 @@
+// Hashtable implementation used by containers -*- C++ -*-
+
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+// Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// <http://www.gnu.org/licenses/>.
+
+/*
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.  Silicon Graphics makes no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ *
+ * Copyright (c) 1994
+ * Hewlett-Packard Company
+ *
+ * Permission to use, copy, modify, distribute and sell this software
+ * and its documentation for any purpose is hereby granted without fee,
+ * provided that the above copyright notice appear in all copies and
+ * that both that copyright notice and this permission notice appear
+ * in supporting documentation.  Hewlett-Packard Company makes no
+ * representations about the suitability of this software for any
+ * purpose.  It is provided "as is" without express or implied warranty.
+ *
+ */
+
+#include <backward/hashtable.h>
+
+_GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
+
+extern const unsigned long __stl_prime_list[_S_num_primes] =
+    {
+      5ul,          53ul,         97ul,         193ul,       389ul,
+      769ul,        1543ul,       3079ul,       6151ul,      12289ul,
+      24593ul,      49157ul,      98317ul,      196613ul,    393241ul,
+      786433ul,     1572869ul,    3145739ul,    6291469ul,   12582917ul,
+      25165843ul,   50331653ul,   100663319ul,  201326611ul, 402653189ul,
+      805306457ul,  1610612741ul, 3221225473ul, 4294967291ul
+    };
+
+_GLIBCXX_END_NAMESPACE

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]