From 7e8cb518e98937dad5b0ffb53829e596d8a71fde Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 11 Apr 2008 03:23:51 +0000 Subject: [PATCH] Finally decided to put the often copied RETURN_AND_SET_ERRNO() macro into a header. This version instantiates the given argument only once. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24900 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/shared/syscall_utils.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 headers/private/shared/syscall_utils.h diff --git a/headers/private/shared/syscall_utils.h b/headers/private/shared/syscall_utils.h new file mode 100644 index 0000000000..3498b5bb26 --- /dev/null +++ b/headers/private/shared/syscall_utils.h @@ -0,0 +1,18 @@ +/* + * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. + * Distributed under the terms of the MIT License. + */ +#ifndef _SYSCALL_UTILS_H +#define _SYSCALL_UTILS_H + +#define RETURN_AND_SET_ERRNO(err) \ + do { \ + __typeof(err) raseResult = (err); \ + if (raseResult < 0) { \ + errno = raseResult; \ + return -1; \ + } \ + return raseResult; \ + } while (false) + +#endif // _SYSCALL_UTILS_H