* dwp.h: New header file.
	* dwp.cc: New source file.
	* gold.h: Move shared declarations to system.h.
	* system.h: New header file.
	* Makefile.am: Add dwp.
	* Makefile.in: Regenerate.
This commit is contained in:
Cary Coutant 2012-10-24 02:26:39 +00:00
parent 657d0d47ba
commit 774299092d
7 changed files with 2451 additions and 153 deletions

View File

@ -1,3 +1,12 @@
2012-10-23 Cary Coutant <ccoutant@google.com>
* dwp.h: New header file.
* dwp.cc: New source file.
* gold.h: Move shared declarations to system.h.
* system.h: New header file.
* Makefile.am: Add dwp.
* Makefile.in: Regenerate.
2012-10-23 Cary Coutant <ccoutant@google.com>
* dwarf_reader.cc (Dwarf_ranges_table::read_range_list): Call

View File

@ -34,6 +34,8 @@ AM_YFLAGS = -d
am__skiplex =
am__skipyacc =
bin_PROGRAMS = dwp
noinst_PROGRAMS = ld-new incremental-dump
noinst_LIBRARIES = libgold.a
@ -172,6 +174,12 @@ incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
$(THREADSLIB) $(LIBDL)
dwp_SOURCES = dwp.cc
dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADSLIB) \
$(LIBDL)
dwp_LDFLAGS = $(GOLD_LDFLAGS)
# Use an explicit dependency for the bison generated header file.
expression.$(OBJEXT): yyscript.h
script-sections.$(OBJEXT): yyscript.h

View File

