15 #define ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0]))
17 #define SECONDS_TO_NANOSECONDS(seconds) ((seconds)*(1000000000))
19 #define ASSERT_OK(label, expr) if((r = expr) != RESULT_OK) { \
20 printf("assertion failed at %s:%d: result 0x%x is not OK\n", __FILE__, __LINE__, r); \
24 #define LIB_ASSERT_OK(label, expr) if((r = expr) != RESULT_OK) { goto label; }
26 #define TRACE printf("tracing at %s:%d\n", __FILE__, __LINE__);
27 #define DBG_TRACE dbg_printf("tracing at %s:%d", __FILE__, __LINE__);
34 uint64_t
str2u64(
const char *str);
51 void hexdump(
const void *rawbuf,
size_t size);
81 int log_string(
const char *
string,
size_t len);
109 #define STB_SPRINTF_DECORATE(name) dbg_##name
110 #include "stb_sprintf.h"
114 int dbg_printf(
char const *fmt, ...);
115 int dbg_vprintf(
char const *fmt, va_list va);
void hexnum(int num)
Convert an int number to hex and prints it to stdout.
void dbg_disconnect()
Disconnect the debug log from the socket.
int trn_result_to_errno(result_t r)
Turns a libtransistor result_t into a POSIX errno. The POSIX errno will be positive. You might want to negate it before returning!
char nybble2hex(uint8_t nybble)
Convert a uint8 nybble to a hex char.
void hexdump_dbg(const void *rawbuf, size_t size)
Hexdump a buffer using the debug logger.
uint32_t result_t
Function result.
Definition: types.h:51
int log_string(const char *string, size_t len)
Log a string to the debug log.
result_t dbg_connect(const char *host, const char *port, int *fd)
Connect the debug log over a socket.
void hexdump(const void *rawbuf, size_t size)
Hexdump a buffer.
uint64_t str2u64(const char *str)
Converts a string to a u64.