vkd3d: Add a macro to mark unreachable code.

This should silence warnings about some branches non returning any value
without requiring additional "return 0" statement or similar.

Also, in theory this might enable to compiler to optimize the program
a little bit more, though that's unlikely to have any measurable effect.
This commit is contained in:
Giovanni Mascellani
2022-08-31 13:25:24 +02:00
committed by Alexandre Julliard
parent 56b2f56b86
commit d5fd309ef8
Notes: Alexandre Julliard 2022-10-18 00:13:00 +02:00
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/11
10 changed files with 52 additions and 71 deletions

View File

@@ -56,12 +56,26 @@ static inline size_t align(size_t addr, size_t alignment)
# define VKD3D_NORETURN __attribute__((noreturn))
# define VKD3D_PRINTF_FUNC(fmt, args) __attribute__((format(printf, fmt, args)))
# define VKD3D_UNUSED __attribute__((unused))
# define VKD3D_UNREACHABLE __builtin_unreachable()
#else
# define VKD3D_NORETURN
# define VKD3D_PRINTF_FUNC(fmt, args)
# define VKD3D_UNUSED
# define VKD3D_UNREACHABLE (void)0
#endif /* __GNUC__ */
VKD3D_NORETURN static inline void vkd3d_unreachable_(const char *filename, unsigned int line)
{
fprintf(stderr, "%s:%u: Aborting, reached unreachable code.\n", filename, line);
abort();
}
#ifdef NDEBUG
#define vkd3d_unreachable() VKD3D_UNREACHABLE
#else
#define vkd3d_unreachable() vkd3d_unreachable_(__FILE__, __LINE__)
#endif
static inline unsigned int vkd3d_popcount(unsigned int v)
{
#ifdef _MSC_VER