@ -38,6 +38,7 @@ POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
bin_PROGRAMS = dwp$(EXEEXT)
noinst_PROGRAMS = ld-new$(EXEEXT) incremental-dump$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@check_PROGRAMS = ld1$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ ld2$(EXEEXT) ld1-r$(EXEEXT) \
@ -94,10 +95,15 @@ am__objects_3 = yyscript.$(OBJEXT)
am_libgold_a_OBJECTS = $(am__objects_1) $(am__objects_2) \
$(am__objects_3) $(am__objects_2)
libgold_a_OBJECTS = $(am_libgold_a_OBJECTS)
PROGRAMS = $(noinst_PROGRAMS)
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
am_dwp_OBJECTS = dwp.$(OBJEXT)
dwp_OBJECTS = $(am_dwp_OBJECTS)
am__DEPENDENCIES_1 =
dwp_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(dwp_LDFLAGS) \
$(LDFLAGS) -o $@
am_incremental_dump_OBJECTS = incremental-dump.$(OBJEXT)
incremental_dump_OBJECTS = $(am_incremental_dump_OBJECTS)
am__DEPENDENCIES_1 =
am__objects_4 = main.$(OBJEXT)
am_ld_new_OBJECTS = $(am__objects_4)
ld_new_OBJECTS = $(am_ld_new_OBJECTS)
@ -138,9 +144,10 @@ CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
@MAINTAINER_MODE_FALSE@am__skipyacc = test -f $@ ||
YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
YLWRAP = $(top_srcdir)/../ylwrap
SOURCES = $(libgold_a_SOURCES) $(incremental_dump_SOURCES) \
$(ld_new_SOURCES) $(EXTRA_ld_new_SOURCES) $(ld1_SOURCES) \
$(ld1_r_SOURCES) $(ld2_SOURCES) $(ld2_r_SOURCES)
SOURCES = $(libgold_a_SOURCES) $(dwp_SOURCES) \
$(incremental_dump_SOURCES) $(ld_new_SOURCES) \
$(EXTRA_ld_new_SOURCES) $(ld1_SOURCES) $(ld1_r_SOURCES) \
$(ld2_SOURCES) $(ld2_r_SOURCES)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-dvi-recursive install-exec-recursive \
@ -514,6 +521,12 @@ incremental_dump_DEPENDENCIES = $(TARGETOBJS) libgold.a $(LIBIBERTY) \
incremental_dump_LDADD = $(TARGETOBJS) libgold.a $(LIBIBERTY) $(LIBINTL) \
$(THREADSLIB) $(LIBDL)
dwp_SOURCES = dwp.cc
dwp_DEPENDENCIES = libgold.a $(LIBIBERTY) $(LIBINTL_DEP)
dwp_LDADD = libgold.a $(LIBIBERTY) $(GOLD_LDADD) $(LIBINTL) $(THREADSLIB) \
$(LIBDL)
dwp_LDFLAGS = $(GOLD_LDFLAGS)
POTFILES = $(CCFILES) $(HFILES) $(TARGETSOURCES)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ld1_SOURCES = $(sources_var)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ld1_DEPENDENCIES = $(deps_var) gcctestdir1/ld
@ -602,12 +615,52 @@ libgold.a: $(libgold_a_OBJECTS) $(libgold_a_DEPENDENCIES)
-rm -f libgold.a
$(libgold_a_AR) libgold.a $(libgold_a_OBJECTS) $(libgold_a_LIBADD)
$(RANLIB) libgold.a
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p; \
then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' `; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
clean-checkPROGRAMS:
-test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS)
clean-noinstPROGRAMS:
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
dwp$(EXEEXT): $(dwp_OBJECTS) $(dwp_DEPENDENCIES)
@rm -f dwp$(EXEEXT)
$(dwp_LINK) $(dwp_OBJECTS) $(dwp_LDADD) $(LIBS)
incremental-dump$(EXEEXT): $(incremental_dump_OBJECTS) $(incremental_dump_DEPENDENCIES)
@rm -f incremental-dump$(EXEEXT)
$(CXXLINK) $(incremental_dump_OBJECTS) $(incremental_dump_LDADD) $(LIBS)
@ -650,6 +703,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/descriptors.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dirsearch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwarf_reader.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dwp.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynobj.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ehframe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/errors.Po@am__quote@
@ -686,6 +740,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/symtab.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/target-select.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/target.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tilegx.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/workqueue-threads.Po@am__quote@
@ -1026,6 +1081,9 @@ check: check-recursive
all-am: Makefile $(LIBRARIES) $(PROGRAMS) config.h
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
@ -1059,8 +1117,8 @@ maintainer-clean-generic:
-rm -f yyscript.h
clean: clean-recursive
clean-am: clean-checkPROGRAMS clean-generic clean-noinstLIBRARIES \
clean-noinstPROGRAMS mostlyclean-am
clean-am: clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
clean-noinstLIBRARIES clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
@ -1087,7 +1145,7 @@ install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am: install-exec-local
install-exec-am: install-binPROGRAMS install-exec-local
install-html: install-html-recursive
@ -1128,7 +1186,7 @@ ps: ps-recursive
ps-am:
uninstall-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check-am \
check-html ctags-recursive install-am install-strip recheck \
@ -1136,19 +1194,20 @@ uninstall-am:
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-TESTS check-am check-html \
clean clean-checkPROGRAMS clean-generic clean-noinstLIBRARIES \
clean-noinstPROGRAMS ctags ctags-recursive distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am install-data-local \
install-dvi install-dvi-am install-exec install-exec-am \
install-exec-local install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am recheck recheck-html \
tags tags-recursive uninstall uninstall-am
clean clean-binPROGRAMS clean-checkPROGRAMS clean-generic \
clean-noinstLIBRARIES clean-noinstPROGRAMS ctags \
ctags-recursive distclean distclean-compile distclean-generic \
distclean-hdr distclean-tags dvi dvi-am html html-am info \
info-am install install-am install-binPROGRAMS install-data \
install-data-am install-data-local install-dvi install-dvi-am \
install-exec install-exec-am install-exec-local install-html \
install-html-am install-info install-info-am install-man \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am recheck recheck-html tags tags-recursive uninstall \
uninstall-am uninstall-binPROGRAMS
# Use an explicit dependency for the bison generated header file.

2074
gold/dwp.cc Normal file

File diff suppressed because it is too large Load Diff

120
gold/dwp.h Normal file
View File

