2008-04-11 07:23:51 +04:00
|
|
|
/*
|
2011-06-12 04:00:23 +04:00
|
|
|
* Copyright 2008-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
|
2008-04-11 07:23:51 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _SYSCALL_UTILS_H
|
|
|
|
#define _SYSCALL_UTILS_H
|
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
|
2008-04-11 07:23:51 +04:00
|
|
|
#define RETURN_AND_SET_ERRNO(err) \
|
|
|
|
do { \
|
2011-06-12 04:00:23 +04:00
|
|
|
__typeof(err) __result = (err); \
|
|
|
|
if (__result < 0) { \
|
|
|
|
errno = __result; \
|
2008-04-11 07:23:51 +04:00
|
|
|
return -1; \
|
|
|
|
} \
|
2011-06-12 04:00:23 +04:00
|
|
|
return __result; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define RETURN_AND_TEST_CANCEL(err) \
|
|
|
|
do { \
|
|
|
|
__typeof(err) __result = (err); \
|
|
|
|
pthread_testcancel(); \
|
|
|
|
return __result; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define RETURN_AND_SET_ERRNO_TEST_CANCEL(err) \
|
|
|
|
do { \
|
|
|
|
__typeof(err) __result = (err); \
|
|
|
|
pthread_testcancel(); \
|
|
|
|
if (__result < 0) { \
|
|
|
|
errno = __result; \
|
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
return __result; \
|
|
|
|
} while (0)
|
|
|
|
|
2008-04-11 07:23:51 +04:00
|
|
|
|
|
|
|
#endif // _SYSCALL_UTILS_H
|