1 // gold.h -- general definitions for gold -*- C++ -*-
10 # define _(String) gettext (String)
12 # define N_(String) gettext_noop (String)
14 # define N_(String) (String)
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)
26 // Figure out how to get a hash set and a hash map.
28 #if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP)
30 #include <tr1/unordered_set>
31 #include <tr1/unordered_map>
33 // We need a template typedef here.
35 #define Unordered_set std::tr1::unordered_set
36 #define Unordered_map std::tr1::unordered_map
38 #elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
40 #include <ext/hash_map>
41 #include <ext/hash_set>
44 #define Unordered_set __gnu_cxx::hash_set
45 #define Unordered_map __gnu_cxx::hash_map
51 struct hash
<std::string
>
54 operator()(std::string s
) const
55 { return __stl_hash_string(s
.c_str()); }
62 operator()(T
* p
) const
63 { return reinterpret_cast<size_t>(p
); }
70 // The fallback is to just use set and map.
75 #define Unordered_set std::set
76 #define Unordered_map std::map
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.
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.
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.
97 #ifdef HAVE_MEMBER_TEMPLATE_SPECIFICATIONS
99 #define SELECT_SIZE_NAME(size) <size>
100 #define SELECT_SIZE(size)
101 #define SELECT_SIZE_ONLY(size)
103 #define ACCEPT_SIZE_ONLY
105 #define SELECT_SIZE_ENDIAN_NAME(size, big_endian) <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
111 #else // !defined(HAVE_MEMBER_TEMPLATE_SPECIFICATIONS)
114 class Select_size
{ };
115 template<int size
, bool big_endian
>
116 class Select_size_endian
{ };
118 #define SELECT_SIZE_NAME(size)
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>
124 #define SELECT_SIZE_ENDIAN_NAME(size, big_endian)
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>
132 #endif // !defined(HAVE_MEMBER_TEMPLATE_SPECIFICATIONS)
134 } // End namespace gold.
139 class General_options
;
140 class Input_argument_list
;
148 // The name of the program as used in error messages.
149 extern const char* program_name
;
151 // This function is called to exit the program. Status is true to
152 // exit success (0) and false to exit failure (1).
154 gold_exit(bool status
) ATTRIBUTE_NORETURN
;
156 // This function is called to emit an unexpected error message and a
157 // newline, and then exit with failure. If PERRNO is true, it reports
158 // the error in errno.
160 gold_fatal(const char* msg
, bool perrno
) ATTRIBUTE_NORETURN
;
162 // This is function is called in some cases if we run out of memory.
164 gold_nomem() ATTRIBUTE_NORETURN
;
166 // This function is called in cases which can not arise if the code is
167 // written correctly.
169 gold_unreachable() ATTRIBUTE_NORETURN
;
171 // Queue up the first set of tasks.
173 queue_initial_tasks(const General_options
&,
175 const Input_argument_list
&,
181 // Queue up the middle set of tasks.
183 queue_middle_tasks(const General_options
&,
184 const Input_objects
*,
189 // Queue up the final set of tasks.
191 queue_final_tasks(const General_options
&,
192 const Input_objects
*,
198 } // End namespace gold.
200 #endif // !defined(GOLD_GOLD_H)