From: Jay Freeman (saurik) Date: Sun, 26 Jan 2014 21:54:07 +0000 (-0800) Subject: Allow errno exceptions to _syscall()'s _assert(). X-Git-Tag: v0.9.501~7 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/ccd33bdc275e7b4b7cc18d484ec68976354e48e2?ds=sidebyside Allow errno exceptions to _syscall()'s _assert(). --- diff --git a/Exception.hpp b/Exception.hpp index da35468..73287dd 100644 --- a/Exception.hpp +++ b/Exception.hpp @@ -74,16 +74,28 @@ while (false) fprintf(stderr, "_trace():%u\n", __LINE__); \ } while (false) -#define _syscall(expr) ({ \ +static _finline bool CYContains(int value, size_t many, int *okay) { + for (size_t i(0); i != many; ++i) + if (value == okay[i]) + return true; + return false; +} + +#define _syscall_(expr, many, okay) ({ \ __typeof__(expr) _value; \ do if ((long) (_value = (expr)) != -1) \ break; \ + else if (CYContains(errno, many, ((int [many]) okay))) \ + break; \ else \ _assert_("syscall", errno == EINTR, #expr, " [errno=%d]", errno); \ while (true); \ _value; \ }) +#define _syscall(expr) \ + _syscall_(expr, 0, {}) + #define _aprcall(expr) \ do { \ apr_status_t _aprstatus((expr)); \