From: Jens Remus Date: Tue, 13 Jan 2026 12:17:49 +0000 (+0100) Subject: gas: sframe: use standard min/max integer constants X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58008ed4e6afd77841c653eee60f60d621fa101a;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 4a70ae13ff5..b4e983957a1 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -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;