vkd3d: Emit an ERR() when reaching unreachable code.

This way the ERR() configuration is reused for unreachable code.
This commit is contained in:
Giovanni Mascellani 2024-07-26 11:51:26 +02:00 committed by Henri Verbeet
parent 4ada72a397
commit fb55c2b227
Notes: Henri Verbeet 2024-07-29 13:23:46 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Conor McCarthy (@cmccarthy)
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/867

View File

@ -108,17 +108,11 @@ static inline uint64_t align(uint64_t addr, size_t alignment)
# define VKD3D_UNREACHABLE (void)0 # define VKD3D_UNREACHABLE (void)0
#endif /* __GNUC__ */ #endif /* __GNUC__ */
VKD3D_NORETURN static inline void vkd3d_unreachable_(const char *filename, unsigned int line) #define vkd3d_unreachable() \
{ do { \
fprintf(stderr, "%s:%u: Aborting, reached unreachable code.\n", filename, line); ERR("%s:%u: Unreachable code reached.\n", __FILE__, __LINE__); \
abort(); VKD3D_UNREACHABLE; \
} } while (0)
#ifdef NDEBUG
#define vkd3d_unreachable() VKD3D_UNREACHABLE
#else
#define vkd3d_unreachable() vkd3d_unreachable_(__FILE__, __LINE__)
#endif
#ifdef VKD3D_NO_TRACE_MESSAGES #ifdef VKD3D_NO_TRACE_MESSAGES
#define TRACE(args...) do { } while (0) #define TRACE(args...) do { } while (0)
@ -188,6 +182,12 @@ const char *debugstr_w(const WCHAR *wstr, size_t wchar_size);
#define VKD3D_DBG_PRINTF_ERR(...) VKD3D_DBG_PRINTF(__VA_ARGS__) #define VKD3D_DBG_PRINTF_ERR(...) VKD3D_DBG_PRINTF(__VA_ARGS__)
#endif #endif
/* Used by vkd3d_unreachable(). */
#ifdef VKD3D_CROSSTEST
#undef ERR
#define ERR(...) do { fprintf(stderr, __VA_ARGS__); abort(); } while (0)
#endif
#ifndef TRACE #ifndef TRACE
#define TRACE VKD3D_DBG_LOG(TRACE) #define TRACE VKD3D_DBG_LOG(TRACE)
#endif #endif