[llvm-commits] [compiler-rt] r165006 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_internal_defs.h sanitizer_linux.cc

Evgeniy Stepanov eugeni.stepanov at gmail.com
Tue Oct 2 06:41:40 PDT 2012


Author: eugenis
Date: Tue Oct  2 08:41:40 2012
New Revision: 165006

URL: http://llvm.org/viewvc/llvm-project?rev=165006&view=rev
Log:
[*San]: handle EINTR.

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=165006&r1=165005&r2=165006&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Tue Oct  2 08:41:40 2012
@@ -179,4 +179,10 @@
 # define GET_CURRENT_FRAME() (uptr)0xDEADBEEF
 #endif
 
+#define HANDLE_EINTR(res, f) {                               \
+  do {                                                                  \
+    res = (f);                                                         \
+  } while (res == -1 && errno == EINTR); \
+  }
+
 #endif  // SANITIZER_DEFS_H

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=165006&r1=165005&r2=165006&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Tue Oct  2 08:41:40 2012
@@ -29,6 +29,7 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <errno.h>
 
 namespace __sanitizer {
 
@@ -56,11 +57,15 @@
 }
 
 uptr internal_read(fd_t fd, void *buf, uptr count) {
-  return (uptr)syscall(__NR_read, fd, buf, count);
+  sptr res;
+  HANDLE_EINTR(res, (sptr)syscall(__NR_read, fd, buf, count));
+  return res;
 }
 
 uptr internal_write(fd_t fd, const void *buf, uptr count) {
-  return (uptr)syscall(__NR_write, fd, buf, count);
+  sptr res;
+  HANDLE_EINTR(res, (sptr)syscall(__NR_write, fd, buf, count));
+  return res;
 }
 
 uptr internal_filesize(fd_t fd) {





More information about the llvm-commits mailing list