111
|
1 // go-system.h -- Go frontend inclusion of gcc header files -*- C++ -*-
|
145
|
2 // Copyright (C) 2009-2020 Free Software Foundation, Inc.
|
111
|
3
|
|
4 // This file is part of GCC.
|
|
5
|
|
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.
|
|
10
|
|
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.
|
|
15
|
|
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/>.
|
|
19
|
|
20 #ifndef GO_SYSTEM_H
|
|
21 #define GO_SYSTEM_H
|
|
22
|
|
23 #include "config.h"
|
|
24
|
|
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
|
|
30
|
|
31 // These must be included before the #poison declarations in system.h.
|
|
32
|
|
33 #include <algorithm>
|
|
34 #include <string>
|
|
35 #include <list>
|
|
36 #include <map>
|
|
37 #include <set>
|
|
38 #include <vector>
|
|
39 #include <sstream>
|
|
40
|
|
41 #if defined(HAVE_UNORDERED_MAP)
|
|
42
|
|
43 # include <unordered_map>
|
|
44 # include <unordered_set>
|
|
45
|
|
46 # define Unordered_map(KEYTYPE, VALTYPE) \
|
|
47 std::unordered_map<KEYTYPE, VALTYPE>
|
|
48
|
|
49 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
|
|
50 std::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
|
|
51
|
|
52 # define Unordered_set(KEYTYPE) \
|
|
53 std::unordered_set<KEYTYPE>
|
|
54
|
|
55 # define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
|
|
56 std::unordered_set<KEYTYPE, HASHFN, EQFN>
|
|
57
|
|
58 #elif defined(HAVE_TR1_UNORDERED_MAP)
|
|
59
|
|
60 # include <tr1/unordered_map>
|
|
61 # include <tr1/unordered_set>
|
|
62
|
|
63 # define Unordered_map(KEYTYPE, VALTYPE) \
|
|
64 std::tr1::unordered_map<KEYTYPE, VALTYPE>
|
|
65
|
|
66 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
|
|
67 std::tr1::unordered_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
|
|
68
|
|
69 # define Unordered_set(KEYTYPE) \
|
|
70 std::tr1::unordered_set<KEYTYPE>
|
|
71
|
|
72 # define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
|
|
73 std::tr1::unordered_set<KEYTYPE, HASHFN, EQFN>
|
|
74
|
|
75 #elif defined(HAVE_EXT_HASH_MAP)
|
|
76
|
|
77 # include <ext/hash_map>
|
|
78 # include <ext/hash_set>
|
|
79
|
|
80 # define Unordered_map(KEYTYPE, VALTYPE) \
|
|
81 __gnu_cxx::hash_map<KEYTYPE, VALTYPE>
|
|
82
|
|
83 # define Unordered_map_hash(KEYTYPE, VALTYPE, HASHFN, EQFN) \
|
|
84 __gnu_cxx::hash_map<KEYTYPE, VALTYPE, HASHFN, EQFN>
|
|
85
|
|
86 # define Unordered_set(KEYTYPE) \
|
|
87 __gnu_cxx::hash_set<KEYTYPE>
|
|
88
|
|
89 # define Unordered_set_hash(KEYTYPE, HASHFN, EQFN) \
|
|
90 __gnu_cxx::hash_set<KEYTYPE, HASHFN, EQFN>
|
|
91
|
|
92 // Provide hash functions for strings and pointers.
|
|
93
|
|
94 namespace __gnu_cxx
|
|
95 {
|
|
96
|
|
97 template<>
|
|
98 struct hash<std::string>
|
|
99 {
|
|
100 size_t
|
|
101 operator()(std::string s) const
|
|
102 { return __stl_hash_string(s.c_str()); }
|
|
103 };
|
|
104
|
|
105 template<typename T>
|
|
106 struct hash<T*>
|
|
107 {
|
|
108 size_t
|
|
109 operator()(T* p) const
|
|
110 { return reinterpret_cast<size_t>(p); }
|
|
111 };
|
|
112
|
|
113 }
|
|
114
|
|
115 #else
|
|
116
|
|
117 # define Unordered_map(KEYTYPE, VALTYPE) \
|
|
118 std::map<KEYTYPE, VALTYPE>
|
|
119
|
|
120 # define Unordered_set(KEYTYPE) \
|
|
121 std::set<KEYTYPE>
|
|
122
|
|
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"
|
|
126
|
|
127 #endif
|
|
128
|
|
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>
|
|
134
|
|
135 #include "system.h"
|
|
136 #include "ansidecl.h"
|
|
137 #include "coretypes.h"
|
|
138
|
|
139 #include "diagnostic-core.h" /* For error_at and friends. */
|
|
140 #include "intl.h" /* For _(). */
|
|
141
|
|
142 // When using gcc, go_assert is just gcc_assert.
|
|
143 #define go_assert(EXPR) gcc_assert(EXPR)
|
|
144
|
|
145 // When using gcc, go_unreachable is just gcc_unreachable.
|
|
146 #define go_unreachable() gcc_unreachable()
|
|
147
|
|
148 #endif // !defined(GO_SYSTEM_H)
|