1 // system.h -- general definitions for gold -*- C++ -*-
3 // Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
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.
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.
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.
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.
33 # define _LIBGETTEXT_H
37 // On some systems, things go awry when <libintl.h> comes after <clocale>.
40 # define _(String) gettext (String)
42 # define N_(String) gettext_noop (String)
44 # define N_(String) (String)
47 // Include <clocale> first to avoid conflicts with these macros.
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)
58 // Figure out how to get a hash set and a hash map.
60 #if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP) \
61 && defined(HAVE_TR1_UNORDERED_MAP_REHASH)
63 #include <tr1/unordered_set>
64 #include <tr1/unordered_map>
66 // We need a template typedef here.
68 #define Unordered_set std::tr1::unordered_set
69 #define Unordered_map std::tr1::unordered_map
70 #define Unordered_multimap std::tr1::unordered_multimap
72 #define reserve_unordered_map(map, n) ((map)->rehash(n))
74 #ifndef HAVE_TR1_HASH_OFF_T
75 // The library does not support hashes of off_t values. Add support
76 // here. This is likely to be specific to libstdc++. This issue
77 // arises with GCC 4.1.x when compiling in 32-bit mode with a 64-bit
79 namespace std { namespace tr1 {
81 struct hash<off_t> : public std::unary_function<off_t, std::size_t>
84 operator()(off_t val) const
85 { return static_cast<std::size_t>(val); }
87 } } // Close namespaces.
88 #endif // !defined(HAVE_TR1_HASH_OFF_T)
90 #elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
92 #include <ext/hash_map>
93 #include <ext/hash_set>
96 #define Unordered_set __gnu_cxx::hash_set
97 #define Unordered_map __gnu_cxx::hash_map
98 #define Unordered_multimap __gnu_cxx::hash_multimap
104 struct hash<std::string>
107 operator()(std::string s) const
108 { return __stl_hash_string(s.c_str()); }
115 operator()(T* p) const
116 { return reinterpret_cast<size_t>(p); }
121 #define reserve_unordered_map(map, n) ((map)->resize(n))
125 // The fallback is to just use set and map.
130 #define Unordered_set std::set
131 #define Unordered_map std::map
132 #define Unordered_multimap std::multimap
134 #define reserve_unordered_map(map, n)
139 extern "C" ssize_t pread(int, void*, size_t, off_t);
142 #ifndef HAVE_FTRUNCATE
143 extern "C" int ftruncate(int, off_t);
147 extern "C" int ffsll(long long);
150 #if !HAVE_DECL_MEMMEM
151 extern "C" void *memmem(const void *, size_t, const void *, size_t);
154 #if !HAVE_DECL_STRNDUP
155 extern "C" char *strndup(const char *, size_t);
158 #endif // !defined(SYSTEM_H)