From dd3f43d65c4009cc1c4e5b7c2cd10142f135f9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 3 May 2020 12:24:34 +0200 Subject: [PATCH] util: thrd_err_as_string(): new function, returns a thrd_*() error string --- util.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/util.h b/util.h index c4496bd1..291a68d7 100644 --- a/util.h +++ b/util.h @@ -1,5 +1,23 @@ #pragma once +#include + #define ALEN(v) (sizeof(v) / sizeof((v)[0])) #define min(x, y) ((x) < (y) ? (x) : (y)) #define max(x, y) ((x) > (y) ? (x) : (y)) + +static inline const char * +thrd_err_as_string(int thrd_err) +{ + switch (thrd_err) { + case thrd_success: return "success"; + case thrd_busy: return "busy"; + case thrd_nomem: return "no memory"; + case thrd_timedout: return "timedout"; + + case thrd_error: + default: return "unknown error"; + } + + return "unknown error"; +}