Intel® X86 Encoder Decoder
xed-util.h File Reference
#include "xed-common-hdrs.h"
#include "xed-types.h"
#include "xed-portability.h"
#include <stdlib.h>
#include <stdio.h>

Macros

#define XED2DIE(x)   do { xed_assert(0); } while(0)
 
#define XED2IMSG(x)
 
#define XED2TMSG(x)
 
#define XED2VMSG(x)
 
#define xed_assert(x)   do { } while(0)
 
#define XED_EMIT_MESSAGES   (0)
 
#define XED_FUNCNAME   ""
 
#define XED_INFO2_VERBOSE   (0)
 
#define XED_INFO_VERBOSE   (0)
 
#define XED_MORE_VERBOSE   (0)
 
#define XED_VERBOSE   (0)
 
#define XED_VERY_VERBOSE   (0)
 
API Input Validation

Macros for validating API inputs at function boundaries

These macros provide runtime validation of API inputs with minimal overhead. They are enabled by default and can be disabled with the –no-api-check build flag. When disabled, they compile to no-ops that suppress unused variable warnings.

#define api_check(cond)   do { (void)(cond); } while(0)
 When API checks are disabled, cast to void to suppress warnings. More...
 

Typedefs

typedef void(* xed_user_abort_function_t) (const char *msg, const char *file, int line, void *other)
 

Functions

XED_DLL_EXPORT xed_uint8_t xed_get_byte (xed_uint64_t x, unsigned int i, unsigned int len)
 
XED_NORETURN XED_NOINLINE XED_DLL_EXPORT void xed_internal_assert (const char *s, const char *file, int line)
 
XED_DLL_EXPORT int xed_itoa (char *buf, xed_uint64_t f, int buflen)
 
XED_DLL_EXPORT int xed_itoa_bin (char *buf, xed_uint64_t f, xed_uint_t bits_to_print, xed_uint_t buflen)
 Convert the input value f into its binary representation as a string and store it in buf. More...
 
XED_DLL_EXPORT int xed_itoa_hex (char *buf, xed_uint64_t f, xed_uint_t bits_to_print, int buflen)
 defaults to lowercase More...
 
XED_DLL_EXPORT int xed_itoa_hex_ul (char *buf, xed_uint64_t f, xed_uint_t bits_to_print, xed_bool_t leading_zeros, int buflen, xed_bool_t lowercase)
 
XED_DLL_EXPORT int xed_itoa_hex_zeros (char *buf, xed_uint64_t f, xed_uint_t bits_to_print, xed_bool_t leading_zeros, int buflen)
 defaults to lowercase More...
 
static XED_INLINE xed_int64_t xed_make_int64 (xed_uint32_t hi, xed_uint32_t lo)
 
static XED_INLINE xed_uint64_t xed_make_uint64 (xed_uint32_t hi, xed_uint32_t lo)
 
XED_DLL_EXPORT void xed_register_abort_function (xed_user_abort_function_t fn, void *other)
 
XED_DLL_EXPORT void xed_set_log_file (void *o)
 Set the FILE* for XED's log msgs. More...
 
XED_DLL_EXPORT void xed_set_verbosity (int v)
 Set the verbosity level for XED. More...
 
XED_DLL_EXPORT xed_uint_t xed_shortest_width_signed (xed_int64_t x, xed_uint8_t legal_widths)
 returns the number of bytes required to store the SIGNED number x given a mask of legal lengths. More...
 
XED_DLL_EXPORT xed_uint_t xed_shortest_width_unsigned (xed_uint64_t x, xed_uint8_t legal_widths)
 returns the number of bytes required to store the UNSIGNED number x given a mask of legal lengths. More...
 
XED_DLL_EXPORT xed_int32_t xed_sign_extend16_32 (xed_int16_t x)
 
XED_DLL_EXPORT xed_int64_t xed_sign_extend16_64 (xed_int16_t x)
 
XED_DLL_EXPORT xed_int64_t xed_sign_extend32_64 (xed_int32_t x)
 
XED_DLL_EXPORT xed_int16_t xed_sign_extend8_16 (xed_int8_t x)
 
XED_DLL_EXPORT xed_int32_t xed_sign_extend8_32 (xed_int8_t x)
 
XED_DLL_EXPORT xed_int64_t xed_sign_extend8_64 (xed_int8_t x)
 
