X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gold%2Fgold.h;h=86311cc437f378da2d21bbfb2672278285c2a32d;hb=3c4e2282566d54b974f6929ee5c1270fb3cea4e5;hp=90f1f7d1f4ecfbf6ae53c5ef387b0d6e55223963;hpb=6e9ba2ca9c85e1d04123b87af1d57d57a5e6e82a;p=binutils-gdb.git diff --git a/gold/gold.h b/gold/gold.h index 90f1f7d1f4e..86311cc437f 100644 --- a/gold/gold.h +++ b/gold/gold.h @@ -1,6 +1,6 @@ // gold.h -- general definitions for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006-2022 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -27,130 +27,12 @@ #include "ansidecl.h" #include +#include #include #include #include -#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 defintions 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 first to avoid conflicts with the macros -// used when ENABLE_NLS is not defined. -#include - -#ifdef ENABLE_NLS -# include -# 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) while (0) /* nothing */ -# define bindtextdomain(Domainname, Dirname) 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 -#include - -// 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)) - -#elif defined(HAVE_EXT_HASH_MAP) && defined(HAVE_EXT_HASH_SET) - -#include -#include -#include - -#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 -{ - size_t - operator()(std::string s) const - { return __stl_hash_string(s.c_str()); } -}; - -template -struct hash -{ - size_t - operator()(T* p) const - { return reinterpret_cast(p); } -}; - -} - -#define reserve_unordered_map(map, n) ((map)->resize(n)) - -#else - -// The fallback is to just use set and map. - -#include -#include - -#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_MREMAP -#define MREMAP_MAYMOVE 1 -extern "C" void *mremap(void *, size_t, size_t, int, ...); -#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 { @@ -171,6 +53,15 @@ class Output_file; template struct Relocate_info; +// Exit status codes. + +enum Exit_status +{ + GOLD_OK = EXIT_SUCCESS, + GOLD_ERR = EXIT_FAILURE, + GOLD_FALLBACK = EXIT_FAILURE + 1 +}; + // Some basic types. For these we use lower case initial letters. // For an offset in an input or output file, use off_t. Note that @@ -188,7 +79,7 @@ extern const char* program_name; // 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(bool status) ATTRIBUTE_NORETURN; +gold_exit(Exit_status status) ATTRIBUTE_NORETURN; // This function is called to emit an error message and then // immediately exit with failure. @@ -208,6 +99,17 @@ gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1; extern void gold_info(const char* msg, ...) ATTRIBUTE_PRINTF_1; +// This function is called to print a trace message. +extern void +gold_trace(const char* msg, ...) ATTRIBUTE_PRINTF_1; + +// This function is called to emit an error message and then +// immediately exit with fallback status (e.g., when +// --incremental-update fails and the link needs to be restarted +// with --incremental-full). +extern void +gold_fallback(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1; + // Work around a bug in gcc 4.3.0. http://gcc.gnu.org/PR35546 . This // can probably be removed after the bug has been fixed for a while. #ifdef HAVE_TEMPLATE_ATTRIBUTES @@ -357,8 +259,8 @@ inline bool is_cident(const char* name) { return (name[strspn(name, - ("0123456789" - "ABCDEFGHIJKLMNOPWRSTUVWXYZ" + ("0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "_"))] == '\0');