[llvm-commits] [compiler-rt] r157922 - in /compiler-rt/trunk/lib: asan/asan_interceptors.cc asan/asan_interceptors.h asan/asan_printf.cc sanitizer_common/sanitizer_libc.cc sanitizer_common/sanitizer_libc.h
Alexey Samsonov
samsonov at google.com
Mon Jun 4 03:30:16 PDT 2012
Author: samsonov
Date: Mon Jun 4 05:30:16 2012
New Revision: 157922
URL: http://llvm.org/viewvc/llvm-project?rev=157922&view=rev
Log:
[Sanitizer] Move internal_strncpy to sanitizer_libc (and make its behavior conforming to manual)
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/asan_interceptors.h
compiler-rt/trunk/lib/asan/asan_printf.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.cc?rev=157922&r1=157921&r2=157922&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Mon Jun 4 05:30:16 2012
@@ -309,13 +309,6 @@
return 0;
}
-char *internal_strncpy(char *dst, const char *src, uptr n) {
- uptr i;
- for (i = 0; i < n && src[i]; i++)
- dst[i] = src[i];
- return dst;
-}
-
} // namespace __asan
// ---------------------- Wrappers ---------------- {{{1
Modified: compiler-rt/trunk/lib/asan/asan_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_interceptors.h?rev=157922&r1=157921&r2=157922&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.h Mon Jun 4 05:30:16 2012
@@ -41,7 +41,6 @@
char *internal_strstr(const char *haystack, const char *needle);
char *internal_strncat(char *dst, const char *src, uptr n);
int internal_strcmp(const char *s1, const char *s2);
-char *internal_strncpy(char *dst, const char *src, uptr n);
// Works only for base=10 and doesn't set errno.
s64 internal_simple_strtoll(const char *nptr, char **endptr, int base);
Modified: compiler-rt/trunk/lib/asan/asan_printf.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_printf.cc?rev=157922&r1=157921&r2=157922&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_printf.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_printf.cc Mon Jun 4 05:30:16 2012
@@ -16,10 +16,13 @@
#include "asan_internal.h"
#include "asan_interceptors.h"
+#include "sanitizer_common/sanitizer_libc.h"
#include <stdarg.h>
#include <stdio.h>
+using namespace __sanitizer; // NOLINT
+
namespace __asan {
extern char *error_message_buffer;
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc?rev=157922&r1=157921&r2=157922&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc Mon Jun 4 05:30:16 2012
@@ -10,6 +10,7 @@
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries. See sanitizer_libc.h for details.
//===----------------------------------------------------------------------===//
+#include "sanitizer_defs.h"
#include "sanitizer_libc.h"
namespace __sanitizer {
@@ -17,4 +18,13 @@
void MiniLibcStub() {
}
+char *internal_strncpy(char *dst, const char *src, uptr n) {
+ uptr i;
+ for (i = 0; i < n && src[i]; i++)
+ dst[i] = src[i];
+ for (; i < n; i++)
+ dst[i] = '\0';
+ return dst;
+}
+
} // namespace __sanitizer
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=157922&r1=157921&r2=157922&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Mon Jun 4 05:30:16 2012
@@ -18,11 +18,16 @@
#ifndef SANITIZER_LIBC_H
#define SANITIZER_LIBC_H
+#include "sanitizer_defs.h"
+
// No code here yet. Will move more code in the next changes.
namespace __sanitizer {
void MiniLibcStub();
+// internal_X() is a custom implementation of X() for use in RTL.
+char *internal_strncpy(char *dst, const char *src, uptr n);
+
} // namespace __sanitizer
#endif // SANITIZER_LIBC_H
More information about the llvm-commits
mailing list