From 8383303e0acce6e4332e2a2097b832e2deb880ec Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 18 Dec 2007 00:48:04 +0000 Subject: Add section_size_type and section_offset_type, use them to replace a lot of instances of off_t. --- gold/gold.h | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'gold/gold.h') diff --git a/gold/gold.h b/gold/gold.h index 32fcc43..8ea24d2 100644 --- a/gold/gold.h +++ b/gold/gold.h @@ -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 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 +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 +inline section_size_type +convert_to_section_size_type(const From from) +{ return convert_types(from); } + // Queue up the first set of tasks. extern void queue_initial_tasks(const General_options&, -- cgit v1.1