| //===-- sanitizer_libc.cc ---------------------------------------*- C++ -*-===// |
| // |
| // 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_defs.h" |
| #include "sanitizer_libc.h" |
| |
| namespace __sanitizer { |
| |
| void MiniLibcStub() { |
| } |
| |
| 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 |