From 2d2e1489527401afb915496f525fcdd636e28a56 Mon Sep 17 00:00:00 2001 From: Chad Versace Date: Tue, 9 Jun 2015 14:54:53 -0700 Subject: [PATCH] vk/util: Add anv_abortf(), anv_abortfv() Convenience functions to print an error message then abort. --- src/vulkan/private.h | 3 +++ src/vulkan/util.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/vulkan/private.h b/src/vulkan/private.h index 26296c931fd..36279fac2cb 100644 --- a/src/vulkan/private.h +++ b/src/vulkan/private.h @@ -98,6 +98,9 @@ void __anv_finishme(const char *file, int line, const char *format, ...) #define anv_finishme(format, ...) \ __anv_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__); +void anv_abortf(const char *format, ...) anv_noreturn anv_printflike(1, 2); +void anv_abortfv(const char *format, va_list va) anv_noreturn; + #define stub_return(v) \ do { \ anv_finishme("stub %s", __func__); \ diff --git a/src/vulkan/util.c b/src/vulkan/util.c index 928f191847f..13af882cffd 100644 --- a/src/vulkan/util.c +++ b/src/vulkan/util.c @@ -43,6 +43,25 @@ __anv_finishme(const char *file, int line, const char *format, ...) fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer); } +void anv_noreturn anv_printflike(1, 2) +anv_abortf(const char *format, ...) +{ + va_list va; + + va_start(va, format); + anv_abortfv(format, va); + va_end(va); +} + +void anv_noreturn +anv_abortfv(const char *format, va_list va) +{ + fprintf(stderr, "vk: error: "); + vfprintf(stderr, format, va); + fprintf(stderr, "\n"); + abort(); +} + int anv_vector_init(struct anv_vector *vector, uint32_t element_size, uint32_t size) { -- 2.30.2