1 //===-- tsan_rtl_proc.cc ------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file is a part of ThreadSanitizer (TSan), a race detector.
12 //===----------------------------------------------------------------------===//
14 #include "sanitizer_common/sanitizer_placement_new.h"
16 #include "tsan_mman.h"
17 #include "tsan_flags.h"
21 Processor *ProcCreate() {
22 void *mem = InternalAlloc(sizeof(Processor));
23 internal_memset(mem, 0, sizeof(Processor));
24 Processor *proc = new(mem) Processor;
27 AllocatorProcStart(proc);
29 if (common_flags()->detect_deadlocks)
30 proc->dd_pt = ctx->dd->CreatePhysicalThread();
34 void ProcDestroy(Processor *proc) {
35 CHECK_EQ(proc->thr, nullptr);
37 AllocatorProcFinish(proc);
39 ctx->clock_alloc.FlushCache(&proc->clock_cache);
40 ctx->metamap.OnProcIdle(proc);
41 if (common_flags()->detect_deadlocks)
42 ctx->dd->DestroyPhysicalThread(proc->dd_pt);
47 void ProcWire(Processor *proc, ThreadState *thr) {
48 CHECK_EQ(thr->proc1, nullptr);
49 CHECK_EQ(proc->thr, nullptr);
54 void ProcUnwire(Processor *proc, ThreadState *thr) {
55 CHECK_EQ(thr->proc1, proc);
56 CHECK_EQ(proc->thr, thr);