1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-06-30 21:21:45 +02:00

(rotate_gr): Fix off-by-1 bug and simplify the function.

(Logical change 1.93)
This commit is contained in:
mostang.com!davidm 2003-08-20 18:02:30 +00:00
parent 0b65016a37
commit 4d40a1cfc8

View file

@ -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)