]>
Commit | Line | Data |
---|---|---|
77429909 CC |
1 | // system.h -- general definitions for gold -*- C++ -*- |
2 | ||
b90efa5b | 3 | // Copyright (C) 2006-2015 Free Software Foundation, Inc. |
77429909 CC |
4 | // Written by Ian Lance Taylor <[email protected]>. |
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 SYSTEM_H | |
24 | #define SYSTEM_H 1 | |
25 | ||
26 | #ifndef ENABLE_NLS | |
27 | // The Solaris version of locale.h always includes libintl.h. If we | |
28 | // have been configured with --disable-nls then ENABLE_NLS will not | |
29 | // be defined and the dummy definitions of bindtextdomain (et al) | |
30 | // below will conflict with the definitions in libintl.h. So we | |
31 | // define these values to prevent the bogus inclusion of libintl.h. | |
32 | # define _LIBINTL_H | |
33 | # define _LIBGETTEXT_H | |
34 | #endif | |
35 | ||
77429909 | 36 | #ifdef ENABLE_NLS |
c2c9fdb4 | 37 | // On some systems, things go awry when <libintl.h> comes after <clocale>. |
77429909 | 38 | # include <libintl.h> |
c2c9fdb4 | 39 | # include <clocale> |
77429909 CC |
40 | # define _(String) gettext (String) |
41 | # ifdef gettext_noop | |
42 | # define N_(String) gettext_noop (String) | |
43 | # else | |
44 | # define N_(String) (String) | |
45 | # endif | |
46 | #else | |
c2c9fdb4 RM |
47 | // Include <clocale> first to avoid conflicts with these macros. |
48 | # include <clocale> | |
77429909 CC |
49 | # define gettext(Msgid) (Msgid) |
50 | # define dgettext(Domainname, Msgid) (Msgid) | |
51 | # define dcgettext(Domainname, Msgid, Category) (Msgid) | |
52 | # define textdomain(Domainname) do {} while (0) /* nothing */ | |
53 | # define bindtextdomain(Domainname, Dirname) do {} while (0) /* nothing */ | |
54 | # define _(String) (String) | |
55 | # define N_(String) (String) | |
56 | #endif | |
57 | ||
58 | // Figure out how to get a hash set and a hash map. | |
59 | ||
8356f2d0 CC |
60 | #if defined(HAVE_UNORDERED_SET) && defined(HAVE_UNORDERED_MAP) |
61 | ||
62 | #include <unordered_set> | |
63 | #include <unordered_map> | |
64 | ||
65 | // We need a template typedef here. | |
66 | ||
67 | #define Unordered_set std::unordered_set | |
68 | #define Unordered_map std::unordered_map | |
69 | #define Unordered_multimap std::unordered_multimap | |
70 | ||
71 | #define reserve_unordered_map(map, n) ((map)->rehash(n)) | |
72 | ||
73 | #elif defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP) \ | |
74 | && defined(HAVE_TR1_UNORDERED_MAP_REHASH) | |
77429909 CC |
75 | |
76 | #include <tr1/unordered_set> | |
77 | #include <tr1/unordered_map> | |
78 | ||
79 | // We need a template typedef here. | |
80 | ||
81 | #define Unordered_set std::tr1::unordered_set | |
82 | #define Unordered_map std::tr1::unordered_map | |
83 | #define Unordered_multimap std::tr1::unordered_multimap | |
84 | ||
85 | #define reserve_unordered_map(map, n) ((map)->rehash(n)) | |
86 | ||
87 | #ifndef HAVE_TR1_HASH_OFF_T | |
88 | // The library does not support hashes of off_t values. Add support | |
89 | // here. This is likely to be specific to libstdc++. This issue | |
90 | // arises with GCC 4.1.x when compiling in 32-bit mode with a 64-bit | |
91 | // off_t type. | |
92 | namespace std { namespace tr1 { | |
93 | template<> | |
94 | struct hash<off_t> : public std::unary_function<off_t, std::size_t> | |
95 | { | |
96 | std::size_t | |
97 | operator()(off_t val) const | |
98 | { return static_cast<std::size_t>(val); } | |
99 | }; | |
100 | } } // Close namespaces. | |
101 | #endif // !defined(HAVE_TR1_HASH_OFF_T) | |
102 | ||
103 | #elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET) | |
104 | ||
105 | #include <ext/hash_map> | |
106 | #include <ext/hash_set> | |
107 | #include <string> | |
108 | ||
109 | #define Unordered_set __gnu_cxx::hash_set | |
110 | #define Unordered_map __gnu_cxx::hash_map | |
111 | #define Unordered_multimap __gnu_cxx::hash_multimap | |
112 | ||
113 | namespace __gnu_cxx | |
114 | { | |
115 | ||
116 | template<> | |
117 | struct hash<std::string> | |
118 | { | |
119 | size_t | |
120 | operator()(std::string s) const | |
121 | { return __stl_hash_string(s.c_str()); } | |
122 | }; | |
123 | ||
124 | template<typename T> | |
125 | struct hash<T*> | |
126 | { | |
127 | size_t | |
128 | operator()(T* p) const | |
129 | { return reinterpret_cast<size_t>(p); } | |
130 | }; | |
131 | ||
132 | } | |
133 | ||
134 | #define reserve_unordered_map(map, n) ((map)->resize(n)) | |
135 | ||
136 | #else | |
137 | ||
138 | // The fallback is to just use set and map. | |
139 | ||
140 | #include <set> | |
141 | #include <map> | |
142 | ||
143 | #define Unordered_set std::set | |
144 | #define Unordered_map std::map | |
145 | #define Unordered_multimap std::multimap | |
146 | ||
147 | #define reserve_unordered_map(map, n) | |
148 | ||
149 | #endif | |
150 | ||
151 | #ifndef HAVE_PREAD | |
152 | extern "C" ssize_t pread(int, void*, size_t, off_t); | |
153 | #endif | |
154 | ||
155 | #ifndef HAVE_FTRUNCATE | |
156 | extern "C" int ftruncate(int, off_t); | |
157 | #endif | |
158 | ||
159 | #ifndef HAVE_FFSLL | |
160 | extern "C" int ffsll(long long); | |
161 | #endif | |
162 | ||
163 | #if !HAVE_DECL_MEMMEM | |
164 | extern "C" void *memmem(const void *, size_t, const void *, size_t); | |
165 | #endif | |
166 | ||
167 | #if !HAVE_DECL_STRNDUP | |
168 | extern "C" char *strndup(const char *, size_t); | |
169 | #endif | |
170 | ||
171 | #endif // !defined(SYSTEM_H) |