diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-07 19:55:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-07 19:55:37 +0000 |
commit | ca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (patch) | |
tree | 9b19e801150082c33e9152275829a6ce90614b55 /lib/msan/lit_tests/malloc_hook.cc | |
parent | 8ef50bf3d1c287b5013c3168de77a462dfce3495 (diff) |
Diffstat (limited to 'lib/msan/lit_tests/malloc_hook.cc')
-rw-r--r-- | lib/msan/lit_tests/malloc_hook.cc | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/lib/msan/lit_tests/malloc_hook.cc b/lib/msan/lit_tests/malloc_hook.cc deleted file mode 100644 index fc68fbc35fbb0..0000000000000 --- a/lib/msan/lit_tests/malloc_hook.cc +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: %clangxx_msan -O2 %s -o %t -// RUN: %t 2>&1 | FileCheck %s -#include <stdlib.h> -#include <unistd.h> - -extern "C" { -int __msan_get_ownership(const void *p); - -void *global_ptr; - -// Note: avoid calling functions that allocate memory in malloc/free -// to avoid infinite recursion. -void __msan_malloc_hook(void *ptr, size_t sz) { - if (__msan_get_ownership(ptr)) { - write(1, "MallocHook\n", sizeof("MallocHook\n")); - global_ptr = ptr; - } -} -void __msan_free_hook(void *ptr) { - if (__msan_get_ownership(ptr) && ptr == global_ptr) - write(1, "FreeHook\n", sizeof("FreeHook\n")); -} -} // extern "C" - -int main() { - volatile int *x = new int; - // CHECK: MallocHook - // Check that malloc hook was called with correct argument. - if (global_ptr != (void*)x) { - _exit(1); - } - *x = 0; - delete x; - // CHECK: FreeHook - return 0; -} |