mirror of
https://github.com/capstone-engine/capstone
synced 2026-08-11 16:26:07 -04:00
* Add workflow to check for C formatting Rename run-clang-tidy.sh for consistency with clang-format script Don't align trailing comments. It leads to unreproducable formatting. Reformat some comments leading in-compilable up code after clang-format Format generated compatibility header. Add clang-format script Be more verbose with clean-up scripts and fail early. Pass clang-format via command line Install clang-format for the HeaderPatcher * Format code with clang-format-17
38 lines
1.1 KiB
C++
38 lines
1.1 KiB
C++
//===- llvm/Support/LEB128.h - [SU]LEB128 utility functions -----*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file declares some utility functions for encoding SLEB128 and
|
|
// ULEB128 values.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
/* Capstone Disassembly Engine */
|
|
/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */
|
|
|
|
#ifndef CS_LLVM_SUPPORT_LEB128_H
|
|
#define CS_LLVM_SUPPORT_LEB128_H
|
|
|
|
#include "include/capstone/capstone.h"
|
|
|
|
/// Utility function to decode a ULEB128 value.
|
|
static inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n)
|
|
{
|
|
const uint8_t *orig_p = p;
|
|
uint64_t Value = 0;
|
|
unsigned Shift = 0;
|
|
do {
|
|
Value += (uint64_t)(*p & 0x7f) << Shift;
|
|
Shift += 7;
|
|
} while (*p++ >= 128);
|
|
if (n)
|
|
*n = (unsigned)(p - orig_p);
|
|
return Value;
|
|
}
|
|
|
|
#endif // LLVM_SYSTEM_LEB128_H
|