/* Utilities for reading leb128 values.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
This file is part of the libiberty library.
Libiberty is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
Libiberty is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with libiberty; see the file COPYING.LIB. If not, write
to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
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".
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
/* Get a definition for inline. */
#include "ansidecl.h"
/* Get a definition for NULL, size_t. */
#include <stddef.h>
/* 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,
and nothing is stored in R.
Note: The result is an int instead of a pointer to the next byte to be
read to avoid const-vs-non-const problems. */
/* Decode the signed 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,
and nothing is stored in R.
Note: The result is an int instead of a pointer to the next byte to be
read to avoid const-vs-non-const problems. */