mirror of
https://github.com/tobast/libunwind-eh_elf.git
synced 2024-11-23 07:57:38 +01:00
(rotate_gr): Fix off-by-1 bug and simplify the function.
(Logical change 1.93)
This commit is contained in:
parent
0b65016a37
commit
4d40a1cfc8
1 changed files with 5 additions and 9 deletions
|
@ -1,26 +1,22 @@
|
||||||
#include "unwind_i.h"
|
#include "unwind_i.h"
|
||||||
|
|
||||||
/* Apply rotation to a general register. The number REG must be in
|
/* Apply rotation to a general register. REG must be in the range 0-127. */
|
||||||
the range of 0-127. */
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
rotate_gr (struct cursor *c, int reg)
|
rotate_gr (struct cursor *c, int reg)
|
||||||
{
|
{
|
||||||
unsigned int rrb_gr, sor, sof;
|
unsigned int rrb_gr, sor;
|
||||||
int preg;
|
int preg;
|
||||||
|
|
||||||
sof = (c->cfm & 0x7f);
|
|
||||||
sor = 8 * ((c->cfm >> 14) & 0xf);
|
sor = 8 * ((c->cfm >> 14) & 0xf);
|
||||||
rrb_gr = (c->cfm >> 18) & 0x7f;
|
rrb_gr = (c->cfm >> 18) & 0x7f;
|
||||||
|
|
||||||
if ((unsigned) (reg - 32) > sof)
|
if ((unsigned) (reg - 32) >= sor)
|
||||||
return reg; /* not a valid stacked register: just return original value */
|
preg = reg;
|
||||||
else if ((unsigned) (reg - 32) > sor)
|
|
||||||
preg = reg; /* register not part of the rotating partition */
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
preg = reg + rrb_gr; /* apply rotation */
|
preg = reg + rrb_gr; /* apply rotation */
|
||||||
if (preg > 32 + (int) sor)
|
if ((unsigned) (preg - 32) >= sor)
|
||||||
preg -= sor; /* wrap around */
|
preg -= sor; /* wrap around */
|
||||||
}
|
}
|
||||||
if (sor)
|
if (sor)
|
||||||
|
|
Loading…
Reference in a new issue