Remove gcc 3.2 compatibility hacks.
[deliverable/binutils-gdb.git] / gold / gold.h
1 // gold.h -- general definitions for gold -*- C++ -*-
2
3 // Copyright 2006, 2007 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
5
6 // This file is part of gold.
7
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
12
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
22
23 #ifndef GOLD_GOLD_H
24 #define GOLD_GOLD_H
25
26 #include "config.h"
27 #include "ansidecl.h"
28
29 #ifdef ENABLE_NLS
30 # include <libintl.h>
31 # define _(String) gettext (String)
32 # ifdef gettext_noop
33 # define N_(String) gettext_noop (String)
34 # else
35 # define N_(String) (String)
36 # endif
37 #else
38 # define gettext(Msgid) (Msgid)
39 # define dgettext(Domainname, Msgid) (Msgid)
40 # define dcgettext(Domainname, Msgid, Category) (Msgid)
41 # define textdomain(Domainname) while (0) /* nothing */
42 # define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
43 # define _(String) (String)
44 # define N_(String) (String)
45 #endif
46
47 // Figure out how to get a hash set and a hash map.
48
49 #if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP)
50
51 #include <tr1/unordered_set>
52 #include <tr1/unordered_map>
53
54 // We need a template typedef here.
55
56 #define Unordered_set std::tr1::unordered_set
57 #define Unordered_map std::tr1::unordered_map
58
59 #elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
60
61 #include <ext/hash_map>
62 #include <ext/hash_set>
63 #include <string>
64
65 #define Unordered_set __gnu_cxx::hash_set
66 #define Unordered_map __gnu_cxx::hash_map
67
68 namespace __gnu_cxx
69 {
70
71 template<>
72 struct hash<std::string>
73 {
74 size_t
75 operator()(std::string s) const
76 { return __stl_hash_string(s.c_str()); }
77 };
78
79 template<typename T>
80 struct hash<T*>
81 {
82 size_t
83 operator()(T* p) const
84 { return reinterpret_cast<size_t>(p); }
85 };
86
87 }
88
89 #else
90
91 // The fallback is to just use set and map.
92
93 #include <set>
94 #include <map>
95
96 #define Unordered_set std::set
97 #define Unordered_map std::map
98
99 #endif
100
101 #ifndef HAVE_PREAD
102 extern "C" ssize_t pread(int, void*, size_t, off_t);
103 #endif
104
105 namespace gold
106 {
107
108 // General declarations.
109
110 class General_options;
111 class Command_line;
112 class Input_argument_list;
113 class Dirsearch;
114 class Input_objects;
115 class Symbol;
116 class Symbol_table;
117 class Layout;
118 class Task;
119 class Workqueue;
120 class Output_file;
121 template<int size, bool big_endian>
122 struct Relocate_info;
123
124 // Some basic types. For these we use lower case initial letters.
125
126 // For an offset in an input or output file, use off_t. Note that
127 // this will often be a 64-bit type even for a 32-bit build.
128
129 // The size of a section if we are going to look at the contents.
130 typedef size_t section_size_type;
131
132 // An offset within a section when we are looking at the contents.
133 typedef ptrdiff_t section_offset_type;
134
135 // The name of the program as used in error messages.
136 extern const char* program_name;
137
138 // This function is called to exit the program. Status is true to
139 // exit success (0) and false to exit failure (1).
140 extern void
141 gold_exit(bool status) ATTRIBUTE_NORETURN;
142
143 // This function is called to emit an error message and then
144 // immediately exit with failure.
145 extern void
146 gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
147
148 // This function is called to issue an error. This will cause gold to
149 // eventually exit with failure.
150 extern void
151 gold_error(const char* msg, ...) ATTRIBUTE_PRINTF_1;
152
153 // This function is called to issue a warning.
154 extern void
155 gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
156
157 // This function is called to issue an error at the location of a
158 // reloc.
159 template<int size, bool big_endian>
160 extern void
161 gold_error_at_location(const Relocate_info<size, big_endian>*,
162 size_t, off_t, const char* format, ...)
163 ATTRIBUTE_PRINTF_4;
164
165 // This function is called to issue a warning at the location of a
166 // reloc.
167 template<int size, bool big_endian>
168 extern void
169 gold_warning_at_location(const Relocate_info<size, big_endian>*,
170 size_t, off_t, const char* format, ...)
171 ATTRIBUTE_PRINTF_4;
172
173 // This function is called to report an undefined symbol.
174 template<int size, bool big_endian>
175 extern void
176 gold_undefined_symbol(const Symbol*,
177 const Relocate_info<size, big_endian>*,
178 size_t, off_t);
179
180 // This is function is called in some cases if we run out of memory.
181 extern void
182 gold_nomem() ATTRIBUTE_NORETURN;
183
184 // This macro and function are used in cases which can not arise if
185 // the code is written correctly.
186
187 #define gold_unreachable() \
188 (gold::do_gold_unreachable(__FILE__, __LINE__, __FUNCTION__))
189
190 extern void do_gold_unreachable(const char*, int, const char*)
191 ATTRIBUTE_NORETURN;
192
193 // Assertion check.
194
195 #define gold_assert(expr) ((void)(!(expr) ? gold_unreachable(), 0 : 0))
196
197 // Print version information.
198 extern void
199 print_version(bool print_short);
200
201 // Get the version string.
202 extern const char*
203 get_version_string();
204
205 // Convert numeric types without unnoticed loss of precision.
206 template<typename To, typename From>
207 inline To
208 convert_types(const From from)
209 {
210 To to = from;
211 gold_assert(static_cast<From>(to) == from);
212 return to;
213 }
214
215 // A common case of convert_types<>: convert to section_size_type.
216 template<typename From>
217 inline section_size_type
218 convert_to_section_size_type(const From from)
219 { return convert_types<section_size_type, From>(from); }
220
221 // Queue up the first set of tasks.
222 extern void
223 queue_initial_tasks(const General_options&,
224 Dirsearch&,
225 const Command_line&,
226 Workqueue*,
227 Input_objects*,
228 Symbol_table*,
229 Layout*);
230
231 // Queue up the middle set of tasks.
232 extern void
233 queue_middle_tasks(const General_options&,
234 const Task*,
235 const Input_objects*,
236 Symbol_table*,
237 Layout*,
238 Workqueue*);
239
240 // Queue up the final set of tasks.
241 extern void
242 queue_final_tasks(const General_options&,
243 const Input_objects*,
244 const Symbol_table*,
245 Layout*,
246 Workqueue*,
247 Output_file* of);
248
249 } // End namespace gold.
250
251 #endif // !defined(GOLD_GOLD_H)
This page took 0.035822 seconds and 5 git commands to generate.