brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · c812ffb Raw
67 lines · c
1//===-- dd_rtl.h ----------------------------------------------------------===//2//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-exception6//7//===----------------------------------------------------------------------===//8#ifndef DD_RTL_H9#define DD_RTL_H10 11#include "sanitizer_common/sanitizer_internal_defs.h"12#include "sanitizer_common/sanitizer_deadlock_detector_interface.h"13#include "sanitizer_common/sanitizer_flags.h"14#include "sanitizer_common/sanitizer_allocator_internal.h"15#include "sanitizer_common/sanitizer_addrhashmap.h"16#include "sanitizer_common/sanitizer_mutex.h"17 18namespace __dsan {19 20typedef DDFlags Flags;21 22struct UserMutex {23  DDMutex dd;24};25 26struct Thread {27  DDPhysicalThread *dd_pt;28  DDLogicalThread *dd_lt;29 30  bool ignore_interceptors;31};32 33struct Callback final : public DDCallback {34  Thread *thr;35 36  Callback(Thread *thr);37  u32 Unwind() override;38};39 40typedef AddrHashMap<UserMutex, 31051> MutexHashMap;41 42struct Context {43  DDetector *dd;44 45  Mutex report_mutex;46  MutexHashMap mutex_map;47};48 49inline Flags* flags() {50  static Flags flags;51  return &flags;52}53 54void Initialize();55void InitializeInterceptors();56 57void ThreadInit(Thread *thr);58void ThreadDestroy(Thread *thr);59 60void MutexBeforeLock(Thread *thr, uptr m, bool writelock);61void MutexAfterLock(Thread *thr, uptr m, bool writelock, bool trylock);62void MutexBeforeUnlock(Thread *thr, uptr m, bool writelock);63void MutexDestroy(Thread *thr, uptr m);64 65}  // namespace __dsan66#endif  // DD_RTL_H67