#ifndef _include_fail_h #define _include_fail_h #define INLINE __attribute__((always_inline)) inline #define NOINLINE __attribute__((noinline)) #define EXPORT(fnct) __attribute__((export_name(fnct))) #define IMPORT(fnct) __attribute__((import_module("env"), import_name(fnct))) #if !defined(TARGET_FAIL) && !defined(TARGET_LINUX_BAREMETAL) && \ !defined(TARGET_LINUX) // Set to linux while editing to prevent lsp errors #define TARGET_LINUX #endif #ifdef TARGET_FAIL #define MAIN void os_main(void) #define PRINT(fmt, ...) #define PRINT_ERROR(fmt, ...) #define PRINT_SUCCESS(fmt, ...) #define HOST_PRINT(msg) #define RET(val) return #endif #ifdef TARGET_LINUX_BAREMETAL #define MAIN int main(int argc, char *argv[]) #define PRINT(fmt, ...) #define PRINT_ERROR(fmt, ...) #define PRINT_SUCCESS(fmt, ...) #define HOST_PRINT(msg) #define RET(val) return #endif #ifdef TARGET_LINUX #define MAIN int main(int argc, char *argv[]) #define PRINT(fmt, ...) fprintf(stdout, fmt, ##__VA_ARGS__) #define PRINT_ERROR(fmt, ...) \ fprintf(stderr, "[Error] "); \ fprintf(stderr, fmt, ##__VA_ARGS__) #define PRINT_SUCCESS(fmt, ...) \ fprintf(stdout, "[Success] "); \ fprintf(stdout, fmt, ##__VA_ARGS__) #define HOST_PRINT(msg) print(msg) #define RET(val) return val; #endif #ifdef __cplusplus extern "C" { #endif // Those functions are defined in the host program void NOINLINE fail_start_trace(void); // Mark start of injection void NOINLINE fail_stop_trace(void); // Mark end of injection void NOINLINE fail_marker_positive(void); // Everything ok void NOINLINE fail_marker_detected(void); // Everything ok void NOINLINE fail_marker_negative(void); // Invalid code void NOINLINE print(const char *msg); #ifdef __cplusplus } #endif #endif