//===-- sanitizer_libc.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. See sanitizer_libc.h for details. //===----------------------------------------------------------------------===// #include "sanitizer_internal_defs.h" #include "sanitizer_libc.h" namespace __sanitizer { void MiniLibcStub() { } void *internal_memchr(const void *s, int c, uptr n) { const char* t = (char*)s; for (uptr i = 0; i < n; ++i, ++t) if (*t == c) return (void*)t; return 0; } int internal_strcmp(const char *s1, const char *s2) { while (true) { unsigned c1 = *s1; unsigned c2 = *s2; if (c1 != c2) return (c1 < c2) ? -1 : 1; if (c1 == 0) break; s1++; s2++; } 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]; for (; i < n; i++) dst[i] = '\0'; return dst; } } // namespace __sanitizer