aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/log.h
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-08-26 07:15:03 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-08-26 07:15:45 +0200
commit93b8646855353ab3adfe5fea8ccb5b0842ad8a0d (patch)
treec87ac95cd819f654d60e360f84a5559faa7de9fe /src/log.h
parentfix macros (diff)
downloadcimple-93b8646855353ab3adfe5fea8ccb5b0842ad8a0d.tar.gz
cimple-93b8646855353ab3adfe5fea8ccb5b0842ad8a0d.zip
add check_errno macro
Diffstat (limited to 'src/log.h')
-rw-r--r--src/log.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/log.h b/src/log.h
index 33e3040..87f352f 100644
--- a/src/log.h
+++ b/src/log.h
@@ -15,6 +15,13 @@
perror(s); \
} while (0)
+#define check_errno(expr, s) \
+ do { \
+ int CONCAT(ret, __LINE__) = expr; \
+ if (CONCAT(ret, __LINE__) < 0) \
+ print_errno(s); \
+ } while (0)
+
#define pthread_print_errno(var, s) \
do { \
errno = var; \