diff options
author | Alexey Samsonov <samsonov@google.com> | 2012-06-07 11:54:08 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2012-06-07 11:54:08 +0000 |
commit | f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18c (patch) | |
tree | c1b2a094e43e75312828df7d892d5cef7c106310 /lib/sanitizer_common/sanitizer_libc.cc | |
parent | 9fe7b96f92606057dacb9130c08d32430d8be86f (diff) | |
download | compiler-rt-f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18c.tar.gz |
[Sanitizer] move internal_strdup and internal_memcpy to common runtime. Make internal allocations from TSan runtime call InternalAlloc from common runtime
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@158148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_libc.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_libc.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/sanitizer_common/sanitizer_libc.cc b/lib/sanitizer_common/sanitizer_libc.cc index 4191cda42..6de28c62d 100644 --- a/lib/sanitizer_common/sanitizer_libc.cc +++ b/lib/sanitizer_common/sanitizer_libc.cc @@ -10,7 +10,7 @@ // This file is shared between AddressSanitizer and ThreadSanitizer // run-time libraries. See sanitizer_libc.h for details. //===----------------------------------------------------------------------===// -#include "sanitizer_internal_defs.h" +#include "sanitizer_common.h" #include "sanitizer_libc.h" namespace __sanitizer { @@ -26,6 +26,22 @@ void *internal_memchr(const void *s, int c, uptr n) { return 0; } +void *internal_memcpy(void *dest, const void *src, uptr n) { + char *d = (char*)dest; + char *s = (char*)src; + for (uptr i = 0; i < n; ++i) + d[i] = s[i]; + return dest; +} + +char* internal_strdup(const char *s) { + uptr len = internal_strlen(s); + char *s2 = (char*)InternalAlloc(len + 1); + internal_memcpy(s2, s, len); + s2[len] = 0; + return s2; +} + int internal_strcmp(const char *s1, const char *s2) { while (true) { unsigned c1 = *s1; |