Files
KytyPS5/src/common/assert.h
T
Mehmet Cambaz c2189de88f controller: give the DualShock 4 the DualSense pad path and release p… (#453)
controller: give the DualShock 4 the DualSense pad path and release pads on exit
2026-09-04 00:10:57 +02:00

64 lines
2.9 KiB
C++

#ifndef KYTY_COMMON_ASSERT_H_
#define KYTY_COMMON_ASSERT_H_
#include "common/common.h"
#include "common/logging/log.h"
#include <cstdlib>
#include <string_view>
namespace Common {
#ifdef __clang__
int DbgExitHandler(char const* file, int line, std::string_view text)
__attribute__((analyzer_noreturn));
int DbgExitHandler(char const* file, int line, fmt::text_style style, std::string_view text)
__attribute__((analyzer_noreturn));
int DbgExitIfHandler(char const* expr, char const* file, int line)
__attribute__((analyzer_noreturn));
int DbgNotImplementedHandler(char const* expr, char const* file, int line)
__attribute__((analyzer_noreturn));
void DbgExit(int status) __attribute__((analyzer_noreturn));
#else
int DbgExitHandler(char const* file, int line, std::string_view text);
int DbgExitHandler(char const* file, int line, fmt::text_style style, std::string_view text);
int DbgExitIfHandler(char const* expr, char const* file, int line);
int DbgNotImplementedHandler(char const* expr, char const* file, int line);
void DbgExit(int status);
#endif
} // namespace Common
#define EXIT_HALT() (Common::DbgExit(321), 1)
#ifndef KYTY_FINAL
#define EXIT_IF(x) \
((void)((x) && Common::DbgExitIfHandler(#x, __FILE__, __LINE__) != 0 && (EXIT_HALT(), 1) != 0))
#else
#define EXIT_IF(x) \
do { \
constexpr bool kyty_exit_if_disabled = false && (x); \
(void)kyty_exit_if_disabled; \
} while (0)
#endif
#define EXIT(...) \
do { \
((void)(Common::DbgExitHandler(__FILE__, __LINE__, ::fmt::sprintf(__VA_ARGS__)) && \
(EXIT_HALT(), 1))); \
} while (0)
#define EXIT_COLOR(style, ...) \
do { \
((void)(Common::DbgExitHandler(__FILE__, __LINE__, (style), \
::fmt::sprintf(__VA_ARGS__)) && \
(EXIT_HALT(), 1))); \
} while (0)
#define EXIT_NOT_IMPLEMENTED(x) \
((void)((x) && Common::DbgNotImplementedHandler(#x, __FILE__, __LINE__) != 0 && \
(EXIT_HALT(), 1) != 0))
#define KYTY_NOT_IMPLEMENTED EXIT_NOT_IMPLEMENTED(true)
#endif /* KYTY_COMMON_ASSERT_H_ */