summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authordevans <devans@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-23 23:42:25 +0000
committerdevans <devans@138bc75d-0d04-0410-961f-82ee72b054a4>2012-05-23 23:42:25 +0000
commit73e554b766960625ed2ebcc024ec8f92434bd337 (patch)
tree0e8345ced8e876bd6d2b29c9b317a2e4141219b7 /include
parent9d68bc02ec949da1fd226477e8138921babbeb0a (diff)
downloadppe42-gcc-73e554b766960625ed2ebcc024ec8f92434bd337.tar.gz
ppe42-gcc-73e554b766960625ed2ebcc024ec8f92434bd337.zip
* leb128.h: #include stdint.h, inttypes.h.
(read_uleb128_to_uint64): Renamed from read_uleb128_to_ull. Change to take a uint64_t * argument instead of unsigned long long. (read_sleb128_to_uint64): Renamed from read_sleb128_to_ll. Change to take an int64_t * argument instead of long long. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187818 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog8
-rw-r--r--include/leb128.h32
2 files changed, 30 insertions, 10 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index 65b34080a88..fd8bdc97001 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,11 @@
+2012-05-23 Doug Evans <dje@google.com>
+
+ * leb128.h: #include stdint.h, inttypes.h.
+ (read_uleb128_to_uint64): Renamed from read_uleb128_to_ull.
+ Change to take a uint64_t * argument instead of unsigned long long.
+ (read_sleb128_to_uint64): Renamed from read_sleb128_to_ll.
+ Change to take an int64_t * argument instead of long long.
+
2012-05-22 Doug Evans <dje@google.com>
* leb128.h: New file.
diff --git a/include/leb128.h b/include/leb128.h
index f0ff3520bea..f584f72e5a9 100644
--- a/include/leb128.h
+++ b/include/leb128.h
@@ -19,7 +19,12 @@ Boston, MA 02110-1301, USA. */
/* The functions defined here can be speed critical.
Since they are all pretty small we keep things simple and just define
- them all as "static inline". */
+ them all as "static inline".
+
+ WARNING: This file is used by GDB which is stuck at C90. :-(
+ Though it can use stdint.h, inttypes.h.
+ Therefore if you want to add support for "long long" you need
+ to wrap it in #ifdef CC_HAS_LONG_LONG. */
#ifndef LEB128_H
#define LEB128_H
@@ -30,6 +35,13 @@ Boston, MA 02110-1301, USA. */
/* Get a definition for NULL, size_t. */
#include <stddef.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
/* Decode the unsigned LEB128 constant at BUF into the variable pointed to
by R, and return the number of bytes read.
If we read off the end of the buffer, zero is returned,
@@ -39,12 +51,12 @@ Boston, MA 02110-1301, USA. */
read to avoid const-vs-non-const problems. */
static inline size_t
-read_uleb128_to_ull (const unsigned char *buf, const unsigned char *buf_end,
- unsigned long long *r)
+read_uleb128_to_uint64 (const unsigned char *buf, const unsigned char *buf_end,
+ uint64_t *r)
{
const unsigned char *p = buf;
unsigned int shift = 0;
- unsigned long long result = 0;
+ uint64_t result = 0;
unsigned char byte;
while (1)
@@ -53,7 +65,7 @@ read_uleb128_to_ull (const unsigned char *buf, const unsigned char *buf_end,
return 0;
byte = *p++;
- result |= ((unsigned long long) (byte & 0x7f)) << shift;
+ result |= ((uint64_t) (byte & 0x7f)) << shift;
if ((byte & 0x80) == 0)
break;
shift += 7;
@@ -72,12 +84,12 @@ read_uleb128_to_ull (const unsigned char *buf, const unsigned char *buf_end,
read to avoid const-vs-non-const problems. */
static inline size_t
-read_sleb128_to_ll (const unsigned char *buf, const unsigned char *buf_end,
- long long *r)
+read_sleb128_to_int64 (const unsigned char *buf, const unsigned char *buf_end,
+ int64_t *r)
{
const unsigned char *p = buf;
unsigned int shift = 0;
- long long result = 0;
+ int64_t result = 0;
unsigned char byte;
while (1)
@@ -86,13 +98,13 @@ read_sleb128_to_ll (const unsigned char *buf, const unsigned char *buf_end,
return 0;
byte = *p++;
- result |= ((unsigned long long) (byte & 0x7f)) << shift;
+ result |= ((uint64_t) (byte & 0x7f)) << shift;
shift += 7;
if ((byte & 0x80) == 0)
break;
}
if (shift < (sizeof (*r) * 8) && (byte & 0x40) != 0)
- result |= -(((unsigned long long) 1) << shift);
+ result |= -(((uint64_t) 1) << shift);
*r = result;
return p - buf;
OpenPOWER on IntegriCloud