XED_DLL_EXPORT xed_int32_t xed_sign_extend_arbitrary_to_32 (xed_uint32_t x, unsigned int bits)
 arbitrary sign extension from a qty of "bits" length to 32b More...
 
XED_DLL_EXPORT xed_int64_t xed_sign_extend_arbitrary_to_64 (xed_uint64_t x, unsigned int bits)
 arbitrary sign extension from a qty of "bits" length to 64b More...
 
XED_DLL_EXPORT xed_uint32_t xed_zero_extend16_32 (xed_uint16_t x)
 
XED_DLL_EXPORT xed_uint64_t xed_zero_extend16_64 (xed_uint16_t x)
 
XED_DLL_EXPORT xed_uint64_t xed_zero_extend32_64 (xed_uint32_t x)
 
XED_DLL_EXPORT xed_uint16_t xed_zero_extend8_16 (xed_uint8_t x)
 
XED_DLL_EXPORT xed_uint32_t xed_zero_extend8_32 (xed_uint8_t x)
 
XED_DLL_EXPORT xed_uint64_t xed_zero_extend8_64 (xed_uint8_t x)
 

Variables

int xed_verbose
 

Macro Definition Documentation

◆ api_check

#define api_check (   cond)    do { (void)(cond); } while(0)

When API checks are disabled, cast to void to suppress warnings.

◆ XED2DIE

#define XED2DIE (   x)    do { xed_assert(0); } while(0)

◆ XED2IMSG

#define XED2IMSG (   x)

◆ XED2TMSG

#define XED2TMSG (   x)

◆ XED2VMSG

#define XED2VMSG (   x)

◆ xed_assert

#define xed_assert (   x)    do { } while(0)

◆ XED_EMIT_MESSAGES

#define XED_EMIT_MESSAGES   (0)

◆ XED_FUNCNAME

#define XED_FUNCNAME   ""

◆ XED_INFO2_VERBOSE

#define XED_INFO2_VERBOSE   (0)

◆ XED_INFO_VERBOSE

#define XED_INFO_VERBOSE   (0)

◆ XED_MORE_VERBOSE

#define XED_MORE_VERBOSE   (0)

◆ XED_VERBOSE

#define XED_VERBOSE   (0)

◆ XED_VERY_VERBOSE

#define XED_VERY_VERBOSE   (0)

Typedef Documentation

◆ xed_user_abort_function_t

typedef void(* xed_user_abort_function_t) (const char *msg, const char *file, int line, void *other)

Function Documentation

◆ xed_get_byte()

XED_DLL_EXPORT xed_uint8_t xed_get_byte ( xed_uint64_t  x,
unsigned int  i,
unsigned int  len 
)

◆ xed_internal_assert()

XED_NORETURN XED_NOINLINE XED_DLL_EXPORT void xed_internal_assert ( const char *  s,
const char *  file,
int  line 
)

◆ xed_itoa()

XED_DLL_EXPORT int xed_itoa ( char *  buf,
xed_uint64_t  f,
int  buflen 
)

◆ xed_itoa_bin()

XED_DLL_EXPORT int xed_itoa_bin ( char *  buf,
xed_uint64_t  f,
xed_uint_t  bits_to_print,
xed_uint_t  buflen 
)

Convert the input value f into its binary representation as a string and store it in buf.

Parameters
bufPointer to the character array where the binary representation will be stored.
fInput value to be converted.
bits_to_printNumber of bits to print (limited to 64 bits).
buflenLength of the buf array.
Returns
The number of characters actually copied (excluding the null terminator).

◆ xed_itoa_hex()

XED_DLL_EXPORT int xed_itoa_hex ( char *  buf,
xed_uint64_t  f,
xed_uint_t  bits_to_print,
int  buflen 
)

defaults to lowercase

◆ xed_itoa_hex_ul()

XED_DLL_EXPORT int xed_itoa_hex_ul ( char *  buf,
xed_uint64_t  f,
xed_uint_t  bits_to_print,
xed_bool_t  leading_zeros,
int  buflen,
xed_bool_t  lowercase 
)

◆ xed_itoa_hex_zeros()

XED_DLL_EXPORT int xed_itoa_hex_zeros ( char *  buf,
xed_uint64_t  f,
xed_uint_t  bits_to_print,
xed_bool_t  leading_zeros,
int  buflen 
)

