mirror of
https://github.com/bminor/binutils-gdb.git
synced 2026-02-04 10:21:30 +00:00
gas: sframe: use standard min/max integer constants
Replace the use of custom VALUE_{8|16|32|64}BIT constant definitions
with the standard INT{8|16|32|64}_{MIN|MAX} ones from stdint.h.
Besides improving readability this also fixes the issue that the
smallest representable signed 8/16/32-bit integer value was
erroneously sized as the next larger integer type. For example
get_offset_size_in_bytes (INT8_MIN) returned 2 instead of 1, due
to INT8_MIN (= -128) != -VALUE_8BIT (= -127):
(gdb) call get_offset_size_in_bytes (-127)
$1 = 1
(gdb) call get_offset_size_in_bytes (-128)
$2 = 2
gas/
* gen-sframe.c (VALUE_8BIT, VALUE_16BIT, VALUE_32BIT,
VALUE_64BIT): Remove.
(get_offset_size_in_bytes): Use standard min/max integer
constants.
Signed-off-by: Jens Remus <jremus@linux.ibm.com>
This commit is contained in:
@@ -197,15 +197,6 @@ sframe_fre_set_fp_track (struct sframe_row_entry *fre, offsetT fp_offset)
|
||||
fre->merge_candidate = false;
|
||||
}
|
||||
|
||||
/* All stack offset values within an FRE are uniformly encoded in the same
|
||||
number of bytes. The size of the stack offset values will, however, vary
|
||||
across FREs. */
|
||||
|
||||
#define VALUE_8BIT 0x7f
|
||||
#define VALUE_16BIT 0x7fff
|
||||
#define VALUE_32BIT 0x7fffffff
|
||||
#define VALUE_64BIT 0x7fffffffffffffff
|
||||
|
||||
/* Given a signed offset, return the size in bytes needed to represent it. */
|
||||
|
||||
static unsigned int
|
||||
@@ -213,14 +204,13 @@ get_offset_size_in_bytes (offsetT value)
|
||||
{
|
||||
unsigned int size = 0;
|
||||
|
||||
if (value <= VALUE_8BIT && value >= (offsetT) -VALUE_8BIT)
|
||||
if (value <= INT8_MAX && value >= INT8_MIN)
|
||||
size = 1;
|
||||
else if (value <= VALUE_16BIT && value >= (offsetT) -VALUE_16BIT)
|
||||
else if (value <= INT16_MAX && value >= INT16_MIN)
|
||||
size = 2;
|
||||
else if (value <= VALUE_32BIT && value >= (offsetT) -VALUE_32BIT)
|
||||
else if (value <= INT32_MAX && value >= INT32_MIN)
|
||||
size = 4;
|
||||
else if ((sizeof (offsetT) > 4) && (value <= (offsetT) VALUE_64BIT
|
||||
&& value >= (offsetT) -VALUE_64BIT))
|
||||
else if ((sizeof (offsetT) > 4) && (value <= INT64_MAX && value >= INT64_MIN))
|
||||
size = 8;
|
||||
|
||||
return size;
|
||||
|
||||
Reference in New Issue
Block a user