merge from gcc
[deliverable/binutils-gdb.git] / gold / dwp.h
CommitLineData
77429909
CC
1// dwp.h -- general definitions for dwp.
2
3// Copyright 2012 Free Software Foundation, Inc.
4// Written by Cary Coutant <ccoutant@google.com>.
5
6// This file is part of dwp, the DWARF packaging utility.
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 DWP_DWP_H
24#define DWP_DWP_H 1
25
26#include "config.h"
27#include "ansidecl.h"
28
29#include <cstddef>
30#include <cstdlib>
31#include <cstring>
32#include <stdint.h>
33#include <sys/types.h>
34
35#include "system.h"
36
37namespace gold
38{
39
40extern const char* program_name;
41
42class General_options;
43class Command_line;
44class Dirsearch;
45class Input_objects;
46class Mapfile;
47class Symbol;
48class Symbol_table;
49class Layout;
50class Task;
51class Workqueue;
52class Output_file;
53template<int size, bool big_endian>
54struct Relocate_info;
55
56// The size of a section if we are going to look at the contents.
57typedef size_t section_size_type;
58
59// An offset within a section when we are looking at the contents.
60typedef ptrdiff_t section_offset_type;
61
62inline bool
63is_prefix_of(const char* prefix, const char* str)
64{
65 return strncmp(prefix, str, strlen(prefix)) == 0;
66}
67
68// Exit status codes.
69
70enum Exit_status
71{
72 GOLD_OK = EXIT_SUCCESS,
73 GOLD_ERR = EXIT_FAILURE,
74 GOLD_FALLBACK = EXIT_FAILURE + 1
75};
76
77// This function is called to exit the program. Status is true to
78// exit success (0) and false to exit failure (1).
79extern void
80gold_exit(Exit_status status) ATTRIBUTE_NORETURN;
81
82// This function is called to emit an error message and then
83// immediately exit with failure.
84extern void
85gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
86
87// This function is called to issue a warning.
88extern void
89gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
90
91#define gold_unreachable() \
92 (gold::do_gold_unreachable(__FILE__, __LINE__, \
93 static_cast<const char*>(__FUNCTION__)))
94
95extern void do_gold_unreachable(const char*, int, const char*)
96 ATTRIBUTE_NORETURN;
97
98// Assertion check.
99
100#define gold_assert(expr) ((void)(!(expr) ? gold_unreachable(), 0 : 0))
101
102// Convert numeric types without unnoticed loss of precision.
103template<typename To, typename From>
104inline To
105convert_types(const From from)
106{
107 To to = from;
108 gold_assert(static_cast<From>(to) == from);
109 return to;
110}
111
112// A common case of convert_types<>: convert to section_size_type.
113template<typename From>
114inline section_size_type
115convert_to_section_size_type(const From from)
116{ return convert_types<section_size_type, From>(from); }
117
118}; // End namespace gold.
119
120#endif // !defined(DWP_DWP_H)
This page took 0.056655 seconds and 4 git commands to generate.