defaults to lowercase

◆ xed_make_int64()

static XED_INLINE xed_int64_t xed_make_int64 ( xed_uint32_t  hi,
xed_uint32_t  lo 
)
static

◆ xed_make_uint64()

static XED_INLINE xed_uint64_t xed_make_uint64 ( xed_uint32_t  hi,
xed_uint32_t  lo 
)
static

◆ xed_set_log_file()

XED_DLL_EXPORT void xed_set_log_file ( void *  o)

Set the FILE* for XED's log msgs.

This takes a FILE* as a void* because some software defines their own FILE* types creating conflicts.

◆ xed_set_verbosity()

XED_DLL_EXPORT void xed_set_verbosity ( int  v)

Set the verbosity level for XED.

◆ xed_shortest_width_signed()

XED_DLL_EXPORT xed_uint_t xed_shortest_width_signed ( xed_int64_t  x,
xed_uint8_t  legal_widths 
)

returns the number of bytes required to store the SIGNED number x given a mask of legal lengths.

For the legal_widths argument, bit 0 implies 1 byte is a legal return width, bit 1 implies that 2 bytes is a legal return width, bit 2 implies that 4 bytes is a legal return width. This returns 8 (indicating 8B) if none of the provided legal widths applies.

◆ xed_shortest_width_unsigned()

XED_DLL_EXPORT xed_uint_t xed_shortest_width_unsigned ( xed_uint64_t  x,
xed_uint8_t  legal_widths 
)

returns the number of bytes required to store the UNSIGNED number x given a mask of legal lengths.

For the legal_widths argument, bit 0 implies 1 byte is a legal return width, bit 1 implies that 2 bytes is a legal return width, bit 2 implies that 4 bytes is a legal return width. This returns 8 (indicating 8B) if none of the provided legal widths applies.

◆ xed_sign_extend16_32()

XED_DLL_EXPORT xed_int32_t xed_sign_extend16_32 ( xed_int16_t  x)

◆ xed_sign_extend16_64()

XED_DLL_EXPORT xed_int64_t xed_sign_extend16_64 ( xed_int16_t  x)

◆ xed_sign_extend32_64()

XED_DLL_EXPORT xed_int64_t xed_sign_extend32_64 ( xed_int32_t  x)

◆ xed_sign_extend8_16()

XED_DLL_EXPORT xed_int16_t xed_sign_extend8_16 ( xed_int8_t  x)

◆ xed_sign_extend8_32()

XED_DLL_EXPORT xed_int32_t xed_sign_extend8_32 ( xed_int8_t  x)

◆ xed_sign_extend8_64()

XED_DLL_EXPORT xed_int64_t xed_sign_extend8_64 ( xed_int8_t  x)

◆ xed_sign_extend_arbitrary_to_32()

XED_DLL_EXPORT xed_int32_t xed_sign_extend_arbitrary_to_32 ( xed_uint32_t  x,
unsigned int  bits 
)

arbitrary sign extension from a qty of "bits" length to 32b

◆ xed_sign_extend_arbitrary_to_64()

XED_DLL_EXPORT xed_int64_t xed_sign_extend_arbitrary_to_64 ( xed_uint64_t  x,
unsigned int  bits 
)

arbitrary sign extension from a qty of "bits" length to 64b

◆ xed_zero_extend16_32()

XED_DLL_EXPORT xed_uint32_t xed_zero_extend16_32 ( xed_uint16_t  x)

◆ xed_zero_extend16_64()

XED_DLL_EXPORT xed_uint64_t xed_zero_extend16_64 ( xed_uint16_t  x)

◆ xed_zero_extend32_64()

XED_DLL_EXPORT xed_uint64_t xed_zero_extend32_64 ( xed_uint32_t  x)

◆ xed_zero_extend8_16()

XED_DLL_EXPORT xed_uint16_t xed_zero_extend8_16 ( xed_uint8_t  x)

◆ xed_zero_extend8_32()

XED_DLL_EXPORT xed_uint32_t xed_zero_extend8_32 ( xed_uint8_t  x)

◆ xed_zero_extend8_64()

XED_DLL_EXPORT xed_uint64_t xed_zero_extend8_64 ( xed_uint8_t  x)

Variable Documentation

◆ xed_verbose

int xed_verbose