* ld-sh/tlsbin-1.d: Update.
[deliverable/binutils-gdb.git] / gold / gold.h
CommitLineData
bae7f79e
ILT
1// gold.h -- general definitions for gold -*- C++ -*-
2
3#ifndef GOLD_GOLD_H
4
5#include "config.h"
6#include "ansidecl.h"
7
8#ifdef ENABLE_NLS
9# include <libintl.h>
10# define _(String) gettext (String)
11# ifdef gettext_noop
12# define N_(String) gettext_noop (String)
13# else
14# define N_(String) (String)
15# endif
16#else
17# define gettext(Msgid) (Msgid)
18# define dgettext(Domainname, Msgid) (Msgid)
19# define dcgettext(Domainname, Msgid, Category) (Msgid)
20# define textdomain(Domainname) while (0) /* nothing */
21# define bindtextdomain(Domainname, Dirname) while (0) /* nothing */
22# define _(String) (String)
23# define N_(String) (String)
24#endif
25
54dc6425
ILT
26// Figure out how to get a hash set and a hash map.
27
d288e464 28#if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP)
bae7f79e
ILT
29
30#include <tr1/unordered_set>
31#include <tr1/unordered_map>
32
33// We need a template typedef here.
34
35#define Unordered_set std::tr1::unordered_set
36#define Unordered_map std::tr1::unordered_map
37
d288e464 38#elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
54dc6425
ILT
39
40#include <ext/hash_map>
41#include <ext/hash_set>
274e99f9 42#include <string>
54dc6425
ILT
43
44#define Unordered_set __gnu_cxx::hash_set
45#define Unordered_map __gnu_cxx::hash_map
46
274e99f9
ILT
47namespace __gnu_cxx
48{
49
50template<>
51struct hash<std::string>
52{
53 size_t
54 operator()(std::string s) const
55 { return __stl_hash_string(s.c_str()); }
56};
57
58template<typename T>
59struct hash<T*>
60{
61 size_t
62 operator()(T* p) const
63 { return reinterpret_cast<size_t>(p); }
64};
65
66}
67
54dc6425
ILT
68#else
69
70// The fallback is to just use set and map.
71
72#include <set>
73#include <map>
74
75#define Unordered_set std::set
76#define Unordered_map std::map
77
78#endif
79
5482377d
ILT
80namespace gold
81{
82// This is a hack to work around a problem with older versions of g++.
83// The problem is that they don't support calling a member template by
84// specifying the template parameters. It works to pass in an
85// argument for argument dependent lookup.
86
87// To use this, the member template method declaration should put
88// ACCEPT_SIZE or ACCEPT_SIZE_ENDIAN after the last parameter. If the
89// method takes no parameters, use ACCEPT_SIZE_ONLY or
90// ACCEPT_SIZE_ENDIAN_ONLY.
91
92// When calling the method, instead of using fn<size>, use fn
93// SELECT_SIZE_NAME or SELECT_SIZE_ENDIAN_NAME. And after the last
94// argument, put SELECT_SIZE(size) or SELECT_SIZE_ENDIAN(size,
95// big_endian). If there is only one argment, use the _ONLY variants.
96
97#ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
98
99#define SELECT_SIZE_NAME <size>
100#define SELECT_SIZE(size)
101#define SELECT_SIZE_ONLY(size)
102#define ACCEPT_SIZE
103#define ACCEPT_SIZE_ONLY
104
105#define SELECT_SIZE_ENDIAN_NAME <size, big_endian>
106#define SELECT_SIZE_ENDIAN(size, big_endian)
107#define SELECT_SIZE_ENDIAN_ONLY(size, big_endian)
108#define ACCEPT_SIZE_ENDIAN
109#define ACCEPT_SIZE_ENDIAN_ONLY
110
111#else // !defined(HAVE_MEMBER_TEMPLATE_SPECIFICATIONS)
112
113template<int size>
114class Select_size { };
115template<int size, bool big_endian>
116class Select_size_endian { };
117
118#define SELECT_SIZE_NAME
119#define SELECT_SIZE(size) , Select_size<size>()
120#define SELECT_SIZE_ONLY(size) Select_size<size>()
121#define ACCEPT_SIZE , Select_size<size>
122#define ACCEPT_SIZE_ONLY Select_size<size>
123
124#define SELECT_SIZE_ENDIAN_NAME
125#define SELECT_SIZE_ENDIAN(size, big_endian) \
126 , Select_size_endian<size, big_endian>()
127#define SELECT_SIZE_ENDIAN_ONLY(size, big_endian) \
128 Select_size_endian<size, big_endian>()
129#define ACCEPT_SIZE_ENDIAN , Select_size_endian<size, big_endian>
130#define ACCEPT_SIZE_ENDIAN_ONLY Select_size_endian<size, big_endian>
131
132#endif // !defined(HAVE_MEMBER_TEMPLATE_SPECIFICATIONS)
133
134} // End namespace gold.
135
bae7f79e
ILT
136namespace gold
137{
138
61ba1cf9
ILT
139class General_options;
140class Input_objects;
141class Symbol_table;
142class Layout;
143class Workqueue;
144class Output_file;
145
bae7f79e
ILT
146// The name of the program as used in error messages.
147extern const char* program_name;
148
149// This function is called to exit the program. Status is true to
150// exit success (0) and false to exit failure (1).
151extern void
152gold_exit(bool status) ATTRIBUTE_NORETURN;
153
154// This function is called to emit an unexpected error message and a
155// newline, and then exit with failure. If PERRNO is true, it reports
156// the error in errno.
157extern void
158gold_fatal(const char* msg, bool perrno) ATTRIBUTE_NORETURN;
159
160// This is function is called in some cases if we run out of memory.
161extern void
162gold_nomem() ATTRIBUTE_NORETURN;
163
164// This function is called in cases which can not arise if the code is
165// written correctly.
166extern void
167gold_unreachable() ATTRIBUTE_NORETURN;
168
61ba1cf9
ILT
169extern void
170queue_final_tasks(const General_options&,
171 const Input_objects*,
172 const Symbol_table*,
173 const Layout*,
174 Workqueue*,
175 Output_file* of);
176
bae7f79e
ILT
177} // End namespace gold.
178
179#endif // !defined(GOLD_GOLD_H)
This page took 0.04507 seconds and 4 git commands to generate.