From 6b652160d1f33ecb31663224813c57288f7008e1 Mon Sep 17 00:00:00 2001 From: Mark Salyzyn Date: Thu, 17 Nov 2016 08:05:10 -0800 Subject: [PATCH] libcutils: sdk(mac) build error Surprise surprise, MAC sdk build has F_GETFD & not TEMP_FAILURE_RETRY. Revert code to original form with the three alternatives for all OSii. Test: Build Bug: 32450474 Change-Id: Ia7361d8107675a620968d8395c5e2351ad364d29 --- libcutils/android_get_control_file.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libcutils/android_get_control_file.cpp b/libcutils/android_get_control_file.cpp index 496fbbfe6..780d9f136 100644 --- a/libcutils/android_get_control_file.cpp +++ b/libcutils/android_get_control_file.cpp @@ -40,6 +40,10 @@ #include "android_get_control_env.h" +#ifndef TEMP_FAILURE_RETRY +#define TEMP_FAILURE_RETRY(exp) (exp) // KISS implementation +#endif + LIBCUTILS_HIDDEN int __android_get_control_from_env(const char* prefix, const char* name) { if (!prefix || !name) return -1; @@ -68,13 +72,13 @@ LIBCUTILS_HIDDEN int __android_get_control_from_env(const char* prefix, // Since we are inheriting an fd, it could legitimately exceed _SC_OPEN_MAX // Still open? -#if defined(F_GETFD) // Linux lowest overhead +#if defined(F_GETFD) // Lowest overhead if (TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD)) < 0) return -1; -#elif defined(F_GETFL) // Mac host lowest overhead - if (fcntl(fd, F_GETFL) < 0) return -1; +#elif defined(F_GETFL) // Alternate lowest overhead + if (TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL)) < 0) return -1; #else // Hail Mary pass struct stat s; - if (fstat(fd, &s) < 0) return -1; + if (TEMP_FAILURE_RETRY(fstat(fd, &s)) < 0) return -1; #endif return static_cast(fd);