diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-05-03 10:24:34 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-05-03 10:24:34 +0000 |
| commit | dd3f43d65c4009cc1c4e5b7c2cd10142f135f9ef (patch) | |
| tree | eb82c1c52df115cc4e2c674e650b9461ba2c0183 /util.h | |
| parent | Merge branch 'space-optimize-combining-chars' (diff) | |
util: thrd_err_as_string(): new function, returns a thrd_*() error string
Diffstat (limited to 'util.h')
| -rw-r--r-- | util.h | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -1,5 +1,23 @@ #pragma once +#include <threads.h> + #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"; +} |
