/* Decode signed LEB128 data. The algorithm is taken from Appendix C of the DWARF 3 spec. Return the number of bytes read.  */
static unsigned long dwarf_read_leb128(char *addr, int *ret)
/* Decode signed LEB128 data. The algorithm is taken from Appendix C of the DWARF 3 spec. Return the number of bytes read.  */
static unsigned long dwarf_read_leb128(char *addr, int *ret)
{
	unsigned char byte;
	int result, shift;
	int num_bits;
	int count;
	result = 0;
	shift = 0;
	count = 0;
	while (1) {
		byte = __raw_readb(addr);
		addr++;
		result |= (byte & 0x7f) << shift;
		shift += 7;
		count++;
		if (!(byte & 0x80))
			break;
	}
	num_bits = 8 * sizeof(result);
	if ((shift < num_bits) && (byte & 0x40))
		result |= (-1 << shift);
	*ret = result;
	return count;
}