summaryrefslogtreecommitdiffstats
path: root/luni/src/main/native/Portability.h
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2015-01-29 16:29:20 +0000
committerNarayan Kamath <narayan@google.com>2015-01-29 17:36:05 +0000
commit8702d65450d23f8d624782dfe7f98d920c4add8f (patch)
tree2ee35bd50a47eda33f7f18eb633d04fdc737ea2c /luni/src/main/native/Portability.h
parent26bb48032cdcc8d69484ff168389c34e1f873250 (diff)
downloadlibcore-8702d65450d23f8d624782dfe7f98d920c4add8f.zip
libcore-8702d65450d23f8d624782dfe7f98d920c4add8f.tar.gz
libcore-8702d65450d23f8d624782dfe7f98d920c4add8f.tar.bz2
Work around 32 bit glibc bug.
Don't allow glibc's TEMP_FAILURE_RETRY on 32 bit hosts, it will truncate 64 bit return types such as from lsee64, sendfile etc. Change-Id: I009510a69ec80d42a17192bf960b056456bd88f5
Diffstat (limited to 'luni/src/main/native/Portability.h')
-rw-r--r--luni/src/main/native/Portability.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/luni/src/main/native/Portability.h b/luni/src/main/native/Portability.h
index 1aaf7a3..5900cb0 100644
--- a/luni/src/main/native/Portability.h
+++ b/luni/src/main/native/Portability.h
@@ -85,4 +85,21 @@ static inline int android_getaddrinfofornet(const char* hostname, const char* se
}
#endif
+#if defined(__GLIBC__) && !defined(__LP64__)
+
+#include <unistd.h>
+
+// 32 bit GLIBC hardcodes a "long int" as the return type for
+// TEMP_FAILURE_RETRY so the return value here gets truncated for
+// functions that return 64 bit types.
+#undef TEMP_FAILURE_RETRY
+#define TEMP_FAILURE_RETRY(exp) ({ \
+ __typeof__(exp) _rc; \
+ do { \
+ _rc = (exp); \
+ } while (_rc == -1 && errno == EINTR); \
+ _rc; })
+
+#endif // __GLIBC__ && !__LP64__
+
#endif // PORTABILITY_H_included