xref: /dragonfly/contrib/binutils-2.27/gold/dwp.h (revision a9fa9459)
1 // dwp.h -- general definitions for dwp.
2 
3 // Copyright (C) 2012-2016 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 
37 namespace gold
38 {
39 
40 extern const char* program_name;
41 
42 class General_options;
43 class Command_line;
44 class Dirsearch;
45 class Input_objects;
46 class Mapfile;
47 class Symbol;
48 class Symbol_table;
49 class Layout;
50 class Task;
51 class Workqueue;
52 class Output_file;
53 template<int size, bool big_endian>
54 struct Relocate_info;
55 
56 // The size of a section if we are going to look at the contents.
57 typedef size_t section_size_type;
58 
59 // An offset within a section when we are looking at the contents.
60 typedef ptrdiff_t section_offset_type;
61 
62 inline bool
is_prefix_of(const char * prefix,const char * str)63 is_prefix_of(const char* prefix, const char* str)
64 {
65   return strncmp(prefix, str, strlen(prefix)) == 0;
66 }
67 
68 // Exit status codes.
69 
70 enum 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).
79 extern void
80 gold_exit(Exit_status status) ATTRIBUTE_NORETURN;
81 
82 // This function is called to emit an error message and then
83 // immediately exit with failure.
84 extern void
85 gold_fatal(const char* format, ...) ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_1;
86 
87 // This function is called to issue a warning.
88 extern void
89 gold_warning(const char* msg, ...) ATTRIBUTE_PRINTF_1;
90 
91 // This function is called to print an informational message.
92 extern void
93 gold_info(const char* msg, ...) ATTRIBUTE_PRINTF_1;
94 
95 #define gold_unreachable() \
96   (gold::do_gold_unreachable(__FILE__, __LINE__, \
97 			     static_cast<const char*>(__FUNCTION__)))
98 
99 extern void do_gold_unreachable(const char*, int, const char*)
100   ATTRIBUTE_NORETURN;
101 
102 // Assertion check.
103 
104 #define gold_assert(expr) ((void)(!(expr) ? gold_unreachable(), 0 : 0))
105 
106 // Convert numeric types without unnoticed loss of precision.
107 template<typename To, typename From>
108 inline To
convert_types(const From from)109 convert_types(const From from)
110 {
111   To to = from;
112   gold_assert(static_cast<From>(to) == from);
113   return to;
114 }
115 
116 // A common case of convert_types<>: convert to section_size_type.
117 template<typename From>
118 inline section_size_type
convert_to_section_size_type(const From from)119 convert_to_section_size_type(const From from)
120 { return convert_types<section_size_type, From>(from); }
121 
122 }; // End namespace gold.
123 
124 #endif // !defined(DWP_DWP_H)
125