summaryrefslogtreecommitdiff
path: root/src/shared/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/util.h')
-rw-r--r--src/shared/util.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/shared/util.h b/src/shared/util.h
index d1cdd901a0..7f050758a0 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -615,3 +615,9 @@ char *strextend(char **x, ...);
char *strrep(const char *s, unsigned n);
void* greedy_realloc(void **p, size_t *allocated, size_t need);
+
+static inline void reset_errno(int *saved_errno) {
+ errno = *saved_errno;
+}
+
+#define PROTECT_ERRNO __attribute__((cleanup(reset_errno))) int _saved_errno_ = errno