[llvm-commits] [compiler-rt] r157985 - in /compiler-rt/trunk/lib/sanitizer_common: sanitizer_libc.h sanitizer_linux.cc sanitizer_mac.cc sanitizer_win.cc

Alexey Samsonov samsonov at google.com
Tue Jun 5 00:05:10 PDT 2012


Author: samsonov
Date: Tue Jun  5 02:05:10 2012
New Revision: 157985

URL: http://llvm.org/viewvc/llvm-project?rev=157985&view=rev
Log:
[Sanitizer] Add sanitizer_win.cc for windows-specific implementations of libc functions. Add internal_open.

Added:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc
Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc

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=157985&r1=157984&r2=157985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Tue Jun  5 02:05:10 2012
@@ -29,10 +29,11 @@
 int internal_strcmp(const char *s1, const char *s2);
 char *internal_strncpy(char *dst, const char *src, uptr n);
 
-#ifndef _WIN32
 void *internal_mmap(void *addr, uptr length, int prot, int flags,
                     int fd, u64 offset);
-#endif  // _WIN32
+
+typedef int fd_t;
+fd_t internal_open(const char *filename, bool write);
 
 }  // namespace __sanitizer
 

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=157985&r1=157984&r2=157985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Tue Jun  5 02:05:10 2012
@@ -16,7 +16,9 @@
 #include "sanitizer_defs.h"
 #include "sanitizer_libc.h"
 
+#include <fcntl.h>
 #include <sys/mman.h>
+#include <sys/stat.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
 #include <unistd.h>
@@ -32,6 +34,11 @@
 #endif
 }
 
+fd_t internal_open(const char *filename, bool write) {
+  return syscall(__NR_open, filename,
+      write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660);
+}
+
 }  // namespace __sanitizer
 
 #endif  // __linux__

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc?rev=157985&r1=157984&r2=157985&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_mac.cc Tue Jun  5 02:05:10 2012
@@ -18,6 +18,9 @@
 #include "sanitizer_libc.h"
 
 #include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
 
 namespace __sanitizer {
 
@@ -26,6 +29,11 @@
   return mmap(addr, length, prot, flags, fd, offset);
 }
 
+fd_t internal_open(const char *filename, bool write) {
+  return open(filename,
+              write ? O_WRONLY | O_CREAT | O_CLOEXEC : O_RDONLY, 0660);
+}
+
 }  // namespace __sanitizer
 
 #endif  // __APPLE__

Added: 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=157985&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc (added)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win.cc Tue Jun  5 02:05:10 2012
@@ -0,0 +1,39 @@
+//===-- sanitizer_win.cc ------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is shared between AddressSanitizer and ThreadSanitizer
+// run-time libraries and implements windows-specific functions from
+// sanitizer_libc.h.
+//===----------------------------------------------------------------------===//
+#ifdef _WIN32
+#include <windows.h>
+
+#include <assert.h>
+
+#include "sanitizer_defs.h"
+#include "sanitizer_libc.h"
+
+#define UNIMPLEMENTED_WIN() assert(false)
+
+namespace __sanitizer {
+
+void *internal_mmap(void *addr, uptr length, int prot, int flags,
+                    int fd, u64 offset) {
+  UNIMPLEMENTED_WIN();
+  return 0;
+}
+
+fd_t internal_open(const char *filename, bool write) {
+  UNIMPLEMENTED_WIN();
+  return 0;
+}
+
+}  // namespace __sanitizer
+
+#endif  // _WIN32





More information about the llvm-commits mailing list