1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-05-17 10:45:18 +02:00
libunwind-eh_elf/src/mi/_ReadSLEB.c
Arun Sharma 781d5d5263 One time whitespace fixup.
for f in $(find src include -name '*.[ch]'); do
  expand -t 8 $f > $tmp; mv $tmp $f;
done
2014-09-27 09:47:23 -07:00

26 lines
472 B
C

#include <libunwind.h>
unw_word_t
_ReadSLEB (unsigned char **dpp)
{
unsigned shift = 0;
unw_word_t byte, result = 0;
unsigned char *bp = *dpp;
while (1)
{
byte = *bp++;
result |= (byte & 0x7f) << shift;
shift += 7;
if ((byte & 0x80) == 0)
break;
}
if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0)
/* sign-extend negative value */
result |= ((unw_word_t) -1) << shift;
*dpp = bp;
return result;
}