summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-10-16 11:34:02 -0700
committerAlex Ray <aray@google.com>2013-07-30 13:57:00 -0700
commitb9fd6f986492d74125274722b8ea1a3819cd216a (patch)
treee3a1603e2dc9a80291b23bb53f12b48f51db7a2e /include
parent5625087e6e56493ad26d4171b78687d17c7136f4 (diff)
downloadsystem_core-b9fd6f986492d74125274722b8ea1a3819cd216a.zip
system_core-b9fd6f986492d74125274722b8ea1a3819cd216a.tar.gz
system_core-b9fd6f986492d74125274722b8ea1a3819cd216a.tar.bz2
Add TEMP_FAILURE_RETRY to ZipUtils
Change-Id: I275c415f14eeffaf9a58d45f3ea014d766441ec3
Diffstat (limited to 'include')
-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 1819266..fb7748e 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 */