1 //===-- tsan_rtl_proc.cpp -----------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is a part of ThreadSanitizer (TSan), a race detector.
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_common/sanitizer_placement_new.h"
15 #include "tsan_mman.h"
16 #include "tsan_flags.h"
20 Processor
*ProcCreate() {
21 void *mem
= InternalAlloc(sizeof(Processor
));
22 internal_memset(mem
, 0, sizeof(Processor
));
23 Processor
*proc
= new(mem
) Processor
;
26 AllocatorProcStart(proc
);
28 if (common_flags()->detect_deadlocks
)
29 proc
->dd_pt
= ctx
->dd
->CreatePhysicalThread();
33 void ProcDestroy(Processor
*proc
) {
34 CHECK_EQ(proc
->thr
, nullptr);
36 AllocatorProcFinish(proc
);
38 ctx
->metamap
.OnProcIdle(proc
);
39 if (common_flags()->detect_deadlocks
)
40 ctx
->dd
->DestroyPhysicalThread(proc
->dd_pt
);
45 void ProcWire(Processor
*proc
, ThreadState
*thr
) {
46 CHECK_EQ(thr
->proc1
, nullptr);
47 CHECK_EQ(proc
->thr
, nullptr);
52 void ProcUnwire(Processor
*proc
, ThreadState
*thr
) {
53 CHECK_EQ(thr
->proc1
, proc
);
54 CHECK_EQ(proc
->thr
, thr
);