/*========================== begin_copyright_notice ============================
Copyright (C) 2021-2024 Intel Corporation

SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/

#ifndef GTREPLAY_ASSERT_H
#define GTREPLAY_ASSERT_H

#include "gtreplay_crt.h"

void internalWarning(const char* msg);
void internalWarning(std::string msg);
void internalError(std::string msg, int line, const char* function);
void internalError(const char* expr, int line, const char* function);
void internalError(const char* expr, std::string msg, int line, const char* function);


#define GTREPLAY_ASSERT(x)               do { if (( x ) == 0) { internalError( #x, __LINE__, __FUNCTION__); exit(EXIT_FAILURE); } } while(0)
#define GTREPLAY_ASSERT_MSG(x, msg)      do { if (( x ) == 0) { internalError( #x, msg, __LINE__, __FUNCTION__); exit(EXIT_FAILURE); } } while(0)

#define GTREPLAY_ERROR()                 do { internalError(NULL, __LINE__, __FUNCTION__); exit(EXIT_FAILURE); } while(0) //the exit is to enforce noreturn attribute
#define GTREPLAY_ERROR_MSG(msg)          do { internalError(msg, __LINE__, __FUNCTION__); exit(EXIT_FAILURE); } while(0) //the exit is to enforce noreturn attribute

#define GTREPLAY_WARNING(msg)            do { internalWarning(msg); } while(0)

#endif // GTREPLAY_ASSERT_H
