From 4d40a1cfc837cff6b7bb98f1fb6387c32f02dc29 Mon Sep 17 00:00:00 2001 From: "mostang.com!davidm" Date: Wed, 20 Aug 2003 18:02:30 +0000 Subject: [PATCH] (rotate_gr): Fix off-by-1 bug and simplify the function. (Logical change 1.93) --- src/ia64/regs.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ia64/regs.h b/src/ia64/regs.h index 4611edac..03e53559 100644 --- a/src/ia64/regs.h +++ b/src/ia64/regs.h @@ -1,26 +1,22 @@ #include "unwind_i.h" -/* Apply rotation to a general register. The number REG must be in - the range of 0-127. */ +/* Apply rotation to a general register. REG must be in the range 0-127. */ static inline int rotate_gr (struct cursor *c, int reg) { - unsigned int rrb_gr, sor, sof; + unsigned int rrb_gr, sor; int preg; - sof = (c->cfm & 0x7f); sor = 8 * ((c->cfm >> 14) & 0xf); rrb_gr = (c->cfm >> 18) & 0x7f; - if ((unsigned) (reg - 32) > sof) - return reg; /* not a valid stacked register: just return original value */ - else if ((unsigned) (reg - 32) > sor) - preg = reg; /* register not part of the rotating partition */ + if ((unsigned) (reg - 32) >= sor) + preg = reg; else { preg = reg + rrb_gr; /* apply rotation */ - if (preg > 32 + (int) sor) + if ((unsigned) (preg - 32) >= sor) preg -= sor; /* wrap around */ } if (sor)