summaryrefslogtreecommitdiffstats
path: root/libsyscalls_section_value.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsyscalls_section_value.c')
-rw-r--r--libsyscalls_section_value.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libsyscalls_section_value.c b/libsyscalls_section_value.c
index dc86cca..6cdb787 100644
--- a/libsyscalls_section_value.c
+++ b/libsyscalls_section_value.c
@@ -4,9 +4,11 @@
enum libsyscalls_error
libsyscalls_section_value(unsigned long long int value_in, size_t bits,
- enum libsyscalls_datatype_section section, unsigned long long int *value_out)
+ enum libsyscalls_datatype_section section,
+ unsigned long long int *value_out)
{
unsigned long long int value = value_in, mask, shift;
+ size_t hbits;
if (bits > sizeof(value) / sizeof(char) * CHAR_BIT ||
bits & (size_t)(LIBSYSCALLS_GET_SECTION_FRACTION(section) - 1U))
@@ -43,14 +45,18 @@ libsyscalls_section_value(unsigned long long int value_in, size_t bits,
break;
case LIBSYSCALLS_SECTION_OUTER_HALF: /* 0xFFFF00000000FFFF */
- value = ((value & (mask << (bits + bits / 2))) >> bits) | (value & (mask >> (bits / 2)));
+ hbits = bits / 2;
+ value = ((value & (mask << (bits + hbits))) >> bits)
+ | (value & (mask >> hbits));
break;
case LIBSYSCALLS_SECTION_ODD_QUARTERS_AS_HALF: /* 0xFFFF0000FFFF0000 */
value >>= bits / 2;
/* fall through */
case LIBSYSCALLS_SECTION_EVEN_QUARTERS_AS_HALF: /* 0x0000FFFF0000FFFF */
- value = ((value & (mask << (bits / 2)) & ~mask) >> (bits / 2)) | (value & (mask >> (bits / 2)));
+ hbits = bits / 2;
+ value = ((value & (mask << hbits) & ~mask) >> hbits)
+ | (value & (mask >> hbits));
break;
case LIBSYSCALLS_SECTION_ODD_BYTES_AS_HALF: /* 0xFF00FF00FF00FF00 */