Daily bump.
[official-gcc.git] / gcc / go / go-system.h
blob3a02464f06625cab384f19280f2225a3bf8f4373
1 // go-system.h -- Go frontend inclusion of gcc header files -*- C++ -*-
2 // Copyright (C) 2009-2018 Free Software Foundation, Inc.
4 // This file is part of GCC.
6 // GCC is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation; either version 3, or (at your option) any later
9 // version.
11 // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 // for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with GCC; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #ifndef GO_SYSTEM_H
21 #define GO_SYSTEM_H
23 #include "config.h"
25 /* Define this so that inttypes.h defines the PRI?64 macros even
26 when compiling with a C++ compiler. Define it here so in the
27 event inttypes.h gets pulled in by another header it is already
28 defined. */
29 #define __STDC_FORMAT_MACROS
31 // These must be included before the #poison declarations in system.h.
33 #include <algorithm>
34 #include <string>
35 #include <list>
36 #include <map>
37 #include <set>
38 #include <vector>
39 #include <sstream>
41 #if defined(HAVE_UNORDERED_MAP)
43 # include <unordered_map>
44 # include <unordered_set>
46 # define Unordered_map(KEYTYPE, VALTYPE) \
47 std::unordered_map<KEYTYPE, VALTYPE>
49 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
50 std::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
52 # define Unordered_set(KEYTYPE) \
53 std::unordered_set<KEYTYPE>
55 # define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
56 std::unordered_set<KEYTYPE, HASHFN, EQFN>
58 #elif defined(HAVE_TR1_UNORDERED_MAP)
60 # include <tr1/unordered_map>
61 # include <tr1/unordered_set>
63 # define Unordered_map(KEYTYPE, VALTYPE) \
64 std::tr1::unordered_map<KEYTYPE, VALTYPE>
66 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
67 std::tr1::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
69 # define Unordered_set(KEYTYPE) \
70 std::tr1::unordered_set<KEYTYPE>
72 # define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
73 std::tr1::unordered_set<KEYTYPE, HASHFN, EQFN>
75 #elif defined(HAVE_EXT_HASH_MAP)
77 # include <ext/hash_map>
78 # include <ext/hash_set>
80 # define Unordered_map(KEYTYPE, VALTYPE) \
81 __gnu_cxx::hash_map<KEYTYPE, VALTYPE>
83 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
84 __gnu_cxx::hash_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
86 # define Unordered_set(KEYTYPE) \
87 __gnu_cxx::hash_set<KEYTYPE>
89 # define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
90 __gnu_cxx::hash_set<KEYTYPE, HASHFN, EQFN>
92 // Provide hash functions for strings and pointers.
94 namespace __gnu_cxx
97 template<>
98 struct hash<std::string>
100 size_t
101 operator()(std::string s) const
102 { return __stl_hash_string(s.c_str()); }
105 template<typename T>
106 struct hash<T*>
108 size_t
109 operator()(T* p) const
110 { return reinterpret_cast<size_t>(p); }
115 #else
117 # define Unordered_map(KEYTYPE, VALTYPE) \
118 std::map<KEYTYPE, VALTYPE>
120 # define Unordered_set(KEYTYPE) \
121 std::set<KEYTYPE>
123 // We could make this work by writing an adapter class which
124 // implemented operator< in terms of the hash function.
125 # error "requires hash table type"
127 #endif
129 // We don't really need iostream, but some versions of gmp.h include
130 // it when compiled with C++, which means that we need to include it
131 // before the macro magic of safe-ctype.h, which is included by
132 // system.h.
133 #include <iostream>
135 #include "system.h"
136 #include "ansidecl.h"
137 #include "coretypes.h"
139 #include "diagnostic-core.h" /* For error_at and friends. */
140 #include "intl.h" /* For _(). */
142 // When using gcc, go_assert is just gcc_assert.
143 #define go_assert(EXPR) gcc_assert(EXPR)
145 // When using gcc, go_unreachable is just gcc_unreachable.
146 #define go_unreachable() gcc_unreachable()
148 #endif // !defined(GO_SYSTEM_H)