1 //===-- tsan_rtl_proc.cc ------------------------------------------------===//
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->clock_alloc.FlushCache(&proc->clock_cache);
39 ctx->metamap.OnProcIdle(proc);
40 if (common_flags()->detect_deadlocks)
41 ctx->dd->DestroyPhysicalThread(proc->dd_pt);
46 void ProcWire(Processor *proc, ThreadState *thr) {
47 CHECK_EQ(thr->proc1, nullptr);
48 CHECK_EQ(proc->thr, nullptr);
53 void ProcUnwire(Processor *proc, ThreadState *thr) {
54 CHECK_EQ(thr->proc1, proc);
55 CHECK_EQ(proc->thr, thr);