[compiler-rt] r234490 - Use RenameFile instead of internal_rename in non-POSIX code

Timur Iskhodzhanov timurrrr at google.com
Thu Apr 9 07:45:17 PDT 2015


Author: timurrrr
Date: Thu Apr  9 09:45:17 2015
New Revision: 234490

URL: http://llvm.org/viewvc/llvm-project?rev=234490&view=rev
Log:
Use RenameFile instead of internal_rename in non-POSIX code


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=234490&r1=234489&r2=234490&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Thu Apr  9 09:45:17 2015
@@ -207,6 +207,9 @@ bool ReadFromFile(fd_t fd, void *buff, u
 bool WriteToFile(fd_t fd, const void *buff, uptr buff_size,
                  uptr *bytes_written = nullptr, error_t *error_p = nullptr);
 
+bool RenameFile(const char *oldpath, const char *newpath,
+                error_t *error_p = nullptr);
+
 bool SupportsColoredOutput(fd_t fd);
 
 // Opens the file 'file_name" and reads up to 'max_len' bytes.

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc?rev=234490&r1=234489&r2=234490&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_mapping_libcdep.cc Thu Apr  9 09:45:17 2015
@@ -118,8 +118,7 @@ void CovUpdateMapping(const char *covera
   res = internal_snprintf((char *)path.data(), path.size(), "%s/%zd.sancov.map",
                           coverage_dir, internal_getpid());
   CHECK_LE(res, path.size());
-  res = internal_rename(tmp_path.data(), path.data());
-  if (internal_iserror(res, &err)) {
+  if (!RenameFile(tmp_path.data(), path.data(), &err)) {
     Printf("sancov.map rename failed: %d\n", err);
     Die();
   }

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h?rev=234490&r1=234489&r2=234490&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Thu Apr  9 09:45:17 2015
@@ -66,7 +66,6 @@ const fd_t kStderrFd = 2;
 uptr internal_ftruncate(fd_t fd, uptr size);
 
 // OS
-uptr internal_rename(const char *oldpath, const char *newpath);
 void NORETURN internal__exit(int exitcode);
 
 uptr internal_getpid();

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=234490&r1=234489&r2=234490&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Thu Apr  9 09:45:17 2015
@@ -243,6 +243,11 @@ bool WriteToFile(fd_t fd, const void *bu
   return true;
 }
 
+bool RenameFile(const char *oldpath, const char *newpath, error_t *error_p) {
+  uptr res = internal_rename(oldpath, newpath);
+  return !internal_iserror(res, error_p);
+}
+
 void *MapFileToMemory(const char *file_name, uptr *buff_size) {
   fd_t fd = OpenFile(file_name, RdOnly);
   CHECK(fd != kInvalidFd);

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h?rev=234490&r1=234489&r2=234490&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.h Thu Apr  9 09:45:17 2015
@@ -46,6 +46,7 @@ uptr internal_fstat(fd_t fd, void *buf);
 uptr internal_dup2(int oldfd, int newfd);
 uptr internal_readlink(const char *path, char *buf, uptr bufsize);
 uptr internal_unlink(const char *path);
+uptr internal_rename(const char *oldpath, const char *newpath);
 uptr internal_lseek(fd_t fd, OFF_T offset, int whence);
 
 uptr internal_ptrace(int request, int pid, void *addr, void *data);

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc?rev=234490&r1=234489&r2=234490&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Thu Apr  9 09:45:17 2015
@@ -469,6 +469,10 @@ bool WriteToFile(fd_t fd, const void *bu
   return false;
 }
 
+bool RenameFile(const char *oldpath, const char *newpath, error_t *error_p) {
+  UNIMPLEMENTED();
+}
+
 uptr internal_sched_yield() {
   Sleep(0);
   return 0;
@@ -482,10 +486,6 @@ uptr internal_ftruncate(fd_t fd, uptr si
   UNIMPLEMENTED();
 }
 
-uptr internal_rename(const char *oldpath, const char *newpath) {
-  UNIMPLEMENTED();
-}
-
 uptr GetRSS() {
   return 0;
 }





More information about the llvm-commits mailing list