From fcbc96191c555b60e5dc4e21e463588337f79ecc Mon Sep 17 00:00:00 2001 From: Andrei Homescu Date: Tue, 15 Mar 2022 01:44:21 +0000 Subject: [PATCH] Fix TEMP_FAILURE_RETRY on non-GNU C++ dialects TEMP_FAILURE_RETRY uses typeof which is only allowed by gcc and clang for GNU dialects. This switches to __typeof__ which is always supported. Bug: 224644083 Test: m Change-Id: I96d48d2f0dc5cd9ab903755d93c71c4eb80f7529 --- libutils/include/utils/Compat.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/libutils/include/utils/Compat.h b/libutils/include/utils/Compat.h index 60025678c..3221899f7 100644 --- a/libutils/include/utils/Compat.h +++ b/libutils/include/utils/Compat.h @@ -71,19 +71,17 @@ static inline int ftruncate64(int fd, off64_t length) { #define CONSTEXPR #endif -/* - * TEMP_FAILURE_RETRY is defined by some, but not all, versions of - * . (Alas, it is not as standard as we'd hoped!) So, if it's - * not already defined, then define it here. - */ +/* TEMP_FAILURE_RETRY is not available on macOS, but still useful there. */ #ifndef TEMP_FAILURE_RETRY /* Used to retry syscalls that can return EINTR. */ -#define TEMP_FAILURE_RETRY(exp) ({ \ - typeof (exp) _rc; \ - do { \ - _rc = (exp); \ - } while (_rc == -1 && errno == EINTR); \ - _rc; }) +#define TEMP_FAILURE_RETRY(exp) \ + ({ \ + __typeof__(exp) _rc; \ + do { \ + _rc = (exp); \ + } while (_rc == -1 && errno == EINTR); \ + _rc; \ + }) #endif #if defined(_WIN32)