summaryrefslogtreecommitdiff
path: root/include/utils
diff options
context:
space:
mode:
author Kenny Root <kroot@google.com> 2012-10-16 16:26:42 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2012-10-16 16:26:42 -0700
commit125beceefd44f6abd17ff336bb989e1850965bd8 (patch)
tree9a4ba33b11b5029b3648244b44fcd89daed6570c /include/utils
parentb82fb3431e5d62298b229f3b8758c832dee41f1d (diff)
parent7abbbc680d03dd8e50a709f89b78ace6b81154b0 (diff)
am 7abbbc68: Merge "Add TEMP_FAILURE_RETRY to ZipUtils"
* commit '7abbbc680d03dd8e50a709f89b78ace6b81154b0': Add TEMP_FAILURE_RETRY to ZipUtils
Diffstat (limited to 'include/utils')
-rw-r--r--include/utils/Compat.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/utils/Compat.h b/include/utils/Compat.h
index 18192661cb..fb7748eaa1 100644
--- a/include/utils/Compat.h
+++ b/include/utils/Compat.h
@@ -39,4 +39,27 @@ static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset)
#endif /* !HAVE_OFF64_T */
+#if HAVE_PRINTF_ZD
+# define ZD "%zd"
+# define ZD_TYPE ssize_t
+#else
+# define ZD "%ld"
+# define ZD_TYPE long
+#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 /* __LIB_UTILS_COMPAT_H */