Patchwork [gccgo] Make sure go-system.h is always included first

login
register
mail settings
Submitter Ian Taylor
Date Nov. 17, 2010, 3:52 a.m.
Message ID <mcrzkt81uak.fsf@google.com>
Download mbox | patch
Permalink /patch/71508/
State New
Headers show

Comments

Ian Taylor - Nov. 17, 2010, 3:52 a.m.
This gccgo patch makes sure that go-system.h is always the first header
file included.  go-system.h in turn includes config.h first, so this
ensure that config.h always comes before anything else, as required for
large file support.  In order to do this, I added includes of <list> and
<algorithm> to go-system.h.  I also realized that there is one use of
unordered_set in the frontend, so I handles that like unordered_map.
Committed to gccgo branch.

Ian

Patch

diff -r b8dc08fdaf6b go/export.cc
--- a/go/export.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/export.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -4,8 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <algorithm>
-
 #include "go-system.h"
 #include "sha1.h"
 
diff -r b8dc08fdaf6b go/go.cc
--- a/go/go.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/go.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -4,10 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <cerrno>
-#include <cstdio>
-#include <string>
-
 #include "go-system.h"
 
 #include "go-c.h"
diff -r b8dc08fdaf6b go/gogo-tree.cc
--- a/go/gogo-tree.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/gogo-tree.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -4,9 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <algorithm>
-#include <list>
-
 #include "go-system.h"
 
 #include <gmp.h>
diff -r b8dc08fdaf6b go/gogo.cc
--- a/go/gogo.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/gogo.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -4,9 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <algorithm>
-#include <list>
-
 #include "go-system.h"
 
 #include "go-dump.h"
diff -r b8dc08fdaf6b go/lex.cc
--- a/go/lex.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/lex.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -4,10 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <cstdio>
-#include <stdint.h>
-#include <algorithm>
-
 #include "go-system.h"
 
 #include "lex.h"
diff -r b8dc08fdaf6b go/statements.cc
--- a/go/statements.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/statements.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -6,7 +6,6 @@ 
 
 #include "go-system.h"
 
-#include <tr1/unordered_set>
 #include <gmp.h>
 
 #ifndef ENABLE_BUILD_WITH_CXX
diff -r b8dc08fdaf6b go/types.cc
--- a/go/types.cc	Tue Nov 16 16:19:36 2010 -0800
+++ b/go/types.cc	Tue Nov 16 19:45:22 2010 -0800
@@ -4,8 +4,6 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-#include <algorithm>
-
 #include "go-system.h"
 
 #include <gmp.h>
Index: go-system.h
===================================================================
--- go-system.h	(revision 166840)
+++ go-system.h	(working copy)
@@ -24,12 +24,15 @@ 
 
 // These must be included before the #poison declarations in system.h.
 
+#include <algorithm>
 #include <string>
+#include <list>
 #include <vector>
 
 #if defined(HAVE_UNORDERED_MAP)
 
 # include <unordered_map>
+# include <unordered_set>
 
 # define Unordered_map(KEYTYPE, VALTYPE) \
 	std::unordered_map<KEYTYPE, VALTYPE>
@@ -37,9 +40,16 @@ 
 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
 	std::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
 
+# define Unordered_set(KEYTYPE, VALTYPE) \
+	std::unordered_set<KEYTYPE, VALTYPE>
+
+# define Unordered_set_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
+	std::unordered_set<KEYTYPE, VALTYPE, HASHFN, EQFN>
+
 #elif defined(HAVE_TR1_UNORDERED_MAP)
 
 # include <tr1/unordered_map>
+# include <tr1/unordered_set>
 
 # define Unordered_map(KEYTYPE, VALTYPE) \
 	std::tr1::unordered_map<KEYTYPE, VALTYPE>
@@ -47,9 +57,16 @@ 
 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
 	std::tr1::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
 
+# define Unordered_set(KEYTYPE, VALTYPE) \
+	std::tr1::unordered_set<KEYTYPE, VALTYPE>
+
+# define Unordered_set_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
+	std::tr1::unordered_set<KEYTYPE, VALTYPE, HASHFN, EQFN>
+
 #elif defined(HAVE_EXT_HASH_MAP)
 
 # include <ext/hash_map>
+# include <ext/hash_set>
 
 # define Unordered_map(KEYTYPE, VALTYPE) \
 	__gnu_cxx::hash_map<KEYTYPE, VALTYPE>
@@ -57,6 +74,12 @@ 
 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
 	__gnu_cxx::hash_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
 
+# define Unordered_set(KEYTYPE, VALTYPE) \
+	__gnu_cxx::hash_set<KEYTYPE, VALTYPE>
+
+# define Unordered_set_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
+	__gnu_cxx::hash_set<KEYTYPE, VALTYPE, HASHFN, EQFN>
+
 // Provide hash functions for strings and pointers.
 
 namespace __gnu_cxx
@@ -83,10 +106,14 @@  struct hash<T*>
 #else
 
 # include <map>
+# include <set>
 
 # define Unordered_map(KEYTYPE, VALTYPE) \
 	std::map<KEYTYPE, VALTYPE>
 
+# define Unordered_set(KEYTYPE, VALTYPE) \
+	std::set<KEYTYPE, VALTYPE>
+
 // We could make this work by writing an adapter class which
 // implemented operator< in terms of the hash function.
 # error "requires hash table type"