@ -0,0 +1,120 @@
// dwp.h -- general definitions for dwp.
// Copyright 2012 Free Software Foundation, Inc.
// Written by Cary Coutant <ccoutant@google.com>.
// This file is part of dwp, the DWARF packaging utility.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
#ifndef DWP_DWP_H
#define DWP_DWP_H 1
#include "config.h"
#include "ansidecl.h"
#include <cstddef>
#include <cstdlib>
#include <cstring>
#include <stdint.h>
#include <sys/types.h>
#include "system.h"
namespace gold
{
extern const char* program_name;
class General_options;
class Command_line;
class Dirsearch;
class Input_objects;
class Mapfile;
class Symbol;
class Symbol_table;
class Layout;
class Task;
class Workqueue;
class Output_file;
template<int size, bool big_endian>
struct Relocate_info;
// The size of a section if we are going to look at the contents.
typedef size_t section_size_type;
// An offset within a section when we are looking at the contents.
typedef ptrdiff_t section_offset_type;
inline bool
is_prefix_of(const char* prefix, const char* str)
{
return strncmp(prefix, str, strlen(prefix)) == 0;
}
// Exit status codes.
enum Exit_status
{
GOLD_OK = EXIT_SUCCESS,
GOLD_ERR = EXIT_FAILURE,
GOLD_FALLBACK = EXIT_FAILURE + 1
};
// This function is called to exit the program. Status is true to
// exit success (0) and false to exit failure (1).
extern void
gold_exit(Exit_status status) ATTRIBUTE_NORETURN;
// This function is called to emit an error message and then
// immediately exit with failure.
extern void
gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
// This function is called to issue a warning.
extern void
gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
#define gold_unreachable() \
(gold::do_gold_unreachable(__FILE__, __LINE__, \
static_cast<const char*>(__FUNCTION__)))
extern void do_gold_unreachable(const char*, int, const char*)
ATTRIBUTE_NORETURN;
// Assertion check.
#define gold_assert(expr) ((void)(!(expr) ? gold_unreachable(), 0 : 0))
// Convert numeric types without unnoticed loss of precision.
template<typename To, typename From>
inline To
convert_types(const From from)
{
To to = from;
gold_assert(static_cast<From>(to) == from);
return to;
}
// A common case of convert_types<>: convert to section_size_type.
template<typename From>
inline section_size_type
convert_to_section_size_type(const From from)
{ return convert_types<section_size_type, From>(from); }
}; // End namespace gold.
#endif // !defined(DWP_DWP_H)

View File

@ -32,137 +32,7 @@
#include <stdint.h>
#include <sys/types.h>
#ifndef ENABLE_NLS
// The Solaris version of locale.h always includes libintl.h. If we
// have been configured with --disable-nls then ENABLE_NLS will not
// be defined and the dummy definitions of bindtextdomain (et al)
// below will conflict with the definitions in libintl.h. So we
// define these values to prevent the bogus inclusion of libintl.h.
# define _LIBINTL_H
# define _LIBGETTEXT_H
#endif
// Always include <clocale> first to avoid conflicts with the macros
// used when ENABLE_NLS is not defined.
#include <clocale>
#ifdef ENABLE_NLS
# include <libintl.h>
# define _(String) gettext (String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define gettext(Msgid) (Msgid)
# define dgettext(Domainname, Msgid) (Msgid)
# define dcgettext(Domainname, Msgid, Category) (Msgid)
# define textdomain(Domainname) do {} while (0) /* nothing */
# define bindtextdomain(Domainname, Dirname) do {} while (0) /* nothing */
# define _(String) (String)
# define N_(String) (String)
#endif
// Figure out how to get a hash set and a hash map.
#if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP) \
&& defined(HAVE_TR1_UNORDERED_MAP_REHASH)
#include <tr1/unordered_set>
#include <tr1/unordered_map>
// We need a template typedef here.
#define Unordered_set std::tr1::unordered_set
#define Unordered_map std::tr1::unordered_map
#define Unordered_multimap std::tr1::unordered_multimap
#define reserve_unordered_map(map, n) ((map)->rehash(n))
#ifndef HAVE_TR1_HASH_OFF_T
// The library does not support hashes of off_t values. Add support
// here. This is likely to be specific to libstdc++. This issue
// arises with GCC 4.1.x when compiling in 32-bit mode with a 64-bit
// off_t type.
namespace std { namespace tr1 {
template<>
struct hash<off_t> : public std::unary_function<off_t, std::size_t>
{
std::size_t
operator()(off_t val) const
{ return static_cast<std::size_t>(val); }
};
} } // Close namespaces.
#endif // !defined(HAVE_TR1_HASH_OFF_T)
#elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
#include <ext/hash_map>
#include <ext/hash_set>
#include <string>
#define Unordered_set __gnu_cxx::hash_set
#define Unordered_map __gnu_cxx::hash_map
#define Unordered_multimap __gnu_cxx::hash_multimap
namespace __gnu_cxx
{
template<>
struct hash<std::string>
{
size_t
operator()(std::string s) const
{ return __stl_hash_string(s.c_str()); }
};
template<typename T>
struct hash<T*>
{
size_t
operator()(T* p) const
{ return reinterpret_cast<size_t>(p); }
};
}
#define reserve_unordered_map(map, n) ((map)->resize(n))
#else
// The fallback is to just use set and map.
#include <set>
#include <map>
#define Unordered_set std::set
#define Unordered_map std::map
#define Unordered_multimap std::multimap
#define reserve_unordered_map(map, n)
#endif
#ifndef HAVE_PREAD
extern "C" ssize_t pread(int, void*, size_t, off_t);
#endif
#ifndef HAVE_FTRUNCATE
extern "C" int ftruncate(int, off_t);
#endif
#ifndef HAVE_FFSLL
extern "C" int ffsll(long long);
#endif
#if !HAVE_DECL_MEMMEM
extern "C" void *memmem(const void *, size_t, const void *, size_t);
#endif
#if !HAVE_DECL_STRNDUP
extern "C" char *strndup(const char *, size_t);
#endif
#include "system.h"
namespace gold
{

158
gold/system.h Normal file
View File

@ -0,0 +1,158 @@
// system.h -- general definitions for gold -*- C++ -*-
// Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
#ifndef SYSTEM_H
#define SYSTEM_H 1
#ifndef ENABLE_NLS
// The Solaris version of locale.h always includes libintl.h. If we
// have been configured with --disable-nls then ENABLE_NLS will not
// be defined and the dummy definitions of bindtextdomain (et al)
// below will conflict with the definitions in libintl.h. So we
// define these values to prevent the bogus inclusion of libintl.h.
# define _LIBINTL_H
# define _LIBGETTEXT_H
#endif
// Always include <clocale> first to avoid conflicts with the macros
// used when ENABLE_NLS is not defined.
#include <clocale>
#ifdef ENABLE_NLS
# include <libintl.h>
# define _(String) gettext (String)
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define gettext(Msgid) (Msgid)
# define dgettext(Domainname, Msgid) (Msgid)
# define dcgettext(Domainname, Msgid, Category) (Msgid)
# define textdomain(Domainname) do {} while (0) /* nothing */
# define bindtextdomain(Domainname, Dirname) do {} while (0) /* nothing */
# define _(String) (String)
# define N_(String) (String)
#endif
// Figure out how to get a hash set and a hash map.
#if defined(HAVE_TR1_UNORDERED_SET) && defined(HAVE_TR1_UNORDERED_MAP) \
&& defined(HAVE_TR1_UNORDERED_MAP_REHASH)
#include <tr1/unordered_set>
#include <tr1/unordered_map>
// We need a template typedef here.
#define Unordered_set std::tr1::unordered_set
#define Unordered_map std::tr1::unordered_map
#define Unordered_multimap std::tr1::unordered_multimap
#define reserve_unordered_map(map, n) ((map)->rehash(n))
#ifndef HAVE_TR1_HASH_OFF_T
// The library does not support hashes of off_t values. Add support
// here. This is likely to be specific to libstdc++. This issue
// arises with GCC 4.1.x when compiling in 32-bit mode with a 64-bit
// off_t type.
namespace std { namespace tr1 {
template<>
struct hash<off_t> : public std::unary_function<off_t, std::size_t>
{
std::size_t
operator()(off_t val) const
{ return static_cast<std::size_t>(val); }
};
} } // Close namespaces.
#endif // !defined(HAVE_TR1_HASH_OFF_T)
#elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET)
#include <ext/hash_map>
#include <ext/hash_set>
#include <string>
#define Unordered_set __gnu_cxx::hash_set
#define Unordered_map __gnu_cxx::hash_map
#define Unordered_multimap __gnu_cxx::hash_multimap
namespace __gnu_cxx
{
template<>
struct hash<std::string>
{
size_t
operator()(std::string s) const
{ return __stl_hash_string(s.c_str()); }
};
template<typename T>
struct hash<T*>
{
size_t
operator()(T* p) const
{ return reinterpret_cast<size_t>(p); }
};
}
#define reserve_unordered_map(map, n) ((map)->resize(n))
#else
// The fallback is to just use set and map.
#include <set>
#include <map>
#define Unordered_set std::set
#define Unordered_map std::map
#define Unordered_multimap std::multimap
#define reserve_unordered_map(map, n)
#endif
#ifndef HAVE_PREAD
extern "C" ssize_t pread(int, void*, size_t, off_t);
#endif
#ifndef HAVE_FTRUNCATE
extern "C" int ftruncate(int, off_t);
#endif
#ifndef HAVE_FFSLL
extern "C" int ffsll(long long);
#endif
#if !HAVE_DECL_MEMMEM
extern "C" void *memmem(const void *, size_t, const void *, size_t);
#endif
#if !HAVE_DECL_STRNDUP
extern "C" char *strndup(const char *, size_t);
#endif
#endif // !defined(SYSTEM_H)