Go to the documentation of this file.
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
105 #define COLOR_BLUE 34
106 #define COLOR_MAGENTA 35
107 #define COLOR_CYAN 36
108 #define COLOR_WHITE 37
160 static inline
int imax(const
int a, const
int b)
162 return a >
b ?
a :
b;
165 static inline int imin(
const int a,
const int b)
167 return a <
b ?
a :
b;
173 fprintf(stderr,
"checkasm: out of memory\n");
int(* func)(AVBPrint *dst, const char *in, const char *arg)
volatile sig_atomic_t checkasm_interrupted
int checkasm_perf_validate_start(const CheckasmPerf *perf)
checkasm_jmp_buf checkasm_context
uint64_t checkasm_gettime_nsec(void)
int checkasm_perf_init(void)
void checkasm_measure_nop_cycles(CheckasmMeasurement *meas, uint64_t target_cycles)
CheckasmPerf checkasm_perf
void checkasm_fprintf(FILE *const f, const int color, const char *const fmt,...) CHECKASM_PRINTF(3
uint64_t checkasm_gettime_nsec_diff(uint64_t t)
Platform and compiler attribute macros.
static int imax(const int a, const int b)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
int checkasm_perf_init_linux(CheckasmPerf *perf)
void checkasm_json(CheckasmJson *json, const char *key, const char *fmt,...) CHECKASM_PRINTF(3
static void * checkasm_mallocz(const size_t size)
void checkasm_set_signal_handlers(void)
void checkasm_noop(void *)
void checkasm_measure_perf_scale(CheckasmMeasurement *meas)
static int imin(const int a, const int b)
int checkasm_perf_init_arm(CheckasmPerf *perf)
static char * checkasm_strdup(const char *str)
Test writing API for checkasm.
static void * checkasm_handle_oom(void *ptr)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
void checkasm_setup_fprintf(void)
int checkasm_perf_validate_start_stop(const CheckasmPerf *perf)
unsigned checkasm_seed(void)
NORETURN void checkasm_fail_abort(const char *msg,...) CHECKASM_PRINTF(1
void checkasm_srand(unsigned seed)
void checkasm_json_pop(CheckasmJson *json, char type)
void void checkasm_json_str(CheckasmJson *json, const char *key, const char *str)
void checkasm_json_push(CheckasmJson *json, const char *const key, char type)
int checkasm_run_on_all_cores(void(*func)(void))
const char * checkasm_get_last_signal_desc(void)
char * checkasm_vasprintf(const char *fmt, va_list arg)
int checkasm_perf_init_macos(CheckasmPerf *perf)
#define CHECKASM_PRINTF(fmt, attr)
Printf-style format string checking attribute.