From 36c7442db32c9c9d37fc4bb5999623a2fd443a0b Mon Sep 17 00:00:00 2001 From: "hp.com!davidm" Date: Tue, 20 Apr 2004 16:53:44 +0000 Subject: [PATCH] (Logical change 1.205) --- src/mi/_ReadSLEB.c | 25 +++++++++++++++++++++++++ src/mi/_ReadULEB.c | 20 ++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/mi/_ReadSLEB.c b/src/mi/_ReadSLEB.c index e69de29b..463abfd8 100644 --- a/src/mi/_ReadSLEB.c +++ b/src/mi/_ReadSLEB.c @@ -0,0 +1,25 @@ +#include + +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; + if ((byte & 0x80) == 0) + break; + shift += 7; + } + + if (shift < 8 * sizeof (unw_word_t) && (byte & 0x40) != 0) + /* sign-extend negative value */ + result |= ((unw_word_t) -1) << shift; + + *dpp = bp; + return result; +} diff --git a/src/mi/_ReadULEB.c b/src/mi/_ReadULEB.c index e69de29b..8952e635 100644 --- a/src/mi/_ReadULEB.c +++ b/src/mi/_ReadULEB.c @@ -0,0 +1,20 @@ +#include + +unw_word_t +_ReadULEB (unsigned char **dpp) +{ + unsigned shift = 0; + unw_word_t byte, result = 0; + unsigned char *bp = *dpp; + + while (1) + { + byte = *bp++; + result |= (byte & 0x7f) << shift; + if ((byte & 0x80) == 0) + break; + shift += 7; + } + *dpp = bp; + return result; +}