Clone TEMP_FAILURE_RETRY in JNIHelp.h, to make up for (take your pick)
laggard libc implementations not keeping up with the times or
(perhaps) agressively modern libc implementations too eagerly
expanding upon the standard.

Change-Id: I4c4d050d15a00f4e82f8beb2b9c386b7c652f495
diff --git a/include/nativehelper/JNIHelp.h b/include/nativehelper/JNIHelp.h
index 1e268f8..b8bc3f0 100644
--- a/include/nativehelper/JNIHelp.h
+++ b/include/nativehelper/JNIHelp.h
@@ -25,6 +25,7 @@
 
 #include "jni.h"
 #include "utils/Log.h"
+#include <unistd.h>
 
 #ifndef NELEM
 # define NELEM(x) ((int) (sizeof(x) / sizeof((x)[0])))
@@ -120,4 +121,19 @@
 }
 #endif
 
+/*
+ * TEMP_FAILURE_RETRY is defined by some, but not all, versions of
+ * <unistd.h>. (Alas, it is not as standard as we'd hoped!) So, if it's
+ * not already defined, then define it here.
+ */
+#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; })
+#endif
+
 #endif /*_NATIVEHELPER_JNIHELP_H*/