2012-06-04 21:55:19 +08:00
|
|
|
//===-- sanitizer_libc.cc -------------------------------------------------===//
|
2012-05-29 20:18:18 +08:00
|
|
|
//
|
|
|
|
// 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
|
2012-05-31 21:42:53 +08:00
|
|
|
// run-time libraries. See sanitizer_libc.h for details.
|
2012-05-29 20:18:18 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2012-06-04 18:30:16 +08:00
|
|
|
#include "sanitizer_defs.h"
|
2012-05-31 21:42:53 +08:00
|
|
|
#include "sanitizer_libc.h"
|
2012-05-29 20:18:18 +08:00
|
|
|
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
|
|
|
void MiniLibcStub() {
|
|
|
|
}
|
|
|
|
|
2012-06-05 17:49:25 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-06-04 21:27:49 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-06-04 18:30:16 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2012-05-29 20:18:18 +08:00
|
|
|
} // namespace __sanitizer
|