Add section_size_type and section_offset_type, use them to replace a

lot of instances of off_t.
This commit is contained in:
Ian Lance Taylor
2007-12-18 00:48:04 +00:00
parent 3d372cd7a1
commit 8383303e0a
22 changed files with 287 additions and 224 deletions

View File

@ -161,10 +161,7 @@ class Select_size_endian { };
#endif // !defined(HAVE_MEMBER_TEMPLATE_SPECIFICATIONS)
} // End namespace gold.
namespace gold
{
// General declarations.
class General_options;
class Command_line;
@ -180,6 +177,17 @@ class Output_file;
template<int size, bool big_endian>
struct Relocate_info;
// 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
// this will often be a 64-bit type even for a 32-bit build.
// 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;
// The name of the program as used in error messages.
extern const char* program_name;
@ -250,6 +258,22 @@ print_version(bool print_short);
extern const char*
get_version_string();
// 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(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); }
// Queue up the first set of tasks.
extern void
queue_initial_tasks(const General_options&,