[llvm-commits] [compiler-rt] r158202 - in /compiler-rt/trunk/lib: asan/asan_interceptors.cc asan/asan_interceptors.h sanitizer_common/sanitizer_libc.cc sanitizer_common/sanitizer_libc.h tsan/rtl/tsan_defs.h tsan/rtl/tsan_interceptors.cc
Alexey Samsonov
samsonov at google.com
Fri Jun 8 07:11:12 PDT 2012
Author: samsonov
Date: Fri Jun 8 09:11:12 2012
New Revision: 158202
URL: http://llvm.org/viewvc/llvm-project?rev=158202&view=rev
Log:
[Sanitizer] add internal_memset and internal_strrchr to sanitizer_common/
Modified:
compiler-rt/trunk/lib/asan/asan_interceptors.cc
compiler-rt/trunk/lib/asan/asan_interceptors.h
compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h
compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
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=158202&r1=158201&r2=158202&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.cc Fri Jun 8 09:11:12 2012
@@ -251,19 +251,6 @@
return 0;
}
-// Should not be used in performance-critical places.
-void* internal_memset(void* s, int c, uptr n) {
- // The next line prevents Clang from making a call to memset() instead of the
- // loop below.
- // FIXME: building the runtime with -ffreestanding is a better idea. However
- // there currently are linktime problems due to PR12396.
- char volatile *t = (char*)s;
- for (uptr i = 0; i < n; ++i, ++t) {
- *t = c;
- }
- return s;
-}
-
char *internal_strstr(const char *haystack, const char *needle) {
// This is O(N^2), but we are not using it in hot places.
uptr len1 = internal_strlen(haystack);
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=158202&r1=158201&r2=158202&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_interceptors.h (original)
+++ compiler-rt/trunk/lib/asan/asan_interceptors.h Fri Jun 8 09:11:12 2012
@@ -34,7 +34,6 @@
s64 internal_atoll(const char *nptr);
uptr internal_strnlen(const char *s, uptr maxlen);
char* internal_strchr(const char *s, int c);
-void* internal_memset(void *s, int c, uptr n);
int internal_memcmp(const void* s1, const void* s2, uptr n);
char *internal_strstr(const char *haystack, const char *needle);
char *internal_strncat(char *dst, const char *src, uptr n);
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=158202&r1=158201&r2=158202&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.cc Fri Jun 8 09:11:12 2012
@@ -34,6 +34,18 @@
return dest;
}
+void *internal_memset(void* s, int c, uptr n) {
+ // The next line prevents Clang from making a call to memset() instead of the
+ // loop below.
+ // FIXME: building the runtime with -ffreestanding is a better idea. However
+ // there currently are linktime problems due to PR12396.
+ char volatile *t = (char*)s;
+ for (uptr i = 0; i < n; ++i, ++t) {
+ *t = c;
+ }
+ return s;
+}
+
char* internal_strdup(const char *s) {
uptr len = internal_strlen(s);
char *s2 = (char*)InternalAlloc(len + 1);
@@ -54,6 +66,14 @@
return 0;
}
+char *internal_strrchr(const char *s, int c) {
+ const char *res = 0;
+ for (uptr i = 0; s[i]; i++) {
+ if (s[i] == c) res = s + i;
+ }
+ return (char*)res;
+}
+
uptr internal_strlen(const char *s) {
uptr i = 0;
while (s[i]) i++;
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=158202&r1=158201&r2=158202&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_libc.h Fri Jun 8 09:11:12 2012
@@ -26,10 +26,13 @@
// String functions
void *internal_memchr(const void *s, int c, uptr n);
void *internal_memcpy(void *dest, const void *src, uptr n);
+// Should not be used in performance-critical places.
+void *internal_memset(void *s, int c, uptr n);
int internal_strcmp(const char *s1, const char *s2);
char *internal_strdup(const char *s);
uptr internal_strlen(const char *s);
char *internal_strncpy(char *dst, const char *src, uptr n);
+char *internal_strrchr(const char *s, int c);
// Memory
void *internal_mmap(void *addr, uptr length, int prot, int flags,
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=158202&r1=158201&r2=158202&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Fri Jun 8 09:11:12 2012
@@ -140,7 +140,6 @@
void internal_strcpy(char *s1, const char *s2);
const char *internal_strstr(const char *where, const char *what);
const char *internal_strchr(const char *where, char what);
-const char *internal_strrchr(const char *where, char what);
struct MD5Hash {
u64 hash[2];
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=158202&r1=158201&r2=158202&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Fri Jun 8 09:11:12 2012
@@ -1545,10 +1545,6 @@
return (const char*)REAL(strchr)((void*)where, what);
}
-const char *internal_strrchr(const char *where, char what) {
- return (const char*)REAL(strrchr)((void*)where, what);
-}
-
void internal_start_thread(void(*func)(void *arg), void *arg) {
void *th;
REAL(pthread_create)(&th, 0, (void*(*)(void *arg))func, arg);
More information about the llvm-commits
mailing list