]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/tsan/Linux/user_malloc.cc
New upstream version 1.19.0+dfsg3
[rustc.git] / src / compiler-rt / test / tsan / Linux / user_malloc.cc
CommitLineData
1a4d82fc
JJ
1// RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s
2#include <stdio.h>
3
92a42be0 4// Defined by tsan.
1a4d82fc
JJ
5extern "C" void *__interceptor_malloc(unsigned long size);
6extern "C" void __interceptor_free(void *p);
7
8extern "C" void *malloc(unsigned long size) {
9 static int first = 0;
10 if (__sync_lock_test_and_set(&first, 1) == 0)
5bcae85e 11 fprintf(stderr, "user malloc\n");
1a4d82fc
JJ
12 return __interceptor_malloc(size);
13}
14
15extern "C" void free(void *p) {
16 __interceptor_free(p);
17}
18
19int main() {
20 volatile char *p = (char*)malloc(10);
21 p[0] = 0;
22 free((void*)p);
23}
24
25// CHECK: user malloc
26// CHECK-NOT: ThreadSanitizer
27