From d74c0fb54b07859b37f74375bd4fee2358f9baa2 Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Fri, 3 Dec 2021 16:14:53 +0100 Subject: [PATCH] [PATCH 69/90] add PTHREAD_CHECK2() accepting an additional non-zero return code use e.g. for * pthread_broadcast(): PTHREAD_BARRIER_SERIAL_THREAD * pthread_cond_timedwait(): ETIMEDOUT avoid the extra function call to the error handler if the command succeeded Gbp-Pq: Name 0069-add-PTHREAD_CHECK2-accepting-an-additional-non-zero-.patch --- lib/CL/pocl_cl.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/CL/pocl_cl.h b/lib/CL/pocl_cl.h index 0b3f096..7d36ca3 100644 --- a/lib/CL/pocl_cl.h +++ b/lib/CL/pocl_cl.h @@ -115,8 +115,20 @@ void pocl_abort_on_pthread_error (int status, unsigned line, const char *func); } #endif -#define PTHREAD_CHECK(code) \ - pocl_abort_on_pthread_error ((code), __LINE__, __FUNCTION__); +/* Some pthread_*() calls may return '0' or a specific non-zero value on + * success. + */ +#define PTHREAD_CHECK2(_status_ok, _code) \ + do \ + { \ + int _pthread_status = (_code); \ + if (_pthread_status != 0 && _pthread_status != (_status_ok)) \ + pocl_abort_on_pthread_error (_pthread_status, __LINE__, \ + __FUNCTION__); \ + } \ + while (0) + +#define PTHREAD_CHECK(code) PTHREAD_CHECK2 (0, code) /* Generic functionality for handling different types of OpenCL (host) objects. */ -- 2.30.2