30#ifndef CHECKASM_INTERNAL_H
31#define CHECKASM_INTERNAL_H
45 #define COLD __attribute__((cold))
50#ifndef __has_attribute
51 #define __has_attribute(x) 0
55 #define NOINLINE __declspec(noinline)
56#elif __has_attribute(noclone)
57 #define NOINLINE __attribute__((noinline, noclone))
59 #define NOINLINE __attribute__((noinline))
63 #define NORETURN __declspec(noreturn)
65 #include <stdnoreturn.h>
66 #define NORETURN noreturn
70 #define ALWAYS_INLINE __forceinline
72 #define ALWAYS_INLINE inline __attribute__((always_inline))
76 #define THREAD_LOCAL __thread
78 #define THREAD_LOCAL _Thread_local
81#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
84 #define PACKED(...) __pragma(pack(push, 1)) __VA_ARGS__ __pragma(pack(pop))
86 #define PACKED(...) __VA_ARGS__ __attribute__((__packed__))
89#if __has_attribute(fallthrough)
90 #define FALLTHROUGH __attribute__((fallthrough))
92 #define FALLTHROUGH do {} while (0)
101#define COLOR_DEFAULT -1
103#define COLOR_GREEN 32
104#define COLOR_YELLOW 33
106#define COLOR_MAGENTA 35
108#define COLOR_WHITE 37
125#define LOG_COLOR(...) checkasm_fprintf(stderr, __VA_ARGS__)
126#define LOG(...) LOG_COLOR(COLOR_DEFAULT, __VA_ARGS__)
177static inline
int imax(const
int a, const
int b)
179 return a >
b ?
a :
b;
182static inline int imin(
const int a,
const int b)
184 return a <
b ?
a :
b;
190 fprintf(stderr,
"checkasm: out of memory\n");
int checkasm_run_on_all_cores(void(*func)(void))
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Test writing API for checkasm.
Platform and compiler attribute macros.
#define CHECKASM_PRINTF(fmt, attr)
Printf-style format string checking attribute.
static char * checkasm_strdup(const char *str)
uint64_t checkasm_gettime_nsec_diff(uint64_t t)
static void * checkasm_mallocz(const size_t size)
int checkasm_perf_init(void)
static int imin(const int a, const int b)
void checkasm_srand(unsigned seed)
uint64_t checkasm_gettime_nsec(void)
void checkasm_json(CheckasmJson *json, const char *key, const char *fmt,...) CHECKASM_PRINTF(3
int checkasm_perf_init_macos(CheckasmPerf *perf)
int checkasm_vfprintf(FILE *const f, int color, const char *fmt, va_list arg) CHECKASM_PRINTF(3
void checkasm_set_signal_handlers(void)
void checkasm_noop(void *)
checkasm_jmp_buf checkasm_context
int checkasm_perf_init_linux(CheckasmPerf *perf)
static int imax(const int a, const int b)
const char * checkasm_get_last_signal_desc(void)
void checkasm_json_pop(CheckasmJson *json, char type)
void checkasm_statusline(const char *status)
unsigned checkasm_seed(void)
int checkasm_perf_validate_start_stop(const CheckasmPerf *perf)
void checkasm_json_push(CheckasmJson *json, const char *const key, char type)
NORETURN void checkasm_fail_abort(const char *msg,...) CHECKASM_PRINTF(1
void checkasm_setup_fprintf(void)
static void * checkasm_handle_oom(void *ptr)
int static int checkasm_fprintf(FILE *const f, int color, const char *fmt,...)
char * checkasm_vasprintf(const char *fmt, va_list arg)
CheckasmPerf checkasm_perf
void void checkasm_json_str(CheckasmJson *json, const char *key, const char *str)
void checkasm_measure_nop_cycles(CheckasmMeasurement *meas, uint64_t target_cycles)
int checkasm_perf_init_arm(CheckasmPerf *perf)
volatile sig_atomic_t checkasm_interrupted
void checkasm_measure_perf_scale(CheckasmMeasurement *meas)
int checkasm_perf_validate_start(const CheckasmPerf *perf)