1 // go-system.h -- Go frontend inclusion of gcc header files -*- C++ -*-
2 // Copyright (C) 2009-2020 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
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
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/>.
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
29 #define __STDC_FORMAT_MACROS
31 // These must be included before the #poison declarations in system.h.
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.
98 struct hash
<std::string
>
101 operator()(std::string s
) const
102 { return __stl_hash_string(s
.c_str()); }
109 operator()(T
* p
) const
110 { return reinterpret_cast<size_t>(p
); }
117 # define Unordered_map(KEYTYPE, VALTYPE) \
118 std::map<KEYTYPE, VALTYPE>
120 # define Unordered_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"
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
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)