summaryrefslogtreecommitdiffstats
path: root/libnativehelper
diff options
context:
space:
mode:
authorDan Bornstein <danfuzz@android.com>2009-10-26 13:33:22 -0700
committerDan Bornstein <danfuzz@android.com>2009-10-26 13:33:22 -0700
commit2237714129f425131669ae43b1326ec5cb1ec655 (patch)
tree4d99d6aacae6f3ca9c67a6c117c743fca9f9a185 /libnativehelper
parentc494c3bf4f20012dfdcc1e5499d802c6f38a6be1 (diff)
downloadandroid_dalvik-2237714129f425131669ae43b1326ec5cb1ec655.tar.gz
android_dalvik-2237714129f425131669ae43b1326ec5cb1ec655.tar.bz2
android_dalvik-2237714129f425131669ae43b1326ec5cb1ec655.zip
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
Diffstat (limited to 'libnativehelper')
-rw-r--r--libnativehelper/include/nativehelper/JNIHelp.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/libnativehelper/include/nativehelper/JNIHelp.h b/libnativehelper/include/nativehelper/JNIHelp.h
index 1e268f845..b8bc3f030 100644
--- a/libnativehelper/include/nativehelper/JNIHelp.h
+++ b/libnativehelper/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 @@ inline void jniSetFileDescriptorOfFD(JNIEnv* env, jobject fileDescriptor,
}
